<?php
set_time_limit(0);
include("config.php");
include("functionsTest.php");

$sqlsms="SELECT * FROM composeAPINEW WHERE sms_status = 'Pending' ORDER BY id ASC";
$querysms=mysqli_query($connect,$sqlsms);
if(mysqli_num_rows($querysms) > 0 ){
	while($row=mysqli_fetch_array($querysms))
	{
		
		//echo '<pre>';print_r($row['mask_name']);
	
		 if(strtolower($row['networkname']) == 'mobilink')
		 {
		 	$mask = $row['mask_name'];
		 	$number = $row['mobile_number'];
		 	$message = $row['message'];
			$password = urlencode('FaiRamUsman@1282aa');
			$message = urlencode($message);
			$mask = urlencode($mask);
			$number = urlencode($number);
		  //  echo "JAZZ<br>";

			$url = "https://connect.jazzcmt.com/sendsms_url.html?Username=03028503264&Password=".$password."&From=".$mask."&To=".$number."&Message=".$message."";
			$sqlInsertSMS="INSERT INTO sms_urls (sms_url,networkname,sms_status) Values('$url','mobilink','Pending')";
			echo $sqlInsertSMS."<br>";
			mysqli_query($connect,$sqlInsertSMS);
		 				
		 }
		

		 $smsID = $row["id"];
		 $sqlUpdateSMS="UPDATE composeAPINEW SET sms_status='Sent' where id='$smsID'";
		//$sqlUpdateSMS="DELETE FROM composeapi where id='$smsID'";
		$queryUpdateSMS=mysqli_query($connect,$sqlUpdateSMS);
				
}}							
?>
