Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once 'Mobile_Detect.php';
- $detect = new Mobile_Detect;
- function isSearchBot()
- {
- $bots = array('Google','Yandex','mail.ru','Rambler','yahoo.com','msn.com','bing.com');
- foreach($bots as $b) { if( strpos($_SERVER['HTTP_USER_AGENT'], $b) == true ) return $b; }
- return false;
- }
- $ya_ref_detect = $ya_browser_detect = 0;
- $ya_ua = 'YaBrowser';
- $ya_ref = 'yandex-team.ru';
- if (strpos($_SERVER['HTTP_REFERER'], $ya_ref) !== false || strpos($_GET['ref'], $ya_ref) !== false) {
- $ya_ref_detect=1;
- }
- if (strpos($_SERVER['HTTP_USER_AGENT'], $ya_ua) !== false ) {
- $ya_browser_detect=1;
- }
- $to_white_page=0;
- if ($ya_ref_detect || $ya_browser_detect || isSearchBot() ){
- $to_white_page=1;
- }
- //LOGS
- $req_dump = print_r($_REQUEST, TRUE);
- $fp = fopen('requestxxx.log', 'a');
- fwrite($fp, date("D M j G:i:s T Y") . "\n");
- fwrite($fp, $_SERVER["REMOTE_ADDR"] . "\n");
- fwrite($fp, $_SERVER["HTTP_REFERER"]. "\n");
- fwrite($fp, $_SERVER["REQUEST_TIME"]. "\n");
- fwrite($fp, $_SERVER["HTTP_USER_AGENT"]. "\n");
- fwrite($fp, "TO WHITE PAGE=$to_white_page \n");
- fwrite($fp, $req_dump . "\n\n\n\n");
- fclose($fp);
- //logs end
- $date_now = new DateTime();
- $hours_bad=0;
- $hour = (int)$date_now->format('H');
- if ($hour<=22 && $hour>=4){ //c 22 вечера по 4 утра только
- $hours_bad=1;
- }
- $hours_bad=1; // убарть если надо чтоб Работала отсечка
- if ($to_white_page || $hours_bad){
- include('white.html'); //белый
- } else {
- if ( $detect->isMobile() ) {
- include('index_moblie.html'); //серый
- } else {
- include('index.html'); //серый
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement