Completed
Push — master ( 2b2520...e78a73 )
by Michael
01:45
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 = wfl_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']      = wfl_imageheader($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']     = wfl_letters();
41
$catarray['toolbar']     = wfl_toolbar();
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  = wfl_getTotalItems();
51
$total_cat = wfl_totalcategory();  // 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    = wfl_getTotalItems($myrow['cid'], 1);
59
    $indicator        = wfl_isnewimage($totallinkload['published']);
60
    if (wfl_checkgroups($myrow['cid'])) {
61
        $title = $wfmyts->htmlSpecialCharsStrip($myrow['title']);
62
63
        $arr = array();
64
        $arr = $mytree->getFirstChild($myrow['cid'], 'title');
65
66
        $space         = 1;
67
        $chcount       = 1;
68
        $subcategories = '';
69
        foreach ($arr as $ele) {
70
            if (true === wfl_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->do_thumb($xoopsModuleConfig['imagequality'], $xoopsModuleConfig['updatethumbs'], $xoopsModuleConfig['keepaspect']);
95
            }
96
        }
97
        if (empty($_image) || $_image === '') {
98
            $imgurl = $indicator['image'];
99
        } else {
100
            $imgurl = "{$xoopsModuleConfig['catimage']}/$_image";
101
        }
102
        // End
103
104
        $xoopsTpl->append('categories', array(
105
            'image'         => XOOPS_URL . "/$imgurl",
106
            'id'            => $myrow['cid'],
107
            'title'         => $title,
108
            'subcategories' => $subcategories,
109
            'totallinks'    => $totallinkload['count'],
110
            'count'         => $count,
111
            'alttext'       => $myrow['description']
112
        ));
113
        ++$count;
114
    }
115
}
116
switch ($total_cat) {
117
    case '1':
118
        $lang_thereare = _MD_WFL_THEREIS;
119
        break;
120
    default:
121
        $lang_thereare = _MD_WFL_THEREARE;
122
        break;
123
}
124
$xoopsTpl->assign('lang_thereare', sprintf($lang_thereare, $total_cat, $listings['count']));
125
$xoopsTpl->assign('module_dir', $xoopsModule->getVar('dirname'));
126
127
// Screenshots display
128
if (isset($xoopsModuleConfig['screenshot']) && $xoopsModuleConfig['screenshot'] == 1) {
129
    $xoopsTpl->assign('shots_dir', $xoopsModuleConfig['screenshots']);
130
    $xoopsTpl->assign('shotwidth', $xoopsModuleConfig['shotwidth']);
131
    $xoopsTpl->assign('shotheight', $xoopsModuleConfig['shotheight']);
132
    $xoopsTpl->assign('show_screenshot', true);
133
}
134
135
$time = time();
136
137
// Show Latest Listings on Index Page
138
$sql       = $xoopsDB->query('SELECT lastlinksyn, lastlinkstotal FROM ' . $xoopsDB->prefix('wflinks_indexpage'));
139
$lastlinks = $xoopsDB->fetchArray($sql);
140
141
if ($lastlinks['lastlinksyn'] == 1 && $lastlinks['lastlinkstotal'] > 0) {
142
    $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('wflinks_links') . ' WHERE published > 0
143
                                AND published <= ' . $time . '
144
                                AND (expired = 0 OR expired > ' . $time . ')
145
                                AND offline = 0
146
                                ORDER BY published DESC', 0, 0);
147
    list($count) = $xoopsDB->fetchRow($result);
148
149
    $count = (($count > $lastlinks['lastlinkstotal'])
150
              && ($lastlinks['lastlinkstotal'] != 0)) ? $lastlinks['lastlinkstotal'] : $count;
151
    $limit = (($start + $xoopsModuleConfig['perpage']) > $count) ? ($count - $start) : $xoopsModuleConfig['perpage'];
152
153
    $result = $xoopsDB->query('SELECT * FROM ' . $xoopsDB->prefix('wflinks_links') . ' WHERE published > 0
154
                                AND published <= ' . $time . '
155
                                AND (expired = 0 OR expired > ' . $time . ')
156
                                AND offline = 0
157
                                ORDER BY published DESC', $limit, $start);
158
    while ($link_arr = $xoopsDB->fetchArray($result)) {
159
        $res_type = 0;
160
        $moderate = 0;
161
        $cid      = $link_arr['cid'];
162
        require XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/linkloadinfo.php';
163
        $xoopsTpl->append('link', $link);
164
    }
165
166
    $pagenav = new XoopsPageNav($count, $xoopsModuleConfig['perpage'], $start, 'start');
167
    $xoopsTpl->assign('pagenav', $pagenav->renderNav());
168
169
    $xoopsTpl->assign('showlatest', $lastlinks['lastlinksyn']);
170
}
171
172
include XOOPS_ROOT_PATH . '/footer.php';
173