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.143.239.63


Current Path : /proc/thread-self/root/var/www/oasis/src/
Upload File :
Current File : //proc/thread-self/root/var/www/oasis/src/uploadteacherattendance.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 loadteachattendance($aobj_context)
{
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
	$collegecode = $_SESSION['collcode'];

    $query = "select ifnull(FTEACHLIST,'') as fteachlist,ifnull(FTEACHATTEND,'') as fteachattend,
    ifnull(date_format(ifnull(FLISTDATE, ''),'%d/%m/%Y'),'') as flistdate, 
    ifnull(date_format(ifnull(FATTENDDATE, ''),'%d/%m/%Y'),'') as fattenddate
    from college where fcollcode = '{$collegecode}'";



    $results = $aobj_context->mobj_db->GetRow($query);

    
    if($results){
        echo $aobj_context->mobj_output->ToJSONEnvelope($results,0,"success"); 
    }else{
        $arr['msg'] = 'Filed to Load...!';
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure");   
    }

	
}


function teachlist_AWS($aobj_context)
{
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
	$collegecode = $_SESSION['collcode'];
    $file = $aobj_context->mobj_data["file"];


    if($file){
        $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($file != '' && $file != NULL)
        {
            $file_path = $aobj_context->main_src."upload/{$file}";

            
            $ext = pathinfo($photo_filename, PATHINFO_EXTENSION);
            $photo_filename = $fappno;
            
            $filename = $funivcode."_".$collegecode."_".$file;
            $tphoto = $funivcode."/".$collegecode."/teacher_attendance/".$filename;
            
            // var_dump($image_path);
            // die();
            // var_dump($photo);
            if(file_exists($file_path)) 
            {
                try {
                    $s3->putObject(['Bucket' => teachattendance, 'Key' => $tphoto, 'SourceFile' => $file_path]);
                        $update="  update college set fteachlist = '{$tphoto}',flistdate = now()
                        where fcollcode = '{$collegecode}'";
                    $up_obj=$aobj_context->mobj_db->Execute($update); 
                    unlink($file_path);
                }catch(S3Exception $e) {
                    $arr['msg'] = 'Unable to upload file';
                    echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
                    return;
                }
            }
        }
    }



    
    if($up_obj){
        $arr['msg'] = "Uploaded Successfully....!";
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
    }else{
        $arr['msg'] = 'Filed to upload...!';
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure");   
    }

	
}


function teachattend_AWS($aobj_context)
{
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
	$collegecode = $_SESSION['collcode'];
    $file = $aobj_context->mobj_data["file"];


    if($file){
        $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($file != '' && $file != NULL)
        {
            $file_path = $aobj_context->main_src."upload/{$file}";

            
            $ext = pathinfo($photo_filename, PATHINFO_EXTENSION);
            $photo_filename = $fappno;
            
            $filename = $funivcode."_".$collegecode."_".$file;
            $tphoto = $funivcode."/".$collegecode."/teacher_attendance/".$filename;
            if(file_exists($file_path)) 
            {
                try {
                    $s3->putObject(['Bucket' => teachattendance, 'Key' => $tphoto, 'SourceFile' => $file_path]);
                        $update="  update college set FTEACHATTEND = '{$tphoto}',FATTENDDATE = now()
                        where fcollcode = '{$collegecode}'";
                        
                    $up_obj=$aobj_context->mobj_db->Execute($update); 
                    unlink($file_path);
                }catch(S3Exception $e) {
                    $arr['msg'] = 'Unable to upload file';
                    echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
                    return;
                }
            }
        }
    }



    
    if($up_obj){
        $arr['msg'] = "Uploaded Successfully....!";
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 
    }else{
        $arr['msg'] = 'Filed to upload...!';
        echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"Failure");   
    }

	
}