Advertisement
Guest User

Untitled

a guest
Jan 11th, 2019
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.05 KB | None | 0 0
  1. <?php
  2. function time_elapsed_string($datetime, $full = false)
  3. {
  4. $now = new DateTime;
  5. $ago = new DateTime($datetime);
  6. $diff = $now->diff($ago);
  7. $diff->w = floor($diff->d / 7);
  8. $diff->d -= $diff->w * 7;
  9. $string = array(
  10. 'y' => 'year',
  11. 'm' => 'month',
  12. 'w' => 'week',
  13. 'd' => 'day',
  14. 'h' => 'hour',
  15. 'i' => 'minute',
  16. 's' => 'second',
  17. );
  18. foreach ($string as $k => &$v) {
  19. if ($diff->$k) {
  20. $v = $diff->$k . ' ' . $v . ($diff->$k > 1 ? 's' : '');
  21. } else {
  22. unset($string[$k]);
  23. }
  24. }
  25. if (!$full) {
  26. $string = array_slice($string, 0, 1);
  27. }
  28. return $string ? implode(', ', $string) . ' ago' : 'just now';
  29. }
  30. function utf8_encode_deep($input) //i know it already exists but i couldnt make it work
  31. {
  32. $output = array();
  33. foreach ($input as $key => $value) {
  34. if (is_string($value)) {
  35. $value = utf8_encode($value);
  36. }
  37. if (is_string($key)) {
  38. $key = utf8_encode($key);
  39. }
  40. if (is_array($value)) {
  41. $value = utf8_encode_deep($value);
  42. }
  43. $output[$key] = $value;
  44. }
  45. return $output;
  46. }
  47. //mysql
  48. $servername = "localhost";
  49. $username = "root";
  50. $password = "pw";
  51. $dbname = "nl";
  52. $conn = new mysqli($servername, $username, $password, $dbname);
  53. if ($conn->connect_error) {
  54. die("connection failed to the database");
  55. }
  56. $getmsg_sql = "SELECT * FROM user_logs ORDER BY timestamp"; //you dont have to use limit but i do so fuck off
  57. $getmsg_result = $conn->query($getmsg_sql);
  58. $getstats_sql = "SELECT timestamp, ipadress FROM `website_logs` WHERE 1 ORDER BY ID DESC LIMIT 1";
  59. $getstats_result = $conn->query($getstats_sql);
  60. if ($getstats_result->num_rows > 0) {
  61. while ($row = $getstats_result->fetch_assoc()) {
  62. $last_message_received = substr(strval($row['timestamp']), 0, 19);
  63. $last_id_received = $row['timestamp'];
  64. }
  65. }
  66. //insert the client id between the brackets or ur mother will have the gay
  67. $adminList = array("", "");
  68. //nigger1, nigger2
  69. if ($getmsg_result->num_rows > 0) {
  70. while ($row = $getmsg_result->fetch_assoc()) {
  71. if (in_array($row['author_id'], $adminList)) {
  72. $lineIsRed = true;
  73. }
  74. $str = $str . "<tr>\n<th>" . $row['username'] . "</th>\n<th>" . substr(strval($row['last_known_ip']), 0, 19) . "</th>\n<th>" . $row['timestamp'] . "";
  75. if ($lineIsRed) {
  76. // $str = $str . '<font color="red">' . utf8_encode($row['country']) . "</font>\n";
  77. } else {
  78. // $str = $str . utf8_encode($row['author_name']);
  79. }
  80. // $str = $str . "</th>\n<th>" . utf8_encode($row['op_system']).
  81. "";
  82. if ($lineIsRed) {
  83. $str = $str . '</font>';
  84. }
  85. $lineIsRed = false;
  86. }
  87. } else {
  88. die("something went wrong. go to index and go back there");
  89. }
  90. $time_out = time_elapsed_string($last_message_received);
  91. ?>
  92.  
  93. <style>
  94. table {
  95. font-family: arial, sans-serif;
  96. border-collapse: collapse;
  97. width: 100%;
  98. }
  99. td, th {
  100. border: 1px solid #dddddd;
  101. text-align: left;
  102. padding: 8px;
  103. }
  104. tr:nth-child(even) {
  105. background-color: #dddddd;
  106. }
  107. </style>
  108.  
  109. <center>
  110. <title>weblogs</title>
  111. <h1>nightlights logs</h1>
  112.  
  113. <?php
  114. $time_out = time_elapsed_string($last_message_received);
  115. $dbc = mysqli_connect('localhost', 'root', 'pw', 'nl') or die('Error connecting to MySQL server.');
  116. if(isset($_POST['submit_button']))
  117. {
  118. mysqli_query($dbc, 'TRUNCATE TABLE `user_logs`');
  119. header("Location: " . $_SERVER['PHP_SELF']);
  120. exit();
  121. }
  122. $verse = "2.0";
  123. echo "if theres too many shit just press this button";
  124. ?>
  125. <form method="post" action="">
  126. <input name="submit_button" type="submit" value=" empty button " />
  127. </form>
  128.  
  129. <br><br>
  130.  
  131. <table>
  132. <tr>
  133. <th>username</th>
  134. <th>ipadress</th>
  135. <th>timestamp</th>
  136. <th>user os</th>-->
  137. <th>image</th>-->
  138. </tr>
  139.  
  140. <!-- you can make some comments here if your not gey lol -->
  141. <br><br>
  142. <?php echo $str; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement