Code: Select all
<?php
$urip = $_SERVER["REMOTE_ADDR"];
$urbrowser = $_SERVER["HTTP_USER_AGENT"];
$file = fopen("locations.txt","a");
include('ip2locationlite.class.php');
$ipLite = new ip2location_lite;
$ipLite->setKey('d0396f12194499c4ef709d170eb921519862b14135e2f8a40b8bb9acd2f5a123');
$locations = $ipLite->getCity($_SERVER['REMOTE_ADDR']);
$errors = $ipLite->getError();
$citynum = 0;
foreach ($locations as $field => $val) {
$citynum +=1;
if ($citynum == 7){
$city = $val;
} if ($citynum == 6){
$region = $val;
}}
$text = "$urip - $city, $region\n$urbrowser\n\n";
fwrite($file,$text);
$text = "Seeing this images tells me your IP, the city, region you live in, and your browser and operating system information.";
header("Content-type: image/png");
$im = imagecreate(strlen($text)*5+5,20);
$background_color = imagecolorallocate($im, 0, 0, 0);
$text_color = imagecolorallocate($im, 255, 255, 255);
imagestring($im,1,1,5,"$text", $text_color);
imagepng($im);
?>