//exit; if (isset($_GET['getref'])) { file_put_contents("/tmp/ref.txt",var_export($_SERVER,true)."\n",FILE_APPEND); } /*if (!in_array($_SERVER['REMOTE_ADDR'],array('95.169.186.103'))) { $block = file_get_contents("/home/politnavigator/html/maintenance.html"); echo $block; exit; }*/ $load = sys_getloadavg(); if ($load[1] > 40 && !in_array($_SERVER['REMOTE_ADDR'],array('62.109.6.167','95.169.186.103','31.40.143.252'))) { $block = file_get_contents("/home/politnavigator/html/maintenance.html"); echo $block; exit; // header('HTTP/1.1 503 Too busy, try again later'); // die('Server too busy. Please try again later.'); } //if (!in_array($_SERVER['REMOTE_ADDR'],array('62.109.6.167','95.169.186.103'))) { // echo "Скоро всё заработает :)".$_SERVER['REMOTE_ADDR']; //} // google translate //global $is_gtranslate; //echo substr($_SERVER['DOCUMENT_URI'],0,4); //echo $_SERVER['DOCUMENT_URI']; //exit; //echo $_SERVER['QUERY_STRING']; //exit; if (stripos($_SERVER['QUERY_STRING'],"/amp?/amp?/amp?/") !== false) { header("Location: ".$_SERVER['DOCUMENT_URI']); exit; } //if (substr($_SERVER['REQUEST_URI'],0,4) == '/en/') { function striposa($haystack, $needles=array(), $offset=0) { $chr = array(); foreach($needles as $needle) { $res = stripos($haystack, $needle, $offset); if ($res !== false) $chr[$needle] = $res; } if(empty($chr)) return false; return min($chr); } //if ($_SERVER['REMOTE_ADDR'] != '62.109.6.167') { // var_dump($_SERVER); // exit; //} if ($_SERVER['QUERY_STRING'] == 'refresh') { header("Location: /"); exit; } require("wp-includes/Mobile_Detect.php"); $detect = new Mobile_Detect; $deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer'); if (!empty($_SERVER['HTTP_USER_AGENT'])) { if (stripos( $_SERVER['HTTP_USER_AGENT'], 'google' ) !== false) { $deviceType = 'phone'; } } //sleep(intval(mt_rand(5,10))); if (empty($_GET['s'])&&substr($_SERVER['DOCUMENT_URI'],0,5) == '/page') { header("Location: /"); exit; } if (substr($_SERVER['HTTP_HOST'],-4) == ".net") { define("IS_POLITNET",true); define("COOKIE_DOMAIN","politnavigator.net"); } else { define("IS_POLITNET",false); define("COOKIE_DOMAIN","politnavigator.news"); } include("ad.php"); function URICleanupFull($uri) { /* $uri = str_replace("full=1&","",$uri); $uri = str_replace("full=1","",$uri); if ($uri=="/?") { $uri = "/"; }*/ // $uri = "/ehkonomist-gigantskaya-dyra-v-byudzhete-ukraine-ni-nelzya-davat-novyjj-kredit.html/amp"; $sp = preg_split("/\?/",$uri); // var_dump($sp); // exit; if (count($sp)>1) { // unset($_GET['_gl']); $vals = array(); foreach ($_GET as $k=>$v) { if ($k != "_gl") { $vals[] = $k."=".$v; } } $uri = $sp[0]; if (count($vals)>0) { $uri .= "?".implode("&",$vals); } } return $uri; } if (stripos($_SERVER['HTTP_HOST'],'politnavigator.net') !== false) { //echo "net"; define("FULL_SITE_URL","https://www.politnavigator.net"); define("MOBILE_SITE_URL","https://m.politnavigator.net"); } else if (stripos($_SERVER['HTTP_HOST'],'politnavigator.news') !== false) { //echo "news"; define("FULL_SITE_URL","https://www.politnavigator.news"); define("MOBILE_SITE_URL","https://m.politnavigator.news"); } else { //echo "default"; define("FULL_SITE_URL","https://www.politnavigator.net"); define("MOBILE_SITE_URL","https://m.politnavigator.net"); } //exit; if (empty($_SERVER['HTTP_REFERER']) || (stripos($_SERVER['HTTP_REFERER'],'politnavigator')===FALSE)) { unset($_COOKIE['__cf_mob_redir']); setcookie('__cf_mob_redir', null, -1, '/'); } if (in_array($_SERVER['HTTP_HOST'],array('m.politnavigator.net','m.politnavigator.news'))) { unset($_COOKIE['__cf_mob_redir']); setcookie('__cf_mob_redir', null, -1, '/'); define("MOBILE_SITE",true); } else { define("MOBILE_SITE",false); } //if (isset($_COOKIE['__cf_mob_redir'])&&($_COOKIE['__cf_mob_redir']==0)) { if (($_SERVER['HTTP_HOST'] == 'en.politnavigator.net') || (isset($_COOKIE['cf_mob_redir'])&&($_COOKIE['cf_mob_redir']==1))) { define("FORCE_FULL_VERSION",true); } if (!defined("FORCE_FULL_VERSION")) { define("FORCE_FULL_VERSION",false); } /*if ((!MOBILE_SITE)&&($deviceType != 'computer')) { if (true) { /// and some coockie to use full/mobile if (in_array($_SERVER['HTTP_HOST'],array('politnavigator.news','www.politnavigator.news'))) { $location = $_SERVER['HTTP_X_FORWARDED_PROTO']."://m.politnavigator.news".$_SERVER['REQUEST_URI']; // header("HTTP/1.1 301 Moved Permanently"); header("Location: ".$location); exit; } } } if ((!MOBILE_SITE)&&($deviceType != 'computer')) { if (true) { /// and some coockie to use full/mobile if (in_array($_SERVER['HTTP_HOST'],array('politnavigator.net','www.politnavigator.net'))) { $location = $_SERVER['HTTP_X_FORWARDED_PROTO']."://m.politnavigator.net".$_SERVER['REQUEST_URI']; // header("HTTP/1.1 301 Moved Permanently"); header("Location: ".$location); exit; } } }*/ //if ($_SERVER['REMOTE_ADDR'] == '185.71.83.130') { // file_put_contents("/tmp/tymah321321",var_export($_SERVER,true)); //} //$msg = date("Y-m-d H:i:s")." HTTP_CF_IPCOUNTRY: ".$_SERVER['HTTP_CF_IPCOUNTRY'].", HTTP_X_FORWARDED_FOR: ".$_SERVER['HTTP_X_FORWARDED_FOR']."\n"; //file_put_contents("/tmp/ip_country.log",$msg,FILE_APPEND); if (!in_array($_SERVER['HTTP_HOST'],array('www.politnavigator.net','en.politnavigator.net','politnavigator.net','www.politnavigator.news','politnavigator.news','m.politnavigator.news','m.politnavigator.net','mail.politnavigator.net'))) { exit; } // politnavigator.cf killer if (!empty($_SERVER['HTTP_REFERER'])&&stripos($_SERVER['HTTP_REFERER'],'politnavigator.cf')!==FALSE) { header('HTTP/1.0 404 Not Found', true, 404); exit; } if (stripos($_SERVER['REMOTE_ADDR'],"2a02:4780:bad:7:fced:1ff:fe07")!==FALSE) { header('HTTP/1.0 404 Not Found', true, 404); exit; } // end of politnavigator.cf killer $uri = $_SERVER['DOCUMENT_URI']; $sp = preg_split("/\//",$uri); $uri = "/".$_SERVER['HTTP_HOST']."_".$sp[1]; //echo $uri; //exit; //echo "111"; //var_dump($_SERVER); function wp_is_mobile_fast() { global $deviceType; if ($deviceType != 'computer') { return true; } else { return false; } } function wp_is_mobile_fast1() { $is_mobile = null; if ( isset( $is_mobile ) ) { return $is_mobile; } if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) { $is_mobile = false; } elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Mobile' ) !== false // many mobile devices (all iPhone, iPad, etc.) || stripos( $_SERVER['HTTP_USER_AGENT'], 'google' ) !== false || strpos( $_SERVER['HTTP_USER_AGENT'], 'Android' ) !== false || strpos( $_SERVER['HTTP_USER_AGENT'], 'Silk/' ) !== false || strpos( $_SERVER['HTTP_USER_AGENT'], 'Kindle' ) !== false || strpos( $_SERVER['HTTP_USER_AGENT'], 'BlackBerry' ) !== false || strpos( $_SERVER['HTTP_USER_AGENT'], 'Opera Mini' ) !== false || strpos( $_SERVER['HTTP_USER_AGENT'], 'Opera Mobi' ) !== false // || strpos( $_SERVER['HTTP_USER_AGENT'], 'WebKit' ) !== false ) { $is_mobile = true; } else { $is_mobile = false; } return $is_mobile; } // test of redirect to mobile //var_dump($sp); //exit; if (false && !empty($sp[1])&&(substr($sp[1],-5)==".html")&&(empty($sp[2]))) { if ((empty($sp[2]))||($sp[2]!='amp')) { if (!FORCE_FULL_VERSION && (MOBILE_SITE||wp_is_mobile_fast())) { $current_url = $sp[1]; $amp_current_url = $current_url . '/amp?imnu='.md5($_SERVER['REMOTE_ADDR'].(empty($_SERVER['HTTP_REFERER'])?'':$_SERVER['HTTP_REFERER']).$_SERVER['HTTP_USER_AGENT']).(!empty($_GET['utm_source'])?"&utm_source=".$_GET['utm_source']:""); // if (!empty($_SERVER['HTTP_USER_AGENT'])&&striposa($_SERVER['HTTP_USER_AGENT'],array('google','lighthouse'))===FALSE) { // if (false) { echo ''; // } exit; } } } if (in_array($_SERVER['REMOTE_ADDR'], // array('185.71.83.130','62.109.6.167','89.107.138.239','89.107.138.229','178.62.89.121','89.107.138.175','178.62.89.121','89.107.138.247','89.107.138.191','89.107.138.110','178.34.158.243','89.107.138.86') array('185.71.83.130','89.107.138.239','89.107.138.229','178.62.89.121','89.107.138.175','178.62.89.121','89.107.138.247','89.107.138.191','89.107.138.110','178.34.158.243','89.107.139.210') )) { $no_hard_cache = true; } else { $no_hard_cache = false; } // $no_hard_cache = true; if(!empty($_SERVER['HTTP_USER_AGENT'])&&(stripos( $_SERVER['HTTP_USER_AGENT'], 'google' ) !== false)) { header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); } $sp = preg_split('/\?/',$_SERVER['REQUEST_URI']); //var_dump( $sp[0]); //exit; //if ($_SERVER['DOCUMENT_URI'] == '/index.php') { if ($sp[0] == '/') { $is_root_page = true; $no_hard_cache = true; } else { $is_root_page = false; } if (!empty($_GET['s'])) { $is_root_page = false; $no_hard_cache = true; } //echo $_SERVER['REQUEST_URI']; if (!FORCE_FULL_VERSION&&($_SERVER['REQUEST_URI'] == '/')&&wp_is_mobile_fast()) { //echo 1; $no_hard_cache = true; } if (($_SERVER['REQUEST_URI'] == '/?news=all')&&wp_is_mobile_fast()) { //echo 1; $no_hard_cache = true; } if (!empty($_GET['newsfeed'])) { $no_hard_cache = true; } if (!empty($_GET['passcode'])) { $no_hard_cache = true; } //if (!empty($_SERVER['HTTP_USER_AGENT'])&&(stripos($_SERVER['HTTP_USER_AGENT'],'google')!==FALSE)) { if (!empty($_SERVER['HTTP_USER_AGENT'])&&(stripos($_SERVER['HTTP_USER_AGENT'],'google')!==FALSE)) { $no_hard_cache = true; } if (count($sp)>=3) { if ($sp[2] == "amp") { $uri = "/amp/".$sp[1]; } $no_hard_cache = true; } //if (in_array($_SERVER['REMOTE_ADDR'],array('185.71.83.130','62.109.6.167','89.107.138.239'))) { //} /*if (file_exists("wp-restore/html".$uri)) { $page = file_get_contents("wp-restore/html".$uri); $page = str_replace("http://www.polit","https://www.polit",$page); echo $page; exit; }*/ $no_hard_cache = true; /* //if ($_SERVER['REMOTE_ADDR']=='62.109.6.167') { //echo ""; if (substr($uri,-10) == "_index.php") { //echo "123"; //exit; //if (!$no_hard_cache && file_exists("new_static_cache".$uri)) { $file_cache_number = intval(time()/60); // file_put_contents("new_cache/index_".$_SERVER['HTTP_HOST'].$file_cache_number.".dat1","aaa"); if (empty($_GET['s'])&& !$no_hard_cache && file_exists("new_cache/index_".$_SERVER['HTTP_HOST'].$file_cache_number.".dat")) { $page = file_get_contents("new_cache/index_".$_SERVER['HTTP_HOST'].$file_cache_number.".dat"); $page = str_replace("http://www.polit","https://www.polit",$page); echo $page; // echo ""; exit; } else { // echo ""; } } else { // echo ""; } //} if (!$no_hard_cache && file_exists("new_static_cache".$uri)) { //echo $uri; //exit; $page = file_get_contents("new_static_cache".$uri); $page = str_replace("http://www.polit","https://www.polit",$page); echo $page; exit; } */ /** * Front to the WordPress application. This file doesn't do anything, but loads * wp-blog-header.php which does and tells WordPress to load the theme. * * @package WordPress */ /** * Tells WordPress to load the WordPress theme and output it. * * @var bool */ define( 'WP_USE_THEMES', true ); /** Loads the WordPress Environment and Template */ require( dirname( __FILE__ ) . '/wp-blog-header.php' );