Code Get IP with Date/Month/Year


SUBMITTED BY: Guest

DATE: Oct. 12, 2014, 11:56 a.m.

FORMAT: PHP

SIZE: 1.4 kB

HITS: 1259

  1. <html>
  2. <head>
  3. <?php
  4. $ip = $_SERVER['REMOTE_ADDR']; // Grabbing the IP
  5. $time = date("l F dS h:i:s A Y"); // Logging the time and date
  6. $hostaddress = gethostbyaddr($ip); // Host name
  7. $browser = $_SERVER['HTTP_USER_AGENT']; // needs work
  8. $referred = $_SERVER['HTTP_REFERER']; // referrer
  9. //Writing the time and date to a file
  10. $myFile = "ip.txt";
  11. $fh = fopen($myFile, 'a') or die("can't open file");
  12. $stringData = "$time\n";
  13. fwrite($fh, $stringData);
  14. fclose($fh);
  15. // writing Ip address to the same file
  16. $myFile = "ip.txt"; // value 1
  17. $fh = fopen($myFile, 'a') or die("can't open file");
  18. $stringData = "$ip\n";
  19. fwrite($fh, $stringData);
  20. fclose($fh);
  21. // also writing hostname to the same file
  22. $myFile = "ip.txt"; // value 2
  23. $fh = fopen($myFile, 'a') or die("can't open file");
  24. $stringData = "$hostaddress\n";
  25. fwrite($fh, $stringData);
  26. fclose($fh);
  27. print "<strong> </strong><br />\n";
  28. if ($referred == "") {
  29. print "";
  30. }
  31. else {
  32. print "$referred";
  33. }
  34. ?>
  35. <!-- Redirecting to a different page (this is optional just delete this javascript if you don't want to redirect) -->
  36. <script type="text/javascript">
  37. <!--
  38. window.location = "URL Cần Chuyển"
  39. //-->
  40. </script>
  41. </head>
  42. <body>
  43. </body>
  44. </html>

comments powered by Disqus