-
Notifications
You must be signed in to change notification settings - Fork 1
/
donators.php
executable file
·172 lines (157 loc) · 7.18 KB
/
donators.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
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<?php
// translator ready
// addnews ready
// mail ready
require_once("common.php");
require_once("lib/http.php");
require_once("lib/systemmail.php");
SuAccess::check_su_access(SU_EDIT_DONATIONS);
Translator::tlschema("donation");
PageParts::page_header("Donator's Page");
require_once("lib/superusernav.php");
SuperUserNavClass::superusernav();
$ret=Http::httpget('ret');
$return = SanitizeClass::cmd_sanitize($ret);
$return = substr($return,strrpos($return,"/")+1);
Translator::tlschema("nav");
OutputClass::addnav("Return whence you came",$return);
Translator::tlschema();
$add = Translator::translate_inline("Add Donation");
OutputClass::rawoutput("<form action='donators.php?op=add1&ret=".rawurlencode($ret)."' method='POST'>");
OutputClass::addnav("","donators.php?op=add1&ret=".rawurlencode($ret)."");
$name = Http::httppost("name");
if ($name=="") $name = Http::httpget("name");
$amt = Http::httppost("amt");
if ($amt=="") $amt = Http::httpget("amt");
$reason = Http::httppost("reason");
if ($reason=="") $reason = Http::httpget("reason");
$txnid = Http::httppost("txnid");
if ($txnid=="") $txnid = Http::httpget("txnid");
if ($reason == "") $reason = Translator::translate_inline("manual donation entry");
OutputClass::output("`bAdd Donation Points:`b`n");
OutputClass::output("Character: ");
OutputClass::rawoutput("<input name='name' value=\"".htmlentities($name, ENT_COMPAT, Settings::getsetting("charset", "ISO-8859-1"))."\">");
OutputClass::output("`nPoints: ");
OutputClass::rawoutput("<input name='amt' size='3' value=\"".htmlentities($amt, ENT_COMPAT, Settings::getsetting("charset", "ISO-8859-1"))."\">");
OutputClass::output("`nReason: ");
OutputClass::rawoutput("<input name='reason' size='30' value=\"".htmlentities($reason, ENT_COMPAT, Settings::getsetting("charset", "ISO-8859-1"))."\">");
OutputClass::rawoutput("<input type='hidden' name='txnid' value=\"".htmlentities($txnid, ENT_COMPAT, Settings::getsetting("charset", "ISO-8859-1"))."\">");
OutputClass::output_notl("`n");
if ($txnid>"") OutputClass::output("For transaction: %s`n",$txnid);
OutputClass::rawoutput("<input type='submit' class='button' value='$add'>");
OutputClass::rawoutput("</form>");
OutputClass::addnav("Donations");
if (($session['user']['superuser'] & SU_EDIT_PAYLOG) &&
file_exists("paylog.php")){
OutputClass::addnav("Payment Log","paylog.php");
}
$op = Http::httpget('op');
if ($op=="add2"){
$id = Http::httpget('id');
$amt = Http::httpget('amt');
$reason = Http::httpget('reason');
$sql="SELECT name FROM ".db_prefix("accounts")." WHERE acctid=$id;";
$result=db_query($sql);
$row=db_fetch_assoc($result);
OutputClass::output("%s donation points added to %s`0, reason: `^%s`0",$amt,$row['name'],$reason);
$txnid = Http::httpget("txnid");
$ret = Http::httpget('ret');
if ($id==$session['user']['acctid']){
$session['user']['donation']+=$amt;
}
if ($txnid > ""){
$result = Modules::modulehook("donation_adjustments",array("points"=>$amt,"amount"=>$amt/100,"acctid"=>$id,"messages"=>array()));
$points = $result['points'];
if (!is_array($result['messages'])){
$result['messages'] = array($result['messages']);
}
foreach($result['messages'] as $messageid=>$message){
DebugLogClass::debuglog($message,false,$id,"donation",0,false);
}
}else{
$points = $amt;
}
// ok to execute when this is the current user, they'll overwrite the
// value at the end of their page hit, and this will allow the display
// table to update in real time.
$sql = "UPDATE " . db_prefix("accounts") . " SET donation=donation+'$points' WHERE acctid='$id'";
db_query($sql);
Modules::modulehook("donation", array("id"=>$id, "amt"=>$points, "manual"=>($txnid>""?false:true)));
if ($txnid>""){
$sql = "UPDATE ".db_prefix("paylog")." SET acctid='$id', processed=1 WHERE txnid='$txnid'";
db_query($sql);
DebugLogClass::debuglog("Received donator points for donating -- Credited manually [$reason]",false,$id,"donation",$points,false);
RedirectClass::redirect("paylog.php");
}else{
DebugLogClass::debuglog("Received donator points -- Manually assigned, not based on a known dollar donation [$reason]",false,$id,"donation",$amt,false);
}
if ($points == 1) {
SystemMailClass::systemmail($id,array("Donation Point Added"),array("`2You have received a donation point for %s.",$reason));
}else {
SystemMailClass::systemmail($id,array("Donation Points Added"),array("`2You have received %d donation points for %s.",$points,$reason));
}
Http::httpset('op', "");
$op = "";
}
if ($op==""){
$sql = "SELECT name,donation,donationspent FROM " . db_prefix("accounts") . " WHERE donation>0 ORDER BY donation DESC LIMIT 25";
$result = db_query($sql);
$name = Translator::translate_inline("Name");
$points = Translator::translate_inline("Points");
$spent = Translator::translate_inline("Spent");
OutputClass::rawoutput("<table border='0' cellpadding='3' cellspacing='1' bgcolor='#999999'>");
OutputClass::rawoutput("<tr class='trhead'><td>$name</td><td>$points</td><td>$spent</td></tr>");
$number=db_num_rows($result);
for ($i=0;$i<$number;$i++){
$row = db_fetch_assoc($result);
OutputClass::rawoutput("<tr class='".($i%2?"trlight":"trdark")."'>");
OutputClass::rawoutput("<td>");
OutputClass::output_notl("`^%s`0",$row['name']);
OutputClass::rawoutput("</td><td>");
OutputClass::output_notl("`@%s`0", number_format($row['donation']));
OutputClass::rawoutput("</td><td>");
OutputClass::output_notl("`%%s`0", number_format($row['donationspent']));
OutputClass::rawoutput("</td>");
OutputClass::rawoutput("</tr>");
}
OutputClass::rawoutput("</table>",true);
}else if ($op=="add1"){
$search="%";
$name = Http::httppost('name');
if ($name=='') $name = Http::httpget('name');
for ($i=0;$i<strlen($name);$i++){
$z = substr($name, $i, 1);
if ($z == "'") $z = "\\'";
$search.=$z."%";
}
$sql = "SELECT name,acctid,donation,donationspent FROM " . db_prefix("accounts") . " WHERE login LIKE '$search' or name LIKE '$search' LIMIT 100";
$result = db_query($sql);
$ret = Http::httpget('ret');
$amt = Http::httppost('amt');
if ($amt=='') $amt = Http::httpget("amt");
$reason = Http::httppost("reason");
if ($reason=="") $reason = Http::httpget("reason");
$txnid = Http::httppost('txnid');
if ($txnid=='') $txnid = Http::httpget("txnid");
OutputClass::output("Confirm the addition of %s points to:`n",$amt);
if ($reason) OutputClass::output("(Reason: `^`b`i%s`i`b`0)`n`n",$reason);
$number=db_num_rows($result);
for ($i=0;$i<$number;$i++){
$row = db_fetch_assoc($result);
if ($ret!=""){
OutputClass::rawoutput("<a href='donators.php?op=add2&id={$row['acctid']}&amt=$amt&ret=".rawurlencode($ret)."&reason=".rawurlencode($reason)."'>");
}else{
OutputClass::rawoutput("<a href='donators.php?op=add2&id={$row['acctid']}&amt=$amt&reason=".rawurlencode($reason)."&txnid=$txnid'>");
}
OutputClass::output_notl("%s (%s/%s)", $row['name'], $row['donation'], $row['donationspent']);
OutputClass::rawoutput("</a>");
OutputClass::output_notl("`n");
if ($ret!=""){
OutputClass::addnav("","donators.php?op=add2&id={$row['acctid']}&amt=$amt&ret=".rawurlencode($ret)."&reason=".rawurlencode($reason));
}else{
OutputClass::addnav("","donators.php?op=add2&id={$row['acctid']}&amt=$amt&reason=".rawurlencode($reason)."&txnid=$txnid");
}
}
}
PageParts::page_footer();
?>