Advertisement
Guest User

IpLog

a guest
Apr 28th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.29 KB | None | 0 0
  1. <?php
  2. error_reporting(E_ALL ^ E_WARNING);
  3. $ref = @$_SERVER[HTTP_REFERER];
  4. $agent = @$_SERVER[HTTP_USER_AGENT];
  5. $ip = @$_SERVER['REMOTE_ADDR'];
  6.  
  7. $host = "IP";
  8. $port = "PORT";
  9. $user = "USER";
  10. $password = "PASS";
  11. $dbname = "NAME";
  12. $tblname = "iplogging";
  13.  
  14. $link = mysqli_connect ($host, $user, $password, $dbname, $port);
  15. $result = mysqli_query ($link, "USE $dbname");
  16. $result = "INSERT INTO iplogging(ref, agent, ip) VALUES ('$ref', '$agent', '$ip')";
  17. $exec = mysqli_query ($link, $result);
  18. ?>
  19.  
  20. iplogging.php
  21.  
  22. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  23. <html lang="de">
  24. <head>
  25. <title>IP LOGS</title>
  26. <meta charset="utf-8">
  27. <meta name="viewport" content="width=device-width, initial-scale=1">
  28. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
  29. <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">
  30. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
  31. <style type="text/css">
  32. .alignright {
  33. float: right;
  34. }
  35. </style>
  36. </head>
  37. <body>
  38. <div class="container">
  39. <div>
  40. <h2>IP LOGS</h2>
  41. </div>
  42. <?php
  43. //error_reporting(E_ALL ^ E_WARNING);
  44. $ref = @$_SERVER[HTTP_REFERER];
  45. $agent = @$_SERVER[HTTP_USER_AGENT];
  46. $ip = @$_SERVER['REMOTE_ADDR'];
  47.  
  48. $host = "IP";
  49. $port = "PORT";
  50. $user = "USER";
  51. $password = "PASS";
  52. $dbname = "NAME";
  53. $tblname = "iplogging";
  54.  
  55. $link = mysqli_connect ($host, $user, $password, $dbname, $port);
  56. $result = mysqli_query ($link, "USE $dbname");
  57. $result = "SELECT * FROM $tblname";
  58. $result .= " ORDER BY id";
  59. $exec = mysqli_query ($link, $result);
  60. echo "<table class=\"table table-hover table-bordered\">
  61. <thead>
  62. <tr>
  63. <th>ID</th>
  64. <th>REFERRER</th>
  65. <th>AGENT</th>
  66. <th>IP</th>
  67. <th>TIMESTAMP</th>
  68. <th>GEOLOCATION</th>
  69. <th>DELETE ENTRY</th>
  70. </tr>
  71. </thead>
  72. <tbody>";
  73. while($row = mysqli_fetch_array($exec, MYSQLI_BOTH)) {
  74. $country_code = trim(file_get_contents("http://ipinfo.io/$row[3]/country"));
  75. $host_name = trim(file_get_contents("http://ipinfo.io/$row[3]/hostname"));
  76. $city = trim(file_get_contents("http://ipinfo.io/$row[3]/city"));
  77. echo "
  78. <tr>
  79. <td>$row[0]</td>
  80. <td>$row[1]</td>
  81. <td>$row[2]</td>
  82. <td>$row[3]</td>
  83. <td>$row[4]</td>
  84. <td style=\"width: 25%;\">Location: $country_code, $city<br />Host: " . $host_name . "</a></td>
  85. <td><a href=" . "iplogger.php?id=" . $row[0] . "><button class=\"btn btn-danger\">DELETE</button></td>
  86. </tr>";
  87. }
  88. echo " </tbody>
  89. </table>";
  90.  
  91. if(!empty($_GET['id'])){
  92. $tempid = $_GET['id'];
  93. $deleterow = mysqli_query ($link, "USE $dbname");
  94. $deleterow = mysqli_query ($link,"DELETE FROM $tblname WHERE id = " . $tempid);
  95. header('location: iplogger.php');
  96. }
  97. ?>
  98. </div>
  99. </body>
  100. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement