Completed
Push — master ( 1aa479...f472f3 )
by Michael
02:12
created

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 *
4
 * Module: WF-Links
5
 * Version: v1.0.3
6
 * Release Date: 21 June 2005
7
 * Developer: John N
8
 * Team: WF-Projects
9
 * Licence: GNU
10
 */
11
12
require_once __DIR__ . '/header.php';
13
14
$start = WflinksUtility::cleanRequestVars($_REQUEST, 'start', 0);
15
$start = (int)$start;
16
17
$GLOBALS['xoopsOption']['template_main'] = 'wflinks_index.tpl';
18
include XOOPS_ROOT_PATH . '/header.php';
19
20
global $xoopsModuleConfig;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
21
$mytree = new WflinksXoopsTree($xoopsDB->prefix('wflinks_cat'), 'cid', 'pid');
22
23
// Begin Main page Heading etc
24
$sql      = 'SELECT * FROM ' . $xoopsDB->prefix('wflinks_indexpage');
25
$head_arr = $xoopsDB->fetchArray($xoopsDB->query($sql));
26
27
$catarray['imageheader']      = WflinksUtility::getImageHeader($head_arr['indeximage'], $head_arr['indexheading']);
28
$catarray['indexheading']     = $wfmyts->displayTarea($head_arr['indexheading']);
29
$catarray['indexheaderalign'] = $wfmyts->htmlSpecialCharsStrip($head_arr['indexheaderalign']);
30
$catarray['indexfooteralign'] = $wfmyts->htmlSpecialCharsStrip($head_arr['indexfooteralign']);
31
32
$html   = $head_arr['nohtml'] ? 0 : 1;
33
$smiley = $head_arr['nosmiley'] ? 0 : 1;
34
$xcodes = $head_arr['noxcodes'] ? 0 : 1;
35
$images = $head_arr['noimages'] ? 0 : 1;
36
$breaks = $head_arr['nobreak'] ? 1 : 0;
37
38
$catarray['indexheader'] = $wfmyts->displayTarea($head_arr['indexheader'], $html, $smiley, $xcodes, $images, $breaks);
39
$catarray['indexfooter'] = $wfmyts->displayTarea($head_arr['indexfooter'], $html, $smiley, $xcodes, $images, $breaks);
40
$catarray['letters']     = WflinksUtility::getLetters();
41
$catarray['toolbar']     = WflinksUtility::getToolbar();
42
$xoopsTpl->assign('catarray', $catarray);
43
44
// End main page Headers
45
$count   = 1;
46
$chcount = 0;
47
$countin = 0;
48
49
// Begin Main page linkload info
50
$listings  = WflinksUtility::getTotalItems();
51
$total_cat = WflinksUtility::getTotalCategory();  // get total amount of categories
52
$catsort   = $xoopsModuleConfig['sortcats'];
53
$sql       = 'SELECT * FROM ' . $xoopsDB->prefix('wflinks_cat') . ' WHERE pid=0 ORDER BY ' . $catsort;
54
$result    = $xoopsDB->query($sql);
55
while ($myrow = $xoopsDB->fetchArray($result)) {
56
    ++$countin;
57
    $subtotallinkload = 0;
58
    $totallinkload    = WflinksUtility::getTotalItems($myrow['cid'], 1);
59
    $indicator        = WflinksUtility::isNewImage($totallinkload['published']);
60
    if (WflinksUtility::checkGroups($myrow['cid'])) {
61
        $title = $wfmyts->htmlSpecialCharsStrip($myrow['title']);
62
63
        $arr = [];
64
        $arr = $mytree->getFirstChild($myrow['cid'], 'title');
65
66
        $space         = 1;
67
        $chcount       = 1;
68
        $subcategories = '';
69
        foreach ($arr as $ele) {
70
            if (true === WflinksUtility::checkGroups($ele['cid'])) {
71
                if ($xoopsModuleConfig['subcats'] == 1) {
72
                    $chtitle = $wfmyts->htmlSpecialCharsStrip($ele['title']);
73
                    if ($chcount > 5) {
74
                        $subcategories .= '...';
75
                        break;
76
                    }
77
                    if ($space > 0) {
78
                        $subcategories .= "<a href='" . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/viewcat.php?cid=' . $ele['cid'] . "'>" . $chtitle . '</a><br>';
79
                    }
80
                    ++$space;
81
                    ++$chcount;
82
                }
83
            }
84
        }
85
86
        // This code is copyright WF-Projects
87
        // Using this code without our permission or removing this code voids the license agreement
88
        $_image = $myrow['imgurl'] ? urldecode($myrow['imgurl']) : '';
89
        if ($_image !== '' && $xoopsModuleConfig['usethumbs']) {
90
            $_thumb_image = new WfThumbsNails($_image, $xoopsModuleConfig['catimage'], 'thumbs');
91
            if ($_thumb_image) {
92
                $_thumb_image->setUseThumbs(1);
93
                $_thumb_image->setImageType('gd2');
94
                $_image = $_thumb_image->createThumb($xoopsModuleConfig['imagequality'], $xoopsModuleConfig['updatethumbs'], $xoopsModuleConfig['keepaspect']);
95
            }
96
        }
97
        $imgurl = "{$xoopsModuleConfig['catimage']}/$_image";
98
        if (empty($_image) || $_image === '') {
99
            $imgurl = $indicator['image'];
100
        }
101
        // End
102
103
        $xoopsTpl->append('categories', [
104
            'image'         => XOOPS_URL . "/$imgurl",
105
            'id'            => $myrow['cid'],
106
            'title'         => $title,
107
            'subcategories' => $subcategories,
108
            'totallinks'    => $totallinkload['count'],
109
            'count'         => $count,
110
            'alttext'       => $myrow['description']
111
        ]);
112
        ++$count;
113
    }
114
}
115
switch ($total_cat) {
116
    case '1':
117
        $lang_thereare = _MD_WFL_THEREIS;
118
        break;
119
    default:
120
        $lang_thereare = _MD_WFL_THEREARE;
121
        break;
122
}
123
$xoopsTpl->assign('lang_thereare', sprintf($lang_thereare, $total_cat, $listings['count']));
124
$xoopsTpl->assign('module_dir', $xoopsModule->getVar('dirname'));
125
126
// Screenshots display
127
if (isset($xoopsModuleConfig['screenshot']) && $xoopsModuleConfig['screenshot'] == 1) {
128
    $xoopsTpl->assign('shots_dir', $xoopsModuleConfig['screenshots']);
129
    $xoopsTpl->assign('shotwidth', $xoopsModuleConfig['shotwidth']);
130
    $xoopsTpl->assign('shotheight', $xoopsModuleConfig['shotheight']);
131
    $xoopsTpl->assign('show_screenshot', true);
132
}
133
134
$time = time();
135
136
// Show Latest Listings on Index Page
137
$sql       = $xoopsDB->query('SELECT lastlinksyn, lastlinkstotal FROM ' . $xoopsDB->prefix('wflinks_indexpage'));
138
$lastlinks = $xoopsDB->fetchArray($sql);
139
140
if ($lastlinks['lastlinksyn'] == 1 && $lastlinks['lastlinkstotal'] > 0) {
141
    $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('wflinks_links') . ' WHERE published > 0
142
                                AND published <= ' . $time . '
143
                                AND (expired = 0 OR expired > ' . $time . ')
144
                                AND offline = 0
145
                                ORDER BY published DESC', 0, 0);
146
    list($count) = $xoopsDB->fetchRow($result);
147
148
    $count = (($count > $lastlinks['lastlinkstotal'])
149
              && ($lastlinks['lastlinkstotal'] != 0)) ? $lastlinks['lastlinkstotal'] : $count;
150
    $limit = (($start + $xoopsModuleConfig['perpage']) > $count) ? ($count - $start) : $xoopsModuleConfig['perpage'];
151
152
    $result = $xoopsDB->query('SELECT * FROM ' . $xoopsDB->prefix('wflinks_links') . ' WHERE published > 0
153
                                AND published <= ' . $time . '
154
                                AND (expired = 0 OR expired > ' . $time . ')
155
                                AND offline = 0
156
                                ORDER BY published DESC', $limit, $start);
157
    while ($link_arr = $xoopsDB->fetchArray($result)) {
158
        $res_type = 0;
159
        $moderate = 0;
160
        $cid      = $link_arr['cid'];
161
        require XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/linkloadinfo.php';
162
        $xoopsTpl->append('link', $link);
163
    }
164
165
    $pagenav = new XoopsPageNav($count, $xoopsModuleConfig['perpage'], $start, 'start');
166
    $xoopsTpl->assign('pagenav', $pagenav->renderNav());
167
168
    $xoopsTpl->assign('showlatest', $lastlinks['lastlinksyn']);
169
}
170
171
include XOOPS_ROOT_PATH . '/footer.php';
172