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.117.254.202
Current Path : /var/www/results/gfgcg/ |
| Current File : /var/www/results/gfgcg/cronjob_sendsms.php |
<?php
//lib16107 lib16103
include ("database.php");
//require_once("cManualMailer.php");
//error_reporting(E_ALL);
ini_set('display_errors', 'on');
include("sendsmsapi.php");
ini_set('memory_limit','900M');
ini_set('max_execution_time',0);
include("sendsmsbulk.php");
include("sendGridMail.php");
//$univcode = trim($_GET['funivcode']);
$univcode = '023';
if($univcode == '')
{
die();
}
$query = "select funivcode, fregno, fenttype, fmobileno as mobileno, fmessage
from sendsms
where ifnull(fstatus, 'F') = 'F' and fenttype = 'RE' and funivcode = '{$univcode}'
and fmobileno is not null";
$result = mysqli_query($conn,$query);
$count = mysqli_num_rows($result);
$username = 'logisyhttp';
$password = 'Logis986';
$from = 'UNISOL';
$category = '';
if($count >0)
{
$i = 0;
while($row = mysqli_fetch_assoc($result))
{
$to = $row['mobileno'];
$text = $row['fmessage'];
$smsresp = sendsmaapi($username,$password,$from,$to,$text,$category);
echo $to."<br>";
$rgInsert[] = "('".$row['funivcode']."','".$row['fregno']."','{$to}','0','{$smsresp}','".$row['fenttype']."','T', DATE_FORMAT(NOW(),'%Y-%m-%d'), DATE_FORMAT(NOW(),'%T'))";
$rgTrimedMobs[$i] = $to;
if($i == 50)
{
$strInsertQuery = "insert into smslog(funivcode, fregno,fmobileno, freasoncode, fguid, fenttype, fstatus,fackdate, facktime) values".implode(',',$rgInsert);
//var_dump($strInsertQuery);
$result1 = mysqli_query($conn,$strInsertQuery);
$srtImplodedMobs = implode("','",$rgTrimedMobs);
$strUpdateQuery = "update sendsms set fstatus = 'T' where fenttype = 'RE' 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 smslog(funivcode,fregno,fmobileno, freasoncode, fguid, fenttype, fstatus,fackdate, facktime) values".implode(',',$rgInsert);
//var_dump($strInsertQuery);
$result1 = mysqli_query($conn,$strInsertQuery);
$srtImplodedMobs = implode("','",$rgTrimedMobs);
$strUpdateQuery = "update sendsms set fstatus = 'T' where fenttype = 'RE' and fmobileno in ('{$srtImplodedMobs}')";
//var_dump($strUpdateQuery);
$result2 = mysqli_query($conn,$strUpdateQuery);
echo "SMS Sent";
/*$strLogSumQuery = "select date_format(x.fackdate, '%d/%m/%Y') as DATE,
x.funivcode as UNIVERSITY_CODE, y.funivname as FUNIVNAME,y.FSTAFFMOBILENO AS sumbob,
x.fenttype as EVENT_TYPE, 'AD' as event, count(x.fmobileno) as SMS_COUNT,
CONCAT('Message : ',x.fenttype, '; SMS Sent Count : ',COUNT(x.fmobileno),
'; Exam : ',ifnull(x.fexamdate,'APRIL / MAY 2018'), '; Client : ',y.funivcode,' - ',y.funivname,'.') AS message
from smslog x
inner join dbname y
on x.funivcode = y.funivcode
where fackdate = date_format(now(), '%Y-%m-%d')
and freasoncode = 0
and facktime >= DATE_SUB(now(), interval 1 hour)
and x.fenttype = 'RE'
group by x.fackdate, y.funivcode, x.fenttype";
$result3 = mysqli_query($conn, $strLogSumQuery);
$strHtmlMail = '<html><body>';
$strHtmlMail .= '<table cellspacing="1" cellpadding="2" border="0" align="center" bgcolor="#505151">';
$strHtmlMail .= "<thead>
<tr bgcolor='#e1eaea'>
<th>DATE</th>
<th>UNIVERSITY CODE</th>
<th>UNIVERSITY NAME</th>
<th>EVENT TYPE</th>
<th>SMS COUNT</th>
</tr>
</thead>";
while($row = mysqli_fetch_assoc($result3))
{
$strTo = $row['sumbob'];
$text = $row['message'];
$category = 'bulk';
$response = sendsmaapibulk($username,$password,$from,$strTo,$text,$category);
$rgExpAmp = explode('&', $response);
array_walk($rgExpAmp, function($val,$key) use(&$final){
list($key, $value) = explode('=', $val);
$final[$key] = $value;
});
$errorcode = explode(',', $final['errorcode']);
$mobnos = explode(',', $final['seqno']);
$rgInsert = array();
$rgTrimedMobs = array();
for($i = 0; $i < count($mobnos);$i++)
{
$rgInsert[] = "('".substr($mobnos[$i],2,11)."','".$errorcode[$i]."','".$final['guid']."','".$row['event']."', DATE_FORMAT(NOW(),'%Y-%m-%d'), DATE_FORMAT(NOW(),'%T'))";
$rgTrimedMobs[$i] = substr($mobnos[$i],2,11);
}
$strInsertQuery = "insert into smslog(fmobileno, freasoncode, fguid, fenttype, fackdate, facktime) values".implode(',',$rgInsert);
$result1 = mysqli_query($conn,$strInsertQuery);
$strHtmlMail .= "<tr bgcolor='#ffffff'><td><center>".$row['DATE']."</center></td><td><center>".$row['UNIVERSITY_CODE']."</center></td><td>".$row['FUNIVNAME']."</td>";
$strHtmlMail .= "<td><center>".$row['EVENT_TYPE']."</center></td><td align='right'>".$row['SMS_COUNT']."</td></tr>";
}
$strHtmlMail .= '</table></body></html>';
$subject = "SMS Sent Status Report";
$emails = ['prashanth.k@logisys.org','arun.v@logisys.org','hnagaraj@hotmail.com','mohan.s@logisys.org', 'hnramesh@logisys.org'];
for($i=0;$i< count($emails); $i++)
{
$emailid = $emails[$i];
$resp = sendGridMail($emailid,$subject,$strHtmlMail);
}
echo $strHtmlMail;*/
}
?>
|