Hvorfor loader min side så langsomt
er der nogen der kan gennemskue hvorfor denne kode skal bruge 10-15sekunder til at loade..??<?php
function get_microtime()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
function calc_microtime($from = 0)
{
return get_microtime() - $from;
}
$t_generated = calc_microtime();
error_reporting(E_ALL);
class TimeCalculator {
var $start_time;
var $caption;
function TimeCalculator($caption) {
$this->start_time = microtime();
$this->caption = $caption;
}
function getElapsedTime() {
$end_time = microtime();
$elapsed_time = round($this->getFloatTime($end_time) - $this->getFloatTime($this->start_time), 3);
echo "<b>{$this->caption}</b> was executed in <b>$elapsed_time</b> seconds <br>\r\n";
}
function getFloatTime($time_str) {
list($usec, $sec) = explode(" ", $time_str);
return ((float)$usec + (float)$sec);
}
}
define ('PATH_TO_SYSTEM_CLASS','system/core/System.php');
//////////////////////////////////////////////////////////////////
//
// start of the script actions
//
//////////////////////////////////////////////////////////////////
require_once(PATH_TO_SYSTEM_CLASS);
//if (file_exists('system/user-config/LocalSettings.php')) echo "file exists"; else "not";
System::loadSystemSettings ('system/user-config/DefaultSettings.php');
System::loadSystemSettings ('system/user-config/LocalSettings.php');
require_once('admin/lang/'. System::getSystemSettings ('LOCALE') .'.php');//ȀЋRˀ
if (is_null(System::getSystemSettings('SITE_URL')))
{
header("Location: install.php");
exit;
}
elseif (is_readable ("install.php"))
{
echo '<p>Your installation is temporarily disabled because the install.php file in the root of your'
.' installation is still readable.<br> To proceed, please remove the file or change its mode to make'
.' it non-readable for the Apache server process and refresh this page.</p>';
exit;
}
System::boot();
System::init();
header("Content-type:text/html;charset=utf-8");
if (Navigator::isRequestedUnderLegalURI()){
$uri = Navigator::getUri();
//$page_config = new PageConfig($uri);
$page_config = PageConfig::getPageConfig ($uri);
// the Responder!!!
if ($page_config->PageExists()){
$page_content = System::getPage($page_config);
$time_generated = calc_microtime($t_generated);
setcookie('time_generated', sprintf('%.3f', $time_generated));
echo $page_content;
}
elseif ($page_config->isADirecotryRequestedWithoutASlashAtTheEnd()){
header($_SERVER['SERVER_PROTOCOL'] . ' 301 Moved Permanently');// no such page in configuration
header("Location: {$_SERVER['REQUEST_URI']}/");
echo "The requested resource is located under a different URL: {$_SERVER['REQUEST_URI']}/";
}
elseif (System::doesParentUserPageExist($uri)) {
$parent_uri = System::getUserPageParentURI($uri);
$page_config = PageConfig::getPageConfig ($parent_uri);
$passed_parameters_via_uri = substr($uri, strlen($parent_uri));
$_REQUEST['passed_parameters_via_uri'] = $passed_parameters_via_uri;
$page_content = System::getPage($page_config);
echo $page_content;
}
else{ // the 404 error case!
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');// no such page in configuration
echo "404 Not Found";
}
}
else{
header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');// not configured to answer such request
echo "The software is not configured to respond to requests of the following host: {$_SERVER['HTTP_HOST']}\n";
}
?>
