aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-01-28 15:52:54 -0800
committerfriendica <info@friendica.com>2014-01-28 15:52:54 -0800
commit6e22aa25cc941f542a192ef32a2e8ee4f23bb1c1 (patch)
tree28abbc98f92287321dbbca75db9e62de53f39b92 /mod
parent8c8be2a05e7646595b2c811dd4ab2ac7d7a98b69 (diff)
downloadvolse-hubzilla-6e22aa25cc941f542a192ef32a2e8ee4f23bb1c1.tar.gz
volse-hubzilla-6e22aa25cc941f542a192ef32a2e8ee4f23bb1c1.tar.bz2
volse-hubzilla-6e22aa25cc941f542a192ef32a2e8ee4f23bb1c1.zip
basic presence indication
Diffstat (limited to 'mod')
-rw-r--r--mod/ping.php25
1 files changed, 25 insertions, 0 deletions
diff --git a/mod/ping.php b/mod/ping.php
index dda87dec2..b9ecf9b41 100644
--- a/mod/ping.php
+++ b/mod/ping.php
@@ -43,6 +43,31 @@ function ping_init(&$a) {
unset($_SESSION['sysmsg_info']);
}
+ if(get_observer_hash() && (! $result['invalid'])) {
+ $r = q("select cp_id from chatpresence where cp_xchan = '%s'",
+ dbesc(get_observer_hash())
+ );
+ if($r) {
+ foreach($r as $rr) {
+ q("update chatpresence set cp_last = '%s' where cp_id = %d limit 1",
+ intval($rr['cp_id'])
+ );
+ }
+ }
+ else {
+ q("insert into chatpresence ( cp_xchan, cp_last, cp_status, cp_client)
+ values( '%s', '%s', '%s', '%s' ) ",
+ dbesc(get_observer_hash()),
+ dbesc(datetime_convert()),
+ dbesc('online'),
+ dbesc($_SERVER['REMOTE_ADDR'])
+ );
+ }
+ }
+
+ q("delete from chatpresence where cp_last < UTC_TIMESTAMP() - INTERVAL 2 MINUTE");
+
+
if((! local_user()) || ($result['invalid'])) {
echo json_encode($result);
killme();