home.html\r
addon\r
*~\r
+robots.txt\r
\r
#ignore documentation, it should be newly built \r
doc/api\r
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', "<br />\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
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 );
public $identities;
public $is_mobile;
public $is_tablet;
-
+ public $performance = array();
+
public $nav_sel;
public $category;
private $cached_profile_image;
private $cached_profile_picdate;
-
+
function __construct() {
global $default_timezone, $argv, $argc;
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();
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"];
+ }
}
}
`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`),
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`),
--
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;
-- --------------------------------------------------------
`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;
$network = null;
$diaspora = false;
$diaspora_base = '';
- $diaspora_guid = '';
+ $diaspora_guid = '';
$diaspora_key = '';
$has_lrdd = false;
$email_conversant = false;
}
}
}
- }
+ }
if($mode == PROBE_NORMAL) {
if(strlen($zot)) {
}
if(strpos($url,'@'))
$addr = str_replace('acct:', '', $url);
- }
+ }
if($network !== NETWORK_ZOT && $network !== NETWORK_DFRN && $network !== NETWORK_MAIL) {
if($diaspora)
$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);
}
$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';
$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');
if (count($lastwall)>0){
$lastwall = $lastwall[0];
-
+
$in_reply_to_status_id = '';
$in_reply_to_user_id = '';
$in_reply_to_screen_name = '';
$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,
$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,
$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);
$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']);
}
// 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))
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 = "<br />".html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8').' <a href="'.$profile.'">'.$author."</a>: <br />»".$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();
$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('<br />','<br />'), $Text);
$Text = preg_replace("/\[img\](.*?)\[\/img\]/ism", '<img src="$1" alt="' . t('Image/photo') . '" />', $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",'<br/><img src="' .$a->get_baseurl() . '/images/lock_icon.gif" alt="' . t('Encrypted content') . '" title="' . t('Encrypted content') . '" /><br />', $Text);
$Text = preg_replace("/\[crypt=(.*?)\](.*?)\[\/crypt\]/ism",'<br/><img src="' .$a->get_baseurl() . '/images/lock_icon.gif" alt="' . t('Encrypted content') . '" title="' . '$1' . ' ' . t('Encrypted content') . '" /><br />', $Text);
// 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;
$Text = str_replace('<br></li>','</li>', $Text);
$Text = mb_convert_encoding($Text, "UTF-8", 'HTML-ENTITIES');
- }
+ //}
call_hooks('bbcode',$Text);
+ $a->save_timestamp($stamp1, "parser");
+
return $Text;
}
if(!function_exists('conversation')) {
function conversation(&$a, $items, $mode, $update, $preview = false) {
-
require_once('include/bbcode.php');
$ssl_state = ((local_user()) ? true : 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[] = "#<a href=\"".$tag["url"]."\" target=\"external-link\">".$tag["term"]."</a>";
+ $prefix = "#";
+ } elseif ($tag["type"] == TERM_MENTION) {
+ $mentions[] = "@<a href=\"".$tag["url"]."\" target=\"external-link\">".$tag["term"]."</a>";
+ $prefix = "@";
+ }
+ $tags[] = $prefix."<a href=\"".$tag["url"]."\" target=\"external-link\">".$tag["term"]."</a>";
+ }
+
+ /*foreach(explode(',',$item['tag']) as $tag){
$tag = trim($tag);
if ($tag!="") {
$t = bbcode($tag);
elseif($t[0] == '@')
$mentions[] = $t;
}
- }
+ }*/
$sp = false;
$profile_link = best_link_url($item,$sp);
public $error = false;
function __construct($server,$user,$pass,$db,$install = false) {
+ global $a;
+
+ $stamp1 = microtime(true);
$server = trim($server);
$user = trim($user);
if(! $install)
system_unavailable();
}
+
+ $a->save_timestamp($stamp1, "network");
}
public function getdb() {
$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".
}
}
+ $a->save_timestamp($stamp1, "database");
if($this->debug)
logger('dba: ' . printable(print_r($r, true)));
}
-
+
function diaspora_request($importer,$xml) {
$a = get_app();
if(! $sender_handle || ! $recipient_handle)
return;
-
+
$contact = diaspora_get_contact_by_handle($importer['uid'],$sender_handle);
if($contact) {
}
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)
$myaddr = bin2hex($a->get_baseurl() . '/profile/' . $a->user['nickname']);
else
$myaddr = bin2hex($a->user['nickname'] . '@' . $a->get_hostname());
-
+
goaway($ret['request'] . "&addr=$myaddr");
-
+
// NOTREACHED
}
}
return $result;
}
}
-
+
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) {
}
}
-
+
// default permissions - anonymous user
$r->link = str_replace('&','&', $r->link);
$r->link = preg_replace('/\<link(.*?)\"\>/','<link$1"/>',$r->link);
$o .= $r->link;
- }
+ }
else
$o .= '<link rel="alternate" type="text/html" href="' . xmlify($r->link) . '" />' . "\r\n";
}
$r->link = str_replace('&','&', $r->link);
$r->link = preg_replace('/\<link(.*?)\"\>/','<link$1"/>',$r->link);
$o .= $r->link;
- }
+ }
else
$o .= '<link rel="alternate" type="text/html" href="' . xmlify($r->link) . '" />' . "\r\n";
}
}
// 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;
if($child[NAMESPACE_ACTIVITY]['object-type'][0]['data']) {
$res['object-type'] = $child[NAMESPACE_ACTIVITY]['object-type'][0]['data'];
$res['object'] .= '<type>' . $child[NAMESPACE_ACTIVITY]['object-type'][0]['data'] . '</type>' . "\n";
- }
+ }
if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'id') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'])
$res['object'] .= '<id>' . $child[SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'] . '</id>' . "\n";
if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'link') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['link'])
$child = $rawobj[0]['child'];
if($child[NAMESPACE_ACTIVITY]['object-type'][0]['data']) {
$res['target'] .= '<type>' . $child[NAMESPACE_ACTIVITY]['object-type'][0]['data'] . '</type>' . "\n";
- }
+ }
if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'id') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'])
$res['target'] .= '<id>' . $child[SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'] . '</id>' . "\n";
if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'link') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['link'])
}
}
+ // Search for ostatus conversation url
+ $links = $item->feed->data["child"][SIMPLEPIE_NAMESPACE_ATOM_10]["feed"][0]["child"][SIMPLEPIE_NAMESPACE_ATOM_10]["entry"][0]["child"]["http://www.w3.org/2005/Atom"]["link"];
+
+ if (is_array($links)) {
+ foreach ($links as $link) {
+ $conversation = array_shift($link["attribs"]);
+
+ if ($conversation["rel"] == "ostatus:conversation") {
+ $res["ostatus_conversation"] = $conversation["href"];
+ logger('get_atom_elements: found conversation url '.$res["ostatus_conversation"]);
+ }
+ };
+ }
+
$arr = array('feed' => $feed, 'item' => $item, 'result' => $res);
call_hooks('parse_atom', $arr);
//if (($res["title"] != "") or (strpos($res["body"], "RT @") > 0)) {
//if (strpos($res["body"], "RT @") !== false) {
- // $debugfile = tempnam("/home/ike/log", "item-res2-");
- // file_put_contents($debugfile, serialize($arr));
- //}
+ /*if (strpos($res["body"], "@") !== false) {
+ $debugfile = tempnam("/var/www/virtual/pirati.ca/phptmp/", "item-res2-");
+ file_put_contents($debugfile, serialize($arr));
+ }*/
return $res;
}
unset($arr['dsprsig']);
}
+ // if an OStatus conversation url was passed in, it is stored and then
+ // removed from the array.
+ $ostatus_conversation = null;
+
+ if (isset($arr["ostatus_conversation"])) {
+ $ostatus_conversation = $arr["ostatus_conversation"];
+ unset($arr["ostatus_conversation"]);
+ }
+
if(x($arr, 'gravity'))
$arr['gravity'] = intval($arr['gravity']);
elseif($arr['parent-uri'] === $arr['uri'])
$arr['gravity'] = 0;
elseif(activity_match($arr['verb'],ACTIVITY_POST))
$arr['gravity'] = 6;
- else
+ else
$arr['gravity'] = 6; // extensible catchall
if(! x($arr,'type'))
require_once('library/langdet/Text/LanguageDetect.php');
$naked_body = preg_replace('/\[(.+?)\]/','',$arr['body']);
$l = new Text_LanguageDetect;
- $lng = $l->detectConfidence($naked_body);
- $arr['postopts'] = (($lng['language']) ? 'lang=' . $lng['language'] . ';' . $lng['confidence'] : '');
+ //$lng = $l->detectConfidence($naked_body);
+ //$arr['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;
+ }
+ $arr['postopts'] = $postopts;
+ }
}
$arr['wall'] = ((x($arr,'wall')) ? intval($arr['wall']) : 0);
$deny_cid = $arr['deny_cid'];
$deny_gid = $arr['deny_gid'];
}
- else {
+ else {
- // find the parent and snarf the item id and ACL's
+ // find the parent and snarf the item id and ACLs
// and anything else we need to inherit
$r = q("SELECT * FROM `item` WHERE `uri` = '%s' AND `uid` = %d ORDER BY `id` ASC LIMIT 1",
logger('item_store: item parent was not found - ignoring item');
return 0;
}
-
+
$parent_deleted = 0;
}
}
if(count($r)) {
$current_post = $r[0]['id'];
logger('item_store: created item ' . $current_post);
- }
- else {
+ create_tags_from_item($r[0]['id']);
+ } else {
logger('item_store: could not locate created item');
return 0;
}
);
}
- if((! $parent_id) || ($arr['parent-uri'] === $arr['uri']))
+ if((! $parent_id) || ($arr['parent-uri'] === $arr['uri']))
$parent_id = $current_post;
if(strlen($allow_cid) || strlen($allow_gid) || strlen($deny_cid) || strlen($deny_gid))
intval($parent_deleted),
intval($current_post)
);
+ create_tags_from_item($current_post);
+
+ // Complete ostatus threads
+ if ($ostatus_conversation)
+ complete_conversation($current_post, $ostatus_conversation);
$arr['id'] = $current_post;
$arr['parent'] = $parent_id;
tag_deliver($arr['uid'],$current_post);
+ // Store the fresh generated item into the cache
+ $cachefile = get_cachefile($arr["guid"]."-".hash("md5", $arr['body']));
+
+ if (($cachefile != '') AND !file_exists($cachefile)) {
+ $s = prepare_text($arr['body']);
+ $a = get_app();
+ $stamp1 = microtime(true);
+ file_put_contents($cachefile, $s);
+ $a->save_timestamp($stamp1, "file");
+ logger('item_store: put item '.$current_post.' into cachefile '.$cachefile);
+ }
+
return $current_post;
}
intval($item_id)
);
- proc_run('php','include/notifier.php','tgroup',$item_id);
+ proc_run('php','include/notifier.php','tgroup',$item_id);
}
if($contact['duplex'] && $contact['dfrn-id'])
$idtosend = '0:' . $orig_id;
if($contact['duplex'] && $contact['issued-id'])
- $idtosend = '1:' . $orig_id;
+ $idtosend = '1:' . $orig_id;
$rino = ((function_exists('mcrypt_encrypt')) ? 1 : 0);
break;
case SSL_POLICY_SELFSIGN:
$ssl_policy = 'self';
- break;
+ break;
case SSL_POLICY_NONE:
default:
$ssl_policy = 'none';
intval(($perm == 'rw') ? 1 : 0),
intval($contact['id'])
);
- $contact['writable'] = (string) 1 - intval($contact['writable']);
+ $contact['writable'] = (string) 1 - intval($contact['writable']);
}
}
logger('consume_feed: empty input');
return;
}
-
+
$feed = new SimplePie();
$feed->set_raw_data($xml);
if($datedir)
if($elems['name'][0]['attribs'][NAMESPACE_DFRN]['updated']) {
$name_updated = $elems['name'][0]['attribs'][NAMESPACE_DFRN]['updated'];
$new_name = $elems['name'][0]['data'];
- }
+ }
if((x($elems,'link')) && ($elems['link'][0]['attribs']['']['rel'] === 'photo') && ($elems['link'][0]['attribs'][NAMESPACE_DFRN]['updated'])) {
$photo_timestamp = datetime_convert('UTC','UTC',$elems['link'][0]['attribs'][NAMESPACE_DFRN]['updated']);
$photo_url = $elems['link'][0]['attribs']['']['href'];
intval($contact['uid'])
);
}
-
+
$img->scaleImageSquare(175);
-
+
$hash = $resource_id;
$r = $img->store($contact['uid'], $contact['id'], $hash, basename($photo_url), 'Contact Photos', 4);
-
+
$img->scaleImage(80);
$r = $img->store($contact['uid'], $contact['id'], $hash, basename($photo_url), 'Contact Photos', 5);
$a = get_app();
- q("UPDATE `contact` SET `avatar-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s'
+ q("UPDATE `contact` SET `avatar-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s'
WHERE `uid` = %d AND `id` = %d LIMIT 1",
dbesc(datetime_convert()),
dbesc($a->get_baseurl() . '/photo/' . $hash . '-4.'.$img->getExt()),
* to contain a sparkle link and perhaps a photo.
*
*/
-
+
$bdtext = sprintf( t('%s\'s birthday'), $contact['name']);
$bdtext2 = sprintf( t('Happy Birthday %s'), ' [url=' . $contact['url'] . ']' . $contact['name'] . '[/url]' ) ;
dbesc($bdtext2),
dbesc('birthday')
);
-
+
// update bdyear
dbesc(implode(',',$newtags)),
intval($i[0]['id'])
);
+ create_tags_from_item($i[0]['id']);
}
}
}
dbesc($item['uri']),
intval($importer['uid'])
);
+ create_tags_from_itemuri($item['uri'], $importer['uid']);
}
else {
$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s',
dbesc($uri),
intval($importer['uid'])
);
+ create_tags_from_itemuri($uri, $importer['uid']);
if($item['last-child']) {
// ensure that last-child is set in case the comment that had it just got wiped.
q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d ",
dbesc($item_id),
intval($importer['uid'])
);
+ create_tags_from_itemuri($item_id, $importer['uid']);
}
// update last-child if it changes
dbesc($parent_uri)
);
if($r && count($r))
- continue;
+ continue;
}
if(($datarray['verb'] === ACTIVITY_TAG) && ($datarray['object-type'] === ACTIVITY_OBJ_TAGTERM)) {
dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . $newtag),
intval($r[0]['id'])
);
+ create_tags_from_item($r[0]['id']);
}
}
}
dbesc($item_id),
intval($importer['uid'])
);
+ create_tags_from_itemuri($item_id, $importer['uid']);
}
// update last-child if it changes
if($elems['name'][0]['attribs'][NAMESPACE_DFRN]['updated']) {
$name_updated = $elems['name'][0]['attribs'][NAMESPACE_DFRN]['updated'];
$new_name = $elems['name'][0]['data'];
- }
+ }
if((x($elems,'link')) && ($elems['link'][0]['attribs']['']['rel'] === 'photo') && ($elems['link'][0]['attribs'][NAMESPACE_DFRN]['updated'])) {
$photo_timestamp = datetime_convert('UTC','UTC',$elems['link'][0]['attribs'][NAMESPACE_DFRN]['updated']);
$photo_url = $elems['link'][0]['attribs']['']['href'];
intval($importer['importer_uid'])
);
}
-
+
$img->scaleImageSquare(175);
-
+
$hash = $resource_id;
$r = $img->store($importer['importer_uid'], $importer['id'], $hash, basename($photo_url), 'Contact Photos', 4);
-
+
$img->scaleImage(80);
$r = $img->store($importer['importer_uid'], $importer['id'], $hash, basename($photo_url), 'Contact Photos', 5);
$a = get_app();
- q("UPDATE `contact` SET `avatar-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s'
+ q("UPDATE `contact` SET `avatar-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s'
WHERE `uid` = %d AND `id` = %d LIMIT 1",
dbesc(datetime_convert()),
dbesc($a->get_baseurl() . '/photo/' . $hash . '-4.'.$img->getExt()),
/** relocated user must have original key pair */
/*$newloc['pubkey'] = notags(unxmlify($base['pubkey'][0]['data']));
$newloc['prvkey'] = notags(unxmlify($base['prvkey'][0]['data']));*/
-
+
logger("items:relocate contact ".print_r($newloc, true).print_r($importer, true), LOGGER_DEBUG);
-
+
// update contact
$r = q("SELECT photo, url FROM contact WHERE id=%d AND uid=%d;",
intval($importer['id']),
intval($importer['importer_uid']));
- if ($r === false)
+ if ($r === false)
return 1;
$old = $r[0];
-
+
$x = q("UPDATE contact SET
name = '%s',
photo = '%s',
if ($x === false)
return 1;
}
-
+
// TODO
// merge with current record, current contents have priority
// update record, set url-updated
$hash = random_string();
-
+
$r = q("INSERT INTO `intro` ( `uid`, `fid`, `contact-id`, `note`, `hash`, `datetime`, `blocked` )
VALUES( %d, %d, %d, '%s', '%s', '%s', %d )",
intval($fsugg['uid']),
$msg['uri'] = notags(unxmlify($base['id'][0]['data']));
$msg['parent-uri'] = notags(unxmlify($base['in-reply-to'][0]['data']));
$msg['created'] = datetime_convert(notags(unxmlify('UTC','UTC',$base['sentdate'][0]['data'])));
-
+
dbesc_array($msg);
$r = dbq("INSERT INTO `mail` (`" . implode("`, `", array_keys($msg))
'verb' => ACTIVITY_POST,
'otype' => 'mail'
);
-
+
notification($notif_params);
return 0;
// NOTREACHED
- }
+ }
$community_page = 0;
$rawtags = $feed->get_feed_tags( NAMESPACE_DFRN, 'community');
);
$importer['forum'] = (string) $community_page;
}
-
+
logger('local_delivery: feed item count = ' . $feed->get_item_quantity());
// process any deleted entries
if(count($i)) {
// For tags, the owner cannot remove the tag on the author's copy of the post.
-
+
$owner_remove = (($item['contact-id'] == $i[0]['contact-id']) ? true: false);
$author_remove = (($item['origin'] && $item['self']) ? true : false);
- $author_copy = (($item['origin']) ? true : false);
+ $author_copy = (($item['origin']) ? true : false);
if($owner_remove && $author_copy)
continue;
- if($author_remove || $owner_remove) {
+ if($author_remove || $owner_remove) {
$tags = explode(',',$i[0]['tag']);
$newtags = array();
if(count($tags)) {
dbesc(implode(',',$newtags)),
intval($i[0]['id'])
);
+ create_tags_from_item($i[0]['id']);
}
}
}
dbesc($item['uri']),
intval($importer['importer_uid'])
);
+ create_tags_from_itemuri($item['uri'], $importer['importer_uid']);
}
else {
$r = q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s',
dbesc($uri),
intval($importer['importer_uid'])
);
+ create_tags_from_itemuri($uri, $importer['importer_uid']);
if($item['last-child']) {
// ensure that last-child is set in case the comment that had it just got wiped.
q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `parent-uri` = '%s' AND `uid` = %d ",
dbesc($item['parent-uri']),
intval($item['uid'])
);
- // who is the last child now?
+ // who is the last child now?
$r = q("SELECT `id` FROM `item` WHERE `parent-uri` = '%s' AND `type` != 'activity' AND `deleted` = 0 AND `uid` = %d
ORDER BY `created` DESC LIMIT 1",
dbesc($item['parent-uri']),
q("UPDATE `item` SET `last-child` = 1 WHERE `id` = %d LIMIT 1",
intval($r[0]['id'])
);
- }
+ }
}
// if this is a relayed delete, propagate it to other recipients
if(count($r)) {
$iid = $r[0]['id'];
if((x($datarray,'edited') !== false) && (datetime_convert('UTC','UTC',$datarray['edited']) !== $r[0]['edited'])) {
-
+
// do not accept (ignore) an earlier edit than one we currently have.
if(datetime_convert('UTC','UTC',$datarray['edited']) < $r[0]['edited'])
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",
dbesc($datarray['title']),
dbesc($item_id),
intval($importer['importer_uid'])
);
+ create_tags_from_itemuri($item_id, $importer['importer_uid']);
proc_run('php',"include/notifier.php","comment-import",$iid);
dbesc($datarray['verb']),
dbesc($datarray['parent-uri']),
dbesc($datarray['parent-uri'])
-
+
);
if($r && count($r))
- continue;
+ continue;
}
if(($datarray['verb'] === ACTIVITY_TAG) && ($datarray['object-type'] === ACTIVITY_OBJ_TAGTERM)) {
-
+
$xo = parse_xml_string($datarray['object'],false);
$xt = parse_xml_string($datarray['target'],false);
intval($importer['importer_uid'])
);
if(! count($tagp))
- continue;
+ continue;
- // extract tag, if not duplicate, and this user allows tags, add to parent item
+ // extract tag, if not duplicate, and this user allows tags, add to parent item
if($xo->id && $xo->content) {
$newtag = '#[url=' . $xo->id . ']'. $xo->content . '[/url]';
intval($tagp[0]['id']),
dbesc(datetime_convert())
);
+ create_tags_from_item($tagp[0]['id']);
}
}
- }
+ }
}
}
$parent = $r[0]['parent'];
$parent_uri = $r[0]['parent-uri'];
}
-
+
if(! $is_like) {
$r1 = q("UPDATE `item` SET `last-child` = 0, `changed` = '%s' WHERE `uid` = %d AND `parent` = %d",
dbesc(datetime_convert()),
if($posted_id && $parent) {
proc_run('php',"include/notifier.php","comment-import","$posted_id");
-
+
if((! $is_like) && (! $importer['self'])) {
require_once('include/enotify.php');
dbesc($item_id),
intval($importer['importer_uid'])
);
+ create_tags_from_itemuri($item_id, $importer['importer_uid']);
}
// update last-child if it changes
dbesc($parent_uri)
);
if($r && count($r))
- continue;
+ continue;
}
intval($importer['importer_uid'])
);
if(! count($r))
- continue;
+ continue;
- // extract tag, if not duplicate, add to parent item
+ // 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",
dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . '#[url=' . $xo->id . ']'. $xo->content . '[/url]'),
intval($r[0]['id'])
);
+ create_tags_from_item($r[0]['id']);
}
- }
+ }
}
}
$posted_id = item_store($datarray);
// find out if our user is involved in this conversation and wants to be notified.
-
+
if(!x($datarray['type']) || $datarray['type'] != 'activity') {
$myconv = q("SELECT `author-link`, `author-avatar`, `parent` FROM `item` WHERE `parent-uri` = '%s' AND `uid` = %d AND `parent` != 0 AND `deleted` = 0",
// first make sure this isn't our own post coming back to us from a wall-to-wall event
if(! link_compare($datarray['author-link'],$importer_url)) {
-
+
foreach($myconv as $conv) {
// now if we find a match, it means we're in this conversation
-
+
if(! link_compare($conv['author-link'],$importer_url))
continue;
dbesc($item_id),
intval($importer['importer_uid'])
);
+ create_tags_from_itemuri($item_id, $importer['importer_uid']);
}
// update last-child if it changes
// send email notification to owner?
}
else {
-
+
// create contact record
$r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `name`, `nick`, `photo`, `network`, `rel`,
if(count($r))
$contact_record = $r[0];
- // create notification
+ // create notification
$hash = random_string();
if(is_array($contact_record)) {
'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME'] . "\n"
. 'Content-type: text/plain; charset=UTF-8' . "\n"
. 'Content-transfer-encoding: 8bit' );
-
+
}
}
}
post_url($url,$params);
logger('subscribe_to_hub: returns: ' . $a->get_curl_code(), LOGGER_DEBUG);
-
+
return;
}
$expire_items = get_pconfig($uid, 'expire','items');
$expire_items = (($expire_items===false)?1:intval($expire_items)); // default if not set: 1
-
+
$expire_notes = get_pconfig($uid, 'expire','notes');
$expire_notes = (($expire_notes===false)?1:intval($expire_notes)); // default if not set: 1
$expire_starred = get_pconfig($uid, 'expire','starred');
$expire_starred = (($expire_starred===false)?1:intval($expire_starred)); // default if not set: 1
-
+
$expire_photos = get_pconfig($uid, 'expire','photos');
$expire_photos = (($expire_photos===false)?0:intval($expire_photos)); // default if not set: 0
-
+
logger('expire: # items=' . count($r). "; expire items: $expire_items, expire notes: $expire_notes, expire starred: $expire_starred, expire photos: $expire_photos");
foreach($r as $item) {
dbesc(datetime_convert()),
intval($item['id'])
);
+ create_tags_from_item($item['id']);
// clean up categories and tags so they don't end up as orphans
dbesc($item['parent-uri']),
intval($item['uid'])
);
+ create_tags_from_item($item['parent-uri'], $item['uid']);
// ignore the result
}
else {
dbesc($item['parent-uri']),
intval($item['uid'])
);
- // who is the last child now?
+ // who is the last child now?
$r = q("SELECT `id` FROM `item` WHERE `parent-uri` = '%s' AND `type` != 'activity' AND `deleted` = 0 AND `uid` = %d ORDER BY `edited` DESC LIMIT 1",
dbesc($item['parent-uri']),
intval($item['uid'])
goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
//NOTREACHED
}
-
+
}
if(! function_exists('fetch_url')) {
function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0, $accept_content=Null) {
+ $stamp1 = microtime(true);
+
$a = get_app();
$ch = @curl_init($url);
- if(($redirects > 8) || (! $ch))
+ if(($redirects > 8) || (! $ch))
return false;
@curl_setopt($ch, CURLOPT_HEADER, true);
}
if($http_code == 301 || $http_code == 302 || $http_code == 303 || $http_code == 307) {
- $matches = array();
- preg_match('/(Location:|URI:)(.*?)\n/', $header, $matches);
- $newurl = trim(array_pop($matches));
+ $new_location_info = @parse_url($curl_info["redirect_url"]);
+ $old_location_info = @parse_url($curl_info["url"]);
+
+ $newurl = $curl_info["redirect_url"];
+
+ if (($new_location_info["path"] == "") AND ($new_location_info["host"] != ""))
+ $newurl = $new_location_info["scheme"]."://".$new_location_info["host"].$old_location_info["path"];
+
+ //$matches = array();
+ //preg_match('/(Location:|URI:)(.*?)\n/', $header, $matches);
+ //$newurl = trim(array_pop($matches));
if(strpos($newurl,'/') === 0)
$newurl = $url . $newurl;
$url_parsed = @parse_url($newurl);
$body = substr($s,strlen($header));
$a->set_curl_headers($header);
@curl_close($ch);
+
+ $a->save_timestamp($stamp1, "network");
+
return($body);
}}
if(! function_exists('post_url')) {
function post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0) {
+
+ $stamp1 = microtime(true);
+
$a = get_app();
$ch = curl_init($url);
if(($redirects > 8) || (! $ch))
$a->set_curl_headers($header);
curl_close($ch);
+
+ $a->save_timestamp($stamp1, "network");
+
return($body);
}}
if($link['@attributes']['rel'] === NAMESPACE_DFRN)
$profile_link = $link['@attributes']['href'];
if($link['@attributes']['rel'] === NAMESPACE_OSTATUSSUB)
- $profile_link = 'stat:' . $link['@attributes']['template'];
+ $profile_link = 'stat:' . $link['@attributes']['template'];
if($link['@attributes']['rel'] === 'http://microformats.org/profile/hcard')
- $hcard = $link['@attributes']['href'];
+ $hcard = $link['@attributes']['href'];
}
}
return $profile_link;
logger('lrdd: constructed url: ' . $url);
$xml = fetch_url($url);
+
$headers = $a->get_curl_headers();
if (! $xml)
elseif(x($link['@attributes'],'href'))
$href = $link['@attributes']['href'];
}
- }
+ }
}
if((! isset($tpl)) || (! strpos($tpl,'{uri}')))
$lines = explode("\n",$headers);
if(count($lines)) {
- foreach($lines as $line) {
+ foreach($lines as $line) {
if((stristr($line,'link:')) && preg_match('/<([^>].*)>.*rel\=[\'\"]lrdd[\'\"]/',$line,$matches)) {
return(fetch_xrd_links($matches[1]));
break;
$lines = explode("\n",$headers);
if(count($lines)) {
- foreach($lines as $line) {
+ foreach($lines as $line) {
// TODO alter the following regex to support multiple relations (space separated)
if((stristr($line,'link:')) && preg_match('/<([^>].*)>.*rel\=[\'\"]lrdd[\'\"]/',$line,$matches)) {
$pagelink = $matches[1];
if(! function_exists('validate_url')) {
function validate_url(&$url) {
-
+
// no naked subdomains (allow localhost for tests)
if(strpos($url,'.') === false && strpos($url,'/localhost/') === false)
return false;
if(substr($url,0,4) != 'http')
$url = 'http://' . $url;
$h = @parse_url($url);
-
+
if(($h) && (dns_get_record($h['host'], DNS_A + DNS_CNAME + DNS_PTR) || filter_var($h['host'], FILTER_VALIDATE_IP) )) {
return true;
}
$i = fetch_url($scaled);
$cachefile = get_cachefile(hash("md5", $scaled));
- if ($cachefile != '')
+ if ($cachefile != '') {
+ $stamp1 = microtime(true);
file_put_contents($cachefile, $i);
+ $a->save_timestamp($stamp1, "file");
+ }
// guess mimetype from headers or filename
$type = guess_image_type($mtch[1],true);
* Return: The parsed XML in an array form. Use print_r() to see the resulting array structure.
* Examples: $array = xml2array(file_get_contents('feed.xml'));
* $array = xml2array(file_get_contents('feed.xml', true, 1, 'attribute'));
- */
+ */
function xml2array($contents, $namespaces = true, $get_attributes=1, $priority = 'attribute') {
if(!$contents) return array();
$result = array();
$attributes_data = array();
-
+
if(isset($value)) {
if($priority == 'tag') $result = $value;
else $result['value'] = $value; // Put the value in a assoc array if we are in the 'Attribute' mode
// See tag status and do the needed.
if($namespaces && strpos($tag,':')) {
- $namespc = substr($tag,0,strrpos($tag,':'));
+ $namespc = substr($tag,0,strrpos($tag,':'));
$tag = strtolower(substr($tag,strlen($namespc)+1));
$result['@namespace'] = $namespc;
}
} else { // This section will make the value an array if multiple tags with the same name appear together
$current[$tag] = array($current[$tag],$result); // This will combine the existing item and the new item together to make an array
$repeated_tag_index[$tag.'_'.$level] = 2;
-
+
if(isset($current[$tag.'_attr'])) { // The attribute of the last(0th) tag must be moved as well
$current[$tag]['0_attr'] = $current[$tag.'_attr'];
unset($current[$tag.'_attr']);
// ...push the new element into that array.
$current[$tag][$repeated_tag_index[$tag.'_'.$level]] = $result;
-
+
if($priority == 'tag' and $get_attributes and $attributes_data) {
$current[$tag][$repeated_tag_index[$tag.'_'.$level] . '_attr'] = $attributes_data;
}
$repeated_tag_index[$tag.'_'.$level] = 1;
if($priority == 'tag' and $get_attributes) {
if(isset($current[$tag.'_attr'])) { // The attribute of the last(0th) tag must be moved as well
-
+
$current[$tag]['0_attr'] = $current[$tag.'_attr'];
unset($current[$tag.'_attr']);
}
-
+
if($attributes_data) {
$current[$tag][$repeated_tag_index[$tag.'_'.$level] . '_attr'] = $attributes_data;
}
$current = &$parent[$level-1];
}
}
-
+
return($xml_array);
-}
+}
--- /dev/null
+<?php
+define('OSTATUS_DEFAULT_POLL_INTERVAL', 30); // given in minutes
+
+function check_conversations() {
+ $last = get_config('system','ostatus_last_poll');
+
+ $poll_interval = intval(get_config('system','ostatus_poll_interval'));
+ if(! $poll_interval)
+ $poll_interval = OSTATUS_DEFAULT_POLL_INTERVAL;
+
+ if($last) {
+ $next = $last + ($poll_interval * 60);
+ if($next > time()) {
+ logger('complete_conversation: poll intervall not reached');
+ return;
+ }
+ }
+
+ logger('complete_conversation: cron_start');
+
+ $start = date("Y-m-d H:i:s", time() - 86400);
+ $conversations = q("SELECT * FROM `term` WHERE `type` = 7 AND `term` > '%s'",
+ dbesc($start));
+ foreach ($conversations AS $conversation) {
+ $id = $conversation['oid'];
+ $url = $conversation['url'];
+ complete_conversation($id, $url);
+ }
+
+ logger('complete_conversation: cron_end');
+
+ set_config('system','ostatus_last_poll', time());
+}
+
+function complete_conversation($itemid, $conversation_url, $only_add_conversation = false) {
+ global $a;
+
+ //logger('complete_conversation: completing conversation url '.$conversation_url.' for id '.$itemid);
+
+ $messages = q("SELECT `uid`, `parent` FROM `item` WHERE `id` = %d LIMIT 1", intval($itemid));
+ if (!$messages)
+ return;
+ $message = $messages[0];
+
+ // Store conversation url if not done before
+ $conversation = q("SELECT `url` FROM `term` WHERE `uid` = %d AND `oid` = %d AND `otype` = %d AND `type` = %d",
+ intval($message["uid"]), intval($itemid), intval(TERM_OBJ_POST), intval(TERM_CONVERSATION));
+
+ if (!$conversation) {
+ $r = q("INSERT INTO `term` (`uid`, `oid`, `otype`, `type`, `term`, `url`) VALUES (%d, %d, %d, %d, '%s', '%s')",
+ intval($message["uid"]), intval($itemid), intval(TERM_OBJ_POST), intval(TERM_CONVERSATION), dbesc(datetime_convert()), dbesc($conversation_url));
+ logger('complete_conversation: Storing conversation url '.$conversation_url.' for id '.$itemid);
+ }
+
+ if ($only_add_conversation)
+ return;
+
+ // Get the parent
+ $parents = q("SELECT `id`, `uri`, `contact-id`, `type`, `verb`, `visible` FROM `item` WHERE `uid` = %d AND `id` = %d LIMIT 1",
+ intval($message["uid"]), intval($message["parent"]));
+ if (!$parents)
+ return;
+ $parent = $parents[0];
+
+ require_once('include/html2bbcode.php');
+ require_once('include/items.php');
+
+ $conv = str_replace("/conversation/", "/api/statusnet/conversation/", $conversation_url).".as";
+
+ logger('complete_conversation: fetching conversation url '.$conv.' for '.$itemid);
+ $conv_as = fetch_url($conv);
+
+ if ($conv_as) {
+ $conv_as = str_replace(',"statusnet:notice_info":', ',"statusnet_notice_info":', $conv_as);
+ $conv_as = json_decode($conv_as);
+
+ $first_id = "";
+ $items = array_reverse($conv_as->items);
+
+ foreach ($items as $single_conv) {
+ if ($first_id == "") {
+ $first_id = $single_conv->id;
+
+ $new_parents = q("SELECT `id`, `uri`, `contact-id`, `type`, `verb`, `visible` FROM `item` WHERE `uid` = %d AND `uri` = '%s' LIMIT 1",
+ intval($message["uid"]), dbesc($first_id));
+ if ($new_parents) {
+ $parent = $new_parents[0];
+ logger('complete_conversation: adopting new parent '.$parent["id"].' for '.$itemid);
+ } else {
+ $parent["id"] = 0;
+ $parent["uri"] = $first_id;
+ }
+ }
+
+ if (isset($single_conv->context->inReplyTo->id))
+ $parent_uri = $single_conv->context->inReplyTo->id;
+ else
+ $parent_uri = $parent["uri"];
+
+ if ($parent["id"] != 0) {
+ $message_exists = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s' LIMIT 1",
+ intval($message["uid"]), dbesc($single_conv->id));
+ if ($message_exists) {
+ $existing_message = $message_exists[0];
+ $r = q("UPDATE `item` SET `parent` = %d, `parent-uri` = '%s', `thr-parent` = '%s' WHERE `id` = %d LIMIT 1",
+ intval($parent["id"]),
+ dbesc($parent["uri"]),
+ dbesc($parent_uri),
+ intval($existing_message["id"]));
+ continue;
+ }
+ }
+
+ $arr = array();
+ $arr["uri"] = $single_conv->id;
+ $arr["plink"] = $single_conv->id;
+ $arr["uid"] = $message["uid"];
+ $arr["contact-id"] = $parent["contact-id"]; // To-Do
+ if ($parent["id"] != 0)
+ $arr["parent"] = $parent["id"];
+ $arr["parent-uri"] = $parent["uri"];
+ $arr["thr-parent"] = $parent_uri;
+ $arr["created"] = $single_conv->published;
+ $arr["edited"] = $single_conv->published;
+ //$arr["owner-name"] = $single_conv->actor->contact->displayName;
+ $arr["owner-name"] = $single_conv->actor->contact->preferredUsername;
+ $arr["owner-link"] = $single_conv->actor->id;
+ $arr["owner-avatar"] = $single_conv->actor->image->url;
+ //$arr["author-name"] = $single_conv->actor->contact->displayName;
+ $arr["author-name"] = $single_conv->actor->contact->preferredUsername;
+ $arr["author-link"] = $single_conv->actor->id;
+ $arr["author-avatar"] = $single_conv->actor->image->url;
+ $arr["body"] = html2bbcode($single_conv->content);
+ $arr["app"] = strip_tags($single_conv->statusnet_notice_info->source);
+ if ($arr["app"] == "")
+ $arr["app"] = $single_conv->provider->displayName;
+ $arr["verb"] = $parent["verb"];
+ $arr["visible"] = $parent["visible"];
+ $arr["location"] = $single_conv->location->displayName;
+ $arr["coord"] = trim($single_conv->location->lat." ".$single_conv->location->lon);
+
+ if ($arr["location"] == "")
+ unset($arr["location"]);
+
+ if ($arr["coord"] == "")
+ unset($arr["coord"]);
+
+ $newitem = item_store($arr);
+
+ // Add the conversation entry (but don't fetch the whole conversation)
+ complete_conversation($newitem, $conversation_url, true);
+
+ // If the newly created item is the top item then change the parent settings of the thread
+ if ($newitem AND ($arr["uri"] == $first_id)) {
+ logger('complete_conversation: setting new parent to id '.$newitem);
+ $new_parents = q("SELECT `id`, `uri`, `contact-id`, `type`, `verb`, `visible` FROM `item` WHERE `uid` = %d AND `id` = %d LIMIT 1",
+ intval($message["uid"]), intval($newitem));
+ if ($new_parents) {
+ $parent = $new_parents[0];
+ logger('complete_conversation: done changing parents to parent '.$newitem);
+ }
+
+ /*logger('complete_conversation: changing parents to parent '.$newitem.' old parent: '.$parent["id"].' new uri: '.$arr["uri"]);
+ $r = q("UPDATE `item` SET `parent` = %d, `parent-uri` = '%s' WHERE `parent` = %d",
+ intval($newitem),
+ dbesc($arr["uri"]),
+ intval($parent["id"]));
+ logger('complete_conversation: done changing parents to parent '.$newitem.' '.print_r($r, true));*/
+ }
+ }
+ }
+}
+?>
q("DELETE FROM `addon` WHERE `name` = '%s' ",
dbesc($plugin)
);
-
+
@include_once('addon/' . $plugin . '/' . $plugin . '.php');
if(function_exists($plugin . '_uninstall')) {
$func = $plugin . '_uninstall';
if(function_exists($plugin . '_install')) {
$func = $plugin . '_install';
$func();
-
+
$plugin_admin = (function_exists($plugin."_plugin_admin")?1:0);
-
+
$r = q("INSERT INTO `addon` (`name`, `installed`, `timestamp`, `plugin_admin`) VALUES ( '%s', 1, %d , %d ) ",
dbesc($plugin),
intval($t),
if(! function_exists('call_hooks')) {
function call_hooks($name, &$data = null) {
+ $stamp1 = microtime(true);
+
$a = get_app();
if((is_array($a->hooks)) && (array_key_exists($name,$a->hooks))) {
}
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' limit 1",
dbesc($name),
dbesc($hook[0]),
dbesc($hook[1])
}
}
}
-
}}
if (! function_exists('get_plugin_info')){
function get_plugin_info($plugin){
+
+ $a = get_app();
+
$info=Array(
'name' => $plugin,
'description' => "",
'author' => array(),
'version' => ""
);
-
+
if (!is_file("addon/$plugin/$plugin.php")) return $info;
-
+
+ $stamp1 = microtime(true);
$f = file_get_contents("addon/$plugin/$plugin.php");
+ $a->save_timestamp($stamp1, "file");
+
$r = preg_match("|/\*.*\*/|msU", $f, $m);
-
+
if ($r){
$ll = explode("\n", $m[0]);
foreach( $ll as $l ) {
$info[$k]=$v;
}
}
-
+
}
}
-
+
}
return $info;
}}
/*
* parse theme comment in search of theme infos.
* like
- *
+ *
* * Name: My Theme
* * Description: My Cool Theme
* * Version: 1.2.3
$info['unsupported'] = true;
if (!is_file("view/theme/$theme/theme.php")) return $info;
-
+
+ $a = get_app();
+ $stamp1 = microtime(true);
$f = file_get_contents("view/theme/$theme/theme.php");
+ $a->save_timestamp($stamp1, "file");
+
$r = preg_match("|/\*.*\*/|msU", $f, $m);
-
-
+
if ($r){
$ll = explode("\n", $m[0]);
foreach( $ll as $l ) {
if(is_null($a)) {
$a = new App;
}
-
+
if(is_null($db)) {
@include(".htconfig.php");
require_once("include/dba.php");
load_hooks();
logger('poller: start');
-
+
// run queue delivery process in the background
proc_run('php',"include/queue.php");
-
+
// run diaspora photo queue process in the background
proc_run('php',"include/dsprphotoq.php");
-
+
// expire any expired accounts
q("UPDATE user SET `account_expired` = 1 where `account_expired` = 0
AND `account_expires_on` != '0000-00-00 00:00:00'
AND `account_expires_on` < UTC_TIMESTAMP() ");
-
+
// delete user and contact records for recently removed accounts
$r = q("SELECT * FROM `user` WHERE `account_removed` = 1 AND `account_expires_on` < UTC_TIMESTAMP() - INTERVAL 3 DAY");
q("DELETE FROM `user` WHERE `uid` = %d", intval($user['uid']));
}
}
-
+
$abandon_days = intval(get_config('system','account_abandon_days'));
if($abandon_days < 1)
$abandon_days = 0;
-
+ // Check OStatus conversations
+ check_conversations();
// once daily run birthday_updates and then expire in background
--- /dev/null
+<?php
+/*
+require_once("boot.php");
+if(@is_null($a)) {
+ $a = new App;
+}
+
+if(is_null($db)) {
+ @include(".htconfig.php");
+ require_once("dba.php");
+ $db = new dba($db_host, $db_user, $db_pass, $db_data);
+ unset($db_host, $db_user, $db_pass, $db_data);
+};
+
+$a->set_baseurl("https://pirati.ca");
+*/
+
+function create_tags_from_item($itemid) {
+ global $a;
+
+ $profile_base = $a->get_baseurl();
+ $profile_data = parse_url($profile_base);
+ $profile_base_friendica = $profile_data['host'].$profile_data['path']."/profile/";
+ $profile_base_diaspora = $profile_data['host'].$profile_data['path']."/u/";
+
+ $searchpath = $a->get_baseurl()."/search?tag=";
+
+ $messages = q("SELECT `guid`, `uid`, `id`, `edited`, `deleted`, `title`, `body`, `tag` FROM `item` WHERE `id` = %d LIMIT 1", intval($itemid));
+
+ if (!$messages)
+ return;
+
+ $message = $messages[0];
+
+ // Clean up all tags
+ q("DELETE FROM `term` WHERE `otype` = %d AND `oid` = %d AND `type` IN (%d, %d)",
+ intval(TERM_OBJ_POST),
+ intval($itemid),
+ intval(TERM_HASHTAG),
+ intval(TERM_MENTION));
+
+ if ($message["deleted"])
+ return;
+
+ $cachefile = get_cachefile($message["guid"]."-".hash("md5", $message['body']));
+
+ if (($cachefile != '') AND !file_exists($cachefile)) {
+ $s = prepare_text($message['body']);
+ $stamp1 = microtime(true);
+ file_put_contents($cachefile, $s);
+ $a->save_timestamp($stamp1, "file");
+ logger('create_tags_from_item: put item '.$message["id"].' into cachefile '.$cachefile);
+ }
+
+ $taglist = explode(",", $message["tag"]);
+
+ $tags = "";
+ foreach ($taglist as $tag)
+ if ((substr(trim($tag), 0, 1) == "#") OR (substr(trim($tag), 0, 1) == "@"))
+ $tags .= " ".trim($tag);
+ else
+ $tags .= " #".trim($tag);
+
+ $data = " ".$message["title"]." ".$message["body"]." ".$tags." ";
+
+ $tags = array();
+
+ $pattern = "/\W\#([^\[].*?)[\s'\".,:;\?!\[\]\/]/ism";
+ if (preg_match_all($pattern, $data, $matches))
+ foreach ($matches[1] as $match)
+ $tags["#".strtolower($match)] = ""; // $searchpath.strtolower($match);
+
+ $pattern = "/\W([\#@])\[url\=(.*?)\](.*?)\[\/url\]/ism";
+ if (preg_match_all($pattern, $data, $matches, PREG_SET_ORDER)) {
+ foreach ($matches as $match)
+ $tags[$match[1].strtolower(trim($match[3], ',.:;[]/\"?!'))] = $match[2];
+ }
+
+ foreach ($tags as $tag=>$link) {
+
+ if (substr(trim($tag), 0, 1) == "#") {
+ $type = TERM_HASHTAG;
+ $term = substr($tag, 1);
+ } elseif (substr(trim($tag), 0, 1) == "@") {
+ $type = TERM_MENTION;
+ $term = substr($tag, 1);
+ } else { // This shouldn't happen
+ $type = TERM_HASHTAG;
+ $term = $tag;
+ }
+
+ $r = q("INSERT INTO `term` (`uid`, `oid`, `otype`, `type`, `term`, `url`) VALUES (%d, %d, %d, %d, '%s', '%s')",
+ intval($message["uid"]), intval($itemid), intval(TERM_OBJ_POST), intval($type), dbesc($term), dbesc($link));
+
+ // Search for mentions
+ if ((substr($tag, 0, 1) == '@') AND (strpos($link, $profile_base_friendica) OR strpos($link, $profile_base_diaspora))) {
+ $users = q("SELECT `uid` FROM `contact` WHERE self AND (`url` = '%s' OR `nurl` = '%s')", $link, $link);
+ foreach ($users AS $user) {
+ if ($user["uid"] == $message["uid"])
+ q("UPDATE `item` SET `mention` = 1 WHERE `id` = %d", intval($itemid));
+ }
+ }
+ }
+}
+
+function create_tags_from_itemuri($itemuri, $uid) {
+ $messages = q("SELECT `id` FROM `item` WHERE uri ='%s' AND uid=%d", dbesc($itemuri), intval($uid));
+
+ foreach ($messages as $message)
+ create_tags_from_item($message["id"]);
+}
+
+function update_items() {
+ //$messages = q("SELECT `id` FROM `item` where tag !='' ORDER BY `created` DESC limit 10");
+ $messages = q("SELECT `id` FROM `item` where tag !=''");
+
+ foreach ($messages as $message)
+ create_tags_from_item($message["id"]);
+}
+
+//print_r($tags);
+//print_r($hashtags);
+//print_r($mentions);
+//update_items();
+//create_tags_from_item(265194);
+//create_tags_from_itemuri("infoagent@diasp.org:cce94abd104c06e8", 2);
+?>
// returns substituted string.
// WARNING: this is pretty basic, and doesn't properly handle search strings that are substrings of each other.
// For instance if 'test' => "foo" and 'testing' => "bar", testing could become either bar or fooing,
-// depending on the order in which they were declared in the array.
+// depending on the order in which they were declared in the array.
require_once("include/template_processor.php");
require_once("include/friendica_smarty.php");
-if(! function_exists('replace_macros')) {
+if(! function_exists('replace_macros')) {
function replace_macros($s,$r) {
global $t;
-// $ts = microtime();
+ $stamp1 = microtime(true);
+
$a = get_app();
if($a->theme['template_engine'] === 'smarty3') {
}
else {
$r = $t->replace($s,$r);
-
+
$output = template_unescape($r);
}
-// $tt = microtime() - $ts;
-// $a = get_app();
-// $a->page['debug'] .= "$tt <br>\n";
+ $a = get_app();
+ $a->save_timestamp($stamp1, "rendering");
+
return $output;
}}
$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')) {
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') {
$template = new FriendicaSmarty();
$template->filename = $template_file;
+ $a->save_timestamp($stamp1, "rendering");
-// $tt = microtime() - $ts;
-// $a->page['debug'] .= "$tt <br>\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 <br>\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")) {
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;
}}
$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
$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']);
$lang = get_browser_language();
-
+
load_translation_table($lang);
/**
if(x($_SESSION,'submanage') && intval($_SESSION['submanage']))
return;
-
+
// urls
}
info(t('Theme settings updated.'));
if(is_ajax()) return;
-
+
goaway($a->get_baseurl(true) . '/admin/themes/' . $theme );
return;
break;
'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){
// 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");
* Page content
*/
$o = '';
-
// urls
if ($a->argc > 1){
switch ($a->argv[1]){
} else {
$o = admin_page_summary($a);
}
-
+
if(is_ajax()) {
echo $o;
killme();
foreach ($users as $user) {
$user_names[$user['nickname']] = $user['username'];
}
-
+
/* Banner */
$banner = get_config('system','banner');
if($banner == false)
$banner = '<a href="http://friendica.com"><img id="logo-img" src="images/friendica-32.png" alt="logo" /></a><span id="logo-text"><a href="http://friendica.com">Friendica</a></span>';
$banner = htmlspecialchars($banner);
-
+
//echo "<pre>"; var_dump($lang_choices); die("</pre>");
/* Register policy */
* @return string
*/
function admin_page_plugins(&$a){
-
+
/**
* Single plugin
*/
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);
} 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 = "<pre>". file_get_contents("addon/$plugin/README") ."</pre>";
- }
-
+ }
+
$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) {
}
}
}
-
+
$t = get_markup_template("admin_plugins.tpl");
return replace_macros($t, array(
'$title' => t('Administration'),
return $o;
}
-
+
/**
* Themes admin page
*
* @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();
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
} 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 = "<pre>". file_get_contents("view/theme/$theme/README") ."</pre>";
- }
-
+ }
+
$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(
'$toggle' => t('Toggle'),
'$settings' => t('Settings'),
'$baseurl' => $a->get_baseurl(true),
-
+
'$plugin' => $theme,
'$status' => $status,
'$action' => $action,
'$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'),
}
- $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);
$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))
);
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));
$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 ",
$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`
`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 ",
}
}
-
+
logger('parent dba_timer: ' . sprintf('%01.4f',$first - $start));
logger('child dba_timer: ' . sprintf('%01.4f',$second - $first));
$o = render_content($a,$items,$mode,false);
-
+
header('Content-type: application/json');
echo json_encode($o);
killme();
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) {
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);
}
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');
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
notice( t('Permission denied.') . EOL);
return;
}
-
+
$is_a_date_query = false;
if($a->argc > 1) {
}
}
}
-
+
// 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);
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');
if(x($_GET,'nets')) {
$network = $_GET['nets'];
}
-
+
return $network;
}
// item filter tabs
// TODO: fix this logic, reduce duplication
//$a->page['content'] .= '<div class="tabs-wrapper">';
-
+
list($no_active, $all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active) = network_query_get_sel_tab($a);
// if no tabs are selected, defaults to comments
if ($no_active=='active') $all_active='active';
//echo "<pre>"; 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(
// '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'),
-
+
$contact_id = $a->cid;
}
- // 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 " : '');
$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))
);
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)) {
$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))
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) {
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
`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 ",
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
}
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`
`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 ",
// 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.
intval($resolution)
);
if(count($r)) {
-
+
$sql_extra = permissions_sql($r[0]['uid']);
// Now we'll see if we can access the photo
}
}
- 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();
}
require_once('include/bbcode.php');
require_once('include/security.php');
require_once('include/redir.php');
-
+require_once('include/tags.php');
function photos_init(&$a) {
dbesc($rr['parent-uri']),
intval($page_owner_uid)
);
+ create_tags_from_itemuri($rr['parent-uri'], $page_owner_uid);
$drop_id = intval($rr['id']);
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']);
$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),
dbesc($resource_id),
intval($page_owner_uid)
);
- }
+ }
}
}
}
intval($item_id),
intval($page_owner_uid)
);
+ create_tags_from_item($item_id);
$best = 0;
foreach($p as $scales) {
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));
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']),
);
}
-
+
$tpl = get_markup_template("saved_searches_aside.tpl");
$o .= replace_macros($tpl, array(
'$searchbox' => '',
'$saved' => $saved,
));
- }
+ }
return $o;
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
$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
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));
}
}
- $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);
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`);
* _ false on failure
*/
public function get_template_data($alike, $dlike) {
+ global $a;
$result = array();
foreach($this->threads as $item) {
$result[] = $item_data;
}
+ //$a->mark_timestamp();
return $result;
}
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[] = "#<a href=\"".$tag["url"]."\" target=\"external-link\">".$tag["term"]."</a>";
+ $prefix = "#";
+ } elseif ($tag["type"] == TERM_MENTION) {
+ $mentions[] = "@<a href=\"".$tag["url"]."\" target=\"external-link\">".$tag["term"]."</a>";
+ $prefix = "@";
+ }
+ $tags[] = $prefix."<a href=\"".$tag["url"]."\" target=\"external-link\">".$tag["term"]."</a>";
+ }
+
+ /*foreach(explode(',',$item['tag']) as $tag){
$tag = trim($tag);
if ($tag!="") {
$t = bbcode($tag);
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']) : '');
* 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");
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);
'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(),
}
}
}
-
+
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' : '');
<?php
-define( 'UPDATE_VERSION' , 1159 );
+define( 'UPDATE_VERSION' , 1162 );
/**
*
if($r)
return UPDATE_SUCCESS;
-
- return UPDATE_FAILED;
}
function update_1158() {
return UPDATE_FAILED;
}
+function update_1159() {
+ $r = q("ALTER TABLE `term` ADD `aid` int(10) unsigned NOT NULL DEFAULT '0',
+ ADD `uid` int(10) unsigned NOT NULL DEFAULT '0',
+ ADD INDEX (`uid`),
+ ADD INDEX (`aid`)");
+
+ if(!$r)
+ return UPDATE_FAILED;
+
+ require_once('include/tags.php');
+ update_items();
+
+ return UPDATE_SUCCESS;
+}
+
+function update_1160() {
+ set_config('system', 'maintenance', 1);
+
+ // Wait for 15 seconds for current requests to
+ // clear before locking up the database
+ sleep(15);
+
+ $r = q("ALTER TABLE `item` ADD `mention` TINYINT(1) NOT NULL DEFAULT '0', ADD INDEX (`mention`)");
+ set_config('system', 'maintenance', 0);
+
+ if(!$r)
+ return UPDATE_FAILED;
+
+ return UPDATE_SUCCESS;
+}
+
+function update_1161() {
+ $r = q("ALTER TABLE `pconfig` ADD INDEX (`cat`)");
+
+ if(!$r)
+ return UPDATE_FAILED;
+
+ return UPDATE_SUCCESS;
+}
</ul>
</div>
{{ else }}
- <div class="profile-edit-side-div"><a class="profile-edit-side-link icon edit" title="$editprofile" href="profiles/$profid" ></a></div>
+ <div class="profile-edit-side-div"><a class="profile-edit-side-link icon edit" title="$editprofile" href="profiles" ></a></div>
{{ endif }}
</div>
max-width: 766px;
padding: 10px 10px 10px 10px;
background-color: white;
+ border-bottom: 1px solid lightgray;
+ border-right: 1px solid lightgray;
+ border-left: 1px solid lightgray;
}
/* wall item */
.tread-wrapper {
max-width: 660px;
word-wrap: break-word;
line-height: 1.36;
+ padding-bottom: 6px;
}
.wall-item-container .wall-item-content img {
.wall-item-tags {
padding-top: 1px;
padding-bottom: 2px;
+ /*display: none;*/
}
+
.tag {
color: rgb(153,153,153);
- padding-left: 3px;
- font-size: 10px;
+ /*padding-left: 3px;
+ font-size: 10px;*/
}
.tag a {
- padding-right: 8px;
+ /*padding-right: 8px;*/
color: rgb(153,153,153);
}
.wwto {
background: linear-gradient(top, #ffffff 0%,#ececf2 100%);*/
}
-#event-notice:hover, ul.tabs li .active, ul.tabs a:hover, #jot-preview-link:hover, .comment-edit-submit-wrapper .fakelink:hover {
+#event-notice:hover, #birthday-notice:hover, ul.tabs li .active, ul.tabs a:hover, #jot-preview-link:hover, .comment-edit-submit-wrapper .fakelink:hover {
color: black;
background-color: #e5e5e5;
text-decoration: none;