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 : 52.14.66.242
<?php
//require_once("/Library/WebServer/Documents/oasis/aws/aws-autoloader.php");
require_once("/var/www/html/aws/aws-autoloader.php");
// require_once("C:/XAMPP/htdocs/aws/aws-autoloader.php");
use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;
function loadQPExamSession($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$univcode = $aobj_context->mobj_data['univcode'];
$examdate = $aobj_context->mobj_data['examdate'];
$query = "select ifnull(q.fsession,'') as fsession,ifnull(r.FDESCPN,'') as fdescpn
from qpupload q
inner join reason r on q.fsession = r.FREASONCD
where q.fexamdate = date_format(STR_TO_DATE('{$examdate}', '%d/%m/%Y'),'%Y-%m-%d') and q.fsession <> ''
group by q.fsession";
// var_dump($query);
// die();
$result = $aobj_context->pobj_db->GetAll($query);
if (count($result) > 0) {
echo $aobj_context->mobj_output->ToJSONEnvelope($result, 0, "success");
} else {
$arr['msg'] = 'Failed to Load';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
}
}
function loadQPExamqpcode($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$univcode = $aobj_context->mobj_data['univcode'];
$examdate = $aobj_context->mobj_data['examdate'];
$session = $aobj_context->mobj_data['session'];
$query = "select ifnull(fqpcode,'') as fqpcode from subject
where fdoe = date_format(STR_TO_DATE('{$examdate}', '%d/%m/%Y'),'%Y-%m-%d')
and fsession = '{$session}'";
$result = $aobj_context->pobj_db->GetAll($query);
if (count($result) > 0) {
echo $aobj_context->mobj_output->ToJSONEnvelope($result, 0, "success");
} else {
$arr['msg'] = 'Failed to Load';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
}
}
function UploadQPDocument($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$univcode = $aobj_context->mobj_data['univcode'];
if ( 0 < $_FILES['file']['error'] ) {
echo 'Error: ' . $_FILES['file']['error'] . '<br>';
}
else {
$x = $_FILES['file'];
$f_file=explode(".",$x["name"]);
$new_filename=$f_file[0].".".$f_file[1];
move_uploaded_file($_FILES['file']['tmp_name'], 'upload/'. $_FILES['file']['name']);
}
if($new_filename){
$arr['err_code'] = 0;
$arr['status'] = 'success';
$arr['qptransmissiondoc']= $new_filename;
$arr['msg'] = 'Updated Successfully...!';
echo json_encode($arr);
return;
}else {
$arr['err_code'] = -1;
$arr['status'] = 'Failure';
$arr['msg'] = 'Failed to Upload';
echo json_encode($arr);
return;
}
}
function saveQPUploadDeatils($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$univcode = $aobj_context->mobj_data['univcode'];
$examdate = $aobj_context->mobj_data['examdate'];
$qpcode = $aobj_context->mobj_data['qpcode'];
$pwd1 = $aobj_context->mobj_data['pwd1'];
$pwd2 = $aobj_context->mobj_data['pwd2'];
$qpfile = $aobj_context->mobj_data['qpfile'];
$session = $aobj_context->mobj_data['session'];
$user = $aobj_context->mobj_data['user'];
$qp = (explode(",",$qpcode));
foreach($qp as $key => $val){
$qpcodestr .= $val."*";
}
if($qpfile){
$s3 = S3Client::factory(
array(
'credentials' => array(
'key' => IAM_KEY,
'secret' => IAM_SECRET
),
'version' => "latest",
'region' => 'ap-south-1'
)
);
if($qpfile != '' && $qpfile != NULL)
{
$file_path = $aobj_context->main_src."upload/{$qpfile}";
$file = $univcode."/".$qpfile;
if(file_exists($file_path))
{
try {
$s3->putObject(['Bucket' => QP_TRAN, 'Key' => $file, 'SourceFile' => $file_path]);
$query = "insert into qpupload (fexamdate,fsession,ffilepath,fupddate,fupduser)
value(date_format(STR_TO_DATE('{$examdate}', '%d/%m/%Y'),'%Y-%m-%d'),'{$session}','{$file}',now(),'{$user}')";
$res=$aobj_context->pobj_db->Execute($query);
unlink($file_path);
}catch(S3Exception $e) {
$arr['msg'] = 'Failed to upload';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
return;
}
}
}
}
if ($res) {
$arr['msg'] = 'Saved Successfully...!';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, 0, "success");
} else {
$arr['msg'] = 'Failed to Load';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
}
}
function viewuplodedqp($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$univcode = $aobj_context->mobj_data['univcode'];
$examdate = $aobj_context->mobj_data['examdate'];
$session = $aobj_context->mobj_data['session'];
$query = "select ifnull(date_format(fexamdate,'%d/%m/%Y'),'') as fexamdate,
ifnull(fsession,'') as fsession,
ifnull(fqpcode,'') as fqpcode,
ifnull(ffilepath,'') as ffilepath,
ifnull(fpwd1,'') as fpwd1,
ifnull(fpwd2,'') as fpwd2,
ifnull(date_format(fupddate,'%d/%m/%Y'),'') as fupddate,
ifnull(fupduser,'') as fupduser from qpupload
where fexamdate = date_format(STR_TO_DATE('{$examdate}', '%d/%m/%Y'),'%Y-%m-%d')
and fsession ='{$session}'";
$result = $aobj_context->pobj_db->GetAll($query);
if ($result) {
echo $aobj_context->mobj_output->ToJSONEnvelope($result, 0, "success");
} else {
$arr['msg'] = 'No data Found..!';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
}
}
?>
|