Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Need to add those functions in a common functions.php file
- function unparse_url($parsed_url) {
- $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
- $host = isset($parsed_url['host']) ? $parsed_url['host'] : '';
- $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';
- $user = isset($parsed_url['user']) ? $parsed_url['user'] : '';
- $pass = isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : '';
- $pass = ($user || $pass) ? "$pass@" : '';
- $path = isset($parsed_url['path']) ? $parsed_url['path'] : '';
- $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : '';
- $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : '';
- return "$scheme$user$pass$host$port$path$query$fragment";
- }
- // Because if URL already is Page URL (?page=), Need to remove page param from URL
- function removeQueryParam($url, $param_to_remove) {
- $parsed = parse_url($url);
- if ($parsed && isset($parsed['query'])) {
- $parsed['query'] = implode('&', array_filter(explode('&', $parsed['query']), function($param) use ($param_to_remove) {
- return explode('=', $param)[0] !== $param_to_remove;
- }));
- if ($parsed['query'] === '') unset($parsed['query']);
- return unparse_url($parsed);
- } else {
- return $url;
- }
- }
- $actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
- $url = removeQueryParam($actual_link,'page');
- preg_match("/[^\/]+$/", $url, $matches);
- $last_word = $matches[0];
- $total_count = getTotalCount($sql_sub);
- $display_list_limit = $view_count;
- $offset = ($page - 1) * $display_list_limit;
- // This way, We don't need to HARDCODE pages name it done dynamically
- pageing_link_build2($last_word);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement