Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- include ('../../core/main.class.php');
- $a = new Application();
- $day = $a->schedStatus('day');
- $serverday = date("l");
- $timestart = strtotime($a->schedStatus('timestart'));
- $timestop = strtotime($a->schedStatus('timestop'));
- $status = intval($a->schedStatus('status'));
- $res = '';
- $udate = $a->unixStamp();
- $active_port = 'gsm-1.1';
- PDODatabase::Instance()->Query( "DELETE n1 FROM temp_message n1, temp_message n2 WHERE n1.id < n2.id AND n1.msg = n2.msg AND n1.tel = n2.tel");
- $message3 = PDODatabase::Instance()->QueryAll("SELECT * FROM temp_message WHERE priority = 2 AND prov = '".$active_port."' ORDER BY id DESC LIMIT 0,1 ");
- $messages = PDODatabase::Instance()->QueryAll("SELECT * FROM temp_message WHERE priority = 1 AND prov = '".$active_port."' ORDER BY id DESC LIMIT 0,1 ");
- $messages4 = PDODatabase::Instance()->QueryAll("SELECT * FROM temp_sched WHERE (priority = 2 OR priority = 1) AND prov = '".$active_port."' AND TEMP_MESSAGE_ID = 0 ORDER BY id DESC LIMIT 0,1 ");
- $messages1 = PDODatabase::Instance()->QueryAll("SELECT * FROM message WHERE over=0 ");
- $findme = "success";
- if(count($messages) > 0 && count($messages1) === 0 && (count($message3) ==0 || count($message3) > 0)){
- echo "Priority 1 Success \n";
- if($a->SCHEDULE_CONDITION($serverday, $day) === TRUE){
- echo "Day Success \n";
- if( time() > $timestart && time() < $timestop ){
- echo "Time Success \n";
- $rs = PDODatabase::Instance()->QueryAll("SELECT * FROM temp_message WHERE priority = 1 AND prov = '".$active_port."' ORDER BY id ");
- for ($i=0; $i < count($rs); $i++) {
- $cronid = rand();
- $mobile = $rs[$i]['tel'];
- $prov = $rs[$i]['prov'];
- $telecom = $rs[$i]['telecom'];
- $phonebookid = $rs[$i]['_phonebookid'];
- $folder = $rs[$i]['folder'];
- $sender = $rs[$i]['sender'];
- $rcount = $rs[$i]['rcount'];
- $prio = $rs[$i]['priority'];
- $a->DELETE_TEMP_MESSAGE($rs[$i]['id']);
- $username = "sms";
- $password = "renner18";
- $message =urlencode(mb_convert_encoding($rs[$i]['msg'], 'utf-8', "auto"));
- $url = "http://119.93.179.80:9887/sendsms?username=$username&password=$password&phonenumber=$mobile&message=$message&port=$prov";
- $link = curl_init();
- curl_setopt($link, CURLOPT_HEADER, 0);
- curl_setopt($link, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($link, CURLOPT_URL, $url);
- $response = curl_exec($link);
- curl_close($link);
- $response = str_replace("\r\n", "\\r\\n", $response);
- $result = json_decode($response, true);
- //var_dump($array);
- $report = $result['report'][0]['1'][0]['result'];
- echo $report . "\n";
- //Send SmS
- $a->SEND_SMS_PER_MOB($udate, $rs[$i]['userid'], $rs[$i]['msg'], $mobile, $prov, '', $telecom, $phonebookid, $folder, $sender, $prio, $rcount, $cronid, $rs[$i]['UNIQUE_ID'], $rs[$i]['BRAND_NAME']);
- $res = "SUCCESS REGULAR";
- if($report == "success"){
- $over = 1;
- $failed =0;
- }else{
- //$over = 2;
- //$failed =1;
- $over = 1;
- $failed =0;
- }
- //Save the incoming message
- $a->INBOX_CONVO($rs[$i]['msg'], $mobile, $phonebookid, $prov, 'inbox', $rs[$i]['userid'], $sender, $failed, '0', $folder, '0', '0', '',$rs[$i]['UNIQUE_ID'], $rs[$i]['BRAND_NAME']);
- //Update Failed IF TRUE OR FALSE
- $resultC = PDODatabase::Instance()->Query("UPDATE message set failed=$failed, over=$over where cronid=$cronid");
- //Delete Incoming Message Cron = 0
- $resultE = PDODatabase::Instance()->Query( "DELETE FROM message where cronid = 0");
- }
- }
- }
- echo 'QUEUED SMS PORT '.$active_port.' : '.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 && count($messages1) === 0){
- echo "Priority 2 \n";
- if($a->SCHEDULE_CONDITION($serverday, $day) === TRUE){
- echo "Day Success \n";
- if( time() > $timestart && time() < $timestop ){
- echo "Time Success \n";
- if($time <= time()){
- echo "Sched Success" ;
- $rs = PDODatabase::Instance()->QueryAll("SELECT * FROM temp_message WHERE priority = 2 AND prov = '".$active_port."' ORDER BY id ");
- for ($i=0; $i < count($rs); $i++) {
- $cronid = rand();
- $mobile = $rs[$i]['tel'];
- $prov = $rs[$i]['prov'];
- $telecom = $rs[$i]['telecom'];
- $phonebookid = $rs[$i]['_phonebookid'];
- $folder = $rs[$i]['folder'];
- $sender = $rs[$i]['sender'];
- $rcount = $rs[$i]['rcount'];
- $prio = $rs[$i]['priority'];
- $a->DELETE_TEMP_MESSAGE($rs[$i]['id']);
- $username = "sms";
- $password = "renner18";
- $message =urlencode(mb_convert_encoding($rs[$i]['msg'], 'utf-8', "auto"));
- $url = "http://119.93.179.80:9887/sendsms?username=$username&password=$password&phonenumber=$mobile&message=$message&port=$prov";
- $link = curl_init();
- curl_setopt($link, CURLOPT_HEADER, 0);
- curl_setopt($link, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($link, CURLOPT_URL, $url);
- $response = curl_exec($link);
- curl_close($link);
- $response = str_replace("\r\n", "\\r\\n", $response);
- $result = json_decode($response, true);
- //var_dump($array);
- $report = $result['report'][0]['1'][0]['result'];
- echo $report . "\n";
- //Send SmS
- $a->SEND_SMS_PER_MOB($udate, $rs[$i]['userid'], $rs[$i]['msg'], $mobile, $prov, '', $telecom, $phonebookid, $folder, $sender, $prio, $rcount, $cronid, $rs[$i]['UNIQUE_ID'], $rs[$i]['BRAND_NAME']);
- $res = "SUCCESS REGULAR";
- if($report == "success"){
- $over = 1;
- $failed =0;
- }else{
- //$over = 2;
- //$failed =1;
- $over = 1;
- $failed =0;
- }
- //Save the incoming message
- $a->INBOX_CONVO($rs[$i]['msg'], $mobile, $phonebookid, $prov, 'inbox', $rs[$i]['userid'], $sender, $failed, '0', $folder, '0', '0', '', $rs[$i]['UNIQUE_ID'], $rs[$i]['BRAND_NAME']);
- //Update Failed IF TRUE OR FALSE
- $resultC = PDODatabase::Instance()->Query("UPDATE message set failed=$failed, over=$over where cronid=$cronid");
- //Delete Incoming Message Cron = 0
- $resultE = PDODatabase::Instance()->Query( "DELETE FROM message where cronid = 0");
- }
- }
- }
- }
- echo 'QUEUED SMS PORT '.$active_port.' : '.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";
- }elseif(count($messages4 > 0) && count($messages4) != 0 && count($messages1) === 0 && count($message3) === 0){
- echo "Priority 2 \n";
- if($a->SCHEDULE_CONDITION($serverday, $day) === TRUE){
- echo "Day Success \n";
- if( time() > $timestart && time() < $timestop ){
- echo "Sched Success" ;
- $rs = PDODatabase::Instance()->QueryAll("SELECT * FROM temp_sched WHERE (priority = 2 OR priority = 1) AND prov = '".$active_port."' AND TEMP_MESSAGE_ID = 0 ORDER BY id ");
- for ($i=0; $i < count($rs); $i++) {
- $cronid = rand();
- $mobile = $rs[$i]['tel'];
- $prov = $rs[$i]['prov'];
- $telecom = $rs[$i]['telecom'];
- $phonebookid = $rs[$i]['_phonebookid'];
- $folder = $rs[$i]['folder'];
- $sender = $rs[$i]['sender'];
- $rcount = $rs[$i]['rcount'];
- $prio = $rs[$i]['priority'];
- PDODatabase::Instance()->Query("UPDATE temp_sched set TEMP_MESSAGE_ID = 1 WHERE id= ".$rs[$i]['id']." ");
- $username = "sms";
- $password = "renner18";
- $message =urlencode(mb_convert_encoding($rs[$i]['msg'], 'utf-8', "auto"));
- $url = "http://119.93.179.80:9887/sendsms?username=$username&password=$password&phonenumber=$mobile&message=$message&port=$prov";
- $link = curl_init();
- curl_setopt($link, CURLOPT_HEADER, 0);
- curl_setopt($link, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($link, CURLOPT_URL, $url);
- $response = curl_exec($link);
- curl_close($link);
- $response = str_replace("\r\n", "\\r\\n", $response);
- $result = json_decode($response, true);
- //var_dump($array);
- $report = $result['report'][0]['1'][0]['result'];
- echo $report . "\n";
- //Send SmS
- $a->SEND_SMS_PER_MOB($udate, $rs[$i]['userid'], $rs[$i]['msg'], $mobile, $prov, '', $telecom, $phonebookid, $folder, $sender, $prio, $rcount, $cronid, $rs[$i]['UNIQUE_ID'], $rs[$i]['BRAND_NAME']);
- $res = "SUCCESS REGULAR";
- if($report == "success"){
- $over = 1;
- $failed =0;
- }else{
- //$over = 2;
- //$failed =1;
- $over = 1;
- $failed =0;
- }
- //Save the incoming message
- $a->INBOX_CONVO($rs[$i]['msg'], $mobile, $phonebookid, $prov, 'inbox', $rs[$i]['userid'], $sender, $failed, '0', $folder, '0', '0', '', $rs[$i]['UNIQUE_ID'], $rs[$i]['BRAND_NAME']);
- //Update Failed IF TRUE OR FALSE
- $resultC = PDODatabase::Instance()->Query("UPDATE message set failed=$failed, over=$over where cronid=$cronid");
- //Delete Incoming Message Cron = 0
- $resultE = PDODatabase::Instance()->Query( "DELETE FROM message where cronid = 0");
- }
- }
- }
- echo 'QUEUED SMS PORT '.$active_port.' : '.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 for Port ".$active_port." to be sent \n";
- }
- echo "\n";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement