Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64
Your IP : 18.118.144.50
<?php
require_once("/var/www/html/aws/aws-autoloader.php");
use Aws\S3\S3Client;
function saveStudyMaterial($aobj_context)
{
$dept = stripslashes($aobj_context->mobj_data["dept"]);
$tech = stripslashes($aobj_context->mobj_data["tech"]);
$fdegree = stripslashes($aobj_context->mobj_data["fdegree"]);
$sem = stripslashes($aobj_context->mobj_data["sem"]);
$subject = stripslashes($aobj_context->mobj_data["subject"]);
$lesson = stripslashes($aobj_context->mobj_data["lesson"]);
$path = stripslashes($aobj_context->mobj_data["path"]);
$src_path=$aobj_context->main_src."/study_material/".$path;
$college = $_SESSION['collcode'];
$univcode = $_SESSION['FUNIVCODE'];
if($college == '')
{
$data = 'Session Expired Login again and enter';
echo $aobj_context->mobj_output->ToJSONEnvelope($data,-1,"failure");
return;
}
$s3 = S3Client::factory(
array(
'credentials' => array(
'key' => IAM_KEY,
'secret' => IAM_SECRET
),
'version' => "latest",
'region' => 'ap-south-1'
)
);
$FUNIVCODE=$_SESSION['FUNIVCODE'];
$path_s3 = $FUNIVCODE."/".$path;
$test = $s3->putObject(['Bucket' => STUDY_MATERIAL, 'Key' => $path_s3, 'SourceFile' => $src_path]);
$query = "insert into osmmain(fcollcode,FDEGREE,FEXAMNO,FSUBCODE,FCHAPTER,FPATH,FCREATEDATE,FUPDDEPT,FUPDTEACH,FAPPRSTATUS,FAPPRDATE)
values('{$college}','{$fdegree}','{$sem}','{$subject}','{$lesson}','{$path}',now(),'{$dept}','{$tech}','approved',now())";
$studresults = $aobj_context->mobj_db->Execute($query);
$ID = $aobj_context->mobj_db->insert_Id();;
if($studresults)
{
unlink($src_path);
$query = "select distinct d.fdescpn,s.fsubname,d.fexamname from degree d
inner join subject s on d.fdegree = s.fdegree
and d.fexamno = s.fexamno
where d.fdegree ='{$fdegree}' and d.fexamno = '{$sem}' and s.fsubcode = '{$subject}'";
$res_sub = $aobj_context->mobj_db->GetRow($query);
$degree_name = $res_sub['fdescpn'];
$sub_name = $res_sub['fsubname'];
$exam_name = $res_sub['fexamname'];
$query = "insert ignore into logisys3_comexam.pushnotif(funivcode,fmobileno,fmobappid, fcollcode, fregno, fdegree, fenttype, fsubcode, ftitle, fbody, fstatus, fyear, fexamtype, fpushdate)
select distinct '{$univcode}',m.fmobileno,m.FAPPMOBID,s.fcollcode, m.fregno, s.fdegree, '{$ID}', '{$ID}',
'Online Study Material Upload' as ftitle,
concat('Dear Student, Study Material Upload for the Degree : ','$degree_name','; Semester : ', '$exam_name','; Subject : ','$sub_name','; chapter / lesson : ','$lesson','. visit Student Portal for more details') AS fmessage,
'F', '2020', '1',NOW()
FROM student s
INNER JOIN logisys3_comexam.masuser m ON s.fregno = m.fregno
AND m.funivcode = '{$univcode}' and ifnull(fappmobid,'') <> ''
where s.fcollcode = '{$college}' and s.fdegree = '{$fdegree}'";
$res = $aobj_context->mobj_db->Execute($query);
$data = "Uploaded Successfully";
echo $aobj_context->mobj_output->ToJSONEnvelope($data,0,"success");
return;
}
else
{
$data = "Upload failure. Please try after some time!";
echo $aobj_context->mobj_output->ToJSONEnvelope($data,-1,"failure");
return;
}
}
function getcolldeg($aobj_context)
{
$college = $_SESSION['collcode'];
// $select_qry = "select distinct d.fdegree, concat(d.fdegree,' - ',d.fdescpn) as fdescpn
// FROM degree d inner join student s on d.fdegree = s.fdegree
// where ifnull(d.fcurrexam,'') = 'T'
// and s.fcollcode = '{$college}'
// order by fdescpn";
$select_qry = "select distinct d.fexamno, concat(d.fexamno,' - ',d.fexamname) as fexamname
FROM degree d
where ifnull(d.fcurrexam,'') = 'T'
group by d.fexamno
order by d.fexamno";
$cntrresults = $aobj_context->mobj_db->GetAll($select_qry);
echo $aobj_context->mobj_output->ToJSONEnvelope($cntrresults,0,"success");
return;
}
function getcolldegexam($aobj_context)
{
$college = $_SESSION['collcode'];
$sem = stripslashes($aobj_context->mobj_data["sem"]);
// $select_qry = "select distinct d.fexamno, concat(d.fexamno,' - ',d.fexamname) as fexamname
// FROM degree d
// where ifnull(d.fcurrexam,'') = 'T'
// and d.fdegree = '{$degree}'
// order by d.fexamno";
$select_qry = "select distinct d.fdegree, concat(d.fdegree,' - ',d.fdescpn) as fdescpn
FROM degree d inner join student s on d.fdegree = s.fdegree
where ifnull(d.fcurrexam,'') = 'T'
and s.fcollcode = '{$college}'
and d.fexamno = '{$sem}'
order by fdescpn";
$cntrresults = $aobj_context->mobj_db->GetAll($select_qry);
echo $aobj_context->mobj_output->ToJSONEnvelope($cntrresults,0,"success");
return;
}
function getSubject($aobj_context)
{
$college = $_SESSION['collcode'];
$degree = stripslashes($aobj_context->mobj_data["degree"]);
$sem = stripslashes($aobj_context->mobj_data["sem"]);
$cnd = "and fexamno = '{$sem}'";
if($sem == 'All')
$cnd = "";
$select_qry = "select distinct s.fsubcode, s.fsubname FROM subject s
where fintass = 'F' and fdegree = '{$degree}'
{$cnd}";
$cntrresults = $aobj_context->mobj_db->GetAll($select_qry);
echo $aobj_context->mobj_output->ToJSONEnvelope($cntrresults,0,"success");
return;
}
function upload_file($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
session_start();
$collcode = $_SESSION['collcode'];
$user_id = $_SESSION['user_id'];
$date = date("dmYhis");
$file_name = replaceChars(basename($_FILES['studymatrial']['name']));
$path_arr = pathinfo($_FILES['studymatrial']['name']);
$file_ext = $path_arr['extension'];
$temp_path = $aobj_context->main_src . "/study_material/";
if (!file_exists($temp_path)) {
mkdir($temp_path);
}
$file_path = "{$collcode}_{$date}_{$file_name}";
$temp_path .= $file_path;
if (isset($_FILES['studymatrial']['name']) && $_FILES['studymatrial']['name'] != '') {
//$size = ($_FILES['studymatrial']['size'] / 1024);
// if ($size > 1024) {
// $data = "Please Upload the Photo of size less than 1 MB";
// echo $aobj_context->mobj_output->ToJSONEnvelope($data, -2, "success");
// return;
// }
if (move_uploaded_file($_FILES['studymatrial']['tmp_name'], $temp_path)) {
$data = "$file_path";
echo $aobj_context->mobj_output->ToJSONEnvelope($data, 0, "success");
return;
}
}
echo $aobj_context->mobj_output->ToJSONEnvelope($data, -1, "failure");
return;
}
function replaceChars($name)
{
$spl_char = array("*", "/", "~", "!", "@", "#", "$", "%", "^", "&", ":", ";", "?", "/", "\\", "_", "-", "'", " ", "");
$link_name = strtolower(str_replace($spl_char, "_", $name));
return str_ireplace("__", "_", $link_name);
}
?>
|