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.147.86.30
<?php
require_once(_DIR_."/../../aws/aws-autoloader.php");
use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;
function getregno($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$univcode = $aobj_context->mobj_data['univcode'];
$degree = $aobj_context->mobj_data['deg'];
$collcode = $aobj_context->mobj_data['collcode'];
// var_dump($degree,$collcode,$univcode);
// die();
$query = "SELECT s.fregno AS FREGNO,s.FPHOTOPATH,s.FDEGREE,s.FNAME, c.FUNIVCODE FROM student s, control c
WHERE s.fcollcode = '{$collcode}' AND s.fdegree ='{$degree}' ORDER BY s.fregno";
$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");
}
}
function getstdinfo($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$univcode = $aobj_context->mobj_data['univcode'];
$degree = $aobj_context->mobj_data['deg'];
$collcode = $aobj_context->mobj_data['collcode'];
$regno = $aobj_context->mobj_data['regno'];
// var_dump($degree,$collcode,$univcode,$regno);
// die();
if($regno=='All'){
$cond="AND s.fregno BETWEEN '00000000' AND 'ZZZZZZZZ'";
}
else{
$cond="";
}
$query = "SELECT s.fregno AS FREGNO,s.FPHOTOPATH,s.FDEGREE,s.FNAME, c.FUNIVCODE FROM student s, control c
WHERE s.fcollcode = '{$collcode}' {$cond} AND s.fdegree ='{$degree}' ORDER BY s.fregno";
$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");
}
}
function upload_photo($aobj_context){
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$univcode = $aobj_context->mobj_data['univcode'];
$collcode = $aobj_context->mobj_data['collcode'];
$regno = $aobj_context->mobj_data['regno'];
$degree= $aobj_context->mobj_data['degree'];
$filename = $_FILES["image"]["name"];
$tempname = $_FILES["image"]["tmp_name"];
$path_server = move_uploaded_file($tempname, 'studupload/'. $filename);
if($filename){
$s3 = S3Client::factory(
array(
'credentials' => array(
'key' => IAM_KEY,
'secret' => IAM_SECRET
),
'version' => "latest",
'region' => 'ap-south-1'
)
);
if($filename != '' && $filename != NULL){
$file_path = $aobj_context->main_src."studupload/{$filename}";
$file = $univcode."/"."student_photos/".$collcode."/".$degree."/".$filename;
$filepath = "student_photos/".$collcode."/".$degree."/".$filename;
if(file_exists($file_path)){
try {
$s3->putObject(['Bucket' => "university-student-photos", 'Key' => $file, 'SourceFile' => $file_path]);
$query = "update student set FPHOTOPATH = '{$filepath}'
where fregno = '{$regno}'";
$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;
}
}
}
}
}
?>
|