Repository navigation
Expand file tree
/
Copy pathkdonations.php
More file actions
135 lines (124 loc) · 4.53 KB
/
Copy pathkdonations.php
File metadata and controls
135 lines (124 loc) · 4.53 KB
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
function kdonations_page_listing_header($action)
{
block_start();
global $make_csv;
if (!$make_csv) {
echo '<table>';
}
echo tag_raw("tr", tag_raw("td", tag_raw("b", sortlink($action, 'datea', 'Datum')))
. tag_raw("td", tag_raw("b", sortlink($action, 'typea', 'Art')))
. tag_raw("td", tag_raw("b", sortlink($action, 'loa', 'LO')))
. tag_raw("td", tag_raw("b", sortlink($action, 'texta', 'Text')))
. tag_raw("td", tag_raw("b", sortlink($action, 'ama', 'Wert')))
. tag_raw("td", tag_raw("b", sortlink($action, 'namea', 'Name'))));
}
function kdonations_page_listing_line($line)
{
global $make_csv,$dbconn;
if (!$make_csv) {
echo "<tr>";
}
echo tag("td", format_date($line["date"]));
$query2 = "SELECT name FROM type WHERE id = " . intval($line["type"]);
$result2 = db_query($dbconn, $query2);
// One cell also without a matching row (empty cell).
$line2 = pg_fetch_array($result2, null, PGSQL_ASSOC) ?: ['name' => ''];
echo tag("td", str_replace(['Spenden (mit Ausnahme der von lebenden Subventionen und Sachspenden)'], ['Spenden'], $line2["name"]));
pg_free_result($result2);
$query2 = "SELECT name FROM lo WHERE id = " . intval($line["orga"]);
$result2 = db_query($dbconn, $query2);
$line2 = pg_fetch_array($result2, null, PGSQL_ASSOC) ?: ['name' => ''];
echo tag("td", $line2["name"]);
pg_free_result($result2);
echo tag_raw("td", preg_replace(['/((BG|FE|ZE|VB|OG|IG)\/\d{9}|\d{5}.\d+)/'], [''], preg_replace(['/((BG|FE|ZE|VB|OG|IG)\/\d+(\s\d+)+)|(((BG|FE|ZE|VB|OG|IG)\/\d+)?[A-Z]{8} [A-Z]{2}\d+)/'], [" " . wrap("i", "Kontodaten") . " "], listing_text($line["comment"]))));
echo tag("td", format_amount($line["amount"], "€"));
echo tag("td", $line["name"]);
if ($make_csv) {
echo "\n";
} else {
echo "</tr>";
}
}
function kdonations_page_captcha()
{
$a = rand(1, 50);
$b = rand(1, 50);
$c = $a + $b - 37;
block_start();
?>
Bevor die Spenderliste angezeigt wird, musst du ein Rätsel lösen, um zu beweisen, dass du kein Roboter bist:
<div class="main" id="default">
<form class="login" action="kdonations" method="POST">
<div>
<label for="captcha_input" class="ui_field_label">Was ergibt die Addition <?php echo $a . ' + ' . $b; ?>?</label>
<input id="captcha_input" name="captcha_input" value="" type="text">
</div>
<input value="<?php echo $c; ?>" name="captcha" type="hidden">
<input value="Bestätigen" name="submit" type="submit">
</form>
</div>
<?php
block_end();
}
function kdonations_page_table()
{
global $dbconn;
$type = -1;
if (isset($_GET["type"]) && preg_match('/^\d+$/', $_GET["type"]) == 1) {
$type = $_GET["type"];
}
$unit = -1;
if (isset($_GET["unit"]) && preg_match('/^-?\d+$/', $_GET["unit"]) == 1) {
$unit = $_GET["unit"];
}
$from = -1;
if (isset($_GET["from"]) && preg_match('/^\d+-\d+-\d+$/', $_GET["from"]) == 1) {
$from = $_GET["from"];
}
$to = -1;
if (isset($_GET["to"]) && preg_match('/^\d+-\d+-\d+$/', $_GET["to"]) == 1) {
$to = $_GET["to"];
}
$where = "";
if ($type != -1) {
$where .= " AND type = $type";
}
if ($unit != -1) {
$where .= " AND orga = $unit";
}
if ($from != -1) {
$where .= " AND date >= '$from'";
}
if ($to != -1) {
$where .= " AND date < '$to'";
}
kdonations_page_listing_header('kdonations');
$sort = getsort();
$query = "SELECT * FROM vouchers WHERE NOT deleted AND type IN (11,12) AND " . eyes() . " AND (SELECT SUM(amount) FROM vouchers B WHERE " . eyes() . " AND B.voucher_id = vouchers.voucher_id) > 0 AND amount > 0 $where ORDER BY $sort";
$result = db_query($dbconn, $query);
while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) {
//kdonations_page_listing_line($line);
// disabled for legal reasons
}
echo 'Aus rechtlichen Gründen werden Spenden nur mit Zustimmung Veröffentlicht.';
pg_free_result($result);
global $make_csv;
if (!$make_csv) {
echo '</table>';
}
block_end();
}
function page_kdonations()
{
echo "<h1>Sachspendenliste der Piratenpartei Österreichs</h1>\n";
if (checklogin('id', false) > 0 || (isset($_POST['captcha_input']) && isset($_POST['captcha'])
&& intval($_POST['captcha_input']) == intval($_POST['captcha']) + 37)) {
// display table
kdonations_page_table();
} else {
// captcha
kdonations_page_captcha();
}
}
?>