Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function time_elapsed_string($datetime, $full = false)
- {
- $now = new DateTime;
- $ago = new DateTime($datetime);
- $diff = $now->diff($ago);
- $diff->w = floor($diff->d / 7);
- $diff->d -= $diff->w * 7;
- $string = array(
- 'y' => 'year',
- 'm' => 'month',
- 'w' => 'week',
- 'd' => 'day',
- 'h' => 'hour',
- 'i' => 'minute',
- 's' => 'second',
- );
- foreach ($string as $k => &$v) {
- if ($diff->$k) {
- $v = $diff->$k . ' ' . $v . ($diff->$k > 1 ? 's' : '');
- } else {
- unset($string[$k]);
- }
- }
- if (!$full) {
- $string = array_slice($string, 0, 1);
- }
- return $string ? implode(', ', $string) . ' ago' : 'just now';
- }
- function utf8_encode_deep($input) //i know it already exists but i couldnt make it work
- {
- $output = array();
- foreach ($input as $key => $value) {
- if (is_string($value)) {
- $value = utf8_encode($value);
- }
- if (is_string($key)) {
- $key = utf8_encode($key);
- }
- if (is_array($value)) {
- $value = utf8_encode_deep($value);
- }
- $output[$key] = $value;
- }
- return $output;
- }
- //mysql
- $servername = "localhost";
- $username = "root";
- $password = "pw";
- $dbname = "nl";
- $conn = new mysqli($servername, $username, $password, $dbname);
- if ($conn->connect_error) {
- die("connection failed to the database");
- }
- $getmsg_sql = "SELECT * FROM user_logs ORDER BY timestamp"; //you dont have to use limit but i do so fuck off
- $getmsg_result = $conn->query($getmsg_sql);
- $getstats_sql = "SELECT timestamp, ipadress FROM `website_logs` WHERE 1 ORDER BY ID DESC LIMIT 1";
- $getstats_result = $conn->query($getstats_sql);
- if ($getstats_result->num_rows > 0) {
- while ($row = $getstats_result->fetch_assoc()) {
- $last_message_received = substr(strval($row['timestamp']), 0, 19);
- $last_id_received = $row['timestamp'];
- }
- }
- //insert the client id between the brackets or ur mother will have the gay
- $adminList = array("", "");
- //nigger1, nigger2
- if ($getmsg_result->num_rows > 0) {
- while ($row = $getmsg_result->fetch_assoc()) {
- if (in_array($row['author_id'], $adminList)) {
- $lineIsRed = true;
- }
- $str = $str . "<tr>\n<th>" . $row['username'] . "</th>\n<th>" . substr(strval($row['last_known_ip']), 0, 19) . "</th>\n<th>" . $row['timestamp'] . "";
- if ($lineIsRed) {
- // $str = $str . '<font color="red">' . utf8_encode($row['country']) . "</font>\n";
- } else {
- // $str = $str . utf8_encode($row['author_name']);
- }
- // $str = $str . "</th>\n<th>" . utf8_encode($row['op_system']).
- "";
- if ($lineIsRed) {
- $str = $str . '</font>';
- }
- $lineIsRed = false;
- }
- } else {
- die("something went wrong. go to index and go back there");
- }
- $time_out = time_elapsed_string($last_message_received);
- ?>
- <style>
- table {
- font-family: arial, sans-serif;
- border-collapse: collapse;
- width: 100%;
- }
- td, th {
- border: 1px solid #dddddd;
- text-align: left;
- padding: 8px;
- }
- tr:nth-child(even) {
- background-color: #dddddd;
- }
- </style>
- <center>
- <title>weblogs</title>
- <h1>nightlights logs</h1>
- <?php
- $time_out = time_elapsed_string($last_message_received);
- $dbc = mysqli_connect('localhost', 'root', 'pw', 'nl') or die('Error connecting to MySQL server.');
- if(isset($_POST['submit_button']))
- {
- mysqli_query($dbc, 'TRUNCATE TABLE `user_logs`');
- header("Location: " . $_SERVER['PHP_SELF']);
- exit();
- }
- $verse = "2.0";
- echo "if theres too many shit just press this button";
- ?>
- <form method="post" action="">
- <input name="submit_button" type="submit" value=" empty button " />
- </form>
- <br><br>
- <table>
- <tr>
- <th>username</th>
- <th>ipadress</th>
- <th>timestamp</th>
- <th>user os</th>-->
- <th>image</th>-->
- </tr>
- <!-- you can make some comments here if your not gey lol -->
- <br><br>
- <?php echo $str; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement