<?php include("parent/callMe.php"); ?>
<?php  include("sessioncheck.php"); ?>
<?php

$sql="SELECT msg_from,msg_details,msg_id FROM edu_messages_details where msg_status='1'";
 //echo $sql;
$data = $m->query($sql);


 foreach(array_chunk($data, 10) as $chunkNumber) {

  //echo "<pre>"; print_r($chunkNumber); echo "</pre>"; 
  
  foreach($chunkNumber as $numb => $value) { 
    $msg_id=$value['msg_id'];
    $numb=$value['msg_from'];
    $sms=$value['msg_details']; 

    if(substr($numb,0,1)=="3"){
    $number1 = "92".$numb;
    }else if(substr($numb,0,1)=="0"){
    $number1 =  "92".substr($numb,1);
    }
    else if(substr($numb,0,2)=="92"){
    $sendmsg1 =  $numb;
    }
    else{
     $number1 = "00";
    }

    $curl = curl_init();

    $url='https://bsms.ufone.com/bsms_v8_api/sendapi-0.3.jsp?id=03348960296&message='.urlencode($sms).'&shortcode=EduPortal&lang=English&mobilenum='.$number1.'&password=Ufone@APi@321&groupname&messagetype=Nontransactional';

      curl_setopt_array($curl, array(
        CURLOPT_URL => $url,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => '',
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => 'GET',
        CURLOPT_HTTPHEADER => array(
          'Cookie: cookiesession1=678B2881QRSTUVXYZABCDEFGHIMN88F6'
        ),
      ));
      $response = curl_exec($curl);
      curl_close($curl);


      $data = array('msg_status' => 0);  
      $m->where("msg_id",$msg_id);
      $m->update('edu_messages_details',$data) ;


        } // ending chunkes loop
    
 } // ending main for loop

?>