diff --git a/Zotlabs/Module/Events.php b/Zotlabs/Module/Events.php index 2bff4676e..b709cd1f4 100644 --- a/Zotlabs/Module/Events.php +++ b/Zotlabs/Module/Events.php @@ -336,7 +336,7 @@ class Events extends \Zotlabs\Web\Controller { /* edit/create form */ if($event_id) { - $r = q("SELECT * FROM `event` WHERE event_hash = '%s' AND `uid` = %d LIMIT 1", + $r = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1", dbesc($event_id), intval(local_channel()) ); @@ -545,8 +545,8 @@ class Events extends \Zotlabs\Web\Controller { ); } elseif($export) { $r = q("SELECT * from event where uid = %d - AND (( `adjust` = 0 AND ( `dtend` >= '%s' or nofinish = 1 ) AND `dtstart` <= '%s' ) - OR ( `adjust` = 1 AND ( `dtend` >= '%s' or nofinish = 1 ) AND `dtstart` <= '%s' )) ", + AND (( adjust = 0 AND ( dtend >= '%s' or nofinish = 1 ) AND dtstart <= '%s' ) + OR ( adjust = 1 AND ( dtend >= '%s' or nofinish = 1 ) AND dtstart <= '%s' )) ", intval(local_channel()), dbesc($start), dbesc($finish), @@ -694,7 +694,7 @@ class Events extends \Zotlabs\Web\Controller { } if($mode === 'drop' && $event_id) { - $r = q("SELECT * FROM `event` WHERE event_hash = '%s' AND `uid` = %d LIMIT 1", + $r = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1", dbesc($event_id), intval(local_channel()) ); diff --git a/Zotlabs/Module/Group.php b/Zotlabs/Module/Group.php index 291566c6d..646310356 100644 --- a/Zotlabs/Module/Group.php +++ b/Zotlabs/Module/Group.php @@ -34,7 +34,7 @@ class Group extends \Zotlabs\Web\Controller { if((argc() == 2) && (intval(argv(1)))) { check_form_security_token_redirectOnErr('/group', 'group_edit'); - $r = q("SELECT * FROM `groups` WHERE `id` = %d AND `uid` = %d LIMIT 1", + $r = q("SELECT * FROM groups WHERE id = %d AND uid = %d LIMIT 1", intval(argv(1)), intval(local_channel()) ); @@ -48,7 +48,7 @@ class Group extends \Zotlabs\Web\Controller { $public = intval($_POST['public']); if((strlen($groupname)) && (($groupname != $group['gname']) || ($public != $group['visible']))) { - $r = q("UPDATE `groups` SET `gname` = '%s', visible = %d WHERE `uid` = %d AND `id` = %d", + $r = q("UPDATE groups SET gname = '%s', visible = %d WHERE uid = %d AND id = %d", dbesc($groupname), intval($public), intval(local_channel()), @@ -101,7 +101,7 @@ class Group extends \Zotlabs\Web\Controller { check_form_security_token_redirectOnErr('/group', 'group_drop', 't'); if(intval(argv(2))) { - $r = q("SELECT `gname` FROM `groups` WHERE `id` = %d AND `uid` = %d LIMIT 1", + $r = q("SELECT gname FROM groups WHERE id = %d AND uid = %d LIMIT 1", intval(argv(2)), intval(local_channel()) ); @@ -133,7 +133,7 @@ class Group extends \Zotlabs\Web\Controller { if((argc() > 1) && (intval(argv(1)))) { require_once('include/acl_selectors.php'); - $r = q("SELECT * FROM `groups` WHERE `id` = %d AND `uid` = %d AND `deleted` = 0 LIMIT 1", + $r = q("SELECT * FROM groups WHERE id = %d AND uid = %d AND deleted = 0 LIMIT 1", intval(argv(1)), intval(local_channel()) ); @@ -212,7 +212,7 @@ class Group extends \Zotlabs\Web\Controller { group_rmv_member(local_channel(),$group['gname'],$member['xchan_hash']); } - $r = q("SELECT abook.*, xchan.* FROM `abook` left join xchan on abook_xchan = xchan_hash WHERE `abook_channel` = %d AND abook_self = 0 and abook_blocked = 0 and abook_pending = 0 and xchan_deleted = 0 order by xchan_name asc", + $r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d AND abook_self = 0 and abook_blocked = 0 and abook_pending = 0 and xchan_deleted = 0 order by xchan_name asc", intval(local_channel()) ); diff --git a/Zotlabs/Module/Lockview.php b/Zotlabs/Module/Lockview.php index d86a3c1d8..7d1d8a43f 100644 --- a/Zotlabs/Module/Lockview.php +++ b/Zotlabs/Module/Lockview.php @@ -102,7 +102,7 @@ class Lockview extends \Zotlabs\Web\Controller { stringify_array_elms($deny_users,true); if(count($allowed_groups)) { - $r = q("SELECT gname FROM `groups` WHERE hash IN ( " . implode(', ', $allowed_groups) . " )"); + $r = q("SELECT gname FROM groups WHERE hash IN ( " . implode(', ', $allowed_groups) . " )"); if($r) foreach($r as $rr) $l[] = '
  • ' . $rr['gname'] . '
  • '; @@ -121,7 +121,7 @@ class Lockview extends \Zotlabs\Web\Controller { } } if(count($deny_groups)) { - $r = q("SELECT gname FROM `groups` WHERE hash IN ( " . implode(', ', $deny_groups) . " )"); + $r = q("SELECT gname FROM groups WHERE hash IN ( " . implode(', ', $deny_groups) . " )"); if($r) foreach($r as $rr) $l[] = '
  • ' . $rr['gname'] . '
  • '; diff --git a/Zotlabs/Module/Manage.php b/Zotlabs/Module/Manage.php index ec9ef4c06..3b7b3c3dd 100644 --- a/Zotlabs/Module/Manage.php +++ b/Zotlabs/Module/Manage.php @@ -93,9 +93,9 @@ class Manage extends \Zotlabs\Web\Controller { $channels[$x]['mail'] = intval($mails[0]['total']); - $events = q("SELECT etype, dtstart, adjust FROM `event` - WHERE `event`.`uid` = %d AND dtstart < '%s' AND dtstart > '%s' and `dismissed` = 0 - ORDER BY `dtstart` ASC ", + $events = q("SELECT etype, dtstart, adjust FROM event + WHERE event.uid = %d AND dtstart < '%s' AND dtstart > '%s' and dismissed = 0 + ORDER BY dtstart ASC ", intval($channels[$x]['channel_id']), dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now + 7 days')), dbesc(datetime_convert('UTC', date_default_timezone_get(), 'now - 1 days')) diff --git a/Zotlabs/Module/Setup.php b/Zotlabs/Module/Setup.php index 88481b4b1..99535b31b 100644 --- a/Zotlabs/Module/Setup.php +++ b/Zotlabs/Module/Setup.php @@ -211,7 +211,7 @@ class Setup extends \Zotlabs\Web\Controller { $db_return_text .= $txt; } if(\DBA::$dba && \DBA::$dba->connected) { - $r = q("SELECT COUNT(*) as `total` FROM `account`"); + $r = q("SELECT COUNT(*) as total FROM account"); if($r && count($r) && $r[0]['total']) { $tpl = get_markup_template('install.tpl'); return replace_macros($tpl, array( diff --git a/include/event.php b/include/event.php index 153654120..cbee2b759 100644 --- a/include/event.php +++ b/include/event.php @@ -362,28 +362,28 @@ function event_store_event($arr) { // The event changed. Update it. - $r = q("UPDATE `event` SET - `edited` = '%s', - `dtstart` = '%s', - `dtend` = '%s', - `summary` = '%s', - `description` = '%s', - `location` = '%s', - `etype` = '%s', - `adjust` = %d, - `nofinish` = %d, - `event_status` = '%s', - `event_status_date` = '%s', - `event_percent` = %d, - `event_repeat` = '%s', - `event_sequence` = %d, - `event_priority` = %d, - `event_vdata` = '%s', - `allow_cid` = '%s', - `allow_gid` = '%s', - `deny_cid` = '%s', - `deny_gid` = '%s' - WHERE `id` = %d AND `uid` = %d", + $r = q("UPDATE event SET + edited = '%s', + dtstart = '%s', + dtend = '%s', + summary = '%s', + description = '%s', + location = '%s', + etype = '%s', + adjust = %d, + nofinish = %d, + event_status = '%s', + event_status_date = '%s', + event_percent = %d, + event_repeat = '%s', + event_sequence = %d, + event_priority = %d, + event_vdata = '%s', + allow_cid = '%s', + allow_gid = '%s', + deny_cid = '%s', + deny_gid = '%s' + WHERE id = %d AND uid = %d", dbesc($arr['edited']), dbesc($arr['dtstart']), diff --git a/include/group.php b/include/group.php index 10853ff6b..39a907336 100644 --- a/include/group.php +++ b/include/group.php @@ -14,11 +14,11 @@ function group_add($uid,$name,$public = 0) { // access lists. What we're doing here is reviving the dead group, but old content which // was restricted to this group may now be seen by the new group members. - $z = q("SELECT * FROM `groups` WHERE `id` = %d LIMIT 1", + $z = q("SELECT * FROM groups WHERE id = %d LIMIT 1", intval($r) ); if(($z) && $z[0]['deleted']) { - /*$r = q("UPDATE `groups` SET `deleted` = 0 WHERE `uid` = %d AND `gname` = '%s' LIMIT 1", + /*$r = q("UPDATE groups SET deleted = 0 WHERE uid = %d AND gname = '%s' LIMIT 1", intval($uid), dbesc($name) );*/ @@ -32,13 +32,13 @@ function group_add($uid,$name,$public = 0) { $dups = false; $hash = random_string() . $name; - $r = q("SELECT id FROM `groups` WHERE hash = '%s' LIMIT 1", dbesc($hash)); + $r = q("SELECT id FROM groups WHERE hash = '%s' LIMIT 1", dbesc($hash)); if($r) $dups = true; } while($dups == true); - $r = q("INSERT INTO `groups` ( hash, uid, visible, gname ) + $r = q("INSERT INTO groups ( hash, uid, visible, gname ) VALUES( '%s', %d, %d, '%s' ) ", dbesc($hash), intval($uid), @@ -57,7 +57,7 @@ function group_add($uid,$name,$public = 0) { function group_rmv($uid,$name) { $ret = false; if(x($uid) && x($name)) { - $r = q("SELECT id, hash FROM `groups` WHERE `uid` = %d AND `gname` = '%s' LIMIT 1", + $r = q("SELECT id, hash FROM groups WHERE uid = %d AND gname = '%s' LIMIT 1", intval($uid), dbesc($name) ); @@ -102,13 +102,13 @@ function group_rmv($uid,$name) { } // remove all members - $r = q("DELETE FROM `group_member` WHERE `uid` = %d AND `gid` = %d ", + $r = q("DELETE FROM group_member WHERE uid = %d AND gid = %d ", intval($uid), intval($group_id) ); // remove group - $r = q("UPDATE `groups` SET `deleted` = 1 WHERE `uid` = %d AND `gname` = '%s'", + $r = q("UPDATE groups SET deleted = 1 WHERE uid = %d AND gname = '%s'", intval($uid), dbesc($name) ); @@ -125,7 +125,7 @@ function group_rmv($uid,$name) { function group_byname($uid,$name) { if((! $uid) || (! strlen($name))) return false; - $r = q("SELECT * FROM `groups` WHERE `uid` = %d AND `gname` = '%s' LIMIT 1", + $r = q("SELECT * FROM groups WHERE uid = %d AND gname = '%s' LIMIT 1", intval($uid), dbesc($name) ); @@ -138,7 +138,7 @@ function group_byname($uid,$name) { function group_rec_byhash($uid,$hash) { if((! $uid) || (! strlen($hash))) return false; - $r = q("SELECT * FROM `groups` WHERE `uid` = %d AND `hash` = '%s' LIMIT 1", + $r = q("SELECT * FROM groups WHERE uid = %d AND hash = '%s' LIMIT 1", intval($uid), dbesc($hash) ); @@ -153,7 +153,7 @@ function group_rmv_member($uid,$name,$member) { return false; if(! ( $uid && $gid && $member)) return false; - $r = q("DELETE FROM `group_member` WHERE `uid` = %d AND `gid` = %d AND xchan = '%s' ", + $r = q("DELETE FROM group_member WHERE uid = %d AND gid = %d AND xchan = '%s' ", intval($uid), intval($gid), dbesc($member) @@ -173,7 +173,7 @@ function group_add_member($uid,$name,$member,$gid = 0) { if((! $gid) || (! $uid) || (! $member)) return false; - $r = q("SELECT * FROM `group_member` WHERE `uid` = %d AND `gid` = %d AND `xchan` = '%s' LIMIT 1", + $r = q("SELECT * FROM group_member WHERE uid = %d AND gid = %d AND xchan = '%s' LIMIT 1", intval($uid), intval($gid), dbesc($member) @@ -183,7 +183,7 @@ function group_add_member($uid,$name,$member,$gid = 0) { // we indicate success because the group member was in fact created // -- It was just created at another time if(! $r) - $r = q("INSERT INTO `group_member` (`uid`, `gid`, `xchan`) + $r = q("INSERT INTO group_member (uid, gid, xchan) VALUES( %d, %d, '%s' ) ", intval($uid), intval($gid), @@ -198,9 +198,9 @@ function group_add_member($uid,$name,$member,$gid = 0) { function group_get_members($gid) { $ret = array(); if(intval($gid)) { - $r = q("SELECT * FROM `group_member` - LEFT JOIN abook ON abook_xchan = `group_member`.`xchan` left join xchan on xchan_hash = abook_xchan - WHERE `gid` = %d AND abook_channel = %d and `group_member`.`uid` = %d and xchan_deleted = 0 and abook_self = 0 and abook_blocked = 0 and abook_pending = 0 ORDER BY xchan_name ASC ", + $r = q("SELECT * FROM group_member + LEFT JOIN abook ON abook_xchan = group_member.xchan left join xchan on xchan_hash = abook_xchan + WHERE gid = %d AND abook_channel = %d and group_member.uid = %d and xchan_deleted = 0 and abook_self = 0 and abook_blocked = 0 and abook_pending = 0 ORDER BY xchan_name ASC ", intval($gid), intval(local_channel()), intval(local_channel()) @@ -232,7 +232,7 @@ function mini_group_select($uid,$group = '') { $grps = array(); $o = ''; - $r = q("SELECT * FROM `groups` WHERE `deleted` = 0 AND `uid` = %d ORDER BY `gname` ASC", + $r = q("SELECT * FROM groups WHERE deleted = 0 AND uid = %d ORDER BY gname ASC", intval($uid) ); $grps[] = array('name' => '', 'hash' => '0', 'selected' => ''); @@ -271,7 +271,7 @@ function group_side($every="connections",$each="group",$edit = false, $group_id ); - $r = q("SELECT * FROM `groups` WHERE `deleted` = 0 AND `uid` = %d ORDER BY `gname` ASC", + $r = q("SELECT * FROM groups WHERE deleted = 0 AND uid = %d ORDER BY gname ASC", intval($_SESSION['uid']) ); $member_of = array(); @@ -328,7 +328,7 @@ function expand_groups($a) { $groups = implode(',', $x); if($groups) - $r = q("SELECT xchan FROM group_member WHERE gid IN ( select id from `groups` where hash in ( $groups ))"); + $r = q("SELECT xchan FROM group_member WHERE gid IN ( select id from groups where hash in ( $groups ))"); $ret = array(); if($r) @@ -340,7 +340,7 @@ function expand_groups($a) { function member_of($c) { - $r = q("SELECT `groups`.`gname`, `groups`.`id` FROM `groups` LEFT JOIN `group_member` ON `group_member`.`gid` = `groups`.`id` WHERE `group_member`.`xchan` = '%s' AND `groups`.`deleted` = 0 ORDER BY `groups`.`gname` ASC ", + $r = q("SELECT groups.gname, groups.id FROM groups LEFT JOIN group_member ON group_member.gid = groups.id WHERE group_member.xchan = '%s' AND groups.deleted = 0 ORDER BY groups.gname ASC ", dbesc($c) ); @@ -350,7 +350,7 @@ function member_of($c) { function groups_containing($uid,$c) { - $r = q("SELECT `gid` FROM `group_member` WHERE `uid` = %d AND `group_member`.`xchan` = '%s' ", + $r = q("SELECT gid FROM group_member WHERE uid = %d AND group_member.xchan = '%s' ", intval($uid), dbesc($c) ); diff --git a/include/socgraph.php b/include/socgraph.php index 4cb5600ec..69365f80f 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -245,10 +245,10 @@ function common_friends($uid,$xchan,$start = 0,$limit=100000000,$shuffle = false function count_common_friends_zcid($uid,$zcid) { - $r = q("SELECT count(*) as `total` - FROM `glink` left join `gcontact` on `glink`.`gcid` = `gcontact`.`id` - where `glink`.`zcid` = %d - and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 ) ", + $r = q("SELECT count(*) as total + FROM glink left join gcontact on glink.gcid = gcontact.id + where glink.zcid = %d + and gcontact.nurl in (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 ) ", intval($zcid), intval($uid) ); @@ -264,12 +264,12 @@ function common_friends_zcid($uid,$zcid,$start = 0, $limit = 9999,$shuffle = fal if($shuffle) $sql_extra = " order by rand() "; else - $sql_extra = " order by `gcontact`.`name` asc "; + $sql_extra = " order by gcontact.name asc "; - $r = q("SELECT `gcontact`.* - FROM `glink` left join `gcontact` on `glink`.`gcid` = `gcontact`.`id` - where `glink`.`zcid` = %d - and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 ) + $r = q("SELECT gcontact.* + FROM glink left join gcontact on glink.gcid = gcontact.id + where glink.zcid = %d + and gcontact.nurl in (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 ) $sql_extra limit %d offset %d", intval($zcid), intval($uid), @@ -283,9 +283,9 @@ function common_friends_zcid($uid,$zcid,$start = 0, $limit = 9999,$shuffle = fal function count_all_friends($uid,$cid) { - $r = q("SELECT count(*) as `total` - FROM `glink` left join `gcontact` on `glink`.`gcid` = `gcontact`.`id` - where `glink`.`cid` = %d and `glink`.`uid` = %d ", + $r = q("SELECT count(*) as total + FROM glink left join gcontact on glink.gcid = gcontact.id + where glink.cid = %d and glink.uid = %d ", intval($cid), intval($uid) ); @@ -299,10 +299,10 @@ function count_all_friends($uid,$cid) { function all_friends($uid,$cid,$start = 0, $limit = 80) { - $r = q("SELECT `gcontact`.* - FROM `glink` left join `gcontact` on `glink`.`gcid` = `gcontact`.`id` - where `glink`.`cid` = %d and `glink`.`uid` = %d - order by `gcontact`.`name` asc LIMIT %d OFFSET %d ", + $r = q("SELECT gcontact.* + FROM glink left join gcontact on glink.gcid = gcontact.id + where glink.cid = %d and glink.uid = %d + order by gcontact.name asc LIMIT %d OFFSET %d ", intval($cid), intval($uid), intval($limit), @@ -319,7 +319,7 @@ function suggestion_query($uid, $myxchan, $start = 0, $limit = 80) { if((! $uid) || (! $myxchan)) return array(); - $r = q("SELECT count(xlink_xchan) as `total`, xchan.* from xchan + $r = q("SELECT count(xlink_xchan) as total, xchan.* from xchan left join xlink on xlink_link = xchan_hash where xlink_xchan in ( select abook_xchan from abook where abook_channel = %d ) and not xlink_link in ( select abook_xchan from abook where abook_channel = %d ) @@ -339,7 +339,7 @@ function suggestion_query($uid, $myxchan, $start = 0, $limit = 80) { if($r && count($r) >= ($limit -1)) return $r; - $r2 = q("SELECT count(xlink_link) as `total`, xchan.* from xchan + $r2 = q("SELECT count(xlink_link) as total, xchan.* from xchan left join xlink on xlink_link = xchan_hash where xlink_xchan = '' and not xlink_link in ( select abook_xchan from abook where abook_channel = %d ) @@ -465,11 +465,11 @@ function poco($a,$extended = false) { $sql_extra = sprintf(" and abook_id = %d and abook_hidden = 0 ",intval($cid)); if($system_mode) { - $r = q("SELECT count(*) as `total` from abook where abook_self = 1 + $r = q("SELECT count(*) as total from abook where abook_self = 1 and abook_channel in (select uid from pconfig where cat = 'system' and k = 'suggestme' and v = '1') "); } else { - $r = q("SELECT count(*) as `total` from abook where abook_channel = %d + $r = q("SELECT count(*) as total from abook where abook_channel = %d $sql_extra ", intval($channel_id) );