Example #1
0
function getActiveSubscriber($msisdn)
{
    $data = R::find('users', 'mobile_number = :num', array('num' => appendCountryCode($msisdn)));
    return $data;
}
Example #2
0
$connect = mysql_connect($server, $username, $password);
$database = mysql_select_db($database);
$group = 10;
$today = strtotime(date('d-M-Y'));
$now = strtotime(date('d-m-Y H:i'));
//$subscribers = R::getAll('select mobile_number from users where subscription_period >= :today and group_id = :group', array(':today' => $today, ':group' => 10));
//$tip = R::find('tip', ' schedule_time = :date', array('date' => $date));
$query2 = "select * from tip where schedule_time <= '" . $now . "' and processed != 1";
$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)) {
        echo appendCountryCode($subscribers['user_phone']);
        echo '<br/>';
        echo $tip['gist'];
        echo '<br/>';
        //smsSender(appendCountryCode($subscribers['user_phone']), $tip['gist']);
    }
    $query3 = "update tip set processed = 1 where id = '" . $tip['id'] . "'";
    $result3 = mysql_query($query3) or die(mysql_error());
}
//echo $count;
function checkDestination($number)
{
    $first = substr($number, 0, 1);
    if ($first == '+') {
        return $number;
    } else {
#$database = 'm_health';
#local
$server = 'localhost';
$username = '******';
$password = '******';
$database = 'mhealth';
$connect = mysql_connect($server, $username, $password);
$database = mysql_select_db($database);
$now = date("Y-m-d h:i:s");
//echo $now;
$sql = "SELECT * FROM medication m join users u where m.users_id = u.id and m.end_date < '{$now}'";
$result = mysql_query($sql) or die(mysql_error());
while ($data = mysql_fetch_array($result)) {
    $msg = "";
    //smsSender(appendCountryCode($data['mobile_number']), $msg);
    echo appendCountryCode($data['mobile_number']) . "<br>";
}
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";
        //return false;