Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.66 KB | None | 0 0
  1. <?php
  2.  
  3. $log = 'logsmz.txt';
  4. $ip = $_SERVER['REMOTE_ADDR'];
  5. $page = $_SERVER['REQUEST_URI'];
  6. $refer = $_SERVER['HTTP_REFERER'];
  7. $date_time = date("l j F Y g:ia", time() - date("Z")) ;
  8. $agent = $_SERVER['HTTP_USER_AGENT'];
  9. $fp = fopen("logsmz.txt", "a");
  10. fputs($fp, "
  11. <b>$date_time</b> <br> <b>IP: </b>$ip<br><b>Page: </b>$page<br><b>Refer: </b>$refer<br><b>Useragent:
  12.  
  13. </b>$agent <br><br>
  14. ");
  15. flock($fp, 3);
  16. fclose($fp);
  17.  
  18. function padding($str, $width, $size)
  19. {
  20. $width = ($width - strlen($str)*$size);
  21. return $width;
  22. }
  23.  
  24. function imagestringcutted($img,$font,$y,$x1,$x2,$text,$color,$align="center") {
  25. $fontwidth = imagefontwidth($font);
  26. $fullwidth = strlen($text) * $fontwidth;
  27. $maxwidth = $x2-$x1;
  28. $targetwidth = $fullwidth-(4*$fontwidth);
  29. if($fullwidth > $maxwidth) {
  30. for($i = 0; $i < strlen($text) AND ((strlen($text)-($i-4))*$fontwidth) > $targetwidth ;$i++) { }
  31. $text = substr($text,0,(strlen($text)-$i)-4)."...";
  32. }
  33. if($align == "left") imagestring($img,$font,$x1,$y,$text,$color);
  34. elseif($align == "right") imagestring($img,$font,$x2 - ((strlen($text) * $fontwidth)),$y,$text,$color);
  35. else imagestring($img,$font,($x2-$x1)/ 2 - strlen($text) * $fontwidth / 2,$y,$text,$color);
  36. }
  37.  
  38. function AnalyzeUserAgent($ua)
  39. {
  40. $browsers = "mozilla msie gecko firefox ";
  41. $browsers.= "konqueror safari netscape navigator ";
  42. $browsers.= "opera mosaic lynx amaya omniweb";
  43. $browsers.= "google chrome";
  44.  
  45. $browsers = split(" ", $browsers);
  46.  
  47. $userAgent = strToLower($ua);
  48.  
  49. $l = strlen($userAgent);
  50. for ($i=0; $i<count($browsers); $i++)
  51. {
  52. $browser = $browsers[$i];
  53. $n = stristr($userAgent, $browser);
  54. if(strlen($n)>0)
  55. {
  56. $version = "";
  57. $navigator = $browser;
  58. $j=strpos($userAgent, $navigator)+$n+strlen($navigator)+1;
  59. for (; $j<=$l; $j++)
  60. {
  61. $s = substr ($userAgent, $j, 1);
  62. if(is_numeric($version.$s) )
  63. $version .= $s;
  64. else
  65. break;
  66. }
  67. }
  68. }
  69. if($navigator == "msie")
  70. $navigator = "IE";
  71. סוגי ווינדוס--
  72. }
  73.  
  74. // init
  75. header("Content-type: image/png");
  76. $bg = "bg.png";
  77. $im = @ImageCreateFromPNG($bg);
  78. $color = imagecolorallocate($im, 0, 0, 0);
  79. $ip = $_SERVER['REMOTE_ADDR'];
  80. $user = AnalyzeUserAgent($_SERVER['HTTP_USER_AGENT']);
  81. // Establish a database connection (adjust address, username, and password)
  82. $dbh = mysql_connect("localhost", "XXXX", "XXXX") or die("Could not connect: " . mysql_error());
  83. mysql_select_db("uplo_ip");
  84. // Create a query string
  85. $country_query = "SELECT country2, country FROM ip2country WHERE ipFrom<=INET_ATON('" . $ip . "') AND ipTo>=INET_ATON('" . $ip . "')";
  86. // Execute the query
  87. $country_exec = mysql_query($country_query);
  88. // Fetch the record set into an array
  89. $ccode_array = mysql_fetch_array($country_exec);
  90. // Close the database connection
  91. mysql_close($dbh);
  92. // Get the country code from the array and save it as a variable
  93. $country_code = $ccode_array['country2'];
  94. // Get the country name from the array and save it as a variable
  95. $country_name = $ccode_array['country'];
  96. // If the database contains a match, print out the country name and country code, otherwise print the IP address
  97. if ($country_code != "")
  98. {
  99. $lower = strtolower($country_code);
  100. $image = "<img src=\"flags/{$lower}.gif\" />";
  101. }
  102. // placing the info on the images
  103. imagestringcutted($im,3,30,0,205,$ip,$color,"right");
  104. imagestringcutted($im,3,47,0,195,$user['platform'],$color,"right");
  105. imagestringcutted($im,3,62,0,195,$user['browser']." ".$user['version'],$color,"right");
  106. imagestringcutted($im,3,62,0,195,$image,$color,"right");
  107.  
  108. // print images
  109. ImagePNG($im);
  110. // delete image from MEMORY
  111. ImageDestroy($im);
  112.  
  113. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement