Completed
Branch master (a25b3b)
by Michael
03:43 queued 01:22
created

index.php (22 issues)

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
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 47 and the first side effect is on line 23.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/*
3
-------------------------------------------------------------------------
4
                     ADSLIGHT 2 : Module for Xoops
5
6
        Redesigned and ameliorate By iluc user at www.frxoops.org
7
        Started with the Classifieds module and made MANY changes
8
        Website : http://www.limonads.com
9
        Contact : [email protected]
10
-------------------------------------------------------------------------
11
             Original credits below Version History
12
##########################################################################
13
#                    Classified Module for Xoops                         #
14
#  By John Mordo user jlm69 at www.xoops.org and www.jlmzone.com         #
15
#      Started with the MyAds module and made MANY changes               #
16
##########################################################################
17
 Original Author: Pascal Le Boustouller
18
 Author Website : [email protected]
19
 Licence Type   : GPL
20
-------------------------------------------------------------------------
21
*/
22
23
include_once __DIR__ . '/header.php';
24
require XOOPS_ROOT_PATH . '/modules/adslight/include/gtickets.php';
25
26
$myts      = MyTextSanitizer::getInstance();
27
$module_id = $xoopsModule->getVar('mid');
28
29
is_object($GLOBALS['xoopsUser']) ? $groups = $GLOBALS['xoopsUser']->getGroups() : $groups = XOOPS_GROUP_ANONYMOUS;
30
31
$gpermHandler = xoops_getHandler('groupperm');
32
33
isset($_POST['item_id']) ? $perm_itemid = (int)$_POST['item_id'] : $perm_itemid = 0;
34
35 View Code Duplication
if (!$gpermHandler->checkRight('adslight_view', $perm_itemid, $groups, $module_id)) {
1 ignored issue
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
36
    redirect_header(XOOPS_URL . '/index.php', 3, _NOPERM);
37
}
38
39
(!$gpermHandler->checkRight('adslight_premium', $perm_itemid, $groups, $module_id)) ? $prem_perm = '0' : $prem_perm = '1';
40
41
include XOOPS_ROOT_PATH . '/modules/adslight/class/classifiedstree.php';
42
//include XOOPS_ROOT_PATH . '/modules/adslight/class/utilities.php';
0 ignored issues
show
Unused Code Comprehensibility introduced by
38% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
43
$mytree = new ClassifiedsTree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid');
44
45
#  function index
46
#####################################################
47
function index()
1 ignored issue
show
index uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
The function index() has been defined more than once; this definition is ignored, only the first definition in admin/main.php (L29-287) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
48
{
49
    global $xoopsDB, $xoopsConfig, $xoopsModule, $xoopsTpl, $myts, $mytree, $meta, $mid, $moduleDirName, $main_lang, $prem_perm, $xoopsModule;
1 ignored issue
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...
50
    $pathIcon16 = $xoopsModule->getInfo('icons16');
51
52
    $GLOBALS['xoopsOption']['template_main'] = 'adslight_index.tpl';
53
54
    include XOOPS_ROOT_PATH . '/header.php';
55
56
    $xoopsTpl->assign('xmid', $xoopsModule->getVar('mid'));
57
    $xoopsTpl->assign('add_from', _ADSLIGHT_ADDFROM . ' ' . $xoopsConfig['sitename']);
58
    $xoopsTpl->assign('add_from_title', _ADSLIGHT_ADDFROM);
59
    $xoopsTpl->assign('add_from_sitename', $xoopsConfig['sitename']);
60
    $xoopsTpl->assign('only_pix', _ADSLIGHT_ONLYPIX);
61
    $xoopsTpl->assign('adslight_logolink', _ADSLIGHT_LOGOLINK);
62
    $xoopsTpl->assign('permit', $prem_perm);
63
64
    $xoopsTpl->assign('xoops_module_header', '<link rel="stylesheet" href="' . XOOPS_URL . '/modules/adslight/assets/css/adslight.css" type="text/css" media="all" />');
65
66
    $banner = xoops_getbanner();
67
    $xoopsTpl->assign('banner', $banner);
68
    $xoopsTpl->assign('use_extra_code', $GLOBALS['xoopsModuleConfig']['adslight_use_index_code']);
69
    $xoopsTpl->assign('adslight_use_banner', $GLOBALS['xoopsModuleConfig']['adslight_use_banner']);
70
    $xoopsTpl->assign('index_extra_code', $GLOBALS['xoopsModuleConfig']['adslight_index_code']);
71
    $xoopsTpl->assign('index_code_place', $GLOBALS['xoopsModuleConfig']['adslight_index_code_place']);
72
    $xoopsTpl->assign('category_title2', _ADSLIGHT_ANNONCES);
73
    // adslight 2
74
    $xoopsTpl->assign('adslight_active_menu', $GLOBALS['xoopsModuleConfig']['adslight_active_menu']);
75
    $xoopsTpl->assign('adslight_active_rss', $GLOBALS['xoopsModuleConfig']['adslight_active_rss']);
76
77
//    ExpireAd();
78
    AdslightUtilities::expireAd();
79
80
    if ($GLOBALS['xoopsUser']) {
81
        $member_usid = $GLOBALS['xoopsUser']->getVar('uid');
82
        if ($usid = $member_usid) {
83
            $xoopsTpl->assign('istheirs', true);
84
85
            list($show_user) = $xoopsDB->fetchRow($xoopsDB->query('SELECT SQL_CACHE COUNT(*) FROM ' . $xoopsDB->prefix('adslight_listing') . " WHERE usid='" . $member_usid . "'"));
86
87
            $xoopsTpl->assign('show_user', $show_user);
88
            $xoopsTpl->assign('show_user_link', 'members.php?usid=' . $member_usid);
89
        }
90
    }
91
92
    $result = $xoopsDB->query('SELECT SQL_CACHE COUNT(*)  FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE valid="No"');
93
    list($propo) = $xoopsDB->fetchRow($result);
94
95
    if ($propo > 0) {
96
        $xoopsTpl->assign('moderated', true);
97
    }
98
    if ($GLOBALS['xoopsUser']) {
99
        if ($GLOBALS['xoopsUser']->isAdmin()) {
100
            $xoopsTpl->assign('admin_block', _ADSLIGHT_ADMINCADRE);
101
            if ($propo == 0) {
102
                $xoopsTpl->assign('confirm_ads', _ADSLIGHT_NO_CLA);
103
            } else {
104
                $xoopsTpl->assign('confirm_ads',
105
                                  _ADSLIGHT_THEREIS . ' ' . $propo . '  ' . _ADSLIGHT_WAIT . '<br><a href="' . XOOPS_URL . '/modules/adslight/admin/validate_ads.php">' . _ADSLIGHT_SEEIT . '</a>');
106
            }
107
        }
108
109
        $categories = AdslightUtilities::getMyItemIds('adslight_submit');
110
        if (is_array($categories) && count($categories) > 0) {
111
            $intro = _ADSLIGHT_INTRO;
112
        } else {
113
            $intro = '';
114
        }
115
        $xoopsTpl->assign('intro', $intro);
116
    }
117
118
    $sql = 'SELECT SQL_CACHE cid, title, img FROM ' . $xoopsDB->prefix('adslight_categories') . ' WHERE pid = 0 ';
119
120
    $categories = AdslightUtilities::getMyItemIds('adslight_view');
121
    if (is_array($categories) && count($categories) > 0) {
122
        $sql .= ' AND cid IN (' . implode(',', $categories) . ') ';
123
    } else {
124
        redirect_header(XOOPS_URL . '/index.php', 3, _NOPERM);
125
    }
126
127
    if ($GLOBALS['xoopsModuleConfig']['adslight_csortorder'] === 'ordre') {
128
        $sql .= 'ORDER BY ordre';
129
    } else {
130
        $sql .= 'ORDER BY title';
131
    }
132
133
    $result = $xoopsDB->query($sql);
134
135
    $count   = 1;
136
    $content = '';
137
    while ($myrow = $xoopsDB->fetchArray($result)) {
138
        $title = $myts->htmlSpecialChars($myrow['title']);
139
140
        if ($myrow['img'] && $myrow['img'] !== 'http://') {
141
            $cat_img = $myts->htmlSpecialChars($myrow['img']);
142
            $img     = '<a href="viewcats.php?cid='
143
                       . $myrow['cid']
144
                       . '"><img src="'
145
                       . XOOPS_URL
146
                       . '/modules/adslight/assets/images/img_cat/'
147
                       . $cat_img
148
                       . '" align="middle" alt="'
149
                       . $title
150
                       . '" /></a>';
151
        } else {
152
            $img = '';
153
        }
154
155
        $totallisting = AdslightUtilities::getTotalItems($myrow['cid'], 1);
156
        $content .= $title . ' ';
157
158
        $arr = array();
0 ignored issues
show
$arr is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
159
        if (in_array($myrow['cid'], $categories)) {
160
            $arr           = $mytree->getFirstChild($myrow['cid'], 'title');
161
            $space         = 0;
162
            $chcount       = 1;
163
            $subcategories = '';
164
            if ($GLOBALS['xoopsModuleConfig']['adslight_souscat'] == 1) {
165
                foreach ($arr as $ele) {
166
                    if (in_array($ele['cid'], $categories)) {
167
                        $chtitle = $myts->htmlSpecialChars($ele['title']);
168
                        if ($chcount > $GLOBALS['xoopsModuleConfig']['adslight_nbsouscat']) {
169
                            $subcategories .= '<a href="viewcats.php?cid=' . $myrow['cid'] . '">' . _ADSLIGHT_CATPLUS . '</a>';
170
                            break;
171
                        }
172
                        if ($space > 0) {
173
                            $subcategories .= '<br>';
174
                        }
175
                        $subcategories .= '-&nbsp;<a href="' . XOOPS_URL . '/modules/adslight/viewcats.php?cid=' . $ele['cid'] . '">' . $chtitle . '</a>';
176
                        ++$space;
177
                        ++$chcount;
178
                        $content .= $ele['title'] . ' ';
179
                    }
180
                }
181
            }
182
            $xoopsTpl->append('categories', array(
183
                'image'         => $img,
184
                'id'            => $myrow['cid'],
185
                'title'         => $myts->htmlSpecialChars($myrow['title']),
186
                'new'           => categorynewgraphic($myrow['cid']),
187
                'subcategories' => $subcategories,
188
                'totallisting'  => $totallisting,
189
                'count'         => $count
190
            ));
191
            ++$count;
192
        }
193
    }
194
    $cat_perms = '';
195
    if (is_array($categories) && count($categories) > 0) {
196
        $cat_perms .= ' AND cid IN (' . implode(',', $categories) . ') ';
197
    }
198
199
    list($ads) = $xoopsDB->fetchRow($xoopsDB->query('SELECT SQL_CACHE COUNT(*)  FROM ' . $xoopsDB->prefix('adslight_listing') . " WHERE valid='Yes' AND status!='1' $cat_perms"));
200
201
    list($catt) = $xoopsDB->fetchRow($xoopsDB->query('SELECT COUNT(*)  FROM ' . $xoopsDB->prefix('' . $moduleDirName . '_categories') . ''));
0 ignored issues
show
The assignment to $catt is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
202
203
    $submit_perms = AdslightUtilities::getMyItemIds('adslight_submit');
0 ignored issues
show
$submit_perms is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
204
205
    if ($GLOBALS['xoopsUser']) {
206
        $add_listing = '' . _ADSLIGHT_ADD_LISTING_BULLOK . '<a href="add.php">' . _ADSLIGHT_ADD_LISTING_SUBOK . '</a>';
207
    } else {
208
        $add_listing = '' . _ADSLIGHT_ADD_LISTING_BULL . '<a href="' . XOOPS_URL . '/register.php">' . _ADSLIGHT_ADD_LISTING_SUB . '</a>.';
209
    }
210
211
    $xoopsTpl->assign('bullinfotext', _ADSLIGHT_ACTUALY . ' ' . $ads . ' ' . _ADSLIGHT_ADVERTISEMENTS . '<br>' . $add_listing);
212
    $xoopsTpl->assign('total_confirm', _ADSLIGHT_AND . " $propo " . _ADSLIGHT_WAIT3);
213
214
    if ($GLOBALS['xoopsModuleConfig']['adslight_newad'] == 1) {
215
        $cat_perms = '';
216
        if (is_array($categories) && count($categories) > 0) {
217
            $cat_perms .= ' AND cid IN (' . implode(',', $categories) . ') ';
218
        }
219
220
        $result = $xoopsDB->query('SELECT SQL_CACHE lid, title, status, type, price, typeprice, date, town, country, usid, premium, valid, photo, hits FROM '
221
                                  . $xoopsDB->prefix('adslight_listing')
222
                                  . " WHERE valid='Yes' AND status!='1' $cat_perms ORDER BY date DESC LIMIT "
223
                                  . $GLOBALS['xoopsModuleConfig']['adslight_newcount']);
224
        if ($result) {
225
            $xoopsTpl->assign('last_head', _ADSLIGHT_THE . ' ' . $GLOBALS['xoopsModuleConfig']['adslight_newcount'] . ' ' . _ADSLIGHT_LASTADD);
226
            $xoopsTpl->assign('last_head_title', _ADSLIGHT_TITLE);
227
            $xoopsTpl->assign('last_head_price', _ADSLIGHT_PRICE);
228
            $xoopsTpl->assign('last_head_date', _ADSLIGHT_DATE);
229
            $xoopsTpl->assign('last_head_local', _ADSLIGHT_LOCAL2);
230
            $xoopsTpl->assign('last_head_hits', _ADSLIGHT_VIEW);
231
            $xoopsTpl->assign('last_head_photo', _ADSLIGHT_PHOTO);
232
            $rank = 1;
233
234
            while (list($lid, $title, $status, $type, $price, $typeprice, $date, $town, $country, $usid, $premium, $valid, $photo, $hits) = $xoopsDB->fetchRow($result)) {
0 ignored issues
show
The assignment to $valid is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
235
                $title     = $myts->htmlSpecialChars($title);
236
                $type      = $myts->htmlSpecialChars($type);
237
                $price     = number_format($price, 2, ',', ' ');
238
                $town      = $myts->htmlSpecialChars($town);
239
                $country   = $myts->htmlSpecialChars($country);
240
                $premium   = $myts->htmlSpecialChars($premium);
241
                $a_item    = array();
242
                $newcount  = $GLOBALS['xoopsModuleConfig']['adslight_countday'];
243
                $startdate = (time() - (86400 * $newcount));
244
245 View Code Duplication
                if ($startdate < $date) {
1 ignored issue
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
246
                    $newitem       = '<img src="' . XOOPS_URL . '/modules/adslight/assets/images/newred.gif" alt="new" />';
247
                    $a_item['new'] = $newitem;
248
                }
249
250
                $useroffset = '';
251
                if ($GLOBALS['xoopsUser']) {
252
                    $timezone = $GLOBALS['xoopsUser']->timezone();
253
                    if (isset($timezone)) {
254
                        $useroffset = $GLOBALS['xoopsUser']->timezone();
255
                    } else {
256
                        $useroffset = $xoopsConfig['default_TZ'];
257
                    }
258
                }
259
260
                $date = ($useroffset * 3600) + $date;
261
                $date = formatTimestamp($date, 's');
262 View Code Duplication
                if ($GLOBALS['xoopsUser']) {
1 ignored issue
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
263
                    if ($GLOBALS['xoopsUser']->isAdmin()) {
264
                        $a_item['admin'] = '<a href="'
265
                                           . XOOPS_URL
266
                                           . '/modules/adslight/admin/validate_ads.php?op=ModifyAds&amp;lid='
267
                                           . $lid
268
                                           . '"><img src="'
269
                                           . $pathIcon16
270
                                           . '/edit.png'
271
                                           . '" border=0 alt="'
272
                                           . _ADSLIGHT_MODADMIN
273
                                           . '" /></a>';
274
                    }
275
                }
276
277
                $result7 = $xoopsDB->query('SELECT nom_type FROM ' . $xoopsDB->prefix('adslight_type') . " WHERE id_type='" . $xoopsDB->escape($type) . "'");
278
                list($nom_type) = $xoopsDB->fetchRow($result7);
279
280
                $a_item['type']  = $myts->htmlSpecialChars($nom_type);
281
                $a_item['title'] = '<a href="' . XOOPS_URL . '/modules/adslight/viewads.php?lid=' . $lid . '"><strong>' . $title . '</strong></a>';
282
283
                $result8 = $xoopsDB->query('SELECT nom_price FROM ' . $xoopsDB->prefix('adslight_price') . " WHERE id_price='" . $xoopsDB->escape($typeprice) . "'");
284
                list($nom_price) = $xoopsDB->fetchRow($result8);
285
286
                if ($price > 0) {
287
                    $a_item['price']           = $price . ' ' . $GLOBALS['xoopsModuleConfig']['adslight_money'] . '';
288
                    $a_item['price_typeprice'] = $myts->htmlSpecialChars($nom_price);
289
                } else {
290
                    $a_item['price']           = '';
291
                    $a_item['price_typeprice'] = $myts->htmlSpecialChars($nom_price);
292
                }
293
                $a_item['premium'] = $premium;
294
                $a_item['date']    = $date;
295
                $a_item['local']   = '';
296
                if ($town) {
297
                    $a_item['local'] .= $town;
298
                }
299
                $a_item['country'] = '';
300
                if ($country) {
301
                    $a_item['country'] = $country;
302
                }
303
304
                if ($status == 2) {
305
                    $a_item['sold'] = _ADSLIGHT_RESERVEDMEMBER;
306
                }
307
308 View Code Duplication
                if ($GLOBALS['xoopsModuleConfig']['active_thumbsindex'] > 0) {
1 ignored issue
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
309
                    $a_item['no_photo'] = '<a href="'
310
                                          . XOOPS_URL
311
                                          . '/modules/adslight/viewads.php?lid='
312
                                          . $lid
313
                                          . '"><img class="thumb" src="'
314
                                          . XOOPS_URL
315
                                          . '/modules/adslight/assets/images/nophoto.jpg" align="left" width="100px" alt="'
316
                                          . $title
317
                                          . '" /></a>';
318
319
                    $updir   = $GLOBALS['xoopsModuleConfig']['adslight_link_upload'];
320
                    $sql     = 'SELECT cod_img, lid, uid_owner, url FROM '
321
                               . $xoopsDB->prefix('adslight_pictures')
322
                               . ' WHERE  uid_owner='
323
                               . $xoopsDB->escape($usid)
324
                               . ' AND lid='
325
                               . $xoopsDB->escape($lid)
326
                               . ' ORDER BY date_added ASC limit 1';
327
                    $resultp = $xoopsDB->query($sql);
328
329
                    while (list($cod_img, $pic_lid, $uid_owner, $url) = $xoopsDB->fetchRow($resultp)) {
0 ignored issues
show
The assignment to $cod_img is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
The assignment to $pic_lid is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
The assignment to $uid_owner is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
330
                        if ($photo) {
331
                            $a_item['photo'] = '<a href="'
332
                                               . XOOPS_URL
333
                                               . '/modules/adslight/viewads.php?lid='
334
                                               . $lid
335
                                               . '"><img class="thumb" src="'
336
                                               . $updir
337
                                               . '/thumbs/thumb_'
338
                                               . $url
339
                                               . '" align="left" width="100px" alt="'
340
                                               . $title
341
                                               . '" /></a>';
342
                        }
343
                    }
344
                } else {
345
                    $a_item['no_photo'] = '<img src="' . XOOPS_URL . '/modules/adslight/assets/images/camera_nophoto.png" align="left" width="24" alt="' . $title . '" />';
346
                    $updir              = $GLOBALS['xoopsModuleConfig']['adslight_link_upload'];
0 ignored issues
show
$updir is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
347
                    $sql                = 'SELECT cod_img, lid, uid_owner, url FROM '
348
                                          . $xoopsDB->prefix('adslight_pictures')
349
                                          . ' WHERE  uid_owner='
350
                                          . $xoopsDB->escape($usid)
351
                                          . ' AND lid='
352
                                          . $xoopsDB->escape($lid)
353
                                          . ' ORDER BY date_added ASC limit 1';
354
                    $resultp            = $xoopsDB->query($sql);
355
356
                    while (list($cod_img, $pic_lid, $uid_owner, $url) = $xoopsDB->fetchRow($resultp)) {
0 ignored issues
show
The assignment to $cod_img is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
The assignment to $pic_lid is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
The assignment to $uid_owner is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
357
                        if ($photo) {
358
                            $a_item['photo'] = '<img src="' . XOOPS_URL . '/modules/adslight/assets/images/camera_photo.png" align="left" width="24" alt="' . $title . '" />';
359
                        }
360
                    }
361
                }
362
                $a_item['hits'] = $hits;
363
                ++$rank;
364
                $xoopsTpl->append('items', $a_item);
365
            }
366
        }
367
    }
368
}
369
370
#  function categorynewgraphic
371
#####################################################
372
/**
373
 * @param $cid
374
 */
375
function categorynewgraphic($cid)
0 ignored issues
show
The parameter $cid is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
376
{
377
    global $xoopsDB;
1 ignored issue
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...
378
}
379
380
######################################################
381
382
$pa      = !isset($_GET['pa']) ? null : $_GET['pa'];
383
$lid     = !isset($_GET['lid']) ? null : $_GET['lid'];
384
$cid     = !isset($_GET['cid']) ? null : $_GET['cid'];
385
$usid    = isset($_GET['usid']) ? $_GET['usid'] : '';
386
$min     = !isset($_GET['min']) ? null : $_GET['min'];
387
$show    = !isset($_GET['show']) ? null : $_GET['show'];
388
$orderby = !isset($_GET['orderby']) ? null : $_GET['orderby'];
389
390
switch ($pa) {
391
    case 'Adsview':
392
        $GLOBALS['xoopsOption']['template_main'] = 'adslight_category.tpl';
393
        adsView($cid, $min, $orderby, $show);
394
        break;
395
    case 'viewads':
396
        $GLOBALS['xoopsOption']['template_main'] = 'adslight_item.tpl';
397
        viewAds($lid);
398
        break;
399
    default:
400
        $GLOBALS['xoopsOption']['template_main'] = 'adslight_index.tpl';
401
        index();
402
        break;
403
}
404
include XOOPS_ROOT_PATH . '/footer.php';
405