Exemple #1
0
 public function rebuildHash($pageId)
 {
     if (is_object($this->_constData)) {
         ob_start();
         $page = new PageReCacher($pageId, $this->dbName);
         $pageHandler = new RealPageHandler($this->localPath, $this->dbName);
         $pageHandler->printPage();
         $content = ob_get_contents();
         ob_clean();
         if (!empty($content)) {
             $hash = md5($content);
             if ($hash != $page->checksum) {
                 $page->refreshLastmodify($hash);
             }
         }
         unset($page, $pageHandler);
         return TRUE;
     }
 }
Exemple #2
0
 public function clearCachePage($pageId)
 {
     if (is_object($this->_constData) && $this->isValidFS) {
         //	        if (VBox::isExist('Page'))
         //				$page = VBox::get('Page');
         //			else
         //			{
         $page = new PageReCacher($pageId);
         //				VBox::set('Page', $page);
         //			}
         $uri_address = $page->address['uri_address'];
         $path_parts = pathinfo($uri_address);
         $dirname = isset($path_parts['dirname']) ? $path_parts['dirname'] : '';
         $filename = isset($path_parts['filename']) ? $path_parts['filename'] : '';
         $extension = isset($path_parts['extension']) ? $path_parts['extension'] : '';
         if (!substr_count($uri_address, '.html')) {
             $dirname = $this->cachePath . 'cache' . (substr($uri_address, 0, 1) != '/' ? '/' : '') . $uri_address . (substr($uri_address, -1) != '/' ? '/' : '');
             $filename = 'index';
             $extension = '.html';
         } else {
             $dirname = $this->cachePath . 'cache' . (substr($dirname, 0, 1) != '/' ? '/' : '') . $dirname . (substr($dirname, -1) != '/' ? '/' : '');
             $filename .= '.';
         }
         $cache_uri_address = $dirname . $filename . $extension;
         if (file_exists($cache_uri_address)) {
             if (unlink($cache_uri_address) === FALSE) {
                 $this->cacheLog['error'][] = 'Page "' . $page->address['uri_address'] . '" (' . $pageId . '): unable to clear file at path "' . $cache_uri_address . '"';
             } else {
                 $page->refreshLastmodify('');
                 $this->cacheLog['event'][] = 'Page "' . $page->address['uri_address'] . '" (' . $pageId . '): succesfuly clear cache at ' . date('d/m/Y H:i:s');
             }
         } else {
             $this->cacheLog['error'][] = 'Page "' . $page->address['uri_address'] . '" (' . $pageId . '): cache file not exists "' . $cache_uri_address . '"';
         }
         unset($page, $pageHandler);
         return !(bool) sizeof($this->cacheLog['error']);
     }
     return FALSE;
 }