0xV3NOMx
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.145.97.1


Current Path : /var/www/oasis/src/
Upload File :
Current File : /var/www/oasis/src/studnamecorr.php

<?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 fetchtab($aobj_context){
        $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);

        $regno=$aobj_context->mobj_data["regno"];
        $query="SELECT col.fcollname, col.fcollcode, stud.fname, stud.fdegree FROM student stud 
        INNER JOIN college col ON stud.fcollcode = col.fcollcode
        inner join degree deg on stud.fdegree = deg.fdegree WHERE stud.fregno ='$regno' and stud.fayear = deg.fadyear";
        // var_dump($query);
        // die();
        $lobj_get_data = $aobj_context->mobj_db->GetRow($query);
        if($lobj_get_data)
        {	
            // $arr['msg']="saved";
            echo $aobj_context->mobj_output->ToJSONEnvelope($lobj_get_data,0,"success"); 
            return;
        }
        else
        {
            $arr['msg'] = "failed..!";
            $data="not found";
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
            return;
        }
    }

function savestudname($aobj_context){
    
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
    $db = $aobj_context->mobj_data["db"];
    $regno=$aobj_context->mobj_data["regno"];
    $oldname=$aobj_context->mobj_data["oldname"];
    $degree=$aobj_context->mobj_data["degree"];
    $newname=$aobj_context->mobj_data["newname"];
    $doccument=$aobj_context->mobj_data["doccument"];
    $fcollcode = $aobj_context->mobj_data["fcollcode"];
    $name_doc=$regno.'_'.$doccument;
    

    $query5="select fregno from studnamecurr where fregno='$regno'";
    $fetch=$aobj_context->mobj_db->GetRow($query5);
    
    if($doccument){
        $s3 = S3Client::factory(
            array(
                'credentials' => array(
                    'key' => IAM_KEY,
                    'secret' => IAM_SECRET
                ),
                'version' => "latest",
                'region'  => 'ap-south-1'
            )
        );
        
        $query = "select funivcode from control";
        $results = $aobj_context->mobj_db->GetRow($query);

        $funivcode = $results['funivcode'];
        
        if($name_doc != '' && $name_doc != NULL)
        {
            $image_path = $aobj_context->main_src."$db/stud_name_uploads/{$doccument}";

    //         var_dump($image_path);
    // die();
            // $ext = pathinfo($photo_filename, PATHINFO_EXTENSION);
           
            
            $tphoto = $funivcode."/changename_doc/".$name_doc;
            
            if(file_exists($image_path)) 
            {
                try {
                    $s3->putObject(['Bucket' => ADMISSION_CERTIFICATES, 'Key' => $tphoto, 'SourceFile' => $image_path]);
      
                    unlink($image_path);
                }catch(S3Exception $e) {
                    $arr['message'] = 'Unable to upload file';
                    echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
                    return;
                }
            }
        }
    }

  

    if($fetch['fregno']==""){
        $query1 = "insert into studnamecurr (fregno, foldname, fnewname, fdoc, fdegree, fcollcode, fcreateddate, fstatus)
        values ('$regno', '$oldname', '$newname', '{$tphoto}', 
        '$degree', '$fcollcode', now(), 'pending')";
        $lobj_get_data = $aobj_context->mobj_db->Execute($query1);   
    }
    else{
        $query2 = "update studnamecurr set fnewname = '$newname', fdoc= '$tphoto', fcreateddate=now(), fstatus = 'pending' where fregno='$regno'";
        $lobj_get_data = $aobj_context->mobj_db->Execute($query2);
    }
   
    if($lobj_get_data){
        $arr['msg']="Saved..";
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
        return;
    }else{
        $arr['msg']="not found";
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
        return;
    }

}

function uploaddoc($aobj_context){
    $db = $aobj_context->mobj_data["db"];

    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'], "$db/stud_name_uploads/". $_FILES['file']['name']);
        
    }

    if($new_filename){
        $arr['err_code'] = 0;
        $arr['status'] = 'success';
        $arr['studupload']=$new_filename;
        $arr['msg'] = 'Updated Successfully...!';
        echo json_encode($arr);
        return;
    }else {
        $arr['err_code'] = -1;
        $arr['status'] = 'Failure';
        $arr['msg'] = 'Failed To update';
        echo json_encode($arr); 
        return;
    }
}

function loadstudnamecurr($aobj_context){
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
    $query = "SELECT IFNULL(fapp, '') AS fapp, 
                     IFNULL(fregno, '')AS fregno,
                     IFNULL(foldname, '')AS foldname, 
                     IFNULL(fnewname, '') AS fnewname,
                     IFNULL(fdegree, '') AS fdegree,  
                     IFNULL(fstatus, '') AS fstatus FROM studnamecurr where fcollcode='{$_SESSION['collcode']}'";
    $lobj_get_data = $aobj_context->mobj_db->GetAll($query);
    
    if($lobj_get_data)
        {	
            echo $aobj_context->mobj_output->ToJSONEnvelope($lobj_get_data,0,"success"); 
            return;
        }
        else
        {
            $data="not found";
            echo $aobj_context->mobj_output->ToJSONEnvelope($data,-1,"failure"); 
            return;
        }          
}

function editDetails($aobj_context){
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
    $regno=$aobj_context->mobj_data["regno"];

    $query = "SELECT IFNULL(fapp, '') AS fapp, 
                     IFNULL(fregno, '')AS fregno,
                     IFNULL(foldname, '')AS foldname, 
                     IFNULL(fnewname, '') AS fnewname, 
                     IFNULL(fdegree, '') AS fdegree FROM studnamecurr where fregno = '$regno'";
    $lobj_get_data = $aobj_context->mobj_db->GetRow($query);

    if($lobj_get_data)
        {	
            echo $aobj_context->mobj_output->ToJSONEnvelope($lobj_get_data,0,"success"); 
            return;
        }
        else
        {
            $data="not found";
            echo $aobj_context->mobj_output->ToJSONEnvelope($data,-1,"failure"); 
            return;
        }          
}

?>