Completed
Push — master ( deac0a...054aa6 )
by Michael
01:55
created

index.php ➔ categorynewgraphic()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
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 50 and the first side effect is on line 25.

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
use Xmf\Request;
24
25
require_once __DIR__ . '/header.php';
26
//require XOOPS_ROOT_PATH . '/modules/adslight/include/gtickets.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...
27
28
$myts      = MyTextSanitizer::getInstance();
29
$module_id = $xoopsModule->getVar('mid');
30
31
$groups = ($GLOBALS['xoopsUser'] instanceof XoopsUser) ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS;
0 ignored issues
show
Bug introduced by
The class XoopsUser does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
32
33
/** @var XoopsGroupPermHandler $gpermHandler */
34
$gpermHandler = xoops_getHandler('groupperm');
35
36
$perm_itemid = Request::getInt('item_id', 0, 'POST');
37
38 View Code Duplication
if (!$gpermHandler->checkRight('adslight_view', $perm_itemid, $groups, $module_id)) {
39
    redirect_header(XOOPS_URL . '/index.php', 3, _NOPERM);
40
}
41
42
$prem_perm = (!$gpermHandler->checkRight('adslight_premium', $perm_itemid, $groups, $module_id)) ? '0' : '1';
43
44
include XOOPS_ROOT_PATH . '/modules/adslight/class/classifiedstree.php';
45
//include XOOPS_ROOT_PATH . '/modules/adslight/class/utility.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...
46
$mytree = new ClassifiedsTree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid');
47
48
#  function index
49
#####################################################
50
function index()
0 ignored issues
show
Best Practice introduced by
The function index() has been defined more than once; this definition is ignored, only the first definition in admin/main.php (L31-289) 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...
51
{
52
    global $xoopsDB, $xoopsConfig, $xoopsModule, $xoopsTpl, $myts, $mytree, $meta, $mid, $moduleDirName, $main_lang, $prem_perm, $xoopsModule;
53
    $pathIcon16      = \Xmf\Module\Admin::iconUrl('', 16);
54
55
    $GLOBALS['xoopsOption']['template_main'] = 'adslight_index.tpl';
56
57
    include XOOPS_ROOT_PATH . '/header.php';
58
59
    $xoopsTpl->assign('xmid', $xoopsModule->getVar('mid'));
60
    $xoopsTpl->assign('add_from', _ADSLIGHT_ADDFROM . ' ' . $xoopsConfig['sitename']);
61
    $xoopsTpl->assign('add_from_title', _ADSLIGHT_ADDFROM);
62
    $xoopsTpl->assign('add_from_sitename', $xoopsConfig['sitename']);
63
    $xoopsTpl->assign('only_pix', _ADSLIGHT_ONLYPIX);
64
    $xoopsTpl->assign('adslight_logolink', _ADSLIGHT_LOGOLINK);
65
    $xoopsTpl->assign('permit', $prem_perm);
66
67
    $xoopsTpl->assign('xoops_module_header', '<link rel="stylesheet" href="' . XOOPS_URL . '/modules/adslight/assets/css/adslight.css" type="text/css" media="all" >');
68
69
    $banner = xoops_getbanner();
70
    $xoopsTpl->assign('banner', $banner);
71
    $xoopsTpl->assign('use_extra_code', $GLOBALS['xoopsModuleConfig']['adslight_use_index_code']);
72
    $xoopsTpl->assign('adslight_use_banner', $GLOBALS['xoopsModuleConfig']['adslight_use_banner']);
73
    $xoopsTpl->assign('index_extra_code', $GLOBALS['xoopsModuleConfig']['adslight_index_code']);
74
    $xoopsTpl->assign('index_code_place', $GLOBALS['xoopsModuleConfig']['adslight_index_code_place']);
75
    $xoopsTpl->assign('category_title2', _ADSLIGHT_ANNONCES);
76
    // adslight 2
77
    $xoopsTpl->assign('adslight_active_menu', $GLOBALS['xoopsModuleConfig']['adslight_active_menu']);
78
    $xoopsTpl->assign('adslight_active_rss', $GLOBALS['xoopsModuleConfig']['adslight_active_rss']);
79
80
    //    ExpireAd();
81
    AdslightUtility::expireAd();
82
83 View Code Duplication
    if ($GLOBALS['xoopsUser']) {
84
        $member_usid = $GLOBALS['xoopsUser']->getVar('uid');
85
        if ($usid = $member_usid) {
86
            $xoopsTpl->assign('istheirs', true);
87
88
            list($show_user) = $xoopsDB->fetchRow($xoopsDB->query('SELECT SQL_CACHE COUNT(*) FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE usid=' . $member_usid . ''));
89
90
            $xoopsTpl->assign('show_user', $show_user);
91
            $xoopsTpl->assign('show_user_link', 'members.php?usid=' . $member_usid . '');
92
        }
93
    }
94
95
    $result = $xoopsDB->query('SELECT SQL_CACHE COUNT(*)  FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE valid="No"');
96
    list($propo) = $xoopsDB->fetchRow($result);
97
98
    if ($propo > 0) {
99
        $xoopsTpl->assign('moderated', true);
100
    }
101
    if ($GLOBALS['xoopsUser'] instanceof XoopsUser) {
0 ignored issues
show
Bug introduced by
The class XoopsUser does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
102
        if ($GLOBALS['xoopsUser']->isAdmin()) {
103
            $xoopsTpl->assign('admin_block', _ADSLIGHT_ADMINCADRE);
104
            if ($propo == 0) {
105
                $xoopsTpl->assign('confirm_ads', _ADSLIGHT_NO_CLA);
106
            } else {
107
                $xoopsTpl->assign('confirm_ads',
108
                                  _ADSLIGHT_THEREIS . ' ' . $propo . '  ' . _ADSLIGHT_WAIT . '<br><a href="' . XOOPS_URL . '/modules/adslight/admin/validate_ads.php">' . _ADSLIGHT_SEEIT . '</a>');
109
            }
110
        }
111
112
        $categories = AdslightUtility::getMyItemIds('adslight_submit');
113
        $intro      = (is_array($categories)
114
                       && (count($categories) > 0)) ? _ADSLIGHT_INTRO : '';
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 = AdslightUtility::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
    $sql .= ('cat_order' == $GLOBALS['xoopsModuleConfig']['adslight_csortorder']) ? 'ORDER BY cat_order' : 'ORDER BY title';
128
129
    $result = $xoopsDB->query($sql);
130
131
    $count   = 1;
132
    $content = '';
133
    while ($myrow = $xoopsDB->fetchArray($result)) {
134
        $title = $myts->htmlSpecialChars($myrow['title']);
135
136
        if ($myrow['img'] && $myrow['img'] !== 'http://') {
137
            $cat_img = $myts->htmlSpecialChars($myrow['img']);
138
            $img     = "<a href=\"viewcats.php?cid={$myrow['cid']}\"><img src=\"" . XOOPS_URL . "/modules/adslight/assets/images/img_cat/{$cat_img}\" align=\"middle\" alt=\"{$title}\"></a>";
139
        } else {
140
            $img = '';
141
        }
142
143
        $totallisting = AdslightUtility::getTotalItems($myrow['cid'], 1);
144
        $content      .= $title . ' ';
145
146
        $arr = array();
0 ignored issues
show
Unused Code introduced by
$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...
147
        if (in_array($myrow['cid'], $categories)) {
148
            $arr           = $mytree->getFirstChild($myrow['cid'], 'title');
149
            $space         = 0;
150
            $chcount       = 1;
151
            $subcategories = '';
152
            if (1 == $GLOBALS['xoopsModuleConfig']['adslight_souscat']) {
153
                foreach ($arr as $ele) {
154
                    if (in_array($ele['cid'], $categories)) {
155
                        $chtitle = $myts->htmlSpecialChars($ele['title']);
156
                        if ($chcount > $GLOBALS['xoopsModuleConfig']['adslight_nbsouscat']) {
157
                            $subcategories .= "<a href=\"viewcats.php?cid={$myrow['cid']}\">" . _ADSLIGHT_CATPLUS . '</a>';
158
                            break;
159
                        }
160
                        if ($space > 0) {
161
                            $subcategories .= '<br>';
162
                        }
163
                        $subcategories .= "-&nbsp;<a href=\"" . XOOPS_URL . "/modules/adslight/viewcats.php?cid={$ele['cid']}\">{$chtitle}</a>";
164
                        ++$space;
165
                        ++$chcount;
166
                        $content .= $ele['title'] . ' ';
167
                    }
168
                }
169
            }
170
            $xoopsTpl->append('categories', array(
171
                'image'         => $img,
172
                'id'            => $myrow['cid'],
173
                'title'         => $myts->htmlSpecialChars($myrow['title']),
174
                'new'           => categorynewgraphic($myrow['cid']),
175
                'subcategories' => $subcategories,
176
                'totallisting'  => $totallisting,
177
                'count'         => $count
178
            ));
179
            ++$count;
180
        }
181
    }
182
    $cat_perms = '';
183
    if (is_array($categories) && count($categories) > 0) {
184
        $cat_perms .= ' AND cid IN (' . implode(',', $categories) . ') ';
185
    }
186
187
    list($ads) = $xoopsDB->fetchRow($xoopsDB->query('SELECT SQL_CACHE COUNT(*)  FROM ' . $xoopsDB->prefix('adslight_listing') . " WHERE valid='Yes' AND status!='1' {$cat_perms}"));
188
189
    list($catt) = $xoopsDB->fetchRow($xoopsDB->query('SELECT COUNT(*)  FROM ' . $xoopsDB->prefix("{$moduleDirName}_categories")));
0 ignored issues
show
Unused Code introduced by
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...
190
191
    $submit_perms = AdslightUtility::getMyItemIds('adslight_submit');
0 ignored issues
show
Unused Code introduced by
$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...
192
193
    if ($GLOBALS['xoopsUser'] instanceof XoopsUser) {
0 ignored issues
show
Bug introduced by
The class XoopsUser does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
194
        $add_listing = '' . _ADSLIGHT_ADD_LISTING_BULLOK . '<a href="add.php">' . _ADSLIGHT_ADD_LISTING_SUBOK . '</a>';
195
    } else {
196
        $add_listing = '' . _ADSLIGHT_ADD_LISTING_BULL . '<a href="' . XOOPS_URL . '/register.php">' . _ADSLIGHT_ADD_LISTING_SUB . '</a>.';
197
    }
198
199
    $xoopsTpl->assign('bullinfotext', _ADSLIGHT_ACTUALY . ' ' . $ads . ' ' . _ADSLIGHT_ADVERTISEMENTS . '<br>' . $add_listing);
200
    $xoopsTpl->assign('total_confirm', _ADSLIGHT_AND . " $propo " . _ADSLIGHT_WAIT3);
201
202
    if (1 == $GLOBALS['xoopsModuleConfig']['adslight_newad']) {
203
        $cat_perms = '';
204
        if (is_array($categories) && count($categories) > 0) {
205
            $cat_perms .= ' AND cid IN (' . implode(',', $categories) . ') ';
206
        }
207
208
        $result = $xoopsDB->query('SELECT SQL_CACHE lid, title, status, type, price, typeprice, date, town, country, usid, premium, valid, photo, hits FROM '
209
                                  . $xoopsDB->prefix('adslight_listing')
210
                                  . " WHERE valid='Yes' and status!='1' {$cat_perms} ORDER BY date DESC LIMIT {$GLOBALS['xoopsModuleConfig']['adslight_newcount']}");
211
        if ($result) {
212
            $xoopsTpl->assign('last_head', _ADSLIGHT_THE . ' ' . $GLOBALS['xoopsModuleConfig']['adslight_newcount'] . ' ' . _ADSLIGHT_LASTADD);
213
            $xoopsTpl->assign('last_head_title', _ADSLIGHT_TITLE);
214
            $xoopsTpl->assign('last_head_price', _ADSLIGHT_PRICE);
215
            $xoopsTpl->assign('last_head_date', _ADSLIGHT_DATE);
216
            $xoopsTpl->assign('last_head_local', _ADSLIGHT_LOCAL2);
217
            $xoopsTpl->assign('last_head_hits', _ADSLIGHT_VIEW);
218
            $xoopsTpl->assign('last_head_photo', _ADSLIGHT_PHOTO);
219
            $rank = 1;
220
221
            while (list($lid, $title, $status, $type, $price, $typeprice, $date, $town, $country, $usid, $premium, $valid, $photo, $hits) = $xoopsDB->fetchRow($result)) {
0 ignored issues
show
Unused Code introduced by
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...
222
                $title = $myts->htmlSpecialChars($title);
223
                $type  = $myts->htmlSpecialChars($type);
224
                //                $price     = number_format($price, 2, ',', ' ');
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% 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...
225
                $town      = $myts->htmlSpecialChars($town);
226
                $country   = $myts->htmlSpecialChars($country);
227
                $premium   = $myts->htmlSpecialChars($premium);
228
                $a_item    = array();
229
                $newcount  = $GLOBALS['xoopsModuleConfig']['adslight_countday'];
230
                $startdate = (time() - (86400 * $newcount));
231
232 View Code Duplication
                if ($startdate < $date) {
233
                    $newitem       = '<img src="' . XOOPS_URL . '/modules/adslight/assets/images/newred.gif" alt="new" >';
234
                    $a_item['new'] = $newitem;
235
                }
236
237
                $useroffset = '';
238
                if ($GLOBALS['xoopsUser'] instanceof XoopsUser) {
0 ignored issues
show
Bug introduced by
The class XoopsUser does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
239
                    $timezone   = $GLOBALS['xoopsUser']->timezone();
240
                    $useroffset = (!empty($timezone)) ? $xoopsUser->timezone() : $xoopsConfig['default_TZ'];
0 ignored issues
show
Bug introduced by
The variable $xoopsUser does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
241
                    if ($xoopsUser->isAdmin()) {
242
                        $a_item['admin'] = "<a href=\""
243
                                           . XOOPS_URL
244
                                           . "/modules/adslight/admin/validate_ads.php?op=ModifyAds&amp;lid={$lid}\"><img src=\"{$pathIcon16}/edit.png\" border=\"0\" alt=\""
245
                                           . _ADSLIGHT_MODADMIN
246
                                           . "\"></a>";
247
                    }
248
                }
249
250
                $date = ($useroffset * 3600) + $date;
251
                $date = formatTimestamp($date, 's');
252
253
                $result7 = $xoopsDB->query('SELECT nom_type FROM ' . $xoopsDB->prefix('adslight_type') . ' WHERE id_type=' . (int)$type);
254
                list($nom_type) = $xoopsDB->fetchRow($result7);
255
256
                $a_item['type']  = $myts->htmlSpecialChars($nom_type);
257
                $a_item['title'] = "<a href=\"" . XOOPS_URL . "/modules/adslight/viewads.php?lid={$lid}\"><strong>{$title}</strong></a>";
258
259
                $result8 = $xoopsDB->query('SELECT nom_price FROM ' . $xoopsDB->prefix('adslight_price') . ' WHERE id_price=' . (int)$typeprice);
260
                list($nom_price) = $xoopsDB->fetchRow($result8);
261
262
                if ($price > 0) {
263
                    $a_item['price']           = $price . ' ' . $GLOBALS['xoopsModuleConfig']['adslight_currency_symbol'] . '';
264
                    $a_item['price_typeprice'] = $myts->htmlSpecialChars($nom_price);
265
                } else {
266
                    $a_item['price']           = '';
267
                    $a_item['price_typeprice'] = $myts->htmlSpecialChars($nom_price);
268
                }
269
                $a_item['premium'] = $premium;
270
                $a_item['date']    = $date;
271
                $a_item['local']   .= $town ? $town : '';
272
                $a_item['country'] = $country ? $country : '';
273
274
                if (2 == $status) {
275
                    $a_item['sold'] = _ADSLIGHT_RESERVEDMEMBER;
276
                }
277
278
                if ($xoopsModuleConfig['active_thumbsindex'] > 0) {
0 ignored issues
show
Bug introduced by
The variable $xoopsModuleConfig does not exist. Did you mean $xoopsModule?

This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.

The variable may have been renamed without also renaming all references.

Loading history...
279
                    $a_item['no_photo'] = "<a href=\""
280
                                          . XOOPS_URL
281
                                          . "/modules/adslight/viewads.php?lid={$lid}\"><img class=\"thumb\" src=\""
282
                                          . XOOPS_URL
283
                                          . "/modules/adslight/assets/images/nophoto.jpg\" align=\"left\" width=\"100px\" alt=\"{$title}\"></a>";
284
285
                    $updir = $GLOBALS['xoopsModuleConfig']['adslight_link_upload'];
286
                    $sql   = 'SELECT cod_img, lid, uid_owner, url FROM '
287
                             . $xoopsDB->prefix('adslight_pictures')
288
                             . ' WHERE  uid_owner='
289
                             . (int)$usid
290
                             . " AND lid={$lid} ORDER BY date_added ASC LIMIT 1";
291
292
                    $resultp = $xoopsDB->query($sql);
293
294
                    while (list($cod_img, $pic_lid, $uid_owner, $url) = $xoopsDB->fetchRow($resultp)) {
0 ignored issues
show
Unused Code introduced by
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...
Unused Code introduced by
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...
Unused Code introduced by
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...
295
                        if ($photo) {
296
                            $a_item['photo'] = "<a href=\""
297
                                               . XOOPS_URL
298
                                               . "/modules/adslight/viewads.php?lid={$lid}\"><img class=\"thumb\" src=\"{$updir}/thumbs/thumb_{$url}\" align=\"left\" width=\"100px\" alt=\"{$title}\"></a>";
299
                        }
300
                    }
301 View Code Duplication
                } else {
302
                    $a_item['no_photo'] = "<img src=\"" . XOOPS_URL . "/modules/adslight/assets/images/camera_nophoto.png\" align=\"left\" width=\"24px\" alt=\"{$title}\">";
303
                    $updir              = $GLOBALS['xoopsModuleConfig']['adslight_link_upload'];
0 ignored issues
show
Unused Code introduced by
$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...
304
                    $sql                = 'SELECT cod_img, lid, uid_owner, url FROM '
305
                                          . $xoopsDB->prefix('adslight_pictures')
306
                                          . ' WHERE uid_owner='
307
                                          . (int)$usid
308
                                          . " AND lid={$lid} ORDER BY date_added ASC LIMIT 1";
309
                    $resultp            = $xoopsDB->query($sql);
310
311
                    while (list($cod_img, $pic_lid, $uid_owner, $url) = $xoopsDB->fetchRow($resultp)) {
0 ignored issues
show
Unused Code introduced by
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...
Unused Code introduced by
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...
Unused Code introduced by
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...
312
                        if ($photo) {
313
                            $a_item['photo'] = "<img src=\"" . XOOPS_URL . "/modules/adslight/assets/images/camera_photo.png\" align=\"left\" width=\"24\" alt=\"{$title}\">";
314
                        }
315
                    }
316
                }
317
                $a_item['hits'] = $hits;
318
                ++$rank;
319
                $xoopsTpl->append('items', $a_item);
320
            }
321
        }
322
    }
323
}
324
325
#  function categorynewgraphic
326
#####################################################
327
/**
328
 * @param $cid
329
 */
330
function categorynewgraphic($cid)
0 ignored issues
show
Unused Code introduced by
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...
331
{
332
    global $xoopsDB;
333
}
334
335
######################################################
336
337
$pa      = Request::getInt('pa', null, 'GET');
338
$lid     = Request::getInt('lid', null, 'GET');
339
$cid     = Request::getInt('cid', null, 'GET');
340
$usid    = Request::getString('usid', '', 'GET');
341
$min     = Request::getInt('min', null, 'GET');
342
$show    = Request::getInt('show', null, 'GET');
343
$orderby = Request::getInt('orderby', null, 'GET');
344
345
switch ($pa) {
346
    case 'Adsview':
347
        $GLOBALS['xoopsOption']['template_main'] = 'adslight_category.tpl';
348
        adsView($cid, $min, $orderby, $show);
349
        break;
350
    case 'viewads':
351
        $GLOBALS['xoopsOption']['template_main'] = 'adslight_item.tpl';
352
        viewAds($lid);
353
        break;
354
    default:
355
        $GLOBALS['xoopsOption']['template_main'] = 'adslight_index.tpl';
356
        index();
357
        break;
358
}
359
include XOOPS_ROOT_PATH . '/footer.php';
360