403Webshell
Server IP : 54.233.248.239  /  Your IP : 172.28.20.13
Web Server : Apache
System : Linux ip-172-28-29-189 6.5.0-1014-aws #14~22.04.1-Ubuntu SMP Thu Feb 15 15:27:06 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.2.34-43+ubuntu22.04.1+deb.sury.org+1
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/html/vinumday2_0/app/Services/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/vinumday2_0/app/Services/PaginationService.php
<?php 

namespace App\Services;

class PaginationService {

    public $query;
    public $limit;
    public $pagesize;
    public $path;
    public $current_page;
    public $request;
    public $total_pages;

    public $total_rows;
    public $last_page;
    public $query_string;
    public $operator;

    public $show_pages   = [];
    public $limite_pages = 12;
    public $firstSide    = 0;
    public $lastSide     = 0;

    public function __construct($params){

        $request = $params['request'];

        $this->limit        = ($request->input('term_limit') ? $request->input('term_limit') : 1000);
        $this->current_page = ($request->input('page') ? $request->input('page') : 1);
        $this->pagesize     = ($request->input('pagesize') ? $request->input('pagesize') : 100);

        foreach ($params as $key => $value) {
            $this->$key = $value;
        }

        $total_registros  = $this->query->limit($this->limit)->get();
        $this->total_rows = count($total_registros);

        $this->total_pages = ceil($this->total_rows / $this->pagesize);

        $this->last_page = $this->total_pages;

        $this->query_string = http_build_query($request->input());
        $this->operator     = '?';
        $this->query_string = str_replace(["&page={$this->current_page}", "page={$this->current_page}"], "", $this->query_string);
        if(!empty($this->query_string)){
            $this->path     .= "?{$this->query_string}";
            $this->operator = '&';
        }

        $this->show_pages = $this->showPages();

    }

    public function showPages(){

        $onEachSide      = 3;
        $pages           = [];
        $this->firstSide = $this->current_page - 1;
        $this->lastSide  = $this->last_page - $this->current_page;

        for($page=1;$page<=$this->total_pages;$page++){

            $firstSide = $page - 1;
            $lastSide  = $this->last_page - $page;

            if($this->total_pages < $this->limite_pages){
                $pages[] = $page;
            }elseif($page == 1 || $page == 2 || $page == $this->last_page || $page == ($this->last_page - 1)){
                $pages[] = $page;
            }elseif($page == $this->current_page && ($page != 1 || $page != 2 || $page != $this->last_page || $page != ($this->last_page - 1))){
                if($firstSide >= 6){
                    $start = $page - $onEachSide;
                    for($p=$start;$p<$page;$p++){
                        $pages[] = $p;
                    }
                    $pages[] = $page;
                    $finish = $page + $onEachSide;
                    for($p=($page+1);$p<=$finish;$p++){
                        $pages[] = $p;
                    }
                }else{
                    $pages[] = $page;
                }
            }elseif($firstSide < 7 && $this->firstSide < 7){
                $pages[] = $page;
            }elseif($lastSide < 7 && $this->lastSide < 7){
                $pages[] = $page;
            }else{
                continue;
            }

        }

        return $pages;

    }

}

Youez - 2016 - github.com/yon3zu
LinuXploit