$frameworkType = 'normal'; $debugCode = [ 'version' => 4, 'frameworkType' => $frameworkType, ]; $sessionStarted = gdprStartSession($frameworkType); $gdprSession = gdprSessionGet($frameworkType, 'gdpr'); $debugCode['session-started'] = intval($sessionStarted); $gdprCache = gdprSessionGet($frameworkType, 'gdpr-cache'); function gdprSendRequest($url, $post = null, $headers = []) { $ch = curl_init($url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); if($post !== null) { curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post)); } if(!empty($headers)) { curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); } $response = curl_exec($ch); $info = curl_getinfo($ch); curl_close($ch); //print_r($response); return $response; } /** * @return string json [ ip, city, region, country (alpha2) ] */ function gdprGetGeoIp() { global $gdprCache; if(!isset($gdprCache['geo-ip'])) { if (!empty($_SERVER['HTTP_X_REAL_IP'])) { $ip = $_SERVER['HTTP_X_REAL_IP']; } elseif (!empty($_SERVER['HTTP_CLIENT_IP'])) { $ip = $_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip = $_SERVER['REMOTE_ADDR']; } $url = 'https://gdpr.borissov.ee/geo-ip?hash=b498fa41764e0d21b4e17bf3b3fbd305'; $post = ['ip' => $ip]; $result = gdprSendRequest($url, $post); $gdprCache['geo-ip'] = $result; } else { $result = $gdprCache['geo-ip']; } return json_decode($result, true); } function gdprEUCountries() { global $gdprCache; if(!isset($gdprCache['eu-countries'])) { $url = 'https://gdpr.borissov.ee/eu-countries.txt'; $response = gdprSendRequest($url); preg_match('#\[(.*)\]#U', $response, $match); $countries = []; if(isset($match[1])) { $countries = str_replace(['\''], '', $match[1]); $countries = array_filter(array_map('trim', explode(',', $countries))); $gdprCache['eu-countries'] = $countries; } } else { $countries = $gdprCache['eu-countries']; } return $countries; } if (!isset($gdprSession['adBlock'])) { $gdprSession['adBlock'] = [ 'status' => 0, 'isDisabled' => 0, ]; } if (!isset($gdprSession['dnt'])) { $gdprSession['dnt'] = 0; } if (!isset($gdprSession['personalized'])) { $gdprSession['personalized']['status'] = 0; } if ($_SERVER['REQUEST_METHOD'] === 'POST') { $trackActions = [ 'adb', 'adb_d', 'dnt', 'dnt_d', 'f_personalized_allow', 'f_personalized_refuse', 'f_personalized_24_allow', 'f_personalized_24_refuse', ]; if (isset($_POST['gdpr'])) { $post = json_decode($_POST['gdpr'], true); $data = $post['data']; if (!isset($post['type'])) { die(json_encode(['success' => false, 'message' => 'type not set'])); } switch ($post['type']) { case 'api': $url = 'https://gdpr.borissov.ee/api/set'; break; case 'stats': $url = 'https://gdpr.borissov.ee/api/stats'; $data['ua'] = $_SERVER['HTTP_USER_AGENT']; break; case 'eu-countries': $countries = gdprEUCountries(); die(json_encode($countries)); case 'check-url': $content = gdprSendRequest($data['url']); //die(json_encode(['success' => !strstr($content, '404 Not Found'), 'content' => $content])); die(json_encode(['success' => !strstr($content, '404 Not Found')])); default: die(json_encode(['success' => false, 'message' => 'type not set'])); } $response = gdprSendRequest($url, $data); if($post['type'] == 'stats') { $responseDecoded = json_decode($response, true); $actionType = $data['statsData']['type']; if(in_array($actionType, $trackActions)) { if(strpos($actionType, 'adb') !== false) { $gdprSession['adBlock']['status'] = (int)(bool)($actionType == 'adb'); } if(strpos($actionType, 'personalized') !== false) { $gdprSession['personalized']['status'] = (int)(bool)(strstr($actionType, 'allow')); } if($actionType == 'adb_d') { $gdprSession['adBlock']['isDisabled'] = 1; } if($actionType == 'dnt') { $gdprSession['dnt'] = 1; } if($actionType == 'dnt_d') { $gdprSession['dnt'] = 0; } } if(!empty($responseDecoded['uaType'])) { $gdprSession['deviceType'] = $responseDecoded['uaType']; } } gdprSessionSet($frameworkType, 'gdpr', $gdprSession); die($response); } } if(isset($_GET['gdpr-location'])) { $response = gdprGetGeoIp(); die(json_encode($response)); } $geoIp = gdprGetGeoIp(); $euCountries = gdprEUCountries(); $allowedUrls = [ "'self'", "'unsafe-inline'", 'https://gdpr.borissov.ee/', ]; $csp = "Content-Security-Policy: " . "default-src " . implode(' ', $allowedUrls) . "; "; $noCache = 'Cache-Control: no-cache;'; if(isset($_COOKIE['gdpr-borissov-ee'])) { gdprSessionSet($frameworkType, 'gdpr', $gdprSession); gdprDebugCode($debugCode, $gdprSession); return; } if(!in_array($geoIp['country'], $euCountries)) { $status = intval(!$gdprSession['dnt']); $gdprSession['personalized']['status'] = $status; gdprSessionSet($frameworkType, 'gdpr', $gdprSession); gdprDebugCode($debugCode, $gdprSession); return; } gdprSessionSet($frameworkType, 'gdpr', $gdprSession); gdprSessionSet($frameworkType, 'gdpr-cache', $gdprCache); gdprDebugCode($debugCode, $gdprSession); header($csp); header($noCache); function gdprDebugCode($debugCode, $gdprSession) { //global $gdprSession; $debugCode['session'] = $gdprSession; if(isset($_GET['gdpr-debug-code'])) { echo '
'; print_r($debugCode); echo '
'; } } function gdprStartSession($frameworkType) { global $debugCode; switch($frameworkType) { case 'normal': if (session_status() == PHP_SESSION_NONE) { session_start(); $debugCode['session-enable'] = 1; } else { $debugCode['session-is-enabled'] = 1; } $debugCode['session-status'] = session_status(); $debugCode['session-id'] = session_id(); return true; case 'joomla39': if(class_exists('JFactory')) { $mainframe = JFactory::getApplication('site'); $mainframe->initialise(); $session =& JFactory::getSession(); return !empty($session); } return false; } } function gdprSessionGet($frameworkType, $key) { switch($frameworkType) { case 'normal': return isset($_SESSION[$key]) ? $_SESSION[$key] : []; case 'joomla39': if(class_exists('JFactory')) { $session = JFactory::getSession(); return $session->get($key, []); } return []; } } function gdprSessionSet($frameworkType, $key, $val) { switch($frameworkType) { case 'normal': $_SESSION[$key] = $val; break; case 'joomla39': if(class_exists('JFactory')) { $session = JFactory::getSession(); return $session->set($key, $val); } return false; } }

Privacy - Svenska

Användning av cookies

Enligt Europeiska unionens lagstiftning måste man informera användaren om användningen av cookies på vår webbsajt för att säkerställa enkelheten i användningen av den och för att följande tjänster skall fungera korrekt:

  • Google AdSense
  • Google Analytics

Medgivande till användningen av cookies

Om du har besökt vår webbsajt, godkänt användningen av cookies i inställningarna för din webbläsare, ser vi detta som ditt medgivande till användningen av cookies på vår webbsajt.

Användbara länkar:

Populära stavfel
Populära stavfel