Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- date_default_timezone_set('Asia/Manila');
- include ('../../core/main.class.php');
- $a = new Application();
- $day = $a->schedStatus('day');
- $resend = $a->resendStatus();
- $serverday = date("l");
- $timestart = strtotime($a->schedStatus('timestart'). 'Asia/Manila' );
- $timestop = strtotime($a->schedStatus('timestop'). 'Asia/Manila' );
- $status = intval($a->schedStatus('status'));
- $res = '';
- $message3 = PDODatabase::Instance()->QueryAll("select * from temp_message where prov=1 and priority = 2 order by id desc limit 2");
- $messages = PDODatabase::Instance()->QueryAll("select * from temp_message where prov=1 and priority = 1 order by id desc limit 2");
- $messages1 = PDODatabase::Instance()->QueryAll("select * from message where over=0");
- //check if scheduled setting is enabled
- if(count($messages) > 0 && (count($message3) ==0 || count($message3) > 0)){
- echo "Priority 1 Success \n";
- foreach ($messages as $msg){
- $time = $msg['crontime'];
- $userid = $msg['userid'];
- $message = $msg['msg'];
- $mobile = $msg['tel'];
- $prov = $msg['prov'];
- $agent = $msg['agent'];
- $groupe = $msg['groupe'];
- $telecom = $msg['telecom'];
- $location = $msg['area'];
- $agent = $msg['_OWNER'];
- $uid = $msg['uid'];
- $id = $msg['id'];
- $rcount = $msg['rcount'];
- $priority = $msg['priority'];
- $params = array(
- ':timestamp'=>$time,
- ':userid'=>$userid,
- ':message'=>$message,
- ':mobile'=>$mobile,
- ':prov'=>$prov,
- ':agent'=>$agent,
- ':user_group'=>$groupe,
- ':telecom'=>$telecom,
- ':location'=>$location,
- ':owner'=>$agent,
- ':uid'=>$uid,
- ':priority'=>$priority
- );
- if( $serverday == "Monday" && $day == "MON" || $serverday == "Tuesday" && $day == "TUE" || $serverday == "Wednesday" && $day == "WED" || $serverday == "Thursday" && $day == "THU" || $serverday == "Friday" && $day == "FRI" || $serverday == "Saturday" && $day == "SAT" || $serverday == "Sunday" && $day == "SUN" || ($serverday == "Monday" || $serverday == "Wednesday" || $serverday == "Friday") && $day == "MWF" || ($serverday == "Monday" || $serverday == "Tuesday" || $serverday == "Wednesday" || $serverday == "Thursday" || $serverday == "Friday") && $day == "WD" || ($serverday == "Saturday" || $serverday == "Sunday") && $day == "WE" || ($serverday == "Monday" || $serverday == "Tuesday" || $serverday == "Wednesday" || $serverday == "Thursday" || $serverday == "Friday" || $serverday == "Saturday" || $serverday == "Sunday") && $day == "All" || ($serverday == "Tuesday" || $serverday == "Thursday") && $day == "TTH" )
- {
- echo "Day Success \n";
- //check scheduled setting time start stop
- if( time() > $timestart && time() < $timestop ){
- echo "Time Success \n";
- $resultD = PDODatabase::Instance()->Query( "DELETE FROM temp_message where id = $id ");
- //debug
- //$res = "REG DEBUG";
- $cronid = rand();
- if($prov == '1'){
- $prov = "gsm-1.1";}
- $username = "sms";
- $password = "renner18";
- $fields = array();
- $fields["username"] = "sms";
- $fields["password"] = "renner18"; //safe use 63
- $fields["phonenumber"] = $mobile;
- $fields["message"] = $message;
- $fields["port"] = $prov;
- $fields_string = http_build_query($fields);
- $outbound_endpoint = "http://119.93.179.80:9889/sendsms?";
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $outbound_endpoint);
- curl_setopt($ch, CURLOPT_POST, count($fields));
- curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- $output = curl_exec($ch);
- $result = json_decode($output,true);
- var_dump($result);
- curl_close($ch);
- //$report = $result['report'][0]['1'][0]['result'];
- $report = $result['result'];
- $result = PDODatabase::Instance()->Query( "INSERT INTO message (crontime, userid, msg, type, tel, prov, goipid, agent, groupe, telecom, area, _OWNER, uid, priority, cronid) VALUES ( :timestamp, :userid, :message, 4, :mobile, :prov, 0, :agent, :user_group, :telecom, :location, :owner, :uid, :priority, $cronid )", $params);
- //response if success
- $res = "SUCCESS REGULAR";
- if($report == "success"){
- $over = 1;
- $failed =0;
- }else{
- $over = 2;
- $failed =1;
- }
- $resultC = PDODatabase::Instance()->Query("UPDATE message set failed=$failed, over=$over where cronid=$cronid");
- }
- }
- echo 'QUEUED SMS: '.count($messages).' | SENDING SMS: '.count($messages1).' | SERVER TIME: '.date("M d, Y, g:i a", time()).' | Start: '.date("M d, Y, g:i a", $timestart).' | Stop: '.date("M d, Y, g:i a", $timestop).' | DAY: '.$day.' | Sched Status: '.$status.' | Response: '.$res;
- echo "\n";
- }
- }
- elseif(count($message3 > 0) && count($message3) != 0){
- echo "Priority 2 \n";
- foreach ($message3 as $msg){
- $time = $msg['crontime'];
- $userid = $msg['userid'];
- $message = $msg['msg'];
- $mobile = $msg['tel'];
- $prov = $msg['prov'];
- $agent = $msg['agent'];
- $groupe = $msg['groupe'];
- $telecom = $msg['telecom'];
- $location = $msg['area'];
- $agent = $msg['_OWNER'];
- $uid = $msg['uid'];
- $id = $msg['id'];
- $rcount = $msg['rcount'];
- $priority = $msg['priority'];
- $params = array(
- ':timestamp'=>$time,
- ':userid'=>$userid,
- ':message'=>$message,
- ':mobile'=>$mobile,
- ':prov'=>$prov,
- ':agent'=>$agent,
- ':user_group'=>$groupe,
- ':telecom'=>$telecom,
- ':location'=>$location,
- ':owner'=>$agent,
- ':uid'=>$uid,
- ':priority'=>$priority
- );
- if( $serverday == "Monday" && $day == "MON" || $serverday == "Tuesday" && $day == "TUE" || $serverday == "Wednesday" && $day == "WED" || $serverday == "Thursday" && $day == "THU" || $serverday == "Friday" && $day == "FRI" || $serverday == "Saturday" && $day == "SAT" || $serverday == "Sunday" && $day == "SUN" || ($serverday == "Monday" || $serverday == "Wednesday" || $serverday == "Friday") && $day == "MWF" || ($serverday == "Monday" || $serverday == "Tuesday" || $serverday == "Wednesday" || $serverday == "Thursday" || $serverday == "Friday") && $day == "WD" || ($serverday == "Saturday" || $serverday == "Sunday") && $day == "WE" || ($serverday == "Monday" || $serverday == "Tuesday" || $serverday == "Wednesday" || $serverday == "Thursday" || $serverday == "Friday" || $serverday == "Saturday" || $serverday == "Sunday") && $day == "All" || ($serverday == "Tuesday" || $serverday == "Thursday") && $day == "TTH" )
- {
- echo "Day Success \n";
- //check scheduled setting time start stop
- if( time() > $timestart && time() < $timestop ){
- echo "Time Success \n";
- if($time <= time()){
- echo "Sched Success" ;
- $resultD = PDODatabase::Instance()->Query( "DELETE FROM temp_message where id = $id ");
- //debug
- //$res = "REG DEBUG";
- $cronid = rand();
- if($prov == '1'){
- $prov = "gsm-1.1";}
- $username = "sms";
- $password = "renner18";
- $fields = array();
- $fields["username"] = "sms";
- $fields["password"] = "renner18"; //safe use 63
- $fields["phonenumber"] = $mobile;
- $fields["message"] = $message;
- $fields["port"] = $prov;
- $fields_string = http_build_query($fields);
- $outbound_endpoint = "http://119.93.179.80:9889/sendsms?";
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $outbound_endpoint);
- curl_setopt($ch, CURLOPT_POST, count($fields));
- curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- $output = curl_exec($ch);
- $result = json_decode($output,true);
- curl_close($ch);
- //$report = $result['report'][0]['1'][0]['result'];
- $report = $result['result'];
- $result = PDODatabase::Instance()->Query( "INSERT INTO message (crontime, userid, msg, type, tel, prov, goipid, agent, groupe, telecom, area, _OWNER, uid, priority, cronid) VALUES ( :timestamp, :userid, :message, 4, :mobile, :prov, 0, :agent, :user_group, :telecom, :location, :owner, :uid, :priority, $cronid )", $params);
- //response if success
- $res = "SUCCESS SCHED";
- if($report == "success"){
- $over = 1;
- $failed =0;
- }else{
- $over = 2;
- $failed =1;
- }
- $resultC = PDODatabase::Instance()->Query("UPDATE message set failed=$failed, over=$over where cronid=$cronid");
- //response if success
- //response if success
- }
- }
- }
- echo 'QUEUED SMS: '.count($message3).' | SENDING SMS: '.count($messages1).' | SERVER TIME: '.date("M d, Y, g:i a", time()).' | Start: '.date("M d, Y, g:i a", $timestart).' | Stop: '.date("M d, Y, g:i a", $timestop).' | DAY: '.$day.' | Sched Status: '.$status.' | Response: '.$res;
- echo "\n";
- }
- }else{
- echo "No Messages to be sent \n";
- }
- echo 'QUEUED SMS: '.count($messages).' | SENDING SMS: '.count($messages1).' | SERVER TIME: '.date("M d, Y, g:i a", time()).' | Start: '.date("M d, Y, g:i a", $timestart).' | Stop: '.date("M d, Y, g:i a", $timestop).' | DAY: '.$day.' | Sched Status: '.$status.' | Response: '.$res;
- echo "\n";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement