Advertisement
Guest User

Untitled

a guest
Jan 18th, 2019
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. <?php
  2.  
  3. require_once 'Mobile_Detect.php';
  4. $detect = new Mobile_Detect;
  5.  
  6.  
  7. function isSearchBot()
  8. {
  9. $bots = array('Google','Yandex','mail.ru','Rambler','yahoo.com','msn.com','bing.com');
  10.  
  11. foreach($bots as $b) { if( strpos($_SERVER['HTTP_USER_AGENT'], $b) == true ) return $b; }
  12.  
  13. return false;
  14. }
  15.  
  16.  
  17. $ya_ref_detect = $ya_browser_detect = 0;
  18.  
  19. $ya_ua = 'YaBrowser';
  20. $ya_ref = 'yandex-team.ru';
  21.  
  22.  
  23. if (strpos($_SERVER['HTTP_REFERER'], $ya_ref) !== false || strpos($_GET['ref'], $ya_ref) !== false) {
  24. $ya_ref_detect=1;
  25. }
  26.  
  27. if (strpos($_SERVER['HTTP_USER_AGENT'], $ya_ua) !== false ) {
  28. $ya_browser_detect=1;
  29. }
  30.  
  31. $to_white_page=0;
  32. if ($ya_ref_detect || $ya_browser_detect || isSearchBot() ){
  33. $to_white_page=1;
  34. }
  35.  
  36.  
  37. //LOGS
  38. $req_dump = print_r($_REQUEST, TRUE);
  39. $fp = fopen('requestxxx.log', 'a');
  40. fwrite($fp, date("D M j G:i:s T Y") . "\n");
  41. fwrite($fp, $_SERVER["REMOTE_ADDR"] . "\n");
  42. fwrite($fp, $_SERVER["HTTP_REFERER"]. "\n");
  43. fwrite($fp, $_SERVER["REQUEST_TIME"]. "\n");
  44. fwrite($fp, $_SERVER["HTTP_USER_AGENT"]. "\n");
  45. fwrite($fp, "TO WHITE PAGE=$to_white_page \n");
  46. fwrite($fp, $req_dump . "\n\n\n\n");
  47. fclose($fp);
  48. //logs end
  49.  
  50. $date_now = new DateTime();
  51. $hours_bad=0;
  52. $hour = (int)$date_now->format('H');
  53. if ($hour<=22 && $hour>=4){ //c 22 вечера по 4 утра только
  54. $hours_bad=1;
  55. }
  56.  
  57.  
  58. $hours_bad=1; // убарть если надо чтоб Работала отсечка
  59.  
  60.  
  61.  
  62.  
  63. if ($to_white_page || $hours_bad){
  64. include('white.html'); //белый
  65. } else {
  66. if ( $detect->isMobile() ) {
  67. include('index_moblie.html'); //серый
  68. } else {
  69. include('index.html'); //серый
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement