Example #1
0
 public function mygetPageContent($args)
 {
     $reg_exp = '#<body>(.*?)<\\/body>#si';
     if (VBox::isExist('Page')) {
         $old_page = @VBox::get('Page');
     }
     $pageId = (int) $args[0];
     //		var_dump($pageId);
     $page = new Page($pageId);
     //		var_dump($page->checkHidden());
     if ($page && !$page->checkHidden()) {
         $page->dropAllHeaders();
         ob_start();
         $agregator = new Agregator($pageId);
         $agregator->process(true);
         $content = ob_get_contents();
         ob_clean();
         if (!is_null($old_page)) {
             VBox::set('Page', $old_page);
         }
         if (!isset($args[1]) && preg_match($reg_exp, $content, $matches)) {
             return $matches[1];
         }
         return $content;
     }
 }
Example #2
0
            echo ' <h2>' . $item->title . '</h2>';
            echo ' <p>' . $item->description . '</p>';
            echo '</div>';
        }
        echo '</div>';
    }
}
?>
 
<!DOCTYPE html>
<html>
 <head>
 <title>Wiadomości z RSS</title>
 <link rel="stylesheet" href="style.css">
 <meta charset="utf-8"> 
 </head>
 <body>
 <?php 
try {
    if (class_exists('SimpleXMLElement')) {
        $agregator = new Agregator();
        $agregator->pobierz();
    } else {
        throw new Exception('Brak obsługi SimpleXML.');
    }
} catch (Exception $e) {
    echo $e->getMessage();
}
?>
 </body>
</html>
Example #3
0
 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;
 }
Example #4
0
        if (isset($matched[1])) {
            header('HTTP/1.1 301 Moved Permanently');
            header('Location: //' . $_SERVER['HTTP_HOST'] . '/' . $matched[1] . '.html');
            include_once LOCAL_PATH . 'application/final.inc.php';
            exit;
        }
    }
}
if ($constData->getConst('siteClosed') && $constData->getConst('realDomain') != $_SERVER['HTTP_HOST']) {
    header('HTTP/1.1 302 Found');
    header('Location: ' . $constData->getConst('maintainPage'));
    include_once LOCAL_PATH . 'application/final.inc.php';
    exit;
}
// создаем Агрегатор
$agregator = new Agregator();
// запускаем
$process = $agregator->process();
// если pageId не найден, и не найдено совпадений в greenList-ах - редирект на 404
if ($process === FALSE) {
    //Error::mail404($request);
    //header('HTTP/1.1 301 Moved Permanently');
    //header('Location: //'.$_SERVER['HTTP_HOST'].$constData->getConst('404page'));
    header('HTTP/1.1 404 Not Found');
    $uri_address = $_SERVER['DOCUMENT_ROOT'] . '/cache/cache/404.html';
    echo file_get_contents($uri_address, FALSE);
    include_once LOCAL_PATH . 'application/final.inc.php';
    exit;
    /*		Error::mail404($request);
    		header('HTTP/1.1 404 Not Found');
    		include_once(LOCAL_PATH.$constData->getConst('404page'));