<?php
function paginate1($currentPage, $maxPages, $pagesToShow)
{
$middle = floor($pagesToShow / 2);
$FirstPage = max(1, $currentPage - $middle); $LastPage = $FirstPage + $pagesToShow - 1;
if ($LastPage > $maxPages)
{
$LastPage = $maxPages;
$FirstPage = $LastPage - $pagesToShow + 1;
}
for($i = $FirstPage; $i <= $LastPage; $i++)
{
$pages[] = array('number'=> $i, 'active'=>($i==$currentPage)); }
return $pages;
}
PD9waHAKCmZ1bmN0aW9uIHBhZ2luYXRlMSgkY3VycmVudFBhZ2UsICRtYXhQYWdlcywgJHBhZ2VzVG9TaG93KQp7CiAgICAkbWlkZGxlID0gZmxvb3IoJHBhZ2VzVG9TaG93IC8gMik7CgkkcGFnZXMgPSBhcnJheSgpOwogICAgICAgCiAgICAkRmlyc3RQYWdlID0gbWF4KDEsICRjdXJyZW50UGFnZSAtICRtaWRkbGUpOwogICAgJExhc3RQYWdlID0gJEZpcnN0UGFnZSArICRwYWdlc1RvU2hvdyAtIDE7CiAgICAKICAgIGlmICgkTGFzdFBhZ2UgPiAkbWF4UGFnZXMpCiAgICB7CiAgICAgICAgJExhc3RQYWdlID0gJG1heFBhZ2VzOwogICAgICAgICRGaXJzdFBhZ2UgPSAkTGFzdFBhZ2UgLSAkcGFnZXNUb1Nob3cgKyAxOwogICAgfSAKCglmb3IoJGkgPSAkRmlyc3RQYWdlOyAkaSA8PSAkTGFzdFBhZ2U7ICRpKyspCiAgICB7CiAgICAgICAgJHBhZ2VzW10gPSBhcnJheSgnbnVtYmVyJz0+ICRpLCAnYWN0aXZlJz0+KCRpPT0kY3VycmVudFBhZ2UpKTsKCX0KCXJldHVybiAkcGFnZXM7Cn0KCmVjaG8gdmFyX2R1bXAocGFnaW5hdGUxKDksMTAsNSkpOw==