- 01
 - 02
 - 03
 - 04
 - 05
 - 06
 - 07
 - 08
 - 09
 - 10
 - 11
 - 12
 - 13
 - 14
 - 15
 - 16
 - 17
 - 18
 - 19
 - 20
 - 21
 - 22
 - 23
 - 24
 - 25
 - 26
 - 27
 - 28
 - 29
 - 30
 - 31
 - 32
 - 33
 - 34
 - 35
 - 36
 - 37
 - 38
 - 39
 - 40
 - 41
 - 42
 - 43
 - 44
 - 45
 - 46
 - 47
 - 48
 - 49
 - 50
 - 51
 - 52
 - 53
 - 54
 - 55
 
                        // $curr_page - старница, на который сейчас находимся
// $n_page - число страниц
// $count - обще число записей
// $param - site - страницы на сайте
//        - adm - в админке
function genNumPage($curr_page, $n_page, $count, $param=null) {
    $string = parse_url($_SERVER['REQUEST_URI']);
    $query = '?'.$string['query'];
    $num_page = ceil($count / $n_page);
    if (isset($param))  $table = new my_Page("site/site_interface.html", "num_page");
    else                $table = new my_Page("interface/interface.html", "num_page");
    
    if ($num_page < 2) return null;
    
    for ($i = 1; $i <= $num_page; $i++) {
        if ($i != $curr_page) {
            if (preg_match('/\?p\=[0-9]{1,3}/', $query))        $href = preg_replace('/\?p\=[0-9]{1,3}/', '?p='.$i, $query);
            elseif (preg_match('/\&p\=[0-9]{1,3}/', $query))    $href = preg_replace('/\&p\=[0-9]{1,3}/', '&p='.$i, $query);
            elseif ($string['query'] != '')                     $href = '?'.$string['query'].'&p='.$i;
            else                                                $href = '?p='.$i;
            
            if ((!$param) || ($param == 'adm')) $str .= " <a href=".$string['host'].$string['path'].$href.">".$i."</a> ";
            else                                $str .= " <a href=".$string['host'].$string['path'].$href.">".$i."</a> | ";
        }
        elseif ((!$param) || ($param == 'adm')) $str .= "<span>".$i."</span>";
        else                                    $str .= "<span>".$i."</span> | ";
    }
    
        if ($curr_page > 1) {
        if (preg_match('/\?p\=[0-9]{1,3}/', $query))        $prev = preg_replace('/\?p\=[0-9]{1,3}/', '?p='.($curr_page - 1), $query);
        elseif (preg_match('/\&p\=[0-9]{1,3}/', $query))    $prev = preg_replace('/\&p\=[0-9]{1,3}/', '&p='.($curr_page - 1), $query);
        elseif ($string['query'] != '')                     $prev = '?'.$string['query'].'&p='.($curr_page - 1);
        else                                                $prev = '?p='.($curr_page - 1);;
        
        if ((!$param) || ($param == 'adm')) $prev = " <a href=".$string['host'].$string['path'].$prev." id=\"PrevLink\">←</a> ";
        else                                $prev = " <a href=".$string['host'].$string['path'].$prev." id=\"PrevLink\">Предыдущая</a> ";
    }
    
    if ($curr_page < $num_page) {
        if (preg_match('/\?p\=[0-9]{1,3}/', $query))        $next = preg_replace('/\?p\=[0-9]{1,3}/', '?p='.($curr_page + 1), $query);
        elseif (preg_match('/\&p\=[0-9]{1,3}/', $query))    $next = preg_replace('/\&p\=[0-9]{1,3}/', '&p='.($curr_page + 1), $query);
        elseif ($string['query'] != '')                     $next = '?'.$string['query'].'&p='.($curr_page + 1);
        else                                                $next = '?p='.($curr_page + 1);;
        
        if ((!$param) || ($param == 'adm')) $next = " <a href=".$string['host'].$string['path'].$next." id=\"NextLink\">→</a> ";
        else                                $next = " <a href=".$string['host'].$string['path'].$next." id=\"NextLink\">Следующая</a> ";
    }
    
    $table->addValueArray(array(
                                "NUM"   => $str,
                                "PREV"  => $prev,
                                "NEXT"  => $next
    ));
    return $table->myReplace();
}
                                     
        
            Генерирует номера страниц. Из одной CMS'ки.