diff --git a/.gitignore b/.gitignore
index 038ac32a5..bf4bd454b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,6 +9,7 @@ favicon.*
home.html
addon
*~
+robots.txt
#ignore documentation, it should be newly built
doc/api
diff --git a/boot.php b/boot.php
index 34d35df70..c03eca498 100644
--- a/boot.php
+++ b/boot.php
@@ -14,8 +14,7 @@ require_once('include/features.php');
define ( 'FRIENDICA_PLATFORM', 'Friendica');
define ( 'FRIENDICA_VERSION', '3.1.1614' );
define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
-define ( 'DB_UPDATE_VERSION', 1159 );
-
+define ( 'DB_UPDATE_VERSION', 1162 );
define ( 'EOL', "
\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
@@ -204,10 +203,12 @@ define ( 'NOTIFY_SYSTEM', 0x8000 );
define ( 'TERM_UNKNOWN', 0 );
define ( 'TERM_HASHTAG', 1 );
-define ( 'TERM_MENTION', 2 );
+define ( 'TERM_MENTION', 2 );
define ( 'TERM_CATEGORY', 3 );
define ( 'TERM_PCATEGORY', 4 );
define ( 'TERM_FILE', 5 );
+define ( 'TERM_SAVEDSEARCH', 6 );
+define ( 'TERM_CONVERSATION', 7 );
define ( 'TERM_OBJ_POST', 1 );
define ( 'TERM_OBJ_PHOTO', 2 );
@@ -355,7 +356,8 @@ if(! class_exists('App')) {
public $identities;
public $is_mobile;
public $is_tablet;
-
+ public $performance = array();
+
public $nav_sel;
public $category;
@@ -403,7 +405,7 @@ if(! class_exists('App')) {
private $cached_profile_image;
private $cached_profile_picdate;
-
+
function __construct() {
global $default_timezone, $argv, $argc;
@@ -412,6 +414,14 @@ if(! class_exists('App')) {
date_default_timezone_set($this->timezone);
+ $this->performance["start"] = microtime(true);
+ $this->performance["database"] = 0;
+ $this->performance["network"] = 0;
+ $this->performance["rendering"] = 0;
+ $this->performance["parser"] = 0;
+ $this->performance["marktime"] = 0;
+ $this->performance["markstart"] = microtime(true);
+
$this->config = array();
$this->page = array();
$this->pager= array();
@@ -719,6 +729,17 @@ if(! class_exists('App')) {
return $this->rdelim[$engine];
}
+ function save_timestamp($stamp, $value) {
+ $duration = (float)(microtime(true)-$stamp);
+
+ $this->performance[$value] += (float)$duration;
+ $this->performance["marktime"] += (float)$duration;
+ }
+
+ function mark_timestamp($mark) {
+ //$this->performance["markstart"] -= microtime(true) - $this->performance["marktime"];
+ $this->performance["markstart"] = microtime(true) - $this->performance["markstart"] - $this->performance["marktime"];
+ }
}
}
diff --git a/database.sql b/database.sql
index 6a4782fb8..f2c558241 100644
--- a/database.sql
+++ b/database.sql
@@ -560,6 +560,7 @@ CREATE TABLE IF NOT EXISTS `item` (
`deleted` tinyint(1) NOT NULL DEFAULT '0',
`origin` tinyint(1) NOT NULL DEFAULT '0',
`forum_mode` tinyint(1) NOT NULL DEFAULT '0',
+ `mention` tinyint(1) NOT NULL DEFAULT '0',
`last-child` tinyint(1) unsigned NOT NULL DEFAULT '1',
PRIMARY KEY (`id`),
KEY `uri` (`uri`),
@@ -589,6 +590,8 @@ CREATE TABLE IF NOT EXISTS `item` (
KEY `uid_commented` (`uid`, `commented`),
KEY `uid_created` (`uid`, `created`),
KEY `uid_unseen` (`uid`, `unseen`),
+ KEY `mention` (`mention`),
+ KEY `resource-id` (`resource-id`),
KEY `event_id` (`event-id`),
FULLTEXT KEY `title` (`title`),
FULLTEXT KEY `body` (`body`),
@@ -1030,18 +1033,22 @@ CREATE TABLE IF NOT EXISTS `spam` (
--
CREATE TABLE IF NOT EXISTS `term` (
- `tid` INT UNSIGNED NOT NULL AUTO_INCREMENT,
- `oid` INT UNSIGNED NOT NULL ,
- `otype` TINYINT( 3 ) UNSIGNED NOT NULL ,
- `type` TINYINT( 3 ) UNSIGNED NOT NULL ,
- `term` CHAR( 255 ) NOT NULL ,
- `url` CHAR( 255 ) NOT NULL,
+ `tid` int(10) unsigned NOT NULL AUTO_INCREMENT,
+ `aid` int(10) unsigned NOT NULL DEFAULT '0',
+ `uid` int(10) unsigned NOT NULL DEFAULT '0',
+ `oid` int(10) unsigned NOT NULL,
+ `otype` tinyint(3) unsigned NOT NULL,
+ `type` tinyint(3) unsigned NOT NULL,
+ `term` char(255) NOT NULL,
+ `url` char(255) NOT NULL,
PRIMARY KEY (`tid`),
- KEY `oid` ( `oid` ),
- KEY `otype` ( `otype` ),
- KEY `type` ( `type` ),
- KEY `term` ( `term` )
-) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+ KEY `oid` (`oid`),
+ KEY `otype` (`otype`),
+ KEY `type` (`type`),
+ KEY `term` (`term`),
+ KEY `uid` (`uid`),
+ KEY `aid` (`aid`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
@@ -1133,3 +1140,17 @@ CREATE TABLE IF NOT EXISTS `userd` (
`username` char(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+
+-- --------------------------------------------------------
+
+--
+-- Table structure for table `tag`
+--
+
+CREATE TABLE IF NOT EXISTS `tag` (
+ `iid` int(11) NOT NULL,
+ `tag` char(255) NOT NULL,
+ `link` char(255) NOT NULL,
+ PRIMARY KEY (`iid`, `tag`),
+ KEY `tag` (`tag`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
diff --git a/include/Scrape.php b/include/Scrape.php
index 611cbda88..7b72a199d 100644
--- a/include/Scrape.php
+++ b/include/Scrape.php
@@ -346,7 +346,7 @@ function probe_url($url, $mode = PROBE_NORMAL) {
$network = null;
$diaspora = false;
$diaspora_base = '';
- $diaspora_guid = '';
+ $diaspora_guid = '';
$diaspora_key = '';
$has_lrdd = false;
$email_conversant = false;
@@ -485,7 +485,7 @@ function probe_url($url, $mode = PROBE_NORMAL) {
}
}
}
- }
+ }
if($mode == PROBE_NORMAL) {
if(strlen($zot)) {
@@ -531,7 +531,7 @@ function probe_url($url, $mode = PROBE_NORMAL) {
}
if(strpos($url,'@'))
$addr = str_replace('acct:', '', $url);
- }
+ }
if($network !== NETWORK_ZOT && $network !== NETWORK_DFRN && $network !== NETWORK_MAIL) {
if($diaspora)
@@ -544,13 +544,13 @@ function probe_url($url, $mode = PROBE_NORMAL) {
$vcard = scrape_vcard($hcard);
// Google doesn't use absolute url in profile photos
-
+
if((x($vcard,'photo')) && substr($vcard['photo'],0,1) == '/') {
$h = @parse_url($hcard);
if($h)
$vcard['photo'] = $h['scheme'] . '://' . $h['host'] . $vcard['photo'];
}
-
+
logger('probe_url: scrape_vcard: ' . print_r($vcard,true), LOGGER_DATA);
}
@@ -561,7 +561,7 @@ function probe_url($url, $mode = PROBE_NORMAL) {
$vcard['nick'] = $addr_parts[0];
}
- if($twitter) {
+ if($twitter) {
logger('twitter: setup');
$tid = basename($url);
$tapi = 'https://api.twitter.com/1/statuses/user_timeline.rss';
diff --git a/include/api.php b/include/api.php
index 9b2073e09..600155666 100644
--- a/include/api.php
+++ b/include/api.php
@@ -521,13 +521,13 @@
$txt = $purifier->purify($txt);
}
$txt = html2bbcode($txt);
-
+
$a->argv[1]=$user_info['screen_name']; //should be set to username?
-
+
$_REQUEST['hush']='yeah'; //tell wall_upload function to return img info instead of echo
require_once('mod/wall_upload.php');
$bebop = wall_upload_post($a);
-
+
//now that we have the img url in bbcode we can add it to the status and insert the wall item.
$_REQUEST['body']=$txt."\n\n".$bebop;
require_once('mod/item.php');
@@ -634,7 +634,7 @@
if (count($lastwall)>0){
$lastwall = $lastwall[0];
-
+
$in_reply_to_status_id = '';
$in_reply_to_user_id = '';
$in_reply_to_screen_name = '';
@@ -642,9 +642,9 @@
$in_reply_to_status_id=$lastwall['parent'];
$in_reply_to_user_id = $lastwall['reply_uid'];
$in_reply_to_screen_name = $lastwall['reply_author'];
- }
+ }
$status_info = array(
- 'text' => html2plain(bbcode($lastwall['body']), 0),
+ 'text' => html2plain(bbcode($lastwall['body'], false, false, true), 0),
'truncated' => false,
'created_at' => api_date($lastwall['created']),
'in_reply_to_status_id' => $in_reply_to_status_id,
@@ -699,11 +699,11 @@
$in_reply_to_status_id=$lastwall['parent'];
$in_reply_to_user_id = $lastwall['reply_uid'];
$in_reply_to_screen_name = $lastwall['reply_author'];
- }
+ }
$user_info['status'] = array(
'created_at' => api_date($lastwall['created']),
'id' => $lastwall['contact-id'],
- 'text' => html2plain(bbcode($lastwall['body']), 0),
+ 'text' => html2plain(bbcode($lastwall['body'], false, false, true), 0),
'source' => (($lastwall['app']) ? $lastwall['app'] : 'web'),
'truncated' => false,
'in_reply_to_status_id' => $in_reply_to_status_id,
@@ -1042,21 +1042,27 @@
$myurl = $a->get_baseurl() . '/profile/'. $a->user['nickname'];
$myurl = substr($myurl,strpos($myurl,'://')+3);
- $myurl = str_replace(array('www.','.'),array('','\\.'),$myurl);
+ //$myurl = str_replace(array('www.','.'),array('','\\.'),$myurl);
+ $myurl = str_replace('www.','',$myurl);
$diasp_url = str_replace('/profile/','/u/',$myurl);
- if (get_config('system','use_fulltext_engine'))
- $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where (MATCH(`author-link`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(`tag`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode))) ",
- dbesc(protect_sprintf($myurl)),
- dbesc(protect_sprintf($myurl)),
- dbesc(protect_sprintf($diasp_url))
- );
- else
- $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` like '%s' or `tag` like '%s' or tag like '%s' )) ",
- dbesc(protect_sprintf('%' . $myurl)),
- dbesc(protect_sprintf('%' . $myurl . ']%')),
- dbesc(protect_sprintf('%' . $diasp_url . ']%'))
- );
+/* if (get_config('system','use_fulltext_engine'))
+ $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where (MATCH(`author-link`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(`tag`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode))) ",
+ dbesc(protect_sprintf($myurl)),
+ dbesc(protect_sprintf($myurl)),
+ dbesc(protect_sprintf($diasp_url))
+ );
+ else
+ $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` like '%s' or `tag` like '%s' or tag like '%s' )) ",
+ dbesc(protect_sprintf('%' . $myurl)),
+ dbesc(protect_sprintf('%' . $myurl . ']%')),
+ dbesc(protect_sprintf('%' . $diasp_url . ']%'))
+ );
+*/
+ $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where `author-link` IN ('https://%s', 'http://%s') OR `mention`)",
+ dbesc(protect_sprintf($myurl)),
+ dbesc(protect_sprintf($myurl))
+ );
if ($max_id > 0)
$sql_extra .= ' AND `item`.`id` <= '.intval($max_id);
@@ -1299,11 +1305,11 @@
$ret['text'] = bbcode($item['body']);
}
elseif ($_GET["getText"] == "plain") {
- $ret['text'] = html2plain(bbcode($item['body']), 0);
+ $ret['text'] = html2plain(bbcode($item['body'], false, false, true), 0);
}
}
else {
- $ret['text'] = $item['title']."\n".html2plain(bbcode($item['body']), 0);
+ $ret['text'] = $item['title']."\n".html2plain(bbcode($item['body'], false, false, true), 0);
}
if (isset($_GET["getUserObjects"]) && $_GET["getUserObjects"] == "false") {
unset($ret['sender']);
@@ -1347,7 +1353,7 @@
}
// Workaround for ostatus messages where the title is identically to the body
- $statusbody = trim(html2plain(bbcode($item['body']), 0));
+ $statusbody = trim(html2plain(bbcode($item['body'], false, false, true), 0));
$statustitle = trim($item['title']);
if (($statustitle != '') and (strpos($statusbody, $statustitle) !== false))
diff --git a/include/bbcode.php b/include/bbcode.php
index 228b75d5a..a587d8c38 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -278,10 +278,39 @@ function bb_ShareAttributes($match) {
return($text);
}
+function bb_ShareAttributesSimple($match) {
+
+ $attributes = $match[1];
+
+ $author = "";
+ preg_match("/author='(.*?)'/ism", $attributes, $matches);
+ if ($matches[1] != "")
+ $author = html_entity_decode($matches[1],ENT_QUOTES,'UTF-8');
+
+ preg_match('/author="(.*?)"/ism', $attributes, $matches);
+ if ($matches[1] != "")
+ $author = $matches[1];
+
+ $profile = "";
+ preg_match("/profile='(.*?)'/ism", $attributes, $matches);
+ if ($matches[1] != "")
+ $profile = $matches[1];
+
+ preg_match('/profile="(.*?)"/ism', $attributes, $matches);
+ if ($matches[1] != "")
+ $profile = $matches[1];
+
+ $text = "
".html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8').' '.$author.":
»".$match[2]."«";
+
+ return($text);
+}
+
// BBcode 2 HTML was written by WAY2WEB.net
// extended to work with Mistpark/Friendica - Mike Macgirvin
-function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
+function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = false) {
+
+ $stamp1 = microtime(true);
$a = get_app();
@@ -340,13 +369,14 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
$Text = str_replace("\r\n","\n", $Text);
// removing multiplicated newlines
-// $search = array("\n\n\n", "\n ", " \n", "[/quote]\n\n", "\n[/quote]");
-// $replace = array("\n\n", "\n", "\n", "[/quote]\n", "[/quote]");
-// do {
-// $oldtext = $Text;
-// $Text = str_replace($search, $replace, $Text);
-// } while ($oldtext != $Text);
-
+ if (get_config("system", "remove_multiplicated_lines")) {
+ $search = array("\n\n\n", "\n ", " \n", "[/quote]\n\n", "\n[/quote]");
+ $replace = array("\n\n", "\n", "\n", "[/quote]\n", "[/quote]");
+ do {
+ $oldtext = $Text;
+ $Text = str_replace($search, $replace, $Text);
+ } while ($oldtext != $Text);
+ }
$Text = str_replace(array("\r","\n"), array('
','
'), $Text);
@@ -515,7 +545,10 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
$Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '', $Text);
// Shared content
- $Text = preg_replace_callback("/\[share(.*?)\](.*?)\[\/share\]/ism","bb_ShareAttributes",$Text);
+ if (!$simplehtml)
+ $Text = preg_replace_callback("/\[share(.*?)\](.*?)\[\/share\]/ism","bb_ShareAttributes",$Text);
+ else
+ $Text = preg_replace_callback("/\[share(.*?)\](.*?)\[\/share\]/ism","bb_ShareAttributesSimple",$Text);
$Text = preg_replace("/\[crypt\](.*?)\[\/crypt\]/ism",'
', $Text);
$Text = preg_replace("/\[crypt=(.*?)\](.*?)\[\/crypt\]/ism",'
', $Text);
@@ -617,7 +650,8 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
// Clean up the HTML by loading and saving the HTML with the DOM
// Only do it when it has to be done - for performance reasons
- if (!$tryoembed) {
+ // Update: Now it is done every time - since bad structured html can break a whole page
+ //if (!$tryoembed) {
$doc = new DOMDocument();
$doc->preserveWhiteSpace = false;
@@ -632,10 +666,12 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
$Text = str_replace('
','', $Text);
$Text = mb_convert_encoding($Text, "UTF-8", 'HTML-ENTITIES');
- }
+ //}
call_hooks('bbcode',$Text);
+ $a->save_timestamp($stamp1, "parser");
+
return $Text;
}
diff --git a/include/conversation.php b/include/conversation.php
index 5296011bb..36ac57f17 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -369,7 +369,6 @@ function visible_activity($item) {
if(!function_exists('conversation')) {
function conversation(&$a, $items, $mode, $update, $preview = false) {
-
require_once('include/bbcode.php');
$ssl_state = ((local_user()) ? true : false);
@@ -524,7 +523,26 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
$tags=array();
$hashtags = array();
$mentions = array();
- foreach(explode(',',$item['tag']) as $tag){
+
+ $taglist = q("SELECT `type`, `term`, `url` FROM `term` WHERE `otype` = %d AND `oid` = %d AND `type` IN (%d, %d) ORDER BY `tid`",
+ intval(TERM_OBJ_POST), intval($item['id']), intval(TERM_HASHTAG), intval(TERM_MENTION));
+
+ foreach($taglist as $tag) {
+
+ if ($tag["url"] == "")
+ $tag["url"] = $searchpath.strtolower($tag["term"]);
+
+ if ($tag["type"] == TERM_HASHTAG) {
+ $hashtags[] = "#".$tag["term"]."";
+ $prefix = "#";
+ } elseif ($tag["type"] == TERM_MENTION) {
+ $mentions[] = "@".$tag["term"]."";
+ $prefix = "@";
+ }
+ $tags[] = $prefix."".$tag["term"]."";
+ }
+
+ /*foreach(explode(',',$item['tag']) as $tag){
$tag = trim($tag);
if ($tag!="") {
$t = bbcode($tag);
@@ -534,7 +552,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
elseif($t[0] == '@')
$mentions[] = $t;
}
- }
+ }*/
$sp = false;
$profile_link = best_link_url($item,$sp);
diff --git a/include/dba.php b/include/dba.php
index ad33705bf..50354b7f4 100644
--- a/include/dba.php
+++ b/include/dba.php
@@ -23,6 +23,9 @@ class dba {
public $error = false;
function __construct($server,$user,$pass,$db,$install = false) {
+ global $a;
+
+ $stamp1 = microtime(true);
$server = trim($server);
$user = trim($user);
@@ -64,6 +67,8 @@ class dba {
if(! $install)
system_unavailable();
}
+
+ $a->save_timestamp($stamp1, "network");
}
public function getdb() {
@@ -78,18 +83,19 @@ class dba {
$this->error = '';
- if(x($a->config,'system') && x($a->config['system'],'db_log'))
- $stamp1 = microtime(true);
+ $stamp1 = microtime(true);
if($this->mysqli)
$result = @$this->db->query($sql);
else
$result = @mysql_query($sql,$this->db);
+ $stamp2 = microtime(true);
+ $duration = (float)($stamp2-$stamp1);
+
if(x($a->config,'system') && x($a->config['system'],'db_log')) {
- $stamp2 = microtime(true);
- $duration = round($stamp2-$stamp1, 3);
- if ($duration > $a->config["system"]["db_loglimit"]) {
+ if (($duration > $a->config["system"]["db_loglimit"])) {
+ $duration = round($duration, 3);
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
@file_put_contents($a->config["system"]["db_log"], $duration."\t".
basename($backtrace[1]["file"])."\t".
@@ -162,6 +168,7 @@ class dba {
}
}
+ $a->save_timestamp($stamp1, "database");
if($this->debug)
logger('dba: ' . printable(print_r($r, true)));
diff --git a/include/diaspora.php b/include/diaspora.php
index 18d37c243..5bf45e241 100755
--- a/include/diaspora.php
+++ b/include/diaspora.php
@@ -559,7 +559,7 @@ function diaspora_decode($importer,$xml) {
}
-
+
function diaspora_request($importer,$xml) {
$a = get_app();
@@ -569,7 +569,7 @@ function diaspora_request($importer,$xml) {
if(! $sender_handle || ! $recipient_handle)
return;
-
+
$contact = diaspora_get_contact_by_handle($importer['uid'],$sender_handle);
if($contact) {
@@ -754,6 +754,20 @@ function diaspora_request($importer,$xml) {
}
function diaspora_post_allow($importer,$contact) {
+
+ // perhaps we were already sharing with this person. Now they're sharing with us.
+ // That makes us friends.
+ // Normally this should have handled by getting a request - but this could get lost
+ if($contact['rel'] == CONTACT_IS_FOLLOWER && $importer['page-flags'] != PAGE_COMMUNITY) {
+ q("UPDATE `contact` SET `rel` = %d, `writable` = 1 WHERE `id` = %d AND `uid` = %d LIMIT 1",
+ intval(CONTACT_IS_FRIEND),
+ intval($contact['id']),
+ intval($importer['uid'])
+ );
+ $contact['rel'] = CONTACT_IS_FRIEND;
+ logger('diaspora_post_allow: defining user '.$contact["nick"].' as friend');
+ }
+
if(($contact['blocked']) || ($contact['readonly']) || ($contact['archive']))
return false;
if($contact['rel'] == CONTACT_IS_SHARING || $contact['rel'] == CONTACT_IS_FRIEND)
diff --git a/include/follow.php b/include/follow.php
index 59f3b1a5f..fc167bb82 100644
--- a/include/follow.php
+++ b/include/follow.php
@@ -48,9 +48,9 @@ function new_contact($uid,$url,$interactive = false) {
$myaddr = bin2hex($a->get_baseurl() . '/profile/' . $a->user['nickname']);
else
$myaddr = bin2hex($a->user['nickname'] . '@' . $a->get_hostname());
-
+
goaway($ret['request'] . "&addr=$myaddr");
-
+
// NOTREACHED
}
}
@@ -61,7 +61,7 @@ function new_contact($uid,$url,$interactive = false) {
return $result;
}
}
-
+
diff --git a/include/items.php b/include/items.php
index 255d580b6..b7be27932 100755
--- a/include/items.php
+++ b/include/items.php
@@ -5,7 +5,10 @@ require_once('include/oembed.php');
require_once('include/salmon.php');
require_once('include/crypto.php');
require_once('include/Photo.php');
+require_once('include/tags.php');
+require_once('include/text.php');
require_once('include/email.php');
+require_once('include/ostatus_conversation.php');
function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0) {
@@ -26,7 +29,7 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0)
}
}
-
+
// default permissions - anonymous user
@@ -238,7 +241,7 @@ function construct_activity_object($item) {
$r->link = str_replace('&','&', $r->link);
$r->link = preg_replace('/\/','',$r->link);
$o .= $r->link;
- }
+ }
else
$o .= '' . "\r\n";
}
@@ -270,7 +273,7 @@ function construct_activity_target($item) {
$r->link = str_replace('&','&', $r->link);
$r->link = preg_replace('/\/','',$r->link);
$o .= $r->link;
- }
+ }
else
$o .= '' . "\r\n";
}
@@ -670,7 +673,7 @@ function get_atom_elements($feed,$item) {
}
// translate OStatus unfollow to activity streams if it happened to get selected
-
+
if((x($res,'verb')) && ($res['verb'] === 'http://ostatus.org/schema/1.0/unfollow'))
$res['verb'] = ACTIVITY_UNFOLLOW;
@@ -721,7 +724,7 @@ function get_atom_elements($feed,$item) {
if($child[NAMESPACE_ACTIVITY]['object-type'][0]['data']) {
$res['object-type'] = $child[NAMESPACE_ACTIVITY]['object-type'][0]['data'];
$res['object'] .= '
\n";
+ $a = get_app();
+ $a->save_timestamp($stamp1, "rendering");
+
return $output;
}}
@@ -438,15 +439,26 @@ function load_view_file($s) {
$lang = 'en';
$b = basename($s);
$d = dirname($s);
- if(file_exists("$d/$lang/$b"))
- return file_get_contents("$d/$lang/$b");
-
+ if(file_exists("$d/$lang/$b")) {
+ $stamp1 = microtime(true);
+ $content = file_get_contents("$d/$lang/$b");
+ $a->save_timestamp($stamp1, "file");
+ return $content;
+ }
+
$theme = current_theme();
- if(file_exists("$d/theme/$theme/$b"))
- return file_get_contents("$d/theme/$theme/$b");
-
- return file_get_contents($s);
+ if(file_exists("$d/theme/$theme/$b")) {
+ $stamp1 = microtime(true);
+ $content = file_get_contents("$d/theme/$theme/$b");
+ $a->save_timestamp($stamp1, "file");
+ return $content;
+ }
+
+ $stamp1 = microtime(true);
+ $content = file_get_contents($s);
+ $a->save_timestamp($stamp1, "file");
+ return $content;
}}
if(! function_exists('get_intltext_template')) {
@@ -461,17 +473,28 @@ function get_intltext_template($s) {
if(! isset($lang))
$lang = 'en';
- if(file_exists("view/$lang$engine/$s"))
- return file_get_contents("view/$lang$engine/$s");
- elseif(file_exists("view/en$engine/$s"))
- return file_get_contents("view/en$engine/$s");
- else
- return file_get_contents("view$engine/$s");
+ if(file_exists("view/$lang$engine/$s")) {
+ $stamp1 = microtime(true);
+ $content = file_get_contents("view/$lang$engine/$s");
+ $a->save_timestamp($stamp1, "file");
+ return $content;
+ } elseif(file_exists("view/en$engine/$s")) {
+ $stamp1 = microtime(true);
+ $content = file_get_contents("view/en$engine/$s");
+ $a->save_timestamp($stamp1, "file");
+ return $content;
+ } else {
+ $stamp1 = microtime(true);
+ $content = file_get_contents("view$engine/$s");
+ $a->save_timestamp($stamp1, "file");
+ return $content;
+ }
}}
if(! function_exists('get_markup_template')) {
function get_markup_template($s, $root = '') {
-// $ts = microtime();
+ $stamp1 = microtime(true);
+
$a = get_app();
if($a->theme['template_engine'] === 'smarty3') {
@@ -479,19 +502,20 @@ function get_markup_template($s, $root = '') {
$template = new FriendicaSmarty();
$template->filename = $template_file;
+ $a->save_timestamp($stamp1, "rendering");
-// $tt = microtime() - $ts;
-// $a->page['debug'] .= "$tt
\n";
return $template;
}
else {
$template_file = get_template_file($a, $s, $root);
-// $file_contents = file_get_contents($template_file);
-// $tt = microtime() - $ts;
-// $a->page['debug'] .= "$tt
\n";
-// return $file_contents;
- return file_get_contents($template_file);
- }
+ $a->save_timestamp($stamp1, "rendering");
+
+ $stamp1 = microtime(true);
+ $content = file_get_contents($template_file);
+ $a->save_timestamp($stamp1, "file");
+ return $content;
+
+ }
}}
if(! function_exists("get_template_file")) {
@@ -547,8 +571,10 @@ function logger($msg,$level = 0) {
if((! $debugging) || (! $logfile) || ($level > $loglevel))
return;
-
+
+ $stamp1 = microtime(true);
@file_put_contents($logfile, datetime_convert() . ':' . session_id() . ' ' . $msg . "\n", FILE_APPEND);
+ $a->save_timestamp($stamp1, "file");
return;
}}
@@ -574,11 +600,12 @@ function get_tags($s) {
$ret = array();
// ignore anything in a code block
-
$s = preg_replace('/\[code\](.*?)\[\/code\]/sm','',$s);
- // ignore anything in a bbtag
+ // Force line feeds at bbtags
+ $s = str_replace(array("[", "]"), array("\n[", "]\n"), $s);
+ // ignore anything in a bbtag
$s = preg_replace('/\[(.*?)\]/sm','',$s);
// Match full names against @tags including the space between first and last
@@ -1030,14 +1057,20 @@ function prepare_body($item,$attach = false) {
$a = get_app();
call_hooks('prepare_body_init', $item);
- $cachefile = get_cachefile($item["guid"]."-".strtotime($item["edited"])."-".hash("crc32", $item['body']));
+ //$cachefile = get_cachefile($item["guid"]."-".strtotime($item["edited"])."-".hash("crc32", $item['body']));
+ $cachefile = get_cachefile($item["guid"]."-".hash("md5", $item['body']));
if (($cachefile != '')) {
- if (file_exists($cachefile))
+ if (file_exists($cachefile)) {
+ $stamp1 = microtime(true);
$s = file_get_contents($cachefile);
- else {
+ $a->save_timestamp($stamp1, "file");
+ } else {
$s = prepare_text($item['body']);
+ $stamp1 = microtime(true);
file_put_contents($cachefile, $s);
+ $a->save_timestamp($stamp1, "file");
+ logger('prepare_body: put item '.$item["id"].' into cachefile '.$cachefile);
}
} else
$s = prepare_text($item['body']);
diff --git a/index.php b/index.php
index a1926d63a..3ccdc725f 100644
--- a/index.php
+++ b/index.php
@@ -33,7 +33,7 @@ $install = ((file_exists('.htconfig.php') && filesize('.htconfig.php')) ? false
$lang = get_browser_language();
-
+
load_translation_table($lang);
/**
diff --git a/mod/admin.php b/mod/admin.php
index 9400a28e0..98e52d28b 100644
--- a/mod/admin.php
+++ b/mod/admin.php
@@ -20,7 +20,7 @@ function admin_post(&$a){
if(x($_SESSION,'submanage') && intval($_SESSION['submanage']))
return;
-
+
// urls
@@ -54,7 +54,7 @@ function admin_post(&$a){
}
info(t('Theme settings updated.'));
if(is_ajax()) return;
-
+
goaway($a->get_baseurl(true) . '/admin/themes/' . $theme );
return;
break;
@@ -100,9 +100,9 @@ function admin_content(&$a) {
'dbsync' => Array($a->get_baseurl(true)."/admin/dbsync/", t('DB updates'), "dbsync"),
//'update' => Array($a->get_baseurl(true)."/admin/update/", t("Software Update") , "update")
);
-
+
/* get plugins admin page */
-
+
$r = q("SELECT * FROM `addon` WHERE `plugin_admin`=1");
$aside['plugins_admin']=Array();
foreach ($r as $h){
@@ -111,7 +111,7 @@ function admin_content(&$a) {
// temp plugins with admin
$a->plugins_admin[] = $plugin;
}
-
+
$aside['logs'] = Array($a->get_baseurl(true)."/admin/logs/", t("Logs"), "logs");
$t = get_markup_template("admin_aside.tpl");
@@ -130,7 +130,6 @@ function admin_content(&$a) {
* Page content
*/
$o = '';
-
// urls
if ($a->argc > 1){
switch ($a->argv[1]){
@@ -161,7 +160,7 @@ function admin_content(&$a) {
} else {
$o = admin_page_summary($a);
}
-
+
if(is_ajax()) {
echo $o;
killme();
@@ -447,13 +446,13 @@ function admin_page_site(&$a) {
foreach ($users as $user) {
$user_names[$user['nickname']] = $user['username'];
}
-
+
/* Banner */
$banner = get_config('system','banner');
if($banner == false)
$banner = 'Friendica';
$banner = htmlspecialchars($banner);
-
+
//echo "
"; var_dump($lang_choices); die(""); /* Register policy */ @@ -780,7 +779,7 @@ function admin_page_users(&$a){ * @return string */ function admin_page_plugins(&$a){ - + /** * Single plugin */ @@ -790,9 +789,9 @@ function admin_page_plugins(&$a){ notice( t("Item not found.") ); return ''; } - + if (x($_GET,"a") && $_GET['a']=="t"){ - check_form_security_token_redirectOnErr('/admin/plugins', 'admin_themes', 't'); + check_form_security_token_redirectOnErr('/admin/plugins', 'admin_themes', 't'); // Toggle plugin status $idx = array_search($plugin, $a->plugins); @@ -817,52 +816,53 @@ function admin_page_plugins(&$a){ } else { $status="off"; $action= t("Enable"); } - + $readme=Null; if (is_file("addon/$plugin/README.md")){ $readme = file_get_contents("addon/$plugin/README.md"); $readme = Markdown($readme); } else if (is_file("addon/$plugin/README")){ $readme = "
". file_get_contents("addon/$plugin/README") .""; - } - + } + $admin_form=""; if (is_array($a->plugins_admin) && in_array($plugin, $a->plugins_admin)){ @require_once("addon/$plugin/$plugin.php"); $func = $plugin.'_plugin_admin'; $func($a, $admin_form); } - + $t = get_markup_template("admin_plugins_details.tpl"); + return replace_macros($t, array( '$title' => t('Administration'), '$page' => t('Plugins'), '$toggle' => t('Toggle'), '$settings' => t('Settings'), '$baseurl' => $a->get_baseurl(true), - + '$plugin' => $plugin, '$status' => $status, '$action' => $action, '$info' => get_plugin_info($plugin), '$str_author' => t('Author: '), - '$str_maintainer' => t('Maintainer: '), - + '$str_maintainer' => t('Maintainer: '), + '$admin_form' => $admin_form, '$function' => 'plugins', '$screenshot' => '', '$readme' => $readme, - '$form_security_token' => get_form_security_token("admin_themes"), + '$form_security_token' => get_form_security_token("admin_themes"), )); - } - - - + } + + + /** * List plugins */ - + $plugins = array(); $files = glob("addon/*/"); if($files) { @@ -874,7 +874,7 @@ function admin_page_plugins(&$a){ } } } - + $t = get_markup_template("admin_plugins.tpl"); return replace_macros($t, array( '$title' => t('Administration'), @@ -945,7 +945,7 @@ function rebuild_theme_table($themes) { return $o; } - + /** * Themes admin page * @@ -953,7 +953,7 @@ function rebuild_theme_table($themes) { * @return string */ function admin_page_themes(&$a){ - + $allowed_themes_str = get_config('system','allowed_themes'); $allowed_themes_raw = explode(',',$allowed_themes_str); $allowed_themes = array(); @@ -989,9 +989,9 @@ function admin_page_themes(&$a){ notice( t("Item not found.") ); return ''; } - + if (x($_GET,"a") && $_GET['a']=="t"){ - check_form_security_token_redirectOnErr('/admin/themes', 'admin_themes', 't'); + check_form_security_token_redirectOnErr('/admin/themes', 'admin_themes', 't'); // Toggle theme status @@ -1019,28 +1019,27 @@ function admin_page_themes(&$a){ } else { $status="off"; $action= t("Enable"); } - + $readme=Null; if (is_file("view/theme/$theme/README.md")){ $readme = file_get_contents("view/theme/$theme/README.md"); $readme = Markdown($readme); } else if (is_file("view/theme/$theme/README")){ $readme = "
". file_get_contents("view/theme/$theme/README") .""; - } - + } + $admin_form=""; if (is_file("view/theme/$theme/config.php")){ require_once("view/theme/$theme/config.php"); if(function_exists("theme_admin")){ $admin_form = theme_admin($a); } - + } - $screenshot = array( get_theme_screenshot($theme), t('Screenshot')); if(! stristr($screenshot[0],$theme)) - $screenshot = null; + $screenshot = null; $t = get_markup_template("admin_plugins_details.tpl"); return replace_macros($t, array( @@ -1049,7 +1048,7 @@ function admin_page_themes(&$a){ '$toggle' => t('Toggle'), '$settings' => t('Settings'), '$baseurl' => $a->get_baseurl(true), - + '$plugin' => $theme, '$status' => $status, '$action' => $action, @@ -1063,21 +1062,19 @@ function admin_page_themes(&$a){ '$form_security_token' => get_form_security_token("admin_themes"), )); - } - - - + } + /** * List themes */ - + $xthemes = array(); if($themes) { foreach($themes as $th) { $xthemes[] = array($th['name'],(($th['allowed']) ? "on" : "off"), get_theme_info($th['name'])); } } - + $t = get_markup_template("admin_plugins.tpl"); return replace_macros($t, array( '$title' => t('Administration'), diff --git a/mod/community.php b/mod/community.php index aa5bb7268..27a9e2194 100644 --- a/mod/community.php +++ b/mod/community.php @@ -64,23 +64,25 @@ function community_content(&$a, $update = 0) { } - $r = q("SELECT distinct(`item`.`uri`), `item`.*, `item`.`id` AS `item_id`, + //$r = q("SELECT distinct(`item`.`uri`) + $r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`, `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`, `user`.`nickname`, `user`.`hidewall` - FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` + FROM `item` FORCE INDEX (`received`) LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` LEFT JOIN `user` ON `user`.`uid` = `item`.`uid` WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`private` = 0 AND `item`.`wall` = 1 AND `user`.`hidewall` = 0 - AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 group by `item`.`uri` + AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`self` ORDER BY `received` DESC LIMIT %d, %d ", intval($a->pager['start']), intval($a->pager['itemspage']) ); +// group by `item`.`uri` if(! count($r)) { info( t('No results.') . EOL); diff --git a/mod/content.php b/mod/content.php index 318c37233..06f5d58b2 100644 --- a/mod/content.php +++ b/mod/content.php @@ -160,16 +160,26 @@ function content_content(&$a, $update = 0) { $sql_extra2 = (($nouveau) ? '' : " AND `item`.`parent` = `item`.`id` "); $sql_extra3 = (($nouveau) ? '' : $sql_extra3); + $sql_table = "`item`"; if(x($_GET,'search')) { $search = escape_tags($_GET['search']); - if (get_config('system','use_fulltext_engine')) { + + if(strpos($search,'#') === 0) { + $tag = true; + $search = substr($search,1); + } + + if (get_config('system','only_tag_search')) + $tag = true; + + /*if (get_config('system','use_fulltext_engine')) { if(strpos($search,'#') === 0) - $sql_extra .= sprintf(" AND (MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode)) ", + $sql_extra .= sprintf(" AND (MATCH(tag) AGAINST ('%s' in boolean mode)) ", dbesc(protect_sprintf($search)) ); else - $sql_extra .= sprintf(" AND (MATCH(`item`.`body`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode)) ", + $sql_extra .= sprintf(" AND (MATCH(`item`.`body`, `item`.`title`) AGAINST ('%s' in boolean mode)) ", dbesc(protect_sprintf($search)), dbesc(protect_sprintf($search)) ); @@ -178,7 +188,19 @@ function content_content(&$a, $update = 0) { dbesc(protect_sprintf('%' . $search . '%')), dbesc(protect_sprintf('%]' . $search . '[%')) ); + }*/ + + 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` "; + } 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))); + else + $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search)))); } + } if(strlen($file)) { $sql_extra .= file_tag_file_query('item',unxmlify($file)); @@ -189,38 +211,39 @@ function content_content(&$a, $update = 0) { $myurl = substr($myurl,strpos($myurl,'://')+3); $myurl = str_replace('www.','',$myurl); $diasp_url = str_replace('/profile/','/u/',$myurl); - if (get_config('system','use_fulltext_engine')) - $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where (MATCH(`author-link`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(`tag`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode))) ", + /*if (get_config('system','use_fulltext_engine')) + $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from $sql_table where (MATCH(`author-link`, `tag`) AGAINST ('%s' in boolean mode) or MATCH(tag) AGAINST ('%s' in boolean mode))) ", dbesc(protect_sprintf($myurl)), dbesc(protect_sprintf($myurl)), dbesc(protect_sprintf($diasp_url)) ); else - $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` like '%s' or `tag` like '%s' or tag like '%s' )) ", + $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from $sql_table where ( `author-link` like '%s' or `tag` like '%s' or tag like '%s' )) ", dbesc(protect_sprintf('%' . $myurl)), dbesc(protect_sprintf('%' . $myurl . ']%')), dbesc(protect_sprintf('%' . $diasp_url . ']%')) - ); + );*/ + $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where `author-link` IN ('https://%s', 'http://%s') OR `mention`)", + dbesc(protect_sprintf($myurl)), + dbesc(protect_sprintf($myurl)) + ); } $pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage'])); - - if($nouveau) { // "New Item View" - show all items unthreaded in reverse created date order - $items = q("SELECT `item`.*, `item`.`id` AS `item_id`, + $items = q("SELECT `item`.*, `item`.`id` AS `item_id`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`writable`, `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` - FROM `item`, `contact` - WHERE `item`.`uid` = %d AND `item`.`visible` = 1 + FROM $sql_table LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` + WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 $simple_update - AND `contact`.`id` = `item`.`contact-id` AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 $sql_extra $sql_nets ORDER BY `item`.`received` DESC $pager_sql ", @@ -241,7 +264,7 @@ function content_content(&$a, $update = 0) { $start = dba_timer(); $r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact_uid` - FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` + FROM $sql_table LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 AND `item`.`moderated` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `item`.`parent` = `item`.`id` @@ -268,9 +291,9 @@ function content_content(&$a, $update = 0) { `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`, `contact`.`writable`, `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` - FROM `item`, `contact` + FROM $sql_table LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 - AND `item`.`moderated` = 0 AND `contact`.`id` = `item`.`contact-id` + AND `item`.`moderated` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `item`.`parent` IN ( %s ) $sql_extra ", @@ -287,7 +310,7 @@ function content_content(&$a, $update = 0) { } } - + logger('parent dba_timer: ' . sprintf('%01.4f',$first - $start)); logger('child dba_timer: ' . sprintf('%01.4f',$second - $first)); @@ -298,7 +321,7 @@ function content_content(&$a, $update = 0) { $o = render_content($a,$items,$mode,false); - + header('Content-type: application/json'); echo json_encode($o); killme(); diff --git a/mod/item.php b/mod/item.php index 4fd4a23dc..cca40e3a0 100644 --- a/mod/item.php +++ b/mod/item.php @@ -19,6 +19,7 @@ require_once('include/crypto.php'); require_once('include/enotify.php'); require_once('include/email.php'); require_once('library/langdet/Text/LanguageDetect.php'); +require_once('include/tags.php'); function item_post(&$a) { @@ -236,9 +237,23 @@ function item_post(&$a) { if (version_compare(PHP_VERSION, '5.3.0', '>=')) { $l = new Text_LanguageDetect; - $lng = $l->detectConfidence($naked_body); + //$lng = $l->detectConfidence($naked_body); + //$postopts = (($lng['language']) ? 'lang=' . $lng['language'] . ';' . $lng['confidence'] : ''); - $postopts = (($lng['language']) ? 'lang=' . $lng['language'] . ';' . $lng['confidence'] : ''); + $lng = $l->detect($naked_body, 3); + + if (sizeof($lng) > 0) { + $postopts = ""; + + foreach ($lng as $language => $score) { + if ($postopts == "") + $postopts = "lang="; + else + $postopts .= ":"; + + $postopts .= $language.";".$score; + } + } logger('mod_item: detect language' . print_r($lng,true) . $naked_body, LOGGER_DATA); } @@ -675,6 +690,7 @@ function item_post(&$a) { intval($post_id), intval($profile_uid) ); + create_tags_from_itemuri($post_id, $profile_uid); // update filetags in pconfig file_tag_update_pconfig($uid,$categories_old,$categories_new,'category'); @@ -740,10 +756,22 @@ function item_post(&$a) { if(count($r)) { $post_id = $r[0]['id']; logger('mod_item: saved item ' . $post_id); + create_tags_from_item($post_id); // update filetags in pconfig file_tag_update_pconfig($uid,$categories_old,$categories_new,'category'); + // Store the fresh generated item into the cache + $cachefile = get_cachefile($datarray["guid"]."-".hash("md5", $datarray['body'])); + + if (($cachefile != '') AND !file_exists($cachefile)) { + $s = prepare_text($datarray['body']); + $stamp1 = microtime(true); + file_put_contents($cachefile, $s); + $a->save_timestamp($stamp1, "file"); + logger('mod_item: put item '.$r[0]['id'].' into cachefile '.$cachefile); + } + if($parent) { // This item is the last leaf and gets the comment box, clear any ancestors diff --git a/mod/network.php b/mod/network.php index b5046b632..ba7bff791 100644 --- a/mod/network.php +++ b/mod/network.php @@ -6,7 +6,7 @@ function network_init(&$a) { notice( t('Permission denied.') . EOL); return; } - + $is_a_date_query = false; if($a->argc > 1) { @@ -17,12 +17,12 @@ function network_init(&$a) { } } } - + // convert query string to array and remove first element (which is friendica args) $query_array = array(); parse_str($a->query_string, $query_array); array_shift($query_array); - + // fetch last used network view and redirect if needed if(! $is_a_date_query) { $sel_tabs = network_query_get_sel_tab($a); @@ -141,11 +141,11 @@ function network_init(&$a) { if(x($_GET['nets']) && $_GET['nets'] === 'all') unset($_GET['nets']); - + $group_id = (($a->argc > 1 && is_numeric($a->argv[1])) ? intval($a->argv[1]) : 0); set_pconfig(local_user(), 'network.view', 'group.selected', $group_id); - + require_once('include/group.php'); require_once('include/contact_widgets.php'); require_once('include/items.php'); @@ -321,7 +321,7 @@ function network_query_get_sel_net() { if(x($_GET,'nets')) { $network = $_GET['nets']; } - + return $network; } @@ -382,14 +382,14 @@ function network_content(&$a, $update = 0) { // item filter tabs // TODO: fix this logic, reduce duplication //$a->page['content'] .= '
"; var_dump($no_active, $all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active); killme(); $cmd = (($datequery) ? '' : $a->cmd); - $len_naked_cmd = strlen(str_replace('/new','',$cmd)); + $len_naked_cmd = strlen(str_replace('/new','',$cmd)); // tabs $tabs = array( @@ -435,10 +435,10 @@ function network_content(&$a, $update = 0) { // 'url'=>$a->get_baseurl(true) . '/network?f=&spam=1' // 'sel'=> $spam_active, // 'title' => t('Posts flagged as SPAM'), -// ), +// ), ); - + if(feature_enabled(local_user(),'personal_tab')) { $tabs[] = array( 'label' => t('Personal'), @@ -500,7 +500,7 @@ function network_content(&$a, $update = 0) { - + $contact_id = $a->cid; @@ -573,11 +573,11 @@ function network_content(&$a, $update = 0) { } - // We don't have to deal with ACL's on this page. You're looking at everything + // We don't have to deal with ACLs on this page. You're looking at everything // that belongs to you, hence you can see all of it. We will filter by group if // desired. - + $sql_options = (($star) ? " and starred = 1 " : ''); $sql_options .= (($bmark) ? " and bookmark = 1 " : ''); @@ -647,16 +647,26 @@ function network_content(&$a, $update = 0) { $sql_extra2 = (($nouveau) ? '' : " AND `item`.`parent` = `item`.`id` "); $sql_extra3 = (($nouveau) ? '' : $sql_extra3); + $sql_table = "`item`"; if(x($_GET,'search')) { $search = escape_tags($_GET['search']); - if (get_config('system','use_fulltext_engine')) { + + if(strpos($search,'#') === 0) { + $tag = true; + $search = substr($search,1); + } + + if (get_config('system','only_tag_search')) + $tag = true; + + /*if (get_config('system','use_fulltext_engine')) { if(strpos($search,'#') === 0) $sql_extra .= sprintf(" AND (MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode)) ", dbesc(protect_sprintf($search)) ); else - $sql_extra .= sprintf(" AND (MATCH(`item`.`body`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode)) ", + $sql_extra .= sprintf(" AND (MATCH(`item`.`body`, `item`.`title`) AGAINST ('%s' in boolean mode)) ", dbesc(protect_sprintf($search)), dbesc(protect_sprintf($search)) ); @@ -665,6 +675,17 @@ function network_content(&$a, $update = 0) { dbesc(protect_sprintf('%' . $search . '%')), dbesc(protect_sprintf('%]' . $search . '[%')) ); + }*/ + + 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` "; + } 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))); + else + $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search)))); } } if(strlen($file)) { @@ -676,8 +697,10 @@ function network_content(&$a, $update = 0) { $myurl = substr($myurl,strpos($myurl,'://')+3); $myurl = str_replace('www.','',$myurl); $diasp_url = str_replace('/profile/','/u/',$myurl); - if (get_config('system','use_fulltext_engine')) + /*if (get_config('system','use_fulltext_engine')) $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where (MATCH(`author-link`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(`tag`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode))) ", + //$sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where (`author-link` IN ('https://%s', 'http://%s') OR MATCH(`tag`) AGAINST ('".'"%s"'."' in boolean mode) or MATCH(tag) AGAINST ('".'"%s"'."' in boolean mode))) ", + //$sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where `author-link` IN ('https://%s', 'http://%s') OR `mention`)", dbesc(protect_sprintf($myurl)), dbesc(protect_sprintf($myurl)), dbesc(protect_sprintf($diasp_url)) @@ -687,8 +710,12 @@ function network_content(&$a, $update = 0) { dbesc(protect_sprintf('%' . $myurl)), dbesc(protect_sprintf('%' . $myurl . ']%')), dbesc(protect_sprintf('%' . $diasp_url . ']%')) - ); + );*/ + $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where `author-link` IN ('https://%s', 'http://%s') OR `mention`)", + dbesc(protect_sprintf($myurl)), + dbesc(protect_sprintf($myurl)) + ); } if($update) { @@ -700,7 +727,7 @@ function network_content(&$a, $update = 0) { else { if( (! get_config('alt_pager', 'global')) && (! get_pconfig(local_user(),'system','alt_pager')) ) { $r = q("SELECT COUNT(*) AS `total` - FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` + FROM $sql_table LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 $sql_extra2 $sql_extra3 @@ -731,11 +758,10 @@ function network_content(&$a, $update = 0) { `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`writable`, `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` - FROM `item`, `contact` + FROM $sql_table LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 $simple_update - AND `contact`.`id` = `item`.`contact-id` AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 $sql_extra $sql_nets ORDER BY `item`.`received` DESC $pager_sql ", @@ -758,7 +784,7 @@ function network_content(&$a, $update = 0) { if($update) { $r = q("SELECT `parent` AS `item_id`, `contact`.`uid` AS `contact_uid` - FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` + 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 . "') and `item`.`moderated` = 0 and `item`.`unseen` = 1 @@ -769,7 +795,7 @@ function network_content(&$a, $update = 0) { } else { $r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact_uid` - FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` + FROM $sql_table LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 AND `item`.`moderated` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `item`.`parent` = `item`.`id` @@ -794,9 +820,9 @@ function network_content(&$a, $update = 0) { `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`, `contact`.`writable`, `contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` - FROM `item`, `contact` + FROM $sql_table LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 - AND `item`.`moderated` = 0 AND `contact`.`id` = `item`.`contact-id` + AND `item`.`moderated` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `item`.`parent` IN ( %s ) $sql_extra ", @@ -818,7 +844,7 @@ function network_content(&$a, $update = 0) { // We aren't going to try and figure out at the item, group, and page // level which items you've seen and which you haven't. If you're looking // at the top level network page just mark everything seen. - + // The $update_unseen is a bit unreliable if you have stuff coming into your stream from a new contact - // and other feeds that bring in stuff from the past. One can't find it all. diff --git a/mod/photo.php b/mod/photo.php index 93db82a64..497dcd750 100644 --- a/mod/photo.php +++ b/mod/photo.php @@ -106,7 +106,7 @@ function photo_init(&$a) { intval($resolution) ); if(count($r)) { - + $sql_extra = permissions_sql($r[0]['uid']); // Now we'll see if we can access the photo @@ -169,10 +169,13 @@ function photo_init(&$a) { } } - if(isset($customres) && $customres > 0 && $customres < 500) { + // Resize only if its not a GIF + if ($mime != "image/gif") { $ph = new Photo($data, $mimetype); if($ph->is_valid()) { - $ph->scaleImageSquare($customres); + if(isset($customres) && $customres > 0 && $customres < 500) { + $ph->scaleImageSquare($customres); + } $data = $ph->imageString(); $mimetype = $ph->getType(); } diff --git a/mod/photos.php b/mod/photos.php index c6892818a..79a51fd4c 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -5,7 +5,7 @@ require_once('include/acl_selectors.php'); require_once('include/bbcode.php'); require_once('include/security.php'); require_once('include/redir.php'); - +require_once('include/tags.php'); function photos_init(&$a) { @@ -252,6 +252,7 @@ function photos_post(&$a) { dbesc($rr['parent-uri']), intval($page_owner_uid) ); + create_tags_from_itemuri($rr['parent-uri'], $page_owner_uid); $drop_id = intval($rr['id']); @@ -321,6 +322,7 @@ function photos_post(&$a) { dbesc($i[0]['uri']), intval($page_owner_uid) ); + create_tags_from_itemuri($i[0]['uri'], $page_owner_uid); $url = $a->get_baseurl(); $drop_id = intval($i[0]['id']); @@ -381,7 +383,7 @@ function photos_post(&$a) { $ph->scaleImage(640); $width = $ph->getWidth(); $height = $ph->getHeight(); - + $x = q("update photo set data = '%s', height = %d, width = %d where `resource-id` = '%s' and uid = %d and scale = 1 limit 1", dbesc($ph->imageString()), intval($height), @@ -403,7 +405,7 @@ function photos_post(&$a) { dbesc($resource_id), intval($page_owner_uid) ); - } + } } } } @@ -605,6 +607,7 @@ function photos_post(&$a) { intval($item_id), intval($page_owner_uid) ); + create_tags_from_item($item_id); $best = 0; foreach($p as $scales) { @@ -880,8 +883,8 @@ function photos_post(&$a) { intval($item_id) ); } - - if($visible) + + if($visible) proc_run('php', "include/notifier.php", 'wall-new', $item_id); call_hooks('photo_post_end',intval($item_id)); @@ -1418,7 +1421,7 @@ function photos_content(&$a) { intval($a->pager['itemspage']) ); - + if((local_user()) && (local_user() == $link_item['uid'])) { q("UPDATE `item` SET `unseen` = 0 WHERE `parent` = %d and `uid` = %d", intval($link_item['parent']), diff --git a/mod/search.php b/mod/search.php index 2753c2e1e..f7d235d45 100644 --- a/mod/search.php +++ b/mod/search.php @@ -23,7 +23,7 @@ function search_saved_searches() { ); } - + $tpl = get_markup_template("saved_searches_aside.tpl"); $o .= replace_macros($tpl, array( @@ -32,7 +32,7 @@ function search_saved_searches() { '$searchbox' => '', '$saved' => $saved, )); - } + } return $o; @@ -124,7 +124,10 @@ function search_content(&$a) { if(! $search) return $o; - if (get_config('system','use_fulltext_engine')) { + if (get_config('system','only_tag_search')) + $tag = true; + + /*if (get_config('system','use_fulltext_engine')) { if($tag) $sql_extra = sprintf(" AND MATCH (`item`.`tag`) AGAINST ('".'"%s"'."' in boolean mode) ", '#'.dbesc(protect_sprintf($search))); else @@ -134,11 +137,25 @@ function search_content(&$a) { $sql_extra = sprintf(" AND `item`.`tag` REGEXP '%s' ", dbesc('\\]' . protect_sprintf(preg_quote($search)) . '\\[')); else $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search)))); + }*/ + + 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 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`) "; + } 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))); + } else { + $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search)))); + } + $sql_table = "`item`"; } - - - // Here is the way permissions work in the search module... // Only public posts can be shown // OR your own posts if you are a logged in member @@ -146,14 +163,15 @@ function search_content(&$a) { if( (! get_config('alt_pager', 'global')) && (! get_pconfig(local_user(),'system','alt_pager')) ) { $r = q("SELECT distinct(`item`.`uri`) as `total` - FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` LEFT JOIN `user` ON `user`.`uid` = `item`.`uid` + FROM $sql_table LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` LEFT JOIN `user` ON `user`.`uid` = `item`.`uid` WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 AND (( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`private` = 0 AND `user`.`hidewall` = 0) OR ( `item`.`uid` = %d )) AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 - $sql_extra group by `item`.`uri` ", + $sql_extra ", intval(local_user()) ); +// $sql_extra group by `item`.`uri` ", if(count($r)) $a->set_pager_total(count($r)); @@ -164,25 +182,25 @@ function search_content(&$a) { } } - $r = q("SELECT distinct(`item`.`uri`), `item`.*, `item`.`id` AS `item_id`, + $r = q("SELECT `item`.`uri`, `item`.*, `item`.`id` AS `item_id`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`, `contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`, `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`, `user`.`nickname`, `user`.`uid`, `user`.`hidewall` - FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` + FROM $sql_table LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` LEFT JOIN `user` ON `user`.`uid` = `item`.`uid` WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0 and `item`.`moderated` = 0 AND (( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`private` = 0 AND `user`.`hidewall` = 0 ) OR ( `item`.`uid` = %d )) AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 $sql_extra - group by `item`.`uri` ORDER BY `received` DESC LIMIT %d , %d ", intval(local_user()), intval($a->pager['start']), intval($a->pager['itemspage']) ); +// group by `item`.`uri` if(! count($r)) { info( t('No results.') . EOL); diff --git a/mods/readme.txt b/mods/readme.txt index 9e79f843f..d74b846d0 100644 --- a/mods/readme.txt +++ b/mods/readme.txt @@ -3,3 +3,4 @@ Site speed can be improved when the following indexes are set. They cannot be se CREATE INDEX `uid_commented` ON `item` (`uid`, `commented`); CREATE INDEX `uid_created` ON `item` (`uid`, `created`); CREATE INDEX `uid_unseen` ON `item` (`uid`, `unseen`); +CREATE INDEX `resource-id` ON `item` (`resource-id`); diff --git a/object/Conversation.php b/object/Conversation.php index 8b838f7d0..bd7a95cf2 100644 --- a/object/Conversation.php +++ b/object/Conversation.php @@ -127,6 +127,7 @@ class Conversation extends BaseObject { * _ false on failure */ public function get_template_data($alike, $dlike) { + global $a; $result = array(); foreach($this->threads as $item) { @@ -140,6 +141,7 @@ class Conversation extends BaseObject { $result[] = $item_data; } + //$a->mark_timestamp(); return $result; } diff --git a/object/Item.php b/object/Item.php index cd42c4008..139a81f71 100644 --- a/object/Item.php +++ b/object/Item.php @@ -146,10 +146,30 @@ class Item extends BaseObject { call_hooks('render_location',$locate); $location = ((strlen($locate['html'])) ? $locate['html'] : render_location_google($locate)); + $searchpath = $a->get_baseurl()."/search?tag="; $tags=array(); $hashtags = array(); $mentions = array(); - foreach(explode(',',$item['tag']) as $tag){ + + $taglist = q("SELECT `type`, `term`, `url` FROM `term` WHERE `otype` = %d AND `oid` = %d AND `type` IN (%d, %d) ORDER BY `tid`", + intval(TERM_OBJ_POST), intval($item['id']), intval(TERM_HASHTAG), intval(TERM_MENTION)); + + foreach($taglist as $tag) { + + if ($tag["url"] == "") + $tag["url"] = $searchpath.strtolower($tag["term"]); + + if ($tag["type"] == TERM_HASHTAG) { + $hashtags[] = "#".$tag["term"].""; + $prefix = "#"; + } elseif ($tag["type"] == TERM_MENTION) { + $mentions[] = "@".$tag["term"].""; + $prefix = "@"; + } + $tags[] = $prefix."".$tag["term"].""; + } + + /*foreach(explode(',',$item['tag']) as $tag){ $tag = trim($tag); if ($tag!="") { $t = bbcode($tag); @@ -159,8 +179,7 @@ class Item extends BaseObject { elseif($t[0] == '@') $mentions[] = $t; } - - } + }*/ $like = ((x($alike,$item['uri'])) ? format_like($alike[$item['uri']],$alike[$item['uri'] . '-l'],'like',$item['uri']) : ''); $dislike = ((x($dlike,$item['uri'])) ? format_like($dlike[$item['uri']],$dlike[$item['uri'] . '-l'],'dislike',$item['uri']) : ''); @@ -171,10 +190,10 @@ class Item extends BaseObject { * Maybe we should establish a way to be notified about conversation changes */ $this->check_wall_to_wall(); - + if($this->is_wall_to_wall() && ($this->get_owner_url() == $this->get_redirect_url())) $osparkle = ' sparkle'; - + if($this->is_toplevel()) { if($conv->get_profile_owner() == local_user()) { $isstarred = (($item['starred']) ? "starred" : "unstarred"); @@ -214,8 +233,28 @@ class Item extends BaseObject { localize_item($item); if ($item["postopts"]) { - $langdata = explode(";", $item["postopts"]); - $langstr = substr($langdata[0], 5)." (".round($langdata[1]*100, 1)."%)"; + //$langdata = explode(";", $item["postopts"]); + //$langstr = substr($langdata[0], 5)." (".round($langdata[1]*100, 1)."%)"; + $langstr = ""; + if (substr($item["postopts"], 0, 5) == "lang=") { + $postopts = substr($item["postopts"], 5); + + $languages = explode(":", $postopts); + + if (sizeof($languages) == 1) { + $languages = array(); + $languages[] = $postopts; + } + + foreach ($languages as $language) { + $langdata = explode(";", $language); + if ($langstr != "") + $langstr .= ", "; + + //$langstr .= $langdata[0]." (".round($langdata[1]*100, 1)."%)"; + $langstr .= round($langdata[1]*100, 1)."% ".$langdata[0]; + } + } } $body = prepare_body($item,true); @@ -244,14 +283,14 @@ class Item extends BaseObject { 'type' => implode("",array_slice(explode("/",$item['verb']),-1)), 'tags' => $tags, - 'hashtags' => $hashtags, - 'mentions' => $mentions, + 'hashtags' => $hashtags, + 'mentions' => $mentions, 'txt_cats' => t('Categories:'), 'txt_folders' => t('Filed under:'), 'has_cats' => ((count($categories)) ? 'true' : ''), 'has_folders' => ((count($folders)) ? 'true' : ''), - 'categories' => $categories, - 'folders' => $folders, + 'categories' => $categories, + 'folders' => $folders, 'body' => $body_e, 'text' => $text_e, 'id' => $this->get_id(), @@ -322,12 +361,12 @@ class Item extends BaseObject { } } } - + if ($this->is_toplevel()) { $result['total_comments_num'] = "$total_children"; $result['total_comments_text'] = tt('comment', 'comments', $total_children); } - + $result['private'] = $item['private']; $result['toplevel'] = ($this->is_toplevel() ? 'toplevel_item' : ''); diff --git a/update.php b/update.php index b70e7b8ce..6dd58757b 100644 --- a/update.php +++ b/update.php @@ -1,6 +1,6 @@