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 : 52.14.204.52


Current Path : /proc/thread-self/root/var/www/html/univadmin_bkp/univadmin/src/
Upload File :
Current File : //proc/thread-self/root/var/www/html/univadmin_bkp/univadmin/src/notificationPush.php

<?php

  function pushNotificationData($aobj_context)
  {
    $aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);

    $req = $aobj_context->req_body['data'];
    $univcode = $aobj_context->mobj_data['univcode'];
    $commondb ="logisys3_comexam";

    if (!array_key_exists('fsendto', $req) || !array_key_exists('fevent', $req)
    || !array_key_exists('fmsg', $req) || !array_key_exists('deggrp', $req))
    {
      $arr['msg'] = 'Invalid Params';
      echo $aobj_context->mobj_output->ToJSONEnvelope($arr, -1, "failure");
      return;
    }
    $deggrp = implode("','", $req['deggrp']);
    $result = false;
    if($req['fsendto'] == 'ST') {
        switch($req['fevent']) {
          case 'GEN':
            $fmsg = $req['fmsg'];
            $fcollfrom = $req['fcollfrom'];
            $fcollto = $req['fcollto'];
            $fregfrom = $req['fregfrom'];
            $fregto = $req['fregto'];
            $fdegfrom = $req['fdegfrom'];
            $fdegto = $req['fdegto'];
            $ftitle = $req['ftitle'];
            $timestamp = date("Ymdhis");
            $entype = "ST".$timestamp;

            $query ="INSERT IGNORE INTO {$commondb}.pushnotif(funivcode, fregno, fdegree, fcollcode, fmobileno, 
            fenttype, fsubcode, ftitle, fmobappid, fbody, fstatus, fdeleted, fyear, fexamtype,fpushdate, fmsgtype)
            SELECT DISTINCT '{$univcode}', m.fregno, cd.fdegree, cd.fcollcode, m.fmobileno, '{$entype}', '{$entype}', 
            '{$ftitle}', m.fappmobid,  CONCAT('{$req['fmsg']}') AS fbody, 
            'F', 'F', YEAR(NOW()), '2', NOW(), 'G' 
            FROM {$commondb}.masuser m  inner join candsum cd on  m.funivcode = '{$univcode}' 
            and m.fregno = cd.fregno
            and cd.fregno between '{$fregfrom}' and '{$fregto}'
            and fcollcode between '{$fcollfrom}' and '{$fcollto}'
            and fdegree between '{$fdegfrom}' and '{$fdegto}' 
            and cd.fdegree in (select distinct fdegree from degree where fdeggrp in ('{$deggrp}'))";
            // var_dump($query);
            $result = $aobj_context->pobj_db->Execute($query);
            $req['fevent'] = $entype;
            break;
          case "HT": 
            $fmsg = $req['fmsg'];
            $fcollfrom = $req['fcollfrom'];
            $fcollto = $req['fcollto'];
            $fregfrom = $req['fregfrom'];
            $fregto = $req['fregto'];
            $fdegfrom = $req['fdegfrom'];
            $fdegto = $req['fdegto'];
            $ftitle = $req['ftitle'];
            $timestamp = date("Ymdhis");
            $entype = "HT".$timestamp;

            $query = "INSERT INTO logisys3_comexam.pushnotif (funivcode, fcollcode, fregno, fdegree, fenttype, fsubcode, 
            ftitle, fbody, fstatus, fpushdate, fyear, fexamtype, fmobileno, fmobappid, fmsgtype)
            select distinct '{$univcode}', x.fcollcode, x.fregno, x.fdegree, '{$entype}', '{$entype}', 
            '{$ftitle}', '{$req['fmsg']}' as fmessage, 'F', now(), x.fyear, x.fexamtype, m.fmobileno, m.fappmobid, 'G'
            from candsum x inner join collexam y on x.fdegree = y.fdegree and x.fcollcode = y.fcollcode
            inner join student z on x.fdegree = z.fdegree and x.fregno = z.fregno 
            inner join {$commondb}.masuser m on x.fregno = m.fregno and m.funivcode = '{$univcode}'
            inner join degree w on x.fdegree = w.fdegree and x.fexamno = w.fexamno 
            where ifnull(x.frecptdate,'') <> '' and date_format(now(),'%Y-%m-%d') between y.fhtfrom and y.fhtto
            and ifnull(z.fexamappblk,'') <> 'T' and w.fdeggrp in ('{$deggrp}') and ifnull(z.fmp,'') <> 'T'
            and x.fregno between '{$fregfrom}' and '{$fregto}'
            and x.fcollcode between '{$fcollfrom}' and '{$fcollto}'
            and x.fdegree between '{$fdegfrom}' and '{$fdegto}'";
            $result = $aobj_context->pobj_db->Execute($query);
            $req['fevent'] = $entype;
            break;
          default:
            break;
        }
      
    }
    else if($req['fsendto'] == 'CL') {

      $query = "select funivcode, funivname, fdbname, fstaffmobileno, fgenmsgno
      from {$commondb}.dbname 
      where funivcode = '{$univcode}'";
      $comexamRes = $aobj_context->mobj_db->GetRow($query);
    
      $db = $comexamRes['fdbname'];
      $funivname = $comexamRes['funivname'];
      $stafmobile = $comexamRes['fstaffmobileno'];
      $msgno = $comexamRes['fgenmsgno'];
      $timestamp = date("dmY");
      $entype = "CM".$msgno.$timestamp;

      $message = "[{$msgno}]".$req['fmsg'];
      
    }
    else if($req['fsendto'] == 'CT') {

      $query = "select funivcode, funivname, fdbname, fstaffmobileno, fgenmsgno
      from logisys3_comexam.dbname 
      where funivcode = '{$univcode}'";
      $comexamRes = $aobj_context->mobj_db->GetRow($query);
    
      $db = $comexamRes['fdbname'];
      $funivname = $comexamRes['funivname'];
      $stafmobile = $comexamRes['fstaffmobileno'];
      $msgno = $comexamRes['fgenmsgno'];
      $timestamp = date("dmY");
      $entype = "CM".$msgno.$timestamp;

      $message = "[{$msgno}]".$req['fmsg'];
      
      
    } else if($req['fsendto'] == 'TH') {

      $query = "select funivcode, funivname, fdbname, fstaffmobileno, fgenmsgno
      from logisys3_comexam.dbname 
      where funivcode = '{$univcode}'";
      $comexamRes = $aobj_context->mobj_db->GetRow($query);
    
      $db = $comexamRes['fdbname'];
      $funivname = $comexamRes['funivname'];
      $stafmobile = $comexamRes['fstaffmobileno'];
      $msgno = $comexamRes['fgenmsgno'];
      $timestamp = date("dmY");
      $entype = "TH".$msgno.$timestamp;

      $message = "[{$msgno}]".$req['fmsg'];

      
    }

    if($result)
    {
      $rows = $aobj_context->pobj_db->affected_rows();
      $arr['msg'] = "{$rows} Records Inserted. Press send button.";
      $arr['event'] = $req['fevent'];
      echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success"); 

    }
    else
    {
      $arr['msg'] = 'DATA Push Failed';
      echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure"); 	
    }
  }

  

?>