Пример #1
0
function deactivate($phone, $service)
{
    $users_phone = removePlus($phone);
    $data = R::findOne('users', ' mobile_number = :phone', array('phone' => $users_phone));
    //var_dump($data->id); exit;
    if (!$data) {
        $msg = "Sorry you are not a subscriber to any mHealth services. To subscribe text mhealth or the package name of your choice to 33121";
        //echo $msg;
        echo smsSender($phone, $msg);
        exit;
    }
    if ($service == '' || strtoupper($service) == "MHEALTH") {
        // R::exec("delete from users where id =" . $data->id);
        R::exec("delete from subscription where user_phone =" . $phone);
        $msg = "You have been stopped from all mHealth services. To re-subscribe text mhealth or the package name of your choice to 33121";
        //echo $msg;
        echo smsSender($phone, $msg);
        exit;
    }
    if (!($service == '' || strtoupper($service) == "MHEALTH")) {
        $cat_id = findUnsubcribeCategory($service);
        if ($cat_id != 0) {
            $sub_data = R::findOne('subscription', ' user_phone = :phone and category_id = :cat', array('phone' => $phone, 'cat' => $cat_id));
            if (!$sub_data) {
                $msg = "Sorry you are not a subscriber to {$service} category. To subscribe under this category, text {$service}  to 33121";
                //echo $msg;
                echo smsSender($phone, $msg);
                exit;
            } else {
                R::exec("delete from subscription where user_phone =" . $phone);
                $msg = "You have been stopped from  {$service} category on mHealth. To re-subscribe text mhealth or the package name of your choice to 33121";
                echo smsSender($phone, $msg);
                //echo $msg;
                exit;
            }
        } else {
            //$msg = "Sorry you are not a subscriber to $service category. To subscribe under this category, text $service  to 35123";
            $msg = "The category you want to subscribe for doest not exist on mHealth services";
            //echo $msg;
            echo smsSender($phone, $msg);
            exit;
        }
    }
    exit;
}
Пример #2
0
$mtn = array('234803', '234806', '234703', '234706', '234810', '234813', '234814', '234816');
$mtn2 = array('+234803', '+234806', '+234703', '+234706', '+234810', '+234813', '+234814', '+234816');
$etisalat = array('234809', '234817', '234818', '234909');
$etisalat2 = array('+234809', '+234817', '+234818', '+234909');
$airtel = array('234802', '234708', '234808', '234812');
$airtel2 = array('+234802', '+234708', '+234808', '+234812');
$query2 = "select * from tip where schedule_time <= '" . $now . "' and processed = 0";
$result2 = mysql_query($query2) or die(mysql_error());
//$tip = mysql_fetch_array($result2);
//var_dump($tip[2]); exit;
while ($tip = mysql_fetch_array($result2)) {
    $query = "select * from subscription where expire_date >= '" . $today . "' and category_id = '" . $tip['category_id'] . "'";
    $result = mysql_query($query) or die(mysql_error());
    while ($subscribers = mysql_fetch_array($result)) {
        if (array_search(substr($subscribers['user_phone'], 0, 6), $mtn) || array_search(substr($subscribers['user_phone'], 0, 7), $mtn2)) {
            smsSender(checkDestination($subscribers['user_phone']), $tip['gist']);
            echo $subscribers['user_phone'];
            echo '<br/>';
            echo $tip['gist'];
            echo '<br/>';
            echo '35123';
            echo '<br/>';
        } elseif (array_search(substr($subscribers['user_phone'], 0, 6), $etisalat) || array_search(substr($subscribers['user_phone'], 0, 7), $etisalat2)) {
            smsSender3(checkDestination($subscribers['user_phone']), $tip['gist']);
            echo $subscribers['user_phone'];
            echo '<br/>';
            echo $tip['gist'];
            echo '<br/>';
            echo '32126';
            echo '<br/>';
        } elseif (array_search(substr($subscribers['user_phone'], 0, 6), $airtel) || array_search(substr($subscribers['user_phone'], 0, 7), $airtel2)) {
Пример #3
0
<?php

set_include_path(dirname(__FILE__) . '/../lib' . PATH_SEPARATOR . dirname(__FILE__) . '/../lib/rb/' . PATH_SEPARATOR . get_include_path());
include_once 'rb.php';
include_once 'db.php';
include_once 'sms_sender.php';
$today = strtotime(date('d-M-Y'));
$subscribers = R::getAll('select mobile_number from users where subscription_period >= :today and group_id = :group', array(':today' => $today, ':group' => 10));
$date = strtotime(date('d-M-Y'));
$tip = R::find('tip', ' schedule_time = :date', array('date' => $date));
if ($tip) {
    $tip = array_shift($tip);
    foreach ($subscribers as $subscriber) {
        //echo $subscriber['mobile_number']; exit;
        smsSender(checkDestination($subscriber['mobile_number']), $tip->gist);
    }
}
//echo $count;
function checkDestination($number)
{
    $first = substr($number, 0, 1);
    if ($first == '+') {
        return $number;
    } else {
        return '+' . $number;
    }
}
Пример #4
0
    $bean->language = $_SESSION['language'];
    $bean->registration_completed = 1;
    $id = R::store($bean);
    $_SESSION['feedback_topic'] = "Registration Completed!";
    $_SESSION['text'] = "Thanks {$lastname} {$firstname}, you have been successfully registered on m-Health. Your Registration ID is " . $_SESSION['sub_id'];
    smsSender($sms_number, $_SESSION['text']);
    header("Location: ../feedback.php");
} elseif ($_SESSION['status'] == 1) {
    $_SESSION['feedback_topic'] = "Registration Has been Completed Before!";
    $_SESSION['text'] = "Thanks {$lastname} {$firstname}, you are already a registered user on m-Health";
    header("Location: ../feedback.php");
} elseif ($_SESSION['status'] == 2) {
    R::exec("update users set\n     first_name = '" . $firstname . "',\n         last_name = '" . $lastname . "',\n             email_addr = '" . $email . "',\n\t\t\t \t language_id = '" . $_SESSION['language'] . "',\n                 mobile_number = '" . $mobile_number . "',\n                     registration_completed = 1,\n                     reg_id = '" . $_SESSION['sub_id'] . "'\n                         where id ='" . $_SESSION['user_id'] . "'");
    $_SESSION['feedback_topic'] = "Registration Completed!";
    $_SESSION['text'] = "Thanks {$lastname} {$firstname}, you have been successfully registered on m-Health. Your Registration ID is " . $_SESSION['sub_id'];
    smsSender($sms_number, $_SESSION['text']);
    header("Location: ../feedback.php");
}
function smsSender($dnrr, $msg)
{
    $id = "m_health";
    $pw = "WKYoDDoCV";
    # ensure that you use the approved password on v2nmobile.
    $url = "http://v2nportal.com/sms/gateway/httpsend.php?U=" . urlencode($id) . "&P=" . urlencode($pw) . "&D=" . urlencode($dnrr) . "&S=" . urlencode("+35123") . "&M=" . urlencode($msg) . "&T=1";
    /* invocation of URL */
    if ($f = @fopen($url, "r")) {
        $answer = fgets($f, 255);
        //echo "<br>answer=$answer"; # remove this if you like
        return $answer;
    } else {
        return "gateway cannot be opened at the moment";