', $Text);
@@ -617,7 +650,8 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
// Clean up the HTML by loading and saving the HTML with the DOM
// Only do it when it has to be done - for performance reasons
- if (!$tryoembed) {
+ // Update: Now it is done every time - since bad structured html can break a whole page
+ //if (!$tryoembed) {
$doc = new DOMDocument();
$doc->preserveWhiteSpace = false;
@@ -632,10 +666,12 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
$Text = str_replace(' ','', $Text);
$Text = mb_convert_encoding($Text, "UTF-8", 'HTML-ENTITIES');
- }
+ //}
call_hooks('bbcode',$Text);
+ $a->save_timestamp($stamp1, "parser");
+
return $Text;
}
diff --git a/include/conversation.php b/include/conversation.php
index 5296011bb..36ac57f17 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -369,7 +369,6 @@ function visible_activity($item) {
if(!function_exists('conversation')) {
function conversation(&$a, $items, $mode, $update, $preview = false) {
-
require_once('include/bbcode.php');
$ssl_state = ((local_user()) ? true : false);
@@ -524,7 +523,26 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
$tags=array();
$hashtags = array();
$mentions = array();
- foreach(explode(',',$item['tag']) as $tag){
+
+ $taglist = q("SELECT `type`, `term`, `url` FROM `term` WHERE `otype` = %d AND `oid` = %d AND `type` IN (%d, %d) ORDER BY `tid`",
+ intval(TERM_OBJ_POST), intval($item['id']), intval(TERM_HASHTAG), intval(TERM_MENTION));
+
+ foreach($taglist as $tag) {
+
+ if ($tag["url"] == "")
+ $tag["url"] = $searchpath.strtolower($tag["term"]);
+
+ if ($tag["type"] == TERM_HASHTAG) {
+ $hashtags[] = "#".$tag["term"]."";
+ $prefix = "#";
+ } elseif ($tag["type"] == TERM_MENTION) {
+ $mentions[] = "@".$tag["term"]."";
+ $prefix = "@";
+ }
+ $tags[] = $prefix."".$tag["term"]."";
+ }
+
+ /*foreach(explode(',',$item['tag']) as $tag){
$tag = trim($tag);
if ($tag!="") {
$t = bbcode($tag);
@@ -534,7 +552,7 @@ function conversation(&$a, $items, $mode, $update, $preview = false) {
elseif($t[0] == '@')
$mentions[] = $t;
}
- }
+ }*/
$sp = false;
$profile_link = best_link_url($item,$sp);
diff --git a/include/dba.php b/include/dba.php
index ad33705bf..50354b7f4 100644
--- a/include/dba.php
+++ b/include/dba.php
@@ -23,6 +23,9 @@ class dba {
public $error = false;
function __construct($server,$user,$pass,$db,$install = false) {
+ global $a;
+
+ $stamp1 = microtime(true);
$server = trim($server);
$user = trim($user);
@@ -64,6 +67,8 @@ class dba {
if(! $install)
system_unavailable();
}
+
+ $a->save_timestamp($stamp1, "network");
}
public function getdb() {
@@ -78,18 +83,19 @@ class dba {
$this->error = '';
- if(x($a->config,'system') && x($a->config['system'],'db_log'))
- $stamp1 = microtime(true);
+ $stamp1 = microtime(true);
if($this->mysqli)
$result = @$this->db->query($sql);
else
$result = @mysql_query($sql,$this->db);
+ $stamp2 = microtime(true);
+ $duration = (float)($stamp2-$stamp1);
+
if(x($a->config,'system') && x($a->config['system'],'db_log')) {
- $stamp2 = microtime(true);
- $duration = round($stamp2-$stamp1, 3);
- if ($duration > $a->config["system"]["db_loglimit"]) {
+ if (($duration > $a->config["system"]["db_loglimit"])) {
+ $duration = round($duration, 3);
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
@file_put_contents($a->config["system"]["db_log"], $duration."\t".
basename($backtrace[1]["file"])."\t".
@@ -162,6 +168,7 @@ class dba {
}
}
+ $a->save_timestamp($stamp1, "database");
if($this->debug)
logger('dba: ' . printable(print_r($r, true)));
diff --git a/include/diaspora.php b/include/diaspora.php
index 18d37c243..5bf45e241 100755
--- a/include/diaspora.php
+++ b/include/diaspora.php
@@ -559,7 +559,7 @@ function diaspora_decode($importer,$xml) {
}
-
+
function diaspora_request($importer,$xml) {
$a = get_app();
@@ -569,7 +569,7 @@ function diaspora_request($importer,$xml) {
if(! $sender_handle || ! $recipient_handle)
return;
-
+
$contact = diaspora_get_contact_by_handle($importer['uid'],$sender_handle);
if($contact) {
@@ -754,6 +754,20 @@ function diaspora_request($importer,$xml) {
}
function diaspora_post_allow($importer,$contact) {
+
+ // perhaps we were already sharing with this person. Now they're sharing with us.
+ // That makes us friends.
+ // Normally this should have handled by getting a request - but this could get lost
+ if($contact['rel'] == CONTACT_IS_FOLLOWER && $importer['page-flags'] != PAGE_COMMUNITY) {
+ q("UPDATE `contact` SET `rel` = %d, `writable` = 1 WHERE `id` = %d AND `uid` = %d LIMIT 1",
+ intval(CONTACT_IS_FRIEND),
+ intval($contact['id']),
+ intval($importer['uid'])
+ );
+ $contact['rel'] = CONTACT_IS_FRIEND;
+ logger('diaspora_post_allow: defining user '.$contact["nick"].' as friend');
+ }
+
if(($contact['blocked']) || ($contact['readonly']) || ($contact['archive']))
return false;
if($contact['rel'] == CONTACT_IS_SHARING || $contact['rel'] == CONTACT_IS_FRIEND)
diff --git a/include/follow.php b/include/follow.php
index 59f3b1a5f..fc167bb82 100644
--- a/include/follow.php
+++ b/include/follow.php
@@ -48,9 +48,9 @@ function new_contact($uid,$url,$interactive = false) {
$myaddr = bin2hex($a->get_baseurl() . '/profile/' . $a->user['nickname']);
else
$myaddr = bin2hex($a->user['nickname'] . '@' . $a->get_hostname());
-
+
goaway($ret['request'] . "&addr=$myaddr");
-
+
// NOTREACHED
}
}
@@ -61,7 +61,7 @@ function new_contact($uid,$url,$interactive = false) {
return $result;
}
}
-
+
diff --git a/include/items.php b/include/items.php
index 255d580b6..b7be27932 100755
--- a/include/items.php
+++ b/include/items.php
@@ -5,7 +5,10 @@ require_once('include/oembed.php');
require_once('include/salmon.php');
require_once('include/crypto.php');
require_once('include/Photo.php');
+require_once('include/tags.php');
+require_once('include/text.php');
require_once('include/email.php');
+require_once('include/ostatus_conversation.php');
function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0) {
@@ -26,7 +29,7 @@ function get_feed_for(&$a, $dfrn_id, $owner_nick, $last_update, $direction = 0)
}
}
-
+
// default permissions - anonymous user
@@ -238,7 +241,7 @@ function construct_activity_object($item) {
$r->link = str_replace('&','&', $r->link);
$r->link = preg_replace('/\/','',$r->link);
$o .= $r->link;
- }
+ }
else
$o .= '' . "\r\n";
}
@@ -270,7 +273,7 @@ function construct_activity_target($item) {
$r->link = str_replace('&','&', $r->link);
$r->link = preg_replace('/\/','',$r->link);
$o .= $r->link;
- }
+ }
else
$o .= '' . "\r\n";
}
@@ -670,7 +673,7 @@ function get_atom_elements($feed,$item) {
}
// translate OStatus unfollow to activity streams if it happened to get selected
-
+
if((x($res,'verb')) && ($res['verb'] === 'http://ostatus.org/schema/1.0/unfollow'))
$res['verb'] = ACTIVITY_UNFOLLOW;
@@ -721,7 +724,7 @@ function get_atom_elements($feed,$item) {
if($child[NAMESPACE_ACTIVITY]['object-type'][0]['data']) {
$res['object-type'] = $child[NAMESPACE_ACTIVITY]['object-type'][0]['data'];
$res['object'] .= '' . $child[NAMESPACE_ACTIVITY]['object-type'][0]['data'] . '' . "\n";
- }
+ }
if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'id') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'])
$res['object'] .= '' . $child[SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'] . '' . "\n";
if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'link') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['link'])
@@ -759,7 +762,7 @@ function get_atom_elements($feed,$item) {
$child = $rawobj[0]['child'];
if($child[NAMESPACE_ACTIVITY]['object-type'][0]['data']) {
$res['target'] .= '' . $child[NAMESPACE_ACTIVITY]['object-type'][0]['data'] . '' . "\n";
- }
+ }
if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'id') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'])
$res['target'] .= '' . $child[SIMPLEPIE_NAMESPACE_ATOM_10]['id'][0]['data'] . '' . "\n";
if(x($child[SIMPLEPIE_NAMESPACE_ATOM_10], 'link') && $child[SIMPLEPIE_NAMESPACE_ATOM_10]['link'])
@@ -829,15 +832,30 @@ function get_atom_elements($feed,$item) {
}
}
+ // 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;
}
@@ -876,13 +894,22 @@ function item_store($arr,$force_parent = false) {
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'))
@@ -898,8 +925,23 @@ function item_store($arr,$force_parent = false) {
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);
@@ -952,9 +994,9 @@ function item_store($arr,$force_parent = false) {
$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",
@@ -1017,7 +1059,7 @@ function item_store($arr,$force_parent = false) {
logger('item_store: item parent was not found - ignoring item');
return 0;
}
-
+
$parent_deleted = 0;
}
}
@@ -1058,8 +1100,8 @@ function item_store($arr,$force_parent = false) {
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;
}
@@ -1072,7 +1114,7 @@ function item_store($arr,$force_parent = false) {
);
}
- 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))
@@ -1093,6 +1135,11 @@ function item_store($arr,$force_parent = false) {
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;
@@ -1136,6 +1183,18 @@ function item_store($arr,$force_parent = false) {
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;
}
@@ -1272,7 +1331,7 @@ function tag_deliver($uid,$item_id) {
intval($item_id)
);
- proc_run('php','include/notifier.php','tgroup',$item_id);
+ proc_run('php','include/notifier.php','tgroup',$item_id);
}
@@ -1343,7 +1402,7 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) {
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);
@@ -1361,7 +1420,7 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) {
break;
case SSL_POLICY_SELFSIGN:
$ssl_policy = 'self';
- break;
+ break;
case SSL_POLICY_NONE:
default:
$ssl_policy = 'none';
@@ -1414,7 +1473,7 @@ function dfrn_deliver($owner,$contact,$atom, $dissolve = false) {
intval(($perm == 'rw') ? 1 : 0),
intval($contact['id'])
);
- $contact['writable'] = (string) 1 - intval($contact['writable']);
+ $contact['writable'] = (string) 1 - intval($contact['writable']);
}
}
@@ -1558,7 +1617,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
logger('consume_feed: empty input');
return;
}
-
+
$feed = new SimplePie();
$feed->set_raw_data($xml);
if($datedir)
@@ -1594,7 +1653,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
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'];
@@ -1637,12 +1696,12 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
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);
@@ -1651,7 +1710,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
$a = get_app();
- q("UPDATE `contact` SET `avatar-date` = '%s', `photo` = '%s', `thumb` = '%s', `micro` = '%s'
+ 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()),
@@ -1701,7 +1760,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
* 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]' ) ;
@@ -1718,7 +1777,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
dbesc($bdtext2),
dbesc('birthday')
);
-
+
// update bdyear
@@ -1810,6 +1869,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
dbesc(implode(',',$newtags)),
intval($i[0]['id'])
);
+ create_tags_from_item($i[0]['id']);
}
}
}
@@ -1824,6 +1884,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
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',
@@ -1834,6 +1895,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
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 ",
@@ -1947,6 +2009,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
dbesc($item_id),
intval($importer['uid'])
);
+ create_tags_from_itemuri($item_id, $importer['uid']);
}
// update last-child if it changes
@@ -1988,7 +2051,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
dbesc($parent_uri)
);
if($r && count($r))
- continue;
+ continue;
}
if(($datarray['verb'] === ACTIVITY_TAG) && ($datarray['object-type'] === ACTIVITY_OBJ_TAGTERM)) {
@@ -2011,6 +2074,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . $newtag),
intval($r[0]['id'])
);
+ create_tags_from_item($r[0]['id']);
}
}
}
@@ -2094,6 +2158,7 @@ function consume_feed($xml,$importer,&$contact, &$hub, $datedir = 0, $pass = 0)
dbesc($item_id),
intval($importer['uid'])
);
+ create_tags_from_itemuri($item_id, $importer['uid']);
}
// update last-child if it changes
@@ -2231,7 +2296,7 @@ function local_delivery($importer,$data) {
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'];
@@ -2270,12 +2335,12 @@ function local_delivery($importer,$data) {
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);
@@ -2284,7 +2349,7 @@ function local_delivery($importer,$data) {
$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()),
@@ -2343,17 +2408,17 @@ function local_delivery($importer,$data) {
/** 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',
@@ -2396,7 +2461,7 @@ function local_delivery($importer,$data) {
if ($x === false)
return 1;
}
-
+
// TODO
// merge with current record, current contents have priority
// update record, set url-updated
@@ -2470,7 +2535,7 @@ function local_delivery($importer,$data) {
$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']),
@@ -2524,7 +2589,7 @@ function local_delivery($importer,$data) {
$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))
@@ -2548,12 +2613,12 @@ function local_delivery($importer,$data) {
'verb' => ACTIVITY_POST,
'otype' => 'mail'
);
-
+
notification($notif_params);
return 0;
// NOTREACHED
- }
+ }
$community_page = 0;
$rawtags = $feed->get_feed_tags( NAMESPACE_DFRN, 'community');
@@ -2567,7 +2632,7 @@ function local_delivery($importer,$data) {
);
$importer['forum'] = (string) $community_page;
}
-
+
logger('local_delivery: feed item count = ' . $feed->get_item_quantity());
// process any deleted entries
@@ -2677,14 +2742,14 @@ function local_delivery($importer,$data) {
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)) {
@@ -2696,6 +2761,7 @@ function local_delivery($importer,$data) {
dbesc(implode(',',$newtags)),
intval($i[0]['id'])
);
+ create_tags_from_item($i[0]['id']);
}
}
}
@@ -2710,6 +2776,7 @@ function local_delivery($importer,$data) {
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',
@@ -2720,6 +2787,7 @@ function local_delivery($importer,$data) {
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 ",
@@ -2727,7 +2795,7 @@ function local_delivery($importer,$data) {
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']),
@@ -2737,7 +2805,7 @@ function local_delivery($importer,$data) {
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
@@ -2831,11 +2899,11 @@ function local_delivery($importer,$data) {
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']),
@@ -2845,6 +2913,7 @@ function local_delivery($importer,$data) {
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);
@@ -2881,14 +2950,14 @@ function local_delivery($importer,$data) {
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);
@@ -2901,9 +2970,9 @@ function local_delivery($importer,$data) {
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]';
@@ -2917,9 +2986,10 @@ function local_delivery($importer,$data) {
intval($tagp[0]['id']),
dbesc(datetime_convert())
);
+ create_tags_from_item($tagp[0]['id']);
}
}
- }
+ }
}
}
@@ -2936,7 +3006,7 @@ function local_delivery($importer,$data) {
$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()),
@@ -2954,7 +3024,7 @@ function local_delivery($importer,$data) {
if($posted_id && $parent) {
proc_run('php',"include/notifier.php","comment-import","$posted_id");
-
+
if((! $is_like) && (! $importer['self'])) {
require_once('include/enotify.php');
@@ -3017,6 +3087,7 @@ function local_delivery($importer,$data) {
dbesc($item_id),
intval($importer['importer_uid'])
);
+ create_tags_from_itemuri($item_id, $importer['importer_uid']);
}
// update last-child if it changes
@@ -3053,7 +3124,7 @@ function local_delivery($importer,$data) {
dbesc($parent_uri)
);
if($r && count($r))
- continue;
+ continue;
}
@@ -3068,24 +3139,25 @@ function local_delivery($importer,$data) {
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",
@@ -3099,11 +3171,11 @@ function local_delivery($importer,$data) {
// 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;
@@ -3191,6 +3263,7 @@ function local_delivery($importer,$data) {
dbesc($item_id),
intval($importer['importer_uid'])
);
+ create_tags_from_itemuri($item_id, $importer['importer_uid']);
}
// update last-child if it changes
@@ -3314,7 +3387,7 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
// send email notification to owner?
}
else {
-
+
// create contact record
$r = q("INSERT INTO `contact` ( `uid`, `created`, `url`, `nurl`, `name`, `nick`, `photo`, `network`, `rel`,
@@ -3337,7 +3410,7 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
if(count($r))
$contact_record = $r[0];
- // create notification
+ // create notification
$hash = random_string();
if(is_array($contact_record)) {
@@ -3375,7 +3448,7 @@ function new_follower($importer,$contact,$datarray,$item,$sharing = false) {
'From: ' . 'Administrator' . '@' . $_SERVER['SERVER_NAME'] . "\n"
. 'Content-type: text/plain; charset=UTF-8' . "\n"
. 'Content-transfer-encoding: 8bit' );
-
+
}
}
}
@@ -3445,7 +3518,7 @@ function subscribe_to_hub($url,$importer,$contact,$hubmode = 'subscribe') {
post_url($url,$params);
logger('subscribe_to_hub: returns: ' . $a->get_curl_code(), LOGGER_DEBUG);
-
+
return;
}
@@ -3778,16 +3851,16 @@ function item_expire($uid,$days) {
$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) {
@@ -3910,6 +3983,7 @@ function drop_item($id,$interactive = true) {
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
@@ -3975,6 +4049,7 @@ function drop_item($id,$interactive = true) {
dbesc($item['parent-uri']),
intval($item['uid'])
);
+ create_tags_from_item($item['parent-uri'], $item['uid']);
// ignore the result
}
else {
@@ -3984,7 +4059,7 @@ function drop_item($id,$interactive = true) {
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'])
@@ -4016,7 +4091,7 @@ function drop_item($id,$interactive = true) {
goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
//NOTREACHED
}
-
+
}
diff --git a/include/network.php b/include/network.php
index 2a8dcc83a..941ef5e1b 100644
--- a/include/network.php
+++ b/include/network.php
@@ -7,10 +7,12 @@
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);
@@ -78,9 +80,17 @@ function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0, $accept_
}
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);
@@ -95,6 +105,9 @@ function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0, $accept_
$body = substr($s,strlen($header));
$a->set_curl_headers($header);
@curl_close($ch);
+
+ $a->save_timestamp($stamp1, "network");
+
return($body);
}}
@@ -102,6 +115,9 @@ function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0, $accept_
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))
@@ -184,6 +200,9 @@ function post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0)
$a->set_curl_headers($header);
curl_close($ch);
+
+ $a->save_timestamp($stamp1, "network");
+
return($body);
}}
@@ -293,9 +312,9 @@ function webfinger_dfrn($s,&$hcard) {
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;
@@ -361,6 +380,7 @@ function lrdd($uri, $debug = false) {
logger('lrdd: constructed url: ' . $url);
$xml = fetch_url($url);
+
$headers = $a->get_curl_headers();
if (! $xml)
@@ -410,7 +430,7 @@ function lrdd($uri, $debug = false) {
elseif(x($link['@attributes'],'href'))
$href = $link['@attributes']['href'];
}
- }
+ }
}
if((! isset($tpl)) || (! strpos($tpl,'{uri}')))
@@ -429,7 +449,7 @@ function lrdd($uri, $debug = false) {
$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;
@@ -475,7 +495,7 @@ function lrdd($uri, $debug = false) {
$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];
@@ -591,14 +611,14 @@ function fetch_xrd_links($url) {
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;
}
@@ -829,8 +849,11 @@ function scale_external_images($s, $include_link = true, $scale_replace = false)
$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);
@@ -920,7 +943,7 @@ function fix_contact_ssl_policy(&$contact,$new_policy) {
* 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();
@@ -978,7 +1001,7 @@ function xml2array($contents, $namespaces = true, $get_attributes=1, $priority =
$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
@@ -994,7 +1017,7 @@ function xml2array($contents, $namespaces = true, $get_attributes=1, $priority =
// 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;
}
@@ -1017,7 +1040,7 @@ function xml2array($contents, $namespaces = true, $get_attributes=1, $priority =
} 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']);
@@ -1040,7 +1063,7 @@ function xml2array($contents, $namespaces = true, $get_attributes=1, $priority =
// ...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;
}
@@ -1051,11 +1074,11 @@ function xml2array($contents, $namespaces = true, $get_attributes=1, $priority =
$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;
}
@@ -1068,6 +1091,6 @@ function xml2array($contents, $namespaces = true, $get_attributes=1, $priority =
$current = &$parent[$level-1];
}
}
-
+
return($xml_array);
-}
+}
diff --git a/include/ostatus_conversation.php b/include/ostatus_conversation.php
new file mode 100644
index 000000000..cdaf80d76
--- /dev/null
+++ b/include/ostatus_conversation.php
@@ -0,0 +1,173 @@
+ 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));*/
+ }
+ }
+ }
+}
+?>
diff --git a/include/plugin.php b/include/plugin.php
index ef0ddd05e..b89cb2c53 100644
--- a/include/plugin.php
+++ b/include/plugin.php
@@ -8,7 +8,7 @@ function uninstall_plugin($plugin){
q("DELETE FROM `addon` WHERE `name` = '%s' ",
dbesc($plugin)
);
-
+
@include_once('addon/' . $plugin . '/' . $plugin . '.php');
if(function_exists($plugin . '_uninstall')) {
$func = $plugin . '_uninstall';
@@ -28,9 +28,9 @@ function install_plugin($plugin) {
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),
@@ -158,6 +158,8 @@ function load_hooks() {
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))) {
@@ -173,7 +175,7 @@ function call_hooks($name, &$data = null) {
}
else {
// remove orphan hooks
- q("delete from hook where hook = '%s' and file = '$s' and function = '%s' limit 1",
+ q("delete from hook where hook = '%s' and file = '%s' and function = '%s' limit 1",
dbesc($name),
dbesc($hook[0]),
dbesc($hook[1])
@@ -181,7 +183,6 @@ function call_hooks($name, &$data = null) {
}
}
}
-
}}
@@ -199,18 +200,24 @@ function call_hooks($name, &$data = null) {
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 ) {
@@ -230,10 +237,10 @@ function get_plugin_info($plugin){
$info[$k]=$v;
}
}
-
+
}
}
-
+
}
return $info;
}}
@@ -242,7 +249,7 @@ function get_plugin_info($plugin){
/*
* parse theme comment in search of theme infos.
* like
- *
+ *
* * Name: My Theme
* * Description: My Cool Theme
* * Version: 1.2.3
@@ -270,11 +277,14 @@ function get_theme_info($theme){
$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 ) {
diff --git a/include/poller.php b/include/poller.php
index 692335aab..e85a4555d 100644
--- a/include/poller.php
+++ b/include/poller.php
@@ -9,7 +9,7 @@ function poller_run(&$argv, &$argc){
if(is_null($a)) {
$a = new App;
}
-
+
if(is_null($db)) {
@include(".htconfig.php");
require_once("include/dba.php");
@@ -57,21 +57,21 @@ function poller_run(&$argv, &$argc){
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");
@@ -81,12 +81,13 @@ function poller_run(&$argv, &$argc){
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
diff --git a/include/tags.php b/include/tags.php
new file mode 100644
index 000000000..c81a752d5
--- /dev/null
+++ b/include/tags.php
@@ -0,0 +1,127 @@
+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);
+?>
diff --git a/include/text.php b/include/text.php
index 6662ac802..97cf6ac20 100644
--- a/include/text.php
+++ b/include/text.php
@@ -6,16 +6,17 @@
// 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') {
@@ -34,12 +35,12 @@ function replace_macros($s,$r) {
}
else {
$r = $t->replace($s,$r);
-
+
$output = template_unescape($r);
}
-// $tt = microtime() - $ts;
-// $a = get_app();
-// $a->page['debug'] .= "$tt \n";
+ $a = get_app();
+ $a->save_timestamp($stamp1, "rendering");
+
return $output;
}}
@@ -438,15 +439,26 @@ function load_view_file($s) {
$lang = 'en';
$b = basename($s);
$d = dirname($s);
- if(file_exists("$d/$lang/$b"))
- return file_get_contents("$d/$lang/$b");
-
+ if(file_exists("$d/$lang/$b")) {
+ $stamp1 = microtime(true);
+ $content = file_get_contents("$d/$lang/$b");
+ $a->save_timestamp($stamp1, "file");
+ return $content;
+ }
+
$theme = current_theme();
- if(file_exists("$d/theme/$theme/$b"))
- return file_get_contents("$d/theme/$theme/$b");
-
- return file_get_contents($s);
+ if(file_exists("$d/theme/$theme/$b")) {
+ $stamp1 = microtime(true);
+ $content = file_get_contents("$d/theme/$theme/$b");
+ $a->save_timestamp($stamp1, "file");
+ return $content;
+ }
+
+ $stamp1 = microtime(true);
+ $content = file_get_contents($s);
+ $a->save_timestamp($stamp1, "file");
+ return $content;
}}
if(! function_exists('get_intltext_template')) {
@@ -461,17 +473,28 @@ function get_intltext_template($s) {
if(! isset($lang))
$lang = 'en';
- if(file_exists("view/$lang$engine/$s"))
- return file_get_contents("view/$lang$engine/$s");
- elseif(file_exists("view/en$engine/$s"))
- return file_get_contents("view/en$engine/$s");
- else
- return file_get_contents("view$engine/$s");
+ if(file_exists("view/$lang$engine/$s")) {
+ $stamp1 = microtime(true);
+ $content = file_get_contents("view/$lang$engine/$s");
+ $a->save_timestamp($stamp1, "file");
+ return $content;
+ } elseif(file_exists("view/en$engine/$s")) {
+ $stamp1 = microtime(true);
+ $content = file_get_contents("view/en$engine/$s");
+ $a->save_timestamp($stamp1, "file");
+ return $content;
+ } else {
+ $stamp1 = microtime(true);
+ $content = file_get_contents("view$engine/$s");
+ $a->save_timestamp($stamp1, "file");
+ return $content;
+ }
}}
if(! function_exists('get_markup_template')) {
function get_markup_template($s, $root = '') {
-// $ts = microtime();
+ $stamp1 = microtime(true);
+
$a = get_app();
if($a->theme['template_engine'] === 'smarty3') {
@@ -479,19 +502,20 @@ function get_markup_template($s, $root = '') {
$template = new FriendicaSmarty();
$template->filename = $template_file;
+ $a->save_timestamp($stamp1, "rendering");
-// $tt = microtime() - $ts;
-// $a->page['debug'] .= "$tt \n";
return $template;
}
else {
$template_file = get_template_file($a, $s, $root);
-// $file_contents = file_get_contents($template_file);
-// $tt = microtime() - $ts;
-// $a->page['debug'] .= "$tt \n";
-// return $file_contents;
- return file_get_contents($template_file);
- }
+ $a->save_timestamp($stamp1, "rendering");
+
+ $stamp1 = microtime(true);
+ $content = file_get_contents($template_file);
+ $a->save_timestamp($stamp1, "file");
+ return $content;
+
+ }
}}
if(! function_exists("get_template_file")) {
@@ -547,8 +571,10 @@ function logger($msg,$level = 0) {
if((! $debugging) || (! $logfile) || ($level > $loglevel))
return;
-
+
+ $stamp1 = microtime(true);
@file_put_contents($logfile, datetime_convert() . ':' . session_id() . ' ' . $msg . "\n", FILE_APPEND);
+ $a->save_timestamp($stamp1, "file");
return;
}}
@@ -574,11 +600,12 @@ function get_tags($s) {
$ret = array();
// ignore anything in a code block
-
$s = preg_replace('/\[code\](.*?)\[\/code\]/sm','',$s);
- // ignore anything in a bbtag
+ // Force line feeds at bbtags
+ $s = str_replace(array("[", "]"), array("\n[", "]\n"), $s);
+ // ignore anything in a bbtag
$s = preg_replace('/\[(.*?)\]/sm','',$s);
// Match full names against @tags including the space between first and last
@@ -1030,14 +1057,20 @@ function prepare_body($item,$attach = false) {
$a = get_app();
call_hooks('prepare_body_init', $item);
- $cachefile = get_cachefile($item["guid"]."-".strtotime($item["edited"])."-".hash("crc32", $item['body']));
+ //$cachefile = get_cachefile($item["guid"]."-".strtotime($item["edited"])."-".hash("crc32", $item['body']));
+ $cachefile = get_cachefile($item["guid"]."-".hash("md5", $item['body']));
if (($cachefile != '')) {
- if (file_exists($cachefile))
+ if (file_exists($cachefile)) {
+ $stamp1 = microtime(true);
$s = file_get_contents($cachefile);
- else {
+ $a->save_timestamp($stamp1, "file");
+ } else {
$s = prepare_text($item['body']);
+ $stamp1 = microtime(true);
file_put_contents($cachefile, $s);
+ $a->save_timestamp($stamp1, "file");
+ logger('prepare_body: put item '.$item["id"].' into cachefile '.$cachefile);
}
} else
$s = prepare_text($item['body']);
diff --git a/index.php b/index.php
index a1926d63a..3ccdc725f 100644
--- a/index.php
+++ b/index.php
@@ -33,7 +33,7 @@ $install = ((file_exists('.htconfig.php') && filesize('.htconfig.php')) ? false
$lang = get_browser_language();
-
+
load_translation_table($lang);
/**
diff --git a/mod/admin.php b/mod/admin.php
index 8a79fb108..98e52d28b 100644
--- a/mod/admin.php
+++ b/mod/admin.php
@@ -20,7 +20,7 @@ function admin_post(&$a){
if(x($_SESSION,'submanage') && intval($_SESSION['submanage']))
return;
-
+
// urls
@@ -54,7 +54,7 @@ function admin_post(&$a){
}
info(t('Theme settings updated.'));
if(is_ajax()) return;
-
+
goaway($a->get_baseurl(true) . '/admin/themes/' . $theme );
return;
break;
@@ -100,9 +100,9 @@ function admin_content(&$a) {
'dbsync' => Array($a->get_baseurl(true)."/admin/dbsync/", t('DB updates'), "dbsync"),
//'update' => Array($a->get_baseurl(true)."/admin/update/", t("Software Update") , "update")
);
-
+
/* get plugins admin page */
-
+
$r = q("SELECT * FROM `addon` WHERE `plugin_admin`=1");
$aside['plugins_admin']=Array();
foreach ($r as $h){
@@ -111,7 +111,7 @@ function admin_content(&$a) {
// temp plugins with admin
$a->plugins_admin[] = $plugin;
}
-
+
$aside['logs'] = Array($a->get_baseurl(true)."/admin/logs/", t("Logs"), "logs");
$t = get_markup_template("admin_aside.tpl");
@@ -130,7 +130,6 @@ function admin_content(&$a) {
* Page content
*/
$o = '';
-
// urls
if ($a->argc > 1){
switch ($a->argv[1]){
@@ -161,7 +160,7 @@ function admin_content(&$a) {
} else {
$o = admin_page_summary($a);
}
-
+
if(is_ajax()) {
echo $o;
killme();
@@ -274,12 +273,14 @@ function admin_page_site_post(&$a){
$diaspora_enabled = ((x($_POST,'diaspora_enabled')) ? True : False);
$ssl_policy = ((x($_POST,'ssl_policy')) ? intval($_POST['ssl_policy']) : 0);
$new_share = ((x($_POST,'new_share')) ? True : False);
+ $hide_help = ((x($_POST,'hide_help')) ? True : False);
$use_fulltext_engine = ((x($_POST,'use_fulltext_engine')) ? True : False);
$itemcache = ((x($_POST,'itemcache')) ? notags(trim($_POST['itemcache'])) : '');
$itemcache_duration = ((x($_POST,'itemcache_duration')) ? intval($_POST['itemcache_duration']) : 0);
$lockpath = ((x($_POST,'lockpath')) ? notags(trim($_POST['lockpath'])) : '');
$temppath = ((x($_POST,'temppath')) ? notags(trim($_POST['temppath'])) : '');
$basepath = ((x($_POST,'basepath')) ? notags(trim($_POST['basepath'])) : '');
+ $singleuser = ((x($_POST,'singleuser')) ? notags(trim($_POST['singleuser'])) : '');
if($ssl_policy != intval(get_config('system','ssl_policy'))) {
if($ssl_policy == SSL_POLICY_FULL) {
@@ -341,7 +342,12 @@ function admin_page_site_post(&$a){
del_config('system','mobile-theme');
} else {
set_config('system','mobile-theme', $theme_mobile);
- }
+ }
+ if ( $singleuser === '---' ) {
+ del_config('system','singleuser');
+ } else {
+ set_config('system','singleuser', $singleuser);
+ }
set_config('system','maximagesize', $maximagesize);
set_config('system','max_image_length', $maximagelength);
set_config('system','jpeg_quality', $jpegimagequality);
@@ -380,6 +386,7 @@ function admin_page_site_post(&$a){
set_config('system','diaspora_enabled', $diaspora_enabled);
set_config('system','new_share', $new_share);
+ set_config('system','hide_help', $hide_help);
set_config('system','use_fulltext_engine', $use_fulltext_engine);
set_config('system','itemcache', $itemcache);
set_config('system','itemcache_duration', $itemcache_duration);
@@ -426,19 +433,26 @@ function admin_page_site(&$a) {
if (file_exists($file . '/mobile')) {
$theme_choices_mobile[$f] = $theme_name;
}
- else {
+ else {
$theme_choices[$f] = $theme_name;
}
}
}
-
-
+
+ /* get user names to make the install a personal install of X */
+ $user_names = array();
+ $user_names['---'] = t('Multi user instance');
+ $users = q("SELECT username, nickname FROM `user`");
+ foreach ($users as $user) {
+ $user_names[$user['nickname']] = $user['username'];
+ }
+
/* Banner */
$banner = get_config('system','banner');
if($banner == false)
$banner = 'Friendica';
$banner = htmlspecialchars($banner);
-
+
//echo "
"; var_dump($lang_choices); die("
");
/* Register policy */
@@ -474,6 +488,8 @@ function admin_page_site(&$a) {
'$theme_mobile' => array('theme_mobile', t("Mobile system theme"), get_config('system','mobile-theme'), t("Theme for mobile devices"), $theme_choices_mobile),
'$ssl_policy' => array('ssl_policy', t("SSL link policy"), (string) intval(get_config('system','ssl_policy')), t("Determines whether generated links should be forced to use SSL"), $ssl_choices),
'$new_share' => array('new_share', t("'Share' element"), get_config('system','new_share'), t("Activates the bbcode element 'share' for repeating items.")),
+ '$hide_help' => array('hide_help', t("Hide help entry from navigation menu"), get_config('system','hide_help'), t("Hides the menu entry for the Help pages from the navigation menu. You can still access it calling /help directly.")),
+ '$singleuser' => array('singleuser', t("Single user instance"), get_config('system','singleuser'), t("Make this instance multi-user or single-user for the named user"), $user_names),
'$maximagesize' => array('maximagesize', t("Maximum image size"), get_config('system','maximagesize'), t("Maximum size in bytes of uploaded images. Default is 0, which means no limits.")),
'$maximagelength' => array('maximagelength', t("Maximum image length"), get_config('system','max_image_length'), t("Maximum length in pixels of the longest side of uploaded images. Default is -1, which means no limits.")),
'$jpegimagequality' => array('jpegimagequality', t("JPEG image quality"), get_config('system','jpeg_quality'), t("Uploaded JPEGS will be saved at this quality setting [0-100]. Default is 100, which is full quality.")),
@@ -763,7 +779,7 @@ function admin_page_users(&$a){
* @return string
*/
function admin_page_plugins(&$a){
-
+
/**
* Single plugin
*/
@@ -773,9 +789,9 @@ function admin_page_plugins(&$a){
notice( t("Item not found.") );
return '';
}
-
+
if (x($_GET,"a") && $_GET['a']=="t"){
- check_form_security_token_redirectOnErr('/admin/plugins', 'admin_themes', 't');
+ check_form_security_token_redirectOnErr('/admin/plugins', 'admin_themes', 't');
// Toggle plugin status
$idx = array_search($plugin, $a->plugins);
@@ -800,52 +816,53 @@ function admin_page_plugins(&$a){
} else {
$status="off"; $action= t("Enable");
}
-
+
$readme=Null;
if (is_file("addon/$plugin/README.md")){
$readme = file_get_contents("addon/$plugin/README.md");
$readme = Markdown($readme);
} else if (is_file("addon/$plugin/README")){
$readme = "