/**
 * Uninstall b2evolution: Delete DB & Cache files
 */
function uninstall_b2evolution()
{
    global $DB;
    /* REMOVE PAGE CACHE */
    load_class('_core/model/_pagecache.class.php', 'PageCache');
    // Remove general page cache
    $PageCache = new PageCache(NULL);
    $PageCache->cache_delete();
    // Skip if T_blogs table is already deleted. Note that db_delete() will not throw any errors on missing tables.
    if ($DB->query('SHOW TABLES LIKE "T_blogs"')) {
        // Get all blogs
        $blogs_SQL = new SQL();
        $blogs_SQL->SELECT('blog_ID');
        $blogs_SQL->FROM('T_blogs');
        $blogs = $DB->get_col($blogs_SQL->get());
        $BlogCache =& get_BlogCache('blog_ID');
        foreach ($blogs as $blog_ID) {
            $Blog = $BlogCache->get_by_ID($blog_ID);
            // Remove page cache of current blog
            $PageCache = new PageCache($Blog);
            $PageCache->cache_delete();
        }
    }
    /* REMOVE DATABASE */
    db_delete();
    echo '<p>' . T_('Reset done!') . '</p>';
}
Example #2
0
 /**
  *
  */
 public function testAction()
 {
     $page = new PageCache();
     $page->id = "/";
     $page->cache = "<xml><xml>";
     $page->save();
     $di = $this->getDI();
     $logger = $di->getShared('logger');
     $this->logger->log("msg", \Phalcon\Logger::INFO);
     $methods = get_class_methods($this);
     $this->logger->log(json_encode($methods), \Phalcon\Logger::INFO);
 }
 static function clear()
 {
     SessionCache::clear();
     SiteCache::clear();
     PageCache::clear();
     return;
 }
 public static function getInstance()
 {
     if (null === self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Example #5
0
 function display($template = null, $cache_id = null, $complile_id = null)
 {
     if ($template == null) {
         global $php;
         $template = $php->env['mvc']['controller'] . '_' . $php->env['mvc']['view'] . '.html';
     }
     if ($this->if_pagecache) {
         $pagecache = new PageCache($this->cache_life);
         if (!$pagecache->isCached()) {
             $pagecache->create(parent::fetch($template, $cache_id, $complile_id));
         }
         $pagecache->load();
     } else {
         parent::display($template, $cache_id, $complile_id);
     }
 }
Example #6
0
 public function singleton()
 {
     if (!isset(self::$instance)) {
         $c = __CLASS__;
         self::$instance = new $c();
     }
     return self::$instance;
 }
Example #7
0
 public static function getLibrary()
 {
     if (!PageCache::$library) {
         $class = Loader::helper('text')->camelcase(PAGE_CACHE_LIBRARY) . 'PageCache';
         PageCache::$library = new $class();
     }
     return PageCache::$library;
 }
Example #8
0
 public function validate()
 {
     $diff = $this->expires - time();
     if ($diff > 0) {
         // it's still valid
         return true;
     } else {
         // invalidate and kill this record.
         $cache = PageCache::getLibrary();
         $cache->purgeByRecord($this);
     }
 }
Example #9
0
<?php

/*
|--------------------------------------------------------------------------
| Cache Before Filter
|--------------------------------------------------------------------------
|
| Checks if the web page is cached, if so returns it.
|
*/
Route::filter('cache_get', function ($route, $request) {
    if (($content = PageCache::get($request->path())) !== null) {
        return $content;
    }
});
/*
|--------------------------------------------------------------------------
| Cache After Filter
|--------------------------------------------------------------------------
|
| Saves the response in the cache for next time
|
*/
Route::filter('cache_set', function ($route, $request, $response = null) {
    if ($response instanceof Illuminate\Http\Response) {
        if ($content = PageCache::set($request->path(), $response->getContent())) {
            $response->setContent($content);
        }
    }
});
Example #10
0
?>
 <?php 
echo t('minutes');
?>
</div>

		</div>

		<hr/>
		<p class="lead"><?php 
echo t('Cache Status');
?>
</p>

		<?php 
$cache = PageCache::getLibrary();
$rec = $cache->getRecord($c);
if ($rec instanceof \Concrete\Core\Cache\Page\PageCacheRecord) {
    ?>
			<div class="alert alert-success">
				<?php 
    echo t('This page currently exists in the full page cache. It expires %s.', Loader::helper('date')->date('m/d/Y g:i a', $rec->getCacheRecordExpiration()));
    ?>
				&nbsp;&nbsp;<button type="button" class="btn btn-xs btn-default pull-right" id="ccm-button-remove-page-from-cache"><?php 
    echo t('Purge');
    ?>
</button>
			</div>
		<?php 
} else {
    if ($rec instanceof \Concrete\Core\Cache\Page\UnknownPageCacheRecord) {
 public function updateAction()
 {
     $id = Request::postParam('pageId');
     $jsonData = Request::postParam('jsonData');
     $preview = $this->sanitizeBoolean(Request::postParam('preview'));
     $preview_language_id = Request::postParam('previewLanguageId');
     // �berpr�fen, ob die Lebenswichtigen Parameter gesetzt sind
     if ($id === null || $jsonData === null || $preview === null || $preview_language_id === null) {
         $this->error(self::RESULT_ERROR_BAD_REQUEST);
         return;
     }
     // �berpr�fen, ob die Seite �berhaupt (noch) existiert
     $properties = $this->pages->getProperties($id);
     if ($properties === false) {
         $this->error(self::RESULT_ERROR_DOES_NOT_EXIST);
         return;
     }
     // Nutzerrechte �berpr�fen
     if (!$this->helpers->canAccessPage($id, Acl::ACTION_EDIT)) {
         $this->error(self::RESULT_ERROR_NOT_AUHTORIZED);
         return;
     }
     // Daten der gew�nschten Seite speichern
     if ($this->pages->setData($id, $jsonData) === false) {
         $this->error();
         return;
     }
     // �nderungs-Datum setzen
     $properties = array('last-change-date' => time(), 'last-change-user-id' => Auth::getUserId(), 'last-change-user-name' => Auth::getScreenName());
     $this->pages->setProperties($id, $properties);
     $properties = $this->pages->getProperties($id);
     // Wenn das die Seite mit den globalen Elementen ist,
     // muss sie sofort ver�ffentlich werden und der Cache muss geleert werden,
     // da die �nderungen potenziell die Ausgabe aller Seiten betreffen k�nnte
     if ($properties['template-id'] == Pages::GLOBAL_ELEMENTS) {
         $this->pages->publish($id);
         PageCache::invalidateAll();
     }
     // R�ckgabe
     $res = array('preview' => $preview);
     // Wenn Vorschau-Modus, dann Frontend-URL zur Vorschau-Version der gespeicherten Seite zur�ckgeben
     if ($preview) {
         $res['previewUrl'] = $this->pages->getPageUrl($id, $preview_language_id, $properties) . '?pixelmanager-preview=true';
     }
     // Yo.
     $this->success($res);
 }
Example #12
0
 public function change_doc_part_name_desc()
 {
     $project_id = $this->post('projectID');
     $domain_handle = $this->post('itemDomain');
     $volume_handle = $this->post('itemVolume');
     $part_handle = $this->post('itemPart');
     $item_type = $this->post('itemType');
     $item_value = $this->post('itemValue');
     $json = Loader::helper('json');
     $pas = new PageActionStatus();
     $pas->action = t('Change Volume/Part Name/Desc');
     $pas->status = t('Unkown error');
     $pas->time = time();
     if (!fse_try_to_login()) {
         $pas->message = t('You do not sign in or session expired.');
         echo $json->encode($pas);
         exit(0);
     }
     if (!in_array($domain_handle, $this->mDomainList)) {
         $pas->status = "error";
         $pas->message = "Invalid doc domain: {$domain_handle}!";
         echo $json->encode($pas);
         exit(0);
     }
     if (!preg_match("/^[a-z0-9_\\-]{4,64}\$/", $project_id)) {
         $pas->status = "error";
         $pas->message = "Invalid given project ID: {$project_id}!";
         echo $json->encode($pas);
         exit(0);
     }
     $project_home_page = ProjectInfo::getProjectPage($project_id, 'home');
     if ($project_home_page == false) {
         $pas->status = "error";
         $pas->message = "No such project: {$project_id}!";
         echo $json->encode($pas);
         exit(0);
     }
     if ($item_type == 'name') {
         if (!preg_match("/^.{1,64}\$/", $item_value)) {
             $pas->status = "error";
             $pas->message = "Bad volume/part name: {$item_value}!";
             echo $json->encode($pas);
             exit(0);
         }
         $page_property = 'cName';
     } else {
         if ($item_type == 'desc') {
             if (!preg_match("/^.{2,255}\$/", $item_value)) {
                 $pas->status = "error";
                 $pas->message = "Bad volume/part desc: {$item_value}!";
                 echo $json->encode($pas);
                 exit(0);
             }
             $page_property = 'cDescription';
         } else {
             $pas->status = "error";
             $pas->message = "Bad item type: {$item_type}!";
             echo $json->encode($pas);
             exit(0);
         }
     }
     $project_info = ProjectInfo::getBasicInfo($project_id);
     if ($project_info['fse_id'] != $_SESSION['FSEInfo']['fse_id']) {
         $pas->status = "error";
         $pas->message = "You are not the owner of {$project_id}!";
         echo $json->encode($pas);
         exit(0);
     }
     $db = Loader::db();
     if (preg_match("/^[a-z0-9\\-]{3,16}\$/", $part_handle)) {
         $res = $db->Execute("UPDATE fsen_project_doc_volume_parts SET part_{$item_type}=?\n\tWHERE project_id=? AND domain_handle=? AND volume_handle=? AND part_handle=?", array($item_value, $project_id, $domain_handle, $volume_handle, $part_handle));
         ProjectInfo::onUpdateProjectPartInfo($project_id, $domain_handle, $volume_handle, $part_handle);
     } else {
         $res = $db->Execute("UPDATE fsen_project_doc_volumes SET volume_{$item_type}=?\n\tWHERE project_id=? AND domain_handle=? AND volume_handle=?", array($item_value, $project_id, $domain_handle, $volume_handle));
         ProjectInfo::onUpdateProjectVolumeInfo($project_id, $domain_handle, $volume_handle);
     }
     if ($db->Affected_Rows() == 0) {
         $pas->status = "error";
         $pas->message = "Nothing changed!";
         echo $json->encode($pas);
         exit(0);
     }
     $cache = PageCache::getLibrary();
     /* update page attributes and refresh block caches */
     if (preg_match("/^[a-z0-9\\-]{3,16}\$/", $part_handle)) {
         $page = ProjectInfo::getProjectPage($project_id, $domain_handle, $volume_handle, $part_handle);
         if ($page != false) {
             $page->update(array($page_property => $item_value));
             $cache->purge($page);
         }
     } else {
         $page = ProjectInfo::getProjectPage($project_id, $domain_handle, $volume_handle);
         if ($page != false) {
             $page->update(array($page_property => $item_value));
             $cache->purge($page);
         }
         $cache->purge($project_home_page);
     }
     $pas->status = "success";
     $pas->message = "Item changed!";
     echo $json->encode($pas);
     exit(0);
 }
Example #13
0
function myPlurk_AddPlurkIcon($target, $mother)
{
    global $blogid, $service, $database, $suri, $blogURL, $pluginURL, $configVal;
    requireComponent('Textcube.Function.misc');
    $data = misc::fetchConfigVal($configVal);
    $attachResponses = isset($data['attachResponses']) && $data['attachResponses'] == 1 ? true : false;
    $plurklang = Setting::getBlogSettingGlobal('blogLanguage', '');
    $plurkIcon = "";
    $responsePlurks = "";
    if ($suri['directive'] != "/rss" && $suri['directive'] != "/m" && $suri['directive'] != "/i/entry" && $suri['directive'] != "/atom" && $suri['directive'] != "/sync" && POD::queryCount("SELECT id FROM {$database['prefix']}PlurkEntries WHERE blogid={$blogid} AND id={$mother}") > 0) {
        $plurk_id = intval(POD::queryCell("SELECT plurkid FROM {$database['prefix']}PlurkEntries WHERE blogid={$blogid} AND id={$mother}"));
        $plurkLink = "http://www.plurk.com/p/" . base_convert($plurk_id, 10, 36);
        if (!empty($plurkLink)) {
            $plurkIcon = '<div id="plurkthis"><img src="' . $pluginURL . '/images/plurkicon.png" border="0" width="16" height="16" alt="Plurk This!" />&nbsp;PLURK: <a href="' . $plurkLink . '" target="_blank">' . $plurkLink . '</a></div><br />';
        }
        if (!$attachResponses) {
            return $plurkIcon . $target;
        }
        $cache = new PageCache();
        $cache->name = 'HC_TCPlurkCache';
        if ($cache->load()) {
            $cache->contents = unserialize($cache->contents);
            if (array_key_exists($mother, $cache->contents) && Timestamp::getUNIXtime() - $cache->dbContents < 600) {
                return $plurkIcon . $target . $cache->contents[$mother];
            }
        }
        require_once "libs/plurk_api.php";
        $plurk = new plurk_api();
        $plurkNickname = isset($data['plurknickname']) ? $data['plurknickname'] : "";
        $plurkPassword = isset($data['plurkpassword']) ? $data['plurkpassword'] : "";
        $plurk_api = 'iMCH3JDDda7c4bs0qiOchZcxAx7t8PA7';
        if (!$plurk->login($plurk_api, $plurkNickname, $plurkPassword)) {
            return $plurkIcon . $target;
        }
        $responsePlurks = "";
        $response = $plurk->get_responses($plurk_id);
        if ($response->responses_seen > 0) {
            $qualifiers = array("loves", "likes", "shares", "gives", "hates", "wants", "wishes", "needs", "will", "hopes", "asks", "has", "was", "wonders", "feels", "thinks", "says", "is");
            $qualifiers_locale = array('en' => $qualifiers, 'zh-TW' => array("愛", "喜歡", "推", "給", "討厭", "想要", "希望", "需要", "打算", "希望", "問", "已經", "曾經", "好奇", "覺得", "想", "說", "正在"), 'zh-CN' => array("爱", "喜欢", "推", "给", "讨厌", "想要", "希望", "需要", "打算", "希望", "问", "已经", "曾经", "好奇", "觉得", "想", "说", "正在"));
            $lang = "en";
            switch ($plurklang) {
                case "zh-TW":
                case "zh-CN":
                    $lang = $plurklang;
                    break;
                default:
                    $lang = "en";
            }
            $friends = array();
            $nick2displayname = array('nickname' => array(), 'displayname' => array());
            foreach ($response->friends as $friend) {
                $friends[$friend->uid]['display_name'] = $friend->display_name;
                $friends[$friend->uid]['nick_name'] = $friend->nick_name;
                $friends[$friend->uid]['has_profile_image'] = $friend->has_profile_image == 1 ? true : false;
                $friends[$friend->uid]['avatar'] = $friend->avatar == null ? "" : $friend->avatar;
                if (!in_array($friend->nick_name, $nick2displayname['nickname'])) {
                    array_push($nick2displayname['nickname'], $friend->nick_name);
                    array_push($nick2displayname['displayname'], $friend->display_name);
                }
            }
            ob_start();
            echo "<div class=\"plurkResponse\" id=\"plurkResponse_{$mother}\">\n";
            echo "<h3>" . _f("%1 Responses to this Plurk", $response->responses_seen) . "</h3>\n";
            echo "<div class=\"plurkResponseLists\">\n<table cellpadding=\"2\" cellspacing=\"2\" border=\"0\">\n";
            foreach ($response->responses as $commentObj) {
                $comment = (array) $commentObj;
                $userIcon = $friends[$comment['user_id']]['has_profile_image'] ? "http://avatars.plurk.com/{$comment['user_id']}-medium{$friends[$comment['user_id']]['avatar']}.gif" : "";
                $display_name = $friends[$comment['user_id']]['display_name'];
                $nick_name = $friends[$comment['user_id']]['nick_name'];
                $qualifier = in_array($comment['qualifier'], $qualifiers) ? $comment['qualifier'] : "";
                $qualifierKey = array_keys($qualifiers, $comment['qualifier']);
                $qualifier_trans = isset($qualifiers_locale[$lang][$qualifierKey[0]]) ? $qualifiers_locale[$lang][$qualifierKey[0]] : '';
                if (preg_match_all('/<a href="http:\\/\\/www.plurk.com\\/(.*?)" class="ex_link">(.*?)<\\/a>/ms', $comment['content'], $matches)) {
                    $mlen = count($matches[1]);
                    for ($i = $mlen - 1; $i >= 0; $i--) {
                        if (in_array($matches[1][$i], $nick2displayname['nickname'])) {
                            $replydisplayname = $nick2displayname['displayname'][array_search($matches[1][$i], $nick2displayname['nickname'])];
                            $comment['content'] = str_replace('<a href="http://www.plurk.com/' . $matches[1][$i] . '" class="ex_link">' . $matches[2][$i] . '</a>', '<a href="http://www.plurk.com/' . $matches[1][$i] . '" class="ex_link">' . $replydisplayname . '</a>', $comment['content']);
                        }
                    }
                }
                echo "<tr><td class=\"user_icon\"><a href=\"http://www.plurk.com/{$nick_name}\" target=\"_blank\"><img src=\"{$userIcon}\" border=\"0\" width=\"45\" height=\"45\" alt=\"{$display_name}\" title=\"{$display_name}\" onerror=\"this.src='{$pluginURL}/images/nonusericon.gif'\" /></a></td>\n";
                echo "<td class=\"plurkcontent\"><a href=\"http://www.plurk.com/{$nick_name}\" target=\"_blank\">{$display_name}</a>&nbsp;\n";
                echo "<span class=\"qualifier_{$qualifier}\">{$qualifier_trans}</span>&nbsp;<span class=\"plurkcomment\">{$comment['content']}</span></td></tr>\n";
            }
            echo "</table>\n</div>\n<p style=\"text-align:right;line-height:1em;\" class=\"plurkResponseMoreButton\">" . _t('MorePlurk...') . "</p>\n";
            echo "</div>\n\n";
            $responsePlurks = ob_get_contents();
            ob_end_clean();
        } else {
            // no response
        }
        $cache->contents[$mother] = $responsePlurks;
        $cache->contents = serialize($cache->contents);
        $cache->dbContents = Timestamp::getUNIXtime();
        $cache->update();
        unset($cache);
    }
    return $plurkIcon . $target . $responsePlurks;
}
Example #14
0
		public function reindex($index = false, $actuallyDoReindex = true) {
			if ($this->isAlias()) {
				return false;
			}
			if ($actuallyDoReindex || ENABLE_PROGRESSIVE_PAGE_REINDEX == false) { 
				$db = Loader::db();
				
				Loader::model('attribute/categories/collection');
				$attribs = CollectionAttributeKey::getAttributes($this->getCollectionID(), $this->getVersionID(), 'getSearchIndexValue');
		
				$db->Execute('delete from CollectionSearchIndexAttributes where cID = ?', array($this->getCollectionID()));
				$searchableAttributes = array('cID' => $this->getCollectionID());
				$rs = $db->Execute('select * from CollectionSearchIndexAttributes where cID = -1');
				AttributeKey::reindex('CollectionSearchIndexAttributes', $searchableAttributes, $attribs, $rs);
				
				if ($index == false) {
					Loader::library('database_indexed_search');
					$index = new IndexedSearch();
				}
				
				$index->reindexPage($this);
				$db->Replace('PageSearchIndex', array('cID' => $this->getCollectionID(), 'cRequiresReindex' => 0), array('cID'), false);

				$cache = PageCache::getLibrary();
				$cache->purge($this);

			} else { 			
				$db = Loader::db();
				Config::save('DO_PAGE_REINDEX_CHECK', true);
				$db->Replace('PageSearchIndex', array('cID' => $this->getCollectionID(), 'cRequiresReindex' => 1), array('cID'), false);
			}
		}
Example #15
0
 function delete()
 {
     Loader::model('page_statistics');
     $cID = $this->getCollectionID();
     if ($cID <= 1) {
         return false;
     }
     $db = Loader::db();
     // run any internal event we have for page deletion
     $ret = Events::fire('on_page_delete', $this);
     if ($ret < 0) {
         return false;
     }
     Log::addEntry(t('Page "%s" at path "%s" deleted', $this->getCollectionName(), $this->getCollectionPath()), t('Page Action'));
     if ($this->isAlias() && $this->getCollectionPointerExternalLink() == '') {
         $this->removeThisAlias();
     } else {
         parent::delete();
         $cID = $this->getCollectionID();
         $cParentID = $this->getCollectionParentID();
         // Now that all versions are gone, we can delete the collection information
         $q = "delete from PagePaths where cID = '{$cID}'";
         $r = $db->query($q);
         // remove all pages where the pointer is this cID
         $r = $db->query("select cID from Pages where cPointerID = ?", array($cID));
         while ($row = $r->fetchRow()) {
             PageStatistics::decrementParents($row['cID']);
             $db->Execute('DELETE FROM PagePaths WHERE cID=?', array($row['cID']));
         }
         // Update cChildren for cParentID
         PageStatistics::decrementParents($cID);
         $q = "delete from PagePermissionAssignments where cID = '{$cID}'";
         $r = $db->query($q);
         $q = "delete from Pages where cID = '{$cID}'";
         $r = $db->query($q);
         $q = "delete from Pages where cPointerID = '{$cID}'";
         $r = $db->query($q);
         $q = "delete from Areas WHERE cID = '{$cID}'";
         $r = $db->query($q);
         $q = "delete from ComposerDrafts WHERE cID = '{$cID}'";
         $r = $db->query($q);
         $db->query('delete from PageSearchIndex where cID = ?', array($cID));
         $q = "select cID from Pages where cParentID = '{$cID}'";
         $r = $db->query($q);
         if ($r) {
             while ($row = $r->fetchRow()) {
                 if ($row['cID'] > 0) {
                     $nc = Page::getByID($row['cID']);
                     if ($nc->isAlias()) {
                         $nc->removeThisAlias();
                     } else {
                         $nc->delete();
                     }
                 }
             }
         }
     }
     $cache = PageCache::getLibrary();
     $cache->purge($this);
 }
Example #16
0
 /**
  * render takes one argument - the item being rendered - and it can either be a path or a page object
  * @access public
  * @param string $view
  * @param array $args
  * @return void
  */
 public function render($view, $args = null)
 {
     if (is_array($args)) {
         extract($args);
     }
     // strip off a slash if there is one at the end
     if (is_string($view)) {
         if (substr($view, strlen($view) - 1) == '/') {
             $view = substr($view, 0, strlen($view) - 1);
         }
     }
     $dsh = Loader::helper('concrete/dashboard');
     $wrapTemplateInTheme = false;
     $this->checkMobileView();
     if (defined('DB_DATABASE') && $view !== '/upgrade') {
         Events::fire('on_start', $this);
     }
     // Extract controller information from the view, and put it in the current context
     if (!isset($this->controller)) {
         $this->controller = Loader::controller($view);
         $this->controller->setupAndRun();
     }
     if ($this->controller->getRenderOverride() != '') {
         $view = $this->controller->getRenderOverride();
     }
     // Determine which inner item to load, load it, and stick it in $innerContent
     $content = false;
     ob_start();
     if ($view instanceof Page) {
         $_pageBlocks = $view->getBlocks();
         if (!$dsh->inDashboard()) {
             $_pageBlocksGlobal = $view->getGlobalBlocks();
             $_pageBlocks = array_merge($_pageBlocks, $_pageBlocksGlobal);
         }
         // do we have any custom menu plugins?
         $cp = new Permissions($view);
         if ($cp->canViewToolbar()) {
             $ih = Loader::helper('concrete/interface/menu');
             $_interfaceItems = $ih->getPageHeaderMenuItems();
             foreach ($_interfaceItems as $_im) {
                 $_controller = $_im->getController();
                 $_controller->outputAutoHeaderItems();
             }
             unset($_interfaceItems);
             unset($_im);
             unset($_controller);
         }
         unset($_interfaceItems);
         unset($_im);
         unset($_controller);
         // now, we output all the custom style records for the design tab in blocks/areas on the page
         $c = $this->getCollectionObject();
         $view->outputCustomStyleHeaderItems();
         $viewPath = $view->getCollectionPath();
         $this->viewPath = $viewPath;
         $cFilename = $view->getCollectionFilename();
         $ctHandle = $view->getCollectionTypeHandle();
         $editMode = $view->isEditMode();
         $c = $view;
         $this->c = $c;
         $env = Environment::get();
         // $view is a page. It can either be a SinglePage or just a Page, but we're not sure at this point, unfortunately
         if ($view->getCollectionTypeID() == 0 && $cFilename) {
             $wrapTemplateInTheme = true;
             $cFilename = trim($cFilename, '/');
             $content = $env->getPath(DIRNAME_PAGES . '/' . $cFilename, $view->getPackageHandle());
             $themeFilename = $c->getCollectionHandle() . '.php';
         } else {
             $rec = $env->getRecord(DIRNAME_PAGE_TYPES . '/' . $ctHandle . '.php', $view->getPackageHandle());
             if ($rec->exists()) {
                 $wrapTemplateInTheme = true;
                 $content = $rec->file;
             }
             $themeFilename = $ctHandle . '.php';
         }
     } else {
         if (is_string($view)) {
             // if we're passing a view but our render override is not null, that means that we're passing
             // a new view from within a controller. If that's the case, then we DON'T override the viewPath, we want to keep it
             // In order to enable editable 404 pages, other editable pages that we render without actually visiting
             if (defined('DB_DATABASE') && $view == '/page_not_found') {
                 $pp = Page::getByPath($view);
                 if (!$pp->isError()) {
                     $this->c = $pp;
                 }
             }
             $viewPath = $view;
             if ($this->controller->getRenderOverride() != '' && $this->getCollectionObject() != null) {
                 // we are INSIDE a collection renderring a view. Which means we want to keep the viewPath that of the collection
                 $this->viewPath = $this->getCollectionObject()->getCollectionPath();
             }
             // we're just passing something like "/login" or whatever. This will typically just be
             // internal Concrete stuff, but we also prepare for potentially having something in DIR_FILES_CONTENT (ie: the webroot)
             if (file_exists(DIR_FILES_CONTENT . "/{$view}/" . FILENAME_COLLECTION_VIEW)) {
                 $content = DIR_FILES_CONTENT . "/{$view}/" . FILENAME_COLLECTION_VIEW;
             } else {
                 if (file_exists(DIR_FILES_CONTENT . "/{$view}.php")) {
                     $content = DIR_FILES_CONTENT . "/{$view}.php";
                 } else {
                     if (file_exists(DIR_FILES_CONTENT_REQUIRED . "/{$view}/" . FILENAME_COLLECTION_VIEW)) {
                         $content = DIR_FILES_CONTENT_REQUIRED . "/{$view}/" . FILENAME_COLLECTION_VIEW;
                     } else {
                         if (file_exists(DIR_FILES_CONTENT_REQUIRED . "/{$view}.php")) {
                             $content = DIR_FILES_CONTENT_REQUIRED . "/{$view}.php";
                         } else {
                             if ($this->getCollectionObject() != null && $this->getCollectionObject()->isGeneratedCollection() && $this->getCollectionObject()->getPackageID() > 0) {
                                 //This is a single_page associated with a package, so check the package views as well
                                 $pagePkgPath = Package::getByID($this->getCollectionObject()->getPackageID())->getPackagePath();
                                 if (file_exists($pagePkgPath . "/single_pages/{$view}/" . FILENAME_COLLECTION_VIEW)) {
                                     $content = $pagePkgPath . "/single_pages/{$view}/" . FILENAME_COLLECTION_VIEW;
                                 } else {
                                     if (file_exists($pagePkgPath . "/single_pages/{$view}.php")) {
                                         $content = $pagePkgPath . "/single_pages/{$view}.php";
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             $wrapTemplateInTheme = true;
             $themeFilename = $view . '.php';
         }
     }
     if (is_object($this->c)) {
         $c = $this->c;
         if (defined('DB_DATABASE') && ($view == '/page_not_found' || $view == '/login')) {
             $view = $c;
             $req = Request::get();
             $req->setCurrentPage($c);
             $_pageBlocks = $view->getBlocks();
             $_pageBlocksGlobal = $view->getGlobalBlocks();
             $_pageBlocks = array_merge($_pageBlocks, $_pageBlocksGlobal);
         }
     }
     if (is_array($_pageBlocks)) {
         foreach ($_pageBlocks as $b1) {
             $b1p = new Permissions($b1);
             if ($b1p->canRead()) {
                 $btc = $b1->getInstance();
                 // now we inject any custom template CSS and JavaScript into the header
                 if ('Controller' != get_class($btc)) {
                     $btc->outputAutoHeaderItems();
                 }
                 $btc->runTask('on_page_view', array($view));
             }
         }
     }
     // Determine which outer item/theme to load
     // obtain theme information for this collection
     if (isset($this->themeOverride)) {
         $theme = $this->themeOverride;
     } else {
         if ($this->controller->theme != false) {
             $theme = $this->controller->theme;
         } else {
             if (($tmpTheme = $this->getThemeFromPath($viewPath)) != false) {
                 $theme = $tmpTheme;
             } else {
                 if (is_object($this->c) && ($tmpTheme = $this->c->getCollectionThemeObject()) != false) {
                     $theme = $tmpTheme;
                 } else {
                     $theme = FILENAME_COLLECTION_DEFAULT_THEME;
                 }
             }
         }
     }
     $this->setThemeForView($theme, $themeFilename, $wrapTemplateInTheme);
     // finally, we include the theme (which was set by setTheme and will automatically include innerContent)
     // disconnect from our db and exit
     $this->controller->on_before_render();
     extract($this->controller->getSets());
     extract($this->controller->getHelperObjects());
     if ($content != false && !$this->disableContentInclude) {
         include $content;
     }
     $innerContent = ob_get_contents();
     if (ob_get_level() > OB_INITIAL_LEVEL) {
         ob_end_clean();
     }
     if (defined('DB_DATABASE') && $view !== '/upgrade') {
         Events::fire('on_before_render', $this);
     }
     if (defined('APP_CHARSET')) {
         header("Content-Type: text/html; charset=" . APP_CHARSET);
     }
     if (file_exists($this->theme)) {
         $cache = PageCache::getLibrary();
         $shouldAddToCache = $cache->shouldAddToCache($this);
         if ($shouldAddToCache) {
             $cache->outputCacheHeaders($c);
         }
         ob_start();
         include $this->theme;
         $pageContent = ob_get_contents();
         ob_end_clean();
         $ret = Events::fire('on_page_output', $pageContent);
         if ($ret != '') {
             print $ret;
             $pageContent = $ret;
         } else {
             print $pageContent;
         }
         $cache = PageCache::getLibrary();
         if ($shouldAddToCache) {
             $cache->set($c, $pageContent);
         }
     } else {
         throw new Exception(t('File %s not found. All themes need default.php and view.php files in them. Consult concrete5 documentation on how to create these files.', $this->theme));
     }
     if (defined('DB_DATABASE') && $view !== '/upgrade') {
         Events::fire('on_render_complete', $this);
     }
     if (ob_get_level() == OB_INITIAL_LEVEL) {
         require DIR_BASE_CORE . '/startup/jobs.php';
         require DIR_BASE_CORE . '/startup/shutdown.php';
         exit;
     }
 }
 public function clearcacheAction()
 {
     PageCache::invalidateAll();
     $this->success();
 }
Example #18
0
 /**
  * Delete a blog and dependencies from database
  *
  * Includes WAY TOO MANY requests because we try to be compatible with MySQL 3.23, bleh!
  *
  * @param boolean true if you want to echo progress
  */
 function dbdelete($echo = false)
 {
     global $DB, $Messages, $Plugins;
     // Try to obtain some serious time to do some serious processing (5 minutes)
     set_max_execution_time(300);
     // Note: No need to localize the status messages...
     if ($echo) {
         echo '<p>MySQL 3.23 compatibility mode!';
     }
     $DB->begin();
     // Get list of cats that are going to be deleted (3.23)
     if ($echo) {
         echo '<br />Getting category list to delete... ';
     }
     $cat_list = implode(',', $DB->get_col("\n\t\t\t\tSELECT cat_ID\n\t\t\t\t  FROM T_categories\n\t\t\t\t WHERE cat_blog_ID = {$this->ID}"));
     if (empty($cat_list)) {
         // There are no cats to delete
         if ($echo) {
             echo 'None!';
         }
     } else {
         // Delete the cats & dependencies
         // Get list of posts that are going to be deleted (3.23)
         if ($echo) {
             echo '<br />Getting post list to delete... ';
         }
         $post_list = implode(',', $DB->get_col("\n\t\t\t\t\tSELECT postcat_post_ID\n\t\t\t\t\t  FROM T_postcats\n\t\t\t\t\t WHERE postcat_cat_ID IN ({$cat_list})"));
         if (empty($post_list)) {
             // There are no posts to delete
             if ($echo) {
                 echo 'None!';
             }
         } else {
             // Delete the posts & dependencies
             // TODO: There's also a constraint FK_post_parent_ID..
             // Delete postcats
             if ($echo) {
                 echo '<br />Deleting post-categories... ';
             }
             $ret = $DB->query("DELETE FROM T_postcats\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE postcat_cat_ID IN ({$cat_list})");
             if ($echo) {
                 printf('(%d rows)', $ret);
             }
             $Messages->add(T_('Deleted post-categories'), 'success');
             // Delete comments
             if ($echo) {
                 echo '<br />Deleting comments on blog\'s posts... ';
             }
             $comments_list = implode(',', $DB->get_col("\n\t\t\t\t\t\tSELECT comment_ID\n\t\t\t\t\t\t  FROM T_comments\n\t\t\t\t\t\t WHERE comment_post_ID IN ({$post_list})"));
             if (!empty($comments_list)) {
                 // Delete the comments & dependencies
                 $DB->query("DELETE FROM T_comments__votes\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE cmvt_cmt_ID IN ({$comments_list})");
                 $ret = $DB->query("DELETE FROM T_comments\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE comment_post_ID IN ({$post_list})");
             } else {
                 // No comments in this blog
                 $ret = 0;
             }
             if ($echo) {
                 printf('(%d rows)', $ret);
             }
             $Messages->add(T_('Deleted comments on blog\'s posts'), 'success');
             // Delete posts
             if ($echo) {
                 echo '<br />Deleting blog\'s posts... ';
             }
             $DB->query("DELETE FROM T_items__itemtag\n\t\t\t\t\t\t\t\t\t\t\tWHERE itag_itm_ID IN ({$post_list})");
             $DB->query("DELETE FROM T_items__item_settings\n\t\t\t\t\t\t\t\t\t\t\tWHERE iset_item_ID IN ({$post_list})");
             $DB->query("DELETE FROM T_items__prerendering\n\t\t\t\t\t\t\t\t\t\t\tWHERE itpr_itm_ID IN ({$post_list})");
             $DB->query("DELETE FROM T_items__status\n\t\t\t\t\t\t\t\t\t\t\tWHERE pst_ID IN ({$post_list})");
             $DB->query("DELETE FROM T_items__subscriptions\n\t\t\t\t\t\t\t\t\t\t\tWHERE isub_item_ID IN ({$post_list})");
             $DB->query("DELETE FROM T_items__version\n\t\t\t\t\t\t\t\t\t\t\tWHERE iver_itm_ID IN ({$post_list})");
             $DB->query("DELETE FROM T_links\n\t\t\t\t\t\t\t\t\t\t\tWHERE link_itm_ID IN ({$post_list})");
             $DB->query("DELETE FROM T_slug\n\t\t\t\t\t\t\t\t\t\t\tWHERE slug_itm_ID IN ({$post_list})");
             $ret = $DB->query("DELETE FROM T_items__item\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE post_ID IN ({$post_list})");
             if ($echo) {
                 printf('(%d rows)', $ret);
             }
             $Messages->add(T_('Deleted blog\'s posts'), 'success');
         }
         // / are there posts?
         // Delete categories
         if ($echo) {
             echo '<br />Deleting blog\'s categories... ';
         }
         $ret = $DB->query("DELETE FROM T_categories\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE cat_blog_ID = {$this->ID}");
         if ($echo) {
             printf('(%d rows)', $ret);
         }
         $Messages->add(T_('Deleted blog\'s categories'), 'success');
     }
     // / are there cats?
     // Delete the blog cache folder - try to delete even if cache is disabled
     load_class('_core/model/_pagecache.class.php', 'PageCache');
     $PageCache = new PageCache($this);
     $PageCache->cache_delete();
     // remember ID, because parent method resets it to 0
     $old_ID = $this->ID;
     // Delete main (blog) object:
     parent::dbdelete();
     $DB->commit();
     // re-set the ID for the Plugin event
     $this->ID = $old_ID;
     $Plugins->trigger_event('AfterCollectionDelete', $params = array('Blog' => &$this));
     $this->ID = 0;
     if ($echo) {
         echo '<br />Done.</p>';
     }
 }
Example #19
0
function MT_Cover_getRecentEntries_purgeCache($target, $mother)
{
    $cache = new PageCache();
    $cache->name = 'MT_Cover_RecentPS';
    $cache->purge();
    return $target;
}
Example #20
0
 public function deleteSection($project_id, $domain_handle, $section_id)
 {
     if (!in_array($domain_handle, $this->mDomainList)) {
         return self::EC_BAD_DOMAIN;
     }
     $db = Loader::db();
     $doc_lang = substr($project_id, -2);
     $section_row = $db->getRow("SELECT page_id, area_handle, block_id, max_ver_code\n\tFROM fsen_document_sections_{$doc_lang} WHERE id=?", array($section_id));
     if (count($section_row) == 0) {
         return self::EC_NO_SUCH_ENTRY;
     }
     $res = $db->Execute("DELETE FROM fsen_document_sections_{$doc_lang} WHERE id=?", array($section_id));
     $page = Page::getByID($section_row['page_id']);
     $area = Area::get($page, $section_row['area_handle']);
     if (!is_object($area)) {
         return self::EC_BAD_PAGEAREA;
     }
     $block = Block::getByID($section_row['block_id'], $page, $section_row['area_handle']);
     if (!$block instanceof Block) {
         return self::EC_NO_SUCH_OBJ;
     }
     $block->delete();
     /* purge the full page cache */
     $page_cache = PageCache::getLibrary();
     $page_cache->purge($page);
     return self::EC_OK;
 }
Example #21
0
 public static function onUpdateBlogInfo($project_id, $domain_handle, $volume_handle, $part_handle, $chapter_handle)
 {
     /* we only flush the cache of the blog and the blog page */
     Cache::delete('BlogInfo', $chapter_handle);
     $cache = PageCache::getLibrary();
     $page = Page::getByPath(self::assemblePath($project_id, $domain_handle, $volume_handle, $part_handle, $chapter_handle));
     $cache->purge($page);
 }
Example #22
0
/**
 * Check if the given blog cache directory is ready for operation
 *
 * @param mixed blog ID, or NULL to check the general cache
 * @param boolean true if function should try to repair the corresponding cache folder, false otherwise
 * @return mixed false if the corresponding setting is disabled, or array( status, message ).
 */
function system_check_blog_cache($blog_ID = NULL, $repair = false)
{
    global $Settings;
    load_class('_core/model/_pagecache.class.php', 'PageCache');
    $Blog = NULL;
    $result = NULL;
    if ($blog_ID == NULL) {
        if ($Settings->get('general_cache_enabled')) {
            $result = system_check_dir('cache', 'general/');
            $before_msg = T_('General cache') . ': ';
        }
    } else {
        $BlogCache =& get_BlogCache();
        $Blog = $BlogCache->get_by_ID($blog_ID);
        if ($Blog->get_setting('cache_enabled')) {
            $result = system_check_dir('cache', 'c' . $blog_ID . '/');
            $before_msg = sprintf(T_('%s cache') . ': ', $Blog->get('shortname'));
        }
    }
    if (!isset($result)) {
        return false;
    }
    if (!$repair || $result == 0) {
        return system_get_result($result);
    }
    // try to repair the corresponding cache folder
    $PageCache = new PageCache($Blog);
    $PageCache->cache_delete();
    $PageCache->cache_create();
    return system_check_blog_cache($blog_ID, false);
}
Example #23
0
<?php

require_once "../lib/common.inc.php";
require_once "../lib/SimpieView.php";
require_once "../models/BookPage.php";
$page_name = isset($_GET['p']) && $_GET['p'] ? trim($_GET['p']) : 'index';
try {
    ensure_page_name_safe($page_name);
    $page = new BookPage($page_name);
    // 线下模式不显示修改时间,因为从Github读取需要的时间太长
    $page_last_update_time = IN_PROD_MODE ? $page->getLastUpdatedAt(true, "Y-m-d H:h") : false;
    // 如果获取修改时间失败,则先暂时禁用缓存,否则无法重新获取最后修改时间
    if ($page_last_update_time === false) {
        PageCache::disable();
    }
    $view = new SimpieView($page->toHtml(), "../templates/layout/book.php", SimpieView::IS_RAW_TEXT);
    $view->render(array('title' => $page->getTitle(), 'page' => $page, 'chapt_list' => BookPage::getChapterList(), 'is_detail_view' => $page_name != 'index', 'page_last_update_time' => $page_last_update_time));
} catch (PageNotFoundException $e) {
    // 尝试查找是否是因为章节调整导致地址发生变化导致的404
    // 通过永久重定向解决搜索引擎和错误地址的问题
    if ($similar_page_name = BookPage::getMostSimilarPageFromPageName($page_name)) {
        redirect_to("/book?p=" . $similar_page_name, 301);
    }
    header($_SERVER['SERVER_PROTOCOL'] . " 404 Not Found");
    header("Status: 404 Not Found");
    $view = 404;
    $title = "Page Not Found";
    $view = new SimpieView("../templates/book_page_{$view}.php", "../templates/layout/book.php");
    $view->render(array('book_page' => $page_name, 'exception' => $e, 'title' => $title, 'rev' => $rev, 'exception' => $e, 'is_detail_view' => true, 'chapt_list' => $chapt_list));
}
<?php

defined('C5_EXECUTE') or die("Access Denied.");
$request = Request::get();
$library = PageCache::getLibrary();
if ($library->shouldCheckCache($request)) {
    $record = $library->getRecord($request);
    if ($record instanceof PageCacheRecord) {
        if ($record->validate()) {
            $library->deliver($record);
            if (ob_get_level() == OB_INITIAL_LEVEL) {
                require DIR_BASE_CORE . '/startup/shutdown.php';
                exit;
            }
            exit;
        }
    }
}
Example #25
0
 /** 
  * Completely flushes the cache
  */
 public function flush()
 {
     $db = Loader::db();
     $r = $db->MetaTables();
     // flush the CSS cache
     if (is_dir(DIR_FILES_CACHE . '/' . DIRNAME_CSS)) {
         $fh = Loader::helper("file");
         $fh->removeAll(DIR_FILES_CACHE . '/' . DIRNAME_CSS);
     }
     $pageCache = PageCache::getLibrary();
     if (is_object($pageCache)) {
         $pageCache->flush();
     }
     if (in_array('Config', $r)) {
         // clear the environment overrides cache
         $env = Environment::get();
         $env->clearOverrideCache();
         if (in_array('btCachedBlockRecord', $db->MetaColumnNames('Blocks'))) {
             $db->Execute('update Blocks set btCachedBlockRecord = null');
         }
         if (in_array('CollectionVersionBlocksOutputCache', $r)) {
             $db->Execute('truncate table CollectionVersionBlocksOutputCache');
         }
     }
     $loc = CacheLocal::get();
     $loc->cache = array();
     $cache = Cache::getLibrary();
     if ($cache) {
         $cache->setOption('caching', true);
         $cache->clean(Zend_Cache::CLEANING_MODE_ALL);
     }
     if (function_exists('apc_clear_cache')) {
         apc_clear_cache();
     }
     Events::fire('on_cache_flush', $cache);
     return true;
 }
Example #26
0
 /**
  * Delete any file that is older than 24 hours from the whole /cache folder (recursively)
  * except index.html files and hiddenfiles (starting with .)
  *
  * @static
  *
  * @return string empty string on success, error message otherwise.
  */
 function prune_page_cache()
 {
     global $cache_path;
     load_funcs('tools/model/_system.funcs.php');
     // check and try to repair cache folders
     system_check_caches();
     $path = trailing_slash($cache_path);
     $first_error = '';
     PageCache::deleteDirContent($path, $first_error);
     return $first_error;
 }
Example #27
0
 public static function getDBPrefix()
 {
     //Use alone for higher performance table prefix fetch
     $prefix = '';
     //Use for standard table prefix fetch (Lower performance, but no configuration required)
     if (self::$tablePrefix == '') {
         if (self::$config != '') {
             try {
                 $config = self::$config;
                 $prefix = $config->global->resources->db->table_prefix;
             } catch (Exception $e) {
             }
         } else {
             if (file_exists('app/etc/local.xml')) {
                 try {
                     $config = self::$config = simplexml_load_file('app/etc/local.xml');
                     $prefix = $config->global->resources->db->table_prefix;
                 } catch (Exception $e) {
                 }
             }
         }
         if ($prefix != '') {
             $prefix = $prefix . "_";
         }
         self::$tablePrefix = $prefix;
         return $prefix;
     } else {
         return self::$tablePrefix;
     }
 }
Example #28
0
 public static function enable()
 {
     self::$enable = true;
 }
Example #29
0
# to something else than this page -- which is the case on demo installs.
# For production systems, properly set the blog URL , then remove the line below:
$redir = 'no';
/**
 * Let b2evolution handle the query string and load the blog data:
 */
require_once dirname(__FILE__) . '/conf/_config.php';
require_once $inc_path . '_blog_main.inc.php';
// Make sure includes will check in the current folder!
$ads_current_skin_path = dirname(__FILE__) . '/';
# Now, below you'll find the magic template...
// --------------------- PAGE LEVEL CACHING SUPPORT ---------------------
// Note: This is totally optional. General caching must be enabled in Global settings, otherwise this will do nothing.
// Delete this block if you don't care about page level caching. Don't forget to delete the matching section at the end of the page.
load_class('_core/model/_pagecache.class.php', 'PageCache');
$PageCache = new PageCache(NULL);
// Check for cached content & Start caching if needed:
if (!$PageCache->check()) {
    // Cache miss, we have to generate:
    // --------------------- PAGE LEVEL CACHING SUPPORT ---------------------
    // This is the main template; it may be used to display very different things.
    // Do inits depending on current $disp:
    skin_init($disp);
    // Add CSS:
    require_css('basic_styles.css', 'rsc_url');
    // the REAL basic styles
    require_css('basic.css', 'rsc_url');
    // Basic styles
    require_css('blog_base.css', 'rsc_url');
    // Default styles for the blog navigation
    require_css('item_base.css', 'rsc_url');
Example #30
0
            $success_message = T_('Your comment is now visible by the blog members.');
            break;
        case 'review':
            if (is_logged_in() && $current_User->check_perm('blog_comment!review', 'create', false, $blog)) {
                $success_message = T_('Your comment is now visible by moderators only (+You).');
                break;
            }
        default:
            $success_message = T_('Your comment has been submitted. It will appear once it has been approved.');
            break;
    }
    $Messages->add($success_message, 'success');
    if (!is_logged_in()) {
        if ($Settings->get('newusers_canregister') == 'yes' && $Settings->get('registration_is_public') && $Comment->Item->Blog->get_setting('comments_register')) {
            // Redirect to the registration form
            $Messages->add(T_('ATTENTION: Create a user account now so that other users can contact you after reading your comment.'), 'error');
            $register_user = array('name' => $Comment->author, 'email' => $Comment->author_email);
            $Session->set('core.register_user', $register_user);
            header_redirect(get_user_register_url($Comment->Item->get_url('public_view'), 'reg after comment', false, '&'));
        }
        // Not logged in user. We want him to see his comment has not vanished if he checks back on the Item page
        // before the cache has expired. Invalidate cache for that page:
        // Note: this is approximative and may not cover all URLs where the user expects to see the comment...
        // TODO: fp> solution: touch dates?
        load_class('_core/model/_pagecache.class.php', 'PageCache');
        $PageCache = new PageCache($Comment->Item->Blog);
        $PageCache->invalidate($Comment->Item->get_single_url());
    }
}
header_redirect();
// Will save $Messages into Session