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.22.42.25


Current Path : /proc/thread-self/root/var/www/html/univadmin_bkp/univadmin/src/
Upload File :
Current File : //proc/thread-self/root/var/www/html/univadmin_bkp/univadmin/src/sendsms_27012018.php

<?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"];
	$univcode = $aobj_context->mobj_data["univcode"];
	date_default_timezone_set('Asia/Kolkata');
	$year =  date("Y");
	$month =  date("m");

	// select
	$query = "";
	$query = "select funivcode, funivname, fdbname, fstaffmobileno, fgenmsgno
	from dbname 
	where funivcode = '{$univcode}'";
	$result = $aobj_context->mobj_db->GetRow($query);

	$db = $result['fdbname'];
	$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')
		$cnd = "and fcollcode = fthcntr";
	$type = $month <= 6 ? 1 : 2;

	$message = '['.$msgno.']'.$message;

	$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}', '{$type}', NOW() 
	from {$db}.college  
	where IFNULL(fdeleted,'') <> 'T' and IFNULL(fmobile,'') <> '' {$cnd}";	

	$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);

		$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 
	from sendsms 
	where fmobileno is not null
	and fstatus = 'F'
	and fenttype = '{$entype}'
	and funivcode = '{$univcode}'
	group by  funivcode, fmessage";
	// var_dump($query);
	$result = $aobj_context->mobj_db->GetAll($query);
	// var_dump($result);
	// return true;
	$username = 'logisyhttp';
	$password = 'Logis986';
	$from = 'UNISOL';
	$category = 'bulk';

	if($result)
	{
		$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'];

			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']."')";
					$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) 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; 
	}
}

?>