1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Module: WF-links |
4
|
|
|
* Version: v1.0.3 |
5
|
|
|
* Release Date: 21 June 2005 |
6
|
|
|
* Developer: John N |
7
|
|
|
* Team: WF-Projects |
8
|
|
|
* Licence: GNU |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
use Xmf\Request; |
12
|
|
|
use XoopsModules\Wflinks; |
13
|
|
|
|
14
|
|
|
require_once __DIR__ . '/header.php'; |
15
|
|
|
|
16
|
|
|
$GLOBALS['xoopsOption']['template_main'] = 'wflinks_newlistindex.tpl'; |
17
|
|
|
require XOOPS_ROOT_PATH . '/header.php'; |
18
|
|
|
|
19
|
|
|
/** @var Wflinks\Helper $helper */ |
20
|
|
|
$helper = Wflinks\Helper::getInstance(); |
21
|
|
|
|
22
|
|
|
global $xoopsDB, $xoopsModule; |
23
|
|
|
|
24
|
|
|
$catarray['imageheader'] = Wflinks\Utility::getImageHeader(); |
25
|
|
|
//$catarray['letters'] = Wflinks\Utility::getLetters(); |
26
|
|
|
//$catarray['toolbar'] = Wflinks\Utility::getToolbar(); |
27
|
|
|
$xoopsTpl->assign('catarray', $catarray); |
28
|
|
|
|
29
|
|
|
if (Request::hasVar('newlinkshowdays', 'GET')) { |
30
|
|
|
$newlinkshowdays = Request::getInt('newlinkshowdays', 0, 'GET') ?: 7; |
31
|
|
|
if (7 != $newlinkshowdays) { |
32
|
|
|
if (14 != $newlinkshowdays) { |
33
|
|
|
if (30 != $newlinkshowdays) { |
34
|
|
|
redirect_header('newlist.php?newlinkshowdays=7', 5, _MD_WFL_STOPIT . '<br><img src="' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/assets/images/icon/security.png">'); |
35
|
|
|
} |
36
|
|
|
} |
37
|
|
|
} |
38
|
|
|
$time_cur = time(); |
39
|
|
|
$duration = ($time_cur - (86400 * 30)); |
40
|
|
|
$duration_week = ($time_cur - (86400 * 7)); |
41
|
|
|
$allmonthlinks = 0; |
42
|
|
|
$allweeklinks = 0; |
43
|
|
|
$result = $xoopsDB->query('SELECT lid, cid, published, updated FROM ' . $xoopsDB->prefix('wflinks_links') . ' WHERE (published >= ' . $duration . ' AND published <= ' . $time_cur . ') OR updated >= ' . $duration . ' AND (expired = 0 OR expired > ' . $time_cur . ') AND offline = 0'); |
44
|
|
|
while (false !== ($myrow = $xoopsDB->fetchArray($result))) { |
45
|
|
|
$published = ($myrow['updated'] > 0) ? $myrow['updated'] : $myrow['published']; |
46
|
|
|
++$allmonthlinks; |
47
|
|
|
if ($published > $duration_week) { |
48
|
|
|
++$allweeklinks; |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
$xoopsTpl->assign('allweeklinks', $allweeklinks); |
52
|
|
|
$xoopsTpl->assign('allmonthlinks', $allmonthlinks); |
53
|
|
|
|
54
|
|
|
// List Last VARIABLE Days of links |
55
|
|
|
$newlinkshowdays = $_GET['newlinkshowdays'] ?? 7; |
56
|
|
|
$xoopsTpl->assign('newlinkshowdays', (int)$newlinkshowdays); |
57
|
|
|
|
58
|
|
|
$dailylinks = []; |
59
|
|
|
for ($i = 0; $i < $newlinkshowdays; ++$i) { |
60
|
|
|
$key = $newlinkshowdays - $i - 1; |
61
|
|
|
$time = $time_cur - (86400 * $key); |
62
|
|
|
$dailylinks[$key]['newlinkdayRaw'] = $time; |
63
|
|
|
$dailylinks[$key]['newlinkView'] = formatTimestamp($time, $helper->getConfig('dateformat')); |
64
|
|
|
$dailylinks[$key]['totallinks'] = 0; |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
$duration = ($time_cur - (86400 * ((int)$newlinkshowdays - 1))); |
69
|
|
|
$result = $xoopsDB->query( |
70
|
|
|
'SELECT lid, cid, published, updated FROM ' . $xoopsDB->prefix('wflinks_links') . ' WHERE (published > ' . $duration . ' AND published <= ' . $time_cur . ') OR (updated >= ' . $duration . ' AND updated <= ' . $time_cur . ') AND (expired = 0 OR expired > ' . $time_cur . ') AND offline = 0' |
71
|
|
|
); |
72
|
|
|
while (false !== ($myrow = $xoopsDB->fetchArray($result))) { |
73
|
|
|
$published = ($myrow['updated'] > 0) ? $myrow['updated'] : $myrow['published']; |
74
|
|
|
$d = date('j', $published); |
75
|
|
|
$m = date('m', $published); |
76
|
|
|
$y = date('Y', $published); |
77
|
|
|
$key = (int)(($time_cur - mktime(0, 0, 0, $m, $d, $y)) / 86400); |
|
|
|
|
78
|
|
|
$dailylinks[$key]['totallinks']++; |
79
|
|
|
} |
80
|
|
|
ksort($dailylinks); |
81
|
|
|
reset($dailylinks); |
82
|
|
|
$xoopsTpl->assign('dailylinks', $dailylinks); |
83
|
|
|
unset($dailylinks); |
84
|
|
|
|
85
|
|
|
$mytree = new Wflinks\Tree($xoopsDB->prefix('wflinks_cat'), 'cid', 'pid'); |
86
|
|
|
$sql = 'SELECT * FROM ' . $xoopsDB->prefix('wflinks_links'); |
87
|
|
|
$sql .= 'WHERE (published > 0 AND published <= ' . $time_cur . ') |
88
|
|
|
OR |
89
|
|
|
(updated > 0 AND updated <= ' . $time_cur . ') |
90
|
|
|
AND |
91
|
|
|
(expired = 0 OR expired > ' . $time_cur . ') |
92
|
|
|
AND |
93
|
|
|
offline = 0 |
94
|
|
|
ORDER BY ' . $helper->getConfig('linkxorder'); |
95
|
|
|
$result = $xoopsDB->query($sql, 10, 0); |
96
|
|
|
while (false !== ($link_arr = $xoopsDB->fetchArray($result))) { |
97
|
|
|
require XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/linkloadinfo.php'; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
// Screenshots display |
101
|
|
|
if ($helper->getConfig('screenshot')) { |
102
|
|
|
$xoopsTpl->assign('shots_dir', $helper->getConfig('screenshots')); |
103
|
|
|
$xoopsTpl->assign('shotwidth', $helper->getConfig('shotwidth')); |
104
|
|
|
$xoopsTpl->assign('shotheight', $helper->getConfig('shotheight')); |
105
|
|
|
$xoopsTpl->assign('show_screenshot', true); |
106
|
|
|
} |
107
|
|
|
$xoopsTpl->assign('module_dir', $xoopsModule->getVar('dirname')); |
108
|
|
|
require XOOPS_ROOT_PATH . '/footer.php'; |
109
|
|
|
|