コード例 #1
0
ファイル: Page.php プロジェクト: ircoco/BlackCatCMS
 /**
  * identify the page to show
  *
  * @access public
  * @param  boolean  $no_intro
  * @return boolean
  **/
 public static function selectPage($no_intro = false)
 {
     global $page_id;
     // may be set by accessor file
     // check if the system is in maintenance mode
     if (self::isMaintenance()) {
         // admin can still see any page
         if (!CAT_Users::getInstance()->is_root()) {
             if (!CAT_Registry::exists('MAINTENANCE_PAGE')) {
                 $result = CAT_Registry::getInstance()->db()->query('SELECT `value` FROM `:prefix:settings` WHERE `name`="maintenance_page"');
                 if (is_resource($result) && $result->rowCount() == 1) {
                     $row = $result->fetch();
                     CAT_Registry::register('MAINTENANCE_PAGE', $row['maintenance_page'], true);
                 }
             }
             $page_id = MAINTENANCE_PAGE;
         }
     }
     // check if intro page to show
     if (INTRO_PAGE && !$no_intro && (!isset($page_id) || !is_numeric($page_id))) {
         // Get intro page content
         $filename = CAT_PATH . PAGES_DIRECTORY . '/intro' . PAGE_EXTENSION;
         if (file_exists($filename)) {
             $handle = @fopen($filename, "r");
             $content = @fread($handle, filesize($filename));
             @fclose($handle);
             CAT_Helper_Page::preprocess($content);
             header("Location: " . CAT_URL . PAGES_DIRECTORY . "/intro" . PAGE_EXTENSION . "");
             // send intro.php as header to allow parsing of php statements
             echo $content;
             return false;
         }
     }
     // search
     if (!$page_id) {
         if (CAT_Registry::get('USE_SHORT_URLS') && isset($_SERVER['REDIRECT_QUERY_STRING'])) {
             $page_id = CAT_Helper_Page::getPageByPath('/' . $_SERVER['REDIRECT_QUERY_STRING']);
         } else {
             $page_id = self::getDefaultPage();
         }
     }
     if (!defined('PAGE_ID')) {
         define('PAGE_ID', $page_id);
     }
     return $page_id;
 }