diff options
author | zotlabs <mike@macgirvin.com> | 2016-10-09 16:31:04 -0700 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2016-10-09 16:31:04 -0700 |
commit | e7233c0c94d0464994df94d8907518d49fcb0650 (patch) | |
tree | face7f2e2c8b6212349e769f6c552138006e1f1e | |
parent | 2bdf135cbcf6208a4c2400d846b2fbffd8ae2c6b (diff) | |
download | volse-hubzilla-e7233c0c94d0464994df94d8907518d49fcb0650.tar.gz volse-hubzilla-e7233c0c94d0464994df94d8907518d49fcb0650.tar.bz2 volse-hubzilla-e7233c0c94d0464994df94d8907518d49fcb0650.zip |
more backquotes - this should take care of most except for the array import queries
30 files changed, 66 insertions, 67 deletions
diff --git a/Zotlabs/Module/Admin/Accounts.php b/Zotlabs/Module/Admin/Accounts.php index 143d00a3b..2043550fc 100644 --- a/Zotlabs/Module/Admin/Accounts.php +++ b/Zotlabs/Module/Admin/Accounts.php @@ -133,10 +133,9 @@ class Accounts { $base = z_root() . '/admin/accounts?f='; $odir = (($dir === 'asc') ? '0' : '1'); - $users = q("SELECT `account_id` , `account_email`, `account_lastlog`, `account_created`, `account_expires`, " . "`account_service_class`, ( account_flags & %d ) > 0 as `blocked`, " . - "(SELECT %s FROM channel as ch " . - "WHERE ch.channel_account_id = ac.account_id and ch.channel_removed = 0 ) as `channels` " . - "FROM account as ac where true $serviceclass order by $key $dir limit %d offset %d ", + $users = q("SELECT account_id , account_email, account_lastlog, account_created, account_expires, account_service_class, ( account_flags & %d ) > 0 as blocked, + (SELECT %s FROM channel as ch WHERE ch.channel_account_id = ac.account_id and ch.channel_removed = 0 ) as channels FROM account as ac + where true $serviceclass order by $key $dir limit %d offset %d ", intval(ACCOUNT_BLOCKED), db_concat('ch.channel_address', ' '), intval(\App::$pager['itemspage']), diff --git a/Zotlabs/Module/Admin/Dbsync.php b/Zotlabs/Module/Admin/Dbsync.php index 305126c7d..cff8a2484 100644 --- a/Zotlabs/Module/Admin/Dbsync.php +++ b/Zotlabs/Module/Admin/Dbsync.php @@ -42,7 +42,7 @@ class Dbsync { } $failed = array(); - $r = q("select * from config where `cat` = 'database' "); + $r = q("select * from config where cat = 'database' "); if(count($r)) { foreach($r as $rr) { $upd = intval(substr($rr['k'],8)); diff --git a/Zotlabs/Module/Connedit.php b/Zotlabs/Module/Connedit.php index 43feac189..c11d1ea16 100644 --- a/Zotlabs/Module/Connedit.php +++ b/Zotlabs/Module/Connedit.php @@ -96,7 +96,7 @@ class Connedit extends \Zotlabs\Web\Controller { $profile_id = $_POST['profile_assign']; if($profile_id) { - $r = q("SELECT profile_guid FROM profile WHERE profile_guid = '%s' AND `uid` = %d LIMIT 1", + $r = q("SELECT profile_guid FROM profile WHERE profile_guid = '%s' AND uid = %d LIMIT 1", dbesc($profile_id), intval(local_channel()) ); diff --git a/Zotlabs/Module/Contactgroup.php b/Zotlabs/Module/Contactgroup.php index bbe56b4ad..2ba53517f 100644 --- a/Zotlabs/Module/Contactgroup.php +++ b/Zotlabs/Module/Contactgroup.php @@ -23,7 +23,7 @@ class Contactgroup extends \Zotlabs\Web\Controller { if((argc() > 1) && (intval(argv(1)))) { - $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()) ); diff --git a/Zotlabs/Module/Cover_photo.php b/Zotlabs/Module/Cover_photo.php index 886958b37..7c8e1323c 100644 --- a/Zotlabs/Module/Cover_photo.php +++ b/Zotlabs/Module/Cover_photo.php @@ -309,7 +309,7 @@ class Cover_photo extends \Zotlabs\Web\Controller { $havescale = true; } - $r = q("SELECT `content`, `mimetype`, resource_id, os_storage FROM photo WHERE id = %d and uid = %d limit 1", + $r = q("SELECT content, mimetype, resource_id, os_storage FROM photo WHERE id = %d and uid = %d limit 1", intval($r[0]['id']), intval(local_channel()) diff --git a/Zotlabs/Module/Dirsearch.php b/Zotlabs/Module/Dirsearch.php index ebd6c3715..927800bbb 100644 --- a/Zotlabs/Module/Dirsearch.php +++ b/Zotlabs/Module/Dirsearch.php @@ -185,7 +185,7 @@ class Dirsearch extends \Zotlabs\Web\Controller { else { $qlimit = " LIMIT " . intval($perpage) . " OFFSET " . intval($startrec); if($return_total) { - $r = q("SELECT COUNT(xchan_hash) AS `total` FROM xchan left join xprof on xchan_hash = xprof_hash where $logic $sql_extra and xchan_network = 'zot' and xchan_hidden = 0 and xchan_orphan = 0 and xchan_deleted = 0 $safesql "); + $r = q("SELECT COUNT(xchan_hash) AS total FROM xchan left join xprof on xchan_hash = xprof_hash where $logic $sql_extra and xchan_network = 'zot' and xchan_hidden = 0 and xchan_orphan = 0 and xchan_deleted = 0 $safesql "); if($r) { $ret['total_items'] = $r[0]['total']; } diff --git a/Zotlabs/Module/Editblock.php b/Zotlabs/Module/Editblock.php index 6a9fa5f2d..654e2251d 100644 --- a/Zotlabs/Module/Editblock.php +++ b/Zotlabs/Module/Editblock.php @@ -80,7 +80,7 @@ class Editblock extends \Zotlabs\Web\Controller { return; } - $itm = q("SELECT * FROM `item` WHERE `id` = %d and uid = %s LIMIT 1", + $itm = q("SELECT * FROM item WHERE id = %d and uid = %s LIMIT 1", intval($post_id), intval($owner) ); diff --git a/Zotlabs/Module/Editlayout.php b/Zotlabs/Module/Editlayout.php index 26732dc77..ea637fcba 100644 --- a/Zotlabs/Module/Editlayout.php +++ b/Zotlabs/Module/Editlayout.php @@ -91,7 +91,7 @@ class Editlayout extends \Zotlabs\Web\Controller { return; } - $itm = q("SELECT * FROM `item` WHERE `id` = %d and uid = %s LIMIT 1", + $itm = q("SELECT * FROM item WHERE id = %d and uid = %s LIMIT 1", intval($post_id), intval($owner) ); diff --git a/Zotlabs/Module/Editpost.php b/Zotlabs/Module/Editpost.php index 838fe9e4f..2c57cde5a 100644 --- a/Zotlabs/Module/Editpost.php +++ b/Zotlabs/Module/Editpost.php @@ -25,7 +25,7 @@ class Editpost extends \Zotlabs\Web\Controller { return; } - $itm = q("SELECT * FROM `item` WHERE `id` = %d AND ( owner_xchan = '%s' OR author_xchan = '%s' ) LIMIT 1", + $itm = q("SELECT * FROM item WHERE id = %d AND ( owner_xchan = '%s' OR author_xchan = '%s' ) LIMIT 1", intval($post_id), dbesc(get_observer_hash()), dbesc(get_observer_hash()) diff --git a/Zotlabs/Module/Editwebpage.php b/Zotlabs/Module/Editwebpage.php index 2da8871a2..3d4af107d 100644 --- a/Zotlabs/Module/Editwebpage.php +++ b/Zotlabs/Module/Editwebpage.php @@ -95,7 +95,7 @@ class Editwebpage extends \Zotlabs\Web\Controller { $sql_extra = item_permissions_sql($owner); - $itm = q("SELECT * FROM `item` WHERE `id` = %d and uid = %s $sql_extra LIMIT 1", + $itm = q("SELECT * FROM item WHERE id = %d and uid = %s $sql_extra LIMIT 1", intval($post_id), intval($owner) ); diff --git a/Zotlabs/Module/Fbrowser.php b/Zotlabs/Module/Fbrowser.php index c534e8f72..3bac81c5a 100644 --- a/Zotlabs/Module/Fbrowser.php +++ b/Zotlabs/Module/Fbrowser.php @@ -32,7 +32,7 @@ class Fbrowser extends \Zotlabs\Web\Controller { $sql_extra2 = " ORDER BY created DESC LIMIT 0, 10"; if (\App::$argc==2){ - $albums = q("SELECT distinct(`album`) AS `album` FROM `photo` WHERE `uid` = %d ", + $albums = q("SELECT distinct(album) AS album FROM photo WHERE uid = %d ", intval(local_channel()) ); // anon functions only from 5.3.0... meglio tardi che mai.. @@ -43,14 +43,14 @@ class Fbrowser extends \Zotlabs\Web\Controller { $album = ""; if (\App::$argc==3){ $album = hex2bin(\App::$argv[2]); - $sql_extra = sprintf("AND `album` = '%s' ",dbesc($album)); + $sql_extra = sprintf("AND album = '%s' ",dbesc($album)); $sql_extra2 = ""; $path[]=array(z_root() . "/fbrowser/image/" . \App::$argv[2] . "/", $album); } - $r = q("SELECT `resource_id`, `id`, `filename`, type, min(`imgscale`) AS `hiq`,max(`imgscale`) AS `loq`, `description` - FROM `photo` WHERE `uid` = %d $sql_extra - GROUP BY `resource_id` $sql_extra2", + $r = q("SELECT resource_id, id, filename, type, min(imgscale) AS hiq,max(imgscale) AS loq, description + FROM photo WHERE uid = %d $sql_extra + GROUP BY resource_id $sql_extra2", intval(local_channel()) ); @@ -70,7 +70,7 @@ class Fbrowser extends \Zotlabs\Web\Controller { break; case "file": if (\App::$argc==2){ - $files = q("SELECT id, filename, filetype FROM `attach` WHERE `uid` = %d ", + $files = q("SELECT id, filename, filetype FROM attach WHERE uid = %d ", intval(local_channel()) ); diff --git a/Zotlabs/Module/Invite.php b/Zotlabs/Module/Invite.php index 5198b1231..6b6f80a31 100644 --- a/Zotlabs/Module/Invite.php +++ b/Zotlabs/Module/Invite.php @@ -111,7 +111,7 @@ class Invite extends \Zotlabs\Web\Controller { $invite_code = autoname(8) . rand(1000,9999); $nmessage = str_replace('$invite_code',$invite_code,$message); - $r = q("INSERT INTO `register` (`hash`,`created`) VALUES ('%s', '%s') ", + $r = q("INSERT INTO register (hash,created) VALUES ('%s', '%s') ", dbesc($invite_code), dbesc(datetime_convert()) ); diff --git a/Zotlabs/Module/Match.php b/Zotlabs/Module/Match.php index c422e4b3e..63bdb60a4 100644 --- a/Zotlabs/Module/Match.php +++ b/Zotlabs/Module/Match.php @@ -25,7 +25,7 @@ class Match extends \Zotlabs\Web\Controller { $o .= '<h2>' . t('Profile Match') . '</h2>'; - $r = q("SELECT `keywords` FROM `profile` WHERE `is_default` = 1 AND `uid` = %d LIMIT 1", + $r = q("SELECT keywords FROM profile WHERE is_default = 1 AND uid = %d LIMIT 1", intval(local_channel()) ); if (! count($r)) diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 4f831c050..99573ad69 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -201,7 +201,7 @@ class Network extends \Zotlabs\Web\Controller { $sql_nets = ''; - $sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE item_thread_top = 1 $sql_options ) "; + $sql_extra = " AND item.parent IN ( SELECT parent FROM item WHERE item_thread_top = 1 $sql_options ) "; if($group) { $contact_str = ''; diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php index 4332fd6e9..1134f4275 100644 --- a/Zotlabs/Module/Photo.php +++ b/Zotlabs/Module/Photo.php @@ -183,7 +183,7 @@ class Photo extends \Zotlabs\Web\Controller { // they won't have the photo link, so there's a reasonable chance that the person // might be able to obtain permission to view it. - $r = q("SELECT * FROM `photo` WHERE `resource_id` = '%s' AND `imgscale` = %d LIMIT 1", + $r = q("SELECT * FROM photo WHERE resource_id = '%s' AND imgscale = %d LIMIT 1", dbesc($photo), intval($resolution) ); diff --git a/Zotlabs/Module/Profile_photo.php b/Zotlabs/Module/Profile_photo.php index f459f7deb..1ae3a0a75 100644 --- a/Zotlabs/Module/Profile_photo.php +++ b/Zotlabs/Module/Profile_photo.php @@ -149,7 +149,7 @@ class Profile_photo extends \Zotlabs\Web\Controller { if($is_default_profile) { $r = q("UPDATE photo SET photo_usage = %d WHERE photo_usage = %d - AND resource_id != '%s' AND `uid` = %d", + AND resource_id != '%s' AND uid = %d", intval(PHOTO_NORMAL), intval(PHOTO_PROFILE), dbesc($base_image['resource_id']), diff --git a/Zotlabs/Module/Profperm.php b/Zotlabs/Module/Profperm.php index b1da147c1..99cd4c58f 100644 --- a/Zotlabs/Module/Profperm.php +++ b/Zotlabs/Module/Profperm.php @@ -55,7 +55,7 @@ class Profperm extends \Zotlabs\Web\Controller { if((argc() > 1) && (intval(argv(1)))) { - $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d AND `is_default` = 0 LIMIT 1", + $r = q("SELECT * FROM profile WHERE id = %d AND uid = %d AND is_default = 0 LIMIT 1", intval(argv(1)), intval(local_channel()) ); diff --git a/Zotlabs/Module/Settings/Channel.php b/Zotlabs/Module/Settings/Channel.php index a7d8b883f..af640d75d 100644 --- a/Zotlabs/Module/Settings/Channel.php +++ b/Zotlabs/Module/Settings/Channel.php @@ -289,7 +289,7 @@ class Channel { $yes_no = array(t('No'),t('Yes')); - $p = q("SELECT * FROM `profile` WHERE `is_default` = 1 AND `uid` = %d LIMIT 1", + $p = q("SELECT * FROM profile WHERE is_default = 1 AND uid = %d LIMIT 1", intval(local_channel()) ); if(count($p)) diff --git a/Zotlabs/Module/Settings/Featured.php b/Zotlabs/Module/Settings/Featured.php index 7d7b1a734..eec5f6c02 100644 --- a/Zotlabs/Module/Settings/Featured.php +++ b/Zotlabs/Module/Settings/Featured.php @@ -19,7 +19,7 @@ class Featured { $o = ''; - $r = q("SELECT * FROM `hook` WHERE `hook` = 'feature_settings' "); + $r = q("SELECT * FROM hook WHERE hook = 'feature_settings' "); if(! $r) $settings_addons = t('No feature settings configured'); diff --git a/Zotlabs/Module/Tasks.php b/Zotlabs/Module/Tasks.php index 6d0a92d91..c8deb11bf 100644 --- a/Zotlabs/Module/Tasks.php +++ b/Zotlabs/Module/Tasks.php @@ -45,7 +45,7 @@ class Tasks extends \Zotlabs\Web\Controller { if((argc() > 2) && (argv(1) === 'complete') && intval(argv(2))) { $ret = array('success' => false); - $r = q("select * from event where `etype` = 'task' and uid = %d and id = %d limit 1", + $r = q("select * from event where etype = 'task' and uid = %d and id = %d limit 1", intval(local_channel()), intval(argv(2)) ); diff --git a/include/channel.php b/include/channel.php index 189748d09..4dd356785 100644 --- a/include/channel.php +++ b/include/channel.php @@ -540,7 +540,7 @@ function identity_basic_export($channel_id, $items = false) { $ret['hubloc'] = $r; } - $r = q("select * from `groups` where uid = %d ", + $r = q("select * from groups where uid = %d ", intval($channel_id) ); @@ -903,7 +903,7 @@ function profile_load($nickname, $profile = '') { // fetch user tags if this isn't the default profile if(! $p[0]['is_default']) { - $x = q("select `keywords` from `profile` where uid = %d and `is_default` = 1 limit 1", + $x = q("select keywords from profile where uid = %d and is_default = 1 limit 1", intval($p[0]['profile_uid']) ); if($x && $can_view_profile) diff --git a/include/connections.php b/include/connections.php index 017117dda..b08d046b3 100644 --- a/include/connections.php +++ b/include/connections.php @@ -297,16 +297,16 @@ function channel_remove($channel_id, $local = true, $unset_session=false) { } - q("DELETE FROM `groups` WHERE `uid` = %d", intval($channel_id)); - q("DELETE FROM `group_member` WHERE `uid` = %d", intval($channel_id)); - q("DELETE FROM `event` WHERE `uid` = %d", intval($channel_id)); - q("DELETE FROM `item` WHERE `uid` = %d", intval($channel_id)); - q("DELETE FROM `mail` WHERE `channel_id` = %d", intval($channel_id)); - q("DELETE FROM `notify` WHERE `uid` = %d", intval($channel_id)); - q("DELETE FROM `photo` WHERE `uid` = %d", intval($channel_id)); - q("DELETE FROM `attach` WHERE `uid` = %d", intval($channel_id)); - q("DELETE FROM `profile` WHERE `uid` = %d", intval($channel_id)); - q("DELETE FROM `pconfig` WHERE `uid` = %d", intval($channel_id)); + q("DELETE FROM groups WHERE uid = %d", intval($channel_id)); + q("DELETE FROM group_member WHERE uid = %d", intval($channel_id)); + q("DELETE FROM event WHERE uid = %d", intval($channel_id)); + q("DELETE FROM item WHERE uid = %d", intval($channel_id)); + q("DELETE FROM mail WHERE channel_id = %d", intval($channel_id)); + q("DELETE FROM notify WHERE uid = %d", intval($channel_id)); + q("DELETE FROM photo WHERE uid = %d", intval($channel_id)); + q("DELETE FROM attach WHERE uid = %d", intval($channel_id)); + q("DELETE FROM profile WHERE uid = %d", intval($channel_id)); + q("DELETE FROM pconfig WHERE uid = %d", intval($channel_id)); // @FIXME At this stage we need to remove the file resources located under /store/$nickname diff --git a/include/conversation.php b/include/conversation.php index 287dd4983..7239e603b 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -269,8 +269,8 @@ function localize_item(&$item){ // (and update to json storage) if (activity_match($item['verb'],ACTIVITY_TAG)) { - $r = q("SELECT * from `item`,`contact` WHERE - `item`.`contact-id`=`contact`.`id` AND `item`.`mid`='%s';", + $r = q("SELECT * from item,contact WHERE + item.contact-id=contact.id AND item.mid='%s';", dbesc($item['parent_mid'])); if(count($r)==0) return; $obj=$r[0]; diff --git a/include/items.php b/include/items.php index c62d53c3e..333795827 100755 --- a/include/items.php +++ b/include/items.php @@ -1717,7 +1717,7 @@ function item_store($arr, $allow_exec = false, $deliver = true) { // find the parent and snarf the item id and ACL's // and anything else we need to inherit - $r = q("SELECT * FROM `item` WHERE `mid` = '%s' AND `uid` = %d ORDER BY `id` ASC LIMIT 1", + $r = q("SELECT * FROM item WHERE mid = '%s' AND uid = %d ORDER BY id ASC LIMIT 1", dbesc($arr['parent_mid']), intval($arr['uid']) ); @@ -1749,8 +1749,8 @@ function item_store($arr, $allow_exec = false, $deliver = true) { if($r[0]['mid'] != $r[0]['parent_mid']) { $arr['parent_mid'] = $r[0]['parent_mid']; - $z = q("SELECT * FROM `item` WHERE `mid` = '%s' AND `parent_mid` = '%s' AND `uid` = %d - ORDER BY `id` ASC LIMIT 1", + $z = q("SELECT * FROM item WHERE mid = '%s' AND parent_mid = '%s' AND uid = %d + ORDER BY id ASC LIMIT 1", dbesc($r[0]['parent_mid']), dbesc($r[0]['parent_mid']), intval($arr['uid']) @@ -1801,7 +1801,7 @@ function item_store($arr, $allow_exec = false, $deliver = true) { if($parent_deleted) $arr['item_deleted'] = 1; - $r = q("SELECT `id` FROM `item` WHERE `mid` = '%s' AND `uid` = %d LIMIT 1", + $r = q("SELECT id FROM item WHERE mid = '%s' AND uid = %d LIMIT 1", dbesc($arr['mid']), intval($arr['uid']) ); @@ -1863,7 +1863,7 @@ function item_store($arr, $allow_exec = false, $deliver = true) { // find the item we just created - $r = q("SELECT * FROM `item` WHERE `mid` = '%s' AND `uid` = %d ORDER BY `id` ASC ", + $r = q("SELECT * FROM item WHERE mid = '%s' AND uid = %d ORDER BY id ASC ", $arr['mid'], // already dbesc'd intval($arr['uid']) ); @@ -1880,7 +1880,7 @@ function item_store($arr, $allow_exec = false, $deliver = true) { } if(count($r) > 1) { logger('item_store: duplicated post occurred. Removing duplicates.'); - q("DELETE FROM `item` WHERE `mid` = '%s' AND `uid` = %d AND `id` != %d ", + q("DELETE FROM item WHERE mid = '%s' AND uid = %d AND id != %d ", $arr['mid'], intval($arr['uid']), intval($current_post) @@ -2177,7 +2177,7 @@ function item_store_update($arr,$allow_exec = false, $deliver = true) { $str .= " `" . $k . "` = '" . $v . "' "; } - $r = dbq("update `item` set " . $str . " where id = " . $orig_post_id ); + $r = dbq("update item set " . $str . " where id = " . $orig_post_id ); if($r) logger('item_store_update: updated item ' . $orig_post_id, LOGGER_DEBUG); @@ -3066,7 +3066,7 @@ function mail_store($arr) { $arr['parent_mid'] = $arr['mid']; } - $r = q("SELECT `id` FROM mail WHERE `mid` = '%s' AND channel_id = %d LIMIT 1", + $r = q("SELECT id FROM mail WHERE mid = '%s' AND channel_id = %d LIMIT 1", dbesc($arr['mid']), intval($arr['channel_id']) ); @@ -3100,7 +3100,7 @@ function mail_store($arr) { // find the item we just created - $r = q("SELECT `id` FROM mail WHERE `mid` = '%s' AND `channel_id` = %d ORDER BY `id` ASC ", + $r = q("SELECT id FROM mail WHERE mid = '%s' AND channel_id = %d ORDER BY id ASC ", $arr['mid'], // already dbesc'd intval($arr['channel_id']) ); @@ -3116,7 +3116,7 @@ function mail_store($arr) { } if(count($r) > 1) { logger('mail_store: duplicated post occurred. Removing duplicates.'); - q("DELETE FROM mail WHERE `mid` = '%s' AND `channel_id` = %d AND `id` != %d ", + q("DELETE FROM mail WHERE mid = '%s' AND channel_id = %d AND id != %d ", $arr['mid'], intval($arr['channel_id']), intval($current_post) @@ -3168,7 +3168,7 @@ function fix_private_photos($s, $uid, $item = null, $cid = 0) { if($x) { $res = substr($i,$x+1); $i = substr($i,0,$x); - $r = q("SELECT * FROM `photo` WHERE `resource_id` = '%s' AND `imgscale` = %d AND `uid` = %d", + $r = q("SELECT * FROM photo WHERE resource_id = '%s' AND imgscale = %d AND uid = %d", dbesc($i), intval($res), intval($uid) @@ -3883,8 +3883,8 @@ function zot_feed($uid,$observer_hash,$arr) { $sys_query = ((is_sys_channel($uid)) ? $sql_extra : ''); $item_normal = item_normal(); - $items = q("SELECT `item`.*, `item`.`id` AS `item_id` FROM `item` - WHERE `item`.`parent` IN ( %s ) $item_normal $sys_query ", + $items = q("SELECT item.*, item.id AS item_id FROM item + WHERE item.parent IN ( %s ) $item_normal $sys_query ", dbesc($parents_str) ); } @@ -3952,7 +3952,7 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C $sql_extra .= protect_sprintf(term_query('item', $arr['cat'], TERM_CATEGORY)); if($arr['gid'] && $uid) { - $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($arr['group']), intval($uid) ); diff --git a/include/message.php b/include/message.php index 748689206..25986092d 100644 --- a/include/message.php +++ b/include/message.php @@ -392,7 +392,7 @@ function private_messages_fetch_message($channel_id, $messageitem_id, $updatesee if($updateseen) { - $r = q("UPDATE `mail` SET mail_seen = 1 where mail_seen = 0 and id = %d AND channel_id = %d", + $r = q("UPDATE mail SET mail_seen = 1 where mail_seen = 0 and id = %d AND channel_id = %d", dbesc($messageitem_id), intval($channel_id) ); @@ -516,7 +516,7 @@ function private_messages_fetch_conversation($channel_id, $messageitem_id, $upda if($updateseen) { - $r = q("UPDATE `mail` SET mail_seen = 1 where mail_seen = 0 and parent_mid = '%s' AND channel_id = %d", + $r = q("UPDATE mail SET mail_seen = 1 where mail_seen = 0 and parent_mid = '%s' AND channel_id = %d", dbesc($r[0]['parent_mid']), intval($channel_id) ); diff --git a/include/security.php b/include/security.php index 9b508d339..5ffa48d9e 100644 --- a/include/security.php +++ b/include/security.php @@ -549,7 +549,7 @@ function check_form_security_token_ForbiddenOnErr($typename = '', $formname = 'f function init_groups_visitor($contact_id) { $groups = array(); - $r = q("SELECT hash FROM `groups` left join group_member on groups.id = group_member.gid WHERE xchan = '%s' ", + $r = q("SELECT hash FROM groups left join group_member on groups.id = group_member.gid WHERE xchan = '%s' ", dbesc($contact_id) ); if($r) { diff --git a/include/selectors.php b/include/selectors.php index d7d070d31..ab049fff6 100644 --- a/include/selectors.php +++ b/include/selectors.php @@ -7,7 +7,7 @@ function contact_profile_assign($current) { $o .= "<select id=\"contact-profile-selector\" name=\"profile_assign\" class=\"form-control\"/>\r\n"; - $r = q("SELECT profile_guid, profile_name FROM `profile` WHERE `uid` = %d", + $r = q("SELECT profile_guid, profile_name FROM profile WHERE uid = %d", intval($_SESSION['uid'])); if($r) { diff --git a/include/statistics_fns.php b/include/statistics_fns.php index ce2eee5e7..cbff3b0b7 100644 --- a/include/statistics_fns.php +++ b/include/statistics_fns.php @@ -64,7 +64,7 @@ function update_channels_active_monthly_stat() { } function update_local_posts_stat() { - $posts = q("SELECT COUNT(*) AS local_posts FROM `item` WHERE item_wall = 1 "); + $posts = q("SELECT COUNT(*) AS local_posts FROM item WHERE item_wall = 1 "); if (is_array($posts)) { $local_posts_stat = intval($posts[0]["local_posts"]); set_config('system','local_posts_stat',$local_posts_stat); diff --git a/include/widgets.php b/include/widgets.php index 2e1e58717..3396a92a5 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -214,13 +214,13 @@ function widget_savedsearch($arr) { $search = ((x($_GET,'search')) ? $_GET['search'] : ''); if(x($_GET,'searchsave') && $search) { - $r = q("select * from `term` where `uid` = %d and `ttype` = %d and `term` = '%s' limit 1", + $r = q("select * from term where uid = %d and ttype = %d and term = '%s' limit 1", intval(local_channel()), intval(TERM_SAVEDSEARCH), dbesc($search) ); if(! $r) { - q("insert into `term` ( `uid`,`ttype`,`term` ) values ( %d, %d, '%s') ", + q("insert into term ( uid,ttype,term ) values ( %d, %d, '%s') ", intval(local_channel()), intval(TERM_SAVEDSEARCH), dbesc($search) @@ -229,7 +229,7 @@ function widget_savedsearch($arr) { } if(x($_GET,'searchremove') && $search) { - q("delete from `term` where `uid` = %d and `ttype` = %d and `term` = '%s'", + q("delete from term where uid = %d and ttype = %d and term = '%s'", intval(local_channel()), intval(TERM_SAVEDSEARCH), dbesc($search) @@ -256,7 +256,7 @@ function widget_savedsearch($arr) { $o = ''; - $r = q("select `tid`,`term` from `term` WHERE `uid` = %d and `ttype` = %d ", + $r = q("select tid,term from term WHERE uid = %d and ttype = %d ", intval(local_channel()), intval(TERM_SAVEDSEARCH) ); diff --git a/include/zot.php b/include/zot.php index f5b7a383e..a214a1b0c 100644 --- a/include/zot.php +++ b/include/zot.php @@ -3372,7 +3372,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { } } if(! $found) { - $r = q("INSERT INTO `groups` ( hash, uid, visible, deleted, gname ) + $r = q("INSERT INTO groups ( hash, uid, visible, deleted, gname ) VALUES( '%s', %d, %d, %d, '%s' ) ", dbesc($cl['collection']), intval($channel['channel_id']), @@ -3446,7 +3446,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) { // if somebody is in the group that wasn't before - add them if(! $found) { - q("INSERT INTO `group_member` (`uid`, `gid`, `xchan`) + q("INSERT INTO group_member (uid, gid, xchan) VALUES( %d, %d, '%s' ) ", intval($channel['channel_id']), intval($y['id']), |