From 79223b6b3d38bfbfb3a6d9530f6ccc5b7bb096c8 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 10 Feb 2015 19:10:18 -0800 Subject: item voting tools --- mod/item.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'mod/item.php') diff --git a/mod/item.php b/mod/item.php index 6ae02b510..ef0491895 100644 --- a/mod/item.php +++ b/mod/item.php @@ -59,6 +59,8 @@ function item_post(&$a) { $api_source = ((x($_REQUEST,'api_source') && $_REQUEST['api_source']) ? true : false); + $consensus = intval($_REQUEST['consensus']); + // 'origin' (if non-zero) indicates that this network is where the message originated, // for the purpose of relaying comments to other conversation members. // If using the API from a device (leaf node) you must set origin to 1 (default) or leave unset. @@ -683,6 +685,9 @@ function item_post(&$a) { $item_flags = $item_flags | ITEM_THREAD_TOP; } + if($consensus) + $item_flags |= ITEM_CONSENSUS; + if ((! $plink) && ($item_flags & ITEM_THREAD_TOP)) { $plink = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $mid; } -- cgit v1.2.3 From da2349bb6a85d13f0aa29046bef3021cf0c884ba Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 12 Feb 2015 17:45:25 -0800 Subject: provide relief to sites that are severely impacted by the slow ITEM_UNSEEN searches. This does not incorporate any other flag optimisations as that will require a major DB update and possibly involve significant downtime. This is just to bite off a little chunk now and provide some much needed relief. --- mod/item.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'mod/item.php') diff --git a/mod/item.php b/mod/item.php index ef0491895..99d28400b 100644 --- a/mod/item.php +++ b/mod/item.php @@ -643,8 +643,7 @@ function item_post(&$a) { } } - if(local_channel() != $profile_uid) - $item_flags |= ITEM_UNSEEN; + $item_unseen = ((local_channel() != $profile_uid) ? 1 : 0); if($post_type === 'wall' || $post_type === 'wall-comment') $item_flags = $item_flags | ITEM_WALL; @@ -694,7 +693,7 @@ function item_post(&$a) { $datarray['aid'] = $channel['channel_account_id']; $datarray['uid'] = $profile_uid; - + $datarray['owner_xchan'] = (($owner_hash) ? $owner_hash : $owner_xchan['xchan_hash']); $datarray['author_xchan'] = $observer['xchan_hash']; $datarray['created'] = $created; @@ -729,6 +728,7 @@ function item_post(&$a) { $datarray['term'] = $post_tags; $datarray['plink'] = $plink; $datarray['route'] = $route; + $datarray['item_unseen'] = $item_unseen; // preview mode - prepare the body for display and send it via json -- cgit v1.2.3 From 084ca3f4a16084068a0ab04af651770142324f3a Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 12 Feb 2015 18:49:42 -0800 Subject: typo --- mod/item.php | 1 + 1 file changed, 1 insertion(+) (limited to 'mod/item.php') diff --git a/mod/item.php b/mod/item.php index 99d28400b..120b5c66f 100644 --- a/mod/item.php +++ b/mod/item.php @@ -529,6 +529,7 @@ function item_post(&$a) { $body = preg_replace_callback('/\[\$b64url(.*?)\[\/(url)\]/ism','red_unescape_codeblock',$body); $body = preg_replace_callback('/\[\$b64code(.*?)\[\/(code)\]/ism','red_unescape_codeblock',$body); + // fix any img tags that should be zmg $body = preg_replace_callback('/\[img(.*?)\](.*?)\[\/img\]/ism','red_zrlify_img_callback',$body); -- cgit v1.2.3 From 4b513d3322e03ed59e796ca60d09ee1d26cc50fb Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 12 Feb 2015 19:22:07 -0800 Subject: issue #896 --- mod/item.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod/item.php') diff --git a/mod/item.php b/mod/item.php index 120b5c66f..eb823b4b0 100644 --- a/mod/item.php +++ b/mod/item.php @@ -740,7 +740,7 @@ function item_post(&$a) { $datarray['author'] = $observer; $datarray['attach'] = json_encode($datarray['attach']); $o = conversation($a,array($datarray),'search',false,'preview'); - logger('preview: ' . $o, LOGGER_DEBUG); +// logger('preview: ' . $o, LOGGER_DEBUG); echo json_encode(array('preview' => $o)); killme(); } -- cgit v1.2.3 From 7ad425bbda549c3937c2feeac593bdcd21167019 Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 14 Feb 2015 21:57:47 -0800 Subject: failure to auto update comments if it's your own. --- mod/item.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod/item.php') diff --git a/mod/item.php b/mod/item.php index eb823b4b0..dbee2df3b 100644 --- a/mod/item.php +++ b/mod/item.php @@ -644,7 +644,7 @@ function item_post(&$a) { } } - $item_unseen = ((local_channel() != $profile_uid) ? 1 : 0); + $item_unseen = 1; if($post_type === 'wall' || $post_type === 'wall-comment') $item_flags = $item_flags | ITEM_WALL; -- cgit v1.2.3 From 53e908d7b7ea1b1ff9aa5ca6154dc4c9e7ca0d13 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 6 Mar 2015 20:45:26 -0800 Subject: when fixing "naked links" make sure not to double link double urls as seen in archive.org - which has the complete unescaped target url, scheme and all, as part of its own. --- mod/item.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod/item.php') diff --git a/mod/item.php b/mod/item.php index dbee2df3b..8b45f5db9 100644 --- a/mod/item.php +++ b/mod/item.php @@ -523,7 +523,7 @@ function item_post(&$a) { $body = preg_replace_callback('/\[url(.*?)\[\/(url)\]/ism','red_escape_codeblock',$body); $body = preg_replace_callback('/\[zrl(.*?)\[\/(zrl)\]/ism','red_escape_codeblock',$body); - $body = preg_replace_callback("/([^\]\='".'"'."]|^|\#\^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\+\,]+)/ism", 'red_zrl_callback', $body); + $body = preg_replace_callback("/([^\]\='".'"'."\/]|^|\#\^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\+\,]+)/ism", 'red_zrl_callback', $body); $body = preg_replace_callback('/\[\$b64zrl(.*?)\[\/(zrl)\]/ism','red_unescape_codeblock',$body); $body = preg_replace_callback('/\[\$b64url(.*?)\[\/(url)\]/ism','red_unescape_codeblock',$body); -- cgit v1.2.3 From 7af012b1f95fb329c9bf127a60e0a383d853e37d Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 17 Mar 2015 00:13:47 -0700 Subject: The random bad signatures are because something somewhere is trimming the body text. It could be any one of hundreds of functions that touch the message body. We really want to trim the body text, so I'm putting back all the trim statements - in mod/item and item_store and item_store_update. The last fix for random bad sigs noted that one of the trims wasn't there, so the others were removed. The correct fix is for all the trims to be there. We will probably have a few (quite a few) bad sigs during the transition back to trimmed text but this should nail it for anybody on recent code and with new content. --- mod/item.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod/item.php') diff --git a/mod/item.php b/mod/item.php index 8b45f5db9..dad883f50 100644 --- a/mod/item.php +++ b/mod/item.php @@ -385,7 +385,7 @@ function item_post(&$a) { $coord = notags(trim($_REQUEST['coord'])); $verb = notags(trim($_REQUEST['verb'])); $title = escape_tags(trim($_REQUEST['title'])); - $body = $_REQUEST['body']; + $body = trim($_REQUEST['body']); $postopts = ''; $private = ( -- cgit v1.2.3 From 62b2fa6ac7ee85c8572eb868eb30dc2e20cf3040 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 22 Mar 2015 20:30:23 -0700 Subject: operation snakebite, cont. --- mod/item.php | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'mod/item.php') diff --git a/mod/item.php b/mod/item.php index dad883f50..6644be291 100644 --- a/mod/item.php +++ b/mod/item.php @@ -35,6 +35,23 @@ function item_post(&$a) { $channel = null; $observer = null; + + /** + * Is this a reply to something? + */ + + $parent = ((x($_REQUEST,'parent')) ? intval($_REQUEST['parent']) : 0); + $parent_mid = ((x($_REQUEST,'parent_mid')) ? trim($_REQUEST['parent_mid']) : ''); + + $remote_xchan = ((x($_REQUEST,'remote_xchan')) ? trim($_REQUEST['remote_xchan']) : false); + $r = q("select * from xchan where xchan_hash = '%s' limit 1", + dbesc($remote_xchan) + ); + if($r) + $remote_observer = $r[0]; + else + $remote_xchan = $remote_observer = false; + $profile_uid = ((x($_REQUEST,'profile_uid')) ? intval($_REQUEST['profile_uid']) : 0); require_once('include/identity.php'); $sys = get_sys_channel(); @@ -116,13 +133,6 @@ function item_post(&$a) { $item_flags = $item_restrict = 0; - /** - * Is this a reply to something? - */ - - $parent = ((x($_REQUEST,'parent')) ? intval($_REQUEST['parent']) : 0); - $parent_mid = ((x($_REQUEST,'parent_mid')) ? trim($_REQUEST['parent_mid']) : ''); - $route = ''; $parent_item = null; $parent_contact = null; @@ -275,6 +285,9 @@ function item_post(&$a) { $walltowall = false; $walltowall_comment = false; + if($remote_xchan) + $observer = $remote_observer; + if($observer) { logger('mod_item: post accepted from ' . $observer['xchan_name'] . ' for ' . $owner_xchan['xchan_name'], LOGGER_DEBUG); -- cgit v1.2.3 From f1a16607095e0ebbd8ce2201a2f087557b39f282 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 25 Mar 2015 19:13:53 -0700 Subject: item_check_service_class - the join is totally unnecessary --- mod/item.php | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'mod/item.php') diff --git a/mod/item.php b/mod/item.php index 6644be291..8aa3d8136 100644 --- a/mod/item.php +++ b/mod/item.php @@ -1071,37 +1071,37 @@ function fix_attached_file_permissions($channel,$observer_hash,$body, function item_check_service_class($channel_id,$iswebpage) { $ret = array('success' => false, $message => ''); + if ($iswebpage) { - $r = q("select count(i.id) as total from item i - right join channel c on (i.author_xchan=c.channel_hash and i.uid=c.channel_id ) - and i.parent=i.id and (i.item_restrict & %d)>0 and not (i.item_restrict & %d)>0 and i.uid= %d ", + $r = q("select count(id) as total from item where parent = id + and ( item_restrict & %d ) > 0 and ( item_restrict & %d ) = 0 and uid = %d ", intval(ITEM_WEBPAGE), intval(ITEM_DELETED), - intval($channel_id) - ); + intval($channel_id) + ); } else { - $r = q("select count(i.id) as total from item i - right join channel c on (i.author_xchan=c.channel_hash and i.uid=c.channel_id ) - and i.parent=i.id and (i.item_restrict=0) and i.uid= %d ", - intval($channel_id) - ); + $r = q("select count(id) as total from item where parent = id and item_restrict = 0 and uid = %d ", + intval($channel_id) + ); } - if(! ($r && count($r))) { - $ret['message'] = t('Unable to obtain identity information from database'); + + if(! $r) { + $ret['message'] = t('Unable to obtain post information from database.'); return $ret; } + if (!$iswebpage) { - if(! service_class_allows($channel_id,'total_items',$r[0]['total'])) { - $result['message'] .= upgrade_message().sprintf(t("You have reached your limit of %1$.0f top level posts."),$r[0]['total']); - return $result; - } + if(! service_class_allows($channel_id,'total_items',$r[0]['total'])) { + $result['message'] .= upgrade_message() . sprintf( t('You have reached your limit of %1$.0f top level posts.'),$r[0]['total']); + return $result; + } } else { - if(! service_class_allows($channel_id,'total_pages',$r[0]['total'])) { - $result['message'] .= upgrade_message().sprintf(t("You have reached your limit of %1$.0f webpages."),$r[0]['total']); - return $result; - } + if(! service_class_allows($channel_id,'total_pages',$r[0]['total'])) { + $result['message'] .= upgrade_message() . sprintf( t('You have reached your limit of %1$.0f webpages.'),$r[0]['total']); + return $result; + } } $ret['success'] = true; -- cgit v1.2.3 From 0bb89778d382fc5758354c6986130ce1ddba7d4c Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 26 Mar 2015 19:55:52 -0700 Subject: add channel_lastpost timestamp to help optimise some outrageously expensive queries. --- mod/item.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'mod/item.php') diff --git a/mod/item.php b/mod/item.php index 8aa3d8136..fa40aea03 100644 --- a/mod/item.php +++ b/mod/item.php @@ -860,6 +860,13 @@ function item_post(&$a) { 'otype' => 'item' )); } + + if($uid && $uid == $profile_uid && (! $datarray['item_restrict'])) { + q("update channel set channel_lastpost = '%s' where channel_id = %d", + dbesc(datetime_convert()), + intval($uid) + ); + } } // photo comments turn the corresponding item visible to the profile wall -- cgit v1.2.3 From 37afc8184751556107a23910be094c80990901dd Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 8 Apr 2015 17:54:52 -0700 Subject: update features, allow sys account page deletion --- mod/item.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'mod/item.php') diff --git a/mod/item.php b/mod/item.php index fa40aea03..45ac4a6aa 100644 --- a/mod/item.php +++ b/mod/item.php @@ -950,6 +950,10 @@ function item_content(&$a) { if(local_channel() && local_channel() == $i[0]['uid']) $local_delete = true; + $sys = get_sys_channel(); + if(is_site_admin() && $sys['channel_id'] == $i[0]['uid']) + $can_delete = true; + $ob_hash = get_observer_hash(); if($ob_hash && ($ob_hash === $i[0]['author_xchan'] || $ob_hash === $i[0]['owner_xchan'] || $ob_hash === $i[0]['source_xchan'])) $can_delete = true; -- cgit v1.2.3 From d3bc721138433b3d4940f0c8ade7ebd39fff9b6e Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 13 Apr 2015 16:03:09 -0700 Subject: item_check_service_class wasn't returning correct results --- mod/item.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'mod/item.php') diff --git a/mod/item.php b/mod/item.php index 45ac4a6aa..53064132c 100644 --- a/mod/item.php +++ b/mod/item.php @@ -116,7 +116,7 @@ function item_post(&$a) { * Check service class limits */ if ($uid && !(x($_REQUEST,'parent')) && !(x($_REQUEST,'post_id'))) { - $ret = item_check_service_class($uid,x($_REQUEST,'webpage')); + $ret = item_check_service_class($uid,(($_REQUEST['webpage'] == ITEM_WEBPAGE) ? true : false)); if (!$ret['success']) { notice( t($ret['message']) . EOL) ; if(x($_REQUEST,'return')) @@ -1084,6 +1084,7 @@ function item_check_service_class($channel_id,$iswebpage) { $ret = array('success' => false, $message => ''); if ($iswebpage) { + // note: we aren't counting comanche templates and blocks, only webpages $r = q("select count(id) as total from item where parent = id and ( item_restrict & %d ) > 0 and ( item_restrict & %d ) = 0 and uid = %d ", intval(ITEM_WEBPAGE), @@ -1092,7 +1093,8 @@ function item_check_service_class($channel_id,$iswebpage) { ); } else { - $r = q("select count(id) as total from item where parent = id and item_restrict = 0 and uid = %d ", + $r = q("select count(id) as total from item where parent = id and item_restrict = 0 and (item_flags & %d) > 0 and uid = %d ", + intval(ITEM_WALL), intval($channel_id) ); } @@ -1103,14 +1105,16 @@ function item_check_service_class($channel_id,$iswebpage) { } if (!$iswebpage) { + $max = service_class_fetch($channel_id,'total_items'); if(! service_class_allows($channel_id,'total_items',$r[0]['total'])) { - $result['message'] .= upgrade_message() . sprintf( t('You have reached your limit of %1$.0f top level posts.'),$r[0]['total']); + $result['message'] .= upgrade_message() . sprintf( t('You have reached your limit of %1$.0f top level posts.'),$max); return $result; } } else { + $max = service_class_fetch($channel_id,'total_pages'); if(! service_class_allows($channel_id,'total_pages',$r[0]['total'])) { - $result['message'] .= upgrade_message() . sprintf( t('You have reached your limit of %1$.0f webpages.'),$r[0]['total']); + $result['message'] .= upgrade_message() . sprintf( t('You have reached your limit of %1$.0f webpages.'),$max); return $result; } } -- cgit v1.2.3 From 9addc4581edf594996151eaf514927d271f04da5 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 16 Apr 2015 23:26:11 +0200 Subject: provide a separate input field for rpost attachments --- mod/item.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod/item.php') diff --git a/mod/item.php b/mod/item.php index 53064132c..d80241f2d 100644 --- a/mod/item.php +++ b/mod/item.php @@ -22,7 +22,6 @@ require_once('include/attach.php'); function item_post(&$a) { - // This will change. Figure out who the observer is and whether or not // they have permission to post here. Else ignore the post. @@ -399,6 +398,7 @@ function item_post(&$a) { $verb = notags(trim($_REQUEST['verb'])); $title = escape_tags(trim($_REQUEST['title'])); $body = trim($_REQUEST['body']); + $body .= trim($_REQUEST['attachment']); $postopts = ''; $private = ( -- cgit v1.2.3 From 53339d19a391e66635c21199484f1e4afa7b2ec7 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 20 Apr 2015 20:14:07 -0700 Subject: issue #176, sender copy of item not obscured if using private mention --- mod/item.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod/item.php') diff --git a/mod/item.php b/mod/item.php index d80241f2d..a732a9f81 100644 --- a/mod/item.php +++ b/mod/item.php @@ -602,7 +602,7 @@ function item_post(&$a) { if($results) { // Set permissions based on tag replacements - set_linkified_perms($results, $str_contact_allow, $str_group_allow, $profile_uid, $parent_item); + set_linkified_perms($results, $str_contact_allow, $str_group_allow, $profile_uid, $parent_item, $private); $post_tags = array(); foreach($results as $result) { -- cgit v1.2.3