|
1
|
|
|
<?php |
|
|
|
|
|
|
2
|
|
|
/************************************************************************/ |
|
3
|
|
|
/* Donations - Paypal financial management module for Xoops 2 */ |
|
4
|
|
|
/* Copyright (c) 2004 by Xoops2 Donations Module Dev Team */ |
|
5
|
|
|
/* http://dev.xoops.org/modules/xfmod/project/?group_id=1060 */ |
|
6
|
|
|
/* $Id: functions.php 8193 2011-11-07 02:42:53Z beckmi $ */ |
|
|
|
|
|
|
7
|
|
|
/************************************************************************/ |
|
8
|
|
|
/* */ |
|
9
|
|
|
/* Based on NukeTreasury for PHP-Nuke - by Dave Lawrence AKA Thrash */ |
|
10
|
|
|
/* NukeTreasury - Financial management for PHP-Nuke */ |
|
11
|
|
|
/* Copyright (c) 2004 by Dave Lawrence AKA Thrash */ |
|
12
|
|
|
/* [email protected] */ |
|
13
|
|
|
/* [email protected] */ |
|
14
|
|
|
/* */ |
|
15
|
|
|
/************************************************************************/ |
|
16
|
|
|
/* */ |
|
17
|
|
|
/* This program is free software; you can redistribute it and/or modify */ |
|
18
|
|
|
/* it under the terms of the GNU General Public License as published by */ |
|
19
|
|
|
/* the Free Software Foundation; either version 2 of the License. */ |
|
20
|
|
|
/* */ |
|
21
|
|
|
/* This program is distributed in the hope that it will be useful, but */ |
|
22
|
|
|
/* WITHOUT ANY WARRANTY; without even the implied warranty of */ |
|
23
|
|
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ |
|
24
|
|
|
/* General Public License for more details. */ |
|
25
|
|
|
/* */ |
|
26
|
|
|
/* You should have received a copy of the GNU General Public License */ |
|
27
|
|
|
/* along with this program; if not, write to the Free Software */ |
|
28
|
|
|
/* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 */ |
|
29
|
|
|
/* USA */ |
|
30
|
|
|
/************************************************************************/ |
|
31
|
|
|
|
|
32
|
|
|
defined('XOOPS_ROOT_PATH') or die('Restricted access'); |
|
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Set the Currency Indicator ($, etc...) |
|
36
|
|
|
* |
|
37
|
|
|
* @param string $curr PAYPAL abbreviation for currency |
|
38
|
|
|
* @return string currency indicator (sign) |
|
39
|
|
|
* |
|
40
|
|
|
*/ |
|
41
|
|
|
function define_curr($curr) |
|
42
|
|
|
{ |
|
43
|
|
|
switch ($curr) |
|
44
|
|
|
{ |
|
45
|
|
|
case 'AUD' : |
|
|
|
|
|
|
46
|
|
|
$curr_sign = _MD_DON_CURR_EUR; |
|
47
|
|
|
break; |
|
48
|
|
|
case 'EUR' : |
|
|
|
|
|
|
49
|
|
|
$curr_sign = _MD_DON_CURR_EUR; |
|
50
|
|
|
break; |
|
51
|
|
|
case 'GBP' : |
|
|
|
|
|
|
52
|
|
|
$curr_sign = _MD_DON_CURR_GBP; |
|
53
|
|
|
break; |
|
54
|
|
|
case 'JPY' : |
|
|
|
|
|
|
55
|
|
|
$curr_sign = _MD_DON_CURR_JPY; |
|
56
|
|
|
break; |
|
57
|
|
|
case 'CAD' : |
|
|
|
|
|
|
58
|
|
|
$curr_sign = _MD_DON_CURR_CAD; |
|
59
|
|
|
break; |
|
60
|
|
|
case 'USD' : |
|
|
|
|
|
|
61
|
|
|
default: |
|
62
|
|
|
$curr_sign = _MD_DON_CURR_USD; |
|
63
|
|
|
break; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
return $curr_sign; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* Get all Config fields from DB |
|
71
|
|
|
* |
|
72
|
|
|
* @return array |
|
73
|
|
|
*/ |
|
74
|
|
|
function configInfo() |
|
75
|
|
|
{ |
|
76
|
|
|
global $xoopsDB; |
|
|
|
|
|
|
77
|
|
|
|
|
78
|
|
|
$query_cfg = "SELECT * FROM ".$xoopsDB->prefix("donations_config")." WHERE subtype = '' OR subtype = 'array'"; |
|
79
|
|
|
$cfgset = $xoopsDB->query($query_cfg); |
|
80
|
|
|
$tr_config = array(); |
|
81
|
|
|
while ( $cfgset && $row = $xoopsDB->fetchArray($cfgset)) |
|
82
|
|
|
{ |
|
83
|
|
|
$tr_config[$row['name']] = $row['value']; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
return $tr_config; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* Get XOOPS Member Object |
|
91
|
|
|
* |
|
92
|
|
|
* @param int $muser_id |
|
93
|
|
|
* @return FALSE - no member info avail for this id, SUCCESS - member object |
|
|
|
|
|
|
94
|
|
|
*/ |
|
95
|
|
|
function mgetusrinfo($muser_id) |
|
96
|
|
|
{ |
|
97
|
|
|
global $xoopsDB; |
|
|
|
|
|
|
98
|
|
|
$thisUser = FALSE; |
|
99
|
|
|
if (intval($muser_id) > 0) { |
|
100
|
|
|
$member_handler =& xoops_gethandler('member'); |
|
101
|
|
|
$thisUser =& $member_handler->getUser($muser_id); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
return $thisUser; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* Retrieve list of db table's field names |
|
109
|
|
|
* |
|
110
|
|
|
* EXAMPLE USAGE: |
|
111
|
|
|
* |
|
112
|
|
|
* $list=simple_query($xoopsDB->prefix('donations_transactions')); |
|
113
|
|
|
* |
|
114
|
|
|
* @param string $table_name DB table name |
|
115
|
|
|
* @param string $key_col (optional) table column name |
|
116
|
|
|
* @param mixed $key_val (optional) table column value |
|
117
|
|
|
* @param array $ignore (optional) list of values to ignore (clear) |
|
118
|
|
|
* @return mixed FALSE - nothing found, SUCCESS - array() of values |
|
119
|
|
|
*/ |
|
120
|
|
|
function simple_query($table_name, $key_col='', $key_val='',$ignore=array()) |
|
121
|
|
|
{ |
|
122
|
|
|
global $xoopsDB; |
|
|
|
|
|
|
123
|
|
|
// open the db |
|
124
|
|
|
$db_link = mysql_connect(XOOPS_DB_HOST, XOOPS_DB_USER, XOOPS_DB_PASS); |
|
125
|
|
|
$keys=''; |
|
126
|
|
|
if($key_col!=''&&$key_val!=''){ |
|
127
|
|
|
$keys = "WHERE $key_col = $key_val"; |
|
128
|
|
|
} |
|
129
|
|
|
// query table using key col/val |
|
130
|
|
|
$simple_q = FALSE; |
|
131
|
|
|
$db_rs = mysql_query("SELECT * FROM $table_name $keys", $db_link); |
|
132
|
|
|
$num_fields = mysql_num_fields($db_rs); |
|
133
|
|
|
if ($num_fields) { |
|
134
|
|
|
// first (and only) row |
|
135
|
|
|
$simple_q = array(); |
|
136
|
|
|
$row = mysql_fetch_assoc($db_rs); |
|
137
|
|
|
// load up array |
|
138
|
|
|
if($key_col!='' && $key_val!=''){ |
|
139
|
|
View Code Duplication |
for ($i = 0; $i < $num_fields; $i++) { |
|
|
|
|
|
|
140
|
|
|
$var=''; |
|
|
|
|
|
|
141
|
|
|
$var = mysql_field_name($db_rs, $i); |
|
142
|
|
|
$simple_q[$var] = $row[$var]; |
|
143
|
|
|
} |
|
144
|
|
|
}else{ |
|
145
|
|
View Code Duplication |
for ($i = 0; $i < $num_fields; $i++) { |
|
|
|
|
|
|
146
|
|
|
$var=''; |
|
|
|
|
|
|
147
|
|
|
$var = mysql_field_name($db_rs, $i); |
|
148
|
|
|
if(!in_array($var,$ignore)){ |
|
149
|
|
|
$simple_q[$var] = ''; |
|
150
|
|
|
} |
|
151
|
|
|
} |
|
152
|
|
|
} |
|
153
|
|
|
} |
|
154
|
|
|
mysql_free_result($db_rs); |
|
155
|
|
|
|
|
156
|
|
|
return $simple_q; |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
/* |
|
160
|
|
|
* Functions for Administration display |
|
161
|
|
|
*/ |
|
162
|
|
|
|
|
163
|
|
|
/** |
|
164
|
|
|
* Display a Config Option html Option Box in a 2 column table row |
|
165
|
|
|
* |
|
166
|
|
|
* @param string $name name of config variable in config DB table |
|
167
|
|
|
* @param string $desc description of option box |
|
168
|
|
|
*/ |
|
169
|
|
|
function ShowYNBox($name, $desc) |
|
170
|
|
|
{ |
|
171
|
|
|
global $tr_config, $modversion, $xoopsDB; |
|
|
|
|
|
|
172
|
|
|
|
|
173
|
|
|
$query_cfg = "SELECT * FROM " . $xoopsDB->prefix("donations_config") |
|
174
|
|
|
. " WHERE name = '{$name}'"; |
|
175
|
|
|
$cfgset = $xoopsDB->query($query_cfg); |
|
176
|
|
|
if( $cfgset ) { |
|
177
|
|
|
$cfg = $xoopsDB->fetchArray($cfgset); |
|
178
|
|
|
$text = htmlentities($cfg['text']); |
|
179
|
|
|
echo "<tr>\n" |
|
180
|
|
|
. " <td title=\"{$text}\" style=\"text-align: right;\">{$desc}</td>\n" |
|
181
|
|
|
. " <td title=\"{$text}\" style=\"text-align: left\">"; |
|
182
|
|
|
echo " <select size=\"1\" name=\"var_{$name}\">"; |
|
183
|
|
|
if( $cfg['value'] ) { |
|
184
|
|
|
echo " <option selected value=\"1\">" . _YES . "</option>" |
|
185
|
|
|
. " <option value=\"0\">" . _NO . "</option>"; |
|
186
|
|
|
} else { |
|
187
|
|
|
echo " <option value=\"1\">" . _YES . "</option>" |
|
188
|
|
|
. " <option selected value=\"0\">" . _NO . "</option>"; |
|
189
|
|
|
} |
|
190
|
|
|
echo " </select>\n"; |
|
191
|
|
|
echo " </td>\n"; |
|
192
|
|
|
echo "</tr>\n"; |
|
193
|
|
|
} |
|
194
|
|
|
} |
|
195
|
|
|
|
|
196
|
|
|
/** |
|
197
|
|
|
* Display a Config option HTML Select Box in 2 column table |
|
198
|
|
|
* |
|
199
|
|
|
* @param string $name name of config DB table column |
|
200
|
|
|
* @param string $desc description of select box to show |
|
201
|
|
|
*/ |
|
202
|
|
|
function ShowDropBox($name, $desc) |
|
203
|
|
|
{ |
|
204
|
|
|
global $tr_config, $modversion, $xoopsDB; |
|
|
|
|
|
|
205
|
|
|
|
|
206
|
|
|
$query_cfg = "SELECT * FROM " . $xoopsDB->prefix("donations_config") |
|
207
|
|
|
. " WHERE name = '{$name}'"; |
|
208
|
|
|
$cfgset = $xoopsDB->query($query_cfg); |
|
209
|
|
|
if( $cfgset ) { |
|
210
|
|
|
$cfg = $xoopsDB->fetchArray($cfgset); |
|
211
|
|
|
$text = htmlentities($cfg['text']); |
|
212
|
|
|
echo "<tr style=\"text-align: center;\">\n" |
|
213
|
|
|
. " <td title=\"{$text}\" style=\"text-align: right; width: 50%;\">{$desc}</td>\n" |
|
214
|
|
|
. " <td title=\"{$text}\" style=\"text-align: left;\">\n"; |
|
215
|
|
|
echo " <select size=\"1\" name=\"var_{$name}-array\">\n"; |
|
216
|
|
|
if( isset($cfg['value']) ) { |
|
217
|
|
|
$splitArr = explode('|', $cfg['value']); |
|
218
|
|
|
$i=0; |
|
219
|
|
|
while($i < count($splitArr)){ |
|
220
|
|
|
$selected = ( 0 == $i ) ? ' selected' : ''; |
|
221
|
|
|
echo " <option{$selected} value=\"{$splitArr[$i]}\">{$splitArr[$i]}</option>\n"; |
|
222
|
|
|
$i++; |
|
223
|
|
|
} |
|
224
|
|
|
} |
|
225
|
|
|
echo " </select>\n"; |
|
226
|
|
|
echo " </td>\n"; |
|
227
|
|
|
echo "</tr>\n"; |
|
228
|
|
|
} |
|
229
|
|
|
} |
|
230
|
|
|
|
|
231
|
|
|
/** |
|
232
|
|
|
* Display Config Array Drop Box in HTML 2 column table row |
|
233
|
|
|
* |
|
234
|
|
|
* @param string $name name of DB column in config table |
|
235
|
|
|
* @param string $desc description to display for select box |
|
236
|
|
|
* @param array $x_array array( array($value1, $attrib1), array(...) ) |
|
237
|
|
|
*/ |
|
238
|
|
|
function ShowArrayDropBox($name, $desc, $x_array) |
|
239
|
|
|
{ |
|
240
|
|
|
global $tr_config, $modversion, $xoopsDB; |
|
|
|
|
|
|
241
|
|
|
$query_cfg = "SELECT * FROM ".$xoopsDB->prefix("donations_config") |
|
242
|
|
|
. " WHERE name = '{$name}' LIMIT 1"; |
|
243
|
|
|
$cfgset = $xoopsDB->query($query_cfg); |
|
244
|
|
|
if( $cfgset ) { |
|
245
|
|
|
$cfg = $xoopsDB->fetchArray($cfgset); |
|
246
|
|
|
$text = htmlentities($cfg['text']); |
|
247
|
|
|
echo "<tr>\n" |
|
248
|
|
|
." <td title=\"{$text}\" style=\"text-align: right;\">{$desc}</td>\n" |
|
249
|
|
|
." <td title=\"{$text}\" style=\"text-align: left;\">\n"; |
|
250
|
|
|
echo " <select size=\"1\" name=\"var_{$name}\">\n"; |
|
251
|
|
|
if ( isset($cfg['value']) ) { |
|
252
|
|
|
if ( 0 == $cfg['value'] ) { |
|
253
|
|
|
echo " <option selected value=\"0\">-------</option>\n"; |
|
254
|
|
|
}else{ |
|
255
|
|
|
echo " <option value=\"0\">-------</option>\n"; |
|
256
|
|
|
} |
|
257
|
|
|
$i=0; |
|
258
|
|
|
while( $i < count($x_array) ){ |
|
259
|
|
|
$mvar = $x_array[$i]; |
|
260
|
|
|
$selected = ''; |
|
261
|
|
|
if ( $mvar[0] == $cfg['value'] ) { |
|
262
|
|
|
$selected = ' selected'; |
|
263
|
|
|
} |
|
264
|
|
|
echo " <option{$selected} value=\"{$mvar[0]}\">{$mvar[1]}</option>\n"; |
|
265
|
|
|
$i++; |
|
266
|
|
|
} |
|
267
|
|
|
} |
|
268
|
|
|
echo " </select>\n"; |
|
269
|
|
|
echo " </td>\n"; |
|
270
|
|
|
echo "</tr>\n"; |
|
271
|
|
|
} |
|
272
|
|
|
} |
|
273
|
|
|
|
|
274
|
|
|
/** |
|
275
|
|
|
* Display Config Option Text Box in a 2 column table row |
|
276
|
|
|
* |
|
277
|
|
|
* @param string $name name of DB column in config table |
|
278
|
|
|
* @param string $desc description of text box to display |
|
279
|
|
|
* @param int $tdWidth width of description field |
|
280
|
|
|
* @param int $inpSize width of text input box |
|
281
|
|
|
* @param string $extra extra info included in input box 'string' |
|
282
|
|
|
*/ |
|
283
|
|
|
function ShowTextBox($name, $desc, $tdWidth, $inpSize, $extra) |
|
284
|
|
|
{ |
|
285
|
|
|
global $tr_config, $modversion, $xoopsDB; |
|
|
|
|
|
|
286
|
|
|
|
|
287
|
|
|
$query_cfg = "SELECT * FROM ".$xoopsDB->prefix("donations_config") |
|
288
|
|
|
. " WHERE name = '{$name}'"; |
|
289
|
|
|
$cfgset = $xoopsDB->query($query_cfg); |
|
290
|
|
|
if( $cfgset ) { |
|
291
|
|
|
$cfg = $xoopsDB->fetchArray($cfgset); |
|
292
|
|
|
$text = htmlentities($cfg['text']); |
|
293
|
|
|
echo "<tr>\n" |
|
294
|
|
|
. " <td title=\"{$text}\" style=\"text-align: right; width: {$tdWidth}\">{$desc}</td>\n" |
|
295
|
|
|
. " <td title=\"{$text}\" style=\"text-align: left;\">\n" |
|
296
|
|
|
. " <input size=\"{$inpSize}\" name=\"var_{$name}\" type=\"text\" value=\"{$cfg['value']}\" {$extra} />\n" |
|
297
|
|
|
. " </td>\n" |
|
298
|
|
|
. "</tr>\n"; |
|
299
|
|
|
} |
|
300
|
|
|
} |
|
301
|
|
|
|
|
302
|
|
|
/************************************************************************ |
|
303
|
|
|
* |
|
304
|
|
|
************************************************************************/ |
|
305
|
|
|
function ShowImgXYBox($xnm, $ynm, $desc, $inpSize, $extra) |
|
306
|
|
|
{ |
|
307
|
|
|
global $tr_config, $modversion, $xoopsDB; |
|
|
|
|
|
|
308
|
|
|
|
|
309
|
|
|
$query_cfg = "SELECT * FROM ".$xoopsDB->prefix("donations_config")." WHERE name = '$xnm'"; |
|
310
|
|
|
$cfgset = $xoopsDB->query($query_cfg); |
|
311
|
|
|
|
|
312
|
|
|
if( $cfgset) { |
|
313
|
|
|
$cfg = $xoopsDB->fetchArray($cfgset); |
|
314
|
|
|
|
|
315
|
|
|
$text = htmlentities($cfg['text']); |
|
316
|
|
|
echo "<tr>\n" |
|
317
|
|
|
. " <td title=\"{$text}\" style=\"text-align: right;\">{$desc}</td>\n" |
|
318
|
|
|
. " <td title=\"{$text}\" style=\"text-align: left;\">\n"; |
|
319
|
|
|
echo " " . _AD_DON_WIDTH . " \n" |
|
320
|
|
|
. " <input size=\"{$inpSize}\" name=\"var_{$cfg['name']}\" type=\"text\" value=\"{$cfg['value']}\" {$extra} />\n"; |
|
321
|
|
|
|
|
322
|
|
|
$query_cfg = "SELECT * FROM ".$xoopsDB->prefix("donations_config")." WHERE name = '$ynm'"; |
|
323
|
|
|
$cfgset = $xoopsDB->query($query_cfg); |
|
324
|
|
|
if( $cfgset) |
|
325
|
|
|
{ |
|
326
|
|
|
$cfg = $xoopsDB->fetchArray($cfgset); |
|
327
|
|
|
echo " " . _AD_DON_HEIGHT . " \n" |
|
328
|
|
|
. " <input size=\"{$inpSize}\" name=\"var_{$cfg['name']}\" type=\"text\" value=\"{$cfg['value']}\" {$extra} />\n"; |
|
329
|
|
|
} |
|
330
|
|
|
echo " </td>\n" |
|
331
|
|
|
. "</tr>\n"; |
|
332
|
|
|
} |
|
333
|
|
|
} |
|
334
|
|
|
|
|
335
|
|
|
/* |
|
336
|
|
|
* Functions to save Administration settings |
|
337
|
|
|
*/ |
|
338
|
|
|
|
|
339
|
|
|
/** |
|
340
|
|
|
* Update the Config option in the database |
|
341
|
|
|
* |
|
342
|
|
|
* @param string $name config var name in the database |
|
343
|
|
|
* @param string $sub config subtype in the database |
|
344
|
|
|
* @param mixed $val config var value |
|
345
|
|
|
* @param string $txt configuration text for this var |
|
346
|
|
|
* @return bool TRUE value updated, FALSE value not updated |
|
347
|
|
|
*/ |
|
348
|
|
|
function UpdateDb($name, $sub, $val, $txt) |
|
349
|
|
|
{ |
|
350
|
|
|
global $tr_config, $ilog, $xoopsDB; |
|
|
|
|
|
|
351
|
|
|
$insert_Recordset = "UPDATE `" . $xoopsDB->prefix("donations_config") . "`" |
|
352
|
|
|
. " SET `value`='$val', `text`='{$txt}'" |
|
353
|
|
|
. " WHERE `name`='{$name}' AND `subtype`='{$sub}'"; |
|
354
|
|
|
$ilog .= "{$insert_Recordset}<br /><br />"; |
|
355
|
|
|
echo "{$insert_Recordset}<br /><br />"; |
|
356
|
|
|
echo "<span style=\"color: #FF0000; font-weight: bold;\">"; |
|
357
|
|
|
$rvalue = $xoopsDB->query($insert_Recordset); |
|
358
|
|
|
echo "</span>"; |
|
359
|
|
|
$retVal = ($rvalue) ? TRUE : FALSE; |
|
360
|
|
|
|
|
361
|
|
|
return $retVal; |
|
362
|
|
|
} |
|
363
|
|
|
|
|
364
|
|
|
/************************************************************************ |
|
365
|
|
|
* |
|
366
|
|
|
************************************************************************/ |
|
367
|
|
|
function UpdateDbShort($name, $sub, $val, $txt) |
|
|
|
|
|
|
368
|
|
|
{ |
|
369
|
|
|
global $tr_config, $ilog, $xoopsDB; |
|
|
|
|
|
|
370
|
|
|
if($sub=='array'){ |
|
371
|
|
|
$newArr = ''; |
|
|
|
|
|
|
372
|
|
|
$query_cfg = "SELECT * FROM ".$xoopsDB->prefix("donations_config") |
|
373
|
|
|
. " WHERE name = '{$name}'"; |
|
374
|
|
|
$cfgset = $xoopsDB->query($query_cfg); |
|
375
|
|
|
$cfg = $xoopsDB->fetchArray($cfgset); |
|
376
|
|
|
if( isset($cfg['value']) ) { |
|
377
|
|
|
$splitArr = explode('|',$cfg['value']); |
|
378
|
|
|
$newArr = $val; |
|
379
|
|
|
$i=0; |
|
380
|
|
|
while($singleVar = $splitArr[$i]) { |
|
381
|
|
|
if ( $singleVar != $val ) { |
|
382
|
|
|
$newArr = $newArr.'|'.$singleVar; |
|
383
|
|
|
} |
|
384
|
|
|
$i++; |
|
385
|
|
|
} |
|
386
|
|
|
$val = $newArr; |
|
387
|
|
|
} |
|
388
|
|
|
} |
|
389
|
|
|
$insert_Recordset = "UPDATE `" . $xoopsDB->prefix("donations_config") . "`" |
|
390
|
|
|
. " SET `value`='{$val}'" |
|
391
|
|
|
. " WHERE `name`='{$name}' AND `subtype`='{$sub}'"; |
|
392
|
|
|
|
|
393
|
|
|
$ilog .= "{$insert_Recordset}<br /><br />\n"; |
|
394
|
|
|
echo "{$insert_Recordset}<br /><br /><span style=\"color: #FF0000; font-weight: bold;\">\n"; |
|
395
|
|
|
$rvalue = $xoopsDB->query($insert_Recordset); |
|
|
|
|
|
|
396
|
|
|
echo "</span>\n"; |
|
397
|
|
|
} |
|
398
|
|
|
|
|
399
|
|
|
/** |
|
400
|
|
|
* Get Configuration Value |
|
401
|
|
|
* |
|
402
|
|
|
* @param string $name name of configuration variable |
|
403
|
|
|
* @return mixed value of config var on success, FALSE on failure |
|
404
|
|
|
* |
|
405
|
|
|
*/ |
|
406
|
|
|
function getLibConfig($name) |
|
407
|
|
|
{ |
|
408
|
|
|
global $xoopsDB; |
|
|
|
|
|
|
409
|
|
|
|
|
410
|
|
|
$sql = "SELECT * FROM ".$xoopsDB->prefix("donations_config") |
|
411
|
|
|
." WHERE name = '{$name}'"; |
|
412
|
|
|
$Recordset = $xoopsDB->query($sql); |
|
413
|
|
|
$row = $xoopsDB->fetchArray($Recordset); |
|
414
|
|
|
// $text = $b = html_entity_decode($row['text']); |
|
|
|
|
|
|
415
|
|
|
$text = html_entity_decode($row['text']); |
|
416
|
|
|
|
|
417
|
|
|
return $text; |
|
418
|
|
|
} |
|
419
|
|
|
|
|
420
|
|
|
/** |
|
421
|
|
|
* |
|
422
|
|
|
* Get All Configuration Values |
|
423
|
|
|
* |
|
424
|
|
|
* @return array SUCCESS - array of config values (name as key); FAIL - empty |
|
425
|
|
|
*/ |
|
426
|
|
|
function getAllLibConfig() |
|
427
|
|
|
{ |
|
428
|
|
|
global $xoopsDB; |
|
|
|
|
|
|
429
|
|
|
|
|
430
|
|
|
$sql = "SELECT * FROM " . $xoopsDB->prefix("donations_config") |
|
431
|
|
|
. " ORDER BY name, subtype"; |
|
432
|
|
|
$sqlquery = $xoopsDB->query($sql); |
|
433
|
|
|
|
|
434
|
|
|
$t = array(); |
|
435
|
|
|
while ($sqlfetch = $xoopsDB->fetchArray($sqlquery)) { |
|
436
|
|
|
$text = html_entity_decode($sqlfetch['text']); |
|
437
|
|
|
$text = str_replace('<br />', "\r\n", $text); |
|
438
|
|
|
$text = str_replace('<br />', "\r\n", $text); |
|
439
|
|
|
|
|
440
|
|
|
if ($sqlfetch['subtype'] == '') { |
|
441
|
|
|
$t[$sqlfetch['name']] = $text; |
|
442
|
|
|
} else { |
|
443
|
|
|
$t[$sqlfetch['name']][$sqlfetch['subtype']] = $text; |
|
444
|
|
|
} |
|
445
|
|
|
} |
|
446
|
|
|
//displayArray($t,"------getAllLibConfig-----------"); |
|
|
|
|
|
|
447
|
|
|
return $t; |
|
448
|
|
|
} |
|
449
|
|
|
/******************************************************************* |
|
450
|
|
|
* |
|
451
|
|
|
*******************************************************************/ |
|
452
|
|
|
function displayArray_don($t, $name = "", $ident = 0) |
|
|
|
|
|
|
453
|
|
|
{ |
|
454
|
|
|
if (is_array($t)) { |
|
455
|
|
|
echo "------------------------------------------------<br />" ; |
|
456
|
|
|
echo "displayArray: " . $name . " - count = " . count($t) ; |
|
457
|
|
|
//echo "<table ".getTblStyle().">"; |
|
|
|
|
|
|
458
|
|
|
echo "<table>\n"; |
|
459
|
|
|
|
|
460
|
|
|
echo " <tr><td>"; |
|
461
|
|
|
//jjd_echo ("displayArray: ".$name." - count = ".count($t), 255, "-") ; |
|
|
|
|
|
|
462
|
|
|
echo "</td></tr>\n"; |
|
463
|
|
|
|
|
464
|
|
|
echo " <tr><td>\n"; |
|
465
|
|
|
echo " <pre>"; |
|
466
|
|
|
echo print_r($t); |
|
467
|
|
|
echo "</pre>\n"; |
|
468
|
|
|
echo " </td></tr>\n"; |
|
469
|
|
|
echo "</table>\n"; |
|
470
|
|
|
} else { |
|
471
|
|
|
echo "The variable ---|{$t}|--- is not an array\n"; |
|
472
|
|
|
// echo "l'indice ---|{$t}|--- n'est pas un tableau\n"; |
|
473
|
|
|
} |
|
474
|
|
|
//jjd_echo ("Fin - ".$name, 255, "-") ; |
|
|
|
|
|
|
475
|
|
|
} |
|
476
|
|
|
/** |
|
477
|
|
|
* Display main top header table |
|
478
|
|
|
* |
|
479
|
|
|
*/ |
|
480
|
|
|
function adminmain() { |
|
481
|
|
|
global $tr_config, $modversion, $xoopsDB; |
|
|
|
|
|
|
482
|
|
|
|
|
483
|
|
|
echo "<div style=\"text-align: center;\">\n"; |
|
484
|
|
|
echo "<table style='text-align: center; border-width: 1px; padding: 2px; margin: 2px; width: 90%;'>\n"; |
|
485
|
|
|
echo " <tr>\n"; |
|
486
|
|
|
echo " <td style='text-align: center; width: 25%;'><a href='index.php?op=Treasury'><img src='../images/admin/business_sm.png' alt='" . _AD_DON_TREASURY . "' /> " . _AD_DON_TREASURY . "</a></td>\n"; |
|
487
|
|
|
echo " <td style='text-align: center; width: 25%;'><a href='index.php?op=ShowLog'><img src='../images/admin/view_text_sm.png' alt='" . _AD_DON_SHOW_LOG . "' /> " . _AD_DON_SHOW_LOG . "</a></td>\n"; |
|
488
|
|
|
echo " <td style='text-align: center; width: 25%;'><a href='transaction.php'><img src='../images/admin/view_detailed_sm.png' alt='" . _AD_DON_SHOW_TXN . "' /> " . _AD_DON_SHOW_TXN . "</a></td>\n"; |
|
489
|
|
|
echo " <td style='text-align: center; width: 25%;'><a href='index.php?op=Config'><img src='../images/admin/configure_sm.png' alt='" . _AD_DON_CONFIGURATION . "' /> " . _AD_DON_CONFIGURATION . "</a></td>\n"; |
|
490
|
|
|
echo " </tr>\n"; |
|
491
|
|
|
echo "</table>\n"; |
|
492
|
|
|
echo "<br /></div>\n"; |
|
493
|
|
|
} |
|
494
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.