-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathDonationsStats.php
executable file
·107 lines (85 loc) · 2.93 KB
/
DonationsStats.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
<?php
$PAGE_TITLE = "KXStudio : Donations";
$PAGE_TYPE = "DONATIONS";
$PAGE_SOURCE_1 = ARRAY("/Donations");
$PAGE_SOURCE_2 = ARRAY("Donations");
include_once("includes/header.php");
require "donate/config.php";
require "donate/connect.php";
$GLOBALS['biggest_donation_date'] = "Unknown";
$GLOBALS['biggest_donation_value'] = 0.0;
$GLOBALS['total_ever'] = 0.0;
function print_donation_year($year) {
global $db_link;
if ($db_link === FALSE) {
echo '<tr><td colspan="6">DB connection failed</td></tr>';
return;
}
$amount = 0.0;
$max_month = 0.0;
$total_year = 0.0;
$donation_count = 0.0;
$sql_donations = mysqli_query($db_link, "SELECT * FROM donations WHERE YEAR(dt) = " . $year);
if (mysqli_num_rows($sql_donations)) {
while ($sql_row = mysqli_fetch_assoc($sql_donations)) {
$amount = $sql_row["amount"];
$donation_count += 1.0;
if ($amount > $max_month) {
$max_month = $amount;
if ($amount > $GLOBALS['biggest_donation_value']) {
$GLOBALS['biggest_donation_date'] = date("Y-m-d", strtotime($sql_row["dt"]));
$GLOBALS['biggest_donation_value'] = $amount;
}
}
$total_year += $amount;
}
}
$GLOBALS['total_ever'] += $total_year;
echo '<tr>';
echo ' <td>' . $year . '</td>';
echo ' <td>' . $donation_count . '</td>';
echo ' <td>' . number_format($total_year, 2) . '€</td>';
if ($donation_count > 0.0) {
echo ' <td>' . number_format($total_year/$donation_count, 2) . '€</td>';
} else {
echo ' <td>0€</td>';
}
echo ' <td>' . number_format($total_year/12.0, 2) . '€</td>';
echo ' <td>' . number_format($max_month, 2) . '€</td>';
echo '</tr>';
}
?>
<p>
KXStudio is and always will be a free and open-source project to everyone.<br/>
Donations help ensure that developers have the needed enthusiasm and motivation to keep working on the project.<br/>
Just because we're open-source doesn't mean we're allergic to money. ;)
</p>
<p>
This page contain statistics regarding donations made to the KXStudio project over time.
</p>
<div class="box box-description">
<table style="text-align:center;">
<tr>
<td> Year </td>
<td> Donation count </td>
<td> Total received </td>
<td> Average per donation </td>
<td> Average per month </td>
<td> Biggest single donation </td>
</tr>
<?php
for ($year = strftime("%Y"); $year >= "2013"; $year -= 1) {
print_donation_year($year);
}
?>
</table>
</div>
<p>
So far the KXStudio project has received <?php echo number_format($GLOBALS['total_ever'], 2); ?>€ in donations.<br/>
The biggest donation ever made was on <?php echo $GLOBALS['biggest_donation_date']; ?>, with a value of <?php echo number_format($GLOBALS['biggest_donation_value'], 2); ?>€.<br/>
Thank you very much for your generosity!
</p>
<p><br/></p>
<?php
include_once("includes/footer.php");
?>