Copy Code code as follows:
<?php
/**
* Function: Pagination class
* Author: phpox
* Time: Sat 18:15:02 CST 2007
*/
Defined (' phpox ') or Die (header ("http/1.1 403 Not Forbidden"));
Class page{
Public $infocount;
Public $pagecount;
Public $items;
Public $pageno;
Public $start;
Public $next;
Public $prev;
Public $maxpages;
Public function __construct ($infocount, $items, $pageno) {
$this->infocount = $infocount;
$this->items = $items;
$this->pageno = $pageno;
$this->pagecount = $this->getpagecount ();
$this->justpageno ();
$this->start = $this->getstart ();
$this->gotoprev ();
$this->gotonext ();
}
Private Function Justpageno () {
if (Emptyempty ($this->pageno) | | $this->pageno < 1) {
$this->pageno = 1;
}
if ($this->pageno > $this->pagecount) {
$this->pageno = $this->pagecount;
}
}
Private Function GoToNext () {
$next = $this->pageno + 1;
if ($next > $this->pagecount) {
$this->next = $this->pagecount;
}else {
$this->next = $next;
}
}
Private Function Gotoprev () {
$prev = $this->pageno-1;
if ($prev < 1) {
$this->prev = 1;
}else {
$this->prev = $prev;
}
}
Private Function Getpagecount () {
Return Ceil ($this->infocount/$this->items);
}
Private Function Getstart () {
if ($this->pageno <= 1) {
return 0;
}else {
Return ($this->pageno-1) * $this->items;
}
}
/**
* Style 0 (PHP)
*/
Public Function ShowPage ($ctlname, $actname, $args = null) {
if ($args!== null) {
if (Is_array ($args)) {
$str = ' & '. Encode_url_args ($args);
}
}
$out = ';
$out. = "Show {$this->items} message per page";
$out. = "Current page <strong><font color=\" #FF0000 \ ">{$this->pageno}</font>/{$this->pagecount}< /strong> ";
$out. = "A total of {$this->infocount} message";
$out. = "<a href= '" ctl={$ctlname}&act={$actname}&p=1$str ' > Home </a> ';
$out. = "<a href= ' ctl={$ctlname}&act={$actname}&p={$this->prev} $str ' > Prev </a> ';
$out. = "<a href= ' ctl={$ctlname}&act={$actname}&p={$this->next} $str ' > next page </a>";
$out. = "<a href= ' ctl={$ctlname}&act={$actname}&p={$this->pagecount} $str ' > End </a>";
$out. = "Jump to:";
$out. = "<select id=\" page\ "name=\" page\ "onchange=\" javascript:window.location= "ctl={$ctlname}&act={$ Actname} $str &p= ' +this.options[this.selectedindex].value;\ ">\n";
$out. = "<option value=\" 1\ "> Please choose </option>\n";
for ($i = 1; $i <= $this->pagecount; $i + +) {
$out. = "<option value=\" $i \ "> {$i} page </option>\n";
}
$out. = "</select>\n";
return $out;
}
/**
* Style 1 (HTML)
*/
function Htmlshowpage ($path, $list, $film) {
$out = ';
$out. = "Show {$this->items} message per page";
$out. = "Current page <strong><font color=\" #FF0000 \ ">{$this->pageno}</font>/{$this->pagecount}< /strong> ";
$out. = "A total of {$this->infocount} message";
$out. = "<a href= ' {$path} $list/{$film}_1.html ' > Home </a> ';
$out. = "<a href= ' {$path} $list/{$film}_{$this->prev}.html ' > Prev </a> ';
$out. = "<a href= ' {$path} $list/{$film}_{$this->next}.html ' > next page </a>";
$out. = "<a href= ' {$path} $list/{$film}_{$this->pagecount}.html ' > End </a>";
$out. = "Jump to:";
$out. = "<select id=\" page\ "name=\" page\ "onchange=\" javascript:window.location= ' {$path}html/$list/{$film}_ ' + This.options[this.selectedindex].value + '. html '/' >\n ';
$out. = "<option value=\" 1\ "> Please choose </option>\n";
for ($i = 1; $i <= $this->pagecount; $i + +) {
$out. = "<option value=\" $i \ "> {$i} page </option>\n";
}
$out. = "</select>\n";
return $out;
}
/**
* Style 2 (discuz)
*/
function multi ($mpurl, $page = 10) {
$multipage = ';
$mpurl. = Strpos ($mpurl, '? ')!== false? ' & ': '? ';
$realpages = 1;
if ($this->infocount > $this->items) {
$offset = 2;
$realpages = @ceil ($this->infocount/$this->items);
$pages = $this->maxpages && $this->maxpages < $realpages? $this->maxpages: $realpages;
if ($page > $pages) {
$from = 1;
$to = $pages;
} else {
$from = $this->pageno-$offset;
$to = $from + $page-1;
if ($from < 1) {
$to = $this->pageno + 1-$from;
$from = 1;
if ($to-$from < $page) {
$to = $page;
}
} elseif ($to > $pages) {
$from = $pages-$page + 1;
$to = $pages;
}
}
$multipage = ($this->pageno-$offset > 1 && $pages > $page? ' <a href= '. $mpurl. ' page=1 ' class= ' a ' >1 ...</a> ': '.
($this->pageno > 1? ' <a href= '. $mpurl. ' Page= '. ($this->pageno-1). " class= "P_redirect" ><<</a> ': ');
for ($i = $from; $i <= $to; $i + +) {
$multipage. = $i = = $this->pageno? ' <a class= ' p_curpage ' ><strong> ' $i. ' </strong></a> ': ' <a href= '. $mpurl. ' page= '. $i. ' " class= "P_num" > '. $i. ' </a> ';
}
$multipage. = ($this->pageno < $pages? ' <a href= '. $mpurl. ' Page= '. ($this->pageno + 1). " class= "P_redirect" >>></a> ': ').
($to < $pages? ' <a href= '. $mpurl. ' page= '. $pages. ' "class=" last ".... '. $realpages. ' </a> ': ').
($pages > $page? ' <kbd><input type= ' text ' name= ' custompage ' size= ' 3 ' onkeydown= ' if (event.keycode==13) {window.location=\ '. $mpurl. ' Page=\ ' +this.value; return false;} " /></kbd> ': ');
$multipage = $multipage? ' <div class= ' p_bar ' ><a class= ' p_total ' > '. $this->infocount. ' </a><a class= ' p_pages ' > '. $ This->pageno. ' /'. $pages. ' </a> '. $multipage. ' </div> ': ';
}
return $multipage;
}
/**
* Style 3 (ZOL)
*/
Public Function Zol ($mpurl)
{
$mpurl. = Strpos ($mpurl, '? ')!== false? ' & ': '? ';
$code = ' <div class= ' f22 mt10 hei14 ' > ';
$code. = ' <div style= ' line-height:30px ' > <font class= ' a_hong14b ' > '. $this->pageno. ' </font><font class= "a_hei14" >/'. $this->pagecount. ' </font> each page <font class= "a_hei14" > '. $this->items. ' </font> altogether <font class= "a_hong14b" > '. $this->infocount. ' </font> Products </div> ';
$code. = ' <table border= ' 0 "align=" right "cellpadding=" 0 "cellspacing=" 3 ">";
$code. = ' <tr> ';
if ($this->pageno = = $this->prev)
{
$code. = "<td width= ' align= ' center ' class= ' Bd_hui huei14b ' ><a disabled= ' disabled ' class= ' ' a_hui12b ' > << prev </a></td> ";
}
Else
{
$code. = "<td width= ' align= ' center ' class= ' Bd_lan a_lan14 ' ><a ' href= ' {$mpurl}page={$this->prev} ' class= ' a_lan12b ' ><< prev </a></td>;
}
$i = 10;
$k = 1;
if ($this->pageno < 1)
{
$this->pageno = 1;
}
if ($this->pageno > $this->pagecount)
{
$this->pageno = $this->pagecount;
}
$s = $this->pageno-2;
if ($s <= 0)
{
$s = 1;
}
$e = $this->pageno+2;
if ($e < 5)
{
$e = 5;
}
if ($e > $this->pagecount)
{
$e = $this->pagecount;
}
for ($j = $s; $j <= $e; $j + +)
{
if ($this->pageno = = $j)
{
$code. = ' <td width= ' bgcolor= ' #2E6AB1 ' class= ' bei14 ' align= ' center ' > ' $j. ' </td> ';
}
Else
{
$code. = "<td width= ' align= ' center ' class= ' Bd_lan a_lan14 ' onmouseover=\ ' this.style.border= ' 1px solid #2062A4 '" Onmouseout=\ "This.style.border= ' 1px solid #AACCEE '" "Style=\" cursor:hand\ "onclick=\" javascript:window.location= (' {$mpurl}page={$j} ') \ > $j </td>;
}
}
if ($this->pageno = = $this->pagecount)
{
$code. = "<td align= ' center ' width= ' class= ' Bd_hui huei14b ' ><a disabled= ' disabled ' > next page >></a ></td> ";
}
Else
{
$code. = "<td align= ' center ' width= ' class= ' Bd_lan lan14b ' ><a ' href= ' {$mpurl}page={$this->next} ' class= ' a_lan12b ' > next page >></a></td> ';
}
$code. = ' </tr> ';
$code. = ' </table> ';
$code. = ' </div> ';
return $code;
}
}