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 : 18.116.47.194


Current Path : /proc/thread-self/root/var/www/html/admission/src/
Upload File :
Current File : //proc/thread-self/root/var/www/html/admission/src/sendsms_15022019.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"];
	$deggrp = $aobj_context->mobj_data["deggrp"];
	$stype = $aobj_context->mobj_data["stype"];
	$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'];
	$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";

	$year_type = $month <= 6 ? 1 : 2;

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


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

		$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
		{
			/*$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
	{
		$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,'') <> '' and INSTR(ffaculty,CONCAT('{$deggrp}','*')) {$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; 
	}
}

?>