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 : 13.58.191.60
<?php
require_once(_DIR_."/../../aws/aws-autoloader.php");
use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;
function getQpUploadDetails($aobj_context){
$teachcode = $aobj_context->mobj_data["userid"];
$fstatus = $aobj_context->mobj_data["fstatus"];
$query = "select ifnull(fnote,'') as fnote,
ifnull(faccno, '')as faccno,
ifnull(fifsccode, '')as fifsccode,
ifnull(fbankname, '')as fbankname
from masteach
where fteachcode = '{$teachcode}'";
$res = $aobj_context->mobj_db->GetRow($query);
if($res['faccno'] == "" || $res['fifsccode'] == "" || $res['fbankname'] == ""){
$arr['msg'] = "Update bank details";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -2, "failure");
return;
}
if($fstatus == "Pending"){
$cond = "and ifnull(qp.fqpdtme,'') = ''";
}else if($fstatus == "Uploaded"){
$cond = "and ifnull(qp.fqpdtme,'') <> ''";
}
$query1 = "select qp.fqpcode, s.fsubname, s.fvalmax, qp.fset, concat(qp.fyear,'-', qp.fexamtype)as fexam,
ifnull(qp.fqpfilepath, '')as fqpfilepath, ifnull(qp.fanskeypath, '')as fanskeypath, s.FQPPATREN, s.FQPSYLLABUS, s.FSUBSHORT, s.FSHORTNAME,
ifnull(qp.fqpdtme,'') as qpupd, DATE_FORMAT(q.flastdate,'%d/%m/%Y') as flastdate, ifnull(fremfile, '')as fremfile,
qp.ftype,
CASE
WHEN q.flastdate < CURRENT_DATE() THEN 'T'
ELSE 'F'
END AS flastdate_status
from qpseterdet qp inner join subject s on qp.fqpcode = s.fqpcode
inner join degree d on s.fdegree = d.fdegree and d.fexamno = s.fexamno
inner join qpseter q on qp.fqpcode = q.fqpcode
and qp.fteachcode = q.fteachcode and qp.fyear = q.fyear
and qp.fexamtype = q.fexamtype
and q.fappointed = 'T'
where qp.fteachcode = '{$teachcode}'
and qp.fstatus = 'ACCEPTED'
$cond
and ifnull(qp.fpretype,'upload') = 'upload'
group by qp.fyear, qp.fexamtype, qp.fqpcode, qp.fteachcode, qp.fset, qp.ftype";
$result = $aobj_context->mobj_db->GetAll($query1);
if(count($result) > 0){
$arr['result'] = $result;
$arr['fnote'] = $res;
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
} else {
$arr['msg'] = 'No data Found';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
}
}
function uploadQuestionPaper($aobj_context){
include("error_log.php");
$univcode = $aobj_context->mobj_data["univcode"];
$userid = $aobj_context->mobj_data["userid"];
$qpcode = $aobj_context->mobj_data["qpcode"];
$sets = $aobj_context->mobj_data["set"];
$fexam = $aobj_context->mobj_data["yearmode"];
$collcode = $aobj_context->mobj_data["collcode"];
$mobile = $aobj_context->mobj_data["mobileno"];
$type = $aobj_context->mobj_data["type"];
$ansstatus = $aobj_context->mobj_data["ansstatus"];
$qpstatus = $aobj_context->mobj_data["qpstatus"];
$remstatus = $aobj_context->mobj_data["remstatus"];
$anskeyfile = $_FILES['anskeyfile']['name'];
$anskeytemp = $_FILES['anskeyfile']['tmp_name'];
$qpfile = $_FILES['qpfile']['name'];
$qptemp = $_FILES['qpfile']['tmp_name'];
$remfile = $_FILES['remfile']['name'];
$remtemp = $_FILES['remfile']['tmp_name'];
$splitExam = explode("-", $fexam);
$fyear = $splitExam[0];
$fexamtype = $splitExam[1];
$length = 30;
$characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
try {
$query = "select count(*) as cnt from qpseter where fteachcode ='{$userid}'
and fqpcode = '{$qpcode}' and fyear = '{$fyear}' and fexamtype = '{$fexamtype}'
and date_format(flastdate, '%Y-%m-%d') >= date_format(now(), '%Y-%m-%d')";
$res = $aobj_context->mobj_db->GetRow($query);
$cnt = $res['cnt'];
if($univcode == '030'){
if($cnt >0){
} else {
$arr['msg'] = 'Last Date is over to upload qp file contact admin';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
return;
}
if($ansstatus !== 'Yes'){
$arr['msg'] = 'Answer key file is mandatory';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
if($qpstatus !== 'Yes'){
$arr['msg'] = 'QP file is mandatory';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
$s3 = S3Client::factory(
array(
'credentials' => array(
'key' => IAM_KEY,
'secret' => IAM_SECRET
),
'version' => "latest",
'region' => 'ap-south-1'
));
if($ansstatus === "Yes"){
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, strlen($characters) - 1)];
}
$ext = pathinfo($anskeyfile, PATHINFO_EXTENSION);
$file_name = $userid."_".$qpcode."_ans_".$randomString.".".$ext;
$key = "QP_Details/".$univcode."/".$fexam."/".$qpcode."/".$file_name;
$s3->putObject(['Bucket' => "qp-upd", 'Key' => $key, 'SourceFile' => $anskeytemp]);
$query1 = " update qpseterdet set ffilename='{$file_name}', fqpduser = '{$userid}',
fqpdtme = now(),
fuploadstatus = 'T', fanskeypath = '{$key}'
where fteachcode = '{$userid}'
and fqpcode = '{$qpcode}'
and fset = '{$sets}'
and fyear = '{$fyear}'
and fexamtype = '{$fexamtype}'
and ftype = '{$type}'";
$result1 = $aobj_context->mobj_db->Execute($query1);
$remarks = "Upload Question Paper - uploaded Question Paper file against ".$qpcode;
$res = error_logs($aobj_context, $univcode, $remarks, $collcode, "Upload Question Paper Details - Upload Question Paper", $userid, $mobile);
}
if($qpstatus === "Yes"){
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, strlen($characters) - 1)];
}
$ext = pathinfo($qpfile, PATHINFO_EXTENSION);
$file_name = $userid."_".$qpcode."_qp_".$sets."_".$randomString.".".$ext;
$key = "QP_Details/".$univcode."/".$fexam."/".$qpcode."/".$file_name;
$s3->putObject(['Bucket' => "qp-upd", 'Key' => $key, 'SourceFile' => $qptemp]);
$query1 = " update qpseterdet set ffilename='{$file_name}', fqpduser = '{$userid}',
fqpdtme = now(),
fuploadstatus = 'T', fqpfilepath = '{$key}'
where fteachcode = '{$userid}'
and fqpcode = '{$qpcode}'
and fset = '{$sets}'
and fyear = '{$fyear}'
and fexamtype = '{$fexamtype}'
and ftype = '{$type}'";
$result1 = $aobj_context->mobj_db->Execute($query1);
$remarks = "Upload Question Paper - uploaded Question Paper file against ".$qpcode;
$res = error_logs($aobj_context, $univcode, $remarks, $collcode, "Upload Question Paper Details - Upload Question Paper", $userid, $mobile);
}
if($remstatus === "Yes"){
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, strlen($characters) - 1)];
}
$ext = pathinfo($qpfile, PATHINFO_EXTENSION);
$file_name = $userid."_".$qpcode."_rem_".$sets."_".$randomString.".".$ext;
$key = "QP_Details/".$univcode."/".$fexam."/".$qpcode."/".$file_name;
$s3->putObject(['Bucket' => "qp-upd", 'Key' => $key, 'SourceFile' => $remtemp]);
$query1 = " update qpseterdet set fqpduser = '{$userid}',
fremupdate = now(),
fuploadstatus = 'T', fremfile = '{$key}'
where fteachcode = '{$userid}'
and fqpcode = '{$qpcode}'
and fset = '{$sets}'
and fyear = '{$fyear}'
and fexamtype = '{$fexamtype}'
and ftype = '{$type}'";
$result1 = $aobj_context->mobj_db->Execute($query1);
$remarks = "Upload Question Paper - uploaded Question Paper file against ".$qpcode;
$res = error_logs($aobj_context, $univcode, $remarks, $collcode, "Upload Question Paper Details - Upload Question Paper", $userid, $mobile);
}
if($result1){
$arr['msg'] = 'Successfully uploaded';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
} else {
$arr['msg'] = 'Failed to upload files';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
} catch (S3Exception $e) {
$arr['msg'] = 'Failed to upload';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
?>
|