-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTransactionHistory.php
106 lines (91 loc) · 2.76 KB
/
TransactionHistory.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
<?php
session_start();
require_once(__DIR__ . "/global.php");
HtmlHeader("Transactions");
if (empty($_SESSION['IsLogged']) || $_SESSION['IsLogged'] != "online")
{
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(ABSOLUTE_DATABASE_PATH);
$db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );
$stmt = $db->prepare('SELECT Points FROM Accounts WHERE Username = ?');
$stmt->execute(array($_SESSION['Username']));
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
$db = NULL;
$balance = 0;
if ($rows)
{
$balance = $rows[0]['Points'];
}
echo "<h1>Points Transactions</h2>";
echo "<a>Total balance: <strong>$balance</strong></a></br>";
echo "<h2>Incoming (last 20)</h2>";
$db = new PDO(ABSOLUTE_DATABASE_PATH);
$db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );
$stmt = $db->prepare('SELECT * FROM Points WHERE Reciver = ? ORDER BY TransactionDate DESC LIMIT 20');
$stmt->execute(array($_SESSION['Username']));
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($rows)
{
foreach ($rows as $row)
{
$send = $row['Sender'];
$reason = $row['Reason'];
$date = $row['TransactionDate'];
$value = $row['Points'];
//working but usernames should be private
/*
if ($send == "SERVER")
{
echo "+$value ($reason) [$date]</br>";
}
else
{
echo "+$value from user '$send' ($reason) [$date]</br>";
}
*/
echo "+$value ($reason) [$date]</br>";
}
}
else
{
echo "You didn't have any incoming transactions yet.</br>";
}
echo "<h2>Outgoing (last 20)</h2>";
$db = new PDO(ABSOLUTE_DATABASE_PATH);
$db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );
$stmt = $db->prepare('SELECT * FROM Points WHERE Sender = ? ORDER BY TransactionDate DESC LIMIT 20');
$stmt->execute(array($_SESSION['Username']));
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($rows)
{
foreach ($rows as $row)
{
$recv = $row['Reciver'];
$reason = $row['Reason'];
$date = $row['TransactionDate'];
$value = $row['Points'];
//Working but usernames should be private
/*
if ($recv == "SERVER")
{
echo "-$value ($reason) [$date]</br>";
}
else
{
echo "-$value to user '$recv' ($reason) [$date]</br>";
}
*/
echo "-$value ($reason) [$date]</br>";
}
}
else
{
echo "You didn't have any outgoing transactions yet.</br>";
}
echo "<form class=\"form\"><input type=\"button\" value=\"Back\" onclick=\"window.location.href='index.php'\"/></form>";
fok();
?>