发新话题
打印

dz6.0伪静态重要函数

dz6.0伪静态重要函数

function rewrite_thread($tid, $page = 0, $prevpage = 0, $extra = '') {
return '<a href="thread-'.$tid.'-'.($page ? $page : 1).'-'.($prevpage && !IS_ROBOT ? $prevpage : 1).'.html"'.stripslashes($extra).'>';
}
function rewrite_forum($fid, $page = 0, $extra = '') {
return '<a href="forum-'.$fid.'-'.($page ? $page : 1).'.html"'.stripslashes($extra).'>';
}
function rewrite_space($uid, $username, $extra = '') {
$GLOBALS['rewritecompatible'] && $username = rawurlencode($username);
return '<a href="space-'.($uid ? 'uid-'.$uid : 'username-'.$username).'.html"'.stripslashes($extra).'>';
}
function rewrite_tag($name, $extra = '') {
$GLOBALS['rewritecompatible'] && $name = rawurlencode($name);
return '<a href="tag-'.$name.'.html"'.stripslashes($extra).'>';
}

function output() {
................
$searcharray = $replacearray = array();
   if($rewritestatus & 1) {
    $searcharray[] = "/\<a href\=\"forumdisplay\.php\?fid\=(\d+)(&page\=(\d+))?\"([^\>]*)\>/e";
    $replacearray[] = "rewrite_forum('\\1', '\\3', '\\4')";
   }
   if($rewritestatus & 2) {
    $searcharray[] = "/\<a href\=\"viewthread\.php\?tid\=(\d+)(&extra\=page\%3D(\d+))?(&page\=(\d+))?\"([^\>]*)\>/e";
    $replacearray[] = "rewrite_thread('\\1', '\\5', '\\3', '\\6')";
   }
   if($rewritestatus & 4) {
    $searcharray[] = "/\<a href\=\"space\.php\?(uid\=(\d+)|username\=([^&]+?))\"([^\>]*)\>/e";
    $replacearray[] = "rewrite_space('\\2', '\\3', '\\4')";
   }
   if($rewritestatus & 8) {
    $searcharray[] = "/\<a href\=\"tag\.php\?name\=([^&]+?)\"([^\>]*)\>/e";
    $replacearray[] = "rewrite_tag('\\1', '\\2')";
   }
   
   $searcharray[] = "/\<a href\=\"index\.php\?gid\=(\d+)/e";
   $replacearray[] = "rewrite_index('\\1')";
  }
  $content = preg_replace($searcharray, $replacearray, ob_get_contents());
................

TOP

发新话题