Bugfixing after adding timestamps

This commit is contained in:
Michael Vogel 2013-01-27 13:57:44 +01:00
parent fdee002f73
commit 2cb576d305
8 changed files with 72 additions and 65 deletions

View file

@ -418,6 +418,8 @@ if(! class_exists('App')) {
$this->performance["network"] = 0; $this->performance["network"] = 0;
$this->performance["rendering"] = 0; $this->performance["rendering"] = 0;
$this->performance["parser"] = 0; $this->performance["parser"] = 0;
$this->performance["marktime"] = 0;
$this->performance["markstart"] = microtime(true);
$this->config = array(); $this->config = array();
$this->page = array(); $this->page = array();
@ -726,12 +728,17 @@ if(! class_exists('App')) {
return $this->rdelim[$engine]; return $this->rdelim[$engine];
} }
function save_timestamp($stamp1, $value) { function save_timestamp($stamp, $value) {
$stamp2 = microtime(true); $duration = (float)(microtime(true)-$stamp);
$duration = (float)($stamp2-$stamp1);
$this->performance[$value] += (float)$duration; $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"];
}
} }
} }

View file

@ -368,7 +368,6 @@ function visible_activity($item) {
if(!function_exists('conversation')) { if(!function_exists('conversation')) {
function conversation(&$a, $items, $mode, $update, $preview = false) { function conversation(&$a, $items, $mode, $update, $preview = false) {
require_once('include/bbcode.php'); require_once('include/bbcode.php');
$ssl_state = ((local_user()) ? true : false); $ssl_state = ((local_user()) ? true : false);

View file

@ -8,7 +8,7 @@ function uninstall_plugin($plugin){
q("DELETE FROM `addon` WHERE `name` = '%s' ", q("DELETE FROM `addon` WHERE `name` = '%s' ",
dbesc($plugin) dbesc($plugin)
); );
@include_once('addon/' . $plugin . '/' . $plugin . '.php'); @include_once('addon/' . $plugin . '/' . $plugin . '.php');
if(function_exists($plugin . '_uninstall')) { if(function_exists($plugin . '_uninstall')) {
$func = $plugin . '_uninstall'; $func = $plugin . '_uninstall';
@ -28,9 +28,9 @@ function install_plugin($plugin) {
if(function_exists($plugin . '_install')) { if(function_exists($plugin . '_install')) {
$func = $plugin . '_install'; $func = $plugin . '_install';
$func(); $func();
$plugin_admin = (function_exists($plugin."_plugin_admin")?1:0); $plugin_admin = (function_exists($plugin."_plugin_admin")?1:0);
$r = q("INSERT INTO `addon` (`name`, `installed`, `timestamp`, `plugin_admin`) VALUES ( '%s', 1, %d , %d ) ", $r = q("INSERT INTO `addon` (`name`, `installed`, `timestamp`, `plugin_admin`) VALUES ( '%s', 1, %d , %d ) ",
dbesc($plugin), dbesc($plugin),
intval($t), intval($t),
@ -195,6 +195,9 @@ function call_hooks($name, &$data = null) {
if (! function_exists('get_plugin_info')){ if (! function_exists('get_plugin_info')){
function get_plugin_info($plugin){ function get_plugin_info($plugin){
$a = get_app();
$info=Array( $info=Array(
'name' => $plugin, 'name' => $plugin,
'description' => "", 'description' => "",
@ -229,10 +232,10 @@ function get_plugin_info($plugin){
$info[$k]=$v; $info[$k]=$v;
} }
} }
} }
} }
} }
return $info; return $info;
}} }}
@ -241,7 +244,7 @@ function get_plugin_info($plugin){
/* /*
* parse theme comment in search of theme infos. * parse theme comment in search of theme infos.
* like * like
* *
* * Name: My Theme * * Name: My Theme
* * Description: My Cool Theme * * Description: My Cool Theme
* * Version: 1.2.3 * * Version: 1.2.3
@ -270,6 +273,7 @@ function get_theme_info($theme){
if (!is_file("view/theme/$theme/theme.php")) return $info; if (!is_file("view/theme/$theme/theme.php")) return $info;
$a = get_app();
$stamp1 = microtime(true); $stamp1 = microtime(true);
$f = file_get_contents("view/theme/$theme/theme.php"); $f = file_get_contents("view/theme/$theme/theme.php");
$a->save_timestamp($stamp1, "file"); $a->save_timestamp($stamp1, "file");

View file

@ -39,9 +39,7 @@ function replace_macros($s,$r) {
$output = template_unescape($r); $output = template_unescape($r);
} }
$a = get_app(); $a = get_app();
$stamp2 = microtime(true); $a->save_timestamp($stamp1, "rendering");
$duration = (float)($stamp2-$stamp1);
$a->performance["rendering"] += (float)$duration;
return $output; return $output;
}} }}

View file

@ -33,7 +33,7 @@ $install = ((file_exists('.htconfig.php') && filesize('.htconfig.php')) ? false
$lang = get_browser_language(); $lang = get_browser_language();
load_translation_table($lang); load_translation_table($lang);
/** /**

View file

@ -20,7 +20,7 @@ function admin_post(&$a){
if(x($_SESSION,'submanage') && intval($_SESSION['submanage'])) if(x($_SESSION,'submanage') && intval($_SESSION['submanage']))
return; return;
// urls // urls
@ -54,7 +54,7 @@ function admin_post(&$a){
} }
info(t('Theme settings updated.')); info(t('Theme settings updated.'));
if(is_ajax()) return; if(is_ajax()) return;
goaway($a->get_baseurl(true) . '/admin/themes/' . $theme ); goaway($a->get_baseurl(true) . '/admin/themes/' . $theme );
return; return;
break; break;
@ -100,9 +100,9 @@ function admin_content(&$a) {
'dbsync' => Array($a->get_baseurl(true)."/admin/dbsync/", t('DB updates'), "dbsync"), 'dbsync' => Array($a->get_baseurl(true)."/admin/dbsync/", t('DB updates'), "dbsync"),
//'update' => Array($a->get_baseurl(true)."/admin/update/", t("Software Update") , "update") //'update' => Array($a->get_baseurl(true)."/admin/update/", t("Software Update") , "update")
); );
/* get plugins admin page */ /* get plugins admin page */
$r = q("SELECT * FROM `addon` WHERE `plugin_admin`=1"); $r = q("SELECT * FROM `addon` WHERE `plugin_admin`=1");
$aside['plugins_admin']=Array(); $aside['plugins_admin']=Array();
foreach ($r as $h){ foreach ($r as $h){
@ -111,7 +111,7 @@ function admin_content(&$a) {
// temp plugins with admin // temp plugins with admin
$a->plugins_admin[] = $plugin; $a->plugins_admin[] = $plugin;
} }
$aside['logs'] = Array($a->get_baseurl(true)."/admin/logs/", t("Logs"), "logs"); $aside['logs'] = Array($a->get_baseurl(true)."/admin/logs/", t("Logs"), "logs");
$t = get_markup_template("admin_aside.tpl"); $t = get_markup_template("admin_aside.tpl");
@ -130,7 +130,6 @@ function admin_content(&$a) {
* Page content * Page content
*/ */
$o = ''; $o = '';
// urls // urls
if ($a->argc > 1){ if ($a->argc > 1){
switch ($a->argv[1]){ switch ($a->argv[1]){
@ -161,7 +160,7 @@ function admin_content(&$a) {
} else { } else {
$o = admin_page_summary($a); $o = admin_page_summary($a);
} }
if(is_ajax()) { if(is_ajax()) {
echo $o; echo $o;
killme(); killme();
@ -431,14 +430,14 @@ function admin_page_site(&$a) {
} }
} }
} }
/* Banner */ /* Banner */
$banner = get_config('system','banner'); $banner = get_config('system','banner');
if($banner == false) 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 = '<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); $banner = htmlspecialchars($banner);
//echo "<pre>"; var_dump($lang_choices); die("</pre>"); //echo "<pre>"; var_dump($lang_choices); die("</pre>");
/* Register policy */ /* Register policy */
@ -763,7 +762,7 @@ function admin_page_users(&$a){
* @return string * @return string
*/ */
function admin_page_plugins(&$a){ function admin_page_plugins(&$a){
/** /**
* Single plugin * Single plugin
*/ */
@ -773,9 +772,9 @@ function admin_page_plugins(&$a){
notice( t("Item not found.") ); notice( t("Item not found.") );
return ''; return '';
} }
if (x($_GET,"a") && $_GET['a']=="t"){ 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 // Toggle plugin status
$idx = array_search($plugin, $a->plugins); $idx = array_search($plugin, $a->plugins);
@ -800,52 +799,53 @@ function admin_page_plugins(&$a){
} else { } else {
$status="off"; $action= t("Enable"); $status="off"; $action= t("Enable");
} }
$readme=Null; $readme=Null;
if (is_file("addon/$plugin/README.md")){ if (is_file("addon/$plugin/README.md")){
$readme = file_get_contents("addon/$plugin/README.md"); $readme = file_get_contents("addon/$plugin/README.md");
$readme = Markdown($readme); $readme = Markdown($readme);
} else if (is_file("addon/$plugin/README")){ } else if (is_file("addon/$plugin/README")){
$readme = "<pre>". file_get_contents("addon/$plugin/README") ."</pre>"; $readme = "<pre>". file_get_contents("addon/$plugin/README") ."</pre>";
} }
$admin_form=""; $admin_form="";
if (is_array($a->plugins_admin) && in_array($plugin, $a->plugins_admin)){ if (is_array($a->plugins_admin) && in_array($plugin, $a->plugins_admin)){
@require_once("addon/$plugin/$plugin.php"); @require_once("addon/$plugin/$plugin.php");
$func = $plugin.'_plugin_admin'; $func = $plugin.'_plugin_admin';
$func($a, $admin_form); $func($a, $admin_form);
} }
$t = get_markup_template("admin_plugins_details.tpl"); $t = get_markup_template("admin_plugins_details.tpl");
return replace_macros($t, array( return replace_macros($t, array(
'$title' => t('Administration'), '$title' => t('Administration'),
'$page' => t('Plugins'), '$page' => t('Plugins'),
'$toggle' => t('Toggle'), '$toggle' => t('Toggle'),
'$settings' => t('Settings'), '$settings' => t('Settings'),
'$baseurl' => $a->get_baseurl(true), '$baseurl' => $a->get_baseurl(true),
'$plugin' => $plugin, '$plugin' => $plugin,
'$status' => $status, '$status' => $status,
'$action' => $action, '$action' => $action,
'$info' => get_plugin_info($plugin), '$info' => get_plugin_info($plugin),
'$str_author' => t('Author: '), '$str_author' => t('Author: '),
'$str_maintainer' => t('Maintainer: '), '$str_maintainer' => t('Maintainer: '),
'$admin_form' => $admin_form, '$admin_form' => $admin_form,
'$function' => 'plugins', '$function' => 'plugins',
'$screenshot' => '', '$screenshot' => '',
'$readme' => $readme, '$readme' => $readme,
'$form_security_token' => get_form_security_token("admin_themes"), '$form_security_token' => get_form_security_token("admin_themes"),
)); ));
} }
/** /**
* List plugins * List plugins
*/ */
$plugins = array(); $plugins = array();
$files = glob("addon/*/"); $files = glob("addon/*/");
if($files) { if($files) {
@ -857,7 +857,7 @@ function admin_page_plugins(&$a){
} }
} }
} }
$t = get_markup_template("admin_plugins.tpl"); $t = get_markup_template("admin_plugins.tpl");
return replace_macros($t, array( return replace_macros($t, array(
'$title' => t('Administration'), '$title' => t('Administration'),
@ -928,7 +928,7 @@ function rebuild_theme_table($themes) {
return $o; return $o;
} }
/** /**
* Themes admin page * Themes admin page
* *
@ -936,7 +936,7 @@ function rebuild_theme_table($themes) {
* @return string * @return string
*/ */
function admin_page_themes(&$a){ function admin_page_themes(&$a){
$allowed_themes_str = get_config('system','allowed_themes'); $allowed_themes_str = get_config('system','allowed_themes');
$allowed_themes_raw = explode(',',$allowed_themes_str); $allowed_themes_raw = explode(',',$allowed_themes_str);
$allowed_themes = array(); $allowed_themes = array();
@ -972,9 +972,9 @@ function admin_page_themes(&$a){
notice( t("Item not found.") ); notice( t("Item not found.") );
return ''; return '';
} }
if (x($_GET,"a") && $_GET['a']=="t"){ 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 // Toggle theme status
@ -998,28 +998,27 @@ function admin_page_themes(&$a){
} else { } else {
$status="off"; $action= t("Enable"); $status="off"; $action= t("Enable");
} }
$readme=Null; $readme=Null;
if (is_file("view/theme/$theme/README.md")){ if (is_file("view/theme/$theme/README.md")){
$readme = file_get_contents("view/theme/$theme/README.md"); $readme = file_get_contents("view/theme/$theme/README.md");
$readme = Markdown($readme); $readme = Markdown($readme);
} else if (is_file("view/theme/$theme/README")){ } else if (is_file("view/theme/$theme/README")){
$readme = "<pre>". file_get_contents("view/theme/$theme/README") ."</pre>"; $readme = "<pre>". file_get_contents("view/theme/$theme/README") ."</pre>";
} }
$admin_form=""; $admin_form="";
if (is_file("view/theme/$theme/config.php")){ if (is_file("view/theme/$theme/config.php")){
require_once("view/theme/$theme/config.php"); require_once("view/theme/$theme/config.php");
if(function_exists("theme_admin")){ if(function_exists("theme_admin")){
$admin_form = theme_admin($a); $admin_form = theme_admin($a);
} }
} }
$screenshot = array( get_theme_screenshot($theme), t('Screenshot')); $screenshot = array( get_theme_screenshot($theme), t('Screenshot'));
if(! stristr($screenshot[0],$theme)) if(! stristr($screenshot[0],$theme))
$screenshot = null; $screenshot = null;
$t = get_markup_template("admin_plugins_details.tpl"); $t = get_markup_template("admin_plugins_details.tpl");
return replace_macros($t, array( return replace_macros($t, array(
@ -1028,7 +1027,7 @@ function admin_page_themes(&$a){
'$toggle' => t('Toggle'), '$toggle' => t('Toggle'),
'$settings' => t('Settings'), '$settings' => t('Settings'),
'$baseurl' => $a->get_baseurl(true), '$baseurl' => $a->get_baseurl(true),
'$plugin' => $theme, '$plugin' => $theme,
'$status' => $status, '$status' => $status,
'$action' => $action, '$action' => $action,
@ -1042,21 +1041,19 @@ function admin_page_themes(&$a){
'$form_security_token' => get_form_security_token("admin_themes"), '$form_security_token' => get_form_security_token("admin_themes"),
)); ));
} }
/** /**
* List themes * List themes
*/ */
$xthemes = array(); $xthemes = array();
if($themes) { if($themes) {
foreach($themes as $th) { foreach($themes as $th) {
$xthemes[] = array($th['name'],(($th['allowed']) ? "on" : "off"), get_theme_info($th['name'])); $xthemes[] = array($th['name'],(($th['allowed']) ? "on" : "off"), get_theme_info($th['name']));
} }
} }
$t = get_markup_template("admin_plugins.tpl"); $t = get_markup_template("admin_plugins.tpl");
return replace_macros($t, array( return replace_macros($t, array(
'$title' => t('Administration'), '$title' => t('Administration'),

View file

@ -321,7 +321,7 @@ function network_query_get_sel_net() {
if(x($_GET,'nets')) { if(x($_GET,'nets')) {
$network = $_GET['nets']; $network = $_GET['nets'];
} }
return $network; return $network;
} }
@ -382,14 +382,14 @@ function network_content(&$a, $update = 0) {
// item filter tabs // item filter tabs
// TODO: fix this logic, reduce duplication // TODO: fix this logic, reduce duplication
//$a->page['content'] .= '<div class="tabs-wrapper">'; //$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); 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 tabs are selected, defaults to comments
if ($no_active=='active') $all_active='active'; 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(); //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); $cmd = (($datequery) ? '' : $a->cmd);
$len_naked_cmd = strlen(str_replace('/new','',$cmd)); $len_naked_cmd = strlen(str_replace('/new','',$cmd));
// tabs // tabs
$tabs = array( $tabs = array(
@ -435,10 +435,10 @@ function network_content(&$a, $update = 0) {
// 'url'=>$a->get_baseurl(true) . '/network?f=&spam=1' // 'url'=>$a->get_baseurl(true) . '/network?f=&spam=1'
// 'sel'=> $spam_active, // 'sel'=> $spam_active,
// 'title' => t('Posts flagged as SPAM'), // 'title' => t('Posts flagged as SPAM'),
// ), // ),
); );
if(feature_enabled(local_user(),'personal_tab')) { if(feature_enabled(local_user(),'personal_tab')) {
$tabs[] = array( $tabs[] = array(
'label' => t('Personal'), 'label' => t('Personal'),
@ -571,11 +571,11 @@ function network_content(&$a, $update = 0) {
} }
// We don't have to deal with ACL's on this page. You're looking at everything // We don't have to deal with ACLs on this page. You're looking at everything
// that belongs to you, hence you can see all of it. We will filter by group if // that belongs to you, hence you can see all of it. We will filter by group if
// desired. // desired.
$sql_options = (($star) ? " and starred = 1 " : ''); $sql_options = (($star) ? " and starred = 1 " : '');
$sql_options .= (($bmark) ? " and bookmark = 1 " : ''); $sql_options .= (($bmark) ? " and bookmark = 1 " : '');

View file

@ -127,6 +127,7 @@ class Conversation extends BaseObject {
* _ false on failure * _ false on failure
*/ */
public function get_template_data($alike, $dlike) { public function get_template_data($alike, $dlike) {
global $a;
$result = array(); $result = array();
foreach($this->threads as $item) { foreach($this->threads as $item) {
@ -140,6 +141,7 @@ class Conversation extends BaseObject {
$result[] = $item_data; $result[] = $item_data;
} }
//$a->mark_timestamp();
return $result; return $result;
} }