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 : 18.217.237.68
Current Path : /var/www/html/sms/ |
| Current File : /var/www/html/sms/sms_statistics.php |
<?php
//lib16107 lib16103
ini_set('display_errors', 'on');
ini_set('max_execution_time', 300);
include("sendsmsapi.php");
include("sendGridMail.php");
$servername = "logisys.cluster-cv9maxyrxjgg.ap-south-1.rds.amazonaws.com";
$username = "admin";
$password = "Logisys2104";
$conn = new mysqli($servername,$username,$password);
if(!$conn)
{
die("Connection failed: " . mysqli_connect_error());
}
$commondb = "logisys3_comexam";
$query = "select FSMSUSER, FSMSPASSWD, FSMSSENDID from {$commondb}.dbname where funivcode = '041'";
$result1 = mysqli_query($conn,$query);
$smsrow = mysqli_fetch_assoc($result1);
$username = $smsrow['FSMSUSER'];
$password = $smsrow['FSMSPASSWD'];
$from = $smsrow['FSMSSENDID'];
$category = 'bulk';
$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 = "select x.funivcode, d.funivname, count(x.fmobileno) as sms_cnt, d.FFOLDER
from logisys3_logs.smslog x, logisys3_comexam.dbname d
where x.funivcode = d.funivcode and fackdate > DATE_SUB(CURDATE(), INTERVAL 1 DAY)
group by x.funivcode
order by sms_cnt desc, x.funivcode";
$result3 = mysqli_query($conn,$query);
$count3 = mysqli_num_rows($result3);
if($count3 >0)
{
$text = "SMS Sent Deatils : ";
$sum = 0;
while($row3 = mysqli_fetch_assoc($result3))
{
$text .= $row3['FFOLDER']." : ".$row3['sms_cnt']."; ";
$sum += $row3['sms_cnt'];
}
}
$text .= "Total SMS Sent : ".moneyFormatIndia($sum)."; SMS Remaining : ".moneyFormatIndia($smsremain);
//var_dump($text);
$to = "919741089633,918277684424,919845532688,919844020272";
$smsresp = sendsmaapi($username,$password,$from,$to,$text,$category);
echo $smsresp;
// continue;
//die();
function moneyFormatIndia($num) {
$explrestunits = "" ;
if(strlen($num)>3) {
$lastthree = substr($num, strlen($num)-3, strlen($num));
$restunits = substr($num, 0, strlen($num)-3); // extracts the last three digits
$restunits = (strlen($restunits)%2 == 1)?"0".$restunits:$restunits; // explodes the remaining digits in 2's formats, adds a zero in the beginning to maintain the 2's grouping.
$expunit = str_split($restunits, 2);
for($i=0; $i<sizeof($expunit); $i++) {
// creates each of the 2's group and adds a comma to the end
if($i==0) {
$explrestunits .= (int)$expunit[$i].","; // if is first value , convert into integer
} else {
$explrestunits .= $expunit[$i].",";
}
}
$thecash = $explrestunits.$lastthree;
} else {
$thecash = $num;
}
return $thecash; // writes the final format where $currency is the currency symbol.
}
?>
|