aboutsummaryrefslogtreecommitdiffstats
path: root/mod/ping.php
diff options
context:
space:
mode:
authormarijus <mario@localhost.localdomain>2014-01-30 00:08:40 +0100
committermarijus <mario@localhost.localdomain>2014-01-30 00:08:40 +0100
commita58239b9a8d8c35fa0e0b916617fa53d1014da58 (patch)
tree4ebaf732d319efb80d9edebd941fb0be9e35cc06 /mod/ping.php
parentb39475db86eca7b5e5615d377d8adc64e6a33056 (diff)
parentfe2b6f3dfb4a9473905dde49b7741a6c03699c23 (diff)
downloadvolse-hubzilla-a58239b9a8d8c35fa0e0b916617fa53d1014da58.tar.gz
volse-hubzilla-a58239b9a8d8c35fa0e0b916617fa53d1014da58.tar.bz2
volse-hubzilla-a58239b9a8d8c35fa0e0b916617fa53d1014da58.zip
Merge branch 'upstream'
Diffstat (limited to 'mod/ping.php')
-rw-r--r--mod/ping.php29
1 files changed, 29 insertions, 0 deletions
diff --git a/mod/ping.php b/mod/ping.php
index dda87dec2..2d5deb9ad 100644
--- a/mod/ping.php
+++ b/mod/ping.php
@@ -43,6 +43,35 @@ function ping_init(&$a) {
unset($_SESSION['sysmsg_info']);
}
+ if(get_observer_hash() && (! $result['invalid'])) {
+ $r = q("select cp_id, cp_room from chatpresence where cp_xchan = '%s' and cp_client = '%s'",
+ dbesc(get_observer_hash()),
+ dbesc($_SERVER['REMOTE_ADDR'])
+ );
+ $basic_presence = false;
+ if($r) {
+ foreach($r as $rr) {
+ if($rr['cp_room'] == 0)
+ $basic_presence = true;
+ q("update chatpresence set cp_last = '%s' where cp_id = %d limit 1",
+ dbesc(datetime_convert()),
+ intval($rr['cp_id'])
+ );
+ }
+ }
+ if(! $basic_presence) {
+ 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 3 MINUTE");
+
if((! local_user()) || ($result['invalid'])) {
echo json_encode($result);
killme();