-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
110 lines (96 loc) · 3.25 KB
/
index.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
session_start();
require_once(__DIR__ . "/global.php");
HtmlHeader("home", IsLoggedIn()); //only print menu when logged in
if (IsLoggedIn() == false)
{
echo "<h1> EggsChange </h1>";
echo "<a>you have to be logged in.</a><br>";
echo "<form class=\"form\"><input type=\"button\" value=\"Login\" onclick=\"window.location.href='login.php'\"/></form>";
fok();
}
$db = new PDO(DATABASE_PATH);
$db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );
$stmt = $db->prepare('SELECT * FROM Accounts WHERE Username = ?');
$stmt->execute(array($_SESSION['Username']));
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($rows)
{
//SQL checks
$state = $rows[0]['STATE'];
$missionID = $rows[0]['missionID'];
if ($state == 1) //currently on mission --> send the user to mission state
{
header("Location: complete.php?id=$missionID");
}
//all good print main
$name = $rows[0]['Username'];
$points = $rows[0]['Points'];
echo "<strong>$name</strong><br>";
echo "<a><abbr title=\"Collect points due fullfilling wishes and use them to wish your own.\">points: <a href=\"TransactionHistory.php\">$points</a></a></abbr></br>";
}
else
{
echo "<a>Invalid account</a></br>";
echo "<form class=\"form\"><input type=\"button\" value=\"Login\" onclick=\"window.location.href='login.php'\"/></form>";
fok();
}
$rep_lvl = GetReputationLevel($_SESSION['Username']);
echo "<a><abbr title=\"Collect positive reputation due accepting wishes you wished.\">Reputation level: $rep_lvl</abbr></br></a>";
if ($rep_lvl > 0)
{
echo "<a></br><strong>Judge Conflicts</strong></br>Judge conflicts to earn reputation and points if you made the correct decision.</br>Help to make EggsChange a trusty place.</br></a>";
echo "<input type=\"button\" value=\"Judge Conflicts\" onclick=\"window.location.href='clean_conflicts.php'\"/>";
}
$db = new PDO(DATABASE_PATH);
$db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );
$name = $_SESSION['Username'];
$stmt = $rows = $db->query('SELECT * FROM Wishes WHERE wish_STATE = 1 AND wisher = ? ORDER BY wish_reward DESC LIMIT 20');
$stmt->execute(array($name));
$db = null;
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($rows)
{
echo "<br><strong>pending confirms: </strong><br>";
foreach ($rows as $row)
{
if (!empty($row['wish_name']))
{
$title = $row['wish_name'];
$reward = $row['wish_reward'];
$id = $row['ID'];
echo "<a href=\"confirm.php?id=$id\">[$reward] $title </a></br>";
}
}
}
else
{
//echo "</br><a>no pending confirms</a>";
}
$db = new PDO(DATABASE_PATH);
$db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );
$name = $_SESSION['Username'];
$stmt = $rows = $db->query('SELECT * FROM Wishes WHERE wish_STATE = 1 AND wish_fullfiller = ? ORDER BY wish_reward DESC LIMIT 20');
$stmt->execute(array($name));
$db = null;
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($rows)
{
echo "<br><strong>pending rewards: </strong><br>";
foreach ($rows as $row)
{
if (!empty($row['wish_name']))
{
$title = $row['wish_name'];
$reward = $row['wish_reward'];
$id = $row['ID'];
echo "<a>[$reward] $title </a><br>";
}
}
}
else
{
//echo "</br><a>no pending rewards</a>";
}
fok();
?>