Skip to content

Instantly share code, notes, and snippets.

@pateketrueke
Created October 5, 2012 15:06
Show Gist options
  • Save pateketrueke/3840359 to your computer and use it in GitHub Desktop.
Save pateketrueke/3840359 to your computer and use it in GitHub Desktop.
Function to retrieve the IP location (fake)
<?php
function region($from)
{
static $url = 'http://www.geoiptool.com/?IP=%s';
$html = file_get_contents(sprintf($url, $from));
$html = strip_tags($html, '<a><span>');
if (preg_match('/Country\s+code:<\/span>([^<>]+)<span/i', $html, $match))
{
if (preg_match('/(\w+)\s+\(\w+\)/', $match[1], $out))
{
return $out[1];
}
}
return FALSE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment