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.116.27.225
<?php
function photoCropDet($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
if($_SERVER['REQUEST_METHOD'] === 'OPTIONS')
{
return;
}
$univcode = $aobj_context->mobj_data["univcode"];
$collcode = $aobj_context->mobj_data["collcode"];
$folder = $aobj_context->mobj_data["folder"];
$fregno = $aobj_context->mobj_data["fregno"];
$query = "select fregno, fphotopath from student where fcollcode = '{$collcode}'
and fregno = '{$fregno}' limit 1";
$results = $aobj_context->pobj_db->GetRow($query);
$fregno = $results['fregno'];
$query = "update student set fcropstatus = 'S' where fregno = '{$fregno}'";
$result = $aobj_context->pobj_db->Execute($query);
$type = pathinfo($results['fphotopath'], PATHINFO_EXTENSION);
$url = 'https://universitysolutions.in/bcu/'.$results['fphotopath'];
$img = file_get_contents($url);
$img64 = base64_encode($img);
if($results)
{
$data['fregno'] = $fregno;
$data['img64'] = 'data:image/' . $type . ';base64,' .$img64;
echo $aobj_context->mobj_output->ToJSONEnvelope($data,0,"success");
return;
}
else
{
$arr['msg'] = "No Data Found";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"error");
return;
}
}
function saveCropedPhoto($aobj_context)
{
if($_SERVER['REQUEST_METHOD'] === 'OPTIONS')
{
return;
}
$req = $aobj_context->req_body['data'];
$data = $req["img64"];
$fregno = $req["fregno"];
$ffolder = $aobj_context->pdb['ffolder'];
if($data==""|| $fregno == ""){
$arr['msg'] = "Invalid Params";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"error");
return;
}
if (preg_match('/^data:image\/(\w+);base64,/', $data, $type)) {
$data = substr($data, strpos($data, ',') + 1);
$type = strtolower($type[1]); // jpg, png, gif
if (!in_array($type, [ 'jpg', 'jpeg', 'png' ])) {
$arr['msg'] = "Invalid Image formats";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"error");
return;
}
$data = base64_decode($data);
if ($data === false) {
$arr['msg'] = "base64_decode failed";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"error");
return;
}
$dir = dirname(__DIR__, 2);
$folder = $dir . DIRECTORY_SEPARATOR . $ffolder . DIRECTORY_SEPARATOR . 'cropped_photos';
if(!file_exists($folder)){
mkdir($folder);
}
$file = $folder."/$fregno." . $type;
$res = file_put_contents($file, $data);
if($res) {
$path = "cropped_photos/$fregno." . $type;
$query = "update student set fcropstatus = 'C', fcroppath = '{$path}'
where fregno = '{$fregno}'";
$result = $aobj_context->pobj_db->Execute($query);
$arr['msg'] = "File Saved Successfully";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success");
return;
}
else {
$arr['msg'] = "Error While Putting file";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"error");
return;
}
} else {
$arr['msg'] = "did not match data URI with image data";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"error");
return;
}
}
function getCollegeDegrees($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
if($_SERVER['REQUEST_METHOD'] === 'OPTIONS')
{
return;
}
$collcode = $aobj_context->mobj_data["collcode"];
$fdeggrp = $aobj_context->mobj_data["fdeggrp"];
$query = "select distinct s.fdegree, d.fdescpn from student s
inner join degree d on s.fdegree = d.fdegree and d.fexamno = 'A'
where s.fcollcode = '{$collcode}' and d.fdeggrp = '{$fdeggrp}'";
// var_dump($query);
$result = $aobj_context->pobj_db->GetAll($query);
if (!$result && gettype($result) == 'boolean') {
$arr['msg'] = "Error while fetching degrees";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "Failure");
return;
}
if (count($result) > 0) {
echo $aobj_context->mobj_output->ToJSONEnvelope($result, 0, "success");
return;
} else {
$arr['msg'] = 'No Records Found';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
return;
}
}
function getStudentPhotosDegreeWise($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
if($_SERVER['REQUEST_METHOD'] === 'OPTIONS')
{
return;
}
$ffolder = $aobj_context->pdb['ffolder'];
$univcode = $aobj_context->mobj_data["univcode"];
$collcode = $aobj_context->mobj_data["collcode"];
$fdegree = $aobj_context->mobj_data["fdegree"];
$regfrom = $aobj_context->mobj_data["regfrom"];
$regto = $aobj_context->mobj_data["regto"];
$query = "select fregno, fname,
concat('http://universitysolutions.in/{$ffolder}/', fphotopath) as fphotopath
from student where fcollcode = '{$collcode}'
and fdegree = '{$fdegree}' and fregno between '{$regfrom}' and '{$regto}'";
$results = $aobj_context->pobj_db->GetAll($query);
if($results)
{
echo $aobj_context->mobj_output->ToJSONEnvelope($results,0,"success");
return;
}
else
{
$arr['msg'] = "No Data Found";
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"error");
return;
}
}
?>
|