/** * Get the location from a given URL using the _ipLocationService object. * Returns falue if no result found or URL is invalid. * * @param string $url The URL to convert. * * @return boolean|IpLocation_Results The IpLocation_Results results * object. Returns false if no results. */ public function getUrlLocation($url) { if (!filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED)) { return false; } $ip = $this->convertDomainToIp($url); $objIpLocationObject = new IpLocation_Ip($this->_ipLocationService); return $objIpLocationObject->getIpLocation($ip); }
public function testIpLocationGivenInvalidIp3() { $objIpLocationObject = new IpLocation_Ip(new IpLocation_Service_CsvWebhosting()); $this->assertFalse($objIpLocationObject->getIpLocation('3.300.300.30')); }
$message = 'Invalid query: ' . mysql_error() . "\n"; $message .= 'Whole query: ' . $query; mysql_close($link); die($message); } $tPeriod = 'since last cleared'; if ($timePeriod > 0) { $tPeriod = "of {$timePeriod} days"; } echo '<html>'; echo "<h1>Podcast requests</h1>"; echo "<h2>For the time period {$tPeriod}</h2>"; echo "<table border='1'>"; echo "<tr><td ><b>Index</b></td><td WIDTH=170><b>Date and Time</b></td><td WIDTH=200><b>Country</b></td><td WIDTH=200><b>IP Address</b></td></tr>"; $counter = 0; while ($row = mysql_fetch_assoc($result)) { $counter += 1; $dateTime = $row['datetime']; $ipAddress = $row['ip']; $objIpLocationObject = new IpLocation_Ip(new IpLocation_Service_GeoIp()); $countryNameResult = $objIpLocationObject->getIpLocation($ipAddress); $countryName = $countryNameResult->__get('countryName'); echo "<tr><td>{$counter}</td><td>{$dateTime}</td><td>{$countryName}</td><td>{$ipAddress}</td></tr>"; } echo "</table><br><a href='http://summerstreetchurch.org/podcasting/stats.php?period=all'>All</a><a> </a><a href='http://summerstreetchurch.org/podcasting/stats.php?period=1'>Last 24 hours</a><br>"; echo "<a href='http://summerstreetchurch.org/podcasting/stats.php?period=7'>Last 7 days</a><a> </a><a href='http://summerstreetchurch.org/podcasting/stats.php?period=31'>Last 31 days</a><br>"; echo "<br><a href='http://summerstreetchurch.org/podcasting/stats.php?period=clear'>Clear Stats</a>"; echo "<br><br><a href='http://summerstreetchurch.org'>Summer Street Church website</a>"; echo '</html>'; mysql_close($link); mysql_free_result($result);