public $is_tablet;
public $is_friendica_app;
public $performance = array();
+ public $callstack = array();
public $nav_sel;
$this->performance["rendering"] = 0;
$this->performance["parser"] = 0;
$this->performance["marktime"] = 0;
- $this->performance["markstart"] = microtime(true);
+
+ $this->performance["file"] = 0;
+ $this->performance["file"] = 0;
+
+ $this->callstack["database"] = array();
+ $this->callstack["network"] = array();
+ $this->callstack["file"] = array();
+ $this->callstack["rendering"] = array();
+ $this->callstack["parser"] = array();
$this->config = array();
$this->page = array();
$this->performance[$value] += (float)$duration;
$this->performance["marktime"] += (float)$duration;
+
+ // Trace the different functions with their timestamps
+ $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 5);
+
+ array_shift($trace);
+
+ $function = array();
+ foreach ($trace AS $func)
+ $function[] = $func["function"];
+
+ $function = implode(", ", $function);
+
+ //$last = array_pop($trace);
+ //$function = $last["function"];
+
+ $this->callstack[$value][$function] += (float)$duration;
+
}
function mark_timestamp($mark) {
}
// add zrl's to public images
- $photo_pattern = "/\[url=(.*?)\/photos\/(.*?)\/image\/(.*?)\]\[img(.*?)\]h(.*?)\[\/img\]\[\/url\]/is";
- if(preg_match($photo_pattern,$item['body'])) {
- $photo_replace = '[url=' . zrl('$1' . '/photos/' . '$2' . '/image/' . '$3' ,true) . '][img' . '$4' . ']h' . '$5' . '[/img][/url]';
- $item['body'] = bb_tag_preg_replace($photo_pattern, $photo_replace, 'url', $item['body']);
- }
+// $photo_pattern = "/\[url=(.*?)\/photos\/(.*?)\/image\/(.*?)\]\[img(.*?)\]h(.*?)\[\/img\]\[\/url\]/is";
+// if(preg_match($photo_pattern,$item['body'])) {
+// $photo_replace = '[url=' . zrl('$1' . '/photos/' . '$2' . '/image/' . '$3' ,true) . '][img' . '$4' . ']h' . '$5' . '[/img][/url]';
+// $item['body'] = bb_tag_preg_replace($photo_pattern, $photo_replace, 'url', $item['body']);
+// }
// add sparkle links to appropriate permalinks
// Repair missing Diaspora settings
$r = q("SELECT `id`, `url` FROM `contact`
- WHERE `uid` > 0 AND `network` = '%s' AND (`batch` = '' OR `notify` = '' OR `poll` = '' OR pubkey = '')
+ WHERE `network` = '%s' AND (`batch` = '' OR `notify` = '' OR `poll` = '' OR pubkey = '')
ORDER BY RAND() LIMIT 50", dbesc(NETWORK_DIASPORA));
if ($r) {
foreach ($r AS $contact) {
array($remote_photo_name, 'scaled_full_' . $remote_photo_name));
if(strpos($parent_item['body'],$link_text) === false) {
+
+ $parent_item['body'] = $link_text . $parent_item['body'];
+
$r = q("UPDATE `item` SET `body` = '%s', `visible` = 1 WHERE `id` = %d AND `uid` = %d",
- dbesc($link_text . $parent_item['body']),
+ dbesc($parent_item['body']),
intval($parent_item['id']),
intval($parent_item['uid'])
);
+ put_item_in_cache($parent_item, true);
update_thread($parent_item['id']);
}
$a = get_app();
$hashtags = "\n";
foreach ($data["keywords"] AS $keyword) {
- $hashtag = str_replace(array(" ", "+", "/", ".", "#", "'"),
- array("","", "", "", "", ""), $keyword);
+ /// @todo make a positive list of allowed characters
+ $hashtag = str_replace(array(" ", "+", "/", ".", "#", "'", "’", "`", "(", ")", "„", "“"),
+ array("","", "", "", "", "", "", "", "", "", "", ""), $keyword);
$hashtags .= "#[url=".$a->get_baseurl()."/search?tag=".rawurlencode($hashtag)."]".$hashtag."[/url] ";
}
}
$stamp1 = microtime(true);
$a = get_app();
-
+
// pass $baseurl to all templates
$r['$baseurl'] = z_root();
-
+
$t = $a->template_engine();
try {
$item['hashtags'] = $hashtags;
$item['mentions'] = $mentions;
+ $test = $item["rendered-html"];
put_item_in_cache($item, true);
$s = $item["rendered-html"];
+ //if ($test != $s)
+ // $s .= "<hr>*********************************<hr>".$test;
+
$prep_arr = array('item' => $item, 'html' => $s, 'preview' => $preview);
call_hooks('prepare_body', $prep_arr);
$s = $prep_arr['html'];
function update_thread($itemid, $setmention = false) {
$items = q("SELECT `uid`, `guid`, `title`, `body`, `created`, `edited`, `commented`, `received`, `changed`, `wall`, `private`, `pubmail`, `moderated`, `visible`, `spam`, `starred`, `bookmark`, `contact-id`, `gcontact-id`,
- `deleted`, `origin`, `forum_mode`, `network` FROM `item` WHERE `id` = %d AND (`parent` = %d OR `parent` = 0) LIMIT 1", intval($itemid), intval($itemid));
+ `deleted`, `origin`, `forum_mode`, `network`, `rendered-html`, `rendered-hash` FROM `item` WHERE `id` = %d AND (`parent` = %d OR `parent` = 0) LIMIT 1", intval($itemid), intval($itemid));
if (!$items)
return;
$sql = "";
foreach ($item AS $field => $data)
- if (!in_array($field, array("guid", "title", "body"))) {
+ if (!in_array($field, array("guid", "title", "body", "rendered-html", "rendered-hash"))) {
if ($sql != "")
$sql .= ", ";
if (!$items)
return;
- $result = q("UPDATE `item` SET `title` = '%s', `body` = '%s' WHERE `id` = %d",
+ $result = q("UPDATE `item` SET `title` = '%s', `body` = '%s', `rendered-html` = '%s', `rendered-hash` = '%s' WHERE `id` = %d",
dbesc($item["title"]),
dbesc($item["body"]),
+ dbesc($item["rendered-html"]),
+ dbesc($item["rendered-hash"]),
intval($items[0]["id"])
);
logger("Updating public shadow for post ".$items[0]["id"]." - guid ".$item["guid"]." Result: ".print_r($result, true), LOGGER_DEBUG);