Hier mal eine veränderte index.php von 1.2.2 zum testen - hat bei mir zwischen 5 und 23 % an Zeit gespart (unter Windows)..
Code: Select all
<?php
#CMS - CMS Made Simple
#(c)2004 by Ted Kulp (wishy@users.sf.net)
#This project's homepage is: http://cmsmadesimple.sf.net
#
#This program is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#$Id: index.php 4217 2007-10-07 15:13:13Z wishy $
$dirname = dirname(__FILE__);
require_once($dirname.'/fileloc.php');
global $gCms;
@ob_start();
if (!isset($_SERVER['REQUEST_URI']) && isset($_SERVER['QUERY_STRING']))
$_SERVER['REQUEST_URI'] = $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'];
if (file_exists(TMP_CACHE_LOCATION.'/SITEDOWN'))
{
echo "<__html><head><title>Maintenance</title></head></__body><p>Site down for maintenance.</p><__body></__html>";
exit;
}
require_once($dirname.'/fileloc.php');
require_once($dirname.'/include.php'); #Makes gCms object
global $gCms;
$params = array_merge($_GET, $_POST);
$smarty = &$gCms->smarty;
$smarty->params = $params;
$smarty->compile_check = false;
$page = '';
if (isset($params['mact']))
{
$ary = explode(',', cms_htmlentities($params['mact']), 4);
$smarty->id = (isset($ary[1])?$ary[1]:'');
}
else
$smarty->id = (isset($params['id'])?intval($params['id']):'');
if (isset($smarty->id) && isset($params[$smarty->id . 'returnid']))
$page = $params[$smarty->id . 'returnid'];
else if (isset($config["query_var"]) && $config["query_var"] != '' && isset($_GET[$config["query_var"]]))
{
$page = $_GET[$config["query_var"]];
if ($config['page_extension'] != '' && endswith($page, $config['page_extension']))
$page = substr($page, 0, strlen($page) - strlen($config['page_extension']));
}
else
{
$calced = cms_calculate_url();
if ($calced != '')
$page = $calced;
}
$page = rtrim($page, '/');
if (strpos($page, '/') !== FALSE)
{
$routes =& $gCms->variables['routes'];
$matched = false;
foreach ($routes as $route)
{
$matches = array();
if (preg_match($route->regex, $page, $matches))
{
//Now setup some assumptions
if (!isset($matches['id']))
$matches['id'] = 'cntnt01';
if (!isset($matches['action']))
$matches['action'] = 'defaulturl';
if (!isset($matches['inline']))
$matches['inline'] = 0;
if (!isset($matches['returnid']))
$matches['returnid'] = ''; #Look for default page
if (!isset($matches['module']))
$matches['module'] = $route->module;
//Get rid of numeric matches
foreach ($matches as $key=>$val)
{
if (is_int($key))
unset($matches[$key]);
else
if ($key != 'id')
$_REQUEST[$matches['id'] . $key] = $val;
}
//Now set any defaults that might not have been in the url
if (isset($route->defaults) && count($route->defaults) > 0)
{
foreach ($route->defaults as $key=>$val)
{
$_REQUEST[$matches['id'] . $key] = $val;
if (array_key_exists($key, $matches))
$matches[$key] = $val;
}
}
//Get a decent returnid
if ($matches['returnid'] == '') {
$contentops =& $gCms->GetContentOperations();
$matches['returnid'] = $contentops->GetDefaultPageID();
}
$_REQUEST['mact'] = $matches['module'] . ',' . $matches['id'] . ',' . $matches['action'] . ',' . $matches['inline'];
$page = $matches['returnid'];
$smarty->id = $matches['id'];
$matched = true;
}
}
if (!$matched)
$page = substr($page, strrpos($page, '/') + 1);
}
if ($page == '')
{
$contentops =& $gCms->GetContentOperations();
$page =& $contentops->GetDefaultContent();
}
else
$page = preg_replace('/\</','',$page);
$pageinfo = PageInfoOperations::LoadPageInfoByContentAlias($page);
if (isset($pageinfo) && $pageinfo !== FALSE)
{
$gCms->variables['pageinfo'] =& $pageinfo;
if( isset($pageinfo->template_encoding) &&
$pageinfo->template_encoding != '' )
set_encoding($pageinfo->template_encoding);
$gCms->variables['content_id'] = $pageinfo->content_id;
$gCms->variables['page'] = $page;
$gCms->variables['page_id'] = $page;
$gCms->variables['page_name'] = $pageinfo->content_alias;
$gCms->variables['position'] = $pageinfo->content_hierarchy;
$contentops =& $gCms->GetContentOperations();
$gCms->variables['friendly_position'] = $contentops->CreateFriendlyHierarchyPosition($pageinfo->content_hierarchy);
$smarty->assign('content_id', $pageinfo->content_id);
$smarty->assign('page', $page);
$smarty->assign('page_id', $page);
$smarty->assign('page_name', $pageinfo->content_alias);
$smarty->assign('page_alias', $pageinfo->content_alias);
$smarty->assign('position', $pageinfo->content_hierarchy);
$smarty->assign('friendly_position', $gCms->variables['friendly_position']);
}
else if (get_site_preference('enablecustom404') == '' || get_site_preference('enablecustom404') == "0")
{
ErrorHandler404();
exit;
}
$html = '';
$cached = '';
if (isset($_GET["print"]))
$html = $smarty->fetch('print:'.$page, '', $pageinfo->template_id) . "\n";
else
{
#If this is a case where a module doesn't want a template to be shown, just disable caching
if (isset($smarty->id) && $smarty->id != '' && isset($_REQUEST[$smarty->id.'showtemplate']) && $_REQUEST[$smarty->id.'showtemplate'] == 'false')
$t='template:notemplate';
else
$t= 'template:'.$pageinfo->template_id;
$html = $smarty->fetch($t) . "\n";
}
reset($gCms->modules);
while (list($key) = each($gCms->modules))
{
$value =& $gCms->modules[$key];
if ($gCms->modules[$key]['installed'] == true && $gCms->modules[$key]['active'] == true)
{
$gCms->modules[$key]['object']->ContentPostRenderNonCached($html);
$gCms->modules[$key]['object']->ContentPostRender($html);
}
}
header("Content-Type: " . $gCms->variables['content-type'] . "; charset=" . (isset($pageinfo->template_encoding) && $pageinfo->template_encoding != ''?$pageinfo->template_encoding:get_encoding()));
echo $html;
@ob_flush();
?>
Ihr könnt ja mal probieren und melden was es bei euch gebracht hat.