Guest User

Untitled

a guest
Jan 2nd, 2024
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.17 KB | None | 0 0
  1. <?php
  2. if (detect_device())
  3. define('USER_DEVICE', 'm');
  4. else {
  5. define('USER_DEVICE', 'p');
  6. }
  7. function getURL()
  8. {
  9. $host = $_SERVER['HTTP_HOST'];
  10. $request_uri = $_SERVER['REQUEST_URI'];
  11. $request_uri = parse_url($request_uri, PHP_URL_PATH);
  12. return trim($host . $request_uri, '/');
  13. }
  14. function slug($str)
  15. {
  16. $str = str_replace(' ', '-', trim($str));
  17. $str = str_replace('_', '-', $str);
  18. $str = preg_replace("/[^A-Za-z0-9-]/", "", $str);
  19. $str = str_replace('---', '-', $str);
  20. $str = str_replace('--', '-', $str);
  21. return strtolower($str);
  22. }
  23.  
  24. function title($str)
  25. {
  26. $str = str_replace([' ', '_'], '-', trim($str));
  27. $str = preg_replace("/[^A-Za-z0-9-()]/", "", $str);
  28. $str = str_replace(['---', '--', '()'], '-', $str);
  29. $str = str_replace('---', '-', $str);
  30. $str = str_replace('--', '-', $str);
  31. $str = str_replace('-', ' ', $str);
  32. return ucwords($str);
  33. }
  34.  
  35.  
  36.  
  37. function formatSize($size, $type = false, $round = 2)
  38. {
  39. $sizes = array('byts', 'kb', 'mb', 'gb', 'tb');
  40. $total = count($sizes) - 1;
  41. for ($i = 0; $size > 1024 && $i < $total; $i++)
  42. $size /= 1024;
  43. if ($type == true)
  44. return array(round($size, $round), $sizes[$i]);
  45. return round($size, $round) . ' ' . $sizes[$i];
  46. }
  47. function fileDownload($Path, $fileName, $ext)
  48. {
  49. switch ($ext) {
  50. case 'MP3':
  51. $mime = "audio/mpeg";
  52. break;
  53. case 'JPG':
  54. $mime = "image/jpg";
  55. break;
  56. default:
  57. $mime = "application/octet-stream";
  58. }
  59.  
  60. header('Content-type: ' . $mime);
  61. header('Content-Disposition: attachment; filename="' . $fileName . '"');
  62. header('Content-Length: ' . filesize($Path));
  63. readfile($Path);
  64. exit;
  65. }
  66. function getPageUrl($page, $link)
  67. {
  68. return str_replace('{{PAGE}}', $page, $link);
  69. }
  70.  
  71. function skyPageNavigate($totalpage, $start, $limit, $link)
  72. {
  73. if ($totalpage != 1 && $totalpage != 0) {
  74. $pagination = '<nav aria-label="Page navigation"><ul class="pagination justify-content-center">';
  75. $totalLink = 5;
  76. $no_of_page = $totalpage;
  77.  
  78. if ($start * $limit > $limit)
  79. $pagination .= '<li class="page-item"><a class="page-link" href="' . getPageUrl($start - 1, $link) . '"><i class="fa fa-caret-left" aria-hidden="true"></i> Prev</a></li>';
  80. // $pagination .= link_to('< Prev', $link.($start-1));
  81.  
  82. $count_record = 0;
  83. $i = 1;
  84. if ($start >= $totalLink - floor($totalLink / 2))
  85. $i = $start - floor($totalLink / 2);
  86.  
  87. if ($no_of_page > $totalLink)
  88. if (($no_of_page - $i) < $totalLink)
  89. $i = $i - ($totalLink - ($no_of_page - $i) - 1);
  90.  
  91. for (; $i <= $no_of_page; $i++) {
  92. if ($start == $i)
  93. $pagination .= '<li class="page-item active" aria-current="page"><a href="#" class="page-link" tabindex="-1">' . $i . '</a></li>';
  94. else
  95. $pagination .= '<li class="page-item"><a class="page-link" href="' . getPageUrl($i, $link) . '">' . $i . '</a></li>';
  96. // $pagination .= link_to($i,$link.$i).'';
  97. $count_record = $count_record + 1;
  98. if ($count_record == $totalLink)
  99. break;
  100. }
  101.  
  102. if ($start < $no_of_page) {
  103. $pagination .= '<li class="page-item"><a class="page-link" href="' . getPageUrl($start + 1, $link) . '">Next <i class="fa fa-caret-right" aria-hidden="true"></i></a></li>';
  104. }
  105. if ($start > 0)
  106. $pagination .= '</ul></nav>';
  107. return $pagination;
  108. }
  109. }
  110.  
  111. function getAds($str)
  112. {
  113. return file_get_contents($str . '_' . USER_DEVICE . '.html');
  114. }
  115.  
  116. function getFileContent($path)
  117. {
  118. global $RootPath;
  119. return file_get_contents($RootPath . '/templates/' . $path . '.html');
  120. }
  121.  
  122. function detect_device()
  123. {
  124. if (preg_match('/uc browser|ucweb|android|up.browser|up.link|windows ce|iemobile|mini|mmp|symbian|midp|wap|phone|pocket|mobile|pda|psp/i', $_SERVER['HTTP_USER_AGENT'])) {
  125. return true;
  126. }
  127. if (stristr($_SERVER['HTTP_USER_AGENT'], 'windows') && !stristr($_SERVER['HTTP_USER_AGENT'], 'windows ce')) {
  128. return false;
  129. }
  130. if (stristr($_SERVER['HTTP_ACCEPT'], 'text/vnd.wap.wml') || stristr($_SERVER['HTTP_ACCEPT'], 'application/vnd.wap.xhtml+xml')) {
  131. return true;
  132. }
  133. if (isset($_SERVER['HTTP_X_WAP_PROFILE']) || isset($_SERVER['HTTP_PROFILE']) || isset($_SERVER['X-OperaMini-Features']) || isset($_SERVER['UA-pixels'])) {
  134. return true;
  135. }
  136. $dmdarray = array(
  137. 'acs-' => 'acs-', 'alav' => 'alav', 'alca' => 'alca', 'amoi' => 'amoi', 'audi' => 'audi', 'aste' => 'aste',
  138. 'avan' => 'avan', 'benq' => 'benq', 'bird' => 'bird', 'blac' => 'blac', 'blaz' => 'blaz', 'brew' => 'brew', 'cell' => 'cell',
  139. 'cldc' => 'cldc', 'cmd-' => 'cmd-', 'dang' => 'dang', 'doco' => 'doco', 'eric' => 'eric', 'hipt' => 'hipt', 'inno' => 'inno',
  140. 'ipaq' => 'ipaq', 'java' => 'java', 'jigs' => 'jigs', 'kddi' => 'kddi', 'keji' => 'keji', 'leno' => 'leno', 'lg-c' => 'lg-c',
  141. 'lg-d' => 'lg-d', 'lg-g' => 'lg-g', 'lge-' => 'lge-', 'maui' => 'maui', 'maxo' => 'maxo', 'midp' => 'midp', 'mits' => 'mits',
  142. 'mmef' => 'mmef', 'mobi' => 'mobi', 'mot-' => 'mot-', 'moto' => 'moto', 'mwbp' => 'mwbp', 'nec-' => 'nec-', 'newt' => 'newt',
  143. 'noki' => 'noki', 'opwv' => 'opwv', 'palm' => 'palm', 'pana' => 'pana', 'pant' => 'pant', 'pdxg' => 'pdxg', 'phil' => 'phil',
  144. 'play' => 'play', 'pluc' => 'pluc', 'port' => 'port', 'prox' => 'prox', 'qtek' => 'qtek', 'qwap' => 'qwap', 'sage' => 'sage',
  145. 'sams' => 'sams', 'sany' => 'sany', 'sch-' => 'sch-', 'sec-' => 'sec-', 'send' => 'send', 'seri' => 'seri', 'sgh-' => 'sgh-',
  146. 'shar' => 'shar', 'sie-' => 'sie-', 'siem' => 'siem', 'smal' => 'smal', 'smar' => 'smar', 'sony' => 'sony', 'sph-' => 'sph-',
  147. 'symb' => 'symb', 't-mo' => 't-mo', 'teli' => 'teli', 'tim-' => 'tim-', 'tosh' => 'tosh', 'treo' => 'treo', 'tsm-' => 'tsm-',
  148. 'upg1' => 'upg1', 'upsi' => 'upsi', 'vk-v' => 'vk-v', 'voda' => 'voda', 'wap-' => 'wap-', 'wapa' => 'wapa', 'wapi' => 'wapi',
  149. 'wapp' => 'wapp', 'wapr' => 'wapr', 'webc' => 'webc', 'winw' => 'winw', 'winw' => 'winw', 'xda-' => 'xda-'
  150. );
  151. // check if the first four characters of the current user agent are set as a key in the array
  152. if (isset($dmdarray[substr($_SERVER['HTTP_USER_AGENT'], 0, 4)])) {
  153. return true;
  154. }
  155. }
  156.  
  157. function Redirect($url)
  158. {
  159. header("Location: $url");
  160. exit;
  161. }
  162.  
Add Comment
Please, Sign In to add comment