-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog.php
58 lines (58 loc) · 2.55 KB
/
log.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<link rel="stylesheet" href="style.css">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="UTF-8">
</head>
<?php
session_start();
if(!$_SESSION['username']) {
echo "<form action='index.php' method='POST' id='form_refresh'>";
echo "<input type='hidden' id='refresh' name='refresh' value='refresh'>";
echo "</form>";
echo "<script>document.getElementById('form_refresh').submit()</script>";
}
$usrname = $_SESSION['username'];
include "connection.php";
$result = mysqli_query($link, "SELECT * FROM `Log`") or die(mysqli_error($link));
while ($row = mysqli_fetch_assoc($result)) {
if ($row['type'] != "stole" && $row['type'] != "gave") {
$usr_from_id = $row['user_from'];
$user_from = mysqli_fetch_assoc(mysqli_query($link, "SELECT * FROM `Participants` WHERE `id`=$usr_from_id"))['naam'];
$ip = $row['type'];
$time = $row['time'];
echo "<span style='color: #85c1e9 ;'>$ip </span>";
echo "logged in as ";
echo "<span style='color: #27ae60 ;'>$user_from </span>";
echo "at ";
echo "<span style='color: #85c1e9 ;'>$time</span><br>";
}
else {
$gift_id = $row['gift'];
$des = mysqli_fetch_assoc(mysqli_query($link, "SELECT * FROM `Gifts` WHERE `id`=$gift_id"))['des'];
$usr_from_id = $row['user_from'];
$user_from = mysqli_fetch_assoc(mysqli_query($link, "SELECT * FROM `Participants` WHERE `id`=$usr_from_id"))['naam'];
$usr_to_id = $row['user_to'];
$user_to = mysqli_fetch_assoc(mysqli_query($link, "SELECT * FROM `Participants` WHERE `id`=$usr_to_id"))['naam'];
echo "<span style='color: #27ae60 ;'>$user_from </span>";
echo $row['type'] . " ";
echo "<span style='color: #85c1e9 ;'>$des </span>";
if ($row['type'] == "stole") {
echo "from ";
}
if ($row['type'] == "gave") {
echo "to ";
}
echo "<span style='color: #27ae60 ;'>$user_to </span>";
echo "at ";
$time = $row['time'];
echo "<span style='color: #85c1e9 ;'>$time</span><br>";
}
}
?>
<br>
<form action='log.php' method='POST' id='form'>
<input type='submit' class='button-34' value='refresh' id='submit' name='submit'>
</form>
<form action='index.php' method='POST' id='form'>
<input type='submit' class='button-34' value='home' id='submit' name='submit'>
</form>