<?php
// the function returns the ip address of the person viewing the page
function userIP()
{
return (isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']);
}
// here we include the necessary files for the geoip script
include("./geoip/geoip.inc");
include("./geoip/geoipcity.inc");
include("./geoip/geoipregionvars.php");
// we open the database file
$gi = geoip_open("./geoip/GeoLiteCity.dat", GEOIP_STANDARD);
// we optain the necessary datails about the IP
$rsGeoData = geoip_record_by_addr($gi, userIP());
//close the database file
geoip_close($gi);
$city = ($rsGeoData->city); // $city stores the name of the city coresponding to the IP
$randNr = rand(1000,2000); // generate a random number between 1000 and 2000
// because the accuracy of the data base is not 100% for every country
// we show an alternative text if the city could not be found
if($city == ""){
echo "[B]We`ve Found $randNr Black Singles in Your Area Online Now![/B]";
}
else{
// show the message
echo "[B]We`ve Found $randNr Black Singles in $city Online Now![/B]";
}
?>