Ejemplo 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 "ไม่มีข้อมูล";
    }
}
Ejemplo n.º 2
0
function usersList()
{
    $db = new DB_Functions();
    $users = $db->getAllUsers();
    if ($users != false) {
        $no_of_users = mysql_num_rows($users);
    } else {
        $no_of_users = 0;
    }
    echo '<li><a >All</a></li>';
    if ($no_of_users > 0) {
        while ($row = mysql_fetch_array($users)) {
            echo '<li><a >' . $row["Name"] . '</a></li>';
        }
    } else {
        echo '<li>No Users Registered Yet!</li>';
    }
}
            ul.devices li .send_btn{
                background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#0096FF), to(#005DFF));
                background: -webkit-linear-gradient(0% 0%, 0% 100%, from(#0096FF), to(#005DFF));
                background: -moz-linear-gradient(center top, #0096FF, #005DFF);
                background: linear-gradient(#0096FF, #005DFF);
                text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
                border-radius: 3px;
                color: #fff;
            }
        </style>
    </head>
    <body>
        <?php 
include_once 'funciones.php';
$db = new DB_Functions();
$users = $db->getAllUsers();
if ($users != false) {
    $no_of_users = mysql_num_rows($users);
} else {
    $no_of_users = 0;
}
?>
        <div class="container">
            <h1>N° de dispositivos registrados: <?php 
echo $no_of_users;
?>
</h1>
            <hr/>
            <ul class="devices">
                <?php 
if ($no_of_users > 0) {
Ejemplo n.º 4
0
         $response["user"]["name"] = $user["name"];
         $response["user"]["email"] = $user["email"];
         $response["user"]["username"] = $user["username"];
         $response["user"]["phone"] = $user["phone"];
         $response["user"]["lat"] = $user["lat"];
         $response["user"]["longi"] = $user["lng"];
         echo json_encode($response);
     } else {
         // User not found
         // echo JSON with error
         $response["error"] = 1;
         echo json_encode($response);
     }
 } else {
     if ($tag == 'getContacts') {
         while ($user = $db->getAllUsers()) {
             $res["use"]["username"] = $user["username"];
             $res["use"]["latitude"] = $user["lat"];
             $res["use"]["longitude"] = $user["lng"];
             $response["user"][] = $res;
         }
         $response["success"] = 1;
         echo json_encode($response);
     } else {
         if ($tag == 'getGpsData') {
             $phone = $_POST['phone'];
             // Check for User
             $user = $db->getGpsData($phone);
             if ($user != false) {
                 // user found
                 // echo JSON with Success
Ejemplo n.º 5
0
// response json
$json = array();
/**
 * Registering a user device
 * Store reg id in users table
 */
if (isset($_POST["name"]) && isset($_POST["email"]) && isset($_POST["regId"])) {
    $name = $_POST["name"];
    $email = $_POST["email"];
    $gcm_regid = $_POST["regId"];
    // GCM Registration ID
    // Store user details in db
    include_once './db_functions.php';
    include_once './GCM.php';
    $db = new DB_Functions();
    $gcm = new GCM();
    $allUser = $db->getAllUsers();
    while ($row = mysql_fetch_assoc($allUser)) {
        if ($gcm_regid == $row['gcm_regid']) {
            exit;
        }
    }
    $res = $db->storeUser($name, $email, $gcm_regid);
    $registatoin_ids = array($gcm_regid);
    //$message = array("product" => "shirt");
    $message = "앱이 성공적으로 설치되었습니다.";
    $result = $gcm->send_notification($registatoin_ids, $message);
    echo $result;
} else {
    // user details missing
}
Ejemplo n.º 6
0
    <title>Gray Routes GCM</title>
    <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
    <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css">

    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
      <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>
<div class = "container">
<center>
        <?php 
require_once 'db_functions.php';
$db = new DB_Functions();
$users = $db->getAllUsers();
$email = $db->getAllUsersEmail();
$name = $db->getAllUsers();
if ($users != false) {
    $no_of_users = mysql_num_rows($users);
} else {
    $no_of_users = 0;
}
?>
            <h1>Devices Registered: <?php 
echo $no_of_users;
?>
</h1>
            <hr/>
            <?php 
if ($no_of_users > 0) {