예제 #1
0
 /**
  * 检验规则是否冲突
  *
  * @access public
  * @param string $value 路由规则
  * @return boolean
  */
 public function checkRule($value)
 {
     if ('custom' != $value) {
         return true;
     }
     $routingTable = $this->options->routingTable;
     $currentTable = array('custom' => array('url' => $this->encodeRule($this->request->customPattern)));
     $parser = new Typecho_Router_Parser($currentTable);
     $currentTable = $parser->parse();
     $regx = $currentTable['custom']['regx'];
     foreach ($routingTable as $key => $val) {
         if ('post' != $key && 'page' != $key) {
             $pathInfo = preg_replace("/\\[([_a-z0-9-]+)[^\\]]*\\]/i", "{\\1}", $val['url']);
             $pathInfo = str_replace(array('{cid}', '{slug}', '{category}', '{year}', '{month}', '{day}', '{', '}'), array('123', 'hello', 'default', '2008', '08', '08', '', ''), $pathInfo);
             if (preg_match($regx, $pathInfo)) {
                 return false;
             }
         }
     }
     return true;
 }
예제 #2
0
 /**
  * 设置路由器默认配置
  *
  * @access public
  * @param mixed $routes 配置信息
  * @return void
  */
 public static function setRoutes($routes)
 {
     /** 载入路由解析支持 */
     require_once 'Typecho/Router/Parser.php';
     if (isset($routes[0])) {
         self::$_routingTable = $routes[0];
     } else {
         /** 解析路由配置 */
         $parser = new Typecho_Router_Parser($routes);
         self::$_routingTable = $parser->parse();
     }
 }
예제 #3
0
 /**
  * 设置路由器默认配置
  *
  * @access public
  * @param mixed $routes 配置信息
  * @return void
  */
 public static function setRoutes($routes)
 {
     if (isset($routes[0])) {
         self::$_routingTable = $routes[0];
     } else {
         /** 解析路由配置 */
         $parser = new Typecho_Router_Parser($routes);
         self::$_routingTable = $parser->parse();
     }
 }
예제 #4
0
파일: Options.php 프로젝트: veryer/sisome
 /**
  * 执行函数
  *
  * @access public
  * @return void
  */
 public function execute()
 {
     $this->db->fetchAll($this->db->select()->from('table.options')->where('user = 0'), array($this, 'push'));
     /** 支持皮肤变量重载 */
     if (!empty($this->row['theme:' . $this->row['theme']])) {
         $themeOptions = NULL;
         /** 解析变量 */
         if ($themeOptions = unserialize($this->row['theme:' . $this->row['theme']])) {
             /** 覆盖变量 */
             $this->row = array_merge($this->row, $themeOptions);
         }
     }
     $this->stack[] =& $this->row;
     /** 初始化站点信息 */
     if (defined('__TYPECHO_SITE_URL__')) {
         $this->siteUrl = __TYPECHO_SITE_URL__;
     }
     $this->originalSiteUrl = $this->siteUrl;
     $this->siteUrl = Typecho_Common::url(NULL, $this->siteUrl);
     $this->plugins = unserialize($this->plugins);
     /** 动态判断皮肤目录 */
     $this->theme = is_dir($this->themeFile($this->theme)) ? $this->theme : 'default';
     /** 动态获取根目录 */
     $this->rootUrl = $this->request->getRequestRoot();
     if (defined('__TYPECHO_ADMIN__')) {
         $adminDir = '/' . trim(defined('__TYPECHO_ADMIN_DIR__') ? __TYPECHO_ADMIN_DIR__ : '/admin/', '/');
         $this->rootUrl = substr($this->rootUrl, 0, -strlen($adminDir));
     }
     /** 增加对SSL连接的支持 */
     if ($this->request->isSecure() && 0 === strpos($this->siteUrl, 'http://')) {
         $this->siteUrl = substr_replace($this->siteUrl, 'https', 0, 4);
     }
     //$router = include __TYPECHO_ROOT_DIR__.'/var/config.php';
     //$parser = new Typecho_Router_Parser($router);
     //$parsedRoutingTable = $parser->parse();
     //$this->routingTable = array($parsedRoutingTable);
     /** 自动初始化路由表 */
     $this->routingTable = unserialize($this->routingTable);
     if (!isset($this->routingTable[0])) {
         /** 解析路由并缓存 */
         $parser = new Typecho_Router_Parser($this->routingTable);
         $parsedRoutingTable = $parser->parse();
         $this->routingTable = array_merge(array($parsedRoutingTable), $this->routingTable);
         $this->db->query($this->db->update('table.options')->rows(array('value' => serialize($this->routingTable)))->where('name = ?', 'routingTable'));
     }
 }
예제 #5
0
 /**
  * 执行函数
  *
  * @access public
  * @return void
  */
 public function execute()
 {
     $this->db->fetchAll($this->db->select()->from('table.options')->where('user = 0'), array($this, 'push'));
     /** 支持皮肤变量重载 */
     if (!empty($this->row['theme:' . $this->row['theme']])) {
         $themeOptions = NULL;
         /** 解析变量 */
         if ($themeOptions = unserialize($this->row['theme:' . $this->row['theme']])) {
             /** 覆盖变量 */
             $this->row = array_merge($this->row, $themeOptions);
         }
     }
     $this->stack[] =& $this->row;
     /** 初始化站点信息 */
     $this->siteUrl = Typecho_Common::url(NULL, $this->siteUrl);
     $this->plugins = unserialize($this->plugins);
     /** 增加对SSL连接的支持 */
     if ($this->request->isSecure() && 0 === strpos($this->siteUrl, 'http://')) {
         $this->siteUrl = substr_replace($this->siteUrl, 'https', 0, 4);
     }
     /** 自动初始化路由表 */
     $this->routingTable = unserialize($this->routingTable);
     if (!isset($this->routingTable[0])) {
         /** 解析路由并缓存 */
         $parser = new Typecho_Router_Parser($this->routingTable);
         $parsedRoutingTable = $parser->parse();
         $this->routingTable = array_merge(array($parsedRoutingTable), $this->routingTable);
         $this->db->query($this->db->update('table.options')->rows(array('value' => serialize($this->routingTable)))->where('name = ?', 'routingTable'));
     }
 }