Passed
Push — master ( 5e790e...222087 )
by Michael
03:14
created

viewads.php (30 issues)

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 60 and the first side effect is on line 26.

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 Luc Bizet user at www.frxoops.org
7
        Started with the Classifieds module and made MANY changes
8
        Website : http://www.luc-bizet.fr
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;
0 ignored issues
show
The type Xmf\Request was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
24
use XoopsModules\Adslight;
25
26
require_once __DIR__ . '/header.php';
27
//require_once 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...
28
xoops_load('XoopsLocal');
0 ignored issues
show
The function xoops_load was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

28
/** @scrutinizer ignore-call */ 
29
xoops_load('XoopsLocal');
Loading history...
29
30
$myts      = \MyTextSanitizer::getInstance();
0 ignored issues
show
The type MyTextSanitizer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
31
$module_id = $xoopsModule->getVar('mid');
32
33
if (is_object($GLOBALS['xoopsUser'])) {
34
    $groups = $GLOBALS['xoopsUser']->getGroups();
35
} else {
36
    $groups = XOOPS_GROUP_ANONYMOUS;
0 ignored issues
show
The constant XOOPS_GROUP_ANONYMOUS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
37
}
38
/** @var XoopsGroupPermHandler $gpermHandler */
39
$gpermHandler = xoops_getHandler('groupperm');
0 ignored issues
show
The function xoops_getHandler was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

39
$gpermHandler = /** @scrutinizer ignore-call */ xoops_getHandler('groupperm');
Loading history...
40
$perm_itemid  = Request::getInt('item_id', 0, 'POST');
41
//If no access
42
if (!$gpermHandler->checkRight('adslight_view', $perm_itemid, $groups, $module_id)) {
43
    redirect_header(XOOPS_URL . '/index.php', 3, _NOPERM);
0 ignored issues
show
The constant _NOPERM was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
The function redirect_header was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

43
    /** @scrutinizer ignore-call */ 
44
    redirect_header(XOOPS_URL . '/index.php', 3, _NOPERM);
Loading history...
The constant XOOPS_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
44
}
45
if (!$gpermHandler->checkRight('adslight_premium', $perm_itemid, $groups, $module_id)) {
46
    $prem_perm = '0';
47
} else {
48
    $prem_perm = '1';
49
}
50
51
include XOOPS_ROOT_PATH . '/modules/adslight/class/classifiedstree.php';
0 ignored issues
show
The constant XOOPS_ROOT_PATH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
52
//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...
53
$mytree = new Adslight\ClassifiedsTree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid');
54
55
#  function viewads
56
#####################################################
57
/**
58
 * @param int $lid
59
 */
60
function viewAds($lid = 0)
61
{
62
    global $xoopsDB, $xoopsConfig, $xoopsModule, $xoopsTpl, $myts, $meta, $moduleDirName, $main_lang, $prem_perm, $xoopsModule;
63
    global $xoopsModuleConfig, $xoopsUser;
64
    $pathIcon16     = \Xmf\Module\Admin::iconUrl('', 16);
0 ignored issues
show
The type Xmf\Module\Admin was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
65
    $contact_pm     = $contact = '';
66
    $pictures_array = [];
67
    $cid            = 0;
68
69
    $tempXoopsLocal                          = new \XoopsLocal;
0 ignored issues
show
The type XoopsLocal was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
70
    $GLOBALS['xoopsOption']['template_main'] = 'adslight_item.tpl';
71
    include XOOPS_ROOT_PATH . '/header.php';
0 ignored issues
show
The constant XOOPS_ROOT_PATH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
72
    include XOOPS_ROOT_PATH . '/include/comment_view.php';
73
    $lid  = ((int)$lid > 0) ? (int)$lid : 0;
74
    $rate = ('1' == $GLOBALS['xoopsModuleConfig']['adslight_rate_item']) ? '1' : '0';
75
    $GLOBALS['xoopsTpl']->assign('rate', $rate);
76
    $GLOBALS['xoopsTpl']->assign('xmid', $xoopsModule->getVar('mid'));
77
    $GLOBALS['xoopsTpl']->assign('adslight_logolink', _ADSLIGHT_LOGOLINK);
78
79
    // Hack redirection erreur 404  si lid=null
80
    if ('' == $lid) {
81
        header('Status: 301 Moved Permanently', false, 301);
82
        //        header('Location: '.XOOPS_URL.'/modules/adslight/404.php');
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% 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...
83
        //        exit();
84
        redirect_header(XOOPS_URL . '/modules/adslight/404.php', 1);
0 ignored issues
show
The function redirect_header was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

84
        /** @scrutinizer ignore-call */ 
85
        redirect_header(XOOPS_URL . '/modules/adslight/404.php', 1);
Loading history...
The constant XOOPS_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
85
    }
86
87
    $GLOBALS['xoopsTpl']->assign('adslight_active_bookmark', $GLOBALS['xoopsModuleConfig']['adslight_active_bookmark']);
88
    $GLOBALS['xoopsTpl']->assign('adslight_style_bookmark', $GLOBALS['xoopsModuleConfig']['adslight_style_bookmark']);
89
    $GLOBALS['xoopsTpl']->assign('adslight_active_xpayement', $GLOBALS['xoopsModuleConfig']['adslight_active_xpayment']);
90
91
    // adslight 2
92
    $GLOBALS['xoopsTpl']->assign('adslight_active_menu', $GLOBALS['xoopsModuleConfig']['adslight_active_menu']);
93
    $GLOBALS['xoopsTpl']->assign('adslight_active_rss', $GLOBALS['xoopsModuleConfig']['adslight_active_rss']);
94
95
    if ($GLOBALS['xoopsUser']) {
96
        $member_usid = $GLOBALS['xoopsUser']->getVar('uid');
97
        if ($usid = $member_usid) {
98
            $GLOBALS['xoopsTpl']->assign('istheirs', true);
99
100
            if (strlen($GLOBALS['xoopsUser']->getVar('name'))) {
101
                $GLOBALS['xoopsTpl']->assign('user_name', $GLOBALS['xoopsUser']->getVar('name') . ' (' . $GLOBALS['xoopsUser']->getVar('uname') . ')');
102
            } else {
103
                $GLOBALS['xoopsTpl']->assign('user_name', $GLOBALS['xoopsUser']->getVar('uname'));
104
            }
105
106
            $GLOBALS['xoopsTpl']->assign('user_email', $GLOBALS['xoopsUser']->getVar('email'));
107
108
            list($show_user) = $xoopsDB->fetchRow($xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_listing') . " WHERE usid=$member_usid"));
109
110
            $GLOBALS['xoopsTpl']->assign('show_user', $show_user);
111
            $GLOBALS['xoopsTpl']->assign('show_user_link', 'members.php?usid=' . $member_usid);
112
        }
113
    }
114
115
    if ($GLOBALS['xoopsUser']) {
116
        $currentid = $GLOBALS['xoopsUser']->getVar('uid', 'E');
117
    }
118
119
    $cat_perms  = '';
120
    $categories = Adslight\Utility::getMyItemIds('adslight_view');
121
    if (is_array($categories) && count($categories) > 0) {
122
        $cat_perms .= ' AND cid IN (' . implode(',', $categories) . ') ';
123
    }
124
125
    $result      = $xoopsDB->query('SELECT l.lid, l.cid, l.title, l.status, l.expire, l.type, l.desctext, l.tel, l.price, l.typeprice, l.typeusure, l.date, l.email, l.submitter, l.usid, l.town, l.country, l.contactby, l.premium, l.valid, l.photo, l.hits, l.item_rating, l.item_votes, l.user_rating, l.user_votes, l.comments, p.cod_img, p.lid, p.uid_owner, p.url FROM '
126
                                   . $xoopsDB->prefix('adslight_listing')
127
                                   . ' l LEFT JOIN '
128
                                   . $xoopsDB->prefix('adslight_pictures')
129
                                   . " p ON l.lid=p.lid  WHERE l.valid='Yes' AND l.lid = "
130
                                   . $xoopsDB->escape($lid)
131
                                   . " and l.status!='1' $cat_perms");
132
    $recordexist = $xoopsDB->getRowsNum($result);
133
134
    // Hack redirection erreur 404  si recordexist=null
135
    if ('' == $recordexist) {
136
        header('Status: 301 Moved Permanently', false, 301);
137
        //        header('Location: '.XOOPS_URL.'/modules/adslight/404.php');
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% 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...
138
        //        exit();
139
        redirect_header(XOOPS_URL . '/modules/adslight/404.php', 1);
140
    }
141
142
    if ($recordexist) {
143
        list($lid, $cid, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typeusure, $date, $email, $submitter, $usid, $town, $country, $contactby, $premium, $valid, $photo, $hits, $item_rating, $item_votes, $user_rating, $user_votes, $comments, $cod_img, $pic_lid, $uid_owner, $url) = $xoopsDB->fetchRow($result);
144
145
        $newcount  = $GLOBALS['xoopsModuleConfig']['adslight_countday'];
146
        $startdate = (time() - (86400 * $newcount));
147
        if ($startdate < $date) {
148
            $newitem = '<img src="' . XOOPS_URL . '/modules/adslight/assets/images/newred.gif" alt="new" >';
149
            $GLOBALS['xoopsTpl']->assign('new', $newitem);
150
        }
151
152
        $updir = $GLOBALS['xoopsModuleConfig']['adslight_link_upload'];
153
        $GLOBALS['xoopsTpl']->assign('add_from', _ADSLIGHT_ADDFROM . ' ' . $xoopsConfig['sitename']);
154
        $GLOBALS['xoopsTpl']->assign('add_from_title', _ADSLIGHT_ADDFROM);
155
        $GLOBALS['xoopsTpl']->assign('add_from_sitename', $xoopsConfig['sitename']);
156
        $GLOBALS['xoopsTpl']->assign('ad_exists', $recordexist);
157
        $GLOBALS['xoopsTpl']->assign('mydirname', $moduleDirName);
158
159
        $count = 0;
160
        $x     = 0;
161
        $i     = 0;
162
163
        $result3 = $xoopsDB->query('SELECT cid, pid, title FROM ' . $xoopsDB->prefix('adslight_categories') . ' WHERE  cid=' . $xoopsDB->escape($cid));
164
        list($ccid, $pid, $ctitle) = $xoopsDB->fetchRow($result3);
165
166
        $GLOBALS['xoopsTpl']->assign('category_title', $ctitle);
167
168
        $module_id = $xoopsModule->getVar('mid');
169
        if (is_object($GLOBALS['xoopsUser'])) {
170
            $groups = $GLOBALS['xoopsUser']->getGroups();
171
        } else {
172
            $groups = XOOPS_GROUP_ANONYMOUS;
0 ignored issues
show
The constant XOOPS_GROUP_ANONYMOUS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
173
        }
174
        /** @var XoopsGroupPermHandler $gpermHandler */
175
        $gpermHandler = xoops_getHandler('groupperm');
0 ignored issues
show
The function xoops_getHandler was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

175
        $gpermHandler = /** @scrutinizer ignore-call */ xoops_getHandler('groupperm');
Loading history...
176
        $GLOBALS['xoopsTpl']->assign('purchasable', $gpermHandler->checkRight('adslight_purchase', $cid, $groups, $module_id));
177
178
        $ctitle     = $myts->htmlSpecialChars($ctitle);
179
        $varid[$x]  = $ccid;
180
        $varnom[$x] = $ctitle;
181
182
        list($nbe) = $xoopsDB->fetchRow($xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE valid="Yes" AND cid=' . $xoopsDB->escape($cid) . ' AND status!="1"'));
183
184
        if (0 != $pid) {
185
            $x = 1;
186
            while (0 != $pid) {
187
                $result4 = $xoopsDB->query('SELECT cid, pid, title FROM ' . $xoopsDB->prefix('adslight_categories') . ' WHERE cid=' . $xoopsDB->escape($pid));
188
                list($ccid, $pid, $ctitle) = $xoopsDB->fetchRow($result4);
189
190
                $ctitle     = $myts->htmlSpecialChars($ctitle);
191
                $varid[$x]  = $ccid;
192
                $varnom[$x] = $ctitle;
193
                ++$x;
194
            }
195
            --$x;
196
        }
197
        $subcats = '';
198
        $arrow   = '&nbsp;<img src="' . XOOPS_URL . '/modules/adslight/assets/images/arrow.gif" alt="&raquo;" >';
199
        while ($x != -1) {
200
            $subcats .= ' ' . $arrow . ' <a href="viewcats.php?cid=' . $varid[$x] . '">' . $varnom[$x] . '</a>';
201
            --$x;
202
        }
203
        $GLOBALS['xoopsTpl']->assign('nav_main', '<a href="index.php">' . _ADSLIGHT_MAIN . '</a>');
204
        $GLOBALS['xoopsTpl']->assign('nav_sub', $subcats);
205
        $GLOBALS['xoopsTpl']->assign('nav_subcount', $nbe);
206
        $viewcount_judge = true;
207
        $useroffset      = '';
208
        if ($GLOBALS['xoopsUser']) {
209
            $timezone = $GLOBALS['xoopsUser']->timezone();
210
            if (isset($timezone)) {
211
                $useroffset = $GLOBALS['xoopsUser']->timezone();
212
            } else {
213
                $useroffset = $xoopsConfig['default_TZ'];
214
            }
215
            if ($GLOBALS['xoopsUser']->isAdmin()) {
216
                $adslight_admin = true;
217
            } else {
218
                $adslight_admin = false;
219
            }
220
221
            if (($adslight_admin = true)
222
                || ($GLOBALS['xoopsUser']->getVar('uid') == $usid)) {
223
                $viewcount_judge = false;
224
            }
225
226
            $contact_pm = '<a href="' . XOOPS_URL . '/pmlite.php?send2=1&amp;to_userid=' . addslashes($usid) . '">&nbsp;' . _ADSLIGHT_CONTACT_BY_PM . '</a>';
227
        }
228
        if (true === $viewcount_judge) {
229
            $xoopsDB->queryF('UPDATE ' . $xoopsDB->prefix('adslight_listing') . ' SET hits=hits+1 WHERE lid = ' . $xoopsDB->escape($lid));
230
        }
231
        if (1 == $item_votes) {
232
            $votestring = _ADSLIGHT_ONEVOTE;
233
        } else {
234
            $votestring = sprintf(_ADSLIGHT_NUMVOTES, $item_votes);
235
        }
236
        $date     = ($useroffset * 3600) + $date;
237
        $date2    = $date + ($expire * 86400);
238
        $date     = formatTimestamp($date, 's');
0 ignored issues
show
The function formatTimestamp was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

238
        $date     = /** @scrutinizer ignore-call */ formatTimestamp($date, 's');
Loading history...
239
        $date2    = formatTimestamp($date2, 's');
240
        $title    = $myts->htmlSpecialChars($title);
241
        $status   = $myts->htmlSpecialChars($status);
242
        $expire   = $myts->htmlSpecialChars($expire);
243
        $type     = $myts->htmlSpecialChars($type);
244
        $desctext = $myts->displayTarea($desctext, 1, 1, 1);
245
        $tel      = $myts->htmlSpecialChars($tel);
246
        //        $price = XoopsLocal::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...
247
        $typeprice = $myts->htmlSpecialChars($typeprice);
248
        $typeusure = $myts->htmlSpecialChars($typeusure);
249
        $submitter = $myts->htmlSpecialChars($submitter);
250
        $usid      = $myts->htmlSpecialChars($usid);
251
        $town      = $myts->htmlSpecialChars($town);
252
        $country   = $myts->htmlSpecialChars($country);
253
        $contactby = $myts->htmlSpecialChars($contactby);
254
        $premium   = $myts->htmlSpecialChars($premium);
255
256
        if (2 == $status) {
257
            $sold = _ADSLIGHT_RESERVED;
258
        } else {
259
            $sold = '';
260
        }
261
262
        $GLOBALS['xoopsTpl']->assign('printA', '<a href="print.php?op=PrintAd&amp;lid=' . $lid . '" ><img src="assets/images/print.gif" border=0 alt="' . _ADSLIGHT_PRINT . '" ></a>&nbsp;');
263
264
        if ($usid > 0) {
265
            $GLOBALS['xoopsTpl']->assign('submitter', '<img src="assets/images/lesannonces.png" border="0" alt="' . _ADSLIGHT_VIEW_MY_ADS . '" >&nbsp;&nbsp;<a href="members.php?usid=' . addslashes($usid) . '" >' . _ADSLIGHT_VIEW_MY_ADS . ' ' . $submitter . '</a>');
266
        } else {
267
            $GLOBALS['xoopsTpl']->assign('submitter', _ADSLIGHT_VIEW_MY_ADS . ' $submitter');
268
        }
269
        $GLOBALS['xoopsTpl']->assign('lid', $lid);
270
        $GLOBALS['xoopsTpl']->assign('read', "$hits " . _ADSLIGHT_VIEW2);
271
        $GLOBALS['xoopsTpl']->assign('rating', $tempXoopsLocal->number_format($item_rating, 2));
272
        $GLOBALS['xoopsTpl']->assign('votes', $votestring);
273
        $GLOBALS['xoopsTpl']->assign('lang_rating', _ADSLIGHT_RATINGC);
274
        $GLOBALS['xoopsTpl']->assign('lang_ratethisitem', _ADSLIGHT_RATETHISITEM);
275
        $GLOBALS['xoopsTpl']->assign('xoop_user', false);
276
        $isOwner = '';
277
        if ($GLOBALS['xoopsUser']) {
278
            $GLOBALS['xoopsTpl']->assign('xoop_user', true);
279
            $currentid = $GLOBALS['xoopsUser']->getVar('uid', 'E');
280
            if ($usid == $currentid) {
281
                $GLOBALS['xoopsTpl']->assign('modifyads', '<img src=' . $pathIcon16 . '/edit.png border="0" alt="' . _ADSLIGHT_MODIFANN . '" >&nbsp;&nbsp;<a href="modify.php?op=ModAd&amp;lid=' . $lid . '">' . _ADSLIGHT_MODIFANN . '</a>');
282
                $GLOBALS['xoopsTpl']->assign('deleteads', '<img src=' . $pathIcon16 . '/delete.png  border="0" alt="' . _ADSLIGHT_SUPPRANN . '" >&nbsp;&nbsp;<a href="modify.php?op=ListingDel&amp;lid=' . $lid . '">' . _ADSLIGHT_SUPPRANN . '</a>');
283
                $GLOBALS['xoopsTpl']->assign('add_photos', '<img src="assets/images/shape_square_add.png" border="0" alt="' . _ADSLIGHT_SUPPRANN . '" >&nbsp;&nbsp;<a href="view_photos.php?lid=' . $lid . '&uid=' . $usid . '">' . _ADSLIGHT_ADD_PHOTOS . '</a>');
284
285
                $isOwner = true;
286
                $GLOBALS['xoopsTpl']->assign('isOwner', $isOwner);
287
            }
288
            if ($GLOBALS['xoopsUser']->isAdmin()) {
289
                $GLOBALS['xoopsTpl']->assign('admin', '<a href="' . XOOPS_URL . '/modules/adslight/admin/modify_ads.php?op=ModifyAds&amp;lid=' . $lid . '"><img src=' . $pathIcon16 . '/edit.png  border=0 alt="' . _ADSLIGHT_MODADMIN . '" ></a>');
290
            }
291
        }
292
293
        $result7 = $xoopsDB->query('SELECT nom_type FROM ' . $xoopsDB->prefix('adslight_type') . " WHERE id_type='" . $xoopsDB->escape($type) . "'");
294
        list($nom_type) = $xoopsDB->fetchRow($result7);
295
296
        $result8 = $xoopsDB->query('SELECT nom_price FROM ' . $xoopsDB->prefix('adslight_price') . " WHERE id_price='" . $xoopsDB->escape($typeprice) . "'");
297
        list($nom_price) = $xoopsDB->fetchRow($result8);
298
299
        $result9 = $xoopsDB->query('SELECT nom_usure FROM ' . $xoopsDB->prefix('adslight_usure') . " WHERE id_usure='" . $xoopsDB->escape($typeusure) . "'");
300
        list($nom_usure) = $xoopsDB->fetchRow($result9);
301
302
        $GLOBALS['xoopsTpl']->assign('type', $myts->htmlSpecialChars($nom_type));
303
        $GLOBALS['xoopsTpl']->assign('title', $title);
304
        $GLOBALS['xoopsTpl']->assign('status', $status);
305
        $GLOBALS['xoopsTpl']->assign('desctext', $desctext);
306
        $GLOBALS['xoopsTpl']->assign('xoops_pagetitle', $title . ' - ' . $town . ': ' . $country . ' - ' . $ctitle);
307
308
        // meta description tags for ads
309
        $desctextclean = strip_tags($desctext, '<font><img><strong><i><u>');
310
        $GLOBALS['xoTheme']->addMeta('meta', 'description', "$title - " . substr($desctextclean, 0, 150));
311
312
        if ($price > 0) {
313
            $GLOBALS['xoopsTpl']->assign('price', '<strong>' . _ADSLIGHT_PRICE2 . '</strong>' . $price . ' ' . $GLOBALS['xoopsModuleConfig']['adslight_currency_symbol'] . ' - ' . $typeprice);
314
            $GLOBALS['xoopsTpl']->assign('price_head', _ADSLIGHT_PRICE2);
315
            //      $GLOBALS['xoopsTpl']->assign('price_price', $price.' '.$GLOBALS['xoopsModuleConfig']['adslight_currency_symbol'].' ');
0 ignored issues
show
Unused Code Comprehensibility introduced by
77% 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...
316
317
            $GLOBALS['xoopsTpl']->assign('price_price', Adslight\Utility::getMoneyFormat('%.2n', $price));
318
319
            $GLOBALS['xoopsTpl']->assign('price_typeprice', $myts->htmlSpecialChars($nom_price));
320
            $GLOBALS['xoopsTpl']->assign('price_currency', $GLOBALS['xoopsModuleConfig']['adslight_currency_code']);
321
            $GLOBALS['xoopsTpl']->assign('price_amount', $price);
322
        }
323
324
        $GLOBALS['xoopsTpl']->assign('usure_typeusure', $nom_usure);
325
        $GLOBALS['xoopsTpl']->assign('premium', $premium);
326
327
        // $GLOBALS['xoopsTpl']->assign('mustlogin', _ADSLIGHT_MUSTLOGIN);
0 ignored issues
show
Unused Code Comprehensibility introduced by
72% 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...
328
        $GLOBALS['xoopsTpl']->assign('redirect', '' . '?xoops_redirect=/modules/adslight/index.php');
329
330
        if ($town) {
331
            $GLOBALS['xoopsTpl']->assign('local_town', $town);
332
        }
333
        if (1 == $GLOBALS['xoopsModuleConfig']['adslight_use_country']) {
334
            if ($country) {
335
                $GLOBALS['xoopsTpl']->assign('local_country', $country);
336
                $GLOBALS['xoopsTpl']->assign('country_head', '<img src="assets/images/world_go.png" border="0" alt="country" >&nbsp;&nbsp;' . _ADSLIGHT_COUNTRY);
337
            }
338
        }
339
340
        $tphon = '';
341
        if ($tel) {
342
            $tphon = '<br>' . _ADSLIGHT_ORBY . '&nbsp;<strong>' . _ADSLIGHT_TEL . '</strong> ' . $tel;
343
        }
344
345
        if (1 == $contactby) {
346
            $contact = '<a rel="nofollow" href="contact.php?lid=' . $lid . '">' . _ADSLIGHT_BYMAIL2 . '</a>' . $tphon . '';
347
        }
348
        if (2 == $contactby) {
349
            $contact = $contact_pm . '' . $tphon;
350
        }
351
        if (3 == $contactby) {
352
            $contact = '<a rel="nofollow" href="contact.php?lid=' . $lid . '">' . _ADSLIGHT_BYMAIL2 . '</a>' . $tphon . '<br>' . _ADSLIGHT_ORBY . '' . $contact_pm;
353
        }
354
        if (4 == $contactby) {
355
            $contact = '<br><strong>' . _ADSLIGHT_TEL . '</strong> ' . $tel;
356
        }
357
        // $GLOBALS['xoopsTpl']->assign('contact', $contact);
0 ignored issues
show
Unused Code Comprehensibility introduced by
79% 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...
358
        $GLOBALS['xoopsTpl']->assign('local_head', '<img src="assets/images/house.png" border="0" alt="local_head" >&nbsp;&nbsp;' . _ADSLIGHT_LOCAL);
359
360
        if ($lid) {
361
            if ($sold) {
362
                $GLOBALS['xoopsTpl']->assign('bullinfotext', $sold);
363
            } else {
364
                if ($GLOBALS['xoopsUser']) {
365
                    $GLOBALS['xoopsTpl']->assign('bullinfotext', _ADSLIGHT_CONTACT_SUBMITTER . ' ' . $submitter . ' ' . _ADSLIGHT_CONTACTBY2 . ' ' . $contact);
366
                } else {
367
                    $GLOBALS['xoopsTpl']->assign('bullinfotext', '<span style="color: #de090e;"><b>' . _ADSLIGHT_MUSTLOGIN . '</b></span>');
368
                }
369
            }
370
        }
371
372
        $user_profile = XoopsUser::getUnameFromId($usid);
0 ignored issues
show
The type XoopsUser was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
373
        $GLOBALS['xoopsTpl']->assign('user_profile', '<img src="assets/images/profil.png" border="0" alt="' . _ADSLIGHT_PROFILE . '" >&nbsp;&nbsp;<a rel="nofollow" href="' . XOOPS_URL . '/user.php?usid=' . addslashes($usid) . '">' . _ADSLIGHT_PROFILE . ' ' . $user_profile . '</a>');
374
375
        if ('' != $photo) {
376
            require_once __DIR__ . '/class/pictures.php';
377
378
            $criteria_lid          = new \Criteria('lid', $lid);
0 ignored issues
show
The type Criteria was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
379
            $criteria_uid          = new \Criteria('uid', $usid);
380
            $album_factory         = new PicturesHandler($xoopsDB);
381
            $pictures_object_array = $album_factory->getObjects($criteria_lid, $criteria_uid);
0 ignored issues
show
$criteria_uid of type Criteria is incompatible with the type boolean expected by parameter $id_as_key of PicturesHandler::getObjects(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

381
            $pictures_object_array = $album_factory->getObjects($criteria_lid, /** @scrutinizer ignore-type */ $criteria_uid);
Loading history...
382
            $pictures_number       = $album_factory->getCount($criteria_lid, $criteria_uid);
383
            if (0 == $pictures_number) {
384
                $nopicturesyet = _ADSLIGHT_NOTHINGYET;
385
                $GLOBALS['xoopsTpl']->assign('lang_nopicyet', $nopicturesyet);
386
            } else {
387
388
                /**
389
                 * Lets populate an array with the data from the pictures
390
                 */
391
                $i = 0;
392
                foreach ($pictures_object_array as $picture) {
393
                    $pictures_array[$i]['url']     = $picture->getVar('url', 's');
394
                    $pictures_array[$i]['desc']    = $picture->getVar('title', 's');
395
                    $pictures_array[$i]['cod_img'] = $picture->getVar('cod_img', 's');
396
                    $pictures_array[$i]['lid']     = $picture->getVar('lid', 's');
397
                    $GLOBALS['xoopsTpl']->assign('pics_array', $pictures_array);
398
399
                    ++$i;
400
                }
401
            }
402
            $owner      = new \XoopsUser();
403
            $identifier = $owner->getUnameFromId($usid);
404
            if (1 == $GLOBALS['xoopsModuleConfig']['adslight_lightbox']) {
405
                $header_lightbox = '<link rel="stylesheet" href="' . XOOPS_URL . '/modules/adslight/assets/css/adslight.css" type="text/css" media="all" >
406
<script type="text/javascript" src="assets/lightbox/js/jquery-1.7.2.min.js"></script>
407
<script type="text/javascript" src="assets/lightbox/js/jquery-ui-1.8.18.custom.min"></script>
408
<script type="text/javascript" src="assets/lightbox/js/jquery.smooth-scroll.min.js"></script>
409
<script type="text/javascript" src="assets/lightbox/js/lightbox.js"></script>
410
<link rel="stylesheet" href="assets/css/galery.css" type="text/css" media="screen" >
411
<link rel="stylesheet" type="text/css" media="screen" href="assets/lightbox/css/lightbox.css"></link>';
412
            } else {
413
                $header_lightbox = '<link rel="stylesheet" href="' . XOOPS_URL . '/modules/adslight/assets/css/adslight.css" type="text/css" media="all" >
414
<link rel="stylesheet" href="assets/css/galery.css" type="text/css" media="screen" >';
415
            }
416
417
            $GLOBALS['xoopsTpl']->assign('path_uploads', $GLOBALS['xoopsModuleConfig']['adslight_link_upload']);
418
419
            $GLOBALS['xoopsTpl']->assign('permit', $prem_perm);
420
421
            if ($GLOBALS['xoopsModuleConfig']['active_rewriteurl'] > 0) {
422
                /*  ici le meta Canonicale pour le Rewrite */
423
                $GLOBALS['xoopsTpl']->assign('xoops_module_header', $header_lightbox);
424
            } else {
425
                $GLOBALS['xoopsTpl']->assign('xoops_module_header', $header_lightbox);
426
            }
427
            $GLOBALS['xoopsTpl']->assign('photo', $photo);
428
            $GLOBALS['xoopsTpl']->assign('pic_lid', $pic_lid);
429
            $GLOBALS['xoopsTpl']->assign('pic_owner', $uid_owner);
430
        } else {
431
            $GLOBALS['xoopsTpl']->assign('photo', '');
432
        }
433
        $GLOBALS['xoopsTpl']->assign('date', '<img alt="date" border="0" src="assets/images/date.png" >&nbsp;&nbsp;<strong>' . _ADSLIGHT_DATE2 . ':</strong> ' . $date . '<br><img alt="date_error" border="0" src="assets/images/date_error.png" >&nbsp;&nbsp;<strong>' . _ADSLIGHT_DISPO . ':</strong> ' . $date2);
434
    } else {
435
        $GLOBALS['xoopsTpl']->assign('no_ad', _ADSLIGHT_NOCLAS);
436
    }
437
    $result8 = $xoopsDB->query('SELECT title FROM ' . $xoopsDB->prefix('adslight_categories') . ' WHERE cid=' . $xoopsDB->escape($cid));
438
439
    list($ctitle) = $xoopsDB->fetchRow($result8);
440
    $GLOBALS['xoopsTpl']->assign('friend', '<img src="assets/images/friend.gif" border="0" alt="' . _ADSLIGHT_SENDFRIENDS . '" >&nbsp;&nbsp;<a rel="nofollow" href="sendfriend.php?op=SendFriend&amp;lid=' . $lid . '">' . _ADSLIGHT_SENDFRIENDS . '</a>');
441
442
    $GLOBALS['xoopsTpl']->assign('alerteabus', '<img src="assets/images/error.png" border="0" alt="' . _ADSLIGHT_ALERTEABUS . '" >&nbsp;&nbsp;<a rel="nofollow" href="report-abuse.php?op=ReportAbuse&amp;lid=' . $lid . '">' . _ADSLIGHT_ALERTEABUS . '</a>');
443
444
    $GLOBALS['xoopsTpl']->assign('link_main', '<a href="../adslight/">' . _ADSLIGHT_MAIN . '</a>');
445
    $GLOBALS['xoopsTpl']->assign('link_cat', '<a href="viewcats.php?cid=' . addslashes($cid) . '">' . _ADSLIGHT_GORUB . ' ' . $ctitle . '</a>');
446
447
    $GLOBALS['xoopsTpl']->assign('printA', '<img src="assets/images/print.gif" border="0" alt="' . _ADSLIGHT_PRINT . '" >&nbsp;&nbsp;<a rel="nofollow" href="print.php?op=PrintAd&amp;lid=' . $lid . '">' . _ADSLIGHT_PRINT . '</a>');
448
}
449
450
#  function categorynewgraphic
451
#####################################################
452
/**
453
 * @param $cid
454
 *
455
 * @return string
456
 */
457
function categorynewgraphic($cid)
458
{
459
    global $xoopsDB;
460
461
    $cat_perms  = '';
462
    $categories = Adslight\Utility::getMyItemIds('adslight_view');
463
    if (is_array($categories) && count($categories) > 0) {
464
        $cat_perms .= ' AND cid IN (' . implode(',', $categories) . ') ';
465
    }
466
467
    $newresult = $xoopsDB->query('SELECT date FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE cid=' . $xoopsDB->escape($cid) . ' AND valid = "Yes" ' . $cat_perms . ' ORDER BY DATE DESC LIMIT 1');
468
    list($date) = $xoopsDB->fetchRow($newresult);
469
470
    $newcount  = $GLOBALS['xoopsModuleConfig']['adslight_countday'];
471
    $startdate = (time() - (86400 * $newcount));
472
    if ($startdate < $date) {
473
        return '<img src="' . XOOPS_URL . '/modules/adslight/assets/images/newred.gif" alt="new" >';
0 ignored issues
show
The constant XOOPS_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
474
    }
475
}
476
477
######################################################
478
479
$pa      = Request::getInt('pa', null, 'GET');
480
$lid     = Request::getInt('lid', null, 'GET');
481
$cid     = Request::getInt('cid', null, 'GET');
482
$usid    = Request::getString('usid', '', 'GET');
483
$min     = Request::getInt('min', null, 'GET');
484
$show    = Request::getInt('show', null, 'GET');
485
$orderby = Request::getInt('orderby', null, 'GET');
486
487
switch ($pa) {
488
489
    default:
490
        $GLOBALS['xoopsOption']['template_main'] = 'adslight_item.tpl';
491
492
        viewAds($lid);
493
        break;
494
}
495
include XOOPS_ROOT_PATH . '/footer.php';
496