Merge pull request #803 from annando/master
SQL performance and reduction of database warnings
This commit is contained in:
commit
7d1a6cc1d6
21 changed files with 348 additions and 202 deletions
2
boot.php
2
boot.php
|
@ -14,7 +14,7 @@ require_once('include/features.php');
|
|||
define ( 'FRIENDICA_PLATFORM', 'Friendica');
|
||||
define ( 'FRIENDICA_VERSION', '3.2.1744' );
|
||||
define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
|
||||
define ( 'DB_UPDATE_VERSION', 1163 );
|
||||
define ( 'DB_UPDATE_VERSION', 1165 );
|
||||
define ( 'EOL', "<br />\r\n" );
|
||||
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
|
||||
|
||||
|
|
|
@ -562,6 +562,7 @@ CREATE TABLE IF NOT EXISTS `item` (
|
|||
`forum_mode` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`mention` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`last-child` tinyint(1) unsigned NOT NULL DEFAULT '1',
|
||||
`network` char(32) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `uri` (`uri`),
|
||||
KEY `uid` (`uid`),
|
||||
|
@ -593,6 +594,7 @@ CREATE TABLE IF NOT EXISTS `item` (
|
|||
KEY `mention` (`mention`),
|
||||
KEY `resource-id` (`resource-id`),
|
||||
KEY `event_id` (`event-id`),
|
||||
KEY `network` (`network`),
|
||||
FULLTEXT KEY `title` (`title`),
|
||||
FULLTEXT KEY `body` (`body`),
|
||||
FULLTEXT KEY `allow_cid` (`allow_cid`),
|
||||
|
|
|
@ -267,9 +267,11 @@ function bb_ShareAttributes($match) {
|
|||
preg_match('/posted="(.*?)"/ism', $attributes, $matches);
|
||||
if ($matches[1] != "")
|
||||
$posted = $matches[1];
|
||||
$reldate = (($posted) ? " " . relative_date($posted) : '');
|
||||
|
||||
$headline = '<br /><div class="shared_header">';
|
||||
$reldate = (($posted) ? " " . relative_date($posted) : '');
|
||||
|
||||
$headline = '<div class="shared_header">';
|
||||
//$headline = '<br /><div class="shared_header">';
|
||||
|
||||
if ($avatar != "")
|
||||
$headline .= '<img src="'.$avatar.'" height="32" width="32" >';
|
||||
|
@ -633,8 +635,10 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
|
|||
$Text = preg_replace_callback("/\[video\](.*?)\[\/video\]/ism", 'tryoembed', $Text);
|
||||
$Text = preg_replace_callback("/\[audio\](.*?)\[\/audio\]/ism", 'tryoembed', $Text);
|
||||
} else {
|
||||
$Text = preg_replace("/\[video\](.*?)\[\/video\]/", '$1', $Text);
|
||||
$Text = preg_replace("/\[audio\](.*?)\[\/audio\]/", '$1', $Text);
|
||||
$Text = preg_replace("/\[video\](.*?)\[\/video\]/",
|
||||
'<a href="$1" target="external-link">$1</a>', $Text);
|
||||
$Text = preg_replace("/\[audio\](.*?)\[\/audio\]/",
|
||||
'<a href="$1" target="external-link">$1</a>', $Text);
|
||||
}
|
||||
|
||||
// html5 video and audio
|
||||
|
@ -659,8 +663,8 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
|
|||
if ($tryoembed)
|
||||
$Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", '<iframe width="' . $a->videowidth . '" height="' . $a->videoheight . '" src="https://www.youtube.com/embed/$1" frameborder="0" ></iframe>', $Text);
|
||||
else
|
||||
$Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism", "https://www.youtube.com/watch?v=$1", $Text);
|
||||
|
||||
$Text = preg_replace("/\[youtube\]([A-Za-z0-9\-_=]+)(.*?)\[\/youtube\]/ism",
|
||||
'<a href="https://www.youtube.com/watch?v=$1" target="external-link">https://www.youtube.com/watch?v=$1</a>', $Text);
|
||||
|
||||
if ($tryoembed) {
|
||||
$Text = preg_replace_callback("/\[vimeo\](https?:\/\/player.vimeo.com\/video\/[0-9]+).*?\[\/vimeo\]/ism",'tryoembed',$Text);
|
||||
|
@ -673,7 +677,8 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
|
|||
if ($tryoembed)
|
||||
$Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", '<iframe width="' . $a->videowidth . '" height="' . $a->videoheight . '" src="https://player.vimeo.com/video/$1" frameborder="0" ></iframe>', $Text);
|
||||
else
|
||||
$Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism", "https://vimeo.com/$1", $Text);
|
||||
$Text = preg_replace("/\[vimeo\]([0-9]+)(.*?)\[\/vimeo\]/ism",
|
||||
'<a href="https://vimeo.com/$1" target="external-link">https://vimeo.com/$1</a>', $Text);
|
||||
|
||||
// $Text = preg_replace("/\[youtube\](.*?)\[\/youtube\]/", '<object width="425" height="350" type="application/x-shockwave-flash" data="http://www.youtube.com/v/$1" ><param name="movie" value="http://www.youtube.com/v/$1"></param><!--[if IE]><embed src="http://www.youtube.com/v/$1" type="application/x-shockwave-flash" width="425" height="350" /><![endif]--></object>', $Text);
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ function delivery_run(&$argv, &$argc){
|
|||
);
|
||||
if(! count($r)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$maxsysload = intval(get_config('system','maxloadavg'));
|
||||
if($maxsysload < 1)
|
||||
|
@ -67,7 +67,7 @@ function delivery_run(&$argv, &$argc){
|
|||
|
||||
// It's ours to deliver. Remove it from the queue.
|
||||
|
||||
q("delete from deliverq where cmd = '%s' and item = %d and contact = %d limit 1",
|
||||
q("delete from deliverq where cmd = '%s' and item = %d and contact = %d",
|
||||
dbesc($cmd),
|
||||
dbesc($item_id),
|
||||
dbesc($contact_id)
|
||||
|
@ -331,7 +331,7 @@ function delivery_run(&$argv, &$argc){
|
|||
if($x && count($x)) {
|
||||
$write_flag = ((($x[0]['rel']) && ($x[0]['rel'] != CONTACT_IS_SHARING)) ? true : false);
|
||||
if((($owner['page-flags'] == PAGE_COMMUNITY) || ($write_flag)) && (! $x[0]['writable'])) {
|
||||
q("update contact set writable = 1 where id = %d limit 1",
|
||||
q("update contact set writable = 1 where id = %d",
|
||||
intval($x[0]['id'])
|
||||
);
|
||||
$x[0]['writable'] = 1;
|
||||
|
@ -430,7 +430,7 @@ function delivery_run(&$argv, &$argc){
|
|||
if($cmd === 'wall-new')
|
||||
$it = $items[0];
|
||||
else {
|
||||
$r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||
$r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||
intval($argv[2]),
|
||||
intval($uid)
|
||||
);
|
||||
|
|
|
@ -983,7 +983,23 @@ function item_store($arr,$force_parent = false) {
|
|||
$arr['app'] = ((x($arr,'app')) ? notags(trim($arr['app'])) : '');
|
||||
$arr['origin'] = ((x($arr,'origin')) ? intval($arr['origin']) : 0 );
|
||||
$arr['guid'] = ((x($arr,'guid')) ? notags(trim($arr['guid'])) : get_guid());
|
||||
$arr['network'] = ((x($arr,'network')) ? trim($arr['network']) : '');
|
||||
|
||||
if ($arr['network'] == "") {
|
||||
$r = q("SELECT `network` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||
intval($arr['contact-id']),
|
||||
intval($arr['uid'])
|
||||
);
|
||||
|
||||
if(count($r))
|
||||
$arr['network'] = $r[0]["network"];
|
||||
|
||||
// Fallback to friendica (why is it empty in some cases?)
|
||||
if ($arr['network'] == "")
|
||||
$arr['network'] = NETWORK_DFRN;
|
||||
|
||||
logger("item_store: Set network to ".$arr["network"]." for ".$arr["uri"], LOGGER_DEBUG);
|
||||
}
|
||||
|
||||
$arr['thr-parent'] = $arr['parent-uri'];
|
||||
if($arr['parent-uri'] === $arr['uri']) {
|
||||
|
@ -1125,7 +1141,7 @@ function item_store($arr,$force_parent = false) {
|
|||
// Set parent id - and also make sure to inherit the parent's ACL's.
|
||||
|
||||
$r = q("UPDATE `item` SET `parent` = %d, `allow_cid` = '%s', `allow_gid` = '%s',
|
||||
`deny_cid` = '%s', `deny_gid` = '%s', `private` = %d, `deleted` = %d WHERE `id` = %d LIMIT 1",
|
||||
`deny_cid` = '%s', `deny_gid` = '%s', `private` = %d, `deleted` = %d WHERE `id` = %d",
|
||||
intval($parent_id),
|
||||
dbesc($allow_cid),
|
||||
dbesc($allow_gid),
|
||||
|
@ -1152,7 +1168,7 @@ function item_store($arr,$force_parent = false) {
|
|||
|
||||
// update the commented timestamp on the parent
|
||||
|
||||
q("UPDATE `item` set `commented` = '%s', `changed` = '%s' WHERE `id` = %d LIMIT 1",
|
||||
q("UPDATE `item` set `commented` = '%s', `changed` = '%s' WHERE `id` = %d",
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
intval($parent_id)
|
||||
|
@ -1277,7 +1293,7 @@ function tag_deliver($uid,$item_id) {
|
|||
// mmh.. no mention.. community page or private group... no wall.. no origin.. top-post (not a comment)
|
||||
// delete it!
|
||||
logger("tag_deliver: no-mention top-level post to communuty or private group. delete.");
|
||||
q("DELETE FROM item WHERE id = %d and uid = %d limit 1",
|
||||
q("DELETE FROM item WHERE id = %d and uid = %d",
|
||||
intval($item_id),
|
||||
intval($uid)
|
||||
);
|
||||
|
@ -1285,7 +1301,7 @@ function tag_deliver($uid,$item_id) {
|
|||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// send a notification
|
||||
|
||||
|
@ -1346,8 +1362,8 @@ function tag_deliver($uid,$item_id) {
|
|||
|
||||
$forum_mode = (($prvgroup) ? 2 : 1);
|
||||
|
||||
q("update item set wall = 1, origin = 1, forum_mode = %d, `owner-name` = '%s', `owner-link` = '%s', `owner-avatar` = '%s',
|
||||
`private` = %d, `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s' where id = %d limit 1",
|
||||
q("update item set wall = 1, origin = 1, forum_mode = %d, `owner-name` = '%s', `owner-link` = '%s', `owner-avatar` = '%s',
|
||||
`private` = %d, `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s' where id = %d",
|
||||
intval($forum_mode),
|
||||
dbesc($c[0]['name']),
|
||||
dbesc($c[0]['url']),
|
||||
|
@ -1498,7 +1514,7 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) {
|
|||
if($perm) {
|
||||
if((($perm == 'rw') && (! intval($contact['writable'])))
|
||||
|| (($perm == 'r') && (intval($contact['writable'])))) {
|
||||
q("update contact set writable = %d where id = %d limit 1",
|
||||
q("update contact set writable = %d where id = %d",
|
||||
intval(($perm == 'rw') ? 1 : 0),
|
||||
intval($contact['id'])
|
||||
);
|
||||
|
@ -1730,12 +1746,12 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
|
|||
else {
|
||||
$resource_id = photo_new_resource();
|
||||
}
|
||||
|
||||
|
||||
$img_str = fetch_url($photo_url,true);
|
||||
// guess mimetype from headers or filename
|
||||
$type = guess_image_type($photo_url,true);
|
||||
|
||||
|
||||
|
||||
|
||||
$img = new Photo($img_str, $type);
|
||||
if($img->is_valid()) {
|
||||
if($have_photo) {
|
||||
|
@ -1760,7 +1776,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
|
|||
$a = get_app();
|
||||
|
||||
q("UPDATE `contact` SET `avatar-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s'
|
||||
WHERE `uid` = %d AND `id` = %d LIMIT 1",
|
||||
WHERE `uid` = %d AND `id` = %d",
|
||||
dbesc(datetime_convert()),
|
||||
dbesc($a->get_baseurl() . '/photo/' . $hash . '-4.'.$img->getExt()),
|
||||
dbesc($a->get_baseurl() . '/photo/' . $hash . '-5.'.$img->getExt()),
|
||||
|
@ -1777,7 +1793,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
|
|||
intval($contact['id'])
|
||||
);
|
||||
|
||||
$x = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1",
|
||||
$x = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `uid` = %d AND `id` = %d",
|
||||
dbesc(notags(trim($new_name))),
|
||||
dbesc(datetime_convert()),
|
||||
intval($contact['uid']),
|
||||
|
@ -1830,7 +1846,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
|
|||
|
||||
// update bdyear
|
||||
|
||||
q("UPDATE `contact` SET `bdyear` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1",
|
||||
q("UPDATE `contact` SET `bdyear` = '%s' WHERE `uid` = %d AND `id` = %d",
|
||||
dbesc(substr($birthday,0,4)),
|
||||
intval($contact['uid']),
|
||||
intval($contact['id'])
|
||||
|
@ -1851,7 +1867,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
|
|||
$community_page = intval($rawtags[0]['data']);
|
||||
}
|
||||
if(is_array($contact) && intval($contact['forum']) != $community_page) {
|
||||
q("update contact set forum = %d where id = %d limit 1",
|
||||
q("update contact set forum = %d where id = %d",
|
||||
intval($community_page),
|
||||
intval($contact['id'])
|
||||
);
|
||||
|
@ -1914,7 +1930,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
|
|||
if(trim($tag) !== trim($xo->body))
|
||||
$newtags[] = trim($tag);
|
||||
}
|
||||
q("update item set tag = '%s' where id = %d limit 1",
|
||||
q("update item set tag = '%s' where id = %d",
|
||||
dbesc(implode(',',$newtags)),
|
||||
intval($i[0]['id'])
|
||||
);
|
||||
|
@ -1938,7 +1954,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
|
|||
else {
|
||||
$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s',
|
||||
`body` = '', `title` = ''
|
||||
WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
|
||||
WHERE `uri` = '%s' AND `uid` = %d",
|
||||
dbesc($when),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc($uri),
|
||||
|
@ -1952,20 +1968,20 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
|
|||
dbesc($item['parent-uri']),
|
||||
intval($item['uid'])
|
||||
);
|
||||
// who is the last child now?
|
||||
$r = q("SELECT `id` FROM `item` WHERE `parent-uri` = '%s' AND `type` != 'activity' AND `deleted` = 0 AND `moderated` = 0 AND `uid` = %d
|
||||
// who is the last child now?
|
||||
$r = q("SELECT `id` FROM `item` WHERE `parent-uri` = '%s' AND `type` != 'activity' AND `deleted` = 0 AND `moderated` = 0 AND `uid` = %d
|
||||
ORDER BY `created` DESC LIMIT 1",
|
||||
dbesc($item['parent-uri']),
|
||||
intval($importer['uid'])
|
||||
);
|
||||
if(count($r)) {
|
||||
q("UPDATE `item` SET `last-child` = 1 WHERE `id` = %d LIMIT 1",
|
||||
q("UPDATE `item` SET `last-child` = 1 WHERE `id` = %d",
|
||||
intval($r[0]['id'])
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2044,13 +2060,13 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
|
|||
// Update content if 'updated' changes
|
||||
|
||||
if(count($r)) {
|
||||
if (edited_timestamp_is_newer($r[0], $datarray)) {
|
||||
if (edited_timestamp_is_newer($r[0], $datarray)) {
|
||||
|
||||
// do not accept (ignore) an earlier edit than one we currently have.
|
||||
if(datetime_convert('UTC','UTC',$datarray['edited']) < $r[0]['edited'])
|
||||
continue;
|
||||
|
||||
$r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
|
||||
$r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d",
|
||||
dbesc($datarray['title']),
|
||||
dbesc($datarray['body']),
|
||||
dbesc($datarray['tag']),
|
||||
|
@ -2070,7 +2086,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
|
|||
dbesc($parent_uri),
|
||||
intval($importer['uid'])
|
||||
);
|
||||
$r = q("UPDATE `item` SET `last-child` = %d , `changed` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
|
||||
$r = q("UPDATE `item` SET `last-child` = %d , `changed` = '%s' WHERE `uri` = '%s' AND `uid` = %d",
|
||||
intval($allow[0]['data']),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc($item_id),
|
||||
|
@ -2119,7 +2135,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
|
|||
if($xo->id && $xo->content) {
|
||||
$newtag = '#[url=' . $xo->id . ']'. $xo->content . '[/url]';
|
||||
if(! (stristr($r[0]['tag'],$newtag))) {
|
||||
q("UPDATE item SET tag = '%s' WHERE id = %d LIMIT 1",
|
||||
q("UPDATE item SET tag = '%s' WHERE id = %d",
|
||||
dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . $newtag),
|
||||
intval($r[0]['id'])
|
||||
);
|
||||
|
@ -2199,7 +2215,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
|
|||
if(datetime_convert('UTC','UTC',$datarray['edited']) < $r[0]['edited'])
|
||||
continue;
|
||||
|
||||
$r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
|
||||
$r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d",
|
||||
dbesc($datarray['title']),
|
||||
dbesc($datarray['body']),
|
||||
dbesc($datarray['tag']),
|
||||
|
@ -2214,7 +2230,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
|
|||
|
||||
$allow = $item->get_item_tags( NAMESPACE_DFRN, 'comment-allow');
|
||||
if($allow && $allow[0]['data'] != $r[0]['last-child']) {
|
||||
$r = q("UPDATE `item` SET `last-child` = %d , `changed` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
|
||||
$r = q("UPDATE `item` SET `last-child` = %d , `changed` = '%s' WHERE `uri` = '%s' AND `uid` = %d",
|
||||
intval($allow[0]['data']),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc($item_id),
|
||||
|
@ -2369,12 +2385,12 @@ function local_delivery($importer,$data) {
|
|||
else {
|
||||
$resource_id = photo_new_resource();
|
||||
}
|
||||
|
||||
|
||||
$img_str = fetch_url($photo_url,true);
|
||||
// guess mimetype from headers or filename
|
||||
$type = guess_image_type($photo_url,true);
|
||||
|
||||
|
||||
|
||||
|
||||
$img = new Photo($img_str, $type);
|
||||
if($img->is_valid()) {
|
||||
if($have_photo) {
|
||||
|
@ -2399,7 +2415,7 @@ function local_delivery($importer,$data) {
|
|||
$a = get_app();
|
||||
|
||||
q("UPDATE `contact` SET `avatar-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s'
|
||||
WHERE `uid` = %d AND `id` = %d LIMIT 1",
|
||||
WHERE `uid` = %d AND `id` = %d",
|
||||
dbesc(datetime_convert()),
|
||||
dbesc($a->get_baseurl() . '/photo/' . $hash . '-4.'.$img->getExt()),
|
||||
dbesc($a->get_baseurl() . '/photo/' . $hash . '-5.'.$img->getExt()),
|
||||
|
@ -2416,7 +2432,7 @@ function local_delivery($importer,$data) {
|
|||
intval($importer['id'])
|
||||
);
|
||||
|
||||
$x = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1",
|
||||
$x = q("UPDATE `contact` SET `name` = '%s', `name-date` = '%s' WHERE `uid` = %d AND `id` = %d",
|
||||
dbesc(notags(trim($new_name))),
|
||||
dbesc(datetime_convert()),
|
||||
intval($importer['importer_uid']),
|
||||
|
@ -2675,7 +2691,7 @@ function local_delivery($importer,$data) {
|
|||
$community_page = intval($rawtags[0]['data']);
|
||||
}
|
||||
if(intval($importer['forum']) != $community_page) {
|
||||
q("update contact set forum = %d where id = %d limit 1",
|
||||
q("update contact set forum = %d where id = %d",
|
||||
intval($community_page),
|
||||
intval($importer['id'])
|
||||
);
|
||||
|
@ -2704,7 +2720,7 @@ function local_delivery($importer,$data) {
|
|||
|
||||
// check for relayed deletes to our conversation
|
||||
|
||||
$is_reply = false;
|
||||
$is_reply = false;
|
||||
$r = q("select * from item where uri = '%s' and uid = %d limit 1",
|
||||
dbesc($uri),
|
||||
intval($importer['importer_uid'])
|
||||
|
@ -2713,7 +2729,7 @@ function local_delivery($importer,$data) {
|
|||
$parent_uri = $r[0]['parent-uri'];
|
||||
if($r[0]['id'] != $r[0]['parent'])
|
||||
$is_reply = true;
|
||||
}
|
||||
}
|
||||
|
||||
if($is_reply) {
|
||||
$community = false;
|
||||
|
@ -2806,7 +2822,7 @@ function local_delivery($importer,$data) {
|
|||
if(trim($tag) !== trim($xo->body))
|
||||
$newtags[] = trim($tag);
|
||||
}
|
||||
q("update item set tag = '%s' where id = %d limit 1",
|
||||
q("update item set tag = '%s' where id = %d",
|
||||
dbesc(implode(',',$newtags)),
|
||||
intval($i[0]['id'])
|
||||
);
|
||||
|
@ -2830,7 +2846,7 @@ function local_delivery($importer,$data) {
|
|||
else {
|
||||
$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s',
|
||||
`body` = '', `title` = ''
|
||||
WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
|
||||
WHERE `uri` = '%s' AND `uid` = %d",
|
||||
dbesc($when),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc($uri),
|
||||
|
@ -2851,7 +2867,7 @@ function local_delivery($importer,$data) {
|
|||
intval($importer['importer_uid'])
|
||||
);
|
||||
if(count($r)) {
|
||||
q("UPDATE `item` SET `last-child` = 1 WHERE `id` = %d LIMIT 1",
|
||||
q("UPDATE `item` SET `last-child` = 1 WHERE `id` = %d",
|
||||
intval($r[0]['id'])
|
||||
);
|
||||
}
|
||||
|
@ -2887,13 +2903,13 @@ function local_delivery($importer,$data) {
|
|||
}
|
||||
else
|
||||
$sql_extra = " and contact.self = 1 and item.wall = 1 ";
|
||||
|
||||
// was the top-level post for this reply written by somebody on this site?
|
||||
// Specifically, the recipient?
|
||||
|
||||
// was the top-level post for this reply written by somebody on this site?
|
||||
// Specifically, the recipient?
|
||||
|
||||
$is_a_remote_comment = false;
|
||||
$top_uri = $parent_uri;
|
||||
|
||||
|
||||
$r = q("select `item`.`parent-uri` from `item`
|
||||
WHERE `item`.`uri` = '%s'
|
||||
LIMIT 1",
|
||||
|
@ -2903,11 +2919,11 @@ function local_delivery($importer,$data) {
|
|||
$top_uri = $r[0]['parent-uri'];
|
||||
|
||||
// POSSIBLE CLEANUP --> Why select so many fields when only forum_mode and wall are used?
|
||||
$r = q("select `item`.`id`, `item`.`uri`, `item`.`tag`, `item`.`forum_mode`,`item`.`origin`,`item`.`wall`,
|
||||
`contact`.`name`, `contact`.`url`, `contact`.`thumb` from `item`
|
||||
LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
|
||||
$r = q("select `item`.`id`, `item`.`uri`, `item`.`tag`, `item`.`forum_mode`,`item`.`origin`,`item`.`wall`,
|
||||
`contact`.`name`, `contact`.`url`, `contact`.`thumb` from `item`
|
||||
LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
|
||||
WHERE `item`.`uri` = '%s' AND (`item`.`parent-uri` = '%s' or `item`.`thr-parent` = '%s')
|
||||
AND `item`.`uid` = %d
|
||||
AND `item`.`uid` = %d
|
||||
$sql_extra
|
||||
LIMIT 1",
|
||||
dbesc($top_uri),
|
||||
|
@ -2954,7 +2970,7 @@ function local_delivery($importer,$data) {
|
|||
continue;
|
||||
|
||||
logger('received updated comment' , LOGGER_DEBUG);
|
||||
$r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
|
||||
$r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d",
|
||||
dbesc($datarray['title']),
|
||||
dbesc($datarray['body']),
|
||||
dbesc($datarray['tag']),
|
||||
|
@ -3030,7 +3046,7 @@ function local_delivery($importer,$data) {
|
|||
intval($importer['importer_uid'])
|
||||
);
|
||||
if(count($i) && ! intval($i[0]['blocktags'])) {
|
||||
q("UPDATE item SET tag = '%s', `edited` = '%s' WHERE id = %d LIMIT 1",
|
||||
q("UPDATE item SET tag = '%s', `edited` = '%s' WHERE id = %d",
|
||||
dbesc($tagp[0]['tag'] . (strlen($tagp[0]['tag']) ? ',' : '') . $newtag),
|
||||
intval($tagp[0]['id']),
|
||||
dbesc(datetime_convert())
|
||||
|
@ -3063,7 +3079,7 @@ function local_delivery($importer,$data) {
|
|||
intval($r[0]['parent'])
|
||||
);
|
||||
|
||||
$r2 = q("UPDATE `item` SET `last-child` = 1, `changed` = '%s' WHERE `uid` = %d AND `id` = %d LIMIT 1",
|
||||
$r2 = q("UPDATE `item` SET `last-child` = 1, `changed` = '%s' WHERE `uid` = %d AND `id` = %d",
|
||||
dbesc(datetime_convert()),
|
||||
intval($importer['importer_uid']),
|
||||
intval($posted_id)
|
||||
|
@ -3122,13 +3138,13 @@ function local_delivery($importer,$data) {
|
|||
// Update content if 'updated' changes
|
||||
|
||||
if(count($r)) {
|
||||
if (edited_timestamp_is_newer($r[0], $datarray)) {
|
||||
if (edited_timestamp_is_newer($r[0], $datarray)) {
|
||||
|
||||
// do not accept (ignore) an earlier edit than one we currently have.
|
||||
if(datetime_convert('UTC','UTC',$datarray['edited']) < $r[0]['edited'])
|
||||
continue;
|
||||
|
||||
$r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
|
||||
$r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d",
|
||||
dbesc($datarray['title']),
|
||||
dbesc($datarray['body']),
|
||||
dbesc($datarray['tag']),
|
||||
|
@ -3148,7 +3164,7 @@ function local_delivery($importer,$data) {
|
|||
dbesc($parent_uri),
|
||||
intval($importer['importer_uid'])
|
||||
);
|
||||
$r = q("UPDATE `item` SET `last-child` = %d , `changed` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
|
||||
$r = q("UPDATE `item` SET `last-child` = %d , `changed` = '%s' WHERE `uri` = '%s' AND `uid` = %d",
|
||||
intval($allow[0]['data']),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc($item_id),
|
||||
|
@ -3193,7 +3209,7 @@ function local_delivery($importer,$data) {
|
|||
// extract tag, if not duplicate, add to parent item
|
||||
if($xo->content) {
|
||||
if(! (stristr($r[0]['tag'],trim($xo->content)))) {
|
||||
q("UPDATE item SET tag = '%s' WHERE id = %d LIMIT 1",
|
||||
q("UPDATE item SET tag = '%s' WHERE id = %d",
|
||||
dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . '#[url=' . $xo->id . ']'. $xo->content . '[/url]'),
|
||||
intval($r[0]['id'])
|
||||
);
|
||||
|
@ -3298,13 +3314,13 @@ function local_delivery($importer,$data) {
|
|||
// Update content if 'updated' changes
|
||||
|
||||
if(count($r)) {
|
||||
if (edited_timestamp_is_newer($r[0], $datarray)) {
|
||||
if (edited_timestamp_is_newer($r[0], $datarray)) {
|
||||
|
||||
// do not accept (ignore) an earlier edit than one we currently have.
|
||||
if(datetime_convert('UTC','UTC',$datarray['edited']) < $r[0]['edited'])
|
||||
continue;
|
||||
|
||||
$r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
|
||||
$r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `edited` = '%s' WHERE `uri` = '%s' AND `uid` = %d",
|
||||
dbesc($datarray['title']),
|
||||
dbesc($datarray['body']),
|
||||
dbesc($datarray['tag']),
|
||||
|
@ -3319,7 +3335,7 @@ function local_delivery($importer,$data) {
|
|||
|
||||
$allow = $item->get_item_tags( NAMESPACE_DFRN, 'comment-allow');
|
||||
if($allow && $allow[0]['data'] != $r[0]['last-child']) {
|
||||
$r = q("UPDATE `item` SET `last-child` = %d , `changed` = '%s' WHERE `uri` = '%s' AND `uid` = %d LIMIT 1",
|
||||
$r = q("UPDATE `item` SET `last-child` = %d , `changed` = '%s' WHERE `uri` = '%s' AND `uid` = %d",
|
||||
intval($allow[0]['data']),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc($item_id),
|
||||
|
@ -3427,7 +3443,7 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
|
|||
if(is_array($contact)) {
|
||||
if(($contact['network'] == NETWORK_OSTATUS && $contact['rel'] == CONTACT_IS_SHARING)
|
||||
|| ($sharing && $contact['rel'] == CONTACT_IS_FOLLOWER)) {
|
||||
$r = q("UPDATE `contact` SET `rel` = %d, `writable` = 1 WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||
$r = q("UPDATE `contact` SET `rel` = %d, `writable` = 1 WHERE `id` = %d AND `uid` = %d",
|
||||
intval(CONTACT_IS_FRIEND),
|
||||
intval($contact['id']),
|
||||
intval($importer['uid'])
|
||||
|
@ -3506,7 +3522,7 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
|
|||
function lose_follower($importer,$contact,$datarray,$item) {
|
||||
|
||||
if(($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_SHARING)) {
|
||||
q("UPDATE `contact` SET `rel` = %d WHERE `id` = %d LIMIT 1",
|
||||
q("UPDATE `contact` SET `rel` = %d WHERE `id` = %d",
|
||||
intval(CONTACT_IS_SHARING),
|
||||
intval($contact['id'])
|
||||
);
|
||||
|
@ -3519,7 +3535,7 @@ function lose_follower($importer,$contact,$datarray,$item) {
|
|||
function lose_sharer($importer,$contact,$datarray,$item) {
|
||||
|
||||
if(($contact['rel'] == CONTACT_IS_FRIEND) || ($contact['rel'] == CONTACT_IS_FOLLOWER)) {
|
||||
q("UPDATE `contact` SET `rel` = %d WHERE `id` = %d LIMIT 1",
|
||||
q("UPDATE `contact` SET `rel` = %d WHERE `id` = %d",
|
||||
intval(CONTACT_IS_FOLLOWER),
|
||||
intval($contact['id'])
|
||||
);
|
||||
|
@ -3558,7 +3574,7 @@ function subscribe_to_hub($url,$importer,$contact,$hubmode = 'subscribe') {
|
|||
logger('subscribe_to_hub: ' . $hubmode . ' ' . $contact['name'] . ' to hub ' . $url . ' endpoint: ' . $push_url . ' with verifier ' . $verify_token);
|
||||
|
||||
if(! strlen($contact['hub-verify'])) {
|
||||
$r = q("UPDATE `contact` SET `hub-verify` = '%s' WHERE `id` = %d LIMIT 1",
|
||||
$r = q("UPDATE `contact` SET `hub-verify` = '%s' WHERE `id` = %d",
|
||||
dbesc($verify_token),
|
||||
intval($contact['id'])
|
||||
);
|
||||
|
@ -4031,7 +4047,7 @@ function drop_item($id,$interactive = true) {
|
|||
logger('delete item: ' . $item['id'], LOGGER_DEBUG);
|
||||
// delete the item
|
||||
|
||||
$r = q("UPDATE `item` SET `deleted` = 1, `title` = '', `body` = '', `edited` = '%s', `changed` = '%s' WHERE `id` = %d LIMIT 1",
|
||||
$r = q("UPDATE `item` SET `deleted` = 1, `title` = '', `body` = '', `edited` = '%s', `changed` = '%s' WHERE `id` = %d",
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
intval($item['id'])
|
||||
|
@ -4073,7 +4089,7 @@ function drop_item($id,$interactive = true) {
|
|||
// If item is a link to an event, nuke the event record.
|
||||
|
||||
if(intval($item['event-id'])) {
|
||||
q("DELETE FROM `event` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||
q("DELETE FROM `event` WHERE `id` = %d AND `uid` = %d",
|
||||
intval($item['event-id']),
|
||||
intval($item['uid'])
|
||||
);
|
||||
|
@ -4082,6 +4098,9 @@ function drop_item($id,$interactive = true) {
|
|||
|
||||
// clean up item_id and sign meta-data tables
|
||||
|
||||
/*
|
||||
// Old code - caused very long queries and warning entries in the mysql logfiles:
|
||||
|
||||
$r = q("DELETE FROM item_id where iid in (select id from item where parent = %d and uid = %d)",
|
||||
intval($item['id']),
|
||||
intval($item['uid'])
|
||||
|
@ -4091,6 +4110,31 @@ function drop_item($id,$interactive = true) {
|
|||
intval($item['id']),
|
||||
intval($item['uid'])
|
||||
);
|
||||
*/
|
||||
|
||||
// The new code splits the queries since the mysql optimizer really has bad problems with subqueries
|
||||
|
||||
// Creating list of parents
|
||||
$r = q("select id from item where parent = %d and uid = %d",
|
||||
intval($item['id']),
|
||||
intval($item['uid'])
|
||||
);
|
||||
|
||||
$parentid = "";
|
||||
|
||||
foreach ($r AS $row) {
|
||||
if ($parentid != "")
|
||||
$parentid .= ", ";
|
||||
|
||||
$parentid .= $row["id"];
|
||||
}
|
||||
|
||||
// Now delete them
|
||||
if ($parentid != "") {
|
||||
$r = q("DELETE FROM item_id where iid in (%s)", dbesc($parentid));
|
||||
|
||||
$r = q("DELETE FROM sign where iid in (%s)", dbesc($parentid));
|
||||
}
|
||||
|
||||
// If it's the parent of a comment thread, kill all the kids
|
||||
|
||||
|
@ -4118,7 +4162,7 @@ function drop_item($id,$interactive = true) {
|
|||
intval($item['uid'])
|
||||
);
|
||||
if(count($r)) {
|
||||
q("UPDATE `item` SET `last-child` = 1 WHERE `id` = %d LIMIT 1",
|
||||
q("UPDATE `item` SET `last-child` = 1 WHERE `id` = %d",
|
||||
intval($r[0]['id'])
|
||||
);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ function lock_function($fn_name, $block = true, $wait_sec = 2, $timeout = 30) {
|
|||
);
|
||||
|
||||
if((count($r)) && (! $r[0]['locked'])) {
|
||||
q("UPDATE locks SET locked = 1 WHERE name = '%s' LIMIT 1",
|
||||
q("UPDATE locks SET locked = 1 WHERE name = '%s'",
|
||||
dbesc($fn_name)
|
||||
);
|
||||
$got_lock = true;
|
||||
|
@ -65,7 +65,7 @@ function block_on_function_lock($fn_name, $wait_sec = 2, $timeout = 30) {
|
|||
|
||||
if(! function_exists('unlock_function')) {
|
||||
function unlock_function($fn_name) {
|
||||
$r = q("UPDATE locks SET locked = 0 WHERE name = '%s' LIMIT 1",
|
||||
$r = q("UPDATE locks SET locked = 0 WHERE name = '%s'",
|
||||
dbesc($fn_name)
|
||||
);
|
||||
|
||||
|
|
|
@ -783,7 +783,7 @@ function add_fcontact($arr,$update = false) {
|
|||
`alias` = '%s',
|
||||
`pubkey` = '%s',
|
||||
`updated` = '%s'
|
||||
WHERE `url` = '%s' AND `network` = '%s' LIMIT 1",
|
||||
WHERE `url` = '%s' AND `network` = '%s'",
|
||||
dbesc($arr['name']),
|
||||
dbesc($arr['photo']),
|
||||
dbesc($arr['request']),
|
||||
|
|
|
@ -111,7 +111,7 @@ function onepoll_run(&$argv, &$argc){
|
|||
|
||||
|
||||
$importer_uid = $contact['uid'];
|
||||
|
||||
|
||||
$r = q("SELECT `contact`.*, `user`.`page-flags` FROM `contact` LEFT JOIN `user` on `contact`.`uid` = `user`.`uid` WHERE `user`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1",
|
||||
intval($importer_uid)
|
||||
);
|
||||
|
@ -122,14 +122,14 @@ function onepoll_run(&$argv, &$argc){
|
|||
|
||||
logger("onepoll: poll: ({$contact['id']}) IMPORTER: {$importer['name']}, CONTACT: {$contact['name']}");
|
||||
|
||||
$last_update = (($contact['last-update'] === '0000-00-00 00:00:00')
|
||||
$last_update = (($contact['last-update'] === '0000-00-00 00:00:00')
|
||||
? datetime_convert('UTC','UTC','now - 7 days', ATOM_TIME)
|
||||
: datetime_convert('UTC','UTC',$contact['last-update'], ATOM_TIME)
|
||||
);
|
||||
|
||||
if($contact['network'] === NETWORK_DFRN) {
|
||||
|
||||
|
||||
|
||||
$idtosend = $orig_id = (($contact['dfrn-id']) ? $contact['dfrn-id'] : $contact['issued-id']);
|
||||
if(intval($contact['duplex']) && $contact['dfrn-id'])
|
||||
$idtosend = '0:' . $orig_id;
|
||||
|
@ -142,12 +142,12 @@ function onepoll_run(&$argv, &$argc){
|
|||
// But this may be our first communication, so set the writable flag if it isn't set already.
|
||||
|
||||
if(! intval($contact['writable']))
|
||||
q("update contact set writable = 1 where id = %d limit 1", intval($contact['id']));
|
||||
q("update contact set writable = 1 where id = %d", intval($contact['id']));
|
||||
|
||||
|
||||
$url = $contact['poll'] . '?dfrn_id=' . $idtosend
|
||||
. '&dfrn_version=' . DFRN_PROTOCOL_VERSION
|
||||
. '&type=data&last_update=' . $last_update
|
||||
$url = $contact['poll'] . '?dfrn_id=' . $idtosend
|
||||
. '&dfrn_version=' . DFRN_PROTOCOL_VERSION
|
||||
. '&type=data&last_update=' . $last_update
|
||||
. '&perm=' . $perm ;
|
||||
|
||||
$handshake_xml = fetch_url($url);
|
||||
|
@ -160,13 +160,13 @@ function onepoll_run(&$argv, &$argc){
|
|||
logger("poller: $url appears to be dead - marking for death ");
|
||||
|
||||
// dead connection - might be a transient event, or this might
|
||||
// mean the software was uninstalled or the domain expired.
|
||||
// mean the software was uninstalled or the domain expired.
|
||||
// Will keep trying for one month.
|
||||
|
||||
mark_for_death($contact);
|
||||
|
||||
// set the last-update so we don't keep polling
|
||||
$r = q("UPDATE `contact` SET `last-update` = '%s' WHERE `id` = %d LIMIT 1",
|
||||
$r = q("UPDATE `contact` SET `last-update` = '%s' WHERE `id` = %d",
|
||||
dbesc(datetime_convert()),
|
||||
intval($contact['id'])
|
||||
);
|
||||
|
@ -179,7 +179,7 @@ function onepoll_run(&$argv, &$argc){
|
|||
|
||||
mark_for_death($contact);
|
||||
|
||||
$r = q("UPDATE `contact` SET `last-update` = '%s' WHERE `id` = %d LIMIT 1",
|
||||
$r = q("UPDATE `contact` SET `last-update` = '%s' WHERE `id` = %d",
|
||||
dbesc(datetime_convert()),
|
||||
intval($contact['id'])
|
||||
);
|
||||
|
@ -188,7 +188,7 @@ function onepoll_run(&$argv, &$argc){
|
|||
|
||||
|
||||
$res = parse_xml_string($handshake_xml);
|
||||
|
||||
|
||||
if(intval($res->status) == 1) {
|
||||
logger("poller: $url replied status 1 - marking for death ");
|
||||
|
||||
|
@ -196,7 +196,7 @@ function onepoll_run(&$argv, &$argc){
|
|||
// set the last-update so we don't keep polling
|
||||
|
||||
|
||||
$r = q("UPDATE `contact` SET `last-update` = '%s' WHERE `id` = %d LIMIT 1",
|
||||
$r = q("UPDATE `contact` SET `last-update` = '%s' WHERE `id` = %d",
|
||||
dbesc(datetime_convert()),
|
||||
intval($contact['id'])
|
||||
);
|
||||
|
@ -213,7 +213,7 @@ function onepoll_run(&$argv, &$argc){
|
|||
return;
|
||||
|
||||
if(((float) $res->dfrn_version > 2.21) && ($contact['poco'] == '')) {
|
||||
q("update contact set poco = '%s' where id = %d limit 1",
|
||||
q("update contact set poco = '%s' where id = %d",
|
||||
dbesc(str_replace('/profile/','/poco/', $contact['url'])),
|
||||
intval($contact['id'])
|
||||
);
|
||||
|
@ -267,7 +267,7 @@ function onepoll_run(&$argv, &$argc){
|
|||
$stat_writeable = 1;
|
||||
|
||||
if($stat_writeable != $contact['writable']) {
|
||||
q("UPDATE `contact` SET `writable` = %d WHERE `id` = %d LIMIT 1",
|
||||
q("UPDATE `contact` SET `writable` = %d WHERE `id` = %d",
|
||||
intval($stat_writeable),
|
||||
intval($contact['id'])
|
||||
);
|
||||
|
@ -305,7 +305,7 @@ function onepoll_run(&$argv, &$argc){
|
|||
unset($password);
|
||||
logger("Mail: Connect to " . $mailconf[0]['user']);
|
||||
if($mbox) {
|
||||
q("UPDATE `mailacct` SET `last_check` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||
q("UPDATE `mailacct` SET `last_check` = '%s' WHERE `id` = %d AND `uid` = %d",
|
||||
dbesc(datetime_convert()),
|
||||
intval($mailconf[0]['id']),
|
||||
intval($importer_uid)
|
||||
|
@ -347,7 +347,7 @@ function onepoll_run(&$argv, &$argc){
|
|||
// Only delete when mails aren't automatically moved or deleted
|
||||
if (($mailconf[0]['action'] != 1) AND ($mailconf[0]['action'] != 3))
|
||||
if($meta->deleted && ! $r[0]['deleted']) {
|
||||
q("UPDATE `item` SET `deleted` = 1, `changed` = '%s' WHERE `id` = %d LIMIT 1",
|
||||
q("UPDATE `item` SET `deleted` = 1, `changed` = '%s' WHERE `id` = %d",
|
||||
dbesc(datetime_convert()),
|
||||
intval($r[0]['id'])
|
||||
);
|
||||
|
@ -496,7 +496,7 @@ function onepoll_run(&$argv, &$argc){
|
|||
dbesc($datarray['parent-uri']),
|
||||
intval($importer_uid)
|
||||
);
|
||||
q("UPDATE `item` SET `last-child` = 1 WHERE `id` = %d LIMIT 1",
|
||||
q("UPDATE `item` SET `last-child` = 1 WHERE `id` = %d",
|
||||
intval($stored_item)
|
||||
);
|
||||
switch ($mailconf[0]['action']) {
|
||||
|
@ -536,7 +536,7 @@ function onepoll_run(&$argv, &$argc){
|
|||
logger('poller: received xml : ' . $xml, LOGGER_DATA);
|
||||
if((! strstr($xml,'<?xml')) && (! strstr($xml,'<rss'))) {
|
||||
logger('poller: post_handshake: response from ' . $url . ' did not contain XML.');
|
||||
$r = q("UPDATE `contact` SET `last-update` = '%s' WHERE `id` = %d LIMIT 1",
|
||||
$r = q("UPDATE `contact` SET `last-update` = '%s' WHERE `id` = %d",
|
||||
dbesc(datetime_convert()),
|
||||
intval($contact['id'])
|
||||
);
|
||||
|
@ -574,7 +574,7 @@ function onepoll_run(&$argv, &$argc){
|
|||
|
||||
$updated = datetime_convert();
|
||||
|
||||
$r = q("UPDATE `contact` SET `last-update` = '%s', `success_update` = '%s' WHERE `id` = %d LIMIT 1",
|
||||
$r = q("UPDATE `contact` SET `last-update` = '%s', `success_update` = '%s' WHERE `id` = %d",
|
||||
dbesc($updated),
|
||||
dbesc($updated),
|
||||
intval($contact['id'])
|
||||
|
|
|
@ -42,7 +42,7 @@ function install_plugin($plugin) {
|
|||
// This way the system won't fall over dead during the update.
|
||||
|
||||
if(file_exists('addon/' . $plugin . '/.hidden')) {
|
||||
q("update addon set hidden = 1 where name = '%s' limit 1",
|
||||
q("update addon set hidden = 1 where name = '%s'",
|
||||
dbesc($plugin)
|
||||
);
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ function reload_plugins() {
|
|||
$func = $pl . '_install';
|
||||
$func();
|
||||
}
|
||||
q("UPDATE `addon` SET `timestamp` = %d WHERE `id` = %d LIMIT 1",
|
||||
q("UPDATE `addon` SET `timestamp` = %d WHERE `id` = %d",
|
||||
intval($t),
|
||||
intval($i['id'])
|
||||
);
|
||||
|
@ -104,7 +104,7 @@ function reload_plugins() {
|
|||
}
|
||||
|
||||
}}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -132,7 +132,7 @@ function register_hook($hook,$file,$function,$priority=0) {
|
|||
if(! function_exists('unregister_hook')) {
|
||||
function unregister_hook($hook,$file,$function) {
|
||||
|
||||
$r = q("DELETE FROM `hook` WHERE `hook` = '%s' AND `file` = '%s' AND `function` = '%s' LIMIT 1",
|
||||
$r = q("DELETE FROM `hook` WHERE `hook` = '%s' AND `file` = '%s' AND `function` = '%s'",
|
||||
dbesc($hook),
|
||||
dbesc($file),
|
||||
dbesc($function)
|
||||
|
@ -175,7 +175,7 @@ function call_hooks($name, &$data = null) {
|
|||
}
|
||||
else {
|
||||
// remove orphan hooks
|
||||
q("delete from hook where hook = '%s' and file = '%s' and function = '%s' limit 1",
|
||||
q("delete from hook where hook = '%s' and file = '%s' and function = '%s'",
|
||||
dbesc($name),
|
||||
dbesc($hook[0]),
|
||||
dbesc($hook[1])
|
||||
|
|
|
@ -6,12 +6,12 @@
|
|||
$session_exists = 0;
|
||||
$session_expire = 180000;
|
||||
|
||||
if(! function_exists('ref_session_open')) {
|
||||
if(! function_exists('ref_session_open')) {
|
||||
function ref_session_open ($s,$n) {
|
||||
return true;
|
||||
}}
|
||||
|
||||
if(! function_exists('ref_session_read')) {
|
||||
if(! function_exists('ref_session_read')) {
|
||||
function ref_session_read ($id) {
|
||||
global $session_exists;
|
||||
if(x($id))
|
||||
|
@ -23,20 +23,20 @@ function ref_session_read ($id) {
|
|||
return '';
|
||||
}}
|
||||
|
||||
if(! function_exists('ref_session_write')) {
|
||||
if(! function_exists('ref_session_write')) {
|
||||
function ref_session_write ($id,$data) {
|
||||
global $session_exists, $session_expire;
|
||||
if(! $id || ! $data) {
|
||||
return false;
|
||||
if(! $id || ! $data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$expire = time() + $session_expire;
|
||||
$default_expire = time() + 300;
|
||||
|
||||
if($session_exists)
|
||||
$r = q("UPDATE `session`
|
||||
SET `data` = '%s', `expire` = '%s'
|
||||
WHERE `sid` = '%s' LIMIT 1",
|
||||
$r = q("UPDATE `session`
|
||||
SET `data` = '%s', `expire` = '%s'
|
||||
WHERE `sid` = '%s'",
|
||||
dbesc($data), dbesc($expire), dbesc($id));
|
||||
else
|
||||
$r = q("INSERT INTO `session`
|
||||
|
@ -46,18 +46,18 @@ function ref_session_write ($id,$data) {
|
|||
return true;
|
||||
}}
|
||||
|
||||
if(! function_exists('ref_session_close')) {
|
||||
if(! function_exists('ref_session_close')) {
|
||||
function ref_session_close() {
|
||||
return true;
|
||||
}}
|
||||
|
||||
if(! function_exists('ref_session_destroy')) {
|
||||
if(! function_exists('ref_session_destroy')) {
|
||||
function ref_session_destroy ($id) {
|
||||
q("DELETE FROM `session` WHERE `sid` = '%s'", dbesc($id));
|
||||
return true;
|
||||
}}
|
||||
|
||||
if(! function_exists('ref_session_gc')) {
|
||||
if(! function_exists('ref_session_gc')) {
|
||||
function ref_session_gc($expire) {
|
||||
q("DELETE FROM `session` WHERE `expire` < %d", dbesc(time()));
|
||||
q("OPTIMIZE TABLE `sess_data`");
|
||||
|
|
|
@ -92,8 +92,8 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
|
|||
}
|
||||
|
||||
if((! $name) || (! $profile_url) || (! $profile_photo))
|
||||
continue;
|
||||
|
||||
continue;
|
||||
|
||||
$x = q("select * from `gcontact` where `nurl` = '%s' limit 1",
|
||||
dbesc(normalise_link($profile_url))
|
||||
);
|
||||
|
@ -102,8 +102,8 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
|
|||
$gcid = $x[0]['id'];
|
||||
|
||||
if($x[0]['name'] != $name || $x[0]['photo'] != $profile_photo) {
|
||||
q("update gcontact set `name` = '%s', `photo` = '%s', `connect` = '%s', `url` = '%s'
|
||||
where `nurl` = '%s' limit 1",
|
||||
q("update gcontact set `name` = '%s', `photo` = '%s', `connect` = '%s', `url` = '%s'
|
||||
where `nurl` = '%s'",
|
||||
dbesc($name),
|
||||
dbesc($profile_photo),
|
||||
dbesc($connect_url),
|
||||
|
@ -146,7 +146,7 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
|
|||
);
|
||||
}
|
||||
else {
|
||||
q("update glink set updated = '%s' where `cid` = %d and `uid` = %d and `gcid` = %d and zcid = %d limit 1",
|
||||
q("update glink set updated = '%s' where `cid` = %d and `uid` = %d and `gcid` = %d and zcid = %d",
|
||||
dbesc(datetime_convert()),
|
||||
intval($cid),
|
||||
intval($uid),
|
||||
|
|
11
index.php
11
index.php
|
@ -494,9 +494,14 @@ var num = $pageno;
|
|||
|
||||
$(window).scroll(function(e){
|
||||
|
||||
//if ($(window).scrollTop() == $(document).height() - $(window).height()){
|
||||
if ($(window).scrollTop() > $("section").height() - $(window).height()){
|
||||
loadcontent();
|
||||
if ($(document).height() != $(window).height()) {
|
||||
// First method that is expected to work - but has problems with Chrome
|
||||
if ($(window).scrollTop() == $(document).height() - $(window).height())
|
||||
loadcontent();
|
||||
} else {
|
||||
// This method works with Chrome - but seems to be much slower in Firefox
|
||||
if ($(window).scrollTop() > (($("section").height() + $("header").height() + $("footer").height()) - $(window).height()))
|
||||
loadcontent();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -191,9 +191,14 @@ function content_content(&$a, $update = 0) {
|
|||
}*/
|
||||
|
||||
if($tag) {
|
||||
$sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d ",
|
||||
dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG));
|
||||
$sql_table = "`term` LEFT JOIN `item` ON `item`.`id` = `term`.`oid` AND `item`.`uid` = `term`.`uid` ";
|
||||
//$sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d ",
|
||||
// dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG));
|
||||
//$sql_table = "`term` LEFT JOIN `item` ON `item`.`id` = `term`.`oid` AND `item`.`uid` = `term`.`uid` ";
|
||||
|
||||
$sql_extra = "";
|
||||
$sql_table = sprintf("`item` INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
|
||||
dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG), intval(local_user()));
|
||||
|
||||
} else {
|
||||
if (get_config('system','use_fulltext_engine'))
|
||||
$sql_extra = sprintf(" AND MATCH (`item`.`body`, `item`.`title`) AGAINST ('%s' in boolean mode) ", dbesc(protect_sprintf($search)));
|
||||
|
|
|
@ -40,7 +40,7 @@ function dfrn_notify_post(&$a) {
|
|||
xml_status(3);
|
||||
}
|
||||
|
||||
$r = q("DELETE FROM `challenge` WHERE `dfrn-id` = '%s' AND `challenge` = '%s' LIMIT 1",
|
||||
$r = q("DELETE FROM `challenge` WHERE `dfrn-id` = '%s' AND `challenge` = '%s'",
|
||||
dbesc($dfrn_id),
|
||||
dbesc($challenge)
|
||||
);
|
||||
|
@ -62,21 +62,21 @@ function dfrn_notify_post(&$a) {
|
|||
xml_status(3);
|
||||
break; // NOTREACHED
|
||||
}
|
||||
|
||||
|
||||
// be careful - $importer will contain both the contact information for the contact
|
||||
// sending us the post, and also the user information for the person receiving it.
|
||||
// since they are mixed together, it is easy to get them confused.
|
||||
|
||||
$r = q("SELECT `contact`.*, `contact`.`uid` AS `importer_uid`,
|
||||
`contact`.`pubkey` AS `cpubkey`,
|
||||
`contact`.`prvkey` AS `cprvkey`,
|
||||
`contact`.`thumb` AS `thumb`,
|
||||
$r = q("SELECT `contact`.*, `contact`.`uid` AS `importer_uid`,
|
||||
`contact`.`pubkey` AS `cpubkey`,
|
||||
`contact`.`prvkey` AS `cprvkey`,
|
||||
`contact`.`thumb` AS `thumb`,
|
||||
`contact`.`url` as `url`,
|
||||
`contact`.`name` as `senderName`,
|
||||
`user`.*
|
||||
FROM `contact`
|
||||
LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`
|
||||
WHERE `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
||||
`user`.*
|
||||
FROM `contact`
|
||||
LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`
|
||||
WHERE `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
||||
AND `user`.`nickname` = '%s' AND `user`.`account_expired` = 0 AND `user`.`account_removed` = 0 $sql_extra LIMIT 1",
|
||||
dbesc($a->argv[1])
|
||||
);
|
||||
|
@ -87,12 +87,12 @@ function dfrn_notify_post(&$a) {
|
|||
//NOTREACHED
|
||||
}
|
||||
|
||||
// $importer in this case contains the contact record for the remote contact joined with the user record of our user.
|
||||
// $importer in this case contains the contact record for the remote contact joined with the user record of our user.
|
||||
|
||||
$importer = $r[0];
|
||||
|
||||
if((($writable != (-1)) && ($writable != $importer['writable'])) || ($importer['forum'] != $forum) || ($importer['prv'] != $prv)) {
|
||||
q("UPDATE `contact` SET `writable` = %d, forum = %d, prv = %d WHERE `id` = %d LIMIT 1",
|
||||
q("UPDATE `contact` SET `writable` = %d, forum = %d, prv = %d WHERE `id` = %d",
|
||||
intval(($writable == (-1)) ? $importer['writable'] : $writable),
|
||||
intval($forum),
|
||||
intval($prv),
|
||||
|
@ -117,7 +117,7 @@ function dfrn_notify_post(&$a) {
|
|||
* Relationship is dissolved permanently
|
||||
*/
|
||||
|
||||
require_once('include/Contact.php');
|
||||
require_once('include/Contact.php');
|
||||
contact_remove($importer['id']);
|
||||
logger('relationship dissolved : ' . $importer['name'] . ' dissolved ' . $importer['username']);
|
||||
xml_status(0);
|
||||
|
@ -218,8 +218,8 @@ function dfrn_notify_content(&$a) {
|
|||
break; // NOTREACHED
|
||||
}
|
||||
|
||||
$r = q("SELECT `contact`.*, `user`.`nickname`, `user`.`page-flags` FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid`
|
||||
WHERE `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `user`.`nickname` = '%s'
|
||||
$r = q("SELECT `contact`.*, `user`.`nickname`, `user`.`page-flags` FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid`
|
||||
WHERE `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `user`.`nickname` = '%s'
|
||||
AND `user`.`account_expired` = 0 AND `user`.`account_removed` = 0 $sql_extra LIMIT 1",
|
||||
dbesc($a->argv[1])
|
||||
);
|
||||
|
@ -265,13 +265,13 @@ function dfrn_notify_content(&$a) {
|
|||
|
||||
header("Content-type: text/xml");
|
||||
|
||||
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n"
|
||||
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n"
|
||||
. '<dfrn_notify>' . "\r\n"
|
||||
. "\t" . '<status>' . $status . '</status>' . "\r\n"
|
||||
. "\t" . '<dfrn_version>' . DFRN_PROTOCOL_VERSION . '</dfrn_version>' . "\r\n"
|
||||
. "\t" . '<rino>' . $rino . '</rino>' . "\r\n"
|
||||
. "\t" . '<perm>' . $perm . '</perm>' . "\r\n"
|
||||
. "\t" . '<dfrn_id>' . $encrypted_id . '</dfrn_id>' . "\r\n"
|
||||
. "\t" . '<perm>' . $perm . '</perm>' . "\r\n"
|
||||
. "\t" . '<dfrn_id>' . $encrypted_id . '</dfrn_id>' . "\r\n"
|
||||
. "\t" . '<challenge>' . $challenge . '</challenge>' . "\r\n"
|
||||
. '</dfrn_notify>' . "\r\n" ;
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ function dfrn_poll_init(&$a) {
|
|||
http_status_exit(403);
|
||||
$user = $r[0]['nickname'];
|
||||
}
|
||||
|
||||
|
||||
logger('dfrn_poll: public feed request from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . $user);
|
||||
header("Content-type: application/atom+xml");
|
||||
echo get_feed_for($a, '', $user,$last_update);
|
||||
|
@ -71,13 +71,13 @@ function dfrn_poll_init(&$a) {
|
|||
break; // NOTREACHED
|
||||
}
|
||||
|
||||
$r = q("SELECT `contact`.*, `user`.`username`, `user`.`nickname`
|
||||
$r = q("SELECT `contact`.*, `user`.`username`, `user`.`nickname`
|
||||
FROM `contact` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`
|
||||
WHERE `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
||||
WHERE `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
||||
AND `user`.`nickname` = '%s' $sql_extra LIMIT 1",
|
||||
dbesc($a->argv[1])
|
||||
);
|
||||
|
||||
|
||||
if(count($r)) {
|
||||
|
||||
$s = fetch_url($r[0]['poll'] . '?dfrn_id=' . $my_id . '&type=profile-check');
|
||||
|
@ -104,10 +104,10 @@ function dfrn_poll_init(&$a) {
|
|||
// Visitors get 1 day session.
|
||||
$session_id = session_id();
|
||||
$expire = time() + 86400;
|
||||
q("UPDATE `session` SET `expire` = '%s' WHERE `sid` = '%s' LIMIT 1",
|
||||
q("UPDATE `session` SET `expire` = '%s' WHERE `sid` = '%s'",
|
||||
dbesc($expire),
|
||||
dbesc($session_id)
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
$profile = $r[0]['nickname'];
|
||||
|
@ -211,13 +211,13 @@ function dfrn_poll_post(&$a) {
|
|||
$ptype = ((x($_POST,'type')) ? $_POST['type'] : '');
|
||||
$dfrn_version = ((x($_POST,'dfrn_version')) ? (float) $_POST['dfrn_version'] : 2.0);
|
||||
$perm = ((x($_POST,'perm')) ? $_POST['perm'] : 'r');
|
||||
|
||||
|
||||
if($ptype === 'profile-check') {
|
||||
|
||||
if((strlen($challenge)) && (strlen($sec))) {
|
||||
|
||||
logger('dfrn_poll: POST: profile-check');
|
||||
|
||||
|
||||
q("DELETE FROM `profile_check` WHERE `expire` < " . intval(time()));
|
||||
$r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1",
|
||||
dbesc($sec)
|
||||
|
@ -289,7 +289,7 @@ function dfrn_poll_post(&$a) {
|
|||
$type = $r[0]['type'];
|
||||
$last_update = $r[0]['last_update'];
|
||||
|
||||
$r = q("DELETE FROM `challenge` WHERE `dfrn-id` = '%s' AND `challenge` = '%s' LIMIT 1",
|
||||
$r = q("DELETE FROM `challenge` WHERE `dfrn-id` = '%s' AND `challenge` = '%s'",
|
||||
dbesc($dfrn_id),
|
||||
dbesc($challenge)
|
||||
);
|
||||
|
@ -323,7 +323,7 @@ function dfrn_poll_post(&$a) {
|
|||
|
||||
$contact = $r[0];
|
||||
$owner_uid = $r[0]['uid'];
|
||||
$contact_id = $r[0]['id'];
|
||||
$contact_id = $r[0]['id'];
|
||||
|
||||
|
||||
if($type === 'reputation' && strlen($url)) {
|
||||
|
@ -356,7 +356,7 @@ function dfrn_poll_post(&$a) {
|
|||
}
|
||||
else {
|
||||
|
||||
// Update the writable flag if it changed
|
||||
// Update the writable flag if it changed
|
||||
logger('dfrn_poll: post request feed: ' . print_r($_POST,true),LOGGER_DATA);
|
||||
if($dfrn_version >= 2.21) {
|
||||
if($perm === 'rw')
|
||||
|
@ -365,13 +365,13 @@ function dfrn_poll_post(&$a) {
|
|||
$writable = 0;
|
||||
|
||||
if($writable != $contact['writable']) {
|
||||
q("UPDATE `contact` SET `writable` = %d WHERE `id` = %d LIMIT 1",
|
||||
q("UPDATE `contact` SET `writable` = %d WHERE `id` = %d",
|
||||
intval($writable),
|
||||
intval($contact_id)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
header("Content-type: application/atom+xml");
|
||||
$o = get_feed_for($a,$dfrn_id, $a->argv[1], $last_update, $direction);
|
||||
echo $o;
|
||||
|
@ -440,9 +440,9 @@ function dfrn_poll_content(&$a) {
|
|||
|
||||
$nickname = $a->argv[1];
|
||||
|
||||
$r = q("SELECT `contact`.*, `user`.`username`, `user`.`nickname`
|
||||
$r = q("SELECT `contact`.*, `user`.`username`, `user`.`nickname`
|
||||
FROM `contact` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`
|
||||
WHERE `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
||||
WHERE `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
||||
AND `user`.`nickname` = '%s' $sql_extra LIMIT 1",
|
||||
dbesc($nickname)
|
||||
);
|
||||
|
@ -522,8 +522,8 @@ function dfrn_poll_content(&$a) {
|
|||
|
||||
logger('dfrn_poll: secure profile: challenge: ' . $xml->challenge . ' expecting ' . $hash);
|
||||
logger('dfrn_poll: secure profile: sec: ' . $xml->sec . ' expecting ' . $sec);
|
||||
|
||||
|
||||
|
||||
|
||||
if(((int) $xml->status == 0) && ($xml->challenge == $hash) && ($xml->sec == $sec)) {
|
||||
$_SESSION['authenticated'] = 1;
|
||||
if(! x($_SESSION,'remote'))
|
||||
|
@ -537,12 +537,12 @@ function dfrn_poll_content(&$a) {
|
|||
// Visitors get 1 day session.
|
||||
$session_id = session_id();
|
||||
$expire = time() + 86400;
|
||||
q("UPDATE `session` SET `expire` = '%s' WHERE `sid` = '%s' LIMIT 1",
|
||||
q("UPDATE `session` SET `expire` = '%s' WHERE `sid` = '%s'",
|
||||
dbesc($expire),
|
||||
dbesc($session_id)
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
goaway($dest);
|
||||
}
|
||||
goaway($dest);
|
||||
|
|
42
mod/item.php
42
mod/item.php
|
@ -106,7 +106,7 @@ function item_post(&$a) {
|
|||
|
||||
if(($r === false) || (! count($r))) {
|
||||
notice( t('Unable to locate original post.') . EOL);
|
||||
if(x($_REQUEST,'return'))
|
||||
if(x($_REQUEST,'return'))
|
||||
goaway($a->get_baseurl() . "/" . $return_path );
|
||||
killme();
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ function item_post(&$a) {
|
|||
|
||||
if((! can_write_wall($a,$profile_uid)) && (! $allow_moderated)) {
|
||||
notice( t('Permission denied.') . EOL) ;
|
||||
if(x($_REQUEST,'return'))
|
||||
if(x($_REQUEST,'return'))
|
||||
goaway($a->get_baseurl() . "/" . $return_path );
|
||||
killme();
|
||||
}
|
||||
|
@ -275,10 +275,10 @@ function item_post(&$a) {
|
|||
if($parent_item) {
|
||||
$private = 0;
|
||||
|
||||
if(($parent_item['private'])
|
||||
|| strlen($parent_item['allow_cid'])
|
||||
|| strlen($parent_item['allow_gid'])
|
||||
|| strlen($parent_item['deny_cid'])
|
||||
if(($parent_item['private'])
|
||||
|| strlen($parent_item['allow_cid'])
|
||||
|| strlen($parent_item['allow_gid'])
|
||||
|| strlen($parent_item['deny_cid'])
|
||||
|| strlen($parent_item['deny_gid'])) {
|
||||
$private = (($parent_item['private']) ? $parent_item['private'] : 1);
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ function item_post(&$a) {
|
|||
$str_contact_deny = $parent_item['deny_cid'];
|
||||
$str_group_deny = $parent_item['deny_gid'];
|
||||
}
|
||||
|
||||
|
||||
$pubmail_enable = ((x($_REQUEST,'pubmail_enable') && intval($_REQUEST['pubmail_enable']) && (! $private)) ? 1 : 0);
|
||||
|
||||
// if using the API, we won't see pubmail_enable - figure out if it should be set
|
||||
|
@ -308,7 +308,7 @@ function item_post(&$a) {
|
|||
if($preview)
|
||||
killme();
|
||||
info( t('Empty post discarded.') . EOL );
|
||||
if(x($_REQUEST,'return'))
|
||||
if(x($_REQUEST,'return'))
|
||||
goaway($a->get_baseurl() . "/" . $return_path );
|
||||
killme();
|
||||
}
|
||||
|
@ -361,7 +361,7 @@ function item_post(&$a) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if($contact_id) {
|
||||
$r = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
|
||||
intval($contact_id)
|
||||
|
@ -375,7 +375,7 @@ function item_post(&$a) {
|
|||
}
|
||||
|
||||
// get contact info for owner
|
||||
|
||||
|
||||
if($profile_uid == local_user()) {
|
||||
$contact_record = $author;
|
||||
}
|
||||
|
@ -400,7 +400,7 @@ function item_post(&$a) {
|
|||
|
||||
/**
|
||||
*
|
||||
* When a photo was uploaded into the message using the (profile wall) ajax
|
||||
* When a photo was uploaded into the message using the (profile wall) ajax
|
||||
* uploader, The permissions are initially set to disallow anybody but the
|
||||
* owner from seeing it. This is because the permissions may not yet have been
|
||||
* set for the post. If it's private, the photo permissions should be set
|
||||
|
@ -433,7 +433,7 @@ function item_post(&$a) {
|
|||
|
||||
if(! count($r))
|
||||
continue;
|
||||
|
||||
|
||||
|
||||
$r = q("UPDATE `photo` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s'
|
||||
WHERE `resource-id` = '%s' AND `uid` = %d AND `album` = '%s' ",
|
||||
|
@ -445,7 +445,7 @@ function item_post(&$a) {
|
|||
intval($profile_uid),
|
||||
dbesc( t('Wall Photos'))
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -464,10 +464,10 @@ function item_post(&$a) {
|
|||
$r = q("SELECT * FROM `attach` WHERE `uid` = %d AND `id` = %d LIMIT 1",
|
||||
intval($profile_uid),
|
||||
intval($attach)
|
||||
);
|
||||
);
|
||||
if(count($r)) {
|
||||
$r = q("UPDATE `attach` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s'
|
||||
WHERE `uid` = %d AND `id` = %d LIMIT 1",
|
||||
WHERE `uid` = %d AND `id` = %d",
|
||||
dbesc($str_contact_allow),
|
||||
dbesc($str_group_allow),
|
||||
dbesc($str_contact_deny),
|
||||
|
@ -555,7 +555,7 @@ function item_post(&$a) {
|
|||
// we tagged a private forum in a top level post and the message was public.
|
||||
// Restrict it.
|
||||
$private = 1;
|
||||
$str_contact_allow = '<' . $private_id . '>';
|
||||
$str_contact_allow = '<' . $private_id . '>';
|
||||
}
|
||||
|
||||
$attachments = '';
|
||||
|
@ -683,7 +683,7 @@ function item_post(&$a) {
|
|||
|
||||
|
||||
if($orig_post) {
|
||||
$r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `attach` = '%s', `file` = '%s', `edited` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||
$r = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `tag` = '%s', `attach` = '%s', `file` = '%s', `edited` = '%s' WHERE `id` = %d AND `uid` = %d",
|
||||
dbesc($datarray['title']),
|
||||
dbesc($datarray['body']),
|
||||
dbesc($datarray['tag']),
|
||||
|
@ -786,7 +786,7 @@ function item_post(&$a) {
|
|||
// Inherit ACL's from the parent item.
|
||||
|
||||
$r = q("UPDATE `item` SET `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `private` = %d
|
||||
WHERE `id` = %d LIMIT 1",
|
||||
WHERE `id` = %d",
|
||||
dbesc($parent_item['allow_cid']),
|
||||
dbesc($parent_item['allow_gid']),
|
||||
dbesc($parent_item['deny_cid']),
|
||||
|
@ -849,7 +849,7 @@ function item_post(&$a) {
|
|||
$parent = $post_id;
|
||||
|
||||
$r = q("UPDATE `item` SET `parent` = %d, `parent-uri` = '%s', `plink` = '%s', `changed` = '%s', `last-child` = 1, `visible` = 1
|
||||
WHERE `id` = %d LIMIT 1",
|
||||
WHERE `id` = %d",
|
||||
intval($parent),
|
||||
dbesc(($parent == $post_id) ? $uri : $parent_item['uri']),
|
||||
dbesc($a->get_baseurl() . '/display/' . $user['nickname'] . '/' . $post_id),
|
||||
|
@ -862,7 +862,7 @@ function item_post(&$a) {
|
|||
// They will show up as people comment on them.
|
||||
|
||||
if(! $parent_item['visible']) {
|
||||
$r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d LIMIT 1",
|
||||
$r = q("UPDATE `item` SET `visible` = 1 WHERE `id` = %d",
|
||||
intval($parent_item['id'])
|
||||
);
|
||||
}
|
||||
|
@ -876,7 +876,7 @@ function item_post(&$a) {
|
|||
|
||||
// update the commented timestamp on the parent
|
||||
|
||||
q("UPDATE `item` set `commented` = '%s', `changed` = '%s' WHERE `id` = %d LIMIT 1",
|
||||
q("UPDATE `item` set `commented` = '%s', `changed` = '%s' WHERE `id` = %d",
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
intval($parent)
|
||||
|
|
|
@ -168,7 +168,7 @@ function network_init(&$a) {
|
|||
}
|
||||
}
|
||||
if(x($_GET,'remove')) {
|
||||
q("delete from `search` where `uid` = %d and `term` = '%s' limit 1",
|
||||
q("delete from `search` where `uid` = %d and `term` = '%s'",
|
||||
intval(local_user()),
|
||||
dbesc($search)
|
||||
);
|
||||
|
@ -572,7 +572,8 @@ function network_content(&$a, $update = 0) {
|
|||
$sql_options = (($star) ? " and starred = 1 " : '');
|
||||
$sql_options .= (($bmark) ? " and bookmark = 1 " : '');
|
||||
|
||||
$sql_nets = (($nets) ? sprintf(" and `contact`.`network` = '%s' ", dbesc($nets)) : '');
|
||||
//$sql_nets = (($nets) ? sprintf(" and `contact`.`network` = '%s' ", dbesc($nets)) : '');
|
||||
$sql_nets = (($nets) ? sprintf(" and `item`.`network` = '%s' ", dbesc($nets)) : '');
|
||||
|
||||
$sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` $sql_options ) ";
|
||||
|
||||
|
@ -608,7 +609,9 @@ function network_content(&$a, $update = 0) {
|
|||
intval($cid)
|
||||
);
|
||||
if(count($r)) {
|
||||
$sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $sql_options AND `contact-id` = " . intval($cid) . " and deleted = 0 ) ";
|
||||
$sql_table = "`item` INNER JOIN (SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $sql_options AND `contact-id` = ".intval($cid)." and deleted = 0 ORDER BY `item`.`received` DESC) AS `temp1` ON item.parent = `temp1`.parent ";
|
||||
$sql_extra = "";
|
||||
//$sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $sql_options AND `contact-id` = " . intval($cid) . " and deleted = 0 ) ";
|
||||
$o = '<h2>' . t('Contact: ') . $r[0]['name'] . '</h2>' . $o;
|
||||
if($r[0]['network'] === NETWORK_OSTATUS && $r[0]['writable'] && (! get_pconfig(local_user(),'system','nowarn_insecure'))) {
|
||||
notice( t('Private messages to this person are at risk of public disclosure.') . EOL);
|
||||
|
@ -639,7 +642,9 @@ function network_content(&$a, $update = 0) {
|
|||
$sql_extra2 = (($nouveau) ? '' : " AND `item`.`parent` = `item`.`id` ");
|
||||
$sql_extra3 = (($nouveau) ? '' : $sql_extra3);
|
||||
$sql_order = "`item`.`received`";
|
||||
$sql_table = "`item`";
|
||||
|
||||
if ($sql_table == "")
|
||||
$sql_table = "`item`";
|
||||
|
||||
if(x($_GET,'search')) {
|
||||
$search = escape_tags($_GET['search']);
|
||||
|
@ -670,11 +675,18 @@ function network_content(&$a, $update = 0) {
|
|||
}*/
|
||||
|
||||
if($tag) {
|
||||
$sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d ",
|
||||
dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG));
|
||||
$sql_table = "`term` LEFT JOIN `item` ON `item`.`id` = `term`.`oid` AND `item`.`uid` = `term`.`uid` ";
|
||||
//$sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d ",
|
||||
// dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG));
|
||||
//$sql_table = "`term` LEFT JOIN `item` ON `item`.`id` = `term`.`oid` AND `item`.`uid` = `term`.`uid` ";
|
||||
|
||||
$sql_order = "`term`.`tid`";
|
||||
//$sql_order = "`term`.`tid`";
|
||||
|
||||
$sql_extra = "";
|
||||
|
||||
$sql_table = sprintf("`item` INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
|
||||
dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG), intval(local_user()));
|
||||
|
||||
$sql_order = "`item`.`received`";
|
||||
} else {
|
||||
if (get_config('system','use_fulltext_engine'))
|
||||
$sql_extra = sprintf(" AND MATCH (`item`.`body`, `item`.`title`) AGAINST ('%s' in boolean mode) ", dbesc(protect_sprintf($search)));
|
||||
|
@ -791,7 +803,7 @@ function network_content(&$a, $update = 0) {
|
|||
// Fetch a page full of parent items for this page
|
||||
|
||||
if($update) {
|
||||
$r = q("SELECT `parent` AS `item_id`, `contact`.`uid` AS `contact_uid`
|
||||
$r = q("SELECT `item`.`parent` AS `item_id`, `contact`.`uid` AS `contact_uid`
|
||||
FROM $sql_table LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
|
||||
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND
|
||||
(`item`.`deleted` = 0 OR item.verb = '" . ACTIVITY_LIKE ."' OR item.verb = '" . ACTIVITY_DISLIKE . "')
|
||||
|
@ -890,3 +902,4 @@ function network_content(&$a, $update = 0) {
|
|||
|
||||
return $o;
|
||||
}
|
||||
|
||||
|
|
|
@ -141,15 +141,22 @@ function search_content(&$a) {
|
|||
|
||||
if($tag) {
|
||||
//$sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d",
|
||||
$sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d group by `item`.`uri` ",
|
||||
dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG));
|
||||
$sql_table = "`term` LEFT JOIN `item` ON `item`.`id` = `term`.`oid` AND `item`.`uid` = `term`.`uid` ";
|
||||
$sql_order = "`term`.`tid`";
|
||||
//$sql_extra = sprintf(" AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d group by `item`.`uri` ",
|
||||
// dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG));
|
||||
//$sql_table = "`term` LEFT JOIN `item` ON `item`.`id` = `term`.`oid` AND `item`.`uid` = `term`.`uid` ";
|
||||
//$sql_order = "`term`.`tid`";
|
||||
//$sql_order = "`item`.`received`";
|
||||
|
||||
//$sql_extra = sprintf(" AND EXISTS (SELECT * FROM `term` WHERE `item`.`id` = `term`.`oid` AND `item`.`uid` = `term`.`uid` AND `term`.`term` = '%s' AND `term`.`otype` = %d AND `term`.`type` = %d) GROUP BY `item`.`uri` ",
|
||||
// dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG));
|
||||
//$sql_table = "`item` FORCE INDEX (`uri`) ";
|
||||
|
||||
$sql_extra = "";
|
||||
|
||||
$sql_table = sprintf("`item` INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
|
||||
dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG), intval(local_user()));
|
||||
|
||||
$sql_order = "`item`.`received`";
|
||||
} else {
|
||||
if (get_config('system','use_fulltext_engine')) {
|
||||
$sql_extra = sprintf(" AND MATCH (`item`.`body`, `item`.`title`) AGAINST ('%s' in boolean mode) ", dbesc(protect_sprintf($search)));
|
||||
|
|
70
update.php
70
update.php
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
define( 'UPDATE_VERSION' , 1163 );
|
||||
define( 'UPDATE_VERSION' , 1165 );
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -1440,4 +1440,72 @@ function update_1161() {
|
|||
function update_1162() {
|
||||
require_once('include/tags.php');
|
||||
update_items();
|
||||
|
||||
return UPDATE_SUCCESS;
|
||||
}
|
||||
|
||||
function update_1163() {
|
||||
set_config('system', 'maintenance', 1);
|
||||
|
||||
$r = q("ALTER TABLE `item` ADD `network` char(32) NOT NULL,
|
||||
ADD INDEX (`network`)");
|
||||
|
||||
set_config('system', 'maintenance', 0);
|
||||
|
||||
if(!$r)
|
||||
return UPDATE_FAILED;
|
||||
|
||||
return UPDATE_SUCCESS;
|
||||
}
|
||||
function update_1164() {
|
||||
set_config('system', 'maintenance', 1);
|
||||
|
||||
$r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '' AND `contact`.`uid` = `item`.`uid`)",
|
||||
NETWORK_DFRN);
|
||||
|
||||
$r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
|
||||
NETWORK_DFRN, NETWORK_DFRN);
|
||||
|
||||
$r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
|
||||
NETWORK_ZOT, NETWORK_ZOT);
|
||||
|
||||
$r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
|
||||
NETWORK_OSTATUS, NETWORK_OSTATUS);
|
||||
|
||||
$r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
|
||||
NETWORK_FEED, NETWORK_FEED);
|
||||
|
||||
$r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
|
||||
NETWORK_DIASPORA, NETWORK_DIASPORA);
|
||||
|
||||
$r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
|
||||
NETWORK_MAIL, NETWORK_MAIL);
|
||||
|
||||
$r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
|
||||
NETWORK_MAIL2, NETWORK_MAIL2);
|
||||
|
||||
$r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
|
||||
NETWORK_FACEBOOK, NETWORK_FACEBOOK);
|
||||
|
||||
$r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
|
||||
NETWORK_LINKEDIN, NETWORK_LINKEDIN);
|
||||
|
||||
$r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
|
||||
NETWORK_XMPP, NETWORK_XMPP);
|
||||
|
||||
$r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
|
||||
NETWORK_MYSPACE, NETWORK_MYSPACE);
|
||||
|
||||
$r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
|
||||
NETWORK_GPLUS, NETWORK_GPLUS);
|
||||
|
||||
$r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
|
||||
NETWORK_PUMPIO, NETWORK_PUMPIO);
|
||||
|
||||
$r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
|
||||
NETWORK_TWITTER, NETWORK_TWITTER);
|
||||
|
||||
set_config('system', 'maintenance', 0);
|
||||
|
||||
return UPDATE_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<aside><?php if(x($page,'aside')) echo $page['aside']; ?></aside>
|
||||
<section><?php if(x($page,'content')) echo $page['content']; ?>
|
||||
<div id="page-footer"></div>
|
||||
</section>
|
||||
</section>
|
||||
<right_aside><?php if(x($page,'right_aside')) echo $page['right_aside']; ?></right_aside>
|
||||
<footer><?php if(x($page,'footer')) echo $page['footer']; ?></footer>
|
||||
</body>
|
||||
|
|
|
@ -292,14 +292,11 @@ body {
|
|||
font-family: 'Lato', "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||
font-size: 14px;
|
||||
background-color: #ffffff;
|
||||
/* background-color: #ddd; */
|
||||
/* background-color: #F2F2F2; */
|
||||
color: #2d2d2d;
|
||||
/* margin: 37px 0px 0px 0px; */
|
||||
margin: 0px 0px 0px 0px;
|
||||
display: table;
|
||||
/* width: 100% */
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-size: 1.1em;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue