if (strlen($Phone) > 10) {
        // a 10 digit number, format as 1-800-555-5555
        $Phone = substr($Phone, 0, 1) . '.' . substr($Phone, 1, 3) . '.' . substr($Phone, 4, 3) . '.' . substr($Phone, 7, 4);
    } else {
        $Phone = substr($Phone, 0, 3) . '.' . substr($Phone, 3, 3) . '.' . substr($Phone, 5, 4);
    }
    return $Phone;
}
function phn_numb($Phone2)
{
    if (!is_numeric(substr($Phone2, 0, 1)) && !is_numeric(substr($Phone2, 1, 1))) {
        return $Phone2;
    }
    $chars = array(' ', '(', ')', '-', '.');
    $Phone = str_replace($chars, "", $Phone2);
    if (strlen($Phone2) > 10) {
        // a 10 digit number, format as 1-800-555-5555
        $Phone2 = substr($Phone2, 0, 1) . '-' . substr($Phone2, 1, 3) . '-' . substr($Phone2, 4, 3) . '-' . substr($Phone2, 7, 4);
    } else {
        $Phone2 = substr($Phone2, 0, 3) . '-' . substr($Phone2, 3, 3) . '-' . substr($Phone2, 5, 4);
    }
    return $Phone2;
}
$Phone = substr('+14357725684', 1);
$Phone2 = substr('19182932500', 0);
//$FormattedPhone = implode(' ',str_split($Phone));
//$phone_text = textPhone($Phone);
$phone_text = substr(phn_numb_dots($Phone), 2);
echo $phone_text . '<br>';
$sms_text = substr(phn_numb($Phone2), 2);
echo $sms_text . '<br>';
Beispiel #2
0
    if (strlen($Phone) > 10) {
        // a 10 digit number, format as 1-800-555-5555
        $Phone = substr($Phone, 0, 1) . '.' . substr($Phone, 1, 3) . '.' . substr($Phone, 4, 3) . '.' . substr($Phone, 7, 4);
    } else {
        $Phone = substr($Phone, 0, 3) . '.' . substr($Phone, 3, 3) . '.' . substr($Phone, 5, 4);
    }
    return $Phone;
}
$CallSid = $_POST['MessageSid'];
$CallStatus = $_POST['status'];
$From = $_POST['From'];
$To = $_POST['To'];
$twilio_appt_id = $_POST['appt_id'];
$return_message = strtolower($_POST['Body']);
$Phone = substr($From, 1);
$phone_dots = substr(phn_numb_dots($Phone), 2);
header("content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$sqlAppts = "SELECT id, user_phone, facility_name FROM appts\nWHERE phone = '" . $phone_dots . "' AND sms = 1\nAND FROM_UNIXTIME(call_time, '%Y-%m-%d') <= CURDATE()\nAND CURDATE() < FROM_UNIXTIME(start_appt, '%Y-%m-%d')\nORDER BY id DESC";
$resultAppts = mysqli_query($con, $sqlAppts);
$num_rows = 0;
//echo $sqlAppts;
while ($row = mysqli_fetch_assoc($resultAppts)) {
    $num_rows++;
    $id = $row['id'];
    $facility_name = $row['facility_name'];
    $user_phone = $row['user_phone'];
    switch ($return_message) {
        case "yes":
            $sqlUpdateAppt = "UPDATE {$tbl_appts} SET  `sms_status`= 'Confirmed' WHERE sms = 1 AND id = " . $id . "";
            $reply = "Your appointment has been confirmed.";