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.139.86.53
<?php
function pushsms($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$message = $aobj_context->mobj_data["message"];
$type = $aobj_context->mobj_data["type"];
$deggrp = $aobj_context->mobj_data["deggrp"];
$stype = $aobj_context->mobj_data["stype"];
$fevent = $aobj_context->mobj_data["fevent"];
$univcode = $aobj_context->mobj_data["univcode"];
date_default_timezone_set('Asia/Kolkata');
$year = date("Y");
$month = date("m");
var_dump($fevent);
die();
// select
$query = "";
$query = "select funivcode, funivname, fdbname, fstaffmobileno, fgenmsgno
from dbname
where funivcode = '{$univcode}'";
$result = $aobj_context->mobj_db->GetRow($query);
$db = $result['fdbname'];
$funivname = $result['funivname'];
$stafmobile = $result['fstaffmobileno'];
$msgno = $result['fgenmsgno'];
$timestamp = date("dmY");
if($type == 'student')
$entype = "ST".$msgno.$timestamp;
else
$entype = "CM".$msgno.$timestamp;
$cnd = "";
if($type == 'centre' && $deggrp == 'UG' )
$cnd = "and fcollcode = fthcntr";
if($type == 'centre' && $deggrp == 'PG')
$cnd = "and fcollcode = fpgthcntr";
if($type == 'centre' && $deggrp == 'MBA')
$cnd = "and fcollcode = fpgthcntrmba";
$year_type = $month <= 6 ? 1 : 2;
$message = '['.$msgno.']'.$message;
$dgrp_cnd = "";
if($deggrp != 'ALL') {
$dgrp_cnd = "and ffaculty like '%{$deggrp}%'";
}
if($type == 'student')
{
$commondb = "logisys3_comexam";
if($stype == 'HT')
{
$query = "insert ignore into {$commondb}.sendsms(funivcode, fregno, fenttype, fsubcode, fmessage, fstatus, fdeleted, fyear, fexamtype, fupdate,fexamdate)
select distinct '{$univcode}', x.fregno, '{$entype}', '{$entype}',
'{$message}' as fmessage, 'F', 'F', x.fyear, x.fexamtype, now(),w.fexamdate
from {$db}.candsum x inner join {$db}.collexam y
on x.fdegree = y.fdegree and x.fcollcode = y.fcollcode
inner join {$db}.student z
on x.fdegree = z.fdegree and x.fregno = z.fregno
inner join {$db}.degree w on x.fdegree = w.fdegree and x.fexamno = w.fexamno
where ifnull(x.frecptdate,'') <> ''
and date_format(now(),'%Y-%m-%d') between y.fhtfrom and y.fhtto
and ifnull(z.fexamappblk,'') <> 'T' and ifnull(w.fdeggrp,'') = '{$deggrp}'
and ifnull(y.fhtpush,'F') <> 'T'
and ifnull(z.fmp,'') <> 'T'";
$result = $aobj_context->mobj_db->Execute($query);
// var_dump($query);
// die();
$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,'') = ''";
$result1 = $aobj_context->mobj_db->Execute($sql1);
}else if($stype == 'ADA')
{
var_dump("a");
die();
}
else
{
/*$query = "insert ignore into {$commondb}.sendsms(funivcode, fregno, fenttype, fsubcode, fmessage, fstatus, fdeleted, fyear, fexamtype, fupdate,fexamdate)
select distinct '{$univcode}', x.fregno, '{$entype}', '{$entype}',
'{$message}' as fmessage, 'F', 'F', x.fyear, x.fexamtype, now(),w.fexamdate
from {$db}.candsum x inner join {$db}.collexam y
on x.fdegree = y.fdegree and x.fcollcode = y.fcollcode
inner join {$db}.student z
on x.fdegree = z.fdegree and x.fregno = z.fregno
inner join {$db}.degree w on x.fdegree = w.fdegree and x.fexamno = w.fexamno
where ifnull(x.frecptdate,'') <> ''
and date_format(now(),'%Y-%m-%d') between y.fhtfrom and y.fhtto
and ifnull(z.fexamappblk,'') <> 'T' and ifnull(w.fdeggrp,'') = '{$deggrp}'
and ifnull(y.fhtpush,'F') <> 'T'
and ifnull(z.fmp,'') <> 'T'";*/
}
}else if($type == 'qpzone') {
$query = "insert ignore into logisys3_comexam.sendsms(funivcode, fregno, fmobileno, fenttype, fsubcode, fmessage, fstatus, fdeleted, fyear, fexamtype,fupdate)
select distinct '{$univcode}', fmobile, fmobile, '{$entype}', '{$entype}',
concat('Message from ', cl.funivname,':', c.fansreceive) as fmessage, 'F', 'F', dg.fyear,dg.fexamtype, NOW()
from {$db}.college c inner join {$db}.deggrp dg on dg.fdeggrp = '{$deggrp}'
inner join {$db}.degcntr dc on dg.fdeggrp = dc.fdeggrp and dc.fyear = dg.fyear
and dc.fexamtype = dg.fexamtype and c.fcollcode = dc.fexamcodet
where IFNULL(c.fdeleted,'') <> 'T' and IFNULL(c.fmobile,'') <> ''
{$dgrp_cnd} and ifnull(fansreceive,'') <> ''";
$result = $aobj_context->mobj_db->Execute($query);
}
else if($type == 'centre')
{
$query = "insert ignore into logisys3_comexam.sendsms(funivcode, fregno, fmobileno, fenttype, fsubcode, fmessage, fstatus, fdeleted, fyear, fexamtype,fupdate)
select distinct '{$univcode}', fmobile, fmobile, '{$entype}', '{$entype}',
'{$message}', 'F', 'F', dg.fyear,dg.fexamtype, NOW()
from {$db}.college c inner join {$db}.deggrp dg on dg.fdeggrp = '{$deggrp}'
inner join {$db}.degcntr dc on dg.fdeggrp = dc.fdeggrp and dc.fyear = dg.fyear
and dc.fexamtype = dg.fexamtype and c.fcollcode = dc.fexamcodet
where IFNULL(c.fdeleted,'') <> 'T' and IFNULL(c.fmobile,'') <> ''
{$dgrp_cnd}";
$result = $aobj_context->mobj_db->Execute($query);
}else if($fevent == 'ADA')
{
}
else
{
$query = "insert ignore into logisys3_comexam.sendsms(funivcode, fregno, fmobileno, fenttype, fsubcode, fmessage, fstatus, fdeleted, fyear, fexamtype,fupdate)
select distinct '{$univcode}', fmobile, fmobile, '{$entype}', '{$entype}',
'{$message}', 'F', 'F', '{$year}', '{$year_type}', NOW()
from {$db}.college
where IFNULL(fdeleted,'') <> 'T' and IFNULL(fmobile,'') <> ''
{$dgrp_cnd} {$cnd}";
//var_dump($query);
$result = $aobj_context->mobj_db->Execute($query);
}
// var_dump($result);
if($result)
{
// $res['data'] = $result;
$query = "update logisys3_comexam.dbname set fgenmsgno = fgenmsgno+1 where funivcode = '{$univcode}'";
$result = $aobj_context->mobj_db->Execute($query);
// echo $entype;
// return;
$res['sms'] = sendsms($aobj_context, $univcode, $entype, $stafmobile);
echo $aobj_context->mobj_output->ToJSONEnvelope($res,0,"success");
}
else
{
$arr['msg'] = 'Invalid Mobile No. / Password';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
}
}
function sendsms($aobj_context, $univcode, $entype, $stafmobile)
{
include("sendsmsbulk.php");
$query1 = "SET SESSION group_concat_max_len=10000000";
$result1 = $aobj_context->mobj_db->Execute($query1);
$query = "select funivcode, group_concat(concat('91', fmobileno)) as mobilenos,
fenttype, fmessage,fexamdate,
if(length(fmessage) > 160, ceiling(307/153), 1) as msg_cnt
from sendsms
where fmobileno is not null
and fstatus = 'F'
and fenttype = '{$entype}'
and funivcode = '{$univcode}'
group by funivcode, fmessage";
$result = $aobj_context->mobj_db->GetAll($query);
$qury = "select FSMSUSER, FSMSPASSWD, FSMSSENDID from dbname where funivcode = '{$univcode}'";
$res = $aobj_context->mobj_db->GetRow($qury);
$username = $res['FSMSUSER'];
$password = $res['FSMSPASSWD'];
$from = $res['FSMSSENDID'];
// var_dump($result);
// return true;
// $username = 'logisyhttp';
// $password = 'logisy@928';
// $from = 'UNISOL';
$category = 'bulk';
if($result)
{
$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);
$qury1 ="insert into smssum(funivcode, fprocdate, fstarttime, fstartcredits) values('{$univcode}',now(),now(),'{$smsremain}')";
$res1 = $aobj_context->mobj_db->Execute($qury1);
$last_id = $aobj_context->mobj_db->insert_id;
$table = "<table><tr><th>Sl. No.</th><th>Mobile No. </th><th>Status</th></tr>";
$j = 1;
foreach($result as $key => $row)
{
$rgBigArr = explode(',', $row['mobilenos']);
$rgSmallArr = array_chunk($rgBigArr,90);
$text = $row['fmessage'];
$msg_cnt = $row['msg_cnt'];
foreach($rgSmallArr as $key => $value)
{
$strTo = implode(',', $value);
$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[] = "('".$row['funivcode']."','".substr($mobnos[$i],2,11)."','".$errorcode[$i]."','".$final['guid']."','".$row['fenttype']."', DATE_FORMAT(NOW(),'%Y-%m-%d'), DATE_FORMAT(NOW(),'%T'),'".$row['fexamdate']."','{$msg_cnt}','{$last_id}')";
$rgTrimedMobs[$i] = substr($mobnos[$i],2,11);
$table .= "<tr><td>{$j}</td><td>{$rgTrimedMobs[$i]}</td>
<td>Sent. </td></tr>";
$j++;
}
$strInsertQuery = "insert into smslog(funivcode, fmobileno, freasoncode, fguid, fenttype, fackdate, facktime, fexamdate, fsmscnt, fprocid) values".implode(',',$rgInsert);
$result = $aobj_context->mobj_db->Execute($strInsertQuery);
$srtImplodedMobs = implode("','",$rgTrimedMobs);
$strUpdateQuery = "update sendsms set fstatus = 'T' where fenttype = '{$row['fenttype']}' and fmobileno in ('{$srtImplodedMobs}')";
$result = $aobj_context->mobj_db->Execute($strUpdateQuery);
}
//echo "Sms Sent.";
}
$response = sendsmaapibulk($username,$password,$from, $stafmobile ,$text,$category);
$table .= "</table>";
return $table;
}
}
function sendsmsotp($aobj_context)
{
include("sendsmsapi.php");
$to = $aobj_context->mobj_data["mobileno"];
$text = $aobj_context->mobj_data["msg"];
$qury = "select FSMSUSER, FSMSPASSWD, FSMSSENDID from logisys3_comexam.dbname where funivcode = '041'";
$result = $aobj_context->mobj_db->GetRow($qury);
$username = $result['FSMSUSER'];
$password = $result['FSMSPASSWD'];
$from = $result['FSMSSENDID'];
$category = '';
if($result)
{
$smsresp = sendsmaapi($username,$password,$from,$to,$text,$category);
echo $smsresp;
return;
}
}
function getSMSDet($aobj_context)
{
$univcode = $aobj_context->mobj_data["univcode"];
$qury = "select funivcode, fenttype, fmessage, sum(if(fstatus='T',1,0)) as fsent, sum(if(fstatus='F',1,0)) as ffpend,
count(fmobileno) as ftotal, date_format(fupdate,'%d/%m/%Y') as pushdate, fyear, fexamtype, fusertype,
if(date_format(fupdate, '%Y-%m-%d') > date_format(date_sub(now(), interval 3 DAY), '%Y-%m-%d'), 'T', 'F') as curdate
from sendsms where funivcode = '{$univcode}' and fmsgtype = 'G'
group by funivcode, fenttype
order by fupdate desc";
$result = $aobj_context->mobj_db->GetAll($qury);
if($result)
{
$arr['data'] = $result;
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success");
}
else
{
$arr['msg'] = 'No Deatils Found';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
}
}
function getNotificationDet($aobj_context)
{
$univcode = $aobj_context->mobj_data["univcode"];
$qury = "select funivcode, fenttype, ftitle, fbody, sum(if(fstatus='T',1,0)) as fsent, sum(if(fstatus='F',1,0)) as ffpend,
count(fmobileno) as ftotal, date_format(fpushdate,'%d/%m/%Y') as pushdate, fyear, fexamtype,
if(date_format(fpushdate, '%Y-%m-%d') = date_format(now(), '%Y-%m-%d'), 'T', 'F') as curdate
from pushnotif where funivcode = '{$univcode}'
and ifnull(fmobappid,'') <> '' and ifnull(fmsgtype,'') = 'G'
group by funivcode, fenttype
order by fpushdate desc";
// var_dump($qury);die();
$result = $aobj_context->mobj_db->GetAll($qury);
if($result)
{
$arr['data'] = $result;
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,0,"success");
}
else
{
$arr['msg'] = 'No Deatils Found';
echo $aobj_context->mobj_output->ToJSONEnvelope($arr,-1,"failure");
}
}
?>
|