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 : 3.133.122.95
Current Path : /var/www/html/oums/src/ |
| Current File : /var/www/html/oums/src/oums_sms_send.php |
<?php
//lib16107 lib16103
error_reporting(E_ALL);
ini_set('display_errors', 'on');
ini_set('display_errors', 'on');
include("sendsmsapi.php");
ini_set('memory_limit','900M');
ini_set('max_execution_time',0);
//$univcode = trim($_GET['funivcode']);
$univcode = '999';
//ST180220202 041 photocopy
if($univcode == '')
{
die();
}
//connect to database
$servername = "logisys.cluster-cv9maxyrxjgg.ap-south-1.rds.amazonaws.com";
$username = "rcubuser";
$password = "rcubuser@124";
$conn = new mysqli($servername,$username,$password);
if(!$conn)
{
die("Connection failed: " . mysqli_connect_error());
}
$evnttype = "oums";
$commondb = "logisys3_comexam";
$db = "logisys3_oums";
$query = "select FSMSUSER, FSMSPASSWD, FSMSSENDID from {$commondb}.dbname where funivcode = '{$univcode}'";
$result1 = mysqli_query($conn,$query);
$smsrow = mysqli_fetch_assoc($result1);
$username = $smsrow['FSMSUSER'];
$password = $smsrow['FSMSPASSWD'];
$from = $smsrow['FSMSSENDID'];
$category = '';
$query = "select funivcode, fregno, fenttype, fmobileno as mobileno,
concat(fmessage, ' Sent Time: ',time(now())) as fmessage, fsubcode,
fmessage, if(length(fmessage) > 160, ceiling(307/153), 1) as msg_cnt
from {$commondb}.sendsms
where ifnull(fstatus, 'F') = 'F' and fenttype = '{$evnttype}'
and funivcode = '{$univcode}'
and fmobileno is not null";
$result = mysqli_query($conn,$query);
$count = mysqli_num_rows($result);
$row = mysqli_fetch_assoc($result);
$taskcode = substr($row['fsubcode'],6);
$remindno = substr($row['fsubcode'],-2);
if($count >0)
{
$i = 0;
$text = "";
$url = "http://203.212.70.200/smpp/creditstatus.jsp?user={$username}&password={$password}";
$session = curl_init($url);
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($session);
curl_close($session);
$res = explode(",",$response);
$res1 = explode("=",$res[1]);
$creditused = $res1[1];
$res2 = explode("=",$res[0]);
$credit = $res2[1];
$smsremain = (int)($credit-$creditused);
$query ="insert into {$commondb}.smssum(funivcode, fprocdate, fstarttime, fstartcredits) values('{$univcode}',now(),now(),'{$smsremain}')";
$res = mysqli_query($conn,$query);
$last_id = $conn->insert_id;
while($row = mysqli_fetch_assoc($result))
{
$to = $row['mobileno'];
$text = $row['fmessage'];
$msg_cnt = $row['msg_cnt'];
$smsresp = sendsmaapi($username,$password,$from,$to,$text,$category);
echo $i." - ".$to."<br>";
$rgInsert[] = "('".$row['funivcode']."','".$row['fregno']."','{$to}','0','{$smsresp}','".$row['fenttype']."','T', DATE_FORMAT(NOW(),'%Y-%m-%d'), DATE_FORMAT(NOW(),'%T'),'{$msg_cnt}','{$last_id}')";
$rgTrimedMobs[$i] = $to;
echo $i.$to."<br>";
if($i == 50)
{
$strInsertQuery = "insert into {$commondb}.smslog(funivcode, fregno,fmobileno, freasoncode, fguid, fenttype, fstatus,fackdate, facktime,fsmscnt, fprocid) values".implode(',',$rgInsert);
//var_dump($strInsertQuery);
$result1 = mysqli_query($conn,$strInsertQuery);
$srtImplodedMobs = implode("','",$rgTrimedMobs);
$strUpdateQuery = "update {$commondb}.sendsms set fstatus = 'T' where fenttype = '$evnttype'
and fmobileno in ('{$srtImplodedMobs}')";
$result2 = mysqli_query($conn,$strUpdateQuery);
if($remindno=="01"){
$oumsUpdateQuery = "update {$db}.taskreminder set fremnsta1 = 'T' where ftaskcode = '$taskcode'
and fmobileno in ('{$srtImplodedMobs}')";
$result3 = mysqli_query($conn,$strUpdateQuery);
}
if($remindno=="02"){
$oumsUpdateQuery = "update {$db}.taskreminder set fremnsta2 = 'T' where ftaskcode = '$taskcode'
and fmobileno in ('{$srtImplodedMobs}')";
$result3 = mysqli_query($conn,$strUpdateQuery);
}
if($remindno=="03"){
$oumsUpdateQuery = "update {$db}.taskreminder set fremnsta3 = 'T' where ftaskcode = '$taskcode'
and fmobileno in ('{$srtImplodedMobs}')";
$result3 = mysqli_query($conn,$strUpdateQuery);
}
unset($rgInsert);
$rgInsert = array();
unset($rgTrimedMobs);
$rgTrimedMobs = array();
$i = 0;
}
$i++;
}
$strInsertQuery = "insert into {$commondb}.smslog(funivcode,fregno,fmobileno, freasoncode, fguid, fenttype, fstatus, fackdate, facktime, fsmscnt, fprocid) values".implode(',',$rgInsert);
$result1 = mysqli_query($conn,$strInsertQuery);
$srtImplodedMobs = implode("','",$rgTrimedMobs);
$strUpdateQuery = "update {$commondb}.sendsms set fstatus = 'T'
where fenttype = '$evnttype' and fmobileno in ('{$srtImplodedMobs}')";
$result2 = mysqli_query($conn,$strUpdateQuery);
if($remindno=="01"){
$oumsUpdateQuery = "update {$db}.taskreminder set fremnsta1 = 'T' where ftaskcode = '$taskcode'
and fmobileno in ('{$srtImplodedMobs}')";
$result3 = mysqli_query($conn,$strUpdateQuery);
}
if($remindno=="02"){
$oumsUpdateQuery = "update {$db}.taskreminder set fremnsta2 = 'T' where ftaskcode = '$taskcode'
and fmobileno in ('{$srtImplodedMobs}')";
$result3 = mysqli_query($conn,$strUpdateQuery);
}
if($remindno=="03"){
$oumsUpdateQuery = "update {$db}.taskreminder set fremnsta3 = 'T' where ftaskcode = '$taskcode'
and fmobileno in ('{$srtImplodedMobs}')";
$result3 = mysqli_query($conn,$strUpdateQuery);
}
}
?>
|