function PageMaker($xmlfile, $xslfile) { global $options, $id, $df, $cacheLifeTime; # Инициализация системы кэширования // Подключаем класс вывода PEAR::Cache_Lite require_once 'cache/output.php'; // Создаем объект класса Cache_Lite_Output $cache = new Cache_Lite_Output($options); // Устанавливаем время жизни кэша для данной части $cache->setLifeTime($cacheLifeTime[$id]); if (!$cache->start($id)) { # Передаем путь к запрошенному документу на вход модуля анализа и преобразования XML+XSLT, # формирующего на выходе запрошенный документ в XHTML-формате. require_once "inc/nstoxhtml.inc"; require_once "inc/setformat.inc"; require_once "inc/nocache.inc"; $outputformat = 'xml'; //if ($xslfile !== "xsl/rbcrss.xsl") $xslfile = "xsl/layout.xsl"; $domxml = new DOMDocument(); $domxml->substituteEntities = true; $domxml->load($xmlfile); @fclose($df); # Снимаем блокировку с файла * $domxsl = new DOMDocument(); $domxsl->load($xslfile); setOutputFormat($domxsl, $outputformat); $xsl = new xsltProcessor(); $xsl->importStylesheet($domxsl); $outdom = $xsl->transformtoDOC($domxml); $outdom = nstoxhtml($outdom); $outdom->formatoutput = true; nocache(); $page = $outdom->saveXML(); echo TrimStr($page); $cache->end(); } }
<?php // Bench script of Cache_Lite_Output // $Id: bench2.php,v 1.1 2009/03/26 18:56:29 mhoegh Exp $ require_once 'Cache/Lite/Output.php'; $options = array('caching' => true, 'cacheDir' => '/tmp/', 'lifeTime' => 10); $cache = new Cache_Lite_Output($options); if (!$cache->start('123')) { // Cache missed... for ($i = 0; $i < 1000; $i++) { // Making of the page... echo '0123456789'; } $cache->end(); }
function articlePage($section, $filePath) { // -----[ CACHE LITE ]----- // Cache Lite is optional but recommended as it rolls and stores the page as HTML // and avoids having to rebuild the page everytime it is called. You will need to clear // the cache if you update the page. You could create a seperate "clearcache.php" page. // See: "/site/orgile/clearcache.php". require_once 'Cache/Lite/Output.php'; $options = array('cacheDir' => '/srv/www/' . SITEURL . '/www/site/ramcache/', 'lifeTime' => '604800'); // Define cache directory and cache lifetime (168 hours). $cache = new Cache_Lite_Output($options); // Begin cache lite. if (!$cache->start($filePath)) { if (is_file($filePath)) { $fileData = file_get_contents($filePath, NULL, NULL, 0, 1000); // This reads the first 1000 chars for speed. // Pulls details from .org file header. $regex = '/^#\\+\\w*:(.*)/m'; preg_match_all($regex, $fileData, $matches); $title = trim($matches[1][0]); $author = trim($matches[1][1]); $date = trim($matches[1][2]); $date = date('c', cleanDate($date)); $description = trim($matches[1][3]); $description = strip_tags($description); // Create HTML header. $htmlHeader = htmlHeader($date, $author, $description, $title, dropDash($section)); // Starts the object buffer. ob_start(); pageHeader(); print '<div id="columnX">'; fetchOne($filePath, 'orgile'); print '</div>'; print '<div id="columnY">'; print '<aside>'; print '<div class="content">'; print '<h2><a href="/' . spaceDash($section) . '/" title="' . spaceDash($section) . '">' . spaceDash($section) . '</a>:</h2>'; print '<ul class="side">'; fetchSome($section, 'list', '0', 'sort'); // See function below. print '</ul><br>'; print '</div>' . sideContent(); print '</aside>'; print '</div>'; pageFooter(); // End the object buffer. $content = ob_get_contents(); ob_end_clean(); $content = $htmlHeader . $content; } // End: is_file($filePath). print $content; // End cache. $cache->end(); } // End: cache lite. }
unset($_SESSION['user_id'], $_SESSION['user_pass']); // считаем пользователя Гостем $_SESSION['user_group'] = 2; $_SESSION['user_name'] = get_username(); define('UID', 0); define('UGROUP', 2); define('UNAME', $_SESSION['user_name']); } } // Заглушка пока нет поддержки многоязычности $_SESSION['user_language'] = DEFAULT_LANGUAGE; // Эксперимент с кэшированием if (!defined('ACP') && empty($_POST) && !isset($_REQUEST['module']) && UGROUP == 2 && CACHE_LIFETIME) { require BASE_DIR . '/lib/Cache/Lite/Output.php'; $options = array('writeControl' => false, 'readControl' => false, 'lifeTime' => CACHE_LIFETIME, 'cacheDir' => BASE_DIR . '/cache/'); $cache = new Cache_Lite_Output($options); if ($cache->start($_SERVER['REQUEST_URI'])) { if (defined('PROFILING') && PROFILING) { echo get_statistic(1, 1, 1, 0); } exit; } } define('DATE_FORMAT', get_settings('date_format')); define('TIME_FORMAT', get_settings('time_format')); define('PAGE_NOT_FOUND_ID', intval(get_settings('page_not_found_id'))); if (isset($_REQUEST['onlycontent']) && 1 == $_REQUEST['onlycontent']) { define('ONLYCONTENT', 1); } function set_locale() {
<!--<script type="text/javascript" src="http://srvpub.com/adServe/banners?tid=34915_50844_0&size=728x90" ></script>--> <?php include SITEDIR . '/libraries/rss.php'; $subTitle = $pageTitle . ' News'; //caching require_once 'Cache/Lite/Output.php'; // Set a few options $options = array('cacheDir' => SITEDIR . '/cache/Pear_cache/', 'lifeTime' => 3600 * 24 * 365 * 10); $cache = new Cache_Lite_Output($options); $key = 'rssNews_' . md5($pageTitle); if (!$cache->start($key)) { //$myRss = new RSSParser("http://news.google.com/news?pz=1&cf=all&ned=us&hl=en&q=".urlencode($pageTitle)."&cf=all&output=rss"); $myRss = new RSSParser("http://www.bing.com/news/search?q=" . urlencode($pageTitle) . "&FORM=HDRSC6&format=RSS"); $itemNum = 0; $myRss_RSSmax = 0; if ($myRss_RSSmax == 0 || $myRss_RSSmax > count($myRss->titles)) { $myRss_RSSmax = count($myRss->titles); } if ($myRss_RSSmax > 0) { ?> <ul> <?php for ($itemNum = 0; $itemNum < $myRss_RSSmax; $itemNum++) { if ($itemNum == 1) { ?> <li><?php include 'googletextads.php'; ?> </li> <?php }