/** * rewrite url * by Aan Gabriel * * @param string $url * @param int $start * @param int $total * @param int $kmess * @return string */ public function Rewrite($text) { $text = html_entity_decode(trim($text), ENT_QUOTES, 'UTF-8'); $text=str_replace(" ","-", $text); $text=str_replace("--","-", $text); $text=str_replace("@","-",$text); $text=str_replace("/","-",$text); $text=str_replace("\\","-",$text); $text=str_replace(":","",$text); $text=str_replace("\"","",$text); $text=str_replace("'","",$text); $text=str_replace("<","",$text); $text=str_replace(">","",$text); $text=str_replace(",","",$text); $text=str_replace("?","",$text); $text=str_replace(";","",$text); $text=str_replace(".","",$text); $text=str_replace("[","",$text); $text=str_replace("]","",$text); $text=str_replace("(","",$text); $text=str_replace(")","",$text); $text=str_replace("*","",$text); $text=str_replace("!","",$text); $text=str_replace("$","-",$text); $text=str_replace("&","-and-",$text); $text=str_replace("%","",$text); $text=str_replace("#","",$text); $text=str_replace("^","",$text); $text=str_replace("=","",$text); $text=str_replace("+","",$text); $text=str_replace("~","",$text); $text=str_replace("`","",$text); $text=str_replace("--","-",$text); $text = preg_replace("/(Р“ |Р“Ў|Р±єЎ|Р±єЈ|Р“Ј|Р“ў|Р±є§|Р±єҐ|Р±є­|Р±є©|Р±є«|Р”ѓ|Р±є±|Р±єЇ|Р±є·|Р±єі|Р±єµ)/", 'a', $text); $text = preg_replace("/(aРњЂ|aРњЃ|aРњЈ|aРњ‰|aРњѓ|Р“ў|Р“ўРњЂ|Р“ўРњЃ|Р“ўРњЈ|Р“ўРњ‰|Р“ўРњѓ|Р”ѓ|Р”ѓРњЂ|Р”ѓРњЃ|Р”ѓРњЈ|Р”ѓРњ‰|Р”ѓРњѓ)/", 'a', $text); $text = preg_replace("/(ГЁ|Р“©|Р±є№|Р±є»|Р±єЅ|Р“Є|Р±»Ѓ|Р±єї|Р±»‡|Р±»ѓ|Р±»…)/", 'e', $text); $text = preg_replace("/(eРњЂ|eРњЃ|eРњЈ|eРњ‰|eРњѓ|Р“Є|Р“ЄРњЂ|Р“ЄРњЃ|Р“ЄРњЈ|Р“ЄРњ‰|Р“ЄРњѓ)/", 'e', $text); $text = preg_replace("/(Р“¬|Р“­|Р±»‹|Р±»‰|Р”©)/", 'i', $text); $text = preg_replace("/(iРњЂ|iРњЃ|iРњЈ|iРњ‰|iРњѓ)/", 'i', $text); $text = preg_replace("/(Р“І|Р“і|Р±»Ќ|Р±»Џ|Р“µ|Р“ґ|Р±»“|Р±»‘|Р±»™|Р±»•|Р±»—|Р–Ў|Р±»ќ|Р±»›|Р±»Ј|Р±»џ|Р±»Ў)/", 'o', $text); $text = preg_replace("/(oРњЂ|oРњЃ|oРњЈ|oРњ‰|oРњѓ|Р“ґ|Р“ґРњЂ|Р“ґРњЃ|Р“ґРњЈ|Р“ґРњ‰|Р“ґРњѓ|Р–Ў|Р–ЎРњЂ|Р–ЎРњЃ|Р–ЎРњЈ|Р–ЎРњ‰|Р–ЎРњѓ)/", 'o', $text); $text = preg_replace("/(Р“№|Р“є|Р±»Ґ|Р±»§|Р•©|Р–°|Р±»«|Р±»©|Р±»±|Р±»­|Р±»Ї)/", 'u', $text); $text = preg_replace("/(uРњЂ|uРњЃ|uРњЈ|uРњ‰|uРњѓ|Р–°|Р–°РњЂ|Р–°РњЃ|Р–°РњЈ|Р–°Рњ‰|Р–°Рњѓ)/", 'u', $text); $text = preg_replace("/(Р±»і|Р“Ѕ|Р±»µ|Р±»·|Р±»№)/", 'y', $text); $text = preg_replace("/(Р”‘)/", 'd', $text); $text = preg_replace("/(yРњЂ|yРњЃ|yРњЈ|yРњ‰|yРњѓ)/", 'y', $text); $text = preg_replace("/(Р”‘)/", 'd', $text); $text = preg_replace("/(Р“Ђ|Р“Ѓ|Р±є |Р±єў|Р“ѓ|Р“‚|Р±є¦|Р±є¤|Р±є¬|Р±єРЃ|Р±єЄ|Р”‚|Р±є°|Р±є®|Р±є¶|Р±єІ|Р±єґ)/", 'A', $text); $text = preg_replace("/(AРњЂ|AРњЃ|AРњЈ|AРњ‰|AРњѓ|Р“‚|Р“‚РњЂ|Р“‚РњЃ|Р“‚РњЈ|Р“‚Рњ‰|Р“‚Рњѓ|Р”‚|Р”‚РњЂ|Р”‚РњЃ|Р”‚РњЈ|Р”‚Рњ‰|Р”‚Рњѓ)/", 'A', $text); $text = preg_replace("/(Р“€|Р“‰|Р±єС‘|Р±єє|Р±єј|Р“Љ|Р±»Ђ|Р±єѕ|Р±»†|Р±»‚|Р±»„)/", 'E', $text); $text = preg_replace("/(EРњЂ|EРњЃ|EРњЈ|EРњ‰|EРњѓ|Р“Љ|Р“ЉРњЂ|Р“ЉРњЃ|Р“ЉРњЈ|Р“ЉРњ‰|Р“ЉРњѓ)/", 'E', $text); $text = preg_replace("/(Р“Њ|Р“Ќ|Р±»Љ|Р±»€|ДЁ)/", 'I', $text); $text = preg_replace("/(IРњЂ|IРњЃ|IРњЈ|IРњ‰|IРњѓ)/", 'I', $text); $text = preg_replace("/(Р“’|Р““|Р±»Њ|Р±»Ћ|Р“•|Р“”|Р±»’|Р±»ђ|Р±»�|Р±»”|Р±»–|Р– |Р±»њ|Р±»љ|Р±»ў|Р±»ћ|Р±» )/", 'O', $text); $text = preg_replace("/(OРњЂ|OРњЃ|OРњЈ|OРњ‰|OРњѓ|Р“”|Р“”РњЂ|Р“”РњЃ|Р“”РњЈ|Р“”Рњ‰|Р“”Рњѓ|Р– |Р– РњЂ|Р– РњЃ|Р– РњЈ|Р– Рњ‰|Р– Рњѓ)/", 'O', $text); $text = preg_replace("/(Р“™|Р“љ|Р±»¤|Р±»¦|ЕЁ|Р–Ї|Р±»Є|Р±»РЃ|Р±»°|Р±»¬|Р±»®)/", 'U', $text);$text = preg_replace("/(UРњЂ|UРњЃ|UРњЈ|UРњ‰|UРњѓ|Р–Ї|Р–ЇРњЂ|Р–ЇРњЃ|Р–ЇРњЈ|Р–ЇРњ‰|Р–ЇРњѓ)/", 'U', $text); $text = preg_replace("/(Р±»І|Р“ќ|Р±»ґ|Р±»¶|Р±»С‘)/", 'Y', $text); $text = preg_replace("/(Р”ђ)/", 'D', $text); $text = preg_replace("/(YРњЂ|YРњЃ|YРњЈ|YРњ‰|YРњѓ)/", 'Y', $text); $text = preg_replace("/(Р”ђ)/", 'D', $text); $text=strtolower($text); return $text; } /** * Постраничная навигация * За основу взята доработанная функция от форума SMF 2.x.x * * @param string $url * @param int $start * @param int $total * @param int $kmess * @return string */ public function displayPagination2($url, $start, $total, $kmess) { $neighbors = 2; if ($start >= $total) { $start = max(0, $total - (($total % $kmess) == 0 ? $kmess : ($total % $kmess))); } else { $start = max(0, (int)$start - ((int)$start % (int)$kmess)); } $base_link = '%s'; $out[] = $start == 0 ? '' : sprintf($base_link, $start / $kmess, '<<'); if ($start > $kmess * $neighbors) { $out[] = sprintf($base_link, 1, '1'); } if ($start > $kmess * ($neighbors + 1)) { $out[] = '...'; } for ($nCont = $neighbors; $nCont >= 1; $nCont--) { if ($start >= $kmess * $nCont) { $tmpStart = $start - $kmess * $nCont; $out[] = sprintf($base_link, $tmpStart / $kmess + 1, $tmpStart / $kmess + 1); } } $out[] = '' . ($start / $kmess + 1) . ''; $tmpMaxPages = (int)(($total - 1) / $kmess) * $kmess; for ($nCont = 1; $nCont <= $neighbors; $nCont++) { if ($start + $kmess * $nCont <= $tmpMaxPages) { $tmpStart = $start + $kmess * $nCont; $out[] = sprintf($base_link, $tmpStart / $kmess + 1, $tmpStart / $kmess + 1); } } if ($start + $kmess * ($neighbors + 1) < $tmpMaxPages) { $out[] = '...'; } if ($start + $kmess * $neighbors < $tmpMaxPages) { $out[] = sprintf($base_link, $tmpMaxPages / $kmess + 1, $tmpMaxPages / $kmess + 1); } if ($start + $kmess < $total) { $display_page = ($start + $kmess) > $total ? $total : ($start / $kmess + 2); $out[] = sprintf($base_link, $display_page, '>>'); } return implode(' ', $out); }