1
|
|
|
<?php |
|
|
|
|
2
|
|
|
|
3
|
|
|
use Xmf\Request; |
4
|
|
|
|
5
|
|
|
require_once __DIR__ . '/common/traitversionchecks.php'; |
6
|
|
|
require_once __DIR__ . '/common/traitserverstats.php'; |
7
|
|
|
require_once __DIR__ . '/common/traitfilesmgmt.php'; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class WflinksUtility |
11
|
|
|
*/ |
12
|
|
|
class WflinksUtility extends XoopsObject |
|
|
|
|
13
|
|
|
{ |
14
|
|
|
use VersionChecks; //checkVerXoops, checkVerPhp Traits |
15
|
|
|
|
16
|
|
|
use ServerStats; // getServerStats Trait |
17
|
|
|
|
18
|
|
|
use FilesManagement; // Files Management Trait |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* wfs_gethandler() |
22
|
|
|
* |
23
|
|
|
* @param $name |
24
|
|
|
* @param boolean $optional |
25
|
|
|
* |
26
|
|
|
* @return bool |
|
|
|
|
27
|
|
|
*/ |
28
|
|
|
public static function getHandler($name, $optional = false) |
|
|
|
|
29
|
|
|
{ |
30
|
|
|
global $handlers, $xoopsModule; |
|
|
|
|
31
|
|
|
|
32
|
|
|
$name = strtolower(trim($name)); |
33
|
|
|
if (!isset($handlers[$name])) { |
34
|
|
|
if (file_exists($hnd_file = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/class/class_' . $name . '.php')) { |
35
|
|
|
require_once $hnd_file; |
36
|
|
|
} |
37
|
|
|
$class = 'wfl' . ucfirst($name) . 'Handler'; |
38
|
|
|
if (class_exists($class)) { |
39
|
|
|
$handlers[$name] = new $class($GLOBALS['xoopsDB']); |
40
|
|
|
} |
41
|
|
|
} |
42
|
|
|
if (!$optional && !isset($handlers[$name])) { |
43
|
|
|
trigger_error('<div>Class <b>' . $class . '</b> does not exist.</div> |
|
|
|
|
44
|
|
|
<div>Handler Name: ' . $name, E_USER_ERROR) . '</div>'; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
return isset($handlers[$name]) ? $handlers[$name] : false; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @param int $cid |
52
|
|
|
* @param string $permType |
53
|
|
|
* @param bool $redirect |
54
|
|
|
* |
55
|
|
|
* @return bool |
56
|
|
|
*/ |
57
|
|
|
public static function checkGroups($cid = 0, $permType = 'WFLinkCatPerm', $redirect = false) |
58
|
|
|
{ |
59
|
|
|
global $xoopsUser, $xoopsModule; |
|
|
|
|
60
|
|
|
|
61
|
|
|
$groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; |
62
|
|
|
$gpermHandler = xoops_getHandler('groupperm'); |
63
|
|
View Code Duplication |
if (!$gpermHandler->checkRight($permType, $cid, $groups, $xoopsModule->getVar('mid'))) { |
|
|
|
|
64
|
|
|
if ($redirect === false) { |
65
|
|
|
return false; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
redirect_header('index.php', 3, _NOPERM); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
return true; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @param int $lid |
76
|
|
|
* @return array|bool|false |
77
|
|
|
*/ |
78
|
|
|
public static function getVoteDetails($lid = 0) |
79
|
|
|
{ |
80
|
|
|
global $xoopsDB; |
|
|
|
|
81
|
|
|
|
82
|
|
|
$sql = 'SELECT |
83
|
|
|
COUNT(rating) AS rate, |
84
|
|
|
MIN(rating) AS min_rate, |
85
|
|
|
MAX(rating) AS max_rate, |
86
|
|
|
AVG(rating) AS avg_rate, |
87
|
|
|
COUNT(ratinguser) AS rating_user, |
88
|
|
|
MAX(ratinguser) AS max_user, |
89
|
|
|
MAX(title) AS max_title, |
90
|
|
|
MIN(title) AS min_title, |
91
|
|
|
sum(ratinguser = 0) AS null_ratinguser |
92
|
|
|
FROM ' . $xoopsDB->prefix('wflinks_votedata'); |
93
|
|
|
if ($lid > 0) { |
94
|
|
|
$sql .= " WHERE lid = $lid"; |
95
|
|
|
} |
96
|
|
|
if (!$result = $xoopsDB->query($sql)) { |
97
|
|
|
return false; |
98
|
|
|
} |
99
|
|
|
$ret = $xoopsDB->fetchArray($result); |
100
|
|
|
|
101
|
|
|
return $ret; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @param int $sel_id |
106
|
|
|
* |
107
|
|
|
* @return array|bool |
108
|
|
|
*/ |
109
|
|
|
public static function calculateVoteData($sel_id = 0) |
110
|
|
|
{ |
111
|
|
|
$ret = []; |
112
|
|
|
$ret['useravgrating'] = 0; |
113
|
|
|
|
114
|
|
|
$sql = 'SELECT rating FROM ' . $xoopsDB->prefix('wflinks_votedata'); |
|
|
|
|
115
|
|
|
if ($sel_id != 0) { |
116
|
|
|
' WHERE lid = ' . $sel_id; |
117
|
|
|
} |
118
|
|
|
if (!$result = $xoopsDB->query($sql)) { |
119
|
|
|
return false; |
120
|
|
|
} |
121
|
|
|
$ret['uservotes'] = $xoopsDB->getRowsNum($result); |
122
|
|
|
while (list($rating) = $xoopsDB->fetchRow($result)) { |
123
|
|
|
$ret['useravgrating'] += (int)$rating; |
124
|
|
|
} |
125
|
|
|
if ($ret['useravgrating'] > 0) { |
126
|
|
|
$ret['useravgrating'] = number_format($ret['useravgrating'] / $ret['uservotes'], 2); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
return $ret; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* @param $array |
134
|
|
|
* @param null $name |
135
|
|
|
* @param null $def |
136
|
|
|
* @param bool $strict |
137
|
|
|
* @param int $lengthcheck |
138
|
|
|
* |
139
|
|
|
* @return array|int|mixed|null|string |
140
|
|
|
*/ |
141
|
|
|
public static function cleanRequestVars($array, $name = null, $def = null, $strict = false, $lengthcheck = 15) |
142
|
|
|
{ |
143
|
|
|
// Sanitise $_request for further use. This method gives more control and security. |
144
|
|
|
// Method is more for functionality rather than beauty at the moment, will correct later. |
145
|
|
|
unset($array['usercookie'], $array['PHPSESSID']); |
146
|
|
|
|
147
|
|
|
if (is_array($array) && $name === null) { |
148
|
|
|
$globals = []; |
149
|
|
|
foreach (array_keys($array) as $k) { |
150
|
|
|
$value = strip_tags(trim($array[$k])); |
151
|
|
|
if ('' !== $value >= $lengthcheck) { |
152
|
|
|
return null; |
153
|
|
|
} |
154
|
|
View Code Duplication |
if (ctype_digit($value)) { |
|
|
|
|
155
|
|
|
$value = (int)$value; |
156
|
|
|
} else { |
157
|
|
|
if ($strict === true) { |
158
|
|
|
$value = preg_replace('/\W/', '', trim($value)); |
159
|
|
|
} |
160
|
|
|
$value = strtolower((string)$value); |
161
|
|
|
} |
162
|
|
|
$globals[$k] = $value; |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
return $globals; |
166
|
|
|
} |
167
|
|
|
if (!array_key_exists($name, $array) || !isset($array[$name])) { |
168
|
|
|
return $def; |
169
|
|
|
} |
170
|
|
|
|
171
|
|
|
$value = strip_tags(trim($array[$name])); |
172
|
|
View Code Duplication |
if (ctype_digit($value)) { |
|
|
|
|
173
|
|
|
$value = (int)$value; |
174
|
|
|
} else { |
175
|
|
|
if ($strict === true) { |
176
|
|
|
$value = preg_replace('/\W/', '', trim($value)); |
177
|
|
|
} |
178
|
|
|
$value = strtolower((string)$value); |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
return $value; |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
// toolbar() |
185
|
|
|
// @return |
186
|
|
|
/** |
187
|
|
|
* @param int $cid |
188
|
|
|
* |
189
|
|
|
* @return string |
190
|
|
|
*/ |
191
|
|
|
public static function getToolbar($cid = 0) |
192
|
|
|
{ |
193
|
|
|
$toolbar = '[ '; |
194
|
|
|
if (true === static::checkGroups($cid, 'WFLinkSubPerm')) { |
195
|
|
|
$toolbar .= "<a href='submit.php?cid=" . $cid . "'>" . _MD_WFL_SUBMITLINK . '</a> | '; |
196
|
|
|
} |
197
|
|
|
$toolbar .= "<a href='newlist.php?newlinkshowdays=7'>" . _MD_WFL_LATESTLIST . "</a> | <a href='topten.php?list=hit'>" . _MD_WFL_POPULARITY . '</a> ]'; |
198
|
|
|
|
199
|
|
|
return $toolbar; |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
|
203
|
|
|
// displayicons() |
204
|
|
|
// @param $time |
205
|
|
|
// @param integer $status |
206
|
|
|
// @param integer $counter |
207
|
|
|
// @return |
208
|
|
|
/** |
209
|
|
|
* @param $time |
210
|
|
|
* @param int $status |
211
|
|
|
* @param int $counter |
212
|
|
|
* |
213
|
|
|
* @return string |
214
|
|
|
*/ |
215
|
|
|
public static function displayIcons($time, $status = 0, $counter = 0) |
216
|
|
|
{ |
217
|
|
|
global $xoopsModuleConfig, $xoopsModule; |
|
|
|
|
218
|
|
|
|
219
|
|
|
$new = ''; |
220
|
|
|
$pop = ''; |
221
|
|
|
|
222
|
|
|
$newdate = (time() - (86400 * (int)$xoopsModuleConfig['daysnew'])); |
223
|
|
|
$popdate = (time() - (86400 * (int)$xoopsModuleConfig['daysupdated'])); |
224
|
|
|
|
225
|
|
|
if ($xoopsModuleConfig['displayicons'] != 3) { |
226
|
|
|
if ($newdate < $time) { |
227
|
|
|
if ((int)$status > 1) { |
228
|
|
|
if ($xoopsModuleConfig['displayicons'] == 1) { |
229
|
|
|
$new = ' <img src="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/assets/images/icon/update.png" alt="" align="top">'; |
230
|
|
|
} |
231
|
|
|
if ($xoopsModuleConfig['displayicons'] == 2) { |
232
|
|
|
$new = '<i>Updated!</i>'; |
233
|
|
|
} |
234
|
|
|
} else { |
235
|
|
|
if ($xoopsModuleConfig['displayicons'] == 1) { |
236
|
|
|
$new = ' <img src="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/assets/images/icon/new.png" alt="" align="top">'; |
237
|
|
|
} |
238
|
|
|
if ($xoopsModuleConfig['displayicons'] == 2) { |
239
|
|
|
$new = '<i>New!</i>'; |
240
|
|
|
} |
241
|
|
|
} |
242
|
|
|
} |
243
|
|
|
if ($popdate > $time) { |
244
|
|
|
if ($counter >= $xoopsModuleConfig['popular']) { |
245
|
|
|
if ($xoopsModuleConfig['displayicons'] == 1) { |
246
|
|
|
$pop = ' <img src ="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/assets/images/icon/popular.png" alt="" align="top">'; |
247
|
|
|
} |
248
|
|
|
if ($xoopsModuleConfig['displayicons'] == 2) { |
249
|
|
|
$pop = '<i>Popular!</i>'; |
250
|
|
|
} |
251
|
|
|
} |
252
|
|
|
} |
253
|
|
|
} |
254
|
|
|
$icons = $new . ' ' . $pop; |
255
|
|
|
|
256
|
|
|
return $icons; |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
|
260
|
|
|
|
261
|
|
|
// updaterating() |
262
|
|
|
// @param $sel_id |
263
|
|
|
// @return updates rating data in itemtable for a given item |
264
|
|
|
/** |
265
|
|
|
* @param $sel_id |
266
|
|
|
*/ |
267
|
|
|
public static function updateRating($sel_id) |
268
|
|
|
{ |
269
|
|
|
global $xoopsDB; |
|
|
|
|
270
|
|
|
$query = 'SELECT rating FROM ' . $xoopsDB->prefix('wflinks_votedata') . ' WHERE lid=' . $sel_id; |
271
|
|
|
$voteresult = $xoopsDB->query($query); |
272
|
|
|
$votesDB = $xoopsDB->getRowsNum($voteresult); |
273
|
|
|
$totalrating = 0; |
274
|
|
|
while (list($rating) = $xoopsDB->fetchRow($voteresult)) { |
275
|
|
|
$totalrating += $rating; |
276
|
|
|
} |
277
|
|
|
$finalrating = $totalrating / $votesDB; |
278
|
|
|
$finalrating = number_format($finalrating, 4); |
279
|
|
|
$sql = sprintf('UPDATE %s SET rating = %u, votes = %u WHERE lid = %u', $xoopsDB->prefix('wflinks_links'), $finalrating, $votesDB, $sel_id); |
280
|
|
|
$xoopsDB->query($sql); |
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
// totalcategory() |
284
|
|
|
// @param integer $pid |
285
|
|
|
// @return |
286
|
|
|
/** |
287
|
|
|
* @param int $pid |
288
|
|
|
* |
289
|
|
|
* @return int |
290
|
|
|
*/ |
291
|
|
|
public static function getTotalCategory($pid = 0) |
292
|
|
|
{ |
293
|
|
|
global $xoopsDB; |
|
|
|
|
294
|
|
|
|
295
|
|
|
$sql = 'SELECT cid FROM ' . $xoopsDB->prefix('wflinks_cat'); |
296
|
|
|
if ($pid > 0) { |
297
|
|
|
$sql .= ' WHERE pid=0'; |
298
|
|
|
} |
299
|
|
|
$result = $xoopsDB->query($sql); |
300
|
|
|
$catlisting = 0; |
301
|
|
|
while (list($cid) = $xoopsDB->fetchRow($result)) { |
302
|
|
|
if (static::checkGroups($cid)) { |
303
|
|
|
++$catlisting; |
304
|
|
|
} |
305
|
|
|
} |
306
|
|
|
|
307
|
|
|
return $catlisting; |
308
|
|
|
} |
309
|
|
|
|
310
|
|
|
// static::getTotalItems() |
|
|
|
|
311
|
|
|
// @param integer $sel_id |
312
|
|
|
// @param integer $get_child |
313
|
|
|
// @param integer $return_sql |
314
|
|
|
// @return |
315
|
|
|
/** |
316
|
|
|
* @param int $sel_id |
317
|
|
|
* @param int $get_child |
318
|
|
|
* @param int $return_sql |
319
|
|
|
* |
320
|
|
|
* @return mixed |
321
|
|
|
*/ |
322
|
|
|
public static function getTotalItems($sel_id = 0, $get_child = 0, $return_sql = 0) |
323
|
|
|
{ |
324
|
|
|
global $xoopsDB, $mytree, $_check_array; |
|
|
|
|
325
|
|
|
|
326
|
|
|
if ($sel_id > 0) { |
327
|
|
|
$sql = 'SELECT DISTINCT a.lid, a.cid, published FROM ' |
328
|
|
|
. $xoopsDB->prefix('wflinks_links') |
329
|
|
|
. ' a LEFT JOIN ' |
330
|
|
|
. $xoopsDB->prefix('wflinks_altcat') |
331
|
|
|
. ' b ' |
332
|
|
|
. 'ON b.lid=a.lid ' |
333
|
|
|
. 'WHERE published > 0 AND published <= ' |
334
|
|
|
. time() |
335
|
|
|
. ' AND (expired = 0 OR expired > ' |
336
|
|
|
. time() |
337
|
|
|
. ') AND offline = 0 ' |
338
|
|
|
. ' AND (b.cid=a.cid OR (a.cid=' |
339
|
|
|
. $sel_id |
340
|
|
|
. ' OR b.cid=' |
341
|
|
|
. $sel_id |
342
|
|
|
. ')) '; |
343
|
|
|
} else { |
344
|
|
|
$sql = 'SELECT lid, cid, published FROM ' . $xoopsDB->prefix('wflinks_links') . ' WHERE offline = 0 AND published > 0 AND published <= ' . time() . ' AND (expired = 0 OR expired > ' . time() . ')'; |
345
|
|
|
} |
346
|
|
|
if ($return_sql == 1) { |
347
|
|
|
return $sql; |
348
|
|
|
} |
349
|
|
|
|
350
|
|
|
$count = 0; |
351
|
|
|
$published_date = 0; |
352
|
|
|
|
353
|
|
|
$items = []; |
|
|
|
|
354
|
|
|
$result = $xoopsDB->query($sql); |
355
|
|
|
while (list($lid, $cid, $published) = $xoopsDB->fetchRow($result)) { |
|
|
|
|
356
|
|
|
if (true === static::checkGroups()) { |
357
|
|
|
++$count; |
358
|
|
|
$published_date = ($published > $published_date) ? $published : $published_date; |
359
|
|
|
} |
360
|
|
|
} |
361
|
|
|
|
362
|
|
|
$child_count = 0; |
363
|
|
|
if ($get_child == 1) { |
364
|
|
|
$items = $mytree->getAllChildId($sel_id); |
365
|
|
|
foreach ($items as $item) { |
366
|
|
|
$query2 = 'SELECT DISTINCT a.lid, a.cid, published FROM ' |
367
|
|
|
. $xoopsDB->prefix('wflinks_links') |
368
|
|
|
. ' a LEFT JOIN ' |
369
|
|
|
. $xoopsDB->prefix('wflinks_altcat') |
370
|
|
|
. ' b ' |
371
|
|
|
. 'ON b.lid=a.lid ' |
372
|
|
|
. 'WHERE published > 0 AND published <= ' |
373
|
|
|
. time() |
374
|
|
|
. ' AND (expired = 0 OR expired > ' |
375
|
|
|
. time() |
376
|
|
|
. ') AND offline = 0 ' |
377
|
|
|
. ' AND (b.cid=a.cid OR (a.cid=' |
378
|
|
|
. $item |
379
|
|
|
. ' OR b.cid=' |
380
|
|
|
. $item |
381
|
|
|
. ')) '; |
382
|
|
|
|
383
|
|
|
$result2 = $xoopsDB->query($query2); |
384
|
|
|
while (list($lid, $published) = $xoopsDB->fetchRow($result2)) { |
|
|
|
|
385
|
|
|
if ($published == 0) { |
386
|
|
|
continue; |
387
|
|
|
} |
388
|
|
|
$published_date = ($published > $published_date) ? $published : $published_date; |
389
|
|
|
++$child_count; |
390
|
|
|
} |
391
|
|
|
} |
392
|
|
|
} |
393
|
|
|
$info['count'] = $count + $child_count; |
|
|
|
|
394
|
|
|
$info['published'] = $published_date; |
395
|
|
|
|
396
|
|
|
return $info; |
397
|
|
|
} |
398
|
|
|
|
399
|
|
|
/** |
400
|
|
|
* @param string $indeximage |
401
|
|
|
* @param string $indexheading |
402
|
|
|
* |
403
|
|
|
* @return string |
404
|
|
|
*/ |
405
|
|
|
public static function getImageHeader($indeximage = '', $indexheading = '') |
406
|
|
|
{ |
407
|
|
|
global $xoopsDB, $xoopsModuleConfig; |
|
|
|
|
408
|
|
|
|
409
|
|
|
if ($indeximage == '') { |
410
|
|
|
$result = $xoopsDB->query('SELECT indeximage, indexheading FROM ' . $xoopsDB->prefix('wflinks_indexpage')); |
411
|
|
|
list($indeximage, $indexheading) = $xoopsDB->fetchRow($result); |
412
|
|
|
} |
413
|
|
|
|
414
|
|
|
$image = ''; |
415
|
|
|
if (!empty($indeximage)) { |
416
|
|
|
$image = static::displayImage($indeximage, "'index.php'", $xoopsModuleConfig['mainimagedir'], $indexheading); |
417
|
|
|
} |
418
|
|
|
|
419
|
|
|
return $image; |
420
|
|
|
} |
421
|
|
|
|
422
|
|
|
/** |
423
|
|
|
* @param string $image |
424
|
|
|
* @param string $path |
425
|
|
|
* @param string $imgsource |
426
|
|
|
* @param string $alttext |
427
|
|
|
* |
428
|
|
|
* @return string |
429
|
|
|
*/ |
430
|
|
|
public static function displayImage($image = '', $path = '', $imgsource = '', $alttext = '') |
431
|
|
|
{ |
432
|
|
|
global $xoopsConfig, $xoopsUser, $xoopsModule; |
|
|
|
|
433
|
|
|
|
434
|
|
|
$showimage = ''; |
435
|
|
|
// Check to see if link is given |
436
|
|
|
if ($path) { |
437
|
|
|
$showimage = '<a href=' . $path . '>'; |
438
|
|
|
} |
439
|
|
|
|
440
|
|
|
// checks to see if the file is valid else displays default blank image |
441
|
|
|
if (!is_dir(XOOPS_ROOT_PATH . "/{$imgsource}/{$image}") |
442
|
|
|
&& file_exists(XOOPS_ROOT_PATH . "/{$imgsource}/{$image}")) { |
443
|
|
|
$showimage .= "<img src='" . XOOPS_URL . "/{$imgsource}/{$image}' border='0' alt='" . $alttext . "'></a>"; |
444
|
|
|
} else { |
445
|
|
|
if ($xoopsUser && $xoopsUser->isAdmin($xoopsModule->getVar('mid'))) { |
446
|
|
|
$showimage .= "<img src='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/assets/images/brokenimg.gif' alt='" . _MD_WFL_ISADMINNOTICE . "'></a>"; |
447
|
|
|
} else { |
448
|
|
|
$showimage .= "<img src='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/assets/images/blank.gif' alt='" . $alttext . "'></a>"; |
449
|
|
|
} |
450
|
|
|
} |
451
|
|
|
clearstatcache(); |
452
|
|
|
|
453
|
|
|
return $showimage; |
454
|
|
|
} |
455
|
|
|
|
456
|
|
|
/** |
457
|
|
|
* @return string |
458
|
|
|
*/ |
459
|
|
|
public static function getLetters() |
460
|
|
|
{ |
461
|
|
|
global $xoopsModule; |
|
|
|
|
462
|
|
|
|
463
|
|
|
$letterchoice = '<div>' . _MD_WFL_BROWSETOTOPIC . '</div>'; |
464
|
|
|
$letterchoice .= '[ '; |
465
|
|
|
$alphabet = [ |
466
|
|
|
'0', |
467
|
|
|
'1', |
468
|
|
|
'2', |
469
|
|
|
'3', |
470
|
|
|
'4', |
471
|
|
|
'5', |
472
|
|
|
'6', |
473
|
|
|
'7', |
474
|
|
|
'8', |
475
|
|
|
'9', |
476
|
|
|
'A', |
477
|
|
|
'B', |
478
|
|
|
'C', |
479
|
|
|
'D', |
480
|
|
|
'E', |
481
|
|
|
'F', |
482
|
|
|
'G', |
483
|
|
|
'H', |
484
|
|
|
'I', |
485
|
|
|
'J', |
486
|
|
|
'K', |
487
|
|
|
'L', |
488
|
|
|
'M', |
489
|
|
|
'N', |
490
|
|
|
'O', |
491
|
|
|
'P', |
492
|
|
|
'Q', |
493
|
|
|
'R', |
494
|
|
|
'S', |
495
|
|
|
'T', |
496
|
|
|
'U', |
497
|
|
|
'V', |
498
|
|
|
'W', |
499
|
|
|
'X', |
500
|
|
|
'Y', |
501
|
|
|
'Z' |
502
|
|
|
]; |
503
|
|
|
$num = count($alphabet) - 1; |
504
|
|
|
$counter = 0; |
505
|
|
|
// while (list(, $ltr) = each($alphabet)) { |
|
|
|
|
506
|
|
|
foreach ($alphabet as $key => $ltr) { |
507
|
|
|
$letterchoice .= "<a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . "/viewcat.php?list=$ltr'>$ltr</a>"; |
508
|
|
|
if ($counter == round($num / 2)) { |
509
|
|
|
$letterchoice .= ' ]<br>[ '; |
510
|
|
|
} elseif ($counter != $num) { |
511
|
|
|
$letterchoice .= ' | '; |
512
|
|
|
} |
513
|
|
|
++$counter; |
514
|
|
|
} |
515
|
|
|
$letterchoice .= ' ]'; |
516
|
|
|
|
517
|
|
|
return $letterchoice; |
518
|
|
|
} |
519
|
|
|
|
520
|
|
|
/** |
521
|
|
|
* @param $published |
522
|
|
|
* |
523
|
|
|
* @return mixed |
524
|
|
|
*/ |
525
|
|
|
public static function isNewImage($published) |
526
|
|
|
{ |
527
|
|
|
global $xoopsModule, $xoopsDB; |
|
|
|
|
528
|
|
|
|
529
|
|
|
$oneday = (time() - (86400 * 1)); |
530
|
|
|
$threedays = (time() - (86400 * 3)); |
531
|
|
|
$week = (time() - (86400 * 7)); |
532
|
|
|
|
533
|
|
|
$path = 'modules/' . $xoopsModule->getVar('dirname') . '/assets/images/icon'; |
534
|
|
|
|
535
|
|
|
if ($published > 0 && $published < $week) { |
536
|
|
|
$indicator['image'] = "$path/linkload4.gif"; |
|
|
|
|
537
|
|
|
$indicator['alttext'] = _MD_WFL_NEWLAST; |
538
|
|
|
} elseif ($published >= $week && $published < $threedays) { |
539
|
|
|
$indicator['image'] = "$path/linkload3.gif"; |
|
|
|
|
540
|
|
|
$indicator['alttext'] = _MD_WFL_NEWTHIS; |
541
|
|
|
} elseif ($published >= $threedays && $published < $oneday) { |
542
|
|
|
$indicator['image'] = "$path/linkload2.gif"; |
|
|
|
|
543
|
|
|
$indicator['alttext'] = _MD_WFL_THREE; |
544
|
|
|
} elseif ($published >= $oneday) { |
545
|
|
|
$indicator['image'] = "$path/linkload1.gif"; |
|
|
|
|
546
|
|
|
$indicator['alttext'] = _MD_WFL_TODAY; |
547
|
|
|
} else { |
548
|
|
|
$indicator['image'] = "$path/linkload.gif"; |
|
|
|
|
549
|
|
|
$indicator['alttext'] = _MD_WFL_NO_FILES; |
550
|
|
|
} |
551
|
|
|
|
552
|
|
|
return $indicator; |
553
|
|
|
} |
554
|
|
|
|
555
|
|
|
/** |
556
|
|
|
* @param $haystack |
557
|
|
|
* @param $needle |
558
|
|
|
* |
559
|
|
|
* @return string |
560
|
|
|
*/ |
561
|
|
|
public static function searchString($haystack, $needle) |
562
|
|
|
{ |
563
|
|
|
return substr($haystack, 0, strpos($haystack, $needle) + 1); |
564
|
|
|
} |
565
|
|
|
|
566
|
|
|
/** |
567
|
|
|
* @param string $header |
568
|
|
|
* @param string $menu |
569
|
|
|
* @param string $extra |
570
|
|
|
* @param int $scount |
571
|
|
|
* |
572
|
|
|
* @return null |
|
|
|
|
573
|
|
|
*/ |
574
|
|
|
public static function getAdminMenu($header = '', $menu = '', $extra = '', $scount = 4) |
|
|
|
|
575
|
|
|
{ |
576
|
|
|
global $xoopsConfig, $xoopsModule, $xoopsModuleConfig; |
|
|
|
|
577
|
|
|
|
578
|
|
|
$_named_url = xoops_getenv('PHP_SELF'); |
579
|
|
|
if ($_named_url) { |
580
|
|
|
$thispage = basename($_named_url); |
581
|
|
|
} |
582
|
|
|
|
583
|
|
|
if (file_exists(__DIR__ . '/../docs/' . $xoopsConfig['language'] . '/readme.html')) { |
584
|
|
|
$docs = '<a href="../docs/' . $xoopsConfig['language'] . '/readme.html" target="_blank">' . _AM_WFL_DOCUMENTATION . '</a> |'; |
585
|
|
|
} elseif (file_exists(__DIR__ . '/../docs/english/readme.html')) { |
586
|
|
|
$docs = '<a href="../docs/english/readme.html" target="_blank">' . _AM_WFL_DOCUMENTATION . '</a> |'; |
587
|
|
|
} else { |
588
|
|
|
$docs = ''; |
589
|
|
|
} |
590
|
|
|
|
591
|
|
|
$op = isset($_GET['op']) ? $op = '?op=' . $_GET['op'] : ''; |
592
|
|
|
|
593
|
|
|
echo "<h4 style='color: #2F5376;'>" . _AM_WFL_MODULE_NAME . '</h4>'; |
594
|
|
|
echo " |
595
|
|
|
<table width='100%' cellspacing='0' cellpadding='0' border='0' class='outer'>\n |
596
|
|
|
<tr>\n |
597
|
|
|
<td style='font-size: 10px; text-align: left; color: #2F5376; padding: 2px 6px; line-height: 18px;'>\n |
598
|
|
|
<a href='../admin/index.php'>" . _AM_WFL_BINDEX . "</a> | \n |
599
|
|
|
<a href='../index.php'>" . _AM_WFL_GOMODULE . "</a> | \n |
600
|
|
|
<a href='../../system/admin.php?fct=preferences&op=showmod&mod=" . $xoopsModule->getVar('mid') . "'>" . _AM_WFL_PREFS . "</a> | \n |
601
|
|
|
<a href='../../system/admin.php?fct=modulesadmin&op=update&module=" . $xoopsModule->getVar('dirname') . "'>" . _AM_WFL_BUPDATE . "</a> | \n |
602
|
|
|
<a href='../admin/permissions.php'>" . _AM_WFL_BPERMISSIONS . "</a> | \n |
603
|
|
|
<a href='../admin/myblocksadmin.php'>" . _AM_WFL_BLOCKADMIN . "</a> | \n |
604
|
|
|
" . $docs . " |
605
|
|
|
<a href='../admin/about.php'>" . _AM_WFL_ABOUT . "</a> \n |
606
|
|
|
</td>\n |
607
|
|
|
</tr>\n |
608
|
|
|
</table><br>\n |
609
|
|
|
"; |
610
|
|
|
|
611
|
|
|
if (empty($menu)) { |
612
|
|
|
// You can change this part to suit your own module. Defining this here will save you form having to do this each time. |
613
|
|
|
$menu = [ |
614
|
|
|
_AM_WFL_INDEXPAGE => 'indexpage.php', |
615
|
|
|
_AM_WFL_MCATEGORY => 'category.php', |
616
|
|
|
_AM_WFL_MLINKS => 'main.php?op=edit', |
617
|
|
|
_AM_WFL_MUPLOADS => 'upload.php', |
618
|
|
|
_AM_WFL_MVOTEDATA => 'votedata.php', |
619
|
|
|
_AM_WFL_MLISTPINGTIMES => 'main.php?op=pingtime', |
620
|
|
|
_AM_WFL_MCOMMENTS => '../../system/admin.php?module=' . $xoopsModule->getVar('mid') . '&status=0&limit=100&fct=comments&selsubmit=Go', |
621
|
|
|
]; |
622
|
|
|
} |
623
|
|
|
|
624
|
|
|
if (!is_array($menu)) { |
625
|
|
|
echo "<table width='100%' cellpadding= '2' cellspacing= '1' class='outer'>\n"; |
626
|
|
|
echo "<tr><td class ='even' align ='center'><b>" . _AM_WFL_NOMENUITEMS . "</b></td></tr></table><br>\n"; |
627
|
|
|
|
628
|
|
|
return false; |
629
|
|
|
} |
630
|
|
|
|
631
|
|
|
$oddnum = [1 => '1', 3 => '3', 5 => '5', 7 => '7', 9 => '9', 11 => '11', 13 => '13']; |
632
|
|
|
// number of rows per menu |
633
|
|
|
$menurows = count($menu) / $scount; |
634
|
|
|
// total amount of rows to complete menu |
635
|
|
|
$menurow = ceil($menurows) * $scount; |
636
|
|
|
// actual number of menuitems per row |
637
|
|
|
$rowcount = $menurow / ceil($menurows); |
|
|
|
|
638
|
|
|
$count = 0; |
639
|
|
|
for ($i = count($menu); $i < $menurow; ++$i) { |
640
|
|
|
$tempArray = [1 => null]; |
641
|
|
|
$menu = array_merge($menu, $tempArray); |
642
|
|
|
++$count; |
643
|
|
|
} |
644
|
|
|
|
645
|
|
|
// Sets up the width of each menu cell |
646
|
|
|
$width = 100 / $scount; |
647
|
|
|
$width = ceil($width); |
648
|
|
|
|
649
|
|
|
$menucount = 0; |
650
|
|
|
$count = 0; |
651
|
|
|
|
652
|
|
|
// Menu table output |
653
|
|
|
echo "<table width='100%' cellpadding= '2' cellspacing= '1' class='outer'><tr>"; |
654
|
|
|
|
655
|
|
|
// Check to see if $menu is and array |
656
|
|
|
if (is_array($menu)) { |
657
|
|
|
$classcounts = 0; |
658
|
|
|
$classcol[0] = 'even'; |
|
|
|
|
659
|
|
|
|
660
|
|
|
for ($i = 1; $i < $menurow; ++$i) { |
661
|
|
|
++$classcounts; |
662
|
|
|
if ($classcounts >= $scount) { |
663
|
|
|
if ($classcol[$i - 1] === 'odd') { |
664
|
|
|
$classcol[$i] = ($classcol[$i - 1] === 'odd' && in_array($classcounts, $oddnum)) ? 'even' : 'odd'; |
665
|
|
|
} else { |
666
|
|
|
$classcol[$i] = ($classcol[$i - 1] === 'even' && in_array($classcounts, $oddnum)) ? 'odd' : 'even'; |
667
|
|
|
} |
668
|
|
|
$classcounts = 0; |
669
|
|
|
} else { |
670
|
|
|
$classcol[$i] = ($classcol[$i - 1] === 'even') ? 'odd' : 'even'; |
671
|
|
|
} |
672
|
|
|
} |
673
|
|
|
unset($classcounts); |
674
|
|
|
|
675
|
|
|
foreach ($menu as $menutitle => $menulink) { |
676
|
|
|
if ($thispage . $op == $menulink) { |
|
|
|
|
677
|
|
|
$classcol[$count] = 'outer'; |
678
|
|
|
} |
679
|
|
|
echo "<td class='" . $classcol[$count] . "' class='txtcenter;' valign='middle' width='$width%'>"; |
680
|
|
|
if (is_string($menulink)) { |
681
|
|
|
echo "<a href='" . $menulink . "'><small>" . $menutitle . '</small></a></td>'; |
682
|
|
|
} else { |
683
|
|
|
echo ' </td>'; |
684
|
|
|
} |
685
|
|
|
++$menucount; |
686
|
|
|
++$count; |
687
|
|
|
|
688
|
|
|
// Break menu cells to start a new row if $count > $scount |
689
|
|
|
if ($menucount >= $scount) { |
690
|
|
|
echo '</tr>'; |
691
|
|
|
$menucount = 0; |
692
|
|
|
} |
693
|
|
|
} |
694
|
|
|
echo '</table><br>'; |
695
|
|
|
unset($count, $menucount); |
696
|
|
|
} |
697
|
|
|
// ###### Output warn messages for security ###### |
698
|
|
|
if (is_dir(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/update/')) { |
699
|
|
|
xoops_error(sprintf(_AM_WFL_WARNINSTALL1, XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/update/')); |
700
|
|
|
echo '<br>'; |
701
|
|
|
} |
702
|
|
|
|
703
|
|
|
$_file = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/update.php'; |
704
|
|
|
if (file_exists($_file)) { |
705
|
|
|
xoops_error(sprintf(_AM_WFL_WARNINSTALL2, XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/update.php')); |
706
|
|
|
echo '<br>'; |
707
|
|
|
} |
708
|
|
|
|
709
|
|
|
$path1 = XOOPS_ROOT_PATH . '/' . $xoopsModuleConfig['mainimagedir']; |
710
|
|
|
if (!is_dir($path1)) { |
711
|
|
|
xoops_error(sprintf(_AM_WFL_WARNINSTALL3, $path1)); |
712
|
|
|
echo '<br>'; |
713
|
|
|
} |
714
|
|
|
if (!is_writable($path1)) { |
715
|
|
|
xoops_error(sprintf(_AM_WFL_WARNINSTALL4, $path1)); |
716
|
|
|
echo '<br>'; |
717
|
|
|
} |
718
|
|
|
|
719
|
|
|
$path1_t = XOOPS_ROOT_PATH . '/' . $xoopsModuleConfig['mainimagedir'] . '/thumbs'; |
720
|
|
|
if (!is_dir($path1_t)) { |
721
|
|
|
xoops_error(sprintf(_AM_WFL_WARNINSTALL3, $path1_t)); |
722
|
|
|
echo '<br>'; |
723
|
|
|
} |
724
|
|
|
if (!is_writable($path1_t)) { |
725
|
|
|
xoops_error(sprintf(_AM_WFL_WARNINSTALL4, $path1_t)); |
726
|
|
|
echo '<br>'; |
727
|
|
|
} |
728
|
|
|
|
729
|
|
|
$path2 = XOOPS_ROOT_PATH . '/' . $xoopsModuleConfig['screenshots']; |
730
|
|
|
if (!is_dir($path2)) { |
731
|
|
|
xoops_error(sprintf(_AM_WFL_WARNINSTALL3, $path2)); |
732
|
|
|
echo '<br>'; |
733
|
|
|
} |
734
|
|
|
if (!is_writable($path2)) { |
735
|
|
|
xoops_error(sprintf(_AM_WFL_WARNINSTALL4, $path2)); |
736
|
|
|
echo '<br>'; |
737
|
|
|
} |
738
|
|
|
|
739
|
|
|
$path2_t = XOOPS_ROOT_PATH . '/' . $xoopsModuleConfig['screenshots'] . '/thumbs'; |
740
|
|
|
if (!is_dir($path2_t)) { |
741
|
|
|
xoops_error(sprintf(_AM_WFL_WARNINSTALL3, $path2_t)); |
742
|
|
|
echo '<br>'; |
743
|
|
|
} |
744
|
|
|
if (!is_writable($path2_t)) { |
745
|
|
|
xoops_error(sprintf(_AM_WFL_WARNINSTALL4, $path2_t)); |
746
|
|
|
echo '<br>'; |
747
|
|
|
} |
748
|
|
|
|
749
|
|
|
$path3 = XOOPS_ROOT_PATH . '/' . $xoopsModuleConfig['catimage']; |
750
|
|
|
if (!is_dir($path3)) { |
751
|
|
|
xoops_error(sprintf(_AM_WFL_WARNINSTALL3, $path3)); |
752
|
|
|
echo '<br>'; |
753
|
|
|
} |
754
|
|
|
if (!is_writable($path3)) { |
755
|
|
|
xoops_error(sprintf(_AM_WFL_WARNINSTALL4, $path3)); |
756
|
|
|
echo '<br>'; |
757
|
|
|
} |
758
|
|
|
|
759
|
|
|
$path3_t = XOOPS_ROOT_PATH . '/' . $xoopsModuleConfig['catimage'] . '/thumbs'; |
760
|
|
|
if (!is_dir($path3_t)) { |
761
|
|
|
xoops_error(sprintf(_AM_WFL_WARNINSTALL3, $path3_t)); |
762
|
|
|
echo '<br>'; |
763
|
|
|
} |
764
|
|
|
if (!is_writable($path3_t)) { |
765
|
|
|
xoops_error(sprintf(_AM_WFL_WARNINSTALL4, $path3_t)); |
766
|
|
|
echo '<br>'; |
767
|
|
|
} |
768
|
|
|
|
769
|
|
|
echo "<h3 style='color: #2F5376;'>" . $header . '</h3>'; |
770
|
|
|
if ($extra) { |
771
|
|
|
echo "<div>$extra</div>"; |
772
|
|
|
} |
773
|
|
|
|
774
|
|
|
return null; |
775
|
|
|
} |
776
|
|
|
|
777
|
|
|
/** |
778
|
|
|
* @param $selected |
779
|
|
|
* @param $dirarray |
780
|
|
|
* @param $namearray |
781
|
|
|
*/ |
782
|
|
|
public static function getDirSelectOption($selected, $dirarray, $namearray) |
783
|
|
|
{ |
784
|
|
|
echo "<select size='1' name='workd' onchange='location.href=\"upload.php?rootpath=\"+this.options[this.selectedIndex].value'>"; |
785
|
|
|
echo "<option value=''>--------------------------------------</option>"; |
786
|
|
|
foreach ($namearray as $namearray => $workd) { |
787
|
|
|
if ($workd === $selected) { |
788
|
|
|
$opt_selected = 'selected'; |
789
|
|
|
} else { |
790
|
|
|
$opt_selected = ''; |
791
|
|
|
} |
792
|
|
|
echo "<option value='" . htmlspecialchars($namearray, ENT_QUOTES) . "' $opt_selected>" . $workd . '</option>'; |
793
|
|
|
} |
794
|
|
|
echo '</select>'; |
795
|
|
|
} |
796
|
|
|
|
797
|
|
|
/** |
798
|
|
|
* @param $FILES |
799
|
|
|
* @param string $uploaddir |
800
|
|
|
* @param string $allowed_mimetypes |
801
|
|
|
* @param string $redirecturl |
802
|
|
|
* @param int $num |
803
|
|
|
* @param int $redirect |
804
|
|
|
* @param int $usertype |
805
|
|
|
* |
806
|
|
|
* @return array|null |
807
|
|
|
*/ |
808
|
|
|
public static function uploadFiles( |
|
|
|
|
809
|
|
|
$FILES, |
810
|
|
|
$uploaddir = 'uploads', |
811
|
|
|
$allowed_mimetypes = '', |
812
|
|
|
$redirecturl = 'index.php', |
813
|
|
|
$num = 0, |
814
|
|
|
$redirect = 0, |
815
|
|
|
$usertype = 1) |
816
|
|
|
{ |
817
|
|
|
global $FILES, $xoopsConfig, $xoopsModuleConfig, $xoopsModule; |
|
|
|
|
818
|
|
|
|
819
|
|
|
$down = []; |
820
|
|
|
// require_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/class/uploader.php'; |
|
|
|
|
821
|
|
|
require_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
822
|
|
|
if (empty($allowed_mimetypes)) { |
823
|
|
|
$allowed_mimetypes = wfl_getmime($FILES['userfile']['name'], $usertype); |
824
|
|
|
} |
825
|
|
|
$upload_dir = XOOPS_ROOT_PATH . '/' . $uploaddir . '/'; |
826
|
|
|
|
827
|
|
|
$maxfilesize = $xoopsModuleConfig['maxfilesize']; |
828
|
|
|
$maxfilewidth = $xoopsModuleConfig['maximgwidth']; |
829
|
|
|
$maxfileheight = $xoopsModuleConfig['maximgheight']; |
830
|
|
|
|
831
|
|
|
$uploader = new XoopsMediaUploader($upload_dir, $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight); |
832
|
|
|
// $uploader->noAdminSizeCheck(1); |
|
|
|
|
833
|
|
|
if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { |
834
|
|
|
if (!$uploader->upload()) { |
835
|
|
|
$errors = $uploader->getErrors(); |
836
|
|
|
redirect_header($redirecturl, 2, $errors); |
837
|
|
|
} else { |
838
|
|
|
if ($redirect) { |
839
|
|
|
redirect_header($redirecturl, 1, _AM_WFL_UPLOADFILE); |
840
|
|
|
} else { |
841
|
|
|
if (is_file($uploader->savedDestination)) { |
842
|
|
|
$down['url'] = XOOPS_URL . '/' . $uploaddir . '/' . strtolower($uploader->savedFileName); |
843
|
|
|
$down['size'] = filesize(XOOPS_ROOT_PATH . '/' . $uploaddir . '/' . strtolower($uploader->savedFileName)); |
844
|
|
|
} |
845
|
|
|
|
846
|
|
|
return $down; |
847
|
|
|
} |
848
|
|
|
} |
849
|
|
|
} else { |
850
|
|
|
$errors = $uploader->getErrors(); |
851
|
|
|
redirect_header($redirecturl, 1, $errors); |
852
|
|
|
} |
853
|
|
|
|
854
|
|
|
return null; |
855
|
|
|
} |
856
|
|
|
|
857
|
|
|
/** |
858
|
|
|
* @param $forumid |
859
|
|
|
* |
860
|
|
|
* @return mixed |
861
|
|
|
*/ |
862
|
|
|
public static function getForum($forumid) |
863
|
|
|
{ |
864
|
|
|
global $xoopsDB, $xoopsConfig; |
|
|
|
|
865
|
|
|
|
866
|
|
|
echo "<select name='forumid'>"; |
867
|
|
|
echo "<option value='0'>----------------------</option>"; |
868
|
|
|
if ($forumid < 4) { |
869
|
|
|
$result = $xoopsDB->query('SELECT forum_name, forum_id FROM ' . $xoopsDB->prefix('bb_forums') . ' ORDER BY forum_id'); |
870
|
|
|
} else { |
871
|
|
|
$result = $xoopsDB->query('SELECT forum_name, forum_id FROM ' . $xoopsDB->prefix('bbex_forums') . ' ORDER BY forum_id'); |
872
|
|
|
} |
873
|
|
View Code Duplication |
while (list($forum_name, $forum_id) = $xoopsDB->fetchRow($result)) { |
|
|
|
|
874
|
|
|
if ($forum_id == $forumid) { |
875
|
|
|
$opt_selected = 'selected'; |
876
|
|
|
} else { |
877
|
|
|
$opt_selected = ''; |
878
|
|
|
} |
879
|
|
|
echo "<option value='" . $forum_id . "' $opt_selected>" . $forum_name . '</option>'; |
880
|
|
|
} |
881
|
|
|
echo '</select></div>'; |
882
|
|
|
|
883
|
|
|
return $forumid; |
884
|
|
|
} |
885
|
|
|
|
886
|
|
|
/** |
887
|
|
|
* @param $heading |
888
|
|
|
*/ |
889
|
|
|
public static function getLinkListHeader($heading) |
890
|
|
|
{ |
891
|
|
|
echo " |
892
|
|
|
<!-- <h4 style='font-weight: bold; color: #0A3760;'>" . $heading . "</h4>\n --> |
893
|
|
|
<table width='100%' cellspacing='1' class='outer' style='font-size: smaller;' summary>\n |
894
|
|
|
<tr>\n |
895
|
|
|
<th class='txtcenter;'>" . _AM_WFL_MINDEX_ID . "</th>\n |
896
|
|
|
<th style='text-align: left;'><b>" . _AM_WFL_MINDEX_TITLE . "</th>\n |
897
|
|
|
<th style='text-align: left;'><b>" . _AM_WFL_CATTITLE . "</th>\n |
898
|
|
|
<th class='txtcenter;'>" . _AM_WFL_MINDEX_POSTER . "</th>\n |
899
|
|
|
<th class='txtcenter;'>" . _AM_WFL_MINDEX_PUBLISH . "</th>\n |
900
|
|
|
<th class='txtcenter;'>" . _AM_WFL_MINDEX_EXPIRE . "</th>\n |
901
|
|
|
<th class='txtcenter;'>" . _AM_WFL_MINDEX_ONLINE . "</th>\n |
902
|
|
|
<th class='txtcenter;'>" . _AM_WFL_MINDEX_ACTION . "</th>\n |
903
|
|
|
</tr>\n |
904
|
|
|
"; |
905
|
|
|
} |
906
|
|
|
|
907
|
|
|
/** |
908
|
|
|
* @param $published |
909
|
|
|
*/ |
910
|
|
|
public static function getLinkListBody($published) |
911
|
|
|
{ |
912
|
|
|
global $wfmyts, $imageArray, $xoopsModuleConfig, $xoopsModule; |
|
|
|
|
913
|
|
|
xoops_load('XoopsUserUtility'); |
914
|
|
|
$lid = $published['lid']; |
915
|
|
|
$cid = $published['cid']; |
916
|
|
|
|
917
|
|
|
$title = "<a href='../singlelink.php?cid=" . $published['cid'] . '&lid=' . $published['lid'] . "'>" . $wfmyts->htmlSpecialCharsStrip(trim($published['title'])) . '</a>'; |
918
|
|
|
$maintitle = urlencode($wfmyts->htmlSpecialChars(trim($published['title']))); |
|
|
|
|
919
|
|
|
$cattitle = static::getCategoryTitle($published['cid']); |
920
|
|
|
$submitter = XoopsUserUtility::getUnameFromId($published['submitter']); |
921
|
|
|
$hwhoisurl = str_replace('http://', '', $published['url']); |
922
|
|
|
$submitted = formatTimestamp($published['date'], $xoopsModuleConfig['dateformat']); |
|
|
|
|
923
|
|
|
$publish = ($published['published'] > 0) ? formatTimestamp($published['published'], $xoopsModuleConfig['dateformatadmin']) : 'Not Published'; |
924
|
|
|
$expires = $published['expired'] ? formatTimestamp($published['expired'], $xoopsModuleConfig['dateformatadmin']) : _AM_WFL_MINDEX_NOTSET; |
925
|
|
|
// if ( ( $published['published'] && $published['published'] < time() ) && $published['offline'] == 0 ) { |
|
|
|
|
926
|
|
|
// $published_status = $imageArray['online']; |
|
|
|
|
927
|
|
|
// } else { |
|
|
|
|
928
|
|
|
// $published_status = ( $published['published'] == 0 ) ? "<a href='newlinks.php'>" . $imageArray['offline'] . "</a>" : $imageArray['offline']; |
|
|
|
|
929
|
|
|
// } |
930
|
|
|
if ($published['offline'] == 0 |
931
|
|
|
&& ($published['published'] && $published['published'] < time()) |
932
|
|
|
&& (($published['expired'] && $published['expired'] > time()) || $published['expired'] == 0)) { |
933
|
|
|
$published_status = $imageArray['online']; |
934
|
|
|
} elseif ($published['offline'] == 0 && ($published['expired'] && $published['expired'] < time())) { |
935
|
|
|
$published_status = $imageArray['expired']; |
936
|
|
|
} else { |
937
|
|
|
$published_status = ($published['published'] == 0) ? "<a href='newlinks.php'>" . $imageArray['offline'] . '</a>' : $imageArray['offline']; |
938
|
|
|
} |
939
|
|
|
$icon = "<a href='main.php?op=edit&lid=" . $lid . "' title='" . _AM_WFL_ICO_EDIT . "'>" . $imageArray['editimg'] . '</a> '; |
940
|
|
|
$icon .= "<a href='main.php?op=delete&lid=" . $lid . "' title='" . _AM_WFL_ICO_DELETE . "'>" . $imageArray['deleteimg'] . '</a> '; |
941
|
|
|
$icon .= "<a href='altcat.php?op=main&cid=" . $cid . '&lid=' . $lid . '&title=' . $wfmyts->htmlSpecialCharsStrip(trim($published['title'])) . "' title='" . _AM_WFL_ALTCAT_CREATEF . "'>" . $imageArray['altcat'] . '</a> '; |
942
|
|
|
$icon .= '<a href="http://whois.domaintools.com/' . $hwhoisurl . '" target="_blank"><img src="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/assets/images/icon/domaintools.png" alt="WHOIS" title="WHOIS" align="absmiddle"></a>'; |
943
|
|
|
|
944
|
|
|
echo " |
945
|
|
|
<tr class='txtcenter;'>\n |
946
|
|
|
<td class='head'><small>" . $lid . "</small></td>\n |
947
|
|
|
<td class='even' style='text-align: left;'><small>" . $title . "</small></td>\n |
948
|
|
|
<td class='even' style='text-align: left;'><small>" . $cattitle . "</small></td>\n |
949
|
|
|
<td class='even'><small>" . $submitter . "</small></td>\n |
950
|
|
|
<td class='even'><small>" . $publish . "</small></td>\n |
951
|
|
|
<td class='even'><small>" . $expires . "</small></td>\n |
952
|
|
|
<td class='even' width='4%'>" . $published_status . "</td>\n |
953
|
|
|
<td class='even' style='text-align: center; width: 6%; white-space: nowrap;'>$icon</td>\n |
954
|
|
|
</tr>\n |
955
|
|
|
"; |
956
|
|
|
unset($published); |
957
|
|
|
} |
958
|
|
|
|
959
|
|
|
/** |
960
|
|
|
* @param $catt |
961
|
|
|
* |
962
|
|
|
* @return mixed |
963
|
|
|
*/ |
964
|
|
|
public static function getCategoryTitle($catt) |
965
|
|
|
{ |
966
|
|
|
global $xoopsDB; |
|
|
|
|
967
|
|
|
$sql = 'SELECT title FROM ' . $xoopsDB->prefix('wflinks_cat') . ' WHERE cid=' . $catt; |
968
|
|
|
$result = $xoopsDB->query($sql); |
969
|
|
|
$result = $xoopsDB->fetchArray($result); |
970
|
|
|
|
971
|
|
|
return $result['title']; |
972
|
|
|
} |
973
|
|
|
|
974
|
|
|
public static function getLinkListFooter() |
975
|
|
|
{ |
976
|
|
|
echo "<tr class='txtcenter;'>\n<td class='head' colspan='7'>" . _AM_WFL_MINDEX_NOLINKSFOUND . "</td>\n</tr>\n"; |
977
|
|
|
} |
978
|
|
|
|
979
|
|
|
/** |
980
|
|
|
* @param $pubrowamount |
981
|
|
|
* @param $start |
982
|
|
|
* @param string $art |
983
|
|
|
* @param string $_this |
984
|
|
|
* |
985
|
|
|
* @return null |
|
|
|
|
986
|
|
|
*/ |
987
|
|
View Code Duplication |
public static function getLinkListPageNav($pubrowamount, $start, $art = 'art', $_this = '') |
|
|
|
|
988
|
|
|
{ |
989
|
|
|
global $xoopsModuleConfig; |
|
|
|
|
990
|
|
|
echo "</table>\n"; |
991
|
|
|
if ($pubrowamount < $xoopsModuleConfig['admin_perpage']) { |
992
|
|
|
return false; |
993
|
|
|
} |
994
|
|
|
// Display Page Nav if published is > total display pages amount. |
995
|
|
|
require_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
996
|
|
|
// $page = ( $pubrowamount > $xoopsModuleConfig['admin_perpage'] ) ? _AM_WFL_MINDEX_PAGE : ''; |
|
|
|
|
997
|
|
|
$pagenav = new XoopsPageNav($pubrowamount, $xoopsModuleConfig['admin_perpage'], $start, 'st' . $art, $_this); |
998
|
|
|
echo '<div align="right" style="padding: 8px;">' . $pagenav->renderNav() . '</div>'; |
999
|
|
|
|
1000
|
|
|
return null; |
1001
|
|
|
} |
1002
|
|
|
|
1003
|
|
|
/** |
1004
|
|
|
* @param $pubrowamount |
1005
|
|
|
* @param $start |
1006
|
|
|
* @param string $art |
1007
|
|
|
* @param string $_this |
1008
|
|
|
* |
1009
|
|
|
* @return null |
|
|
|
|
1010
|
|
|
*/ |
1011
|
|
View Code Duplication |
public static function getLinkListPageNavLeft($pubrowamount, $start, $art = 'art', $_this = '') |
|
|
|
|
1012
|
|
|
{ |
1013
|
|
|
global $xoopsModuleConfig; |
|
|
|
|
1014
|
|
|
// echo "</table>\n"; |
1015
|
|
|
if ($pubrowamount < $xoopsModuleConfig['admin_perpage']) { |
1016
|
|
|
return false; |
1017
|
|
|
} |
1018
|
|
|
// Display Page Nav if published is > total display pages amount. |
1019
|
|
|
require_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
1020
|
|
|
// $page = ( $pubrowamount > $xoopsModuleConfig['admin_perpage'] ) ? _AM_WFL_MINDEX_PAGE : ''; |
|
|
|
|
1021
|
|
|
$pagenav = new XoopsPageNav($pubrowamount, $xoopsModuleConfig['admin_perpage'], $start, 'st' . $art, $_this); |
1022
|
|
|
echo '<div align="left" style="padding: 8px;">' . $pagenav->renderNav() . '</div>'; |
1023
|
|
|
|
1024
|
|
|
return null; |
1025
|
|
|
} |
1026
|
|
|
|
1027
|
|
|
// Retreive an editor according to the module's option "form_options" |
1028
|
|
|
|
1029
|
|
|
/** |
1030
|
|
|
* @param $caption |
1031
|
|
|
* @param $name |
1032
|
|
|
* @param $value |
1033
|
|
|
* |
1034
|
|
|
* @return bool|\XoopsFormDhtmlTextArea|\XoopsFormEditor|\XoopsFormFckeditor|\XoopsFormHtmlarea|\XoopsFormTextArea |
|
|
|
|
1035
|
|
|
*/ |
1036
|
|
|
public static function getWysiwygForm($caption, $name, $value) |
1037
|
|
|
{ |
1038
|
|
|
global $xoopsModuleConfig, $xoopsUser, $xoopsModule; |
|
|
|
|
1039
|
|
|
|
1040
|
|
|
$editor = false; |
1041
|
|
|
$x22 = false; |
1042
|
|
|
$xv = str_replace('XOOPS ', '', XOOPS_VERSION); |
1043
|
|
|
if (substr($xv, 2, 1) == '2') { |
1044
|
|
|
$x22 = true; |
1045
|
|
|
} |
1046
|
|
|
$editor_configs = []; |
1047
|
|
|
$editor_configs['name'] = $name; |
1048
|
|
|
$editor_configs['value'] = $value; |
1049
|
|
|
$editor_configs['rows'] = 35; |
1050
|
|
|
$editor_configs['cols'] = 60; |
1051
|
|
|
$editor_configs['width'] = '100%'; |
1052
|
|
|
$editor_configs['height'] = '400px'; |
1053
|
|
|
|
1054
|
|
|
$isadmin = ((is_object($xoopsUser) && !empty($xoopsUser)) |
1055
|
|
|
&& $xoopsUser->isAdmin($xoopsModule->mid())); |
1056
|
|
|
if ($isadmin === true) { |
1057
|
|
|
$formuser = $xoopsModuleConfig['form_options']; |
1058
|
|
|
} else { |
1059
|
|
|
$formuser = $xoopsModuleConfig['form_optionsuser']; |
1060
|
|
|
} |
1061
|
|
|
|
1062
|
|
|
switch ($formuser) { |
1063
|
|
|
case 'fck': |
1064
|
|
|
if (!$x22) { |
1065
|
|
|
if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/fckeditor/formfckeditor.php')) { |
1066
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopseditor/fckeditor/formfckeditor.php'; |
1067
|
|
|
$editor = new XoopsFormFckeditor($editor_configs, true); |
1068
|
|
|
} else { |
1069
|
|
|
if ($dhtml) { |
|
|
|
|
1070
|
|
|
$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60); |
1071
|
|
|
} else { |
1072
|
|
|
$editor = new XoopsFormTextArea($caption, $name, $value, 7, 60); |
1073
|
|
|
} |
1074
|
|
|
} |
1075
|
|
|
} else { |
1076
|
|
|
$editor = new XoopsFormEditor($caption, 'fckeditor', $editor_configs); |
1077
|
|
|
} |
1078
|
|
|
break; |
1079
|
|
|
|
1080
|
|
|
case 'htmlarea': |
1081
|
|
|
if (!$x22) { |
1082
|
|
|
if (is_readable(XOOPS_ROOT_PATH . '/class/htmlarea/formhtmlarea.php')) { |
1083
|
|
|
require_once XOOPS_ROOT_PATH . '/class/htmlarea/formhtmlarea.php'; |
1084
|
|
|
$editor = new XoopsFormHtmlarea($caption, $name, $value); |
1085
|
|
|
} |
1086
|
|
|
} else { |
1087
|
|
|
$editor = new XoopsFormEditor($caption, 'htmlarea', $editor_configs); |
1088
|
|
|
} |
1089
|
|
|
break; |
1090
|
|
|
|
1091
|
|
|
case 'dhtml': |
1092
|
|
|
if (!$x22) { |
1093
|
|
|
$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60); |
1094
|
|
|
} else { |
1095
|
|
|
$editor = new XoopsFormEditor($caption, 'dhtmltextarea', $editor_configs); |
1096
|
|
|
} |
1097
|
|
|
break; |
1098
|
|
|
|
1099
|
|
|
case 'textarea': |
1100
|
|
|
$editor = new XoopsFormTextArea($caption, $name, $value); |
1101
|
|
|
break; |
1102
|
|
|
|
1103
|
|
|
case 'koivi': |
1104
|
|
|
if (!$x22) { |
1105
|
|
|
if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/koivi/formwysiwygtextarea.php')) { |
1106
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopseditor/koivi/formwysiwygtextarea.php'; |
1107
|
|
|
$editor = new XoopsFormWysiwygTextArea($caption, $name, $value, '100%', '400px'); |
1108
|
|
|
} else { |
1109
|
|
|
if ($dhtml) { |
1110
|
|
|
$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60); |
1111
|
|
|
} else { |
1112
|
|
|
$editor = new XoopsFormTextArea($caption, $name, $value, 7, 60); |
1113
|
|
|
} |
1114
|
|
|
} |
1115
|
|
|
} else { |
1116
|
|
|
$editor = new XoopsFormEditor($caption, 'koivi', $editor_configs); |
1117
|
|
|
} |
1118
|
|
|
break; |
1119
|
|
|
|
1120
|
|
|
case 'tinyeditor': |
1121
|
|
|
if (!$x22) { |
1122
|
|
|
if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/tinyeditor/formtinyeditortextarea.php')) { |
1123
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopseditor/tinyeditor/formtinyeditortextarea.php'; |
1124
|
|
|
$editor = new XoopsFormTinyeditorTextArea([ |
1125
|
|
|
'caption' => $caption, |
1126
|
|
|
'name' => $name, |
1127
|
|
|
'value' => $value, |
1128
|
|
|
'width' => '100%', |
1129
|
|
|
'height' => '400px' |
1130
|
|
|
]); |
1131
|
|
|
} else { |
1132
|
|
|
if ($dhtml) { |
1133
|
|
|
$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 50, 60); |
1134
|
|
|
} else { |
1135
|
|
|
$editor = new XoopsFormTextArea($caption, $name, $value, 7, 60); |
1136
|
|
|
} |
1137
|
|
|
} |
1138
|
|
|
} else { |
1139
|
|
|
$editor = new XoopsFormEditor($caption, 'tinyeditor', $editor_configs); |
1140
|
|
|
} |
1141
|
|
|
break; |
1142
|
|
|
|
1143
|
|
|
case 'dhtmlext': |
1144
|
|
|
if (!$x22) { |
1145
|
|
|
if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/dhtmlext/dhtmlext.php')) { |
1146
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopseditor/dhtmlext/dhtmlext.php'; |
1147
|
|
|
$editor = new XoopsFormDhtmlTextAreaExtended($caption, $name, $value, 10, 50); |
1148
|
|
|
} else { |
1149
|
|
|
if ($dhtml) { |
1150
|
|
|
$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 50, 60); |
1151
|
|
|
} else { |
1152
|
|
|
$editor = new XoopsFormTextArea($caption, $name, $value, 7, 60); |
1153
|
|
|
} |
1154
|
|
|
} |
1155
|
|
|
} else { |
1156
|
|
|
$editor = new XoopsFormEditor($caption, 'dhtmlext', $editor_configs); |
1157
|
|
|
} |
1158
|
|
|
break; |
1159
|
|
|
|
1160
|
|
|
case 'tinymce': |
1161
|
|
|
if (!$x22) { |
1162
|
|
|
if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/tinymce/formtinymce.php')) { |
1163
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopseditor/tinymce/formtinymce.php'; |
1164
|
|
|
$editor = new XoopsFormTinymce([ |
1165
|
|
|
'caption' => $caption, |
1166
|
|
|
'name' => $name, |
1167
|
|
|
'value' => $value, |
1168
|
|
|
'width' => '100%', |
1169
|
|
|
'height' => '400px' |
1170
|
|
|
]); |
1171
|
|
|
} elseif (is_readable(XOOPS_ROOT_PATH . '/editors/tinymce/formtinymce.php')) { |
1172
|
|
|
require_once XOOPS_ROOT_PATH . '/editors/tinymce/formtinymce.php'; |
1173
|
|
|
$editor = new XoopsFormTinymce([ |
1174
|
|
|
'caption' => $caption, |
1175
|
|
|
'name' => $name, |
1176
|
|
|
'value' => $value, |
1177
|
|
|
'width' => '100%', |
1178
|
|
|
'height' => '400px' |
1179
|
|
|
]); |
1180
|
|
|
} else { |
1181
|
|
|
if ($dhtml) { |
1182
|
|
|
$editor = new XoopsFormDhtmlTextArea($caption, $name, $value, 20, 60); |
1183
|
|
|
} else { |
1184
|
|
|
$editor = new XoopsFormTextArea($caption, $name, $value, 7, 60); |
1185
|
|
|
} |
1186
|
|
|
} |
1187
|
|
|
} else { |
1188
|
|
|
$editor = new XoopsFormEditor($caption, 'tinymce', $editor_configs); |
1189
|
|
|
} |
1190
|
|
|
break; |
1191
|
|
|
} |
1192
|
|
|
|
1193
|
|
|
return $editor; |
1194
|
|
|
} |
1195
|
|
|
|
1196
|
|
|
/** |
1197
|
|
|
* @param $countryn |
1198
|
|
|
* |
1199
|
|
|
* @return mixed |
1200
|
|
|
*/ |
1201
|
|
|
public static function getCountryName($countryn) |
1202
|
|
|
{ |
1203
|
|
|
$country_array = [ |
1204
|
|
|
'' => 'Unknown', |
1205
|
|
|
'-' => 'Unknown', |
1206
|
|
|
'AD' => 'Andorra', |
1207
|
|
|
'AE' => 'United Arab Emirates', |
1208
|
|
|
'AF' => 'Afghanistan', |
1209
|
|
|
'AG' => 'Antigua and Barbuda', |
1210
|
|
|
'AI' => 'Anguilla', |
1211
|
|
|
'AL' => 'Albania', |
1212
|
|
|
'AM' => 'Armenia', |
1213
|
|
|
'AN' => 'Netherlands Antilles', |
1214
|
|
|
'AO' => 'Angola', |
1215
|
|
|
'AQ' => 'Antarctica', |
1216
|
|
|
'AR' => 'Argentina', |
1217
|
|
|
'AS' => 'American Samoa', |
1218
|
|
|
'AT' => 'Austria', |
1219
|
|
|
'AU' => 'Australia', |
1220
|
|
|
'AW' => 'Aruba', |
1221
|
|
|
'AX' => 'Åland Islands', // Added |
1222
|
|
|
'AZ' => 'Azerbaijan', |
1223
|
|
|
'BA' => 'Bosnia and Herzegovina', |
1224
|
|
|
'BB' => 'Barbados', |
1225
|
|
|
'BD' => 'Bangladesh', |
1226
|
|
|
'BE' => 'Belgium', |
1227
|
|
|
'BF' => 'Burkina Faso', |
1228
|
|
|
'BG' => 'Bulgaria', |
1229
|
|
|
'BH' => 'Bahrain', |
1230
|
|
|
'BI' => 'Burundi', |
1231
|
|
|
'BJ' => 'Benin', |
1232
|
|
|
'BL' => 'Saint Barthélemy', // Added |
1233
|
|
|
'BM' => 'Bermuda', |
1234
|
|
|
'BN' => 'Brunei Darussalam', |
1235
|
|
|
'BO' => 'Bolivia', |
1236
|
|
|
'BR' => 'Brazil', |
1237
|
|
|
'BS' => 'Bahamas', |
1238
|
|
|
'BT' => 'Bhutan', |
1239
|
|
|
'BV' => 'Bouvet Island', |
1240
|
|
|
'BW' => 'Botswana', |
1241
|
|
|
'BY' => 'Belarus', |
1242
|
|
|
'BZ' => 'Belize', |
1243
|
|
|
'CA' => 'Canada', |
1244
|
|
|
'CC' => 'Cocos (Keeling) Islands', |
1245
|
|
|
'CD' => 'Congo (Dem. Rep.)', // Added |
1246
|
|
|
'CF' => 'Central African Republic', |
1247
|
|
|
'CG' => 'Congo', |
1248
|
|
|
'CH' => 'Switzerland', |
1249
|
|
|
'CI' => "Cote D'Ivoire", // Removed: (Ivory Coast) |
1250
|
|
|
'CK' => 'Cook Islands', |
1251
|
|
|
'CL' => 'Chile', |
1252
|
|
|
'CM' => 'Cameroon', |
1253
|
|
|
'CN' => 'China', |
1254
|
|
|
'CO' => 'Colombia', |
1255
|
|
|
'CR' => 'Costa Rica', |
1256
|
|
|
'CS' => 'Czechoslovakia (former)', // Not listed anymore |
1257
|
|
|
'CU' => 'Cuba', |
1258
|
|
|
'CV' => 'Cape Verde', |
1259
|
|
|
'CX' => 'Christmas Island', |
1260
|
|
|
'CY' => 'Cyprus', |
1261
|
|
|
'CZ' => 'Czech Republic', |
1262
|
|
|
'DE' => 'Germany', |
1263
|
|
|
'DJ' => 'Djibouti', |
1264
|
|
|
'DK' => 'Denmark', |
1265
|
|
|
'DM' => 'Dominica', |
1266
|
|
|
'DO' => 'Dominican Republic', |
1267
|
|
|
'DZ' => 'Algeria', |
1268
|
|
|
'EC' => 'Ecuador', |
1269
|
|
|
'EE' => 'Estonia', |
1270
|
|
|
'EG' => 'Egypt', |
1271
|
|
|
'EH' => 'Western Sahara', |
1272
|
|
|
'ER' => 'Eritrea', |
1273
|
|
|
'ES' => 'Spain', |
1274
|
|
|
'EU' => 'Europe', |
1275
|
|
|
'ET' => 'Ethiopia', |
1276
|
|
|
'FI' => 'Finland', |
1277
|
|
|
'FJ' => 'Fiji', |
1278
|
|
|
'FK' => 'Falkland Islands (Malvinas)', |
1279
|
|
|
'FM' => 'Micronesia', |
1280
|
|
|
'FO' => 'Faroe Islands', |
1281
|
|
|
'FR' => 'France', |
1282
|
|
|
'FX' => 'France, Metropolitan', // Not listed anymore |
1283
|
|
|
'GA' => 'Gabon', |
1284
|
|
|
'GB' => 'Great Britain', // Name was: Great Britain (UK) |
1285
|
|
|
'GD' => 'Grenada', |
1286
|
|
|
'GE' => 'Georgia', |
1287
|
|
|
'GF' => 'French Guiana', |
1288
|
|
|
'GG' => 'Guernsey', // Added |
1289
|
|
|
'GH' => 'Ghana', |
1290
|
|
|
'GI' => 'Gibraltar', |
1291
|
|
|
'GL' => 'Greenland', |
1292
|
|
|
'GM' => 'Gambia', |
1293
|
|
|
'GN' => 'Guinea', |
1294
|
|
|
'GP' => 'Guadeloupe', |
1295
|
|
|
'GQ' => 'Equatorial Guinea', |
1296
|
|
|
'GR' => 'Greece', |
1297
|
|
|
'GS' => 'S. Georgia and S. Sandwich Isls.', |
1298
|
|
|
'GT' => 'Guatemala', |
1299
|
|
|
'GU' => 'Guam', |
1300
|
|
|
'GW' => 'Guinea-Bissau', |
1301
|
|
|
'GY' => 'Guyana', |
1302
|
|
|
'HK' => 'Hong Kong', |
1303
|
|
|
'HM' => 'Heard and McDonald Islands', |
1304
|
|
|
'HN' => 'Honduras', |
1305
|
|
|
'HR' => 'Croatia', |
1306
|
|
|
'HT' => 'Haiti', |
1307
|
|
|
'HU' => 'Hungary', |
1308
|
|
|
'ID' => 'Indonesia', |
1309
|
|
|
'IE' => 'Ireland', |
1310
|
|
|
'IL' => 'Israel', |
1311
|
|
|
'IM' => 'Isle of Man', // Added |
1312
|
|
|
'IN' => 'India', |
1313
|
|
|
'IO' => 'British Indian Ocean Territory', |
1314
|
|
|
'IQ' => 'Iraq', |
1315
|
|
|
'IR' => 'Iran', // Changed name |
1316
|
|
|
'IS' => 'Iceland', |
1317
|
|
|
'IT' => 'Italy', |
1318
|
|
|
'JE' => 'Jersey', |
1319
|
|
|
'JM' => 'Jamaica', |
1320
|
|
|
'JO' => 'Jordan', |
1321
|
|
|
'JP' => 'Japan', |
1322
|
|
|
'KE' => 'Kenya', |
1323
|
|
|
'KG' => 'Kyrgyzstan', |
1324
|
|
|
'KH' => 'Cambodia', |
1325
|
|
|
'KI' => 'Kiribati', |
1326
|
|
|
'KM' => 'Comoros', |
1327
|
|
|
'KN' => 'Saint Kitts and Nevis', |
1328
|
|
|
'KP' => 'Korea (North)', // Official name: Korea, Democratic People's Republic of |
1329
|
|
|
'KR' => 'Korea (South)', // Official name: Korea, Republic of |
1330
|
|
|
'KW' => 'Kuwait', |
1331
|
|
|
'KY' => 'Cayman Islands', |
1332
|
|
|
'KZ' => 'Kazakhstan', |
1333
|
|
|
'LA' => 'Laos', // Official name: Lao People's Democratic Republic |
1334
|
|
|
'LB' => 'Lebanon', |
1335
|
|
|
'LC' => 'Saint Lucia', |
1336
|
|
|
'LI' => 'Liechtenstein', |
1337
|
|
|
'LK' => 'Sri Lanka', |
1338
|
|
|
'LR' => 'Liberia', |
1339
|
|
|
'LS' => 'Lesotho', |
1340
|
|
|
'LT' => 'Lithuania', |
1341
|
|
|
'LU' => 'Luxembourg', |
1342
|
|
|
'LV' => 'Latvia', |
1343
|
|
|
'LY' => 'Libya', // Official name: Libyan Arab Jamahiriya |
1344
|
|
|
'MA' => 'Morocco', |
1345
|
|
|
'MC' => 'Monaco', |
1346
|
|
|
'MD' => 'Moldova', // Official name: Moldova, Republic of |
1347
|
|
|
'ME' => 'Montenegro', // Added |
1348
|
|
|
'MF' => 'Saint Martin', // Added |
1349
|
|
|
'MG' => 'Madagascar', |
1350
|
|
|
'MH' => 'Marshall Islands', |
1351
|
|
|
'MK' => 'Macedonia', // Official name: Macedonia, The Former Yugoslav Republic of |
1352
|
|
|
'ML' => 'Mali', |
1353
|
|
|
'MM' => 'Myanmar', |
1354
|
|
|
'MN' => 'Mongolia', |
1355
|
|
|
'MO' => 'Macao', // Corrected name |
1356
|
|
|
'MP' => 'Northern Mariana Islands', |
1357
|
|
|
'MQ' => 'Martinique', |
1358
|
|
|
'MR' => 'Mauritania', |
1359
|
|
|
'MS' => 'Montserrat', |
1360
|
|
|
'MT' => 'Malta', |
1361
|
|
|
'MU' => 'Mauritius', |
1362
|
|
|
'MV' => 'Maldives', |
1363
|
|
|
'MW' => 'Malawi', |
1364
|
|
|
'MX' => 'Mexico', |
1365
|
|
|
'MY' => 'Malaysia', |
1366
|
|
|
'MZ' => 'Mozambique', |
1367
|
|
|
'NA' => 'Namibia', |
1368
|
|
|
'NC' => 'New Caledonia', |
1369
|
|
|
'NE' => 'Niger', |
1370
|
|
|
'NF' => 'Norfolk Island', |
1371
|
|
|
'NG' => 'Nigeria', |
1372
|
|
|
'NI' => 'Nicaragua', |
1373
|
|
|
'NL' => 'Netherlands', |
1374
|
|
|
'NO' => 'Norway', |
1375
|
|
|
'NP' => 'Nepal', |
1376
|
|
|
'NR' => 'Nauru', |
1377
|
|
|
'NT' => 'Neutral Zone', |
1378
|
|
|
'NU' => 'Niue', |
1379
|
|
|
'NZ' => 'New Zealand', |
1380
|
|
|
'OM' => 'Oman', |
1381
|
|
|
'PA' => 'Panama', |
1382
|
|
|
'PE' => 'Peru', |
1383
|
|
|
'PF' => 'French Polynesia', |
1384
|
|
|
'PG' => 'Papua New Guinea', |
1385
|
|
|
'PH' => 'Philippines', |
1386
|
|
|
'PK' => 'Pakistan', |
1387
|
|
|
'PL' => 'Poland', |
1388
|
|
|
'PM' => 'St. Pierre and Miquelon', |
1389
|
|
|
'PN' => 'Pitcairn', |
1390
|
|
|
'PR' => 'Puerto Rico', |
1391
|
|
|
'PS' => 'Palestinian Territory, Occupied', // Added |
1392
|
|
|
'PT' => 'Portugal', |
1393
|
|
|
'PW' => 'Palau', |
1394
|
|
|
'PY' => 'Paraguay', |
1395
|
|
|
'QA' => 'Qatar', |
1396
|
|
|
'RE' => 'Reunion', |
1397
|
|
|
'RO' => 'Romania', |
1398
|
|
|
'RS' => 'Serbia', // Added |
1399
|
|
|
'RU' => 'Russian Federation', |
1400
|
|
|
'RW' => 'Rwanda', |
1401
|
|
|
'SA' => 'Saudi Arabia', |
1402
|
|
|
'SB' => 'Solomon Islands', |
1403
|
|
|
'SC' => 'Seychelles', |
1404
|
|
|
'SD' => 'Sudan', |
1405
|
|
|
'SE' => 'Sweden', |
1406
|
|
|
'SG' => 'Singapore', |
1407
|
|
|
'SH' => 'St. Helena', |
1408
|
|
|
'SI' => 'Slovenia', |
1409
|
|
|
'SJ' => 'Svalbard and Jan Mayen Islands', |
1410
|
|
|
'SK' => 'Slovakia', // Changed name, was: Slovak Republic |
1411
|
|
|
'SL' => 'Sierra Leone', |
1412
|
|
|
'SM' => 'San Marino', |
1413
|
|
|
'SN' => 'Senegal', |
1414
|
|
|
'SO' => 'Somalia', |
1415
|
|
|
'SR' => 'Suriname', |
1416
|
|
|
'ST' => 'Sao Tome and Principe', |
1417
|
|
|
'SU' => 'USSR (former)', // Removed from ISO list, doesn' exsist anymore |
1418
|
|
|
'SV' => 'El Salvador', |
1419
|
|
|
'SY' => 'Syrian Arab Republic', // Changed name, was: Syria |
1420
|
|
|
'SZ' => 'Swaziland', |
1421
|
|
|
'TC' => 'Turks and Caicos Islands', |
1422
|
|
|
'TD' => 'Chad', |
1423
|
|
|
'TF' => 'French Southern Territories', |
1424
|
|
|
'TG' => 'Togo', |
1425
|
|
|
'TH' => 'Thailand', |
1426
|
|
|
'TJ' => 'Tajikistan', |
1427
|
|
|
'TK' => 'Tokelau', |
1428
|
|
|
'TL' => 'Timor-Leste', // Added |
1429
|
|
|
'TM' => 'Turkmenistan', |
1430
|
|
|
'TN' => 'Tunisia', |
1431
|
|
|
'TO' => 'Tonga', |
1432
|
|
|
'TP' => 'East Timor', // Removed from ISO list, doesn' exsist anymore |
1433
|
|
|
'TR' => 'Turkey', |
1434
|
|
|
'TT' => 'Trinidad and Tobago', |
1435
|
|
|
'TV' => 'Tuvalu', |
1436
|
|
|
'TW' => 'Taiwan', // Official name acc. to iso-list: Taiwan, Province of China |
1437
|
|
|
'TZ' => 'Tanzania', |
1438
|
|
|
'UA' => 'Ukraine', |
1439
|
|
|
'UG' => 'Uganda', |
1440
|
|
|
'UK' => 'United Kingdom', // Doesn't exsist in iso-list ? |
1441
|
|
|
'UM' => 'US Minor Outlying Islands', |
1442
|
|
|
'US' => 'United States', |
1443
|
|
|
'UY' => 'Uruguay', |
1444
|
|
|
'UZ' => 'Uzbekistan', |
1445
|
|
|
'VA' => 'Vatican City State', |
1446
|
|
|
'VC' => 'Saint Vincent and the Grenadines', |
1447
|
|
|
'VE' => 'Venezuela', |
1448
|
|
|
'VG' => 'Virgin Islands, British', |
1449
|
|
|
'VI' => 'Virgin Islands, U.S.', |
1450
|
|
|
'VN' => 'Viet Nam', |
1451
|
|
|
'VU' => 'Vanuatu', |
1452
|
|
|
'WF' => 'Wallis and Futuna Islands', |
1453
|
|
|
'WS' => 'Samoa', |
1454
|
|
|
'YE' => 'Yemen', |
1455
|
|
|
'YT' => 'Mayotte', |
1456
|
|
|
'YU' => 'Yugoslavia', // Removed from iso list |
1457
|
|
|
'ZA' => 'South Africa', |
1458
|
|
|
'ZM' => 'Zambia', |
1459
|
|
|
'ZR' => 'Zaire', // Removed from iso list |
1460
|
|
|
'ZW' => 'Zimbabwe' |
1461
|
|
|
]; |
1462
|
|
|
|
1463
|
|
|
return $country_array[$countryn]; |
1464
|
|
|
} |
1465
|
|
|
|
1466
|
|
|
/** |
1467
|
|
|
* @param $document |
1468
|
|
|
* |
1469
|
|
|
* @return mixed |
1470
|
|
|
*/ |
1471
|
|
|
public static function convertHtml2text($document) |
1472
|
|
|
{ |
1473
|
|
|
$search = [ |
1474
|
|
|
"'<script[^>]*?>.*?</script>'si", // Strip out javascript |
1475
|
|
|
"'<img.*?>'si", // Strip out img tags |
1476
|
|
|
"'<[\/\!]*?[^<>]*?>'si", // Strip out HTML tags |
1477
|
|
|
"'([\r\n])[\s]+'", // Strip out white space |
1478
|
|
|
"'&(quot|#34);'i", // Replace HTML entities |
1479
|
|
|
"'&(amp|#38);'i", |
1480
|
|
|
"'&(lt|#60);'i", |
1481
|
|
|
"'&(gt|#62);'i", |
1482
|
|
|
"'&(nbsp|#160);'i", |
1483
|
|
|
"'&(iexcl|#161);'i", |
1484
|
|
|
"'&(cent|#162);'i", |
1485
|
|
|
"'&(pound|#163);'i", |
1486
|
|
|
"'&(copy|#169);'i" |
1487
|
|
|
]; // evaluate as php |
1488
|
|
|
|
1489
|
|
|
$replace = [ |
1490
|
|
|
'', |
1491
|
|
|
'', |
1492
|
|
|
'', |
1493
|
|
|
"\\1", |
1494
|
|
|
'"', |
1495
|
|
|
'&', |
1496
|
|
|
'<', |
1497
|
|
|
'>', |
1498
|
|
|
' ', |
1499
|
|
|
chr(161), |
1500
|
|
|
chr(162), |
1501
|
|
|
chr(163), |
1502
|
|
|
chr(169), |
1503
|
|
|
]; |
1504
|
|
|
|
1505
|
|
|
$text = preg_replace($search, $replace, $document); |
1506
|
|
|
|
1507
|
|
|
preg_replace_callback('/&#(\d+);/', function ($matches) { |
1508
|
|
|
return chr($matches[1]); |
1509
|
|
|
}, $document); |
1510
|
|
|
|
1511
|
|
|
return $text; |
1512
|
|
|
} |
1513
|
|
|
|
1514
|
|
|
// Start functions for Google PageRank |
1515
|
|
|
// Source: http://www.sws-tech.com/scripts/googlepagerank.php |
1516
|
|
|
// This code is released under the public domain |
1517
|
|
|
/** |
1518
|
|
|
* @param $a |
1519
|
|
|
* @param $b |
1520
|
|
|
* |
1521
|
|
|
* @return float|int |
1522
|
|
|
*/ |
1523
|
|
|
public static function fillZeroes($a, $b) |
1524
|
|
|
{ |
1525
|
|
|
$z = hexdec(80000000); |
1526
|
|
|
//echo $z; |
1527
|
|
|
if ($z & $a) { |
1528
|
|
|
$a >>= 1; |
1529
|
|
|
$a &= (~$z); |
1530
|
|
|
$a |= 0x40000000; |
1531
|
|
|
$a >>= ($b - 1); |
1532
|
|
|
} else { |
1533
|
|
|
$a >>= $b; |
1534
|
|
|
} |
1535
|
|
|
|
1536
|
|
|
return $a; |
1537
|
|
|
} |
1538
|
|
|
|
1539
|
|
|
/** |
1540
|
|
|
* @param $a |
1541
|
|
|
* @param $b |
1542
|
|
|
* @param $c |
1543
|
|
|
* |
1544
|
|
|
* @return array |
1545
|
|
|
*/ |
1546
|
|
|
public static function mix($a, $b, $c) |
1547
|
|
|
{ |
1548
|
|
|
$a -= $b; |
1549
|
|
|
$a -= $c; |
1550
|
|
|
$a ^= static::fillZeroes($c, 13); |
1551
|
|
|
$b -= $c; |
1552
|
|
|
$b -= $a; |
1553
|
|
|
$b ^= ($a << 8); |
1554
|
|
|
$c -= $a; |
1555
|
|
|
$c -= $b; |
1556
|
|
|
$c ^= static::fillZeroes($b, 13); |
1557
|
|
|
$a -= $b; |
1558
|
|
|
$a -= $c; |
1559
|
|
|
$a ^= static::fillZeroes($c, 12); |
1560
|
|
|
$b -= $c; |
1561
|
|
|
$b -= $a; |
1562
|
|
|
$b ^= ($a << 16); |
1563
|
|
|
$c -= $a; |
1564
|
|
|
$c -= $b; |
1565
|
|
|
$c ^= static::fillZeroes($b, 5); |
1566
|
|
|
$a -= $b; |
1567
|
|
|
$a -= $c; |
1568
|
|
|
$a ^= static::fillZeroes($c, 3); |
1569
|
|
|
$b -= $c; |
1570
|
|
|
$b -= $a; |
1571
|
|
|
$b ^= ($a << 10); |
1572
|
|
|
$c -= $a; |
1573
|
|
|
$c -= $b; |
1574
|
|
|
$c ^= static::fillZeroes($b, 15); |
1575
|
|
|
|
1576
|
|
|
return [$a, $b, $c]; |
1577
|
|
|
} |
1578
|
|
|
|
1579
|
|
|
/** |
1580
|
|
|
* @param $url |
1581
|
|
|
* @param null $length |
1582
|
|
|
* @param int $init |
1583
|
|
|
* |
1584
|
|
|
* @return mixed |
1585
|
|
|
*/ |
1586
|
|
|
public static function googleCh($url, $length = null, $init = 0xE6359A60) |
1587
|
|
|
{ |
1588
|
|
|
if (null === $length) { |
1589
|
|
|
$length = count($url); |
1590
|
|
|
} |
1591
|
|
|
$a = $b = 0x9E3779B9; |
1592
|
|
|
$c = $init; |
1593
|
|
|
$k = 0; |
1594
|
|
|
$len = $length; |
1595
|
|
|
while ($len >= 12) { |
1596
|
|
|
$a += ($url[$k + 0] + ($url[$k + 1] << 8) + ($url[$k + 2] << 16) + ($url[$k + 3] << 24)); |
1597
|
|
|
$b += ($url[$k + 4] + ($url[$k + 5] << 8) + ($url[$k + 6] << 16) + ($url[$k + 7] << 24)); |
1598
|
|
|
$c += ($url[$k + 8] + ($url[$k + 9] << 8) + ($url[$k + 10] << 16) + ($url[$k + 11] << 24)); |
1599
|
|
|
$mix = static::mix($a, $b, $c); |
1600
|
|
|
$a = $mix[0]; |
1601
|
|
|
$b = $mix[1]; |
1602
|
|
|
$c = $mix[2]; |
1603
|
|
|
$k += 12; |
1604
|
|
|
$len -= 12; |
1605
|
|
|
} |
1606
|
|
|
$c += $length; |
1607
|
|
|
switch ($len) { /* all the case statements fall through */ |
1608
|
|
|
case 11: |
1609
|
|
|
$c += ($url[$k + 10] << 24); |
1610
|
|
|
// no break |
1611
|
|
|
case 10: |
1612
|
|
|
$c += ($url[$k + 9] << 16); |
1613
|
|
|
// no break |
1614
|
|
|
case 9: |
1615
|
|
|
$c += ($url[$k + 8] << 8); |
1616
|
|
|
/* the first byte of c is reserved for the length */ |
1617
|
|
|
// no break |
1618
|
|
|
case 8: |
1619
|
|
|
$b += ($url[$k + 7] << 24); |
1620
|
|
|
// no break |
1621
|
|
|
case 7: |
1622
|
|
|
$b += ($url[$k + 6] << 16); |
1623
|
|
|
// no break |
1624
|
|
|
case 6: |
1625
|
|
|
$b += ($url[$k + 5] << 8); |
1626
|
|
|
// no break |
1627
|
|
|
case 5: |
1628
|
|
|
$b += $url[$k + 4]; |
1629
|
|
|
// no break |
1630
|
|
|
case 4: |
1631
|
|
|
$a += ($url[$k + 3] << 24); |
1632
|
|
|
// no break |
1633
|
|
|
case 3: |
1634
|
|
|
$a += ($url[$k + 2] << 16); |
1635
|
|
|
// no break |
1636
|
|
|
case 2: |
1637
|
|
|
$a += ($url[$k + 1] << 8); |
1638
|
|
|
// no break |
1639
|
|
|
case 1: |
1640
|
|
|
$a += $url[$k + 0]; |
1641
|
|
|
/* case 0: nothing left to add */ |
1642
|
|
|
} |
1643
|
|
|
$mix = static::mix($a, $b, $c); |
1644
|
|
|
//echo $mix[0]; |
|
|
|
|
1645
|
|
|
/*-------------------------------------------- report the result */ |
1646
|
|
|
|
1647
|
|
|
return $mix[2]; |
1648
|
|
|
} |
1649
|
|
|
|
1650
|
|
|
//converts a string into an array of integers containing the numeric value of the char |
1651
|
|
|
|
1652
|
|
|
/** |
1653
|
|
|
* @param $string |
1654
|
|
|
* |
1655
|
|
|
* @return mixed |
1656
|
|
|
*/ |
1657
|
|
|
public static function strord($string) |
1658
|
|
|
{ |
1659
|
|
|
for ($i = 0, $iMax = strlen($string); $i < $iMax; ++$i) { |
1660
|
|
|
$result[$i] = ord($string{$i}); |
|
|
|
|
1661
|
|
|
} |
1662
|
|
|
|
1663
|
|
|
return $result; |
|
|
|
|
1664
|
|
|
} |
1665
|
|
|
|
1666
|
|
|
/** |
1667
|
|
|
* @param $url |
1668
|
|
|
* |
1669
|
|
|
* @return bool|string |
1670
|
|
|
*/ |
1671
|
|
|
public static function pagerank($url) |
1672
|
|
|
{ |
1673
|
|
|
$pagerank = ''; |
1674
|
|
|
$ch = '6' . static::googleCh(static::strord('info:' . $url)); |
1675
|
|
|
$fp = fsockopen('www.google.com', 80, $errno, $errstr, 30); |
1676
|
|
|
if (!$fp) { |
1677
|
|
|
echo "$errstr ($errno)<br>\n"; |
1678
|
|
|
} else { |
1679
|
|
|
$out = 'GET /search?client=navclient-auto&ch=' . $ch . '&features=Rank&q=info:' . $url . " HTTP/1.1\r\n"; |
1680
|
|
|
$out .= "Host: www.google.com\r\n"; |
1681
|
|
|
$out .= "Connection: Close\r\n\r\n"; |
1682
|
|
|
|
1683
|
|
|
fwrite($fp, $out); |
1684
|
|
|
|
1685
|
|
|
while (!feof($fp)) { |
1686
|
|
|
$data = fgets($fp, 128); |
1687
|
|
|
$pos = strpos($data, 'Rank_'); |
1688
|
|
|
if ($pos === false) { |
|
|
|
|
1689
|
|
|
} else { |
1690
|
|
|
$pagerank = substr($data, $pos + 9); |
1691
|
|
|
} |
1692
|
|
|
} |
1693
|
|
|
fclose($fp); |
1694
|
|
|
} |
1695
|
|
|
|
1696
|
|
|
return $pagerank; |
1697
|
|
|
} |
1698
|
|
|
|
1699
|
|
|
// End functions for Google PageRank |
1700
|
|
|
|
1701
|
|
|
// Check if Tag module is installed |
1702
|
|
|
/** |
1703
|
|
|
* @return bool |
|
|
|
|
1704
|
|
|
*/ |
1705
|
|
View Code Duplication |
public static function isTagModuleIncluded() |
|
|
|
|
1706
|
|
|
{ |
1707
|
|
|
static $wfl_tag_module_included; |
1708
|
|
|
if (!isset($wfl_tag_module_included)) { |
1709
|
|
|
$modulesHandler = xoops_getHandler('module'); |
1710
|
|
|
$tag_mod = $modulesHandler->getByDirName('tag'); |
1711
|
|
|
if (!$tag_mod) { |
1712
|
|
|
$tag_mod = false; |
|
|
|
|
1713
|
|
|
} else { |
1714
|
|
|
$wfl_tag_module_included = $tag_mod->getVar('isactive') == 1; |
1715
|
|
|
} |
1716
|
|
|
} |
1717
|
|
|
|
1718
|
|
|
return $wfl_tag_module_included; |
1719
|
|
|
} |
1720
|
|
|
|
1721
|
|
|
// Add item_tag to Tag-module |
1722
|
|
|
|
1723
|
|
|
/** |
1724
|
|
|
* @param $lid |
1725
|
|
|
* @param $item_tag |
1726
|
|
|
*/ |
1727
|
|
|
public static function updateTag($lid, $item_tag) |
1728
|
|
|
{ |
1729
|
|
|
global $xoopsModule; |
|
|
|
|
1730
|
|
|
if (static::isTagModuleIncluded()) { |
1731
|
|
|
require_once XOOPS_ROOT_PATH . '/modules/tag/include/formtag.php'; |
1732
|
|
|
$tagHandler = xoops_getModuleHandler('tag', 'tag'); |
1733
|
|
|
$tagHandler->updateByItem($item_tag, $lid, $xoopsModule->getVar('dirname'), 0); |
1734
|
|
|
} |
1735
|
|
|
} |
1736
|
|
|
|
1737
|
|
|
// Check if News module is installed |
1738
|
|
|
|
1739
|
|
|
/** |
1740
|
|
|
* @return bool |
|
|
|
|
1741
|
|
|
*/ |
1742
|
|
View Code Duplication |
public static function isNewsModuleIncluded() |
|
|
|
|
1743
|
|
|
{ |
1744
|
|
|
static $wfl_news_module_included; |
1745
|
|
|
if (!isset($wfl_news_module_included)) { |
1746
|
|
|
$modulesHandler = xoops_getHandler('module'); |
1747
|
|
|
$news_mod = $modulesHandler->getByDirName('news'); |
1748
|
|
|
if (!$news_mod) { |
1749
|
|
|
$news_mod = false; |
|
|
|
|
1750
|
|
|
} else { |
1751
|
|
|
$wfl_news_module_included = $news_mod->getVar('isactive') == 1; |
1752
|
|
|
} |
1753
|
|
|
} |
1754
|
|
|
|
1755
|
|
|
return $wfl_news_module_included; |
1756
|
|
|
} |
1757
|
|
|
|
1758
|
|
|
/** |
1759
|
|
|
* @param $banner_id |
1760
|
|
|
* |
1761
|
|
|
* @return null|string |
1762
|
|
|
*/ |
1763
|
|
View Code Duplication |
public static function getBannerFromIdBanner($banner_id) |
|
|
|
|
1764
|
|
|
{ |
1765
|
|
|
###### Hack by www.stefanosilvestrini.com ###### |
1766
|
|
|
global $xoopsConfig; |
|
|
|
|
1767
|
|
|
$db = XoopsDatabaseFactory::getDatabaseConnection(); |
1768
|
|
|
$bresult = $db->query('SELECT COUNT(*) FROM ' . $db->prefix('banner') . ' WHERE bid=' . $banner_id); |
1769
|
|
|
list($numrows) = $db->fetchRow($bresult); |
1770
|
|
|
if ($numrows > 1) { |
1771
|
|
|
--$numrows; |
1772
|
|
|
mt_srand((double)microtime() * 1000000); |
1773
|
|
|
$bannum = mt_rand(0, $numrows); |
1774
|
|
|
} else { |
1775
|
|
|
$bannum = 0; |
1776
|
|
|
} |
1777
|
|
|
if ($numrows > 0) { |
1778
|
|
|
$bresult = $db->query('SELECT * FROM ' . $db->prefix('banner') . ' WHERE bid=' . $banner_id, 1, $bannum); |
1779
|
|
|
list($bid, $cid, $imptotal, $impmade, $clicks, $imageurl, $clickurl, $date, $htmlbanner, $htmlcode) = $db->fetchRow($bresult); |
|
|
|
|
1780
|
|
|
if ($xoopsConfig['my_ip'] == xoops_getenv('REMOTE_ADDR')) { |
|
|
|
|
1781
|
|
|
// EMPTY |
1782
|
|
|
} else { |
1783
|
|
|
$db->queryF(sprintf('UPDATE %s SET impmade = impmade+1 WHERE bid = %u', $db->prefix('banner'), $bid)); |
1784
|
|
|
} |
1785
|
|
|
/* Check if this impression is the last one and print the banner */ |
1786
|
|
|
if ($imptotal == $impmade) { |
1787
|
|
|
$newid = $db->genId($db->prefix('bannerfinish') . '_bid_seq'); |
1788
|
|
|
$sql = sprintf('INSERT INTO %s (bid, cid, impressions, clicks, datestart, dateend) VALUES (%u, %u, %u, %u, %u, %u)', $db->prefix('bannerfinish'), $newid, $cid, $impmade, $clicks, $date, time()); |
1789
|
|
|
$db->queryF($sql); |
1790
|
|
|
$db->queryF(sprintf('DELETE FROM %s WHERE bid = %u', $db->prefix('banner'), $bid)); |
1791
|
|
|
} |
1792
|
|
|
if ($htmlbanner) { |
1793
|
|
|
$bannerobject = $htmlcode; |
1794
|
|
|
} else { |
1795
|
|
|
$bannerobject = '<div align="center"><a href="' . XOOPS_URL . '/banners.php?op=click&bid=' . $bid . '" target="_blank">'; |
1796
|
|
|
if (stristr($imageurl, '.swf')) { |
1797
|
|
|
$bannerobject = $bannerobject |
1798
|
|
|
. '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="468" height="60">' |
1799
|
|
|
. '<param name="movie" value="' |
1800
|
|
|
. $imageurl |
1801
|
|
|
. '"></param>' |
1802
|
|
|
. '<param name="quality" value="high"></param>' |
1803
|
|
|
. '<embed src="' |
1804
|
|
|
. $imageurl |
1805
|
|
|
. '" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="468" height="60">' |
1806
|
|
|
. '</embed>' |
1807
|
|
|
. '</object>'; |
1808
|
|
|
} else { |
1809
|
|
|
$bannerobject = $bannerobject . '<img src="' . $imageurl . '" alt="">'; |
1810
|
|
|
} |
1811
|
|
|
$bannerobject .= '</a></div>'; |
1812
|
|
|
} |
1813
|
|
|
|
1814
|
|
|
return $bannerobject; |
1815
|
|
|
} |
1816
|
|
|
|
1817
|
|
|
return null; |
1818
|
|
|
} |
1819
|
|
|
|
1820
|
|
|
/** |
1821
|
|
|
* @param $client_id |
1822
|
|
|
* |
1823
|
|
|
* @return string |
1824
|
|
|
*/ |
1825
|
|
View Code Duplication |
public static function getBannerFromIdClient($client_id) |
|
|
|
|
1826
|
|
|
{ |
1827
|
|
|
###### Hack by www.stefanosilvestrini.com ###### |
1828
|
|
|
global $xoopsConfig; |
|
|
|
|
1829
|
|
|
$db = XoopsDatabaseFactory::getDatabaseConnection(); |
1830
|
|
|
$bresult = $db->query('SELECT COUNT(*) FROM ' . $db->prefix('banner') . ' WHERE cid=' . $client_id); |
1831
|
|
|
list($numrows) = $db->fetchRow($bresult); |
1832
|
|
|
if ($numrows > 1) { |
1833
|
|
|
--$numrows; |
1834
|
|
|
mt_srand((double)microtime() * 1000000); |
1835
|
|
|
$bannum = mt_rand(0, $numrows); |
1836
|
|
|
} else { |
1837
|
|
|
$bannum = 0; |
1838
|
|
|
} |
1839
|
|
|
if ($numrows > 0) { |
1840
|
|
|
$bresult = $db->query('SELECT * FROM ' . $db->prefix('banner') . ' WHERE cid=' . $client_id . ' ORDER BY rand()', 1, $bannum); |
1841
|
|
|
list($bid, $cid, $imptotal, $impmade, $clicks, $imageurl, $clickurl, $date, $htmlbanner, $htmlcode) = $db->fetchRow($bresult); |
|
|
|
|
1842
|
|
|
if ($xoopsConfig['my_ip'] == xoops_getenv('REMOTE_ADDR')) { |
|
|
|
|
1843
|
|
|
// EMPTY |
1844
|
|
|
} else { |
1845
|
|
|
$db->queryF(sprintf('UPDATE %s SET impmade = impmade+1 WHERE bid = %u', $db->prefix('banner'), $bid)); |
1846
|
|
|
} |
1847
|
|
|
/* Check if this impression is the last one and print the banner */ |
1848
|
|
|
if ($imptotal == $impmade) { |
1849
|
|
|
$newid = $db->genId($db->prefix('bannerfinish') . '_bid_seq'); |
1850
|
|
|
$sql = sprintf('INSERT INTO %s (bid, cid, impressions, clicks, datestart, dateend) VALUES (%u, %u, %u, %u, %u, %u)', $db->prefix('bannerfinish'), $newid, $cid, $impmade, $clicks, $date, time()); |
1851
|
|
|
$db->queryF($sql); |
1852
|
|
|
$db->queryF(sprintf('DELETE FROM %s WHERE bid = %u', $db->prefix('banner'), $bid)); |
1853
|
|
|
} |
1854
|
|
|
if ($htmlbanner) { |
1855
|
|
|
$bannerobject = $htmlcode; |
1856
|
|
|
} else { |
1857
|
|
|
$bannerobject = '<div align="center"><a href="' . XOOPS_URL . '/banners.php?op=click&bid=' . $bid . '" target="_blank">'; |
1858
|
|
|
if (stristr($imageurl, '.swf')) { |
1859
|
|
|
$bannerobject = $bannerobject |
1860
|
|
|
. '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" width="468" height="60">' |
1861
|
|
|
. '<param name="movie" value="' |
1862
|
|
|
. $imageurl |
1863
|
|
|
. '"></param>' |
1864
|
|
|
. '<param name="quality" value="high"></param>' |
1865
|
|
|
. '<embed src="' |
1866
|
|
|
. $imageurl |
1867
|
|
|
. '" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="468" height="60">' |
1868
|
|
|
. '</embed>' |
1869
|
|
|
. '</object>'; |
1870
|
|
|
} else { |
1871
|
|
|
$bannerobject = $bannerobject . '<img src="' . $imageurl . '" alt="">'; |
1872
|
|
|
} |
1873
|
|
|
$bannerobject .= '</a></div>'; |
1874
|
|
|
} |
1875
|
|
|
|
1876
|
|
|
return $bannerobject; |
1877
|
|
|
} |
1878
|
|
|
|
1879
|
|
|
return null; |
1880
|
|
|
} |
1881
|
|
|
|
1882
|
|
|
/** |
1883
|
|
|
* @param $email |
1884
|
|
|
* |
1885
|
|
|
* @return mixed |
1886
|
|
|
*/ |
1887
|
|
View Code Duplication |
public function convertEmail($email) |
|
|
|
|
1888
|
|
|
{ |
1889
|
|
|
$search = [ |
1890
|
|
|
"/\@/", |
1891
|
|
|
"/\./", |
1892
|
|
|
"/\mailto:/", |
1893
|
|
|
]; |
1894
|
|
|
|
1895
|
|
|
$replace = [ |
1896
|
|
|
' AT ', |
1897
|
|
|
' DOT ', |
1898
|
|
|
'', |
1899
|
|
|
]; |
1900
|
|
|
|
1901
|
|
|
$text = preg_replace($search, $replace, $email); |
1902
|
|
|
|
1903
|
|
|
return $text; |
1904
|
|
|
} |
1905
|
|
|
|
1906
|
|
|
/** |
1907
|
|
|
* @param $email |
1908
|
|
|
* |
1909
|
|
|
* @return mixed |
1910
|
|
|
*/ |
1911
|
|
View Code Duplication |
public function printemailcnvrt($email) |
|
|
|
|
1912
|
|
|
{ |
1913
|
|
|
$search = [ |
1914
|
|
|
"/\ AT /", |
1915
|
|
|
"/\ DOT /", |
1916
|
|
|
]; |
1917
|
|
|
|
1918
|
|
|
$replace = [ |
1919
|
|
|
'@', |
1920
|
|
|
'.', |
1921
|
|
|
]; |
1922
|
|
|
|
1923
|
|
|
$text = preg_replace($search, $replace, $email); |
1924
|
|
|
|
1925
|
|
|
return $text; |
1926
|
|
|
} |
1927
|
|
|
|
1928
|
|
|
/** |
1929
|
|
|
* @param $str |
1930
|
|
|
* @param $start |
1931
|
|
|
* @param $length |
1932
|
|
|
* @param string $trimmarker |
1933
|
|
|
* |
1934
|
|
|
* @return string |
1935
|
|
|
*/ |
1936
|
|
|
public static function getSubstring($str, $start, $length, $trimmarker = '...') |
1937
|
|
|
{ |
1938
|
|
|
$configHandler = xoops_getHandler('config'); |
1939
|
|
|
$im_multilanguageConfig = $configHandler->getConfigsByCat(IM_CONF_MULILANGUAGE); |
1940
|
|
|
|
1941
|
|
|
if ($im_multilanguageConfig['ml_enable']) { |
1942
|
|
|
$tags = explode(',', $im_multilanguageConfig['ml_tags']); |
1943
|
|
|
$strs = []; |
1944
|
|
|
$hasML = false; |
1945
|
|
|
foreach ($tags as $tag) { |
1946
|
|
|
if (preg_match("/\[" . $tag . "](.*)\[\/" . $tag . "\]/sU", $str, $matches)) { |
1947
|
|
|
if (count($matches) > 0) { |
1948
|
|
|
$hasML = true; |
1949
|
|
|
$strs[] = $matches[1]; |
1950
|
|
|
} |
1951
|
|
|
} |
1952
|
|
|
} |
1953
|
|
|
} else { |
1954
|
|
|
$hasML = false; |
1955
|
|
|
} |
1956
|
|
|
|
1957
|
|
|
if (!$hasML) { |
1958
|
|
|
$strs = [$str]; |
1959
|
|
|
} |
1960
|
|
|
|
1961
|
|
|
for ($i = 0; $i <= count($strs) - 1; ++$i) { |
|
|
|
|
1962
|
|
|
if (!XOOPS_USE_MULTIBYTES) { |
1963
|
|
|
$strs[$i] = (strlen($strs[$i]) - $start <= $length) ? substr($strs[$i], $start, $length) : substr($strs[$i], $start, $length - strlen($trimmarker)) . $trimmarker; |
1964
|
|
|
} |
1965
|
|
|
|
1966
|
|
|
if (function_exists('mb_internal_encoding') && @mb_internal_encoding(_CHARSET)) { |
1967
|
|
|
$str2 = mb_strcut($strs[$i], $start, $length - strlen($trimmarker)); |
1968
|
|
|
$strs[$i] = $str2 . (mb_strlen($strs[$i]) != mb_strlen($str2) ? $trimmarker : ''); |
1969
|
|
|
} |
1970
|
|
|
|
1971
|
|
|
// phppp patch |
1972
|
|
|
$DEP_CHAR = 127; |
|
|
|
|
1973
|
|
|
$pos_st = 0; |
1974
|
|
|
$action = false; |
1975
|
|
|
for ($pos_i = 0, $pos_iMax = strlen($strs[$i]); $pos_i < $pos_iMax; ++$pos_i) { |
1976
|
|
|
if (ord(substr($strs[$i], $pos_i, 1)) > 127) { |
1977
|
|
|
++$pos_i; |
1978
|
|
|
} |
1979
|
|
|
if ($pos_i <= $start) { |
1980
|
|
|
$pos_st = $pos_i; |
1981
|
|
|
} |
1982
|
|
|
if ($pos_i >= $pos_st + $length) { |
1983
|
|
|
$action = true; |
1984
|
|
|
break; |
1985
|
|
|
} |
1986
|
|
|
} |
1987
|
|
|
$strs[$i] = $action ? substr($strs[$i], $pos_st, $pos_i - $pos_st - strlen($trimmarker)) . $trimmarker : $strs[$i]; |
1988
|
|
|
|
1989
|
|
|
$strs[$i] = $hasML ? '[' . $tags[$i] . ']' . $strs[$i] . '[/' . $tags[$i] . ']' : $strs[$i]; |
|
|
|
|
1990
|
|
|
} |
1991
|
|
|
$str = implode('', $strs); |
1992
|
|
|
|
1993
|
|
|
return $str; |
1994
|
|
|
} |
1995
|
|
|
// Reusable Link Sorting Functions |
1996
|
|
|
// convertOrderByIn() |
1997
|
|
|
// @param $orderby |
1998
|
|
|
// @return |
1999
|
|
|
/** |
2000
|
|
|
* @param $orderby |
2001
|
|
|
* |
2002
|
|
|
* @return string |
2003
|
|
|
*/ |
2004
|
|
|
public static function convertOrderByIn($orderby) |
2005
|
|
|
{ |
2006
|
|
|
switch (trim($orderby)) { |
2007
|
|
|
case 'titleA': |
2008
|
|
|
$orderby = 'title ASC'; |
2009
|
|
|
break; |
2010
|
|
|
case 'dateA': |
2011
|
|
|
$orderby = 'published ASC'; |
2012
|
|
|
break; |
2013
|
|
|
case 'hitsA': |
2014
|
|
|
$orderby = 'hits ASC'; |
2015
|
|
|
break; |
2016
|
|
|
case 'ratingA': |
2017
|
|
|
$orderby = 'rating ASC'; |
2018
|
|
|
break; |
2019
|
|
|
case 'countryA': |
2020
|
|
|
$orderby = 'country ASC'; |
2021
|
|
|
break; |
2022
|
|
|
case 'titleD': |
2023
|
|
|
$orderby = 'title DESC'; |
2024
|
|
|
break; |
2025
|
|
|
case 'hitsD': |
2026
|
|
|
$orderby = 'hits DESC'; |
2027
|
|
|
break; |
2028
|
|
|
case 'ratingD': |
2029
|
|
|
$orderby = 'rating DESC'; |
2030
|
|
|
break; |
2031
|
|
|
case'dateD': |
|
|
|
|
2032
|
|
|
$orderby = 'published DESC'; |
2033
|
|
|
break; |
2034
|
|
|
case 'countryD': |
2035
|
|
|
$orderby = 'country DESC'; |
2036
|
|
|
break; |
2037
|
|
|
} |
2038
|
|
|
|
2039
|
|
|
return $orderby; |
2040
|
|
|
} |
2041
|
|
|
|
2042
|
|
|
/** |
2043
|
|
|
* @param $orderby |
2044
|
|
|
* |
2045
|
|
|
* @return string |
2046
|
|
|
*/ |
2047
|
|
|
public static function convertOrderByTrans($orderby) |
2048
|
|
|
{ |
2049
|
|
|
if ($orderby === 'hits ASC') { |
2050
|
|
|
$orderbyTrans = _MD_WFL_POPULARITYLTOM; |
2051
|
|
|
} |
2052
|
|
|
if ($orderby === 'hits DESC') { |
2053
|
|
|
$orderbyTrans = _MD_WFL_POPULARITYMTOL; |
2054
|
|
|
} |
2055
|
|
|
if ($orderby === 'title ASC') { |
2056
|
|
|
$orderbyTrans = _MD_WFL_TITLEATOZ; |
2057
|
|
|
} |
2058
|
|
|
if ($orderby === 'title DESC') { |
2059
|
|
|
$orderbyTrans = _MD_WFL_TITLEZTOA; |
2060
|
|
|
} |
2061
|
|
|
if ($orderby === 'published ASC') { |
2062
|
|
|
$orderbyTrans = _MD_WFL_DATEOLD; |
2063
|
|
|
} |
2064
|
|
|
if ($orderby === 'published DESC') { |
2065
|
|
|
$orderbyTrans = _MD_WFL_DATENEW; |
2066
|
|
|
} |
2067
|
|
|
if ($orderby === 'rating ASC') { |
2068
|
|
|
$orderbyTrans = _MD_WFL_RATINGLTOH; |
2069
|
|
|
} |
2070
|
|
|
if ($orderby === 'rating DESC') { |
2071
|
|
|
$orderbyTrans = _MD_WFL_RATINGHTOL; |
2072
|
|
|
} |
2073
|
|
|
if ($orderby === 'country ASC') { |
2074
|
|
|
$orderbyTrans = _MD_WFL_COUNTRYLTOH; |
2075
|
|
|
} |
2076
|
|
|
if ($orderby === 'country DESC') { |
2077
|
|
|
$orderbyTrans = _MD_WFL_COUNTRYHTOL; |
2078
|
|
|
} |
2079
|
|
|
|
2080
|
|
|
return $orderbyTrans; |
|
|
|
|
2081
|
|
|
} |
2082
|
|
|
|
2083
|
|
|
/** |
2084
|
|
|
* @param $orderby |
2085
|
|
|
* |
2086
|
|
|
* @return string |
2087
|
|
|
*/ |
2088
|
|
|
|
2089
|
|
|
public static function convertOrderByOut($orderby) |
2090
|
|
|
{ |
2091
|
|
|
if ($orderby === 'title ASC') { |
2092
|
|
|
$orderby = 'titleA'; |
2093
|
|
|
} |
2094
|
|
|
if ($orderby === 'published ASC') { |
2095
|
|
|
$orderby = 'dateA'; |
2096
|
|
|
} |
2097
|
|
|
if ($orderby === 'hits ASC') { |
2098
|
|
|
$orderby = 'hitsA'; |
2099
|
|
|
} |
2100
|
|
|
if ($orderby === 'rating ASC') { |
2101
|
|
|
$orderby = 'ratingA'; |
2102
|
|
|
} |
2103
|
|
|
if ($orderby === 'country ASC') { |
2104
|
|
|
$orderby = 'countryA'; |
2105
|
|
|
} |
2106
|
|
|
if ($orderby === 'weight ASC') { |
2107
|
|
|
$orderby = 'weightA'; |
2108
|
|
|
} |
2109
|
|
|
if ($orderby === 'title DESC') { |
2110
|
|
|
$orderby = 'titleD'; |
2111
|
|
|
} |
2112
|
|
|
if ($orderby === 'published DESC') { |
2113
|
|
|
$orderby = 'dateD'; |
2114
|
|
|
} |
2115
|
|
|
if ($orderby === 'hits DESC') { |
2116
|
|
|
$orderby = 'hitsD'; |
2117
|
|
|
} |
2118
|
|
|
if ($orderby === 'rating DESC') { |
2119
|
|
|
$orderby = 'ratingD'; |
2120
|
|
|
} |
2121
|
|
|
if ($orderby === 'country DESC') { |
2122
|
|
|
$orderby = 'countryD'; |
2123
|
|
|
} |
2124
|
|
|
|
2125
|
|
|
return $orderby; |
2126
|
|
|
} |
2127
|
|
|
} |
2128
|
|
|
|
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.