function sendSMS($countryCode, $phoneNo, $phoneCode) { global $site_address; $trunk_msg = "Your Activation Phone code is: " . $phoneCode; $x = sendToTrunkSMS($site_address, $phoneNo, $trunk_msg); if ($x) { return 1; } else { return 0; } }
function sendSMS($phone, $smsname, $smsMessage) { //a recursive function that sends more that one pages to one user global $conn, $units; $message = substr($smsMessage, 0, 160); //send 1 message $result = sendToTrunkSMS($smsname, $phone, $smsMessage); //returns bool if ($result) { //this section represents clickAtel $units = $units - 1; $sql = "UPDATE TRUNKregistration SET `SMSunits` = '{$units}' WHERE `TRUNKregistration`.`phoneNo` = '{$_SESSION['phoneNo']}' "; if (!mysql_query($sql)) { $_SESSION['message'] .= "<p>Unable to process your account information Please contact Us</p><br/>"; } else { $_SESSION['balance'] = $_SESSION['balance'] - 1; } ++$_SESSION['no']; $_SESSION['message'] .= "<p>Sending SMS to " . urldecode($phone) . " " . "Was a Success" . "</p>"; //session based log $sentStatus = 1; } else { //log error message. Cannot connect to www.trunksms.com $_SESSION['message'] .= "<p>Sending SMS to " . $phone . " Failed </p><br/>"; $sentStatus = 0; } //////////////////////////////////////////////////////////////////////// $status_msg = htmlentities($_SESSION['message']); $sql = "INSERT INTO TRUNKsent (`id`, `org`, `phoneNo`, `toNum`, `mesg`, `fromNa`, `units`, `statusMsg`, `date`, `sent`) VALUES (NULL, '{$_SESSION['name']}', '{$_SESSION['phoneNo']}', '{$phone}', '{$smsMessage}', '{$smsname}', '{$units}', '{$status_msg}', NOW(), '{$sentStatus}')"; $result = @mysql_query($sql); ///////////////////////////////////////////////////////////////// $nextMesg = trim(str_replace($message, "", $smsMessage)); $count = strlen($nextMesg); if ($count > 0 && $units > 0) { sendSMS($phone, $smsname, $nextMesg); //a recursive call } unset($result, $units, $count, $smsMessage, $message); }