1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Class MyalbumUtil |
5
|
|
|
*/ |
6
|
|
|
class XdonationsUtility extends XoopsObject |
|
|
|
|
7
|
|
|
{ |
8
|
|
|
/** |
9
|
|
|
* Function responsible for checking if a directory exists, we can also write in and create an index.html file |
10
|
|
|
* |
11
|
|
|
* @param string $folder The full path of the directory to check |
12
|
|
|
* |
13
|
|
|
* @return void |
14
|
|
|
*/ |
15
|
|
|
public static function createFolder($folder) |
16
|
|
|
{ |
17
|
|
|
// try { |
18
|
|
|
// if (!mkdir($folder) && !is_dir($folder)) { |
|
|
|
|
19
|
|
|
// throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder)); |
|
|
|
|
20
|
|
|
// } else { |
|
|
|
|
21
|
|
|
// file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>'); |
|
|
|
|
22
|
|
|
// } |
23
|
|
|
// } |
24
|
|
|
// catch (Exception $e) { |
|
|
|
|
25
|
|
|
// echo 'Caught exception: ', $e->getMessage(), "\n", '<br/>'; |
|
|
|
|
26
|
|
|
// } |
27
|
|
|
try { |
28
|
|
|
if (!file_exists($folder)) { |
29
|
|
|
if (!mkdir($folder) && !is_dir($folder)) { |
30
|
|
|
throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder)); |
31
|
|
|
} |
32
|
|
|
file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>'); |
33
|
|
|
} |
34
|
|
|
} |
35
|
|
|
catch (Exception $e) { |
36
|
|
|
echo 'Caught exception: ', $e->getMessage(), "\n", '<br/>'; |
37
|
|
|
} |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @param $file |
42
|
|
|
* @param $folder |
43
|
|
|
* @return bool |
44
|
|
|
*/ |
45
|
|
|
public static function copyFile($file, $folder) |
46
|
|
|
{ |
47
|
|
|
return copy($file, $folder); |
48
|
|
|
// try { |
49
|
|
|
// if (!is_dir($folder)) { |
|
|
|
|
50
|
|
|
// throw new \RuntimeException(sprintf('Unable to copy file as: %s ', $folder)); |
|
|
|
|
51
|
|
|
// } else { |
|
|
|
|
52
|
|
|
// return copy($file, $folder); |
|
|
|
|
53
|
|
|
// } |
54
|
|
|
// } catch (Exception $e) { |
|
|
|
|
55
|
|
|
// echo 'Caught exception: ', $e->getMessage(), "\n", "<br/>"; |
|
|
|
|
56
|
|
|
// } |
57
|
|
|
// return false; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @param $src |
62
|
|
|
* @param $dst |
63
|
|
|
*/ |
64
|
|
|
public static function recurseCopy($src, $dst) |
65
|
|
|
{ |
66
|
|
|
$dir = opendir($src); |
67
|
|
|
// @mkdir($dst); |
68
|
|
|
while (false !== ($file = readdir($dir))) { |
69
|
|
|
if (($file !== '.') && ($file !== '..')) { |
70
|
|
|
if (is_dir($src . '/' . $file)) { |
71
|
|
|
self::recurseCopy($src . '/' . $file, $dst . '/' . $file); |
72
|
|
|
} else { |
73
|
|
|
copy($src . '/' . $file, $dst . '/' . $file); |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
closedir($dir); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* |
82
|
|
|
* Verifies XOOPS version meets minimum requirements for this module |
83
|
|
|
* @static |
84
|
|
|
* @param XoopsModule $module |
85
|
|
|
* |
86
|
|
|
* @return bool true if meets requirements, false if not |
87
|
|
|
*/ |
88
|
|
|
public static function checkVerXoops(XoopsModule $module) |
89
|
|
|
{ |
90
|
|
|
xoops_loadLanguage('admin', $module->dirname()); |
91
|
|
|
//check for minimum XOOPS version |
92
|
|
|
$currentVer = substr(XOOPS_VERSION, 6); // get the numeric part of string |
93
|
|
|
$currArray = explode('.', $currentVer); |
94
|
|
|
$requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string |
95
|
|
|
$reqArray = explode('.', $requiredVer); |
96
|
|
|
$success = true; |
97
|
|
|
foreach ($reqArray as $k => $v) { |
98
|
|
|
if (isset($currArray[$k])) { |
99
|
|
|
if ($currArray[$k] > $v) { |
100
|
|
|
break; |
101
|
|
|
} elseif ($currArray[$k] == $v) { |
102
|
|
|
continue; |
103
|
|
|
} else { |
104
|
|
|
$success = false; |
105
|
|
|
break; |
106
|
|
|
} |
107
|
|
|
} else { |
108
|
|
|
if ((int)$v > 0) { // handles things like x.x.x.0_RC2 |
109
|
|
|
$success = false; |
110
|
|
|
break; |
111
|
|
|
} |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
if (!$success) { |
116
|
|
|
$module->setErrors(sprintf(_AM_XDONATION_ERROR_BAD_XOOPS, $requiredVer, $currentVer)); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
return $success; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* |
124
|
|
|
* Verifies PHP version meets minimum requirements for this module |
125
|
|
|
* @static |
126
|
|
|
* @param XoopsModule $module |
127
|
|
|
* |
128
|
|
|
* @return bool true if meets requirements, false if not |
129
|
|
|
*/ |
130
|
|
|
public static function checkVerPhp(XoopsModule $module) |
131
|
|
|
{ |
132
|
|
|
xoops_loadLanguage('admin', $module->dirname()); |
133
|
|
|
// check for minimum PHP version |
134
|
|
|
$success = true; |
135
|
|
|
$verNum = PHP_VERSION; |
136
|
|
|
$reqVer = $module->getInfo('min_php'); |
137
|
|
|
if (false !== $reqVer && '' !== $reqVer) { |
138
|
|
|
if (version_compare($verNum, $reqVer, '<')) { |
139
|
|
|
$module->setErrors(sprintf(_AM_XDONATION_ERROR_BAD_PHP, $reqVer, $verNum)); |
140
|
|
|
$success = false; |
141
|
|
|
} |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
return $success; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* @param $curr |
149
|
|
|
* @return string |
150
|
|
|
*/ |
151
|
|
|
public static function defineCurrency($curr) |
152
|
|
|
{ |
153
|
|
|
switch ($curr) { |
154
|
|
|
case 'AUD': |
155
|
|
|
$currencySign = _MD_XDONATION_CURR_AUD; |
156
|
|
|
break; |
157
|
|
|
case 'EUR': |
158
|
|
|
$currencySign = _MD_XDONATION_CURR_EUR; |
159
|
|
|
break; |
160
|
|
|
case 'GBP': |
161
|
|
|
$currencySign = _MD_XDONATION_CURR_GBP; |
162
|
|
|
break; |
163
|
|
|
case 'JPY': |
164
|
|
|
$currencySign = _MD_XDONATION_CURR_JPY; |
165
|
|
|
break; |
166
|
|
|
case 'CAD': |
167
|
|
|
$currencySign = _MD_XDONATION_CURR_CAD; |
168
|
|
|
break; |
169
|
|
|
case 'USD': |
170
|
|
|
default: |
171
|
|
|
$currencySign = _MD_XDONATION_CURR_USD; |
172
|
|
|
break; |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
return $currencySign; |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* Get all Config fields from DB |
180
|
|
|
* |
181
|
|
|
* @return array |
182
|
|
|
*/ |
183
|
|
|
public static function getConfigInfo() |
184
|
|
|
{ |
185
|
|
|
global $xoopsDB; |
|
|
|
|
186
|
|
|
|
187
|
|
|
$query_cfg = 'SELECT * FROM ' . $xoopsDB->prefix('donations_config') . " WHERE subtype = '' OR subtype = 'array'"; |
188
|
|
|
$cfgset = $xoopsDB->query($query_cfg); |
189
|
|
|
$tr_config = array(); |
190
|
|
|
while ($cfgset && $row = $xoopsDB->fetchArray($cfgset)) { |
191
|
|
|
$tr_config[$row['name']] = $row['value']; |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
return $tr_config; |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
/** |
198
|
|
|
* Get XOOPS Member Object |
199
|
|
|
* |
200
|
|
|
* @param int $muser_id |
201
|
|
|
* @return FALSE - no member info avail for this id, SUCCESS - member object |
|
|
|
|
202
|
|
|
*/ |
203
|
|
|
public static function getUserInfo($muser_id) |
204
|
|
|
{ |
205
|
|
|
global $xoopsDB; |
|
|
|
|
206
|
|
|
$thisUser = false; |
207
|
|
|
if ((int)$muser_id > 0) { |
208
|
|
|
$memberHandler = xoops_getHandler('member'); |
209
|
|
|
$thisUser = $memberHandler->getUser($muser_id); |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
return $thisUser; |
213
|
|
|
} |
214
|
|
|
|
215
|
|
|
/** |
216
|
|
|
* Retrieve list of db table's field names |
217
|
|
|
* |
218
|
|
|
* EXAMPLE USAGE: |
219
|
|
|
* |
220
|
|
|
* $list=XdonationsUtility::runSimpleQuery($xoopsDB->prefix('donations_transactions')); |
221
|
|
|
* |
222
|
|
|
* @param string $table_name DB table name |
223
|
|
|
* @param string $key_col (optional) table column name |
224
|
|
|
* @param mixed $key_val (optional) table column value |
225
|
|
|
* @param array $ignore (optional) list of values to ignore (clear) |
226
|
|
|
* @return mixed FALSE - nothing found, SUCCESS - array() of values |
227
|
|
|
*/ |
228
|
|
|
public static function runSimpleQuery($table_name, $key_col = '', $key_val = '', $ignore = array()) |
229
|
|
|
{ |
230
|
|
|
global $xoopsDB; |
|
|
|
|
231
|
|
|
// open the db |
232
|
|
|
// $db_link = mysqli_connect(XOOPS_DB_HOST, XOOPS_DB_USER, XOOPS_DB_PASS); |
|
|
|
|
233
|
|
|
$keys = ''; |
234
|
|
|
if ($key_col != '' && $key_val != '') { |
235
|
|
|
$keys = "WHERE $key_col = $key_val"; |
236
|
|
|
} |
237
|
|
|
// query table using key col/val |
238
|
|
|
$simple_q = false; |
239
|
|
|
$db_rs = $xoopsDB->query("SELECT * FROM $table_name $keys"); |
240
|
|
|
$num_fields = $xoopsDB->getFieldsNum($db_rs); |
241
|
|
|
if ($num_fields) { |
242
|
|
|
// first (and only) row |
243
|
|
|
$simple_q = array(); |
244
|
|
|
$row = $xoopsDB->fetchArray($db_rs); |
245
|
|
|
// load up array |
246
|
|
|
if ($key_col != '' && $key_val != '') { |
247
|
|
View Code Duplication |
for ($i = 0; $i < $num_fields; ++$i) { |
|
|
|
|
248
|
|
|
$var = ''; |
|
|
|
|
249
|
|
|
$var = $xoopsDB->getFieldName($db_rs, $i); |
250
|
|
|
$simple_q[$var] = $row[$var]; |
251
|
|
|
} |
252
|
|
|
} else { |
253
|
|
View Code Duplication |
for ($i = 0; $i < $num_fields; ++$i) { |
|
|
|
|
254
|
|
|
$var = ''; |
|
|
|
|
255
|
|
|
$var = $xoopsDB->getFieldName($db_rs, $i); |
256
|
|
|
if (!in_array($var, $ignore)) { |
257
|
|
|
$simple_q[$var] = ''; |
258
|
|
|
} |
259
|
|
|
} |
260
|
|
|
} |
261
|
|
|
} |
262
|
|
|
$xoopsDB->freeRecordSet($db_rs); |
263
|
|
|
|
264
|
|
|
return $simple_q; |
265
|
|
|
} |
266
|
|
|
|
267
|
|
|
/* |
268
|
|
|
* Functions for Administration display |
269
|
|
|
*/ |
270
|
|
|
|
271
|
|
|
/** |
272
|
|
|
* Display a Config Option html Option Box in a 2 column table row |
273
|
|
|
* |
274
|
|
|
* @param string $name name of config variable in config DB table |
275
|
|
|
* @param string $desc description of option box |
276
|
|
|
*/ |
277
|
|
|
public static function showYNBox($name, $desc) |
278
|
|
|
{ |
279
|
|
|
global $tr_config, $modversion, $xoopsDB; |
|
|
|
|
280
|
|
|
|
281
|
|
|
$query_cfg = 'SELECT * FROM ' . $xoopsDB->prefix('donations_config') . " WHERE name = '{$name}'"; |
282
|
|
|
$cfgset = $xoopsDB->query($query_cfg); |
283
|
|
|
if ($cfgset) { |
284
|
|
|
$cfg = $xoopsDB->fetchArray($cfgset); |
285
|
|
|
$text = htmlentities($cfg['text']); |
286
|
|
|
echo "<tr>\n" . " <td title=\"{$text}\" style=\"text-align: right;\">{$desc}</td>\n" . " <td title=\"{$text}\" style=\"text-align: left;\">"; |
287
|
|
|
echo " <select size=\"1\" name=\"var_{$name}\">"; |
288
|
|
|
if ($cfg['value']) { |
289
|
|
|
echo ' <option selected value="1">' . _YES . '</option>' . ' <option value="0">' . _NO . '</option>'; |
290
|
|
|
} else { |
291
|
|
|
echo ' <option value="1">' . _YES . '</option>' . ' <option selected value="0">' . _NO . '</option>'; |
292
|
|
|
} |
293
|
|
|
echo " </select>\n"; |
294
|
|
|
echo " </td>\n"; |
295
|
|
|
echo "</tr>\n"; |
296
|
|
|
} |
297
|
|
|
} |
298
|
|
|
|
299
|
|
|
/** |
300
|
|
|
* Display a Config option HTML Select Box in 2 column table |
301
|
|
|
* |
302
|
|
|
* @param string $name name of config DB table column |
303
|
|
|
* @param string $desc description of select box to show |
304
|
|
|
*/ |
305
|
|
|
public static function showDropBox($name, $desc) |
306
|
|
|
{ |
307
|
|
|
global $tr_config, $modversion, $xoopsDB; |
|
|
|
|
308
|
|
|
|
309
|
|
|
$query_cfg = 'SELECT * FROM ' . $xoopsDB->prefix('donations_config') . " WHERE name = '{$name}'"; |
310
|
|
|
$cfgset = $xoopsDB->query($query_cfg); |
311
|
|
|
if ($cfgset) { |
312
|
|
|
$cfg = $xoopsDB->fetchArray($cfgset); |
313
|
|
|
$text = htmlentities($cfg['text']); |
314
|
|
|
echo "<tr style=\"text-align: center;\">\n" . " <td title=\"{$text}\" style=\"text-align: right; width: 50%;\">{$desc}</td>\n" . " <td title=\"{$text}\" style=\"text-align: left;\">\n"; |
315
|
|
|
echo " <select size=\"1\" name=\"var_{$name}-array\">\n"; |
316
|
|
|
if (isset($cfg['value'])) { |
317
|
|
|
$splitArr = explode('|', $cfg['value']); |
318
|
|
|
$i = 0; |
319
|
|
|
while ($i < count($splitArr)) { |
320
|
|
|
$selected = (0 == $i) ? ' selected' : ''; |
321
|
|
|
echo " <option{$selected} value=\"{$splitArr[$i]}\">{$splitArr[$i]}</option>\n"; |
322
|
|
|
++$i; |
323
|
|
|
} |
324
|
|
|
} |
325
|
|
|
echo " </select>\n"; |
326
|
|
|
echo " </td>\n"; |
327
|
|
|
echo "</tr>\n"; |
328
|
|
|
} |
329
|
|
|
} |
330
|
|
|
|
331
|
|
|
/** |
332
|
|
|
* Display Config Array Drop Box in HTML 2 column table row |
333
|
|
|
* |
334
|
|
|
* @param string $name name of DB column in config table |
335
|
|
|
* @param string $desc description to display for select box |
336
|
|
|
* @param array $x_array array( array($value1, $attrib1), array(...) ) |
337
|
|
|
*/ |
338
|
|
|
public static function showArrayDropBox($name, $desc, $x_array) |
339
|
|
|
{ |
340
|
|
|
global $tr_config, $modversion, $xoopsDB; |
|
|
|
|
341
|
|
|
$query_cfg = 'SELECT * FROM ' . $xoopsDB->prefix('donations_config') . " WHERE name = '{$name}' LIMIT 1"; |
342
|
|
|
$cfgset = $xoopsDB->query($query_cfg); |
343
|
|
|
if ($cfgset) { |
344
|
|
|
$cfg = $xoopsDB->fetchArray($cfgset); |
345
|
|
|
$text = htmlentities($cfg['text']); |
346
|
|
|
echo "<tr>\n" . " <td title=\"{$text}\" style=\"text-align: right;\">{$desc}</td>\n" . " <td title=\"{$text}\" style=\"text-align: left;\">\n"; |
347
|
|
|
echo " <select size=\"1\" name=\"var_{$name}\">\n"; |
348
|
|
|
if (isset($cfg['value'])) { |
349
|
|
|
if (0 == $cfg['value']) { |
350
|
|
|
echo " <option selected value=\"0\">-------</option>\n"; |
351
|
|
|
} else { |
352
|
|
|
echo " <option value=\"0\">-------</option>\n"; |
353
|
|
|
} |
354
|
|
|
$i = 0; |
355
|
|
|
while ($i < count($x_array)) { |
356
|
|
|
$mvar = $x_array[$i]; |
357
|
|
|
$selected = ''; |
358
|
|
|
if ($mvar[0] == $cfg['value']) { |
359
|
|
|
$selected = ' selected'; |
360
|
|
|
} |
361
|
|
|
echo " <option{$selected} value=\"{$mvar[0]}\">{$mvar[1]}</option>\n"; |
362
|
|
|
++$i; |
363
|
|
|
} |
364
|
|
|
} |
365
|
|
|
echo " </select>\n"; |
366
|
|
|
echo " </td>\n"; |
367
|
|
|
echo "</tr>\n"; |
368
|
|
|
} |
369
|
|
|
} |
370
|
|
|
|
371
|
|
|
/** |
372
|
|
|
* Display Config Option Text Box in a 2 column table row |
373
|
|
|
* |
374
|
|
|
* @param string $name name of DB column in config table |
375
|
|
|
* @param string $desc description of text box to display |
376
|
|
|
* @param int $tdWidth width of description field |
377
|
|
|
* @param int $inpSize width of text input box |
378
|
|
|
* @param string $extra extra info included in input box 'string' |
379
|
|
|
*/ |
380
|
|
|
public static function showTextBox($name, $desc, $tdWidth, $inpSize, $extra) |
381
|
|
|
{ |
382
|
|
|
global $tr_config, $modversion, $xoopsDB; |
|
|
|
|
383
|
|
|
|
384
|
|
|
$query_cfg = 'SELECT * FROM ' . $xoopsDB->prefix('donations_config') . " WHERE name = '{$name}'"; |
385
|
|
|
$cfgset = $xoopsDB->query($query_cfg); |
386
|
|
|
if ($cfgset) { |
387
|
|
|
$cfg = $xoopsDB->fetchArray($cfgset); |
388
|
|
|
$text = htmlentities($cfg['text']); |
389
|
|
|
echo "<tr>\n" |
390
|
|
|
. " <td title=\"{$text}\" style=\"text-align: right; width: {$tdWidth};\">{$desc}</td>\n" |
391
|
|
|
. " <td title=\"{$text}\" style=\"text-align: left;\">\n" |
392
|
|
|
. " <input size=\"{$inpSize}\" name=\"var_{$name}\" type=\"text\" value=\"{$cfg['value']}\" {$extra} />\n" |
393
|
|
|
. " </td>\n" |
394
|
|
|
. "</tr>\n"; |
395
|
|
|
} |
396
|
|
|
} |
397
|
|
|
|
398
|
|
|
/************************************************************************ |
399
|
|
|
* |
400
|
|
|
*********************************************************************** |
401
|
|
|
* @param $xnm |
402
|
|
|
* @param $ynm |
403
|
|
|
* @param $desc |
404
|
|
|
* @param $inpSize |
405
|
|
|
* @param $extra |
406
|
|
|
*/ |
407
|
|
|
public static function showImgXYBox($xnm, $ynm, $desc, $inpSize, $extra) |
408
|
|
|
{ |
409
|
|
|
global $tr_config, $modversion, $xoopsDB; |
|
|
|
|
410
|
|
|
|
411
|
|
|
$query_cfg = 'SELECT * FROM ' . $xoopsDB->prefix('donations_config') . " WHERE name = '$xnm'"; |
412
|
|
|
$cfgset = $xoopsDB->query($query_cfg); |
413
|
|
|
|
414
|
|
|
if ($cfgset) { |
415
|
|
|
$cfg = $xoopsDB->fetchArray($cfgset); |
416
|
|
|
|
417
|
|
|
$text = htmlentities($cfg['text']); |
418
|
|
|
echo "<tr>\n" . " <td title=\"{$text}\" style=\"text-align: right;\">{$desc}</td>\n" . " <td title=\"{$text}\" style=\"text-align: left;\">\n"; |
419
|
|
|
echo ' ' . _AD_XDONATION_WIDTH . " \n" . " <input size=\"{$inpSize}\" name=\"var_{$cfg['name']}\" type=\"text\" value=\"{$cfg['value']}\" {$extra} />\n"; |
420
|
|
|
|
421
|
|
|
$query_cfg = 'SELECT * FROM ' . $xoopsDB->prefix('donations_config') . " WHERE name = '$ynm'"; |
422
|
|
|
$cfgset = $xoopsDB->query($query_cfg); |
423
|
|
|
if ($cfgset) { |
424
|
|
|
$cfg = $xoopsDB->fetchArray($cfgset); |
425
|
|
|
echo ' ' . _AD_XDONATION_HEIGHT . " \n" . " <input size=\"{$inpSize}\" name=\"var_{$cfg['name']}\" type=\"text\" value=\"{$cfg['value']}\" {$extra} />\n"; |
426
|
|
|
} |
427
|
|
|
echo " </td>\n" . "</tr>\n"; |
428
|
|
|
} |
429
|
|
|
} |
430
|
|
|
|
431
|
|
|
/* |
432
|
|
|
* Functions to save Administration settings |
433
|
|
|
*/ |
434
|
|
|
|
435
|
|
|
/** |
436
|
|
|
* Update the Config option in the database |
437
|
|
|
* |
438
|
|
|
* @param string $name config var name in the database |
439
|
|
|
* @param string $sub config subtype in the database |
440
|
|
|
* @param mixed $val config var value |
441
|
|
|
* @param string $txt configuration text for this var |
442
|
|
|
* @return bool TRUE value updated, FALSE value not updated |
443
|
|
|
*/ |
444
|
|
|
public static function updateDb($name, $sub, $val, $txt) |
445
|
|
|
{ |
446
|
|
|
global $tr_config, $ilog, $xoopsDB; |
|
|
|
|
447
|
|
|
$insertRecordset = 'UPDATE `' . $xoopsDB->prefix('donations_config') . '`' . " SET `value`='$val', `text`='{$txt}'" . " WHERE `name`='{$name}' AND `subtype`='{$sub}'"; |
448
|
|
|
$ilog .= "{$insertRecordset}<br><br>"; |
449
|
|
|
echo "{$insertRecordset}<br><br>"; |
450
|
|
|
echo '<span style="color: #FF0000; font-weight: bold;">'; |
451
|
|
|
$rvalue = $xoopsDB->query($insertRecordset); |
452
|
|
|
echo '</span>'; |
453
|
|
|
$retVal = $rvalue ? true : false; |
454
|
|
|
|
455
|
|
|
return $retVal; |
456
|
|
|
} |
457
|
|
|
|
458
|
|
|
/************************************************************************ |
459
|
|
|
* |
460
|
|
|
*********************************************************************** |
461
|
|
|
* @param $name |
462
|
|
|
* @param $sub |
463
|
|
|
* @param $val |
464
|
|
|
* @param $txt |
465
|
|
|
*/ |
466
|
|
|
public static function updateDbShort($name, $sub, $val, $txt = '') |
467
|
|
|
{ |
468
|
|
|
global $tr_config, $ilog, $xoopsDB; |
|
|
|
|
469
|
|
|
if ($sub === 'array') { |
470
|
|
|
$newArr = ''; |
|
|
|
|
471
|
|
|
$query_cfg = 'SELECT * FROM ' . $xoopsDB->prefix('donations_config') . " WHERE name = '{$name}'"; |
472
|
|
|
$cfgset = $xoopsDB->query($query_cfg); |
473
|
|
|
$cfg = $xoopsDB->fetchArray($cfgset); |
474
|
|
|
if (isset($cfg['value'])) { |
475
|
|
|
$splitArr = explode('|', $cfg['value']); |
476
|
|
|
$newArr = $val; |
477
|
|
|
$i = 0; |
478
|
|
|
while (false != ($singleVar = $splitArr[$i])) { |
479
|
|
|
if ($singleVar != $val) { |
480
|
|
|
$newArr = $newArr . '|' . $singleVar; |
481
|
|
|
} |
482
|
|
|
++$i; |
483
|
|
|
} |
484
|
|
|
$val = $newArr; |
485
|
|
|
} |
486
|
|
|
} |
487
|
|
|
$insertRecordset = 'UPDATE `' . $xoopsDB->prefix('donations_config') . '`' . " SET `value`='{$val}'" . " WHERE `name`='{$name}' AND `subtype`='{$sub}'"; |
488
|
|
|
|
489
|
|
|
$ilog .= "{$insertRecordset}<br><br>\n"; |
490
|
|
|
echo "{$insertRecordset}<br><br><span style=\"color: #FF0000; font-weight: bold;\">\n"; |
491
|
|
|
$rvalue = $xoopsDB->query($insertRecordset); |
|
|
|
|
492
|
|
|
echo "</span>\n"; |
493
|
|
|
} |
494
|
|
|
|
495
|
|
|
/** |
496
|
|
|
* Get Configuration Value |
497
|
|
|
* |
498
|
|
|
* @param string $name name of configuration variable |
499
|
|
|
* @return mixed value of config var on success, FALSE on failure |
500
|
|
|
* |
501
|
|
|
*/ |
502
|
|
|
public static function getLibConfig($name) |
503
|
|
|
{ |
504
|
|
|
global $xoopsDB; |
|
|
|
|
505
|
|
|
|
506
|
|
|
$sql = 'SELECT * FROM ' . $xoopsDB->prefix('donations_config') . " WHERE name = '{$name}'"; |
507
|
|
|
$Recordset = $xoopsDB->query($sql); |
508
|
|
|
$row = $xoopsDB->fetchArray($Recordset); |
509
|
|
|
// $text = $b = html_entity_decode($row['text']); |
|
|
|
|
510
|
|
|
$text = html_entity_decode($row['text']); |
511
|
|
|
|
512
|
|
|
return $text; |
513
|
|
|
} |
514
|
|
|
|
515
|
|
|
/** |
516
|
|
|
* |
517
|
|
|
* Get All Configuration Values |
518
|
|
|
* |
519
|
|
|
* @return array SUCCESS - array of config values (name as key); FAIL - empty |
520
|
|
|
*/ |
521
|
|
|
public static function getAllLibConfig() |
522
|
|
|
{ |
523
|
|
|
global $xoopsDB; |
|
|
|
|
524
|
|
|
|
525
|
|
|
$sql = 'SELECT * FROM ' . $xoopsDB->prefix('donations_config') . ' ORDER BY name, subtype'; |
526
|
|
|
$sqlQuery = $xoopsDB->query($sql); |
527
|
|
|
|
528
|
|
|
$t = array(); |
529
|
|
|
while (false !== ($sqlfetch = $xoopsDB->fetchArray($sqlQuery))) { |
530
|
|
|
$text = html_entity_decode($sqlfetch['text']); |
531
|
|
|
$text = str_replace('<br>', "\r\n", $text); |
532
|
|
|
$text = str_replace('<br>', "\r\n", $text); |
533
|
|
|
|
534
|
|
|
if ($sqlfetch['subtype'] == '') { |
535
|
|
|
$t[$sqlfetch['name']] = $text; |
536
|
|
|
} else { |
537
|
|
|
$t[$sqlfetch['name']][$sqlfetch['subtype']] = $text; |
538
|
|
|
} |
539
|
|
|
} |
540
|
|
|
|
541
|
|
|
//displayArray($t,"------getAllLibConfig-----------"); |
|
|
|
|
542
|
|
|
return $t; |
543
|
|
|
} |
544
|
|
|
|
545
|
|
|
/******************************************************************* |
546
|
|
|
* |
547
|
|
|
****************************************************************** |
548
|
|
|
* @param $t |
549
|
|
|
* @param string $name |
550
|
|
|
* @param int $ident |
551
|
|
|
*/ |
552
|
|
|
public static function displayDonorArray($t, $name = '', $ident = 0) |
553
|
|
|
{ |
554
|
|
|
if (is_array($t)) { |
555
|
|
|
echo '------------------------------------------------<br>'; |
556
|
|
|
echo 'displayArray: ' . $name . ' - count = ' . count($t); |
557
|
|
|
//echo "<table ".getTblStyle().">"; |
|
|
|
|
558
|
|
|
echo "<table>\n"; |
559
|
|
|
|
560
|
|
|
echo ' <tr><td>'; |
561
|
|
|
//jjd_echo ("displayArray: ".$name." - count = ".count($t), 255, "-") ; |
|
|
|
|
562
|
|
|
echo "</td></tr>\n"; |
563
|
|
|
|
564
|
|
|
echo " <tr><td>\n"; |
565
|
|
|
echo ' <pre>'; |
566
|
|
|
echo print_r($t); |
567
|
|
|
echo "</pre>\n"; |
568
|
|
|
echo " </td></tr>\n"; |
569
|
|
|
echo "</table>\n"; |
570
|
|
|
} else { |
571
|
|
|
echo "The variable ---|{$t}|--- is not an array\n"; |
572
|
|
|
// echo "l'indice ---|{$t}|--- n'est pas un tableau\n"; |
573
|
|
|
} |
574
|
|
|
//jjd_echo ("Fin - ".$name, 255, "-") ; |
|
|
|
|
575
|
|
|
} |
576
|
|
|
|
577
|
|
|
/** |
578
|
|
|
* Display main top header table |
579
|
|
|
* |
580
|
|
|
*/ |
581
|
|
|
public static function adminmain() |
582
|
|
|
{ |
583
|
|
|
global $tr_config, $modversion, $xoopsDB; |
|
|
|
|
584
|
|
|
|
585
|
|
|
echo "<div style=\"text-align: center;\">\n"; |
586
|
|
|
echo "<table style='text-align: center; border-width: 1px; padding: 2px; margin: 2px; width: 90%;'>\n"; |
587
|
|
|
echo " <tr>\n"; |
588
|
|
|
echo " <td style='text-align: center; width: 25%;'><a href='index.php?op=Treasury'><img src='../images/admin/business_sm.png' alt='" . _AD_XDONATION_TREASURY . "' /> " . _AD_XDONATION_TREASURY . "</a></td>\n"; |
589
|
|
|
echo " <td style='text-align: center; width: 25%;'><a href='index.php?op=ShowLog'><img src='../images/admin/view_text_sm.png' alt='" . _AD_XDONATION_SHOW_LOG . "' /> " . _AD_XDONATION_SHOW_LOG . "</a></td>\n"; |
590
|
|
|
echo " <td style='text-align: center; width: 25%;'><a href='transaction.php'><img src='../images/admin/view_detailed_sm.png' alt='" . _AD_XDONATION_SHOW_TXN . "' /> " . _AD_XDONATION_SHOW_TXN . "</a></td>\n"; |
591
|
|
|
echo " <td style='text-align: center; width: 25%;'><a href='index.php?op=Config'><img src='../images/admin/configure_sm.png' alt='" . _AD_XDONATION_CONFIGURATION . "' /> " . _AD_XDONATION_CONFIGURATION . "</a></td>\n"; |
592
|
|
|
echo " </tr>\n"; |
593
|
|
|
echo "</table>\n"; |
594
|
|
|
echo "<br></div>\n"; |
595
|
|
|
} |
596
|
|
|
|
597
|
|
|
} |
598
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.