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


Current Path : /proc/thread-self/root/var/www/html/admission/src/
Upload File :
Current File : //proc/thread-self/root/var/www/html/admission/src/omrqnentry.php

<?php
    require_once("/var/www/html/aws/aws-autoloader.php");
    use Aws\S3\S3Client;
    use Aws\S3\Exception\S3Exception;
    
    function getOmrQpCode($aobj_context){
        $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
        $univcode = $aobj_context->mobj_data["univcode"];

        $query = "select concat(ifnull(fsubname, ''), ' ', '[',ifnull(fqpcode, ''),']')as subname, 
                  ifnull(fqpcode, '')as qpcode from subject where ifnull(fqpcode, '')<>''
                  and ifnull(fsuspend, 'T') <> 'T' and ifnull(fonlineqp, 'F') = 'T'
                  order by fsubname";
        $result=$aobj_context->pobj_db->GetAll($query);
        if ($result) {
            echo $aobj_context->mobj_output->TOJSONEnvelope($result, 0, "success");
        }else{
            $arr['msg']="no qpcode found";
            echo $aobj_context->mobj_output->TOJSONEnvelope($arr, -1, "failed");
        }
    }

    function getOmrYearMode($aobj_context){
        $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
        $univcode = $aobj_context->mobj_data["univcode"];
        $qpcode = $aobj_context->mobj_data["qpcode"];

        $query = "select ifnull(d.fmeyear, '')as fyear, ifnull(d.fmeexamtyp, '')as fexamtype, 
                  ifnull(d.fexamdate, '')as fexamdate, ifnull(s.fvalmax, '')as fvalmax from degree d 
                  inner join subject s on s.fdegree=d.fdegree and s.fexamno=d.fexamno
                  where fqpcode='{$qpcode}'";
        $result=$aobj_context->pobj_db->GetRow($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, "failed");
        }
    }


    function saveOmrQnDet($aobj_context){
        $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
        $univcode = $aobj_context->mobj_data["univcode"];
        $qpcode = $aobj_context->mobj_data["qpcode"];
        $year = $aobj_context->mobj_data["year"];
        $mode = $aobj_context->mobj_data["mode"];
        $examdate = $aobj_context->mobj_data["examdate"];
        $maxmarks = $aobj_context->mobj_data["maxmarks"];
        $maxqn = $aobj_context->mobj_data["maxqn"];
        $eachqn = $aobj_context->mobj_data["eachqn"];


        $query = "insert into mcqqp(fqpcode, fyear, fexamtype, fexamdate, fmaxmarks, fmaxqn, fqnmarks, fcreatedate, fcreateuser)
                  values ('{$qpcode}', '{$year}', '{$mode}', '{$examdate}', '{$maxmarks}', '{$maxqn}', '{$eachqn}', now(), '{$user}')";
        $result=$aobj_context->pobj_db->Execute($query);

        for($i=1; $i<=$maxqn; $i++){
            $query = "insert into mcqqpdet(fqpcode, fyear, fexamtype, fqpno)
                      values('{$qpcode}', '{$year}', '{$mode}', '{$i}')";
            $result=$aobj_context->pobj_db->Execute($query);
        }

        if ($result) {
            $arr['msg']="Updated Successfully";
            echo $aobj_context->mobj_output->TOJSONEnvelope($arr, 0, "success");
        }else{
            $arr['msg']="Failed to update";
            echo $aobj_context->mobj_output->TOJSONEnvelope($arr, -1, "failed");
        }
    }

    function viewOmrMarksEnrtyDet($aobj_context){
        $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
        $univcode = $aobj_context->mobj_data["univcode"];
    
        $query = "select fqpcode, fyear, fexamtype, fexamdate, fmaxmarks, fmaxqn, fqnmarks from mcqqp";
        $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, "failed");
        }
    }

    function getOmrMCQQP($aobj_context){
        $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
        $univcode = $aobj_context->mobj_data["univcode"];
        $qpcode = $aobj_context->mobj_data["qpcode"];
        $year = $aobj_context->mobj_data["year"];
        $mode = $aobj_context->mobj_data["mode"];
        $qnno = $aobj_context->mobj_data["qnno"];
    
        $query = "select fqpcode, fyear, fexamtype, fexamdate, fmaxmarks, fmaxqn, fqnmarks from mcqqp 
                  where fqpcode='{$qpcode}' and fyear='{$year}' and fexamtype='{$mode}'";
        $result=$aobj_context->pobj_db->GetRow($query);

        $query1 = "select fqpno, fmaxmarks, fquestion, fopta, foptb, 
                  foptc, foptd, fkeyans, ifnull(fqnfile, '')as fqnfile, ifnull(foptafile, '')as foptafile, 
                  ifnull(foptbfile, '')as foptbfile, 
                  ifnull(foptcfile, '')as foptcfile, ifnull(foptdfile, '')as foptdfile from mcqqpdet 
                  where fqpcode='{$qpcode}' and fyear='{$year}' and fexamtype='{$mode}'";

                //   var_dump($query1);die();
        $result1=$aobj_context->pobj_db->GetAll($query1);
        
        if ($result) {
            $arr['mcqqp'] = $result;
            $arr['mcqqpdet'] = $result1;
            echo $aobj_context->mobj_output->TOJSONEnvelope($arr, 0, "success");
        }else{
            $arr['msg']="no data found";
            echo $aobj_context->mobj_output->TOJSONEnvelope($arr, -1, "failed");
        }
    }

    function saveOmrQp($aobj_context){
        $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
        $univcode = $aobj_context->mobj_data["univcode"];
        $data = json_decode($aobj_context->mobj_data["data"], true);
        $qpcode = $aobj_context->mobj_data["qpcode"];
        $year = $aobj_context->mobj_data["year"];
        $mode = $aobj_context->mobj_data["mode"];
        $qnno = $aobj_context->mobj_data["qnno"];
    
        $query = "update mcqqpdet set fmaxmarks = '{$data['maxQnMarks']}', fquestion = '{$data['question']}', fopta = '{$data['optionA']}', foptb = '{$data['optionB']}', 
                  foptc = '{$data['optionC']}', foptd = '{$data['optionD']}', fkeyans = '{$data['keyAns']}' where fqpcode = '{$qpcode}'
                  and fyear = '{$year}' and fexamtype = '{$mode}' and fqpno = '{$qnno}'";
        $result=$aobj_context->pobj_db->Execute($query);
        if ($result) {
            $arr['msg']="success";
            echo $aobj_context->mobj_output->TOJSONEnvelope($arr, 0, "success");
        }else{
            $arr['msg']="failure";
            echo $aobj_context->mobj_output->TOJSONEnvelope($arr, -1, "failed");
            return;
        }
    }

    function uploadOmrFileHandlers($aobj_context){
        $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
        $univcode = $aobj_context->mobj_data["univcode"];
        $qpcode = $aobj_context->mobj_data["qpcode"];
        $year = $aobj_context->mobj_data["year"];
        $mode = $aobj_context->mobj_data["mode"];
        $qnno = $aobj_context->mobj_data["qnno"];
        $field = $aobj_context->mobj_data["field"];
        
        $filedata = $_FILES['file']['tmp_name'];
        $ext = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);
        $filename = $qpcode.'_'.$year.'_'.$mode.'_'.$field.'.'.$ext;
        $key = $univcode. '/'. $qpcode. '/'. $year. '/'. $mode .'/'. $filename;

        $s3 = S3Client::factory(
        array(
            'credentials' => array(
                'key' => IAM_KEY,
                'secret' => IAM_SECRET
            ),
            'version' => "latest",
            'region'  => 'ap-south-1'
        ));

        try {
             $s3->putObject(['Bucket' => "omr-files", 'Key' => $key, 'SourceFile' => $filedata]);
            $query = "update mcqqpdet set $field = '{$key}' where fqpcode = '{$qpcode}'
                      and fyear = '{$year}' and fexamtype = '{$mode}' and fqpno = '{$qnno}'";
            $result=$aobj_context->pobj_db->Execute($query);
            if ($result) {
                $arr['msg']=$key;
                echo $aobj_context->mobj_output->TOJSONEnvelope($arr, 0, "success");
            }else{
                $arr['msg']="failure";
                echo $aobj_context->mobj_output->TOJSONEnvelope($arr, -1, "failed");
                return;
            }
        }catch(S3Exception $e) {
            $arr['msg'] = 'failure';
            echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 
            return;
        }

       
    }
?>