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.219.81.129
<?php
/*
* Api For sending result sms through web export after uploading the result
*
url == http://studentportal.logisys.org/result_sms_push.php
post data == funivcode=003&fdbname=logisys3_kus
*
*/
ini_set('memory_limit','900M');
ini_set('max_execution_time',0);
//include 'database.php';
include("sendGridMail.php");
//connect to database
$servername = "97.74.228.93";
$username = "logisys3_logu";
$password = "Logisys@2106";
$conn = new mysqli($servername,$username,$password);
if(!$conn)
{
die("Connection failed: " . mysqli_connect_error());
}
$commondb = "logisys3_comexam";
// Will be sent by mohan sir through web export
$db = 'logisys3_bcu';
$univcode = '041';
//Result Push data to common databse
if( $db != '' && $univcode != '')
{
$sql1 = "insert ignore into {$commondb}.sendsms(funivcode, fregno, fenttype, fsubcode, fmessage, fstatus, fdeleted, fyear, fexamtype,fupdate)
select distinct '{$univcode}', x.fregno, 'RE', x.fexamno,
concat('Dear ', st.fname,' (',x.fregno ,')',', your result for ',d.fexamname, ' ',
d.fexamdate, ' exam has been announced. Result : ',
y.fclass,'. Visit student portal studentportal.universitysolutions.in for details.') as fmessage, 'F', 'F', x.fyear, x.fexamtype, now()
from {$db}.res_fee x
inner join {$db}.resmarks y
on x.fdegree = y.fdegree
and x.fexamno = y.fexamno
and x.fregno = y.fregno
inner join {$db}.degree d
on x.fdegree = d.fdegree and x.fexamno = d.fexamno
inner join {$db}.student st
on x.fregno = st.fregno
where x.fresultdate = date_format(now(),'%Y-%m-%d') and fclass not like '%Fail%'
and ifnull(x.frespush,'') <> 'T'";
$result1 = mysqli_query($conn, $sql1);
$sql1 = "insert ignore into {$commondb}.sendsms(funivcode, fregno, fenttype, fsubcode, fmessage, fstatus, fdeleted, fyear, fexamtype,fupdate)
select distinct '{$univcode}', x.fregno, 'RE', x.fexamno,
concat('Dear ', st.fname,' (',x.fregno ,')',', your result for ',d.fexamname, ' ',
d.fexamdate, ' exam has been announced. ',
'Visit student portal studentportal.universitysolutions.in for details.') as fmessage, 'F', 'F', x.fyear, x.fexamtype, now()
from {$db}.res_fee x
inner join {$db}.resmarks y
on x.fdegree = y.fdegree
and x.fexamno = y.fexamno
and x.fregno = y.fregno
inner join {$db}.degree d
on x.fdegree = d.fdegree and x.fexamno = d.fexamno
inner join {$db}.student st
on x.fregno = st.fregno
where x.fresultdate = date_format(now(),'%Y-%m-%d') and fclass like '%Fail%'
and ifnull(x.frespush,'') <> 'T'";
$result1 = mysqli_query($conn, $sql1);
if($result1)
{
$sql1 = "update {$commondb}.sendsms x, {$commondb}.masuser y set x.fmobileno = y.fmobileno
where x.funivcode = y.funivcode and x.fregno = y.fregno and ifnull(x.fmobileno,'') = ''";
$result2 = mysqli_query($conn, $sql1);
$sql1 = "update {$db}.res_fee x set x.frespush = 'T'
where x.fresultdate = date_format(now(),'%Y-%m-%d')
and ifnull(x.frespush,'') <> 'T'";
$result3 = mysqli_query($conn, $sql1);
echo "success";
}
else
{
echo "failure";
}
}
/*if($result2)
{
$query = "select s.funivcode, d.funivname, s.fenttype,count(fmobileno) as pushcount,date_format(left(fupdate,10),'%d.%m.%Y') as pushdate
from {$commondb}.sendsms s
inner join {$commondb}.dbname d
on s.funivcode = d.funivcode
where ifnull(fmobileno,'') <> ''
and ifnull(fstatus,'') = 'F'
and left(fupdate,10) = date_format(now(),'%Y-%m-%d')
and fupdate >= DATE_SUB(now(), interval 2 hour)
and s.funivcode = '{$univcode}'
and s.fenttype = 'RE'
group by s.funivcode,s.fenttype";
$result = mysqli_query($conn, $query);
$count = mysqli_num_rows($result);
if($count > 0)
{
$table = '<table cellspacing="1" cellpadding="2" border="0" align="center" bgcolor="#505151">
<thead>
<tr bgcolor="#e1eaea">
<th>Sl.<br> No.</th>
<th>University <br>Code</th>
<th>University Name</th>
<th>Event <br> Type</th>
<th>Count</th>
<th>Date</th>
</tr>
</thead>';
$i = 1;
while($row = mysqli_fetch_array($result, MYSQLI_ASSOC))
{
//var_dump($row);
$table .= "<tr bgcolor='#ffffff' >";
$table .= "<td><center>".$i."</center></td>";
$table .= "<td><center>".$row['funivcode']."</center></td>";
$table .= "<td>".$row['funivname']."</td>";
$table .= "<td><center>".$row['fenttype']."</center></td>";
$table .= "<td align='right'>".$row['pushcount']."</td>";
$table .= "<td><center>".$row['pushdate']."</center></td>";
$table .= "</tr>";
//$sum +=$row['pushcount'];
$i++;
}
$table.="</table>";
$emails = ['prashanth.k@logisys.org','arun.v@logisys.org'];
$subject = "RESULTS SMS DATA UPLOAD STATISTICS";
for($i=0;$i< count($emails); $i++)
{
$emailid = $emails[$i];
//$resp = sendGridMail($emailid,$subject,$table);
//echo $resp;
}
}
echo "success";
}
else
{
echo "failure";
}*/
?>
|