public function rebuildCachePageAdress($pageId) { if ($this->loginPage == $pageId) { return true; } if (is_object($this->_constData) && $this->isValidFS) { $page = new PageReCacher($pageId); if (!$page->checkHidden()) { ob_start(); $agregator = new Agregator($pageId); $agregator->process(); $content = ob_get_contents(); ob_clean(); /* if (VBox::isExist('Page')) $page = VBox::get('Page'); else { $page = new PageReCacher($pageId); // VBox::set('Page', $page); } */ if ($page->checkCacheable()) { if (!empty($content)) { $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 .= '.'; } if (!file_exists($dirname)) { mkdir($dirname, 0775, true); } $cache_uri_address = $dirname . $filename . $extension; if (file_put_contents($cache_uri_address, $content) === FALSE) { $this->cacheLog['error'][] = 'Page "' . $page->address['uri_address'] . '" (' . $pageId . '): unable to create file at path "' . $cache_uri_address . '"'; } else { chmod($cache_uri_address, 0664); $hash = md5($content); if ($hash != $page->checksum) { $page->refreshLastmodify($hash); $this->cacheLog['event'][] = 'Page "' . $page->address['uri_address'] . '" (' . $pageId . '): succesfuly modified at ' . date('d/m/Y H:i:s'); } } } else { $this->cacheLog['event'][] = 'Page "' . $page->address['uri_address'] . '" (' . $pageId . '): reseive empty content while rebuilding page.'; } } else { $this->cacheLog['event'][] = 'Page "' . $page->address['uri_address'] . '" (' . $pageId . '): is not cacheble.'; } } else { $this->cacheLog['event'][] = 'Page "' . $page->address['uri_address'] . '" (' . $pageId . '): is hiden.'; } unset($page, $pageHandler); // return $this->flushLog(); return !(bool) sizeof($this->cacheLog['error']); } return FALSE; }