Guest User

Untitled

a guest
Jun 24th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.79 KB | None | 0 0
  1. <?php
  2. function getPage(){
  3.    return (isset($_GET['pg'])) ? array_filter(explode('/', $_GET['pg']), 'noEmpty') : array('home');
  4. }
  5.  
  6. function noEmpty($item){
  7.    return !(empty($item));
  8. }
  9.  
  10. /*Retorna a pagina q será incluida*/
  11.  
  12. function getIncludePage(){
  13.    $page = getPage();
  14.    if(file_exists("arquivos/$page.php")){
  15.        $path = "arquivos/$page.php";
  16.     }else{
  17.       $path = "arquivos/error.php";
  18.     }
  19.    include_once($path);
  20. }
  21.  
  22. /*Retorna o primeiro parâmetro depois da pagina*/
  23.  function getFirstParam(){
  24.      $page = getPage();
  25.      return (isset($page[1])) ? $page[1] : 0;
  26. }
  27.  
  28. /*Retorna num numero de paginação*/
  29.  function getNumberPagination(){
  30.      $page = getPage();
  31.      return (isset($page[1]) && $page == 'page' && isset($page[2])) ? (int)$page[2] : 1;
  32.  }
  33.  
  34. ?>
Add Comment
Please, Sign In to add comment