Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $log = 'logsmz.txt';
- $ip = $_SERVER['REMOTE_ADDR'];
- $page = $_SERVER['REQUEST_URI'];
- $refer = $_SERVER['HTTP_REFERER'];
- $date_time = date("l j F Y g:ia", time() - date("Z")) ;
- $agent = $_SERVER['HTTP_USER_AGENT'];
- $fp = fopen("logsmz.txt", "a");
- fputs($fp, "
- <b>$date_time</b> <br> <b>IP: </b>$ip<br><b>Page: </b>$page<br><b>Refer: </b>$refer<br><b>Useragent:
- </b>$agent <br><br>
- ");
- flock($fp, 3);
- fclose($fp);
- function padding($str, $width, $size)
- {
- $width = ($width - strlen($str)*$size);
- return $width;
- }
- function imagestringcutted($img,$font,$y,$x1,$x2,$text,$color,$align="center") {
- $fontwidth = imagefontwidth($font);
- $fullwidth = strlen($text) * $fontwidth;
- $maxwidth = $x2-$x1;
- $targetwidth = $fullwidth-(4*$fontwidth);
- if($fullwidth > $maxwidth) {
- for($i = 0; $i < strlen($text) AND ((strlen($text)-($i-4))*$fontwidth) > $targetwidth ;$i++) { }
- $text = substr($text,0,(strlen($text)-$i)-4)."...";
- }
- if($align == "left") imagestring($img,$font,$x1,$y,$text,$color);
- elseif($align == "right") imagestring($img,$font,$x2 - ((strlen($text) * $fontwidth)),$y,$text,$color);
- else imagestring($img,$font,($x2-$x1)/ 2 - strlen($text) * $fontwidth / 2,$y,$text,$color);
- }
- function AnalyzeUserAgent($ua)
- {
- $browsers = "mozilla msie gecko firefox ";
- $browsers.= "konqueror safari netscape navigator ";
- $browsers.= "opera mosaic lynx amaya omniweb";
- $browsers.= "google chrome";
- $browsers = split(" ", $browsers);
- $userAgent = strToLower($ua);
- $l = strlen($userAgent);
- for ($i=0; $i<count($browsers); $i++)
- {
- $browser = $browsers[$i];
- $n = stristr($userAgent, $browser);
- if(strlen($n)>0)
- {
- $version = "";
- $navigator = $browser;
- $j=strpos($userAgent, $navigator)+$n+strlen($navigator)+1;
- for (; $j<=$l; $j++)
- {
- $s = substr ($userAgent, $j, 1);
- if(is_numeric($version.$s) )
- $version .= $s;
- else
- break;
- }
- }
- }
- if($navigator == "msie")
- $navigator = "IE";
- סוגי ווינדוס--
- }
- // init
- header("Content-type: image/png");
- $bg = "bg.png";
- $im = @ImageCreateFromPNG($bg);
- $color = imagecolorallocate($im, 0, 0, 0);
- $ip = $_SERVER['REMOTE_ADDR'];
- $user = AnalyzeUserAgent($_SERVER['HTTP_USER_AGENT']);
- // Establish a database connection (adjust address, username, and password)
- $dbh = mysql_connect("localhost", "XXXX", "XXXX") or die("Could not connect: " . mysql_error());
- mysql_select_db("uplo_ip");
- // Create a query string
- $country_query = "SELECT country2, country FROM ip2country WHERE ipFrom<=INET_ATON('" . $ip . "') AND ipTo>=INET_ATON('" . $ip . "')";
- // Execute the query
- $country_exec = mysql_query($country_query);
- // Fetch the record set into an array
- $ccode_array = mysql_fetch_array($country_exec);
- // Close the database connection
- mysql_close($dbh);
- // Get the country code from the array and save it as a variable
- $country_code = $ccode_array['country2'];
- // Get the country name from the array and save it as a variable
- $country_name = $ccode_array['country'];
- // If the database contains a match, print out the country name and country code, otherwise print the IP address
- if ($country_code != "")
- {
- $lower = strtolower($country_code);
- $image = "<img src=\"flags/{$lower}.gif\" />";
- }
- // placing the info on the images
- imagestringcutted($im,3,30,0,205,$ip,$color,"right");
- imagestringcutted($im,3,47,0,195,$user['platform'],$color,"right");
- imagestringcutted($im,3,62,0,195,$user['browser']." ".$user['version'],$color,"right");
- imagestringcutted($im,3,62,0,195,$image,$color,"right");
- // print images
- ImagePNG($im);
- // delete image from MEMORY
- ImageDestroy($im);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement