<?php
        
        # Results per page. Works for the control panel and the website as well
        if (isset($cwd))
            $n = get_account($_SESSION['userID'])['results_'.$cwd];
        else
            $n = $files_to_load;
        
        
        
         # Go to last page max param value
         # if $n is 0, warning! cannot divide by zero.
        $finallink = $n == 0 ? 0 : ceil($catnum / $n ) * $n;
        
        if (isset($_GET['max'])) {
        
            if (abs($_GET['max']) > $catnum)
                $_GET['max'] = $finallink;
        
            $ofp = $_GET['max'];
        }
            
        else
         $ofp = $n;
        
        
        
        # next and previous page values
        $nextlink = $ofp + $n;
        $prevlink = $ofp - $n;
            
        # results on a single page
        $first = $ofp - $n;
        $last = $ofp;
            
        
        
        #calculate the number of results in the last page
        /*
        $marg = $catnum / $n;
        $marg = floatval($marg) - intval($marg);
        $nlp = $n / (1/$marg);
        */
        
        
        

?>