示例#1
0
function show_lighttpd()
{
    $ur = new UrlRule("");
    if (method_exists('UrlRule', 'Make_lighttpd')) {
        return $ur->Make_lighttpd();
    }
}
示例#2
0
文件: tag.php 项目: zblogcn/zblogphp
 /**
  * @param $name
  * @return mixed|string
  */
 public function __get($name)
 {
     global $zbp;
     if ($name == 'Url') {
         foreach ($GLOBALS['hooks']['Filter_Plugin_Tag_Url'] as $fpname => &$fpsignal) {
             $fpsignal = PLUGIN_EXITSIGNAL_NONE;
             $fpreturn = $fpname($this);
             if ($fpsignal == PLUGIN_EXITSIGNAL_RETURN) {
                 return $fpreturn;
             }
         }
         $backAttr = $zbp->option['ZC_ALIAS_BACK_ATTR'];
         $u = new UrlRule($zbp->option['ZC_TAGS_REGEX']);
         $u->Rules['{%id%}'] = $this->ID;
         $u->Rules['{%alias%}'] = rawurlencode($this->Alias == '' ? $this->{$backAttr} : $this->Alias);
         return $u->Make();
     }
     if ($name == 'Template') {
         $value = $this->data[$name];
         if ($value == '') {
             $value = $zbp->option['ZC_INDEX_DEFAULT_TEMPLATE'];
         }
         return $value;
     }
     return parent::__get($name);
 }
示例#3
0
 public function parseRequest($request)
 {
     $rule = new UrlRule();
     $result = $rule->parseRequest($this, $request);
     if ($result !== false) {
         return $result;
     } else {
         exit("error:" . __FILE__ . __LINE__);
     }
 }
示例#4
0
 private function generateAndMatch($url, $regex, $type, $hasPage = false)
 {
     $m = [];
     $r = UrlRule::OutputUrlRegEx($regex, $type, $hasPage);
     preg_match($r, $url, $m);
     return $m;
 }
示例#5
0
 /**
  * 构造分页条
  * @return null
  */
 public function Make()
 {
     global $zbp;
     if ($this->PageCount == 0) {
         return null;
     }
     $this->PageAll = ceil($this->Count / $this->PageCount);
     $this->PageFirst = 1;
     $this->PageLast = $this->PageAll;
     $this->PagePrevious = $this->PageNow - 1;
     if ($this->PagePrevious < 1) {
         $this->PagePrevious = 1;
     }
     $this->PageNext = $this->PageNow + 1;
     if ($this->PageNext > $this->PageAll) {
         $this->PageNext = $this->PageAll;
     }
     $this->UrlRule->Rules['{%page%}'] = $this->PageFirst;
     $this->buttons['‹‹'] = $this->UrlRule->Make();
     if ($this->PageNow != $this->PageFirst) {
         $this->UrlRule->Rules['{%page%}'] = $this->PagePrevious;
         $this->buttons['‹'] = $this->UrlRule->Make();
         $this->prevbutton = $this->buttons['‹'];
     }
     $j = $this->PageNow;
     if ($j + $this->PageBarCount > $this->PageAll) {
         $j = $this->PageAll - $this->PageBarCount + 1;
     }
     if ($j < 1) {
         $j = 1;
     }
     for ($i = $j; $i < $j + $this->PageBarCount; $i++) {
         if ($i > $this->PageAll) {
             break;
         }
         $this->UrlRule->Rules['{%page%}'] = $i;
         $this->buttons[$i] = $this->UrlRule->Make();
     }
     if ($this->PageNow != $this->PageNext) {
         $this->UrlRule->Rules['{%page%}'] = $this->PageNext;
         $this->buttons['›'] = $this->UrlRule->Make();
         $this->nextbutton = $this->buttons['›'];
     }
     $this->UrlRule->Rules['{%page%}'] = $this->PageLast;
     $this->buttons['››'] = $this->UrlRule->Make();
 }
示例#6
0
 public function __get($name)
 {
     global $zbp;
     if ($name == 'Url') {
         $u = new UrlRule($zbp->option['ZC_AUTHOR_REGEX']);
         $u->Rules['{%id%}'] = $this->ID;
         $u->Rules['{%alias%}'] = $this->Alias == '' ? urlencode($this->Name) : $this->Alias;
         return $u->Make();
     }
     if ($name == 'Avatar') {
         foreach ($GLOBALS['Filter_Plugin_Mebmer_Avatar'] as $fpname => &$fpsignal) {
             $fpreturn = $fpname($this);
             if ($fpreturn) {
                 return $fpreturn;
             }
         }
         if ($this->_avatar) {
             return $this->_avatar;
         }
         $s = $zbp->usersdir . 'avatar/' . $this->ID . '.png';
         if (file_exists($s)) {
             $this->_avatar = $zbp->host . 'zb_users/avatar/' . $this->ID . '.png';
             return $this->_avatar;
         }
         $this->_avatar = $zbp->host . 'zb_users/avatar/0.png';
         return $this->_avatar;
     }
     if ($name == 'LevelName') {
         return $zbp->lang['user_level_name'][$this->Level];
     }
     if ($name == 'EmailMD5') {
         return md5($this->Email);
     }
     if ($name == 'Meta') {
         return $this->Metas->serialize();
     }
     if ($name == 'Template') {
         $value = $this->data[$name];
         if ($value == '') {
             $value = $zbp->option['ZC_INDEX_DEFAULT_TEMPLATE'];
         }
         return $value;
     }
     return parent::__get($name);
 }
示例#7
0
 public function __get($name)
 {
     global $zbp;
     if ($name == 'Url') {
         $u = new UrlRule($zbp->option['ZC_TAGS_REGEX']);
         $u->Rules['{%id%}'] = $this->ID;
         $u->Rules['{%alias%}'] = $this->Alias == '' ? urlencode($this->Name) : $this->Alias;
         return $u->Make();
     }
     if ($name == 'Template') {
         $value = $this->Data[$name];
         if ($value == '') {
             $value = $zbp->option['ZC_INDEX_DEFAULT_TEMPLATE'];
         }
         return $value;
     }
     return parent::__get($name);
 }
示例#8
0
 public function __get($name)
 {
     global $zbp;
     switch ($name) {
         case 'Category':
             return $zbp->GetCategoryByID($this->CateID);
             break;
         case 'Author':
             return $zbp->GetMemberByID($this->AuthorID);
             break;
         case 'StatusName':
             return $zbp->lang['post_status_name'][$this->Status];
             break;
         case 'Url':
             if ($this->Type == ZC_POST_TYPE_ARTICLE) {
                 $u = new UrlRule($zbp->option['ZC_ARTICLE_REGEX']);
             } else {
                 $u = new UrlRule($zbp->option['ZC_PAGE_REGEX']);
             }
             $u->Rules['{%id%}'] = $this->ID;
             if ($this->Alias) {
                 $u->Rules['{%alias%}'] = $this->Alias;
             } else {
                 $u->Rules['{%alias%}'] = urlencode($this->Title);
             }
             $u->Rules['{%year%}'] = $this->Time('Y');
             $u->Rules['{%month%}'] = $this->Time('m');
             $u->Rules['{%day%}'] = $this->Time('d');
             if ($this->Category->Alias) {
                 $u->Rules['{%category%}'] = $this->Category->Alias;
             } else {
                 $u->Rules['{%category%}'] = urlencode($this->Category->Name);
             }
             if ($this->Author->Alias) {
                 $u->Rules['{%author%}'] = $this->Author->Alias;
             } else {
                 $u->Rules['{%author%}'] = urlencode($this->Author->Name);
             }
             return $u->Make();
             break;
         case 'Tags':
             return $zbp->LoadTagsByIDString($this->Tag);
             break;
         case 'TagsCount':
             return substr_count($this->Tag, '{');
             break;
         case 'TagsName':
             return $this->TagsToNameString;
         case 'Template':
             $value = $this->Data[$name];
             if ($value == '') {
                 $value = GetValueInArray($this->Category->GetDataArray(), 'LogTemplate');
                 if ($value == '') {
                     $value = $zbp->option['ZC_POST_DEFAULT_TEMPLATE'];
                 }
             }
             return $value;
         case 'CommentPostUrl':
             foreach ($GLOBALS['Filter_Plugin_Post_CommentPostUrl'] as $fpname => &$fpsignal) {
                 $fpreturn = $fpname($this);
                 if ($fpreturn) {
                     return $fpreturn;
                 }
             }
             $key = '&amp;key=' . md5($zbp->guid . $this->ID . date('Y-m-d'));
             return $zbp->host . 'zb_system/cmd.php?act=cmt&amp;postid=' . $this->ID . $key;
             break;
         case 'ValidCodeUrl':
             return $zbp->validcodeurl . '?id=cmt';
             break;
         case 'Prev':
             static $_prev = null;
             if ($_prev !== null) {
                 return $_prev;
             }
             $articles = $zbp->GetPostList(array('*'), array(array('=', 'log_Type', 0), array('=', 'log_Status', 0), array('<', 'log_PostTime', $this->PostTime)), array('log_PostTime' => 'DESC'), array(1), null);
             if (count($articles) == 1) {
                 $_prev = $articles[0];
             } else {
                 $_prev = '';
             }
             return $_prev;
             break;
         case 'Next':
             static $_next = null;
             if ($_next !== null) {
                 return $_next;
             }
             $articles = $zbp->GetPostList(array('*'), array(array('=', 'log_Type', 0), array('=', 'log_Status', 0), array('>', 'log_PostTime', $this->PostTime)), array('log_PostTime' => 'ASC'), array(1), null);
             if (count($articles) == 1) {
                 $_next = $articles[0];
             } else {
                 $_next = '';
             }
             return $_next;
             break;
         default:
             return parent::__get($name);
             break;
     }
 }
 /**
  * @test
  * @dataProvider testDataProvider
  */
 public function isValid($data, $expected)
 {
     $rule = new UrlRule();
     $this->assertEquals($expected, $rule->isValid($data));
 }
示例#10
0
function BuildModule_archives()
{
    global $zbp;
    $fdate;
    $ldate;
    $sql = $zbp->db->sql->Select($zbp->table['Post'], array('log_PostTime'), null, array('log_PostTime' => 'DESC'), array(1), null);
    $array = $zbp->db->Query($sql);
    if (count($array) == 0) {
        return '';
    }
    $ldate = array(date('Y', $array[0]['log_PostTime']), date('m', $array[0]['log_PostTime']));
    $sql = $zbp->db->sql->Select($zbp->table['Post'], array('log_PostTime'), null, array('log_PostTime' => 'ASC'), array(1), null);
    $array = $zbp->db->Query($sql);
    if (count($array) == 0) {
        return '';
    }
    $fdate = array(date('Y', $array[0]['log_PostTime']), date('m', $array[0]['log_PostTime']));
    $arraydate = array();
    for ($i = $fdate[0]; $i < $ldate[0] + 1; $i++) {
        for ($j = 1; $j < 13; $j++) {
            $arraydate[] = strtotime($i . '-' . $j);
        }
    }
    foreach ($arraydate as $key => $value) {
        if ($value - strtotime($ldate[0] . '-' . $ldate[1]) > 0) {
            unset($arraydate[$key]);
        }
        if ($value - strtotime($fdate[0] . '-' . $fdate[1]) < 0) {
            unset($arraydate[$key]);
        }
    }
    $arraydate = array_reverse($arraydate);
    $s = '';
    foreach ($arraydate as $key => $value) {
        $url = new UrlRule($zbp->option['ZC_DATE_REGEX']);
        $url->Rules['{%date%}'] = date('Y-n', $value);
        $url->Rules['{%year%}'] = date('Y', $value);
        $url->Rules['{%month%}'] = date('n', $value);
        $url->Rules['{%day%}'] = 1;
        $fdate = $value;
        $ldate = strtotime(date('Y-m-t', $value)) + 60 * 60 * 24;
        $sql = $zbp->db->sql->Count($zbp->table['Post'], array(array('COUNT', '*', 'num')), array(array('=', 'log_Type', '0'), array('=', 'log_Status', '0'), array('BETWEEN', 'log_PostTime', $fdate, $ldate)));
        $n = GetValueInArrayByCurrent($zbp->db->Query($sql), 'num');
        if ($n > 0) {
            $s .= '<li><a href="' . $url->Make() . '">' . str_replace(array('%y%', '%m%'), array(date('Y', $fdate), date('n', $fdate)), $zbp->lang['msg']['year_month']) . ' (' . $n . ')</a></li>';
        }
    }
    return $s;
}
示例#11
0
 /**
  * @param $name
  * @return int|mixed|null|string
  */
 public function __get($name)
 {
     global $zbp;
     if ($name == 'Url') {
         $u = new UrlRule($zbp->option['ZC_CATEGORY_REGEX']);
         $u->Rules['{%id%}'] = $this->ID;
         $u->Rules['{%alias%}'] = $this->Alias == '' ? urlencode($this->Name) : $this->Alias;
         return $u->Make();
     }
     if ($name == 'Symbol') {
         if ($this->ParentID == 0) {
             return;
         } else {
             $l = $this->Level;
             if ($l == 1) {
                 return '&nbsp;└';
             } elseif ($l == 2) {
                 return '&nbsp;&nbsp;&nbsp;└';
             } elseif ($l == 3) {
                 return '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;└';
             }
             return;
         }
     }
     if ($name == 'Level') {
         if ($this->ParentID == 0) {
             $this->RootID = 0;
             return 0;
         }
         if ($zbp->categorys[$this->ParentID]->ParentID == 0) {
             $this->RootID = $this->ParentID;
             return 1;
         }
         if ($zbp->categorys[$zbp->categorys[$this->ParentID]->ParentID]->ParentID == 0) {
             $this->RootID = $zbp->categorys[$this->ParentID]->ParentID;
             return 2;
         }
         if ($zbp->categorys[$zbp->categorys[$zbp->categorys[$this->ParentID]->ParentID]->ParentID]->ParentID == 0) {
             $this->RootID = $zbp->categorys[$zbp->categorys[$this->ParentID]->ParentID]->ParentID;
             return 3;
         }
         return 0;
     }
     if ($name == 'SymbolName') {
         return $this->Symbol . htmlspecialchars($this->Name);
     }
     if ($name == 'Parent') {
         if ($this->ParentID == 0) {
             return null;
         } else {
             return $zbp->categorys[$this->ParentID];
         }
     }
     if ($name == 'Template') {
         $value = $this->data[$name];
         if ($value == '') {
             $value = $zbp->option['ZC_INDEX_DEFAULT_TEMPLATE'];
         }
         return $value;
     }
     if ($name == 'LogTemplate') {
         $value = $this->data[$name];
         if ($value == '') {
             $value = $zbp->option['ZC_POST_DEFAULT_TEMPLATE'];
         }
         return $value;
     }
     return parent::__get($name);
 }
示例#12
0
文件: post.php 项目: zblogcn/zblogphp
 /**
  * @param $name
  * @return array|int|mixed|null|string
  */
 public function __get($name)
 {
     global $zbp;
     switch ($name) {
         case 'Category':
             return $zbp->GetCategoryByID($this->CateID);
             break;
         case 'Author':
             return $zbp->GetMemberByID($this->AuthorID);
             break;
         case 'StatusName':
             return $zbp->lang['post_status_name'][$this->Status];
             break;
         case 'Url':
             foreach ($GLOBALS['hooks']['Filter_Plugin_Post_Url'] as $fpname => &$fpsignal) {
                 $fpsignal = PLUGIN_EXITSIGNAL_NONE;
                 $fpreturn = $fpname($this);
                 if ($fpsignal == PLUGIN_EXITSIGNAL_RETURN) {
                     return $fpreturn;
                 }
             }
             $u = new UrlRule($zbp->GetPostType_UrlRule($this->Type));
             $u->Rules['{%id%}'] = $this->ID;
             if ($this->Alias) {
                 $u->Rules['{%alias%}'] = $this->Alias;
             } else {
                 if ($zbp->option['ZC_POST_ALIAS_USE_ID_NOT_TITLE'] == false) {
                     $u->Rules['{%alias%}'] = rawurlencode($this->Title);
                 } else {
                     $u->Rules['{%alias%}'] = $this->ID;
                 }
             }
             $u->Rules['{%year%}'] = $this->Time('Y');
             $u->Rules['{%month%}'] = $this->Time('m');
             $u->Rules['{%day%}'] = $this->Time('d');
             if ($this->Category->Alias) {
                 $u->Rules['{%category%}'] = $this->Category->Alias;
             } else {
                 $u->Rules['{%category%}'] = rawurlencode($this->Category->Name);
             }
             if ($this->Author->Alias) {
                 $u->Rules['{%author%}'] = $this->Author->Alias;
             } else {
                 $u->Rules['{%author%}'] = rawurlencode($this->Author->Name);
             }
             return $u->Make();
             break;
         case 'Tags':
             return $zbp->LoadTagsByIDString($this->Tag);
             break;
         case 'TagsCount':
             return substr_count($this->Tag, '{');
             break;
         case 'TagsName':
             return $this->TagsToNameString();
         case 'Template':
             $value = $this->data[$name];
             if ($value == '') {
                 $value = GetValueInArray($this->Category->GetData(), 'LogTemplate');
                 if ($value == '') {
                     $value = $zbp->GetPostType_Template($this->Type);
                 }
             }
             return $value;
         case 'CommentPostUrl':
             foreach ($GLOBALS['hooks']['Filter_Plugin_Post_CommentPostUrl'] as $fpname => &$fpsignal) {
                 $fpreturn = $fpname($this);
                 if ($fpsignal == PLUGIN_EXITSIGNAL_RETURN) {
                     $fpsignal = PLUGIN_EXITSIGNAL_NONE;
                     return $fpreturn;
                 }
             }
             $key = '&amp;key=' . $zbp->GetCmtKey($this->ID);
             return $zbp->host . 'zb_system/cmd.php?act=cmt&amp;postid=' . $this->ID . $key;
             break;
         case 'ValidCodeUrl':
             return $zbp->validcodeurl . '?id=cmt';
             break;
         case 'Prev':
             if ($this->_prev !== '') {
                 return $this->_prev;
             }
             foreach ($GLOBALS['hooks']['Filter_Plugin_Post_Prev'] as $fpname => &$fpsignal) {
                 $this->_prev = $fpname($this);
                 if ($this->_prev !== '') {
                     return $this->_prev;
                 }
             }
             $articles = $zbp->GetPostList(array('*'), array(array('=', 'log_Type', 0), array('=', 'log_Status', 0), array('<', 'log_PostTime', $this->PostTime)), array('log_PostTime' => 'DESC'), array(1), null);
             if (count($articles) == 1) {
                 $this->_prev = $articles[0];
             } else {
                 $this->_prev = null;
             }
             return $this->_prev;
             break;
         case 'Next':
             if ($this->_next !== '') {
                 return $this->_next;
             }
             foreach ($GLOBALS['hooks']['Filter_Plugin_Post_Next'] as $fpname => &$fpsignal) {
                 $this->_prev = $fpname($this);
                 if ($this->_prev !== '') {
                     return $this->_prev;
                 }
             }
             $articles = $zbp->GetPostList(array('*'), array(array('=', 'log_Type', 0), array('=', 'log_Status', 0), array('>', 'log_PostTime', $this->PostTime)), array('log_PostTime' => 'ASC'), array(1), null);
             if (count($articles) == 1) {
                 $this->_next = $articles[0];
             } else {
                 $this->_next = null;
             }
             return $this->_next;
             break;
         case 'RelatedList':
             foreach ($GLOBALS['hooks']['Filter_Plugin_Post_RelatedList'] as $fpname => &$fpsignal) {
                 $fpreturn = $fpname($this);
                 if ($fpsignal == PLUGIN_EXITSIGNAL_RETURN) {
                     $fpsignal = PLUGIN_EXITSIGNAL_NONE;
                     return $fpreturn;
                 }
             }
             return GetList($zbp->option['ZC_RELATEDLIST_COUNT'], null, null, null, null, null, array('is_related' => $this->ID));
         case 'TopType':
             $toptype = $this->Metas->toptype;
             if ($this->IsTop == true && $toptype == null) {
                 $toptype = 'index';
             }
             return $toptype;
         case 'TypeName':
             return $zbp->GetPostType_Name($this->Type);
         default:
             return parent::__get($name);
             break;
     }
 }
示例#13
0
 /**
  * 导出文章归档模块数据
  * @return string 模块内容
  */
 public static function Archives()
 {
     global $zbp;
     $template = $zbp->template;
     $tags = array();
     $urls = array();
     //array(url,name,count);
     $maxli = $zbp->modulesbyfilename['archives']->MaxLi;
     if ($maxli < 0) {
         return '';
     }
     $sql = $zbp->db->sql->Select($zbp->table['Post'], array('log_PostTime'), null, array('log_PostTime' => 'DESC'), array(1), null);
     $array = $zbp->db->Query($sql);
     if (count($array) == 0) {
         return '';
     }
     $ldate = array(date('Y', $array[0]['log_PostTime']), date('m', $array[0]['log_PostTime']));
     $sql = $zbp->db->sql->Select($zbp->table['Post'], array('log_PostTime'), null, array('log_PostTime' => 'ASC'), array(1), null);
     $array = $zbp->db->Query($sql);
     if (count($array) == 0) {
         return '';
     }
     $fdate = array(date('Y', $array[0]['log_PostTime']), date('m', $array[0]['log_PostTime']));
     $arraydate = array();
     for ($i = $fdate[0]; $i < $ldate[0] + 1; $i++) {
         for ($j = 1; $j < 13; $j++) {
             $arraydate[] = strtotime($i . '-' . $j);
         }
     }
     foreach ($arraydate as $key => $value) {
         if ($value - strtotime($ldate[0] . '-' . $ldate[1]) > 0) {
             unset($arraydate[$key]);
         }
         if ($value - strtotime($fdate[0] . '-' . $fdate[1]) < 0) {
             unset($arraydate[$key]);
         }
     }
     $arraydate = array_reverse($arraydate);
     $s = '';
     $i = 0;
     foreach ($arraydate as $key => $value) {
         if ($i >= $maxli && $maxli > 0) {
             break;
         }
         $url = new UrlRule($zbp->option['ZC_DATE_REGEX']);
         $url->Rules['{%date%}'] = date('Y-n', $value);
         $url->Rules['{%year%}'] = date('Y', $value);
         $url->Rules['{%month%}'] = date('n', $value);
         $url->Rules['{%day%}'] = 1;
         $fdate = $value;
         $ldate = strtotime(date('Y-m-t', $value)) + 60 * 60 * 24;
         $sql = $zbp->db->sql->Count($zbp->table['Post'], array(array('COUNT', '*', 'num')), array(array('=', 'log_Type', '0'), array('=', 'log_Status', '0'), array('BETWEEN', 'log_PostTime', $fdate, $ldate)));
         $n = GetValueInArrayByCurrent($zbp->db->Query($sql), 'num');
         if ($n > 0) {
             //$urls[]=array($url->Make(),str_replace(array('%y%', '%m%'), array(date('Y', $fdate), date('n', $fdate)), $zbp->lang['msg']['year_month']),$n);
             $meta = new Metas();
             $meta->Url = $url->Make();
             $meta->Name = str_replace(array('%y%', '%m%'), array(date('Y', $fdate), date('n', $fdate)), $zbp->lang['msg']['year_month']);
             $meta->Count = $n;
             $urls[] = $meta;
             $i++;
         }
     }
     $tags['urls'] = $urls;
     $template->SetTagsAll($tags);
     $ret = $template->Output('module-archives');
     return $ret;
 }
示例#14
0
/**
 * 根据Rewrite_url规则显示页面
 * @api Filter_Plugin_ViewAuto_Begin
 * @api Filter_Plugin_ViewAuto_End
 * @param string $inpurl 页面url
 * @return null|string
 */
function ViewAuto($inpurl)
{
    global $zbp;
    foreach ($GLOBALS['hooks']['Filter_Plugin_ViewAuto_Begin'] as $fpname => &$fpsignal) {
        $fpreturn = $fpname($inpurl);
        if ($fpsignal == PLUGIN_EXITSIGNAL_RETURN) {
            $fpsignal = PLUGIN_EXITSIGNAL_NONE;
            return $fpreturn;
        }
    }
    $url = GetValueInArray(explode('?', $inpurl), '0');
    if ($zbp->cookiespath === substr($url, 0, strlen($zbp->cookiespath))) {
        $url = substr($url, strlen($zbp->cookiespath));
    }
    if (IS_IIS && isset($_GET['rewrite'])) {
        //iis+httpd.ini下如果存在真实文件
        $realurl = $zbp->path . urldecode($url);
        if (is_readable($realurl) && is_file($realurl)) {
            die(file_get_contents($realurl));
        }
        unset($realurl);
    }
    $url = trim(urldecode($url), '/');
    if ($url == '' || $url == 'index.php') {
        ViewList(null, null, null, null, null);
        return null;
    }
    if ($zbp->option['ZC_STATIC_MODE'] == 'REWRITE') {
        $r = UrlRule::OutputUrlRegEx($zbp->option['ZC_INDEX_REGEX'], 'index');
        $m = array();
        if (preg_match($r, $url, $m) == 1) {
            ViewList($m['page'], null, null, null, null, true);
            return null;
        }
        $r = UrlRule::OutputUrlRegEx($zbp->option['ZC_DATE_REGEX'], 'date', false);
        $m = array();
        if (preg_match($r, $url, $m) == 1) {
            isset($m['page']) ? null : ($m['page'] = 0);
            $result = ViewList($m['page'], null, null, $m, null, true);
            if ($result == true) {
                return null;
            }
        }
        $r = UrlRule::OutputUrlRegEx($zbp->option['ZC_DATE_REGEX'], 'date', true);
        $m = array();
        if (preg_match($r, $url, $m) == 1) {
            $result = ViewList($m['page'], null, null, $m, null, true);
            if ($result == true) {
                return null;
            }
        }
        $r = UrlRule::OutputUrlRegEx($zbp->option['ZC_AUTHOR_REGEX'], 'auth', false);
        $m = array();
        if (preg_match($r, $url, $m) == 1) {
            isset($m['page']) ? null : ($m['page'] = 0);
            $result = ViewList($m['page'], null, $m, null, null, true);
            if ($result == true) {
                return null;
            }
        }
        $r = UrlRule::OutputUrlRegEx($zbp->option['ZC_AUTHOR_REGEX'], 'auth', true);
        $m = array();
        if (preg_match($r, $url, $m) == 1) {
            $result = ViewList($m['page'], null, $m, null, null, true);
            if ($result == true) {
                return null;
            }
        }
        $r = UrlRule::OutputUrlRegEx($zbp->option['ZC_TAGS_REGEX'], 'tags', false);
        $m = array();
        if (preg_match($r, $url, $m) == 1) {
            isset($m['page']) ? null : ($m['page'] = 0);
            $result = ViewList($m['page'], null, null, null, $m, true);
            if ($result == true) {
                return null;
            }
        }
        $r = UrlRule::OutputUrlRegEx($zbp->option['ZC_TAGS_REGEX'], 'tags', true);
        $m = array();
        if (preg_match($r, $url, $m) == 1) {
            $result = ViewList($m['page'], null, null, null, $m, true);
            if ($result == true) {
                return null;
            }
        }
        $r = UrlRule::OutputUrlRegEx($zbp->option['ZC_CATEGORY_REGEX'], 'cate', false);
        $m = array();
        if (preg_match($r, $url, $m) == 1) {
            isset($m['page']) ? null : ($m['page'] = 0);
            $result = ViewList($m['page'], $m, null, null, null, true);
            if ($result == true) {
                return null;
            }
        }
        $r = UrlRule::OutputUrlRegEx($zbp->option['ZC_CATEGORY_REGEX'], 'cate', true);
        $m = array();
        if (preg_match($r, $url, $m) == 1) {
            $result = ViewList($m['page'], $m, null, null, null, true);
            if ($result == true) {
                return null;
            }
        }
        $r = UrlRule::OutputUrlRegEx($zbp->option['ZC_ARTICLE_REGEX'], 'article');
        $m = array();
        if (preg_match($r, $url, $m) == 1) {
            $result = ViewPost($m, null, true);
            if ($result == false) {
                $zbp->ShowError(2, __FILE__, __LINE__);
            }
            return null;
        }
        $r = UrlRule::OutputUrlRegEx($zbp->option['ZC_PAGE_REGEX'], 'page');
        $m = array();
        if (preg_match($r, $url, $m) == 1) {
            $result = ViewPost($m, null, true);
            if ($result == false) {
                $zbp->ShowError(2, __FILE__, __LINE__);
            }
            return null;
        }
    }
    foreach ($GLOBALS['hooks']['Filter_Plugin_ViewAuto_End'] as $fpname => &$fpsignal) {
        $fpreturn = $fpname($url);
        if ($fpsignal == PLUGIN_EXITSIGNAL_RETURN) {
            $fpsignal = PLUGIN_EXITSIGNAL_NONE;
            return $fpreturn;
        }
    }
    if (isset($zbp->option['ZC_COMPATIBLE_ASP_URL']) && $zbp->option['ZC_COMPATIBLE_ASP_URL'] == true) {
        if (isset($_GET['id']) || isset($_GET['alias'])) {
            ViewPost(GetVars('id', 'GET'), GetVars('alias', 'GET'));
            return null;
        } elseif (isset($_GET['page']) || isset($_GET['cate']) || isset($_GET['auth']) || isset($_GET['date']) || isset($_GET['tags'])) {
            ViewList(GetVars('page', 'GET'), GetVars('cate', 'GET'), GetVars('auth', 'GET'), GetVars('date', 'GET'), GetVars('tags', 'GET'));
            return null;
        }
    }
    $zbp->ShowError(2, __FILE__, __LINE__);
}
示例#15
0
 /**
  * @param $name
  * @return int|mixed|null|string
  */
 public function __get($name)
 {
     global $zbp;
     if ($name == 'Url') {
         foreach ($GLOBALS['hooks']['Filter_Plugin_Category_Url'] as $fpname => &$fpsignal) {
             $fpsignal = PLUGIN_EXITSIGNAL_NONE;
             $fpreturn = $fpname($this);
             if ($fpsignal == PLUGIN_EXITSIGNAL_RETURN) {
                 return $fpreturn;
             }
         }
         $backAttr = $zbp->option['ZC_ALIAS_BACK_ATTR'];
         $u = new UrlRule($zbp->option['ZC_CATEGORY_REGEX']);
         $u->Rules['{%id%}'] = $this->ID;
         $u->Rules['{%alias%}'] = rawurlencode($this->Alias == '' ? $this->{$backAttr} : $this->Alias);
         return $u->Make();
     }
     if ($name == 'Symbol') {
         if ($this->ParentID == 0) {
             return;
         } else {
             $l = $this->Level;
             return str_repeat('&nbsp;', $l * 2 - 1) . '└';
         }
     }
     if ($name == 'Level') {
         return $this->GetDeep($this);
     }
     if ($name == 'SymbolName') {
         return $this->Symbol . htmlspecialchars($this->Name);
     }
     if ($name == 'Parent') {
         if ($this->ParentID == 0) {
             return null;
         } else {
             return $zbp->categorys[$this->ParentID];
         }
     }
     if ($name == 'Template') {
         $value = $this->data[$name];
         if ($value == '') {
             $value = $zbp->option['ZC_INDEX_DEFAULT_TEMPLATE'];
         }
         return $value;
     }
     if ($name == 'LogTemplate') {
         $value = $this->data[$name];
         if ($value == '') {
             $value = $zbp->option['ZC_POST_DEFAULT_TEMPLATE'];
         }
         return $value;
     }
     return parent::__get($name);
 }
示例#16
0
 /**
  * @param $name
  * @return mixed|string
  */
 public function __get($name)
 {
     global $zbp;
     if ($name == 'Url') {
         $u = new UrlRule($zbp->option['ZC_AUTHOR_REGEX']);
         $u->Rules['{%id%}'] = $this->ID;
         $u->Rules['{%alias%}'] = $this->Alias == '' ? rawurlencode($this->Name) : $this->Alias;
         return $u->Make();
     }
     if ($name == 'Avatar') {
         foreach ($GLOBALS['hooks']['Filter_Plugin_Mebmer_Avatar'] as $fpname => &$fpsignal) {
             $fpreturn = $fpname($this);
             if ($fpreturn) {
                 $fpsignal = PLUGIN_EXITSIGNAL_NONE;
                 return $fpreturn;
             }
         }
         if ($this->_avatar) {
             return $this->_avatar;
         }
         $s = $zbp->usersdir . 'avatar/' . $this->ID . '.png';
         if (is_readable($s)) {
             $this->_avatar = $zbp->host . 'zb_users/avatar/' . $this->ID . '.png';
             return $this->_avatar;
         }
         $this->_avatar = $zbp->host . 'zb_users/avatar/0.png';
         return $this->_avatar;
     }
     if ($name == 'LevelName') {
         return $zbp->lang['user_level_name'][$this->Level];
     }
     if ($name == 'EmailMD5') {
         return md5($this->Email);
     }
     if ($name == 'StaticName') {
         if ($this->Alias) {
             return $this->Alias;
         }
         return $this->Name;
     }
     if ($name == 'Template') {
         $value = $this->data[$name];
         if ($value == '') {
             $value = $zbp->option['ZC_INDEX_DEFAULT_TEMPLATE'];
         }
         return $value;
     }
     if ($name == 'PassWord_MD5Path') {
         return md5($this->Password . $zbp->guid);
     }
     if ($name == 'IsGod') {
         if ($this->_isgod === true || $this->_isgod === false) {
             return $this->_isgod;
         } else {
             $sql = $zbp->db->sql->Select($zbp->table['Member'], '*', array(array('=', 'mem_Level', 1)), 'mem_ID ASC', 1, null);
             $am = $zbp->GetListType('Member', $sql);
             if ($am[0]->ID == $this->ID) {
                 $this->_isgod = true;
             } else {
                 $this->_isgod = false;
             }
             return $this->_isgod;
         }
     }
     return parent::__get($name);
 }
示例#17
0
 /**
  * @param $url
  * @param $type
  * @return string
  */
 public function Rewrite_httpdini($url, $type)
 {
     global $zbp;
     if (UrlRule::$categorylayer == -1) {
         foreach ($zbp->categorys as $c) {
             if ($c->Level > UrlRule::$categorylayer && strpos($c->Alias, '/') !== false) {
                 UrlRule::$categorylayer = $c->Level;
             }
         }
         if (UrlRule::$categorylayer == -1) {
             UrlRule::$categorylayer = 0;
         }
     }
     switch (UrlRule::$categorylayer) {
         case 3:
             $fullcategory = '[^\\./_]*|[^\\./_]*/[^\\./_]*|[^\\./_]*/[^\\./_]*/[^\\./_]*|[^\\./_]+/[^\\./_]*/[^\\./_]*/[^\\./_]*';
             break;
         case 2:
             $fullcategory = '[^\\./_]*|[^\\./_]*/[^\\./_]*|[^\\./_]*/[^\\./_]*/[^\\./_]*';
             break;
         case 1:
             $fullcategory = '[^\\./_]*|[^\\./_]*/[^\\./_]*';
             break;
         default:
             $fullcategory = '[^\\./_]*';
             break;
     }
     $s = $url;
     $s = str_replace('%page%', '%poaogoe%', $s);
     $url = str_replace('{%host%}', '', $url);
     $url = str_replace('.', '\\.', $url);
     if ($type == 'index') {
         $url = str_replace('%page%', '%poaogoe%', $url);
         preg_match('/[^\\{\\}]+(?=\\{%%poaogoe%%\\})/i', $s, $matches);
         if (isset($matches[0])) {
             $url = str_replace($matches[0], '(?:' . $matches[0] . ')<:1:>', $url);
         }
         $url = $url . ' ' . $zbp->cookiespath . 'index\\.php\\?page=$1&rewrite=1';
         $url = str_replace('%poaogoe%', '([0-9]*)', $url);
     }
     if ($type == 'cate' || $type == 'tags' || $type == 'date' || $type == 'auth') {
         $url = str_replace('%page%', '%poaogoe%', $url);
         preg_match('/(?<=\\})[^\\{\\}]+(?=\\{%poaogoe%\\})/i', $s, $matches);
         if (isset($matches[0])) {
             $url = str_replace($matches[0], '(?:' . $matches[0] . ')?', $url);
         }
         $url = $url . ' ' . $zbp->cookiespath . 'index\\.php\\?' . $type . '=$1&page=$2&rewrite=1';
         $url = str_replace('%poaogoe%', '([0-9]*)', $url);
         $url = str_replace('%id%', '([0-9]+)', $url);
         $url = str_replace('%date%', '([0-9\\-]+)', $url);
         if ($type == 'cate') {
             $url = str_replace('%alias%', '(' . $fullcategory . ')', $url);
         } else {
             $url = str_replace('%alias%', '([^\\./_]+?)', $url);
         }
     }
     if ($type == 'page' || $type == 'article') {
         if (strpos($url, '%alias%') === false) {
             $url = $url . '(\\?.*)? ' . $zbp->cookiespath . 'index\\.php\\?id=$1&rewrite=1';
             $url = str_replace('%id%', '([0-9]+)', $url);
         } else {
             $url = $url . '(\\?.*)? ' . $zbp->cookiespath . 'index\\.php\\?alias=$1&rewrite=1';
             if ($type == 'article') {
                 $url = str_replace('%alias%', '(?!zb_)([^/]+)', $url);
             } else {
                 $url = str_replace('%alias%', '(?!zb_)(.+)', $url);
             }
         }
         $url = str_replace('%category%', '(?:' . $fullcategory . ')', $url);
         $url = str_replace('%author%', '(?:[^\\./_]+)', $url);
         $url = str_replace('%year%', '(?:[0-9]<:4:>)', $url);
         $url = str_replace('%month%', '(?:[0-9]<:1,2:>)', $url);
         $url = str_replace('%day%', '(?:[0-9]<:1,2:>)', $url);
     }
     $url = str_replace('{', '', $url);
     $url = str_replace('}', '', $url);
     $url = str_replace('<:', '{', $url);
     $url = str_replace(':>', '}', $url);
     return 'RewriteRule ' . $zbp->cookiespath . $url . ' [I,L]';
 }