aboutsummaryrefslogtreecommitdiffstats
path: root/mod/ping.php
diff options
context:
space:
mode:
authorRedMatrix <info@friendica.com>2014-11-14 08:52:38 +1100
committerRedMatrix <info@friendica.com>2014-11-14 08:52:38 +1100
commit9132a1c1954bcdeb3a7356212e2c8982e5878bbd (patch)
treeaa7002d73dbcd4136033589f1cb135184f4126c1 /mod/ping.php
parent109cb936632c693d3f24afb9e2ce533797ad1a7f (diff)
parentac27db22c18ee7a82a52cbadb3efe2760b910499 (diff)
downloadvolse-hubzilla-9132a1c1954bcdeb3a7356212e2c8982e5878bbd.tar.gz
volse-hubzilla-9132a1c1954bcdeb3a7356212e2c8982e5878bbd.tar.bz2
volse-hubzilla-9132a1c1954bcdeb3a7356212e2c8982e5878bbd.zip
Merge pull request #690 from habeascodice/master
Initial postgres support
Diffstat (limited to 'mod/ping.php')
-rw-r--r--mod/ping.php34
1 files changed, 18 insertions, 16 deletions
diff --git a/mod/ping.php b/mod/ping.php
index e52c162ec..d7b9e3d2e 100644
--- a/mod/ping.php
+++ b/mod/ping.php
@@ -107,7 +107,7 @@ function ping_init(&$a) {
$basic_presence = false;
if($r) {
$basic_presence = true;
- q("update chatpresence set cp_last = '%s' where cp_id = %d limit 1",
+ q("update chatpresence set cp_last = '%s' where cp_id = %d",
dbesc(datetime_convert()),
intval($r[0]['cp_id'])
);
@@ -128,7 +128,9 @@ function ping_init(&$a) {
* and shouldn't count as online anymore. We allow an expection for bots.
*/
- q("delete from chatpresence where cp_last < UTC_TIMESTAMP() - INTERVAL 3 MINUTE and cp_client != 'auto' ");
+ q("delete from chatpresence where cp_last < %s - INTERVAL %s and cp_client != 'auto' ",
+ db_utcnow(), db_quoteinterval('3 MINUTE')
+ );
if((! local_user()) || ($result['invalid'])) {
echo json_encode($result);
@@ -148,14 +150,14 @@ function ping_init(&$a) {
if(x($_REQUEST, 'markRead') && local_user()) {
switch($_REQUEST['markRead']) {
case 'network':
- $r = q("update item set item_flags = ( item_flags ^ %d ) where (item_flags & %d) and uid = %d",
+ $r = q("update item set item_flags = ( item_flags & ~%d ) where (item_flags & %d)>0 and uid = %d",
intval(ITEM_UNSEEN),
intval(ITEM_UNSEEN),
intval(local_user())
);
break;
case 'home':
- $r = q("update item set item_flags = ( item_flags ^ %d ) where (item_flags & %d) and (item_flags & %d) and uid = %d",
+ $r = q("update item set item_flags = ( item_flags & ~%d ) where (item_flags & %d)>0 and (item_flags & %d) and uid = %d",
intval(ITEM_UNSEEN),
intval(ITEM_UNSEEN),
intval(ITEM_WALL),
@@ -163,7 +165,7 @@ function ping_init(&$a) {
);
break;
case 'messages':
- $r = q("update mail set mail_flags = ( mail_flags ^ %d ) where channel_id = %d and not (mail_flags & %d)",
+ $r = q("update mail set mail_flags = ( mail_flags | %d ) where channel_id = %d and not (mail_flags & %d)>0",
intval(MAIL_SEEN),
intval(local_user()),
intval(MAIL_SEEN)
@@ -197,17 +199,17 @@ function ping_init(&$a) {
);
if($t && intval($t[0]['total']) > 49) {
$z = q("select * from notify where uid = %d
- and seen = 0 order by date desc limit 0, 50",
+ and seen = 0 order by date desc limit 50",
intval(local_user())
);
}
else {
$z1 = q("select * from notify where uid = %d
- and seen = 0 order by date desc limit 0, 50",
+ and seen = 0 order by date desc limit 50",
intval(local_user())
);
$z2 = q("select * from notify where uid = %d
- and seen = 1 order by date desc limit 0, %d",
+ and seen = 1 order by date desc limit %d",
intval(local_user()),
intval(50 - intval($t[0]['total']))
);
@@ -235,8 +237,8 @@ function ping_init(&$a) {
if(argc() > 1 && argv(1) === 'messages') {
$channel = $a->get_channel();
$t = q("select mail.*, xchan.* from mail left join xchan on xchan_hash = from_xchan
- where channel_id = %d and not ( mail_flags & %d ) and not (mail_flags & %d )
- and from_xchan != '%s' order by created desc limit 0,50",
+ where channel_id = %d and not ( mail_flags & %d )>0 and not (mail_flags & %d )>0
+ and from_xchan != '%s' order by created desc limit 50",
intval(local_user()),
intval(MAIL_SEEN),
intval(MAIL_DELETED),
@@ -265,7 +267,7 @@ function ping_init(&$a) {
$result = array();
$r = q("SELECT * FROM item
- WHERE item_restrict = %d and ( item_flags & %d ) and uid = %d",
+ WHERE item_restrict = %d and ( item_flags & %d )>0 and uid = %d",
intval(ITEM_VISIBLE),
intval(ITEM_UNSEEN),
intval(local_user())
@@ -287,7 +289,7 @@ function ping_init(&$a) {
if(argc() > 1 && (argv(1) === 'intros')) {
$result = array();
- $r = q("SELECT * FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and (abook_flags & %d) and not ((abook_flags & %d) or (xchan_flags & %d))",
+ $r = q("SELECT * FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and (abook_flags & %d)>0 and not ((abook_flags & %d)>0 or (xchan_flags & %d)>0)",
intval(local_user()),
intval(ABOOK_FLAG_PENDING),
intval(ABOOK_FLAG_SELF|ABOOK_FLAG_IGNORED),
@@ -371,7 +373,7 @@ function ping_init(&$a) {
if($vnotify & (VNOTIFY_NETWORK|VNOTIFY_CHANNEL)) {
$r = q("SELECT id, item_restrict, item_flags FROM item
- WHERE (item_restrict = %d) and ( item_flags & %d ) and uid = %d",
+ WHERE (item_restrict = %d) and ( item_flags & %d )>0 and uid = %d",
intval(ITEM_VISIBLE),
intval(ITEM_UNSEEN),
intval(local_user())
@@ -398,7 +400,7 @@ function ping_init(&$a) {
$t2 = dba_timer();
if($vnotify & VNOTIFY_INTRO) {
- $intr = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and (abook_flags & %d) and not ((abook_flags & %d) or (xchan_flags & %d))",
+ $intr = q("SELECT COUNT(abook.abook_id) AS total FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash where abook_channel = %d and (abook_flags & %d)>0 and not ((abook_flags & %d)>0 or (xchan_flags & %d)>0)",
intval(local_user()),
intval(ABOOK_FLAG_PENDING),
intval(ABOOK_FLAG_SELF|ABOOK_FLAG_IGNORED),
@@ -416,7 +418,7 @@ function ping_init(&$a) {
if($vnotify & VNOTIFY_MAIL) {
$mails = q("SELECT count(id) as total from mail
- WHERE channel_id = %d AND not (mail_flags & %d) and from_xchan != '%s' ",
+ WHERE channel_id = %d AND not (mail_flags & %d)>0 and from_xchan != '%s' ",
intval(local_user()),
intval(MAIL_SEEN),
dbesc($channel['channel_hash'])
@@ -427,7 +429,7 @@ function ping_init(&$a) {
if($vnotify & VNOTIFY_REGISTER) {
if ($a->config['system']['register_policy'] == REGISTER_APPROVE && is_site_admin()) {
- $regs = q("SELECT count(account_id) as total from account where (account_flags & %d)",
+ $regs = q("SELECT count(account_id) as total from account where (account_flags & %d)>0",
intval(ACCOUNT_PENDING)
);
if($regs)