SMS Sent SMS# 2827


11)
{
$mtable=”mcore_send_sms”;
}
*/
//end checking pending sms and setting modem table

//start checking time difference
$sqlquery1=”select sent_stamp from “. $mtable . ” where sender_ip='” . $_SERVER[‘REMOTE_ADDR’] . “‘ order by _id desc limit 1”;
$result1=mysql_query($sqlquery1);
while($row = mysql_fetch_array($result1)){
$starttime=strtotime($row[‘sent_stamp’]);
}
mysql_free_result($result1);
$endtime=time();
$diff=$endtime – $starttime;
//end checking time difference

//start checking interval of 45 seconds and setting flag on error
if ($diff<45)
{
$errcode=1; //error code 1 represent more waiting
}
//end checking interval of 45 seconds and setting flag on error

//start checking prefix and setting an error flag
if ($prefix!=03)
{
$errcode=2; //error code 2 represent invalid prefix
}
//end checking prefix and setting an error flag

//start checking recepient address length
if ($digits!=11)
{
$errcode=3; //error code 3 represent invalid recipient length
}
//end checking recepient address length

if ($errcode==0){
//$trimsms = utf8_decode($_SESSION[sms_text]);
$trimsms = $_SESSION[sms_text];
$trimsms = substr($trimsms, 0, 280);
//start appending from in footer and taking length after adding from
$frm=substr($_SESSION[‘sender’], 0, 11);
$trimsms .= “\nFrom:”;
$trimsms .= $frm;
$smslen=strlen($trimsms);
$smscount=1;
if ($smslen>159){
$smscount=2;
}
//end appending from in footer and taking length after adding from

//start appending advertisement message after checking length
switch ($smslen) {
case $smslen<=95:
$admsg = “\nSend free sms to any number in Pakistan,\nVisit smsjan.com”;
break;
case $smslen<=110:
$admsg = “\nVisit smsjan.com to send free SMS from web”;
break;
case $smslen<=122:
$admsg = “\nVisit smsjan.com for free web2sms”;
break;
case $smslen<=140:
$admsg = “\nVisit smsjan.com”;
break;
default :
$admsg=”\n smsjan.com”;
break;
}
if (admsg==””){
$admsg=”[smsjan.com]”;
}
$ref=$_SERVER[‘HTTP_REFERER’];
$chkurl2=!strstr($txtreferrer,’smsjan.com’);
if($chkurl2==0)
{
$admsg=”\nsmsjan.com”;
}
$trimsms .= $admsg;
//end appending from in footer and taking length after adding from

//start making and executing query to insert record for adding into query
$sqlquery=”insert into ” . $mtable . ”
(sender, sender_ip, sms_type, sms_to, sms_text, sent_stamp,referrer,sms_count)
values
(‘”. $frm .”‘, ‘”. $_SERVER[‘REMOTE_ADDR’] .”‘,” . $sms_type . “, ‘” . $to . “‘, ‘” . $trimsms . “‘, ‘”. date(“y/m/d : H:i:s”, time()).”‘, ‘” . $txtreferrer .”‘, ‘” . $smscount . “‘)”;
mysql_query($sqlquery);
//end of query query to insert record for adding into query
mysql_close($conn1);
}

switch ($errcode) {
case 0:
echo ““;
echo “SMS successfully sent to ” .$to ;
echo “
“;
break;
case 1:
$w8=45 – $diff;
echo “You cannot send more than
1 SMS every 45 seconds.
Please wait ” . $w8 . ” seconds, and try again.
“;
break;
case 2:
echo ““;
echo “Invalid recipient number.
” ;
echo “Please remove country code (if any).
” ;
echo “Please remove dashes(hypen) (if any).
” ;
echo “
“;
break;
case 3:
echo ““;
echo “Invalid recipient number.
” ;
echo “Recipient number must be 11 digits long.
” ;
echo “
“;
break;
case 4:
echo ““;
echo “Recipient number blocked
” ;
echo “Recipient chosen not to receive SMS.
” ;
echo “
“;
break;
default:
echo ““;
echo “Error sending SMS.
” ;
echo “
“;
break;
}
}
?>

Leave a Reply