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