0byt3m1n1
Path:
/
var
/
www
/
listcrawler.app
/
public_html
/
admin
/
helpers
/
[
Home
]
File: helpers.php
<?php /** * Function to generate random string. */ function randomString($n) { $generated_string = ""; $domain = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; $len = strlen($domain); // Loop to create random string for ($i = 0; $i < $n; $i++) { // Generate a random index to pick characters $index = rand(0, $len - 1); // Concatenating the character // in resultant string $generated_string = $generated_string . $domain[$index]; } return $generated_string; } /** * */ function getSecureRandomToken() { $token = bin2hex(openssl_random_pseudo_bytes(16)); return $token; } /** * Clear Auth Cookie */ function clearAuthCookie() { unset($_COOKIE['series_id']); unset($_COOKIE['remember_token']); setcookie('series_id', null, -1, '/'); setcookie('remember_token', null, -1, '/'); } /** * */ function clean_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } function paginationLinks($current_page, $total_pages, $base_url) { if ($total_pages <= 1) { return false; } $html = ''; if (!empty($_GET)) { // We must unset $_GET[page] if previously built by http_build_query function unset($_GET['page']); // To keep the query sting parameters intact while navigating to next/prev page, $http_query = "?" . http_build_query($_GET); } else { $http_query = "?"; } $html = '<ul class="pagination text-center">'; if ($current_page == 1) { $html .= '<li class="disabled"><a>First</a></li>'; } else { $html .= '<li><a href="' . $base_url . $http_query . '&page=1">First</a></li>'; } // Show pagination links //var i = (Number(data.page) > 5 ? Number(data.page) - 4 : 1); if ($current_page > 10) { $i = $current_page - 9; } else { $i = 1; } for (; $i <= ($current_page + 9) && ($i <= $total_pages); $i++) { ($current_page == $i) ? $li_class = ' class="active"' : $li_class = ''; $link = $base_url . $http_query; $html = $html . '<li' . $li_class . '><a href="' . $link . '&page=' . $i . '">' . $i . '</a></li>'; if ($i == $current_page + 9 && $i < $total_pages) { $html = $html . '<li class="disabled"><a>...</a></li>'; } } if ($current_page == $total_pages) { $html .= '<li class="disabled"><a>Last</a></li>'; } else { $html .= '<li><a href="' . $base_url . $http_query . '&page=' . $total_pages . '">Last</a></li>'; } $html = $html . '</ul>'; return $html; } function get_query_string(){ $arr = explode("?",$_SERVER['REQUEST_URI']); if (count($arr) == 2){ return ""; }else{ return "?".end($arr)."<br>"; } } /* Function resizeImage($filename_original,$filename_resized,$new_w,$new_h) creates a resizeImage image variables: $filename_original Original filename $filename_resized Filename of the resized image $new_w width of resized image $new_h height of resized image */ function resizeImage($filename_original, $filename_resized, $new_w, $new_h) { $extension = pathinfo($filename_original, PATHINFO_EXTENSION); if ( preg_match("/jpg|jpeg/", $extension) ) $src_img=@imagecreatefromjpeg($filename_original); if ( preg_match("/png/", $extension) ) $src_img=@imagecreatefrompng($filename_original); if(!$src_img) return false; $old_w = imageSX($src_img); $old_h = imageSY($src_img); $x_ratio = $new_w / $old_w; $y_ratio = $new_h / $old_h; if ( ($old_w <= $new_w) && ($old_h <= $new_h) ) { $thumb_w = $old_w; $thumb_h = $old_h; } elseif ( $y_ratio <= $x_ratio ) { $thumb_w = round($old_w * $y_ratio); $thumb_h = round($old_h * $y_ratio); } else { $thumb_w = round($old_w * $x_ratio); $thumb_h = round($old_h * $x_ratio); } $dst_img=ImageCreateTrueColor($thumb_w,$thumb_h); imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_w,$old_h); if (preg_match("/png/",$extension)) imagepng($dst_img,$filename_resized); else imagejpeg($dst_img,$filename_resized,100); imagedestroy($dst_img); imagedestroy($src_img); return true; }