-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpush2appid.php
More file actions
54 lines (46 loc) · 1.23 KB
/
push2appid.php
File metadata and controls
54 lines (46 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
include_once ("./db_functions.php");
$i_AppId = 0;
// Get arguments
if (isset($_GET["appid"]))
$i_AppId = $_GET["appid"];
if ($i_AppId == null)
$i_AppId = 0;
if (isset($_GET["msg"]))
$s_Msg = $_GET["msg"];
if ($s_Msg == null)
$s_Msg = "";
// Check on valid AppId
if (! is_numeric($i_AppId) || $i_AppId <= 0) {
echo "\r\nArgumentenfehler\r\n";
return (- 1);
}
// Get and check appid in database
$no_of_users = 0;
$db = new DB_Functions();
$user = $db->getUserByAppid($i_AppId); // Get web_ext_mobile_users.* where
// AppId
if ($user != false)
$no_of_users = mysql_num_rows($user);
if ($no_of_users <= 0) {
echo "\r\nApp_Id " . $i_AppId . " unbekannt!\r\n";
return (- 1);
}
// Get values
$row = mysql_fetch_array($user);
$RegId = $row["gcm_regid"];
if ($RegId == "" || $RegId == null) {
echo "\r\nGCM_RegId (" . $i_AppId . ") unbekannt!\r\n";
return (- 1);
}
include_once './gcm.php';
$gcm = new GCM();
$registration_ids = array($RegId);
$message = array("message" => $s_Msg);
$result = $gcm->send_notification($registration_ids, $message);
if ($result === FALSE) {
echo "\r\nPushNotification fehlgeschlagen!\r\n";
return (- 1);
}
return (1);
?>