-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathc2dm.php
More file actions
27 lines (24 loc) · 1.03 KB
/
c2dm.php
File metadata and controls
27 lines (24 loc) · 1.03 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
<?php
/**
* This PHP script is called form the Android application
* when the android application registers or deregisters a C2DM request.
*/
require_once('includes/config.php');
$c2dm_key = isset($_REQUEST['c2dm_key']) ? $_REQUEST['c2dm_key'] : false;
if($c2dm_key){
if(isset($_REQUEST['register'])){
// user is registering with c2dm.
// store their new entry in the db (if that key doesn't already exists)
$sql = "REPLACE INTO `c2dm` SET ";
$sql .= " `start_time` = '".time()."'";
$sql .= ", `end_time` = 0";
$sql .= ", `notify_type` = 1"; // 1 is door? maybe allow different notification levels down the track.
$sql .= ", `c2dm_key` = '".mysql_real_escape_string($c2dm_key)."'";
mysql_query($sql) or die(mysql_error());
echo 'registered.';
}else if(isset($_REQUEST['unregister'])){
$sql = "UPDATE `c2dm` SET `end_time` = '".time()."' WHERE c2dm_key = '".mysql_real_escape_string($c2dm_key)."'";
mysql_query($sql);
echo 'unregistered.';
}
}