0xV3NOMx
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.145.43.92


Current Path : /var/www/html/sms/
Upload File :
Current File : /var/www/html/sms/cronjob_sendsms.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 = '003';
//ST180220202 041 photocopy    
if($univcode == '')
{
	die();
}

//connect to database
$servername = "logisys.cluster-cv9maxyrxjgg.ap-south-1.rds.amazonaws.com";
$username   = "admin";
$password  = "Logisys2104";
$conn = new  mysqli($servername,$username,$password);
$event = 'ST27092020';
if(!$conn) 
{
    die("Connection failed: " . mysqli_connect_error());
}

$commondb = "logisys3_comexam";

$query = "select FSMSUSER, FSMSPASSWD, FSMSSENDID from {$commondb}.dbname where funivcode = '{$univcode}'";
$result1 = mysqli_query($conn,$query);
$smsrow = mysqli_fetch_assoc($result1);

$query = "select funivcode, fregno, fenttype, fmobileno as mobileno, 
concat(fmessage, ' Sent Time: ',time(now())) as fmessage,
if(length(fmessage) > 160, ceiling(length(fmessage)/153), 1) as msg_cnt
from {$commondb}.sendsms 
where ifnull(fstatus, 'F') = 'F' and fenttype = '{$event}'
and funivcode = '{$univcode}'
and fmobileno is not null";

$result = mysqli_query($conn,$query);
$count = mysqli_num_rows($result);

$username = $smsrow['FSMSUSER'];
$password = $smsrow['FSMSPASSWD'];
$from = $smsrow['FSMSSENDID'];
$category = '';

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 = '{$event}'
			and fmobileno in ('{$srtImplodedMobs}')";
			//var_dump($strUpdateQuery);	
			
			$result2 = 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 = '{$event}'  and fmobileno in ('{$srtImplodedMobs}')";
	//var_dump($strUpdateQuery);	
	$result2 = mysqli_query($conn,$strUpdateQuery);

	$username = $username;
	$password = $password;
	$from = $from;
	$category = 'bulk';


	//pg test
	//$to = "919741089633,918277684424,919844020272,919845532688,919480278729,919886494428,919900120447,919986554632";

	//PHD
	//$to = "919741089633,918277684424,919844020272,919845532688,919480278729,919449259058,919986554632";

	//kus - Arun and Prashant, mohan, ramesh, cheta, yogendra
   $to = "919741089633,919845532688,918277684424,919844059406,919844020272,919901001637,919448149461,919731400914,919845782929,919611474110,919482971796";

   // GCG - Arun and Prashant, mohan, ramesh, mahesh,coe,principlae
  //  $to = "919741089633,918277684424,919845532688,919844020272,919986554632,919448890863,919036572747";

   //Arun and Prashant
   //$to = "919741089633,918277684424,919986554632,919845532688";
    

  //BCU : Arun and Prashant, mohan, ramesh, mahesh,RE
  //$to = "918277684424,919538219443,919845532688,919844020272,919986554632,919844059406,919741089633,919845640772,918105473869";
    
	//Arun and Prashant, mohan, niranjan,RE Madam
	//$to = "919741089633,918277684424,919845532688,919964040441,919845559557";
    
    //rcub
	//$to = "918277684424,919845532688,919844020272,919844059406,919741089633,919538618751,919449575108,919448238385,919448008278,919844218894,919036948843,919448235042";
	
	//dud
	//$to = "918277684424,919964040441,919845532688,919844020272,919844059406,918792859141,918105462759,919741089633,917892795239,919845559557";

	//bnu
	//$to = "918277684424,919845532688,919844020272,919986554632,919844059406,919741089633,9449264711,9449819738,9742143018";

	$smsresp = sendsmaapi($username,$password,$from,$to,$text,$category);
	echo $smsresp;
}




?>