aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2021-05-05 08:36:18 +0000
committerMario <mario@mariovavti.com>2021-05-05 08:36:18 +0000
commit0dc09ea238adf141d5a93fd1a734d6156c6e6ad3 (patch)
treee551d02bc238b6b131e1c3ae759a8f90ab25cfde
parent8d4b1ba7d499bcb8b3b161f3f55660389d857c46 (diff)
downloadvolse-hubzilla-0dc09ea238adf141d5a93fd1a734d6156c6e6ad3.tar.gz
volse-hubzilla-0dc09ea238adf141d5a93fd1a734d6156c6e6ad3.tar.bz2
volse-hubzilla-0dc09ea238adf141d5a93fd1a734d6156c6e6ad3.zip
possible minor performance improvement
-rw-r--r--Zotlabs/Module/Channel.php8
-rw-r--r--Zotlabs/Module/Display.php4
-rw-r--r--Zotlabs/Module/Hq.php34
-rw-r--r--Zotlabs/Module/Oep.php262
4 files changed, 154 insertions, 154 deletions
diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php
index ab5000b9a..a7deb4f6b 100644
--- a/Zotlabs/Module/Channel.php
+++ b/Zotlabs/Module/Channel.php
@@ -308,9 +308,9 @@ class Channel extends Controller {
if (($update) && (!$load)) {
if ($mid) {
- $r = q("SELECT parent AS item_id from item where mid like '%s' and uid = %d $item_normal_update
+ $r = q("SELECT parent AS item_id from item where mid = '%s' and uid = %d $item_normal_update
AND item_wall = 1 $simple_update $sql_extra limit 1",
- dbesc($mid . '%'),
+ dbesc($mid),
intval(App::$profile['profile_uid'])
);
}
@@ -356,9 +356,9 @@ class Channel extends Controller {
if ($noscript_content || $load) {
if ($mid) {
- $r = q("SELECT parent AS item_id from item where mid like '%s' and uid = %d $item_normal
+ $r = q("SELECT parent AS item_id from item where mid = '%s' and uid = %d $item_normal
AND item_wall = 1 $sql_extra limit 1",
- dbesc($mid . '%'),
+ dbesc($mid),
intval(App::$profile['profile_uid'])
);
if (!$r) {
diff --git a/Zotlabs/Module/Display.php b/Zotlabs/Module/Display.php
index 21d3e2e08..e6caa9906 100644
--- a/Zotlabs/Module/Display.php
+++ b/Zotlabs/Module/Display.php
@@ -97,8 +97,8 @@ class Display extends \Zotlabs\Web\Controller {
if($decoded)
$item_hash = $decoded;
- $r = q("select id, uid, mid, parent, parent_mid, thr_parent, verb, item_type, item_deleted, author_xchan, item_blocked from item where mid like '%s' limit 1",
- dbesc($item_hash . '%')
+ $r = q("select id, uid, mid, parent, parent_mid, thr_parent, verb, item_type, item_deleted, author_xchan, item_blocked from item where mid = '%s' limit 1",
+ dbesc($item_hash)
);
if($r) {
diff --git a/Zotlabs/Module/Hq.php b/Zotlabs/Module/Hq.php
index 4c2067299..a2c4100ad 100644
--- a/Zotlabs/Module/Hq.php
+++ b/Zotlabs/Module/Hq.php
@@ -41,7 +41,7 @@ class Hq extends \Zotlabs\Web\Controller {
if(argc() > 1 && argv(1) !== 'load') {
$item_hash = argv(1);
}
-
+
if($_REQUEST['mid'])
$item_hash = $_REQUEST['mid'];
@@ -49,9 +49,9 @@ class Hq extends \Zotlabs\Web\Controller {
$item_normal_update = item_normal_update();
if(! $item_hash) {
- $r = q("SELECT mid FROM item
+ $r = q("SELECT mid FROM item
WHERE uid = %d $item_normal
- AND mid = parent_mid
+ AND mid = parent_mid
ORDER BY created DESC LIMIT 1",
intval(local_channel())
);
@@ -71,10 +71,10 @@ class Hq extends \Zotlabs\Web\Controller {
$target_item = null;
- $r = q("select id, uid, mid, parent_mid, thr_parent, verb, item_type, item_deleted, item_blocked from item where mid like '%s' limit 1",
- dbesc($item_hash . '%')
+ $r = q("select id, uid, mid, parent_mid, thr_parent, verb, item_type, item_deleted, item_blocked from item where mid = '%s' limit 1",
+ dbesc($item_hash)
);
-
+
if($r) {
$target_item = $r[0];
}
@@ -83,7 +83,7 @@ class Hq extends \Zotlabs\Web\Controller {
if($target_item['item_blocked'] == ITEM_MODERATED) {
goaway(z_root() . '/moderate/' . $target_item['id']);
}
-
+
$simple_update = '';
if($update && $_SESSION['loadtime'])
$simple_update = " AND (( item_unseen = 1 AND item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) OR item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) ";
@@ -94,16 +94,16 @@ class Hq extends \Zotlabs\Web\Controller {
$sys_item = false;
}
-
+
if(! $update) {
$channel = \App::get_channel();
$channel_acl = [
- 'allow_cid' => $channel['channel_allow_cid'],
- 'allow_gid' => $channel['channel_allow_gid'],
- 'deny_cid' => $channel['channel_deny_cid'],
+ 'allow_cid' => $channel['channel_allow_cid'],
+ 'allow_gid' => $channel['channel_allow_gid'],
+ 'deny_cid' => $channel['channel_deny_cid'],
'deny_gid' => $channel['channel_deny_gid']
- ];
+ ];
$x = [
'is_owner' => true,
@@ -143,7 +143,7 @@ class Hq extends \Zotlabs\Web\Controller {
// if the target item is not a post (eg a like) we want to address its thread parent
//$mid = ((($target_item['verb'] == ACTIVITY_LIKE) || ($target_item['verb'] == ACTIVITY_DISLIKE)) ? $target_item['thr_parent'] : $target_item['mid']);
$mid = $target_item['mid'];
- // if we got a decoded hash we must encode it again before handing to javascript
+ // if we got a decoded hash we must encode it again before handing to javascript
if($decoded)
$mid = 'b64.' . base64url_encode($mid);
}
@@ -154,7 +154,7 @@ class Hq extends \Zotlabs\Web\Controller {
$o .= '<div id="live-hq"></div>' . "\r\n";
$o .= "<script> var profile_uid = " . local_channel()
. "; var netargs = '?f='; var profile_page = " . \App::$pager['page'] . ";</script>\r\n";
-
+
\App::$page['htmlhead'] .= replace_macros(get_markup_template("build_query.tpl"),[
'$baseurl' => z_root(),
'$pgtype' => 'hq',
@@ -241,14 +241,14 @@ class Hq extends \Zotlabs\Web\Controller {
else {
$r = [];
}
-
+
if($r) {
- $items = q("SELECT item.*, item.id AS item_id
+ $items = q("SELECT item.*, item.id AS item_id
FROM item
WHERE parent = '%s' $item_normal ",
dbesc($r[0]['item_id'])
);
-
+
xchan_query($items,true,(($sys_item) ? local_channel() : 0));
$items = fetch_post_tags($items,true);
$items = conv_sort($items,'created');
diff --git a/Zotlabs/Module/Oep.php b/Zotlabs/Module/Oep.php
index 75304161b..faad2fc52 100644
--- a/Zotlabs/Module/Oep.php
+++ b/Zotlabs/Module/Oep.php
@@ -11,24 +11,24 @@ require_once('include/security.php');
class Oep extends \Zotlabs\Web\Controller {
function init() {
-
+
logger('oep: ' . print_r($_REQUEST,true), LOGGER_DEBUG, LOG_INFO);
-
+
$html = ((argc() > 1 && argv(1) === 'html') ? true : false);
if($_REQUEST['url']) {
$_REQUEST['url'] = strip_zids($_REQUEST['url']);
$url = $_REQUEST['url'];
}
-
+
if(! $url)
http_status_exit(404, 'Not found');
-
+
$maxwidth = $_REQUEST['maxwidth'];
$maxheight = $_REQUEST['maxheight'];
$format = $_REQUEST['format'];
if($format && $format !== 'json')
http_status_exit(501, 'Not implemented');
-
+
if(fnmatch('*/photos/*/album/*',$url))
$arr = $this->oep_album_reply($_REQUEST);
elseif(fnmatch('*/photos/*/image/*',$url))
@@ -47,7 +47,7 @@ class Oep extends \Zotlabs\Web\Controller {
$arr = $this->oep_cards_reply($_REQUEST);
elseif(fnmatch('*/articles/*',$url))
$arr = $this->oep_articles_reply($_REQUEST);
-
+
if($arr) {
if($html) {
if($arr['type'] === 'rich') {
@@ -61,13 +61,13 @@ class Oep extends \Zotlabs\Web\Controller {
}
killme();
}
-
+
http_status_exit(404,'Not found');
-
+
}
-
+
function oep_display_reply($args) {
-
+
$ret = array();
$url = $args['url'];
$maxwidth = intval($args['maxwidth']);
@@ -83,8 +83,8 @@ class Oep extends \Zotlabs\Web\Controller {
$item_normal = item_normal();
- $p = q("select * from item where mid like '%s' limit 1",
- dbesc($res . '%')
+ $p = q("select * from item where mid = '%s' limit 1",
+ dbesc($res)
);
if(! $p)
@@ -92,7 +92,7 @@ class Oep extends \Zotlabs\Web\Controller {
$c = channelx_by_n($p[0]['uid']);
-
+
if(! ($c && $res))
return;
@@ -100,27 +100,27 @@ class Oep extends \Zotlabs\Web\Controller {
return;
$sql_extra = item_permissions_sql($c['channel_id']);
-
- $p = q("select * from item where mid like '%s' and uid = %d $sql_extra $item_normal limit 1",
- dbesc($res . '%'),
+
+ $p = q("select * from item where mid = '%s' and uid = %d $sql_extra $item_normal limit 1",
+ dbesc($res),
intval($c['channel_id'])
);
if(! $p)
return;
-
+
xchan_query($p,true);
$p = fetch_post_tags($p,true);
// This function can get tripped up if the item is already a reshare
- // (the multiple share declarations do not parse cleanly if nested)
+ // (the multiple share declarations do not parse cleanly if nested)
// So build a template with a known nonsense string as the content, and then
// replace that known string with the actual rendered content, sending
// each content layer through bbcode() separately.
$x = '2eGriplW^*Jmf4';
-
+
$o = "[share author='".urlencode($p[0]['author']['xchan_name']).
"' profile='".$p[0]['author']['xchan_url'] .
"' avatar='".$p[0]['author']['xchan_photo_s'].
@@ -131,29 +131,29 @@ class Oep extends \Zotlabs\Web\Controller {
if($p[0]['title'])
$o .= '[b]'.$p[0]['title'].'[/b]'."\r\n";
- $o .= $x;
+ $o .= $x;
$o .= "[/share]";
$o = bbcode($o);
-
+
$o = str_replace($x,bbcode($p[0]['body']),$o);
-
+
$ret['type'] = 'rich';
-
+
$w = (($maxwidth) ? $maxwidth : 640);
$h = (($maxheight) ? $maxheight : intval($w * 2 / 3));
-
+
$ret['html'] = '<div style="width: ' . $w . '; height: ' . $h . '; font-family: sans-serif,arial,freesans;" >' . $o . '</div>';
-
+
$ret['width'] = $w;
$ret['height'] = $h;
-
+
return $ret;
-
+
}
function oep_cards_reply($args) {
-
+
$ret = [];
$url = $args['url'];
$maxwidth = intval($args['maxwidth']);
@@ -164,7 +164,7 @@ class Oep extends \Zotlabs\Web\Controller {
$res = $matches[3];
}
if(! ($nick && $res))
- return $ret;
+ return $ret;
$channel = channelx_by_nick($nick);
@@ -187,8 +187,8 @@ class Oep extends \Zotlabs\Web\Controller {
return $ret;
}
- $r = q("select * from item
- where item.uid = %d and item_type = %d
+ $r = q("select * from item
+ where item.uid = %d and item_type = %d
$sql_extra order by item.created desc",
intval($channel['channel_id']),
intval(ITEM_TYPE_CARD)
@@ -208,7 +208,7 @@ class Oep extends \Zotlabs\Web\Controller {
$x = '2eGriplW^*Jmf4';
-
+
$o = "[share author='".urlencode($p[0]['author']['xchan_name']).
"' profile='".$p[0]['author']['xchan_url'] .
"' avatar='".$p[0]['author']['xchan_photo_s'].
@@ -219,28 +219,28 @@ class Oep extends \Zotlabs\Web\Controller {
if($p[0]['title'])
$o .= '[b]'.$p[0]['title'].'[/b]'."\r\n";
- $o .= $x;
+ $o .= $x;
$o .= "[/share]";
$o = bbcode($o);
-
+
$o = str_replace($x,bbcode($p[0]['body']),$o);
-
+
$ret['type'] = 'rich';
-
+
$w = (($maxwidth) ? $maxwidth : 640);
$h = (($maxheight) ? $maxheight : intval($w * 2 / 3));
-
+
$ret['html'] = '<div style="width: ' . $w . '; height: ' . $h . '; font-family: sans-serif,arial,freesans;" >' . $o . '</div>';
-
+
$ret['width'] = $w;
$ret['height'] = $h;
-
+
return $ret;
-
+
}
function oep_articles_reply($args) {
-
+
$ret = [];
$url = $args['url'];
$maxwidth = intval($args['maxwidth']);
@@ -251,7 +251,7 @@ class Oep extends \Zotlabs\Web\Controller {
$res = $matches[3];
}
if(! ($nick && $res))
- return $ret;
+ return $ret;
$channel = channelx_by_nick($nick);
@@ -273,8 +273,8 @@ class Oep extends \Zotlabs\Web\Controller {
return $ret;
}
- $r = q("select * from item
- where item.uid = %d and item_type = %d
+ $r = q("select * from item
+ where item.uid = %d and item_type = %d
$sql_extra order by item.created desc",
intval($channel['channel_id']),
intval(ITEM_TYPE_ARTICLE)
@@ -294,7 +294,7 @@ class Oep extends \Zotlabs\Web\Controller {
$x = '2eGriplW^*Jmf4';
-
+
$o = "[share author='".urlencode($p[0]['author']['xchan_name']).
"' profile='".$p[0]['author']['xchan_url'] .
"' avatar='".$p[0]['author']['xchan_photo_s'].
@@ -305,71 +305,71 @@ class Oep extends \Zotlabs\Web\Controller {
if($p[0]['title'])
$o .= '[b]'.$p[0]['title'].'[/b]'."\r\n";
- $o .= $x;
+ $o .= $x;
$o .= "[/share]";
$o = bbcode($o);
-
+
$o = str_replace($x,bbcode($p[0]['body']),$o);
-
+
$ret['type'] = 'rich';
-
+
$w = (($maxwidth) ? $maxwidth : 640);
$h = (($maxheight) ? $maxheight : intval($w * 2 / 3));
-
+
$ret['html'] = '<div style="width: ' . $w . '; height: ' . $h . '; font-family: sans-serif,arial,freesans;" >' . $o . '</div>';
-
+
$ret['width'] = $w;
$ret['height'] = $h;
-
+
return $ret;
-
+
}
-
+
function oep_mid_reply($args) {
-
+
$ret = array();
$url = $args['url'];
$maxwidth = intval($args['maxwidth']);
$maxheight = intval($args['maxheight']);
-
+
if(preg_match('#//(.*?)/(.*?)/(.*?)/(.*?)mid\=(.*?)(&|$)#',$url,$matches)) {
$chn = $matches[3];
$res = $matches[5];
}
-
+
if(! ($chn && $res))
return;
$c = q("select * from channel where channel_address = '%s' limit 1",
dbesc($chn)
);
-
+
if(! $c)
return;
if(! perm_is_allowed($c[0]['channel_id'],get_observer_hash(),'view_stream'))
return;
-
+
$sql_extra = item_permissions_sql($c[0]['channel_id']);
-
+
$p = q("select * from item where mid = '%s' and uid = %d $sql_extra limit 1",
dbesc($res),
intval($c[0]['channel_id'])
);
if(! $p)
return;
-
+
xchan_query($p,true);
$p = fetch_post_tags($p,true);
// This function can get tripped up if the item is already a reshare
- // (the multiple share declarations do not parse cleanly if nested)
+ // (the multiple share declarations do not parse cleanly if nested)
// So build a template with a known nonsense string as the content, and then
// replace that known string with the actual rendered content, sending
// each content layer through bbcode() separately.
$x = '2eGriplW^*Jmf4';
-
+
$o = "[share author='".urlencode($p[0]['author']['xchan_name']).
"' profile='".$p[0]['author']['xchan_url'] .
"' avatar='".$p[0]['author']['xchan_photo_s'].
@@ -379,52 +379,52 @@ class Oep extends \Zotlabs\Web\Controller {
"' message_id='".$p[0]['mid']."']";
if($p[0]['title'])
$o .= '[b]'.$p[0]['title'].'[/b]'."\r\n";
- $o .= $x;
+ $o .= $x;
$o .= "[/share]";
$o = bbcode($o);
-
+
$o = str_replace($x,bbcode($p[0]['body']),$o);
$ret['type'] = 'rich';
-
+
$w = (($maxwidth) ? $maxwidth : 640);
$h = (($maxheight) ? $maxheight : intval($w * 2 / 3));
-
+
$ret['html'] = '<div style="width: ' . $w . '; height: ' . $h . '; font-family: sans-serif,arial,freesans;" >' . $o . '</div>';
-
+
$ret['width'] = $w;
$ret['height'] = $h;
-
+
return $ret;
-
+
}
-
+
function oep_profile_reply($args) {
-
-
+
+
require_once('include/channel.php');
$url = $args['url'];
-
+
if(preg_match('#//(.*?)/(.*?)/(.*?)(/|\?|&|$)#',$url,$matches)) {
$chn = $matches[3];
}
-
+
if(! $chn)
return;
-
+
$c = channelx_by_nick($chn);
-
+
if(! $c)
return;
-
-
+
+
$maxwidth = intval($args['maxwidth']);
$maxheight = intval($args['maxheight']);
-
+
$width = 800;
$height = 375;
-
+
if($maxwidth) {
$width = $maxwidth;
$height = (375 / 800) * $width;
@@ -434,59 +434,59 @@ class Oep extends \Zotlabs\Web\Controller {
$width = (800 / 375) * $maxheight;
$height = $maxheight;
}
- }
+ }
$ret = array();
-
+
$ret['type'] = 'rich';
$ret['width'] = intval($width);
$ret['height'] = intval($height);
-
+
$ret['html'] = get_zcard_embed($c,get_observer_hash(),array('width' => $width, 'height' => $height));
-
+
return $ret;
-
+
}
-
+
function oep_album_reply($args) {
-
+
$ret = array();
$url = $args['url'];
$maxwidth = intval($args['maxwidth']);
$maxheight = intval($args['maxheight']);
-
+
if(preg_match('|//(.*?)/(.*?)/(.*?)/album/|',$url,$matches)) {
$chn = $matches[3];
$res = basename($url);
}
-
+
if(! ($chn && $res))
return;
$c = q("select * from channel where channel_address = '%s' limit 1",
dbesc($chn)
);
-
+
if(! $c)
return;
-
+
if(! perm_is_allowed($c[0]['channel_id'],get_observer_hash(),'view_files'))
return;
$sql_extra = permissions_sql($c[0]['channel_id']);
-
+
$p = q("select resource_id from photo where album = '%s' and uid = %d and imgscale = 0 $sql_extra order by created desc limit 1",
dbesc($res),
intval($c[0]['channel_id'])
);
if(! $p)
return;
-
+
$res = $p[0]['resource_id'];
-
+
$r = q("select height, width, imgscale, resource_id from photo where uid = %d and resource_id = '%s' $sql_extra order by imgscale asc",
intval($c[0]['channel_id']),
dbesc($res)
);
-
+
if($r) {
foreach($r as $rr) {
$foundres = false;
@@ -494,62 +494,62 @@ class Oep extends \Zotlabs\Web\Controller {
continue;
if($maxwidth && $rr['width'] > $maxwidth)
continue;
- $foundres = true;
+ $foundres = true;
break;
}
-
+
if($foundres) {
$ret['type'] = 'link';
$ret['thumbnail_url'] = z_root() . '/photo/' . '/' . $rr['resource_id'] . '-' . $rr['imgscale'];
$ret['thumbnail_width'] = $rr['width'];
$ret['thumbnail_height'] = $rr['height'];
}
-
-
+
+
}
return $ret;
-
+
}
-
-
+
+
function oep_phototop_reply($args) {
-
+
$ret = array();
$url = $args['url'];
$maxwidth = intval($args['maxwidth']);
$maxheight = intval($args['maxheight']);
-
+
if(preg_match('|//(.*?)/(.*?)/(.*?)$|',$url,$matches)) {
$chn = $matches[3];
}
-
+
if(! $chn)
return;
$c = q("select * from channel where channel_address = '%s' limit 1",
dbesc($chn)
);
-
+
if(! $c)
return;
-
+
if(! perm_is_allowed($c[0]['channel_id'],get_observer_hash(),'view_files'))
return;
$sql_extra = permissions_sql($c[0]['channel_id']);
-
+
$p = q("select resource_id from photo where uid = %d and imgscale = 0 $sql_extra order by created desc limit 1",
intval($c[0]['channel_id'])
);
if(! $p)
return;
-
+
$res = $p[0]['resource_id'];
-
+
$r = q("select height, width, imgscale, resource_id from photo where uid = %d and resource_id = '%s' $sql_extra order by imgscale asc",
intval($c[0]['channel_id']),
dbesc($res)
);
-
+
if($r) {
foreach($r as $rr) {
$foundres = false;
@@ -557,42 +557,42 @@ class Oep extends \Zotlabs\Web\Controller {
continue;
if($maxwidth && $rr['width'] > $maxwidth)
continue;
- $foundres = true;
+ $foundres = true;
break;
}
-
+
if($foundres) {
$ret['type'] = 'link';
$ret['thumbnail_url'] = z_root() . '/photo/' . '/' . $rr['resource_id'] . '-' . $rr['imgscale'];
$ret['thumbnail_width'] = $rr['width'];
$ret['thumbnail_height'] = $rr['height'];
}
-
-
+
+
}
return $ret;
-
+
}
-
-
+
+
function oep_photo_reply($args) {
-
+
$ret = array();
$url = $args['url'];
$maxwidth = intval($args['maxwidth']);
$maxheight = intval($args['maxheight']);
-
+
if(preg_match('|//(.*?)/(.*?)/(.*?)/image/|',$url,$matches)) {
$chn = $matches[3];
$res = basename($url);
}
-
+
if(! ($chn && $res))
return;
$c = q("select * from channel where channel_address = '%s' limit 1",
dbesc($chn)
);
-
+
if(! $c)
return;
@@ -600,13 +600,13 @@ class Oep extends \Zotlabs\Web\Controller {
return;
$sql_extra = permissions_sql($c[0]['channel_id']);
-
-
+
+
$r = q("select height, width, imgscale, resource_id from photo where uid = %d and resource_id = '%s' $sql_extra order by imgscale asc",
intval($c[0]['channel_id']),
dbesc($res)
);
-
+
if($r) {
foreach($r as $rr) {
$foundres = false;
@@ -614,20 +614,20 @@ class Oep extends \Zotlabs\Web\Controller {
continue;
if($maxwidth && $rr['width'] > $maxwidth)
continue;
- $foundres = true;
+ $foundres = true;
break;
}
-
+
if($foundres) {
$ret['type'] = 'link';
$ret['thumbnail_url'] = z_root() . '/photo/' . '/' . $rr['resource_id'] . '-' . $rr['imgscale'];
$ret['thumbnail_width'] = $rr['width'];
$ret['thumbnail_height'] = $rr['height'];
}
-
-
+
+
}
return $ret;
-
+
}
}