Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include_once('../../core/main.class.php');
- if (!isset($_SESSION)) {
- session_start();
- }
- $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';
- $username = "sms";
- $password = "renner18";
- $link_url = "http://10.39.187.29";
- //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");
- //PDODatabase::Instance()->Query( "DELETE n1 FROM temp_sched n1, temp_sched n2 WHERE n1.id < n2.id AND n1.msg = n2.msg AND n1.tel = n2.tel");
- $message3 = PDODatabase::Instance()->QueryOne("SELECT COUNT(*) AS ID FROM temp_message WHERE priority = 2 AND prov = '".$active_port."' ORDER BY id DESC LIMIT 0,1 ");
- $messages = PDODatabase::Instance()->QueryOne("SELECT COUNT(*) AS ID FROM temp_message WHERE priority = 1 AND prov = '".$active_port."' ORDER BY id DESC LIMIT 0,1 ");
- $messages4 = PDODatabase::Instance()->QueryOne("SELECT COUNT(*) AS ID 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()->QueryOne("SELECT COUNT(*) AS ID FROM message WHERE over=0 ");
- $findme = "success";
- if($messages['ID'] > 0 && $messages1['ID'] === 0 && $message3['ID'] ==0 || $message3['ID'] > 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 LIMIT 0,20");
- 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']);
- $message =urlencode(mb_convert_encoding($rs[$i]['msg'], 'utf-8', "auto"));
- $url = $link_url."/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.' : '.$messages['ID'].' | SENDING SMS: '.$messages1['ID'].' | 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($message3['ID'] > 0 && $message3['ID'] != 0 && $messages1['ID'] === 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 LIMIT 0,20 ");
- 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']);
- $message =urlencode(mb_convert_encoding($rs[$i]['msg'], 'utf-8', "auto"));
- $url = $link_url."/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.' : '.$message3['ID'].' | SENDING SMS: '.$messages1['ID'].' | 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($messages4['ID'] > 0 && $messages4['ID'] != 0 && $messages1['ID'] === 0 && $message3['ID'] === 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 LIMIT 0,20 ");
- 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']." ");
- $message =urlencode(mb_convert_encoding($rs[$i]['msg'], 'utf-8', "auto"));
- $url = $link_url."/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.' : '.$message3['ID'].' | SENDING SMS: '.$messages1['ID'].' | 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