欢迎来到福编程网,本站提供各种互联网专业知识!

DISCUZ 分页代码

发布时间:2007-01-02 作者: 来源:转载
复制代码代码如下:

复制代码 代码如下:/*
[Discuz!](C)2001-2006ComsenzInc.
ThisisNOTafreeware,useissubjecttolicenseterms

$RCSfile:global.func.php,v$
$Revision:1.83.2.7$
$Date:2006/10/2708:08:18$
*/

functionmulti($num,$perpage,$curpage,$mpurl,$maxpages=0){
$multipage='';
$mpurl.=strpos($mpurl,'?')?'&':'?';
if($num>$perpage){
$page=10;
$offset=2;

$realpages=@ceil($num/$perpage);
$pages=$maxpages&&$maxpages<$realpages?$maxpages:$realpages;

if($page>$pages){
$from=1;
$to=$pages;
}else{
$from=$curpage-$offset;
$to=$from+$page-1;
if($from<1){
$to=$curpage+1-$from;
$from=1;
if($to-$from<$page){
$to=$page;
}
}elseif($to>$pages){
$from=$pages-$page+1;
$to=$pages;
}
}

$multipage=($curpage-$offset>1&&$pages>$page?'|?':'').
($curpage>1?'??':'');
for($i=$from;$i<=$to;$i++){
$multipage.=$i==$curpage?''.$i.'':
''.$i.'';
}

$multipage.=($curpage<$pages?'??':'').
($to<$pages?'?|':'').
($curpage==$maxpages?'??':'').
($pages>$page?'':'');

$multipage=$multipage?''.$num.''.$curpage.'/'.$realpages.''.$multipage.'

':'';
}
return$multipage;
}
?>

相关推荐