Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.99 KB | None | 0 0
  1.  <?php
  2. $servername = "localhost";
  3. $username = "USER";
  4. $password = "PASSW";
  5. $dbname = "db1";
  6.  
  7. // Create connection
  8. $conn = new mysqli($servername, $username, $password, $dbname);
  9. // Check connection
  10. if ($conn->connect_error) {
  11.     die("Connection failed: " . $conn->connect_error);
  12. }
  13.  
  14. if (isset($_GET['log']) && $_GET['log'] === 'show') {
  15.     $sql = "SELECT * FROM `log`";
  16.     $result = $conn->query($sql);
  17.  
  18.     if ($result->num_rows > 0) {
  19.         print "<h1>Log</h1><pre>";
  20.         while($row = $result->fetch_assoc()) {
  21.             print_r($row);
  22.         }
  23.         print "</pre><h1>End</h1>";
  24.     }
  25. } else {
  26.     $sql = "INSERT INTO `log` (data, data2, data3, data4) VALUES ('" . $_SERVER['HTTP_CLIENT_IP'] . "', '" . $_SERVER['REMOTE_ADDR'] . "', '" . $_SERVER['HTTP_X_FORWARDED_FOR'] . "', '" . $_SERVER['HTTP_REFERER'] . "');";
  27.  
  28.     if ($conn->query($sql) === TRUE) {
  29.         echo "Loading...";
  30.     } else {
  31.         echo "Error: " . $sql . "<br>" . $conn->error;
  32.     }
  33.  
  34.     $conn->close();
  35.  
  36.     header('Location: https://trexi.webnode.cz');
  37. }
  38. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement