Exemplo n.º 1
0
function smartpush($uid, $message)
{
    include "db_functions.php";
    include "gcm.php";
    $gcm = new GCM();
    $db = new DB_Functions();
    $users = $db->getAllUsers();
    if ($users != false) {
        $no_of_users = mysql_num_rows($users);
    } else {
        $no_of_users = 0;
    }
    if ($no_of_users > 0) {
        while ($row = mysql_fetch_array($users)) {
            $regId = $row['gcm_regid'];
            // $message = "สวัสดีชาวโลก";
            $registatoin_ids = array($regId);
            // $message = array("price" => $message);
            $result = $gcm->send_notification($registatoin_ids, $message);
            //echo $result;
        }
    } else {
        echo "ไม่มีข้อมูล";
    }
}
function updateRequestStatus()
{
    $userRequestID = trim($_REQUEST['user_request_id']);
    $requestStatus = trim($_REQUEST['status']);
    $lastInserted_payment_id = 0;
    $rm = new Response_Methods();
    if ($userRequestID == "" || $requestStatus == "") {
        $result = $rm->fields_validation();
        return $result;
    } else {
        if ($requestStatus == 'Accepted') {
            $fromBankID = $rm->idToValue('payment_from_bank_id', 'user_requests_t', 'user_request_id', $userRequestID);
            $toBankID = $rm->idToValue('payment_to_bank_id', 'user_requests_t', 'user_request_id', $userRequestID);
            $amount = $rm->idToValue('amount', 'user_requests_t', 'user_request_id', $userRequestID);
            $fromBankBalance = $rm->idToValue('initial_bank_balance', 'bank_details_t', 'bank_id', $fromBankID);
            $toBankBalance = $rm->idToValue('initial_bank_balance', 'bank_details_t', 'bank_id', $toBankID);
            if ($fromBankBalance < $amount) {
                $result = $rm->insufficient_balance();
                return $result;
            } else {
                if ($fromBankID != $toBankID) {
                    $fromBankBalance = $fromBankBalance - $amount;
                    $toBankBalance = $toBankBalance + $amount;
                }
                $updateFromBankBalance['initial_bank_balance'] = $fromBankBalance;
                $affectedRowsFrom = $rm->update_record($updateFromBankBalance, 'bank_details_t', 'bank_id', $fromBankID);
                $updateToBankBalance['initial_bank_balance'] = $toBankBalance;
                $affectedRowsTo = $rm->update_record($updateToBankBalance, 'bank_details_t', 'bank_id', $toBankID);
                $getInsertFieldValue['amount'] = $amount;
                $getInsertFieldValue['payment_from_bank_id'] = $fromBankID;
                $getInsertFieldValue['payment_to_bank_id'] = $toBankID;
                $getInsertFieldValue['user_request_id'] = $userRequestID;
                $lastInserted_payment_id = $rm->insert_record($getInsertFieldValue, 'payment_details_t');
                $login_user_id = $rm->idToValue('login_user_id', 'user_requests_t', 'user_request_id', $userRequestID);
                $gcm_regid = $rm->getUserGCMREGID($login_user_id);
                if ($gcm_regid != "" || $gcm_regid != "NA") {
                    $gcm = new GCM();
                    $registatoin_ids = array($gcm_regid);
                    $msg = "Request " . $requestStatus;
                    $message = array("Response" => $msg);
                    $resultPush = $gcm->send_notification($registatoin_ids, $message);
                }
                $getRegisterFieldValue['status'] = $requestStatus;
                $affectedRows = $rm->update_record($getRegisterFieldValue, 'user_requests_t', 'user_request_id', $userRequestID);
                if ($affectedRows >= 0) {
                    $result = $rm->requestStatusSuccess($lastInserted_payment_id);
                    return $result;
                } else {
                    $result = $rm->requestStatusFail();
                    return $result;
                }
            }
        }
    }
}
 function mailing() {
     $gcm = new GCM();
     file_put_contents('mylog.log',"  1----<br>_SEND NOTIFICATION_<br>----  ", FILE_APPEND);
     $result = $dbManager->query("SELECT * FROM `Users` WHERE id IN (SELECT idUser FROM `Сourier`)");
     
     while($row = $dbManager->fetch_assoc($result)) {
         $registatoin_ids = $row['registerId'];
         
         file_put_contents('mylog.log',"  2----<br>_SEND NOTIFICATION_<br>----  ", FILE_APPEND);
         $gcm->send_notification($registatoin_ids, "DEBUG");    
     }
     
             
 }
Exemplo n.º 4
0
function addUserRequest()
{
    //$companyId = $_REQUEST['companyId'];
    $login_user_id = trim($_REQUEST['userID']);
    $fromBankID = trim($_REQUEST['fromBankID']);
    $toBankID = trim($_REQUEST['toBankID']);
    //$paymentDate = trim($_REQUEST['paymentDate']);
    //$paymentReason = trim($_REQUEST['paymentReason']);
    $amount = trim($_REQUEST['amount']);
    $paymentType = trim($_REQUEST['paymentType']);
    $rm = new Response_Methods();
    if ($login_user_id == "" || $fromBankID == "" || $amount == "" || $paymentType == "") {
        $result = $rm->fields_validation();
        return $result;
    } else {
        date_default_timezone_set('Asia/Calcutta');
        $createdDate = date('Y-m-d H:i:s');
        $getList = array();
        //inserting payment details
        $getInsertFieldValue['login_user_id'] = $login_user_id;
        $companyID = $rm->idToValue('company_id', 'user_details_t', 'login_user_id', $login_user_id);
        $getInsertFieldValue['payment_from_bank_id'] = $fromBankID;
        $getInsertFieldValue['payment_to_bank_id'] = $toBankID;
        //$getInsertFieldValue['payment_date']=$paymentDate;
        //$getInsertFieldValue['payment_reason']=$paymentReason;
        $getInsertFieldValue['amount'] = $amount;
        $getInsertFieldValue['payment_type'] = $paymentType;
        $getInsertFieldValue['request_created_date'] = $createdDate;
        $getInsertFieldValue['company_id'] = $companyID;
        $lastInserted_user_request_id = $rm->insert_record($getInsertFieldValue, 'user_requests_t');
        if (!empty($lastInserted_user_request_id)) {
            //Do Transactions by updating bank current balance
            /* Sending Push Notification to Admin */
            $gcm_regid = $rm->getUserGCMREGID(2);
            if ($gcm_regid != "" || $gcm_regid != "NA") {
                $gcm = new GCM();
                $registatoin_ids = array($gcm_regid);
                $msg = "User Payment Request Made. Please Check";
                $message = array("Response" => $msg);
                $resultPush = $gcm->send_notification($registatoin_ids, $message);
            }
            $result = $rm->userRequestSuccessJson($lastInserted_user_request_id);
            return $result;
        } else {
            $result = $rm->userRequestFailJson();
            return $result;
        }
    }
}
Exemplo n.º 5
0
/**
 * Created by PhpStorm.
 * Date: 12/7/2015
 * Time: 12:30 PM
 * @param $regId
 * @param $account
 * @param $name
 * @return mixed
 * @throws InvalidParameterException
 */
function gcm_register($regId, $account, $name)
{
    if (!$account) {
        $response['status'] = 1;
        $response['result'] = 'please enter valid user account';
        return $response;
        exit;
    } else {
        $user = get_user_by_username($account);
        if (!$user) {
            throw new InvalidParameterException('registration:usernamenotvalid');
            $response['status'] = 1;
            $response['result'] = 'user account not valid';
            return $response;
            exit;
        }
    }
    // create the tables for API stats
    $path = elgg_get_plugins_path();
    run_sql_script($path . "elgg_with_rest_api/schema/mysql.sql");
    if ($account && $regId) {
        $elgg_post = 1;
        $elgg_message = 1;
        // Store user details in db
        include_once $path . 'elgg_with_rest_api/lib/DB_Register_Functions.php';
        include_once $path . 'elgg_with_rest_api/lib/GCM.php';
        $db = new DB_Register_Functions();
        $gcm = new GCM();
        if ($db->checkUser($regId)) {
            $res = $db->updateUser($name, $account, $regId, $elgg_post, $elgg_message);
            $response['status'] = 0;
            $response['result'] = "success update gcm regId and user info";
        } else {
            $res = $db->storeUser($name, $account, $regId, $elgg_post, $elgg_message);
            $registration_ids = array($regId);
            $message = array("from_name" => "Core Server", "subject" => "Core App Notification", "message" => "Enable Receive Notification");
            $result = $gcm->send_notification($registration_ids, $message);
            $response['status'] = 0;
            $response['result'] = "success Insert gcm regId and user info";
        }
    } else {
        // user details missing
        $response['status'] = 1;
        $response['result'] = 'Missing name or reg id';
    }
    return $response;
}
Exemplo n.º 6
0
function send_notification($status, $id)
{
    global $db;
    $gcm = new GCM();
    if ($status == 0 || $status == "0") {
        $query = "SELECT * FROM login,family WHERE member_id = '{$id}' AND id = family_id ";
        $result = $db->query_db($query);
        if ($db->number_of_rows($result) > 0) {
            while ($row = $db->fetch_array($result)) {
                $regId = $row["gcm_regId"];
                $message = " is in danger";
                $registatoin_ids = array($regId);
                $message = array("message" => $message, "id" => $id);
                $notification_result = $gcm->send_notification($registatoin_ids, $message);
            }
        } else {
            // no family members are found
        }
    }
}
Exemplo n.º 7
0
function distribusiSurat($db, $token, $id_surat, $subject, $tu, $tembusan, $nama_institusi)
{
    $tujuan = explode("@+id/", $tu);
    // explode dulu tujuannya
    $registration_ids = array();
    for ($i = 0; $i < count($tujuan); $i++) {
        if (!empty($tujuan[$i])) {
            //            echo $id_surat . " - " . $tujuan[$i] . " - " . $tembusan . " <br/>";
            kirimSurat($db, $id_surat, $tujuan[$i], $tembusan);
            if (!empty(pushNotification($db, $tujuan[$i]))) {
                $registration_ids = pushNotification($db, $tujuan[$i]);
            }
        }
    }
    if (count($registration_ids) > 0) {
        $gcm = new GCM();
        $pesan = array("message" => $subject, "title" => "Surat baru dari {$nama_institusi}", "msgcnt" => 1, "sound" => "beep.wav");
        $result = $gcm->send_notification($registration_ids, $pesan);
    } else {
        $result = '"Not a GCM User"';
    }
    echo '{"isUnreads": ' . countUnreads($token) . ', "isFavorites": ' . countFavorites($token) . ', "isUnsigned": ' . countUnsigned($token) . ', "result": ' . $result . '}';
    //    echo $result;
}
<?php

if (isset($_POST["title"]) && isset($_POST["message"])) {
    $title = $_POST["title"];
    $message = $_POST["message"];
    include_once './gcm.php';
    $gcm = new GCM();
    $result = $gcm->send_notification($title, $message);
    echo $result;
}
Exemplo n.º 9
0
 function send_pn_action()
 {
     $helper_obj = new Helper();
     if ($helper_obj->user_is_logged_in() && $helper_obj->check_role(SUPER_ADMIN_ROLE_ID)) {
         $db_functions_obj = new DbFunctions();
         $cid = $_POST['add_client'];
         $msg = $_POST['msg'];
         $client_info = $db_functions_obj->get_client_by_id($cid);
         $tokens = $db_functions_obj->get_tokens($cid);
         define("GOOGLE_API_KEY", $client_info->api);
         // Place your Google API Key
         include_once 'includes/classes/GCM.php';
         $gcm = new GCM();
         foreach ($tokens as $token) {
             $user_token = $token->token;
             $type = $token->type;
             //ios
             if ($type == 1) {
                 $pn_obj = new PushNotification();
                 $pn_obj->push_notification($msg, $user_token, 2, $client_info->pem);
             } else {
                 if ($type == 2) {
                     $m = array("message" => $msg);
                     $deviceId[] = $user_token;
                     $result = $gcm->send_notification($deviceId, $m);
                 }
             }
         }
         exit;
     }
 }
Exemplo n.º 10
0
<?php

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(-1);
if (isset($_GET["caseNum"])) {
    // include config
    include_once './db_functions.php';
    $title = $_GET["title"];
    $message = $_GET["message"];
    $caseNum = $_GET["caseNum"];
    $db = new DB_Functions();
    $regId = $db->getUserRegIdByCaseNum($caseNum);
    $regIdarr = array();
    array_push($regIdarr, $regId);
    include_once './GCM.php';
    $gcm = new GCM();
    $message = array("message" => $message, "title" => $title);
    $result = $gcm->send_notification($regIdarr, $message);
    echo $result;
}
Exemplo n.º 11
0
         if ($driver_gcm_id != '') {
             $gcm = new GCM();
             $user['Traveler_name'] = $user_name;
             $user['Traveler_mobile'] = $user_mobile;
             $user['Pickup_address'] = $user_location;
             $user['Travel_time'] = $user_time;
             $user['Vehicle_type'] = '';
             $user['From'] = $user_location;
             $user['To'] = '';
             $user['Trip_id'] = $id;
             $user['ridestatus'] = 'RideLater';
             $user['Packages'] = '';
             $notification['message'][] = $user;
             $notifications = json_encode($notification);
             $message = "Customer Name : {$user_name},Mobile : {$user_mobile},Pickup Location : {$user_location},Strat Time : {$user_time}";
             $gcm->send_notification(array($driver_gcm_id), $notifications);
         }
         $to = $user_email;
         $name = $user_name;
         $subject = "Trip Assign Confirmation";
         $message = "\n<html>\n<head>\n<title>HTML email</title>\n</head>\n<body>\n<table bgcolor='#F4F4F4' align='center' cellspacing='0' cellpadding='0' border='0' style='width:600px'>\n<tbody>\n<tr>\n<td width='600' style='border:1px solid #ccc;'>\n\n<table align='center' cellspacing='0' cellpadding='0' border='0' style='width:100%'>\n<tbody>\n<tr><td><a target='_blank' href='http://maruthicabs.com/images/logo.png'><img border='0' alt='maruthicabs' src='http://maruthicabs.com/images/logo.png' width='25%'height='60' style='padding:5px;'></a></td></tr>\n</tbody>\n</table>\n<table bgcolor='#ffffff' align='center' cellspacing='0' cellpadding='0' border='0' style='width:600px'>\n<tbody>\n<tr>\n<td height='32' align='center' colspan='2' style='background:#f0c004'>\n<a target='_blank' style='color:#fff;font-weight:bold; font-family:Arial; font-size:20px; text-decoration:none; padding:0px 15px'>Trip Assign Confirmation</a>\n</td>\n</tr>\n<tr>\n<td colspan='2' height='15'>&nbsp;</td>\n</tr>\n<tr>\n<td>\n<table cellspacing='0' cellpadding='0' border='0' style='width:600px'>\n<tbody>\n<tr>\n<td width='15' height='100%'>&nbsp;</td>\n<td valign='top'>\n\n<p style='margin-top:5px;font-family:Arial;color: #333;'>Dear {$name}, </p>\n<p style='margin-top:5px;font-family:Arial;color: #333;'>Thank you for choosing Maruthicabs for {$user_time}, Cab No: {$vehicle_reg}, Chauffer: {$drivername}, Cell: {$driver_number} will reach you.  Conditions Apply. </p>\n<div style='clear:both;'></div>\n<div style='clear:both;'></div>\n<p style='margin-top:15px; margin-bottom:2px;font-family:Arial;color: #333;'>Regards</p>\n\n<p style='margin-top:1px;font-family:Arial;color: #333;'>Maruthi Cabs Team</p>\n</td>\n<div style='clear:both;'></div>\n<td width='15' height='100%'>&nbsp;</td>\n</tr>\n\n<tr>\n<td colspan='2' height='15'>&nbsp;</td>\n</tr>\n</tbody>\n</table>\n</td>\n</tr>\n</tbody>\n</table>\n\n<table cellspacing='0' cellpadding='0' border='0' style='width:600px'>\n<tr>\n<td bgcolor='#f4f4f4' align='center' style='font-family:Arial;font-size:12px;line-height:20px; padding:10px 0px; color:#666;'>\n<span style='color:#6a6a6a'>\n&copy;2015, <a target='_blank' href='http://maruthicabs.com/'>Maruthi Cabs</a> All Rights Reserved. </span> <br>\n</td>\n</tr>\n</table>\n</td>\n</tr>\n</tbody>\n</table>\n</body>\n</html>\n";
         // Always set content-type when sending HTML email
         $headers = '';
         $headers .= 'MIME-Version: 1.0' . "\r\n";
         $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
         $headers .= 'From: Mcabs.ee<' . mcabs . '>' . "\r\n";
         $mail = mail($to, $subject, $message, $headers);
     } else {
         echo "<div class='admin_faile'>Assigned Failed.</div>";
     }
 } else {
<?php

if (isset($_GET["regId"]) && isset($_GET["message"])) {
    $regId = $_GET["regId"];
    $message = $_GET["message"];
    include_once './GCM.php';
    $gcm = new GCM();
    $registrationIds = [$regId];
    $message = ["price" => $message];
    $result = $gcm->send_notification($registrationIds, $message);
    echo $result;
}
Exemplo n.º 13
0
<?php

require_once "../php_include/config.php";
require_once "../GCM.php";
$reg_ids[] = 'APA91bGyIHXA78mAr9-Q4FxFBPxyQrQmMre5oWAnbchAID0_dLsegdHkgiuVhvIsCby72I6NLsU8bl5Pk6aCMO6vHecVSPNY8N9edY7pei41T6xMb4j6a0zfUc51GTEdZnajolPPgPEB';
if (!empty($reg_ids)) {
    $push_data = array('push_type' => '6', 'data' => array('message' => 'Dummy push to gcm user'));
    try {
        GCM::send_notification($reg_ids, $push_data);
    } catch (Exception $e) {
        //echo $e->getMessage();
    }
}
            }
            $result_sendername = mysqli_query($conn, "SELECT *  FROM usertable where userid='{$fromid}'") or die(mysql_error());
            if (mysqli_num_rows($result_sendername) > 0) {
                while ($row = $result_sendername->fetch_assoc()) {
                    $sender_name = $row['firstname'];
                    $sender_lname = $row['lastname'];
                    $logintype = $row['logintype'];
                }
            }
            $result = mysqli_query($conn, "SELECT * FROM usertable where userid='{$toid}'") or die(mysql_error());
            if (mysqli_num_rows($result) > 0) {
                while ($row = $result->fetch_assoc()) {
                    include_once './GCM.php';
                    $regId = $row["gcmid"];
                    $gcm = new GCM();
                    $registatoin_ids = array($regId);
                    $res = $gcm->send_notification($registatoin_ids, $message, $sender_name, $fromid, $sender_lname, $logintype, $chattype, $messagetype);
                }
                //end of while
            }
        } else {
            $response["success"] = "block";
            $response["message"] = "You can not message this user.";
            echo json_encode($response);
        }
    } else {
        $response["success"] = "false";
        $response["message"] = "User Not Logged in.";
        echo json_encode($response);
    }
}
Exemplo n.º 15
0
        }
        if ($_POST['func'] == "ejemplo_push") {
            //ejemplo push
            $extraData = array('notifType' => 'chat', 'perros_id' => $notif['perros_id'], 'amigos_usuarios_id' => $notif['usuario_id'], 'usuario_nombre' => $notif['amigos_nombre']);
            /*if($notif['goto'] == 'video'){
                  $notifMgs = "Hay empresas que te quieren conocer";
              }else{*/
            $notifMgs = "Purina Walk Chat " . $notif['nombre'] . ": " . $notif['mensaje'];
            //}
            //$notifMgs = utf8_decode($notif['notificacion'] . " " .$notif['descripcion']);
            //$notifMgs = "Hay empresas que te quieren conocer";
            if ($notif['plataforma'] != "") {
                if ($notif['plataforma'] == 'Android') {
                    //echo 'send notif android';
                    $GCM = new GCM();
                    $GCM->send_notification(array('0' => $notif['regid']), $notifMgs, $extraData);
                } else {
                    //echo 'send notif IOS';
                    /*$NOTIF_IOS = new NOTIF_IOS();
                      $NOTIF_IOS->send_notification( array('0' => $notif['regid']), $notifMgs, $extraData);*/
                }
            }
        }
        $response['arrayData']['id'] = @(string) $_POST['id'];
    }
    //send_emails(utf8_decode($emailContent), $emailSubject, unserialize(EMAIL_ADMIN_UR));
}
$responseJson = json_encode($response);
if (@$_POST['callback']) {
    echo $_POST['callback'] . "(" . $responseJson . ")";
} else {
Exemplo n.º 16
0
    $registration_ids[] = $list['token_id'];
}
//print_r($registration_ids);
//$message = array();
/*선행 조건 2016-03-08 (화)
여태까지 보낸 로그를 카운트 모바일에서 보낸 것을 합산 하여서 제한 갯수를 초과한 경우 보내지 않도록 설계

*/
include_once "./GCM.php";
$gcm = new GCM();
/* 자동 전송 crontab linux scheduler */
if ($mode == "crontab") {
    $messages = array("title" => $title, "message" => $message, "is_mms" => $is_mms, "receiver_num" => $receiver_num, "img_url" => $img_url);
    /*prq_gcm_log 발생*/
    //echo  $gcm->send_notification($registration_ids, $message);
    $push = json_decode($gcm->send_notification($registration_ids, $messages));
    $p_temp = $push->results[0]->message_id;
    $result = strpos($p_temp, "0:") !== false ? true : false;
    $result_msg = $result ? "전달 성공" : "전송 실패";
    $gc_ipaddr = '123.142.52.91';
    $sql = array();
    $sql[] = "INSERT INTO `prq_gcm_log` SET ";
    $sql[] = "gc_subject='" . $title . "',";
    $sql[] = "gc_content='" . $message . "',";
    $sql[] = "gc_ismms='" . $is_mms . "',";
    $sql[] = "gc_receiver='" . $receiver_num . "',";
    $sql[] = "gc_sender='" . $phone . "',";
    $sql[] = "gc_imgurl='" . $img_url . "',";
    $sql[] = "gc_result='" . $result_msg . "',";
    $sql[] = "gc_ipaddr='" . $gc_ipaddr . "',";
    $sql[] = "gc_stno='" . $st_no . "',";
<?php

require_once "../../../config.php";
require_once "../../../dist/class/class.connect.php";
require_once "../../../dist/functions/data.access.php";
$c_host = $databaselocation;
$c_user = $databaseuser;
$c_pass = $databasepass;
$c_db = $databasename;
session_start();
if (!isset($_SESSION["loged"])) {
    $html = file_get_contents("../../session_error.html");
    $html;
} else {
    $message = $_GET["message"];
    $gcm_regs = getGCMRegs();
    include_once './GCM.php';
    $gcm = new GCM();
    foreach ($gcm_regs as $regs) {
        $result = $gcm->send_notification($regs->reg_id, $message);
    }
    $result = TRUE;
    echo $result;
}
Exemplo n.º 18
0
                $sender = "Gray Routes";
            }
        }
        if ($_POST["username"] != "") {
            if (isset($_POST["username"])) {
                $username = $_POST["username"];
                $recipients = $db->getUserByUserName($username);
                $sender = "Gray Routes personal message for ";
            }
        } else {
            $username = "";
        }
        if (isset($_POST["sender"])) {
            $sender = $_POST["sender"];
        }
        if ($recipients != false) {
            while ($row = mysql_fetch_array($recipients)) {
                $regId = $row["gcm_regid"];
                require_once 'GCM.php';
                $gcm = new GCM();
                $registration_ids = array($regId);
                $content = array("sender" => $sender, "message" => $message, "user" => $username);
                $result = $gcm->send_notification($registration_ids, $content);
                echo $result;
            }
        }
    }
}
?>
</body>
</html>		
Exemplo n.º 19
0
<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
if (isset($_GET["regId"]) && isset($_GET["message"])) {
    $regId = $_GET["regId"];
    $message = $_GET["message"];
    include_once './GCM.php';
    $gcm = new GCM();
    $registation_ids = array($regId);
    $message = array("price" => $message);
    $result = $gcm->send_notification($registation_ids, $message);
    echo $result;
}
 public function Send_Individual_Notice($gcm_keys, $police_ids, $messages_real)
 {
     include_once 'GCM.php';
     $gcm = new GCM();
     $regIds = $gcm_keys;
     //"APA91bEoMfb2ci7vwp2ssqUgEERfYrG2H-a5DzE5_bVkngNS_yiJDsEO17gEBRT-VjTHGV0E2XZHhZKd7pmhGXlieiEB2868f3vg7XvwJMHINFrY4B7EjVq0bMYQSkNQOays1hQCk_fp";
     $registatoin_idss = array($regIds);
     $messages = $messages_real;
     $messages = array("message" => $messages);
     //modifying a little below
     $result = $gcm->send_notification($registatoin_idss, $messages);
     $this->Add_Notice_To_Database_With_Id($messages_real, $police_ids);
 }
Exemplo n.º 21
0
    //echo $query;
    $result = mysqli_query($connection, $query);
    testForQuery($result);
    //calculate distance
    $query = "SELECT Latitude, Longitude FROM gcm_users WHERE 1";
    $result = mysqli_query($connection, $query);
    testForQuery($result);
    $count = 0;
    while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
        $latTo = $row["Latitude"];
        $longTo = $row["Longitude"];
        $distances[$count] = calculateDistance($latitude, $longitude, $latTo, $longTo);
        $count++;
    }
    sort($distances);
    $distanceArray = array("First" => $distances[0]);
    echo json_encode($distanceArray);
    /*here we send the information to registered police mobiles*/
    include_once './GCM.php';
    $gcm = new GCM();
    $query = "SELECT * FROM gcm_users WHERE 1";
    $result = mysqli_query($connection, $query);
    testForQuery($result);
    $message = "A " . $race . " " . $sex . " " . "with " . $height . " build has been reported to be involved in a " . $category . " at " . $address . "\n\n" . "Reported Description: " . $description . "\n\n" . "Reported Vehicle#: " . $vehicle_no;
    while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
        $registatoin_ids = array($row["gcm_regid"]);
        $message1 = array("alert" => $message, "addr" => $address);
        $sendResult = $gcm->send_notification($registatoin_ids, $message1);
    }
    mysqli_close($connection);
}
Exemplo n.º 22
0
        if (count($regs) > 0) {
            print "mORE THEN ONE USER <br>";
            include_once './GCM.php';
            $gcm = new GCM();
            $result = $gcm->send_notification($regs, array("price" => $xml));
            decodeResult($result, $regs, $con);
            unset($gcm);
        }
        //header( 'Location:' . PROJECT_URL . 'index.php?message=The%20Message%20Was%20Sent');
        exit;
        die;
    }
    print "Less then one thounsend  users [" . count($registatoin_ids) . "]<br>";
    include_once './GCM.php';
    $gcm = new GCM();
    $result = $gcm->send_notification($registatoin_ids, array("price" => $xml));
    print "The message decoades <br>";
    //header( 'Location:' . PROJECT_URL . 'index.php?message=The%20Message%20Was%20Sent');
    echo "Sent Successfully <br>";
}
function getFileExtension($filename)
{
    $ext = explode(".", $filename);
    $ext = end($ext);
    return strtolower($ext);
}
function loadImage($filename)
{
    $ext = getFileExtension($filename);
    print "Load Image " . $ext . " === " . $filename . "<br>";
    switch ($ext) {
Exemplo n.º 23
0
function mensajes($Ids, $mas, $emisor, $receptor)
{
    global $ipServ;
    $gcm = new GCM();
    $Ids = array($Ids);
    $mes = array("mensaje" => $mas);
    $res = $gcm->send_notification($Ids, $mes);
    $obj['Emisor'] = $emisor;
    $obj['Receptor'] = $receptor;
    $obj['Mensaje'] = $mas;
    $data = array('idusr' => $receptor, 'idjefe' => $emisor, 'mensaje' => $mas);
    //	$obj['dataServicio']=$data;
    $response = curl("POST", 'telmex/add/mensaje', $data);
    if ($response === FALSE) {
        $obj['Error'] == 'Error al conectarse al servicio para agregar mensaje';
    } else {
        //		$obj['response']=$response;
        if ($res->failure == 0) {
            $obj['success'] = $res->success;
            $obj['multicast_id'] = $res->multicast_id;
            $obj['failure'] = $res->failure;
            $obj['canonical_ids'] = $res->canonical_ids;
            $obj['message_id'] = $res->results[0]->message_id;
        } else {
            if ($res->failure == 1) {
                $obj['errorMessage'] = 'La API de Google devolvió un error';
                $obj['success'] = $res->success;
                $obj['multicast_id'] = $res->multicast_id;
                $obj['failure'] = $res->failure;
                $obj['canonical_ids'] = $res->canonical_ids;
                $obj['error'] = $res->results[0]->error;
            }
        }
    }
    return $obj;
}
Exemplo n.º 24
0
<?php

require_once './GCM.php';
if (isset($_POST["message"]) && isset($_POST["regid"])) {
    $message = $_POST["message"];
    $regId = $_POST["regid"];
    $timestamp = date("Y-m-d H:i:s");
    $msg = array('message' => $message, 'timestamp' => $timestamp);
    $ids = array();
    array_push($ids, $regId);
    // You can send message to 10 ids in one request.
    //Push all(max 10) reg ids to $ids array.
    $gcm = new GCM();
    $response = $gcm->send_notification($ids, $msg);
    echo "Notification sent.";
} else {
    echo 'Invalid data';
}
Exemplo n.º 25
0
function send_android_push($user_id, $message, $title)
{
    require_once 'gcm/GCM_1.php';
    /* require_once 'gcm/const.php'; */
    if (!isset($user_id) || empty($user_id)) {
        $registatoin_ids = "0";
    } else {
        $registatoin_ids = trim($user_id);
    }
    if (!isset($message) || empty($message)) {
        $msg = "Message not set";
    } else {
        $msg = trim($message);
    }
    if (!isset($title) || empty($title)) {
        $title1 = "Message not set";
    } else {
        $title1 = trim($title);
    }
    /* $message = array(TEAM => $title1, MESSAGE => $msg); */
    $message = array('team' => $title1, 'message' => $msg);
    $gcm = new GCM();
    $registatoin_ids = array($registatoin_ids);
    $gcm->send_notification($registatoin_ids, $message);
}
Exemplo n.º 26
0
     } catch (Exception $e) {
     }
 } else {
     $sql = "INSERT into user_like(id,liked_by,liked_to,status,created_on) values(DEFAULT,:user_id,:user_id2,:status,NOW())";
     $sth = $conn->prepare($sql);
     $sth->bindValue('user_id', $user_id);
     $sth->bindValue('user_id2', $user_id2);
     $sth->bindValue('status', $flag);
     try {
         $sth->execute();
         $success = "1";
         $msg = "Status Updated";
         if ($new_match) {
             if ($other_like_status == '1' && ($flag = '1')) {
                 if (!empty($reg_ids)) {
                     GCM::send_notification($reg_ids, $message);
                 }
                 if (!empty($apnid)) {
                     try {
                         $apns->newMessage($apnid);
                         $apns->addMessageAlert($message['msg']);
                         $apns->addMessageSound('x.wav');
                         $apns->addMessageCustom('u', $user_id);
                         $apns->addMessageCustom('t', $message['type']);
                         //$apns->addMessageCustom('x', $profile_pic);
                         $apns->queueMessage();
                         $apns->processQueue();
                     } catch (Exception $e) {
                     }
                 }
             }
 }
 $businesses = array_map('massage', $businesses);
 // Get all devices registration IDs
 foreach ($businesses as $business) {
     if ($business->meta['os_type'] == 'android' && $business->meta['business_id'] == $postid) {
         $android_devices[] = $business->meta['registration_id'];
     } elseif ($business->meta['os_type'] == 'ios' && $business->meta['business_id'] == $postid) {
         $ios_devices[] = $business->meta['registration_id'];
     }
 }
 // Send Push notification to Android devices
 if (count($android_devices) > 0) {
     $gcm = new GCM();
     $msg_body = $coupon_biz_name . ': Use coupon code ' . $_POST['coupon_code'] . ' to avail ' . $_POST['coupon_desc'] . ' on ' . $_POST['coupon_start_date'] . ' to  ' . $_POST['coupon_end_date'];
     $message = array('message' => $msg_body);
     $result = $gcm->send_notification($android_devices, $message);
 }
 // Send Push notification to iOS
 if (count($ios_devices) > 0) {
     $message = $coupon_biz_name . ': Use coupon code ' . $_POST['coupon_code'] . ' to avail ' . $_POST['coupon_desc'] . ' on ' . $_POST['coupon_start_date'] . ' to  ' . $_POST['coupon_end_date'];
     $ctx = stream_context_create();
     stream_context_set_option($ctx, 'ssl', 'local_cert', 'Vintelli.pem');
     stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
     stream_context_set_option($ctx, 'ssl', 'cafile', 'entrust_2048_ca.cer');
     // Open a connection to the APNS server
     // ssl://gateway.sandbox.push.apple.com:2195
     // ssl://gateway.push.apple.com:2195
     $fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, $ctx);
     if (!$fp) {
         exit("Failed to connect: {$err} {$errstr}" . PHP_EOL);
     }
Exemplo n.º 28
0
<?php

include 'classes/gcm.php';
$GCM = new GCM();
$user_data = json_decode(file_get_contents('php://input'));
$message = $user_data->message;
$gcm_id = $user_data->gcm_regid;
$ev = $user_data->event->project_name;
$ev_id = $user_data->event->event_id;
$GCM->send_notification($gcm_id, $message, $ev, $ev_id);
Exemplo n.º 29
0
<?php

if (isset($_GET["regId"]) && isset($_GET["message"])) {
    $regId = $_GET["regId"];
    $message = $_GET["message"];
    include_once 'GCM.php';
    $gcm = new GCM();
    $registatoin_ids = array($regId);
    $mensaje = array('message' => $message, 'title' => 'PushNotification', 'msgcnt' => '3', 'timeToLive' => 3000);
    $result = $gcm->send_notification($registatoin_ids, $mensaje);
    echo $result;
}
Exemplo n.º 30
0
function send_android_push($user_id, $title, $message, $id, $url)
{
    require_once 'gcm/GCM_1.php';
    require_once 'gcm/const.php';
    if (!isset($user_id) || empty($user_id)) {
        $registatoin_ids = "0";
    } else {
        $registatoin_ids = trim($user_id);
    }
    if (!isset($message) || empty($message)) {
        $msg = "Message not set";
    } else {
        $msg = trim($message);
    }
    if (!isset($title) || empty($title)) {
        $title1 = "Message not set";
    } else {
        $title1 = trim($title);
    }
    $message = array('title' => $title1, 'message' => $msg, 'url' => $url, 'single_id' => $id);
    $gcm = new GCM();
    $registatoin_ids = array($registatoin_ids);
    $gcm->send_notification($registatoin_ids, $message);
    //Log::info($gcm);
}