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 : 3.15.186.27
<?php
require_once(_DIR_."/../../aws/aws-autoloader.php");
use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;
function tdvsuploadqp($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$univcode = $aobj_context->mobj_data["univcode"];
$qpcode = $aobj_context->mobj_data["qpcode"];
$deggrp = $aobj_context->mobj_data["deggrp"];
$sem = $aobj_context->mobj_data["sem"];
$filename = $_FILES['file']['name'];
$tmp_name = $_FILES['file']['tmp_name'];
if($filename !== '' && $filename !== NULL){
$server_path = move_uploaded_file($tmp_name, 'uploadqpscheme/'. $filename);
$file_path = $aobj_context->main_src."uploadqpscheme/{$filename}";
if(file_exists($file_path)){
$s3 = S3Client::factory(
array(
'credentials' => array(
'key' => IAM_KEY,
'secret' => IAM_SECRET
),
'version' => "latest",
'region' => 'ap-south-1'
));
$yearmode = "select concat(FYEAR, '-' ,FEXAMTYPE)as YearAndMode from tdvs_deggrp where fdeggrp = '{$deggrp}';";
$yearmoderesult = $aobj_context->pobj_db->GetRow($yearmode);
if($yearmoderesult){
$key = $univcode."/".$yearmoderesult['YearAndMode']."/".$deggrp."/"."qp/".$deggrp."/".$filename;
try {
$s3->putObject(['Bucket' => "answer-booklets", 'Key' => $key, 'SourceFile' => $file_path]);
$query = "update tdvs_masqp set fqppath = '{$key}'
where fdeggrp = '{$deggrp}' and fqpcode = '{$qpcode}'";
$result = $aobj_context->pobj_db->Execute($query);
if($result){
unlink($file_path);
$arr['msg'] = 'File uploaded';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"Success");
return;
}else{
$arr['msg'] = 'Failed to upload';
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;
}
}
}
}
}
function tdvsuploadscheme($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$univcode = $aobj_context->mobj_data["univcode"];
$qpcode = $aobj_context->mobj_data["qpcode"];
$deggrp = $aobj_context->mobj_data["deggrp"];
$sem = $aobj_context->mobj_data["sem"];
$filename = $_FILES['file']['name'];
$tmp_name = $_FILES['file']['tmp_name'];
if($filename !== '' && $filename !== NULL){
$server_path = move_uploaded_file($tmp_name, 'uploadqpscheme/'. $filename);
$file_path = $aobj_context->main_src."uploadqpscheme/{$filename}";
if(file_exists($file_path)){
$s3 = S3Client::factory(
array(
'credentials' => array(
'key' => IAM_KEY,
'secret' => IAM_SECRET
),
'version' => "latest",
'region' => 'ap-south-1'
));
$yearmode = "select concat(FYEAR,'-', FEXAMTYPE)as YearAndMode from tdvs_deggrp where fdeggrp = '{$deggrp}';";
$yearmoderesult = $aobj_context->pobj_db->GetRow($yearmode);
if($yearmoderesult){
$key = $univcode."/".$yearmoderesult['YearAndMode']."/".$deggrp."/"."scheme/".$deggrp."/".$filename;
try {
$s3->putObject(['Bucket' => "answer-booklets", 'Key' => $key, 'SourceFile' => $file_path]);
$query = "update tdvs_masqp set fschempath = '{$key}'
where fdeggrp = '{$deggrp}' and fqpcode = '{$qpcode}'";
$result = $aobj_context->pobj_db->Execute($query);
if($result){
unlink($file_path);
$arr['msg'] = 'File uploaded';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"Success");
return;
}else{
$arr['msg'] = 'Failed to upload';
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;
}
}
}
}
}
function getTdvsSubjects($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$univcode = $aobj_context->mobj_data["univcode"];
$query = "insert ignore into tdvs_masqp
(fqpcode, fexamno, fsubname, fsmaxmarks, fdoe, fboard, fdeggrp)
select distinct fqpcode, s.fexamno, fsubname, fvalmax, fdoe, fboard,
d.fdeggrp from subject s inner join degree d on
d.fdegree = s.fdegree and d.fexamno = s.fexamno where fqpcode <> ''";
$result = $aobj_context->pobj_db->Execute($query);
$query = "update subject s, tdvs_masqp q set q.fsubname = s.fsubname, q.fsmaxmarks = s.fvalmax
where s.fqpcode = q.fqpcode";
$result1 = $aobj_context->pobj_db->Execute($query);
if($result){
$arr['msg'] = 'Success';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success");
return;
}else{
$arr['msg'] = 'Something Went Wrong';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
return;
}
}
?>
|