Completed
Push — master ( 67bb37...e20777 )
by Michael
02:35
created

modify.php (20 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 44 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 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
include_once __DIR__ . '/header.php';
24
$moduleDirName = basename(__DIR__);
25
$main_lang     = '_' . strtoupper($moduleDirName);
26
require_once XOOPS_ROOT_PATH . '/modules/adslight/include/gtickets.php';
27
$myts      = MyTextSanitizer::getInstance();
28
$module_id = $xoopsModule->getVar('mid');
29
30
$groups       = ($GLOBALS['xoopsUser'] instanceof XoopsUser) ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS;
0 ignored issues
show
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...
31
/** @var XoopsGroupPermHandler $gpermHandler */
32
$gpermHandler = xoops_getHandler('groupperm');
33
$perm_itemid  = XoopsRequest::getInt('item_id', 0, 'POST');
34
35
//If no access
36 View Code Duplication
if (!$gpermHandler->checkRight('adslight_submit', $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...
37
    redirect_header(XOOPS_URL . '/modules/adslight/index.php', 3, _NOPERM);
38
}
39
40
/**
41
 * @param $lid
42
 * @param $ok
43
 */
44
function listingDel($lid, $ok)
0 ignored issues
show
The function listingDel() has been defined more than once; this definition is ignored, only the first definition in admin/modify_ads.php (L388-422) 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...
45
{
46
    global $xoopsDB, $xoopsConfig, $xoopsTheme, $xoopsLogger, $moduleDirName, $main_lang;
47
48
    $result = $xoopsDB->query('SELECT usid FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE lid=' . $xoopsDB->escape($lid));
49
    list($usid) = $xoopsDB->fetchRow($result);
50
51
    $result1 = $xoopsDB->query('SELECT url FROM ' . $xoopsDB->prefix('adslight_pictures') . ' WHERE lid=' . $xoopsDB->escape($lid));
52
53
    if ($GLOBALS['xoopsUser']) {
54
        $currentid = $GLOBALS['xoopsUser']->getVar('uid', 'E');
55
        if ($usid == $currentid) {
56
            if ($ok == 1) {
57
                while (list($purl) = $xoopsDB->fetchRow($result1)) {
58
                    if ($purl) {
59
                        $destination = XOOPS_ROOT_PATH . '/uploads/AdsLight';
60
                        if (file_exists("$destination/$purl")) {
61
                            unlink("$destination/$purl");
62
                        }
63
                        $destination2 = XOOPS_ROOT_PATH . '/uploads/AdsLight/thumbs';
64
                        if (file_exists("$destination2/thumb_$purl")) {
65
                            unlink("$destination2/thumb_$purl");
66
                        }
67
                        $destination3 = XOOPS_ROOT_PATH . '/uploads/AdsLight/midsize';
68
                        if (file_exists("$destination3/resized_$purl")) {
69
                            unlink("$destination3/resized_$purl");
70
                        }
71
72
                        $xoopsDB->queryF('DELETE FROM ' . $xoopsDB->prefix('adslight_pictures') . ' WHERE lid=' . $xoopsDB->escape($lid));
73
                    }
74
                }
75
                $xoopsDB->queryF('DELETE FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE lid=' . $xoopsDB->escape($lid));
76
                redirect_header('index.php', 1, _ADSLIGHT_ANNDEL);
77
            } else {
78
                echo "<table width='100%' border='0' cellspacing='1' cellpadding='8'><tr class='bg4'><td valign='top'>\n";
79
                echo '<br><div style="text-align:center">';
80
                echo '<strong>' . _ADSLIGHT_SURDELANN . '</strong></div><br><br>';
81
            }
82
            echo "[ <a href=\"modify.php?op=ListingDel&amp;lid=" . $lid . "&amp;ok=1\">" . _ADSLIGHT_OUI . "</a> | <a href=\"index.php\">" . _ADSLIGHT_NON . '</a> ]<br><br>';
83
            echo '</td></tr></table>';
84
        }
85
    }
86
}
87
88
/**
89
 * @param $r_lid
90
 * @param $ok
91
 */
92
function delReply($r_lid, $ok)
93
{
94
    global $xoopsDB, $xoopsConfig, $xoopsTheme, $xoopsLogger, $moduleDirName, $main_lang;
95
96
    $result = $xoopsDB->query('SELECT l.usid, r.r_lid, r.lid, r.title, r.date, r.submitter, r.message, r.tele, r.email, r.r_usid FROM '
97
                              . $xoopsDB->prefix('adslight_listing')
98
                              . ' l LEFT JOIN '
99
                              . $xoopsDB->prefix('adslight_replies')
100
                              . ' r ON l.lid=r.lid  WHERE r.r_lid='
101
                              . $xoopsDB->escape($r_lid));
102
    list($usid, $r_lid, $rlid, $title, $date, $submitter, $message, $tele, $email, $r_usid) = $xoopsDB->fetchRow($result);
0 ignored issues
show
The assignment to $rlid 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 $title 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 $date 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 $submitter 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 $message 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 $tele 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 $email 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 $r_usid 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...
103
104
    if ($GLOBALS['xoopsUser']) {
105
        $currentid = $GLOBALS['xoopsUser']->getVar('uid', 'E');
106
        if ($usid == $currentid) {
107
            if ($ok == 1) {
108
                $xoopsDB->queryF('DELETE FROM ' . $xoopsDB->prefix('adslight_replies') . ' WHERE r_lid=' . $xoopsDB->escape($r_lid));
109
                redirect_header('members.php?usid=' . addslashes($usid) . '', 1, _ADSLIGHT_ANNDEL);
110
            } else {
111
                echo "<table width='100%' border='0' cellspacing='1' cellpadding='8'><tr class='bg4'><td valign='top'>\n";
112
                echo '<br><div style="text-align:center">';
113
                echo '<strong>' . _ADSLIGHT_SURDELANN . '</strong></div><br><br>';
114
            }
115
            echo "[ <a href=\"modify.php?op=DelReply&amp;r_lid="
116
                 . addslashes($r_lid)
117
                 . "&amp;ok=1\">"
118
                 . _ADSLIGHT_OUI
119
                 . "</a> | <a href=\"members.php?usid="
120
                 . addslashes($usid)
121
                 . "\">"
122
                 . _ADSLIGHT_NON
123
                 . '</a> ]<br><br>';
124
            echo '</td></tr></table>';
125
        }
126
    }
127
}
128
129
/**
130
 * @param $lid
131
 */
132
function modAd($lid)
133
{
134
    global $xoopsDB, $xoopsModule, $xoopsConfig, $xoopsTheme, $myts, $xoopsLogger, $moduleDirName, $main_lang;
135
    $contactselect = '';
136
    include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
137
    include_once XOOPS_ROOT_PATH . '/modules/adslight/class/utilities.php';
138
    echo "<script language=\"javascript\">\nfunction CLA(CLA) { var MainWindow = window.open (CLA, \"_blank\",\"width=500,height=300,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no\");}\n</script>";
139
140
    include_once XOOPS_ROOT_PATH . '/modules/adslight/class/classifiedstree.php';
141
    $mytree = new ClassifiedsTree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid');
142
143
    $result = $xoopsDB->query('SELECT lid, cid, title, status, expire, type, desctext, tel, price, typeprice, typeusure, date, email, submitter, usid, town, country, contactby, premium, valid FROM '
144
                              . $xoopsDB->prefix('adslight_listing')
145
                              . ' WHERE lid='
146
                              . $xoopsDB->escape($lid));
147
    list($lid, $cide, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typeusure, $date, $email, $submitter, $usid, $town, $country, $contactby, $premium, $valid) = $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...
148
149
    $categories = AdslightUtilities::getMyItemIds('adslight_submit');
150 View Code Duplication
    if (is_array($categories) && count($categories) > 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...
151
        if (!in_array($cide, $categories)) {
152
            redirect_header(XOOPS_URL . '/modules/adslight/index.php', 3, _NOPERM);
153
        }
154
    } else {    // User can't see any category
155
        redirect_header(XOOPS_URL . '/index.php', 3, _NOPERM);
156
    }
157
158
159
    if ($GLOBALS['xoopsUser']) {
160
        $calusern = $GLOBALS['xoopsUser']->uid();
161
        if ($usid == $calusern) {
162
            echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _ADSLIGHT_MODIFANN . '</legend><br><br>';
163
            $title      = $myts->htmlSpecialChars($title);
164
            $status     = $myts->htmlSpecialChars($status);
165
            $expire     = $myts->htmlSpecialChars($expire);
166
            $type       = $myts->htmlSpecialChars($type);
167
            $desctext   = $myts->displayTarea($desctext, 1);
168
            $tel        = $myts->htmlSpecialChars($tel);
169
170
//            $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...
171
172
            xoops_load('XoopsLocal');
173
            $tempXoopsLocal = new XoopsLocal;
174
            //  For US currency with 2 numbers after the decimal comment out if you dont want 2 numbers after decimal
175
            $price = $tempXoopsLocal->number_format($price, 2, ',', ' ');
176
            //  For other countries uncomment the below line and comment out the above line
177
            //      $price = $tempXoopsLocal->number_format($price);
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% 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...
178
179
180
            $typeprice  = $myts->htmlSpecialChars($typeprice);
181
            $typeusure  = $myts->htmlSpecialChars($typeusure);
182
            $submitter  = $myts->htmlSpecialChars($submitter);
183
            $town       = $myts->htmlSpecialChars($town);
184
            $country    = $myts->htmlSpecialChars($country);
185
            $contactby  = $myts->htmlSpecialChars($contactby);
186
            $premium    = $myts->htmlSpecialChars($premium);
187
            $useroffset = '';
188 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...
189
                $timezone   = $GLOBALS['xoopsUser']->timezone();
190
                $useroffset = (!empty($timezone)) ? $GLOBALS['xoopsUser']->timezone() : $xoopsConfig['default_TZ'];
191
            }
192
            $dates = ($useroffset * 3600) + $date;
0 ignored issues
show
$dates 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...
193
            $dates = formatTimestamp($date, 's');
194
195
            echo "<form action=\"modify.php\" method=post enctype=\"multipart/form-data\">
196
    <table><tr class=\"head\" border=\"2\">
197
    <td class=\"head\">" . _ADSLIGHT_NUMANNN . " </td><td class=\"head\" border=\"1\">$lid " . _ADSLIGHT_DU . " $dates</td>
198
    </tr><tr>";
199
200
            if ($GLOBALS['xoopsModuleConfig']['adslight_diff_name'] == '1') {
201
                echo "<td class=\"head\">" . _ADSLIGHT_SENDBY . " </td><td class=\"head\"><input type=\"text\" name=\"submitter\" size=\"50\" value=\"$submitter\" /></td>";
202
            } else {
203
                echo "<td class=\"head\">" . _ADSLIGHT_SENDBY . " </td><td class=\"head\"><input type=\"hidden\" name=\"submitter\" value=\"$submitter\">$submitter</td>";
204
            }
205
            echo '</tr><tr>';
206
207
            if (1 == $contactby) {
208
                $contactselect = _ADSLIGHT_CONTACT_BY_EMAIL;
209
            }
210
            if (2 == $contactby) {
211
                $contactselect = _ADSLIGHT_CONTACT_BY_PM;
212
            }
213
            if (3 == $contactby) {
214
                $contactselect = _ADSLIGHT_CONTACT_BY_BOTH;
215
            }
216
            if (4 == $contactby) {
217
                $contactselect = _ADSLIGHT_CONTACT_BY_PHONE;
218
            }
219
220
            echo " <td class='head'>" . _ADSLIGHT_CONTACTBY . " </td><td class='head'><select name=\"contactby\">
221
    <option value=\"" . $contactby . "\">" . $contactselect . "</option>
222
    <option value=\"1\">" . _ADSLIGHT_CONTACT_BY_EMAIL . "</option>
223
    <option value=\"2\">" . _ADSLIGHT_CONTACT_BY_PM . "</option>
224
    <option value=\"3\">" . _ADSLIGHT_CONTACT_BY_BOTH . "</option>
225
    <option value=\"4\">" . _ADSLIGHT_CONTACT_BY_PHONE . '</option></select></td></tr>';
226
227
            if ($GLOBALS['xoopsModuleConfig']['adslight_diff_email'] == '1') {
228
                echo "<tr><td class=\"head\">" . _ADSLIGHT_EMAIL . " </td><td class=\"head\"><input type=\"text\" name=\"email\" size=\"50\" value=\"$email\" /></td>";
229
            } else {
230
                echo "<tr><td class=\"head\">" . _ADSLIGHT_EMAIL . " </td><td class=\"head\">$email<input type=\"hidden\" name=\"email\" value=\"$email\" /></td>";
231
            }
232
            echo "</tr><tr>
233
    <td class=\"head\">" . _ADSLIGHT_TEL . " </td><td class=\"head\"><input type=\"text\" name=\"tel\" size=\"50\" value=\"$tel\" /></td>
234
    </tr>";
235
            echo "<tr>
236
    <td class=\"head\">" . _ADSLIGHT_TOWN . " </td><td class=\"head\"><input type=\"text\" name=\"town\" size=\"50\" value=\"$town\" /></td>
237
    </tr>";
238
            if ($GLOBALS['xoopsModuleConfig']['adslight_use_country'] == '1') {
239
                echo "<tr>
240
    <td class=\"head\">" . _ADSLIGHT_COUNTRY . " </td><td class=\"head\"><input type=\"text\" name=\"country\" size=\"50\" value=\"$country\" /></td>
241
    </tr>";
242
            } else {
243
                echo "<input type=\"hidden\" name=\"country\" value=\"\">";
244
            }
245
246
            echo "<tr><td class='head'>" . _ADSLIGHT_STATUS . "</td><td class='head'><input type=\"radio\" name=\"status\" value=\"0\"";
247
            if ('0' == $status) {
248
                echo 'checked';
249
            }
250
            echo '>' . _ADSLIGHT_ACTIVE . "&nbsp;&nbsp; <input type=\"radio\" name=\"status\" value=\"1\"";
251
            if ('1' == $status) {
252
                echo 'checked';
253
            }
254
            echo '>' . _ADSLIGHT_INACTIVE . "&nbsp;&nbsp; <input type=\"radio\" name=\"status\" value=\"2\"";
255
            if ('2' == $status) {
256
                echo 'checked';
257
            }
258
            echo '>' . _ADSLIGHT_SOLD . '</td></tr>';
259
            echo "<tr>
260
    <td class=\"head\">" . _ADSLIGHT_TITLE2 . " </td><td class=\"head\"><input type=\"text\" name=\"title\" size=\"50\" value=\"$title\" /></td>
261
    </tr>";
262
            echo "<tr><td class=\"head\">"
263
                 . _ADSLIGHT_PRICE2
264
                 . " </td><td class=\"head\"><input type=\"text\" name=\"price\" size=\"20\" value=\"$price\" /> "
265
                 . $GLOBALS['xoopsModuleConfig']['adslight_money'];
266
267
            $result3 = $xoopsDB->query('SELECT nom_price, id_price FROM ' . $xoopsDB->prefix('adslight_price') . ' ORDER BY id_price');
268
            echo " <select name=\"typeprice\">";
269
            while (list($nom_price, $id_price) = $xoopsDB->fetchRow($result3)) {
270
                $sel = '';
271
                if ($id_price == $typeprice) {
272
                    $sel = 'selected';
273
                }
274
                echo "<option value=\"$id_price\" $sel>$nom_price</option>";
275
            }
276
            echo '</select></td></tr>';
277
            $module_id = $xoopsModule->getVar('mid');
278
            $groups    = ($GLOBALS['xoopsUser'] instanceof XoopsUser) ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS;
0 ignored issues
show
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...
279
280
            /** @var XoopsGroupPermHandler $gpermHandler */
281
            $gpermHandler = xoops_getHandler('groupperm');
282
            $perm_itemid  = XoopsRequest::getInt('item_id', 0, 'GET');
283
284
            //If no access
285
            if (!$gpermHandler->checkRight('adslight_premium', $perm_itemid, $groups, $module_id)) {
286
                echo "<tr>
287
    <td width='30%' class='head'>" . _ADSLIGHT_WILL_LAST . " </td><td class='head'>$expire  " . _ADSLIGHT_DAY . '</td>
288
    </tr>';
289
                echo "<input type=\"hidden\" name=\"expire\" value=\"$expire\" />";
290
            } else {
291
                echo "<tr>
292
    <td width='30%' class='head'>" . _ADSLIGHT_HOW_LONG . " </td><td class='head'><input type=\"text\" name=\"expire\" size=\"3\" maxlength=\"3\" value=\"$expire\" />  " . _ADSLIGHT_DAY . '</td>
293
    </tr>';
294
            }
295
296
            /// Type d'annonce
297
            echo "<tr>
298
    <td class=\"head\">" . _ADSLIGHT_TYPE . " </td><td class=\"head\"><select name=\"type\">";
299
300
            $result5 = $xoopsDB->query('SELECT nom_type, id_type FROM ' . $xoopsDB->prefix('adslight_type') . ' ORDER BY nom_type');
301
            while (list($nom_type, $id_type) = $xoopsDB->fetchRow($result5)) {
302
                $sel = '';
303
                if ($id_type == $type) {
304
                    $sel = 'selected';
305
                }
306
                echo "<option value=\"$id_type\" $sel>$nom_type</option>";
307
            }
308
            echo '</select></td></tr>';
309
310
            /// Etat de l'objet
311
            echo "<tr>
312
    <td class=\"head\">" . _ADSLIGHT_TYPE_USURE . " </td><td class=\"head\"><select name=\"typeusure\">";
313
314
            $result6 = $xoopsDB->query('SELECT nom_usure, id_usure FROM ' . $xoopsDB->prefix('adslight_usure') . ' ORDER BY nom_usure');
315
            while (list($nom_usure, $id_usure) = $xoopsDB->fetchRow($result6)) {
316
                $sel = '';
317
                if ($id_usure == $typeusure) {
318
                    $sel = 'selected';
319
                }
320
                echo "<option value=\"$id_usure\" $sel>$nom_usure</option>";
321
            }
322
            echo '</select></td></tr>';
323
324
            echo "<tr>
325
    <td class=\"head\">" . _ADSLIGHT_CAT . " </td><td class=\"head\">";
326
            $mytree->makeMySelBox('title', 'title', $cide, '', 'cid');
327
            echo "</td>
328
    </tr><tr>
329
    <td class=\"head\">" . _ADSLIGHT_DESC . " </td><td class=\"head\">";
330
            $wysiwyg_text_area = AdslightUtilities::getEditor(_ADSLIGHT_DESC, 'desctext', $desctext, '100%', '200px');
331
            echo $wysiwyg_text_area->render();
332
            echo "</td></tr>
333
    <td colspan=2><br><input type=\"submit\" value=\"" . _ADSLIGHT_MODIFANN . "\" /></td>
334
    </tr></table>";
335
            echo "<input type=\"hidden\" name=\"op\" value=\"ModAdS\" />";
336
337
            $module_id = $xoopsModule->getVar('mid');
338 View Code Duplication
            if (is_object($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...
339
                $groups =& $GLOBALS['xoopsUser']->getGroups();
340
            } else {
341
                $groups = XOOPS_GROUP_ANONYMOUS;
342
            }
343
            /** @var XoopsGroupPermHandler $gpermHandler */
344
            $gpermHandler = xoops_getHandler('groupperm');
345
            $perm_itemid = XoopsRequest::getInt('item_id', 0, 'POST');
346
            //If no access
347
            if (!$gpermHandler->checkRight('adslight_premium', $perm_itemid, $groups, $module_id)) {
348
                if ($GLOBALS['xoopsModuleConfig']['adslight_moderated'] == '1') {
349
                    echo "<input type=\"hidden\" name=\"valid\" value=\"No\" />";
350
                    echo '<br>' . _ADSLIGHT_MODIFBEFORE . '<br>';
351
                } else {
352
                    echo "<input type=\"hidden\" name=\"valid\" value=\"Yes\" />";
353
                }
354
            } else {
355
                echo "<input type=\"hidden\" name=\"valid\" value=\"Yes\" />";
356
            }
357
            echo "<input type=\"hidden\" name=\"lid\" value=\"$lid\" />";
358
            echo "<input type=\"hidden\" name=\"premium\" value=\"$premium\" />";
359
            echo "<input type=\"hidden\" name=\"date\" value=\"$date\" />
360
    " . $GLOBALS['xoopsGTicket']->getTicketHtml(__LINE__, 1800, 'token') . '';
361
            echo '</form><br></fieldset><br>';
362
        }
363
    }
364
}
365
366
/**
367
 * @param $lid
368
 * @param $cat
369
 * @param $title
370
 * @param $status
371
 * @param $expire
372
 * @param $type
373
 * @param $desctext
374
 * @param $tel
375
 * @param $price
376
 * @param $typeprice
377
 * @param $typeusure
378
 * @param $date
379
 * @param $email
380
 * @param $submitter
381
 * @param $town
382
 * @param $country
383
 * @param $contactby
384
 * @param $premium
385
 * @param $valid
386
 */
387
function modAdS(
388
    $lid,
389
    $cat,
390
    $title,
391
    $status,
392
    $expire,
393
    $type,
394
    $desctext,
395
    $tel,
396
    $price,
397
    $typeprice,
398
    $typeusure,
399
    $date,
400
    $email,
401
    $submitter,
402
    $town,
403
    $country,
404
    $contactby,
405
    $premium,
406
    $valid
407
) {
408
    global $xoopsDB, $xoopsConfig, $myts, $xoopsLogger, $moduleDirName, $main_lang, $xoopsGTicket;
409
410
    if (!$xoopsGTicket->check(true, 'token')) {
411
        redirect_header(XOOPS_URL . '/modules/adslight/index.php', 3, $xoopsGTicket->getErrors());
412
    }
413
    $title     = $myts->addSlashes($title);
414
    $status    = $myts->addSlashes($status);
415
    $expire    = $myts->addSlashes($expire);
416
    $type      = $myts->addSlashes($type);
417
    $desctext  = $myts->displayTarea($desctext, 1, 1, 1, 1, 1);
418
    $tel       = $myts->addSlashes($tel);
419
    $price     = str_replace(array(' '), '', $price);
420
    $typeprice = $myts->addSlashes($typeprice);
421
    $typeusure = $myts->addSlashes($typeusure);
422
    $submitter = $myts->addSlashes($submitter);
423
    $town      = $myts->addSlashes($town);
424
    $country   = $myts->addSlashes($country);
425
    $contactby = $myts->addSlashes($contactby);
426
    $premium   = $myts->addSlashes($premium);
427
428
    $xoopsDB->query('UPDATE '
429
                    . $xoopsDB->prefix('adslight_listing')
430
                    . " SET cid='$cat', title='$title', status='$status',  expire='$expire', type='$type', desctext='$desctext', tel='$tel', price='$price', typeprice='$typeprice', typeusure='$typeusure', email='$email', submitter='$submitter', town='$town', country='$country', contactby='$contactby', premium='$premium', valid='$valid' WHERE lid=$lid");
431
432
    redirect_header('index.php', 1, _ADSLIGHT_ANNMOD2);
433
}
434
435
####################################################
436
foreach ($_POST as $k => $v) {
437
    ${$k} = $v;
438
}
439
$ok = XoopsRequest::getString('ok', '', 'GET');
440
441
if (!isset($_POST['lid']) && isset($_GET['lid'])) {
442
    $lid = $_GET['lid'];
443
}
444
if (!isset($_POST['r_lid']) && isset($_GET['r_lid'])) {
445
    $r_lid = $_GET['r_lid'];
446
}
447
if (!isset($_POST['op']) && isset($_GET['op'])) {
448
    $op = $_GET['op'];
449
}
450
switch ($op) {
451
452
    case 'ModAd':
453
        include XOOPS_ROOT_PATH . '/header.php';
454
        modAd($lid);
455
        include XOOPS_ROOT_PATH . '/footer.php';
456
        break;
457
458
    case 'ModAdS':
459
        modAdS($lid, $cid, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typeusure, $date, $email, $submitter, $town, $country, $contactby, $premium, $valid);
460
        break;
461
462
    case 'ListingDel':
463
        include XOOPS_ROOT_PATH . '/header.php';
464
        listingDel($lid, $ok);
465
        include XOOPS_ROOT_PATH . '/footer.php';
466
        break;
467
468
    case 'DelReply':
469
        include XOOPS_ROOT_PATH . '/header.php';
470
        delReply($r_lid, $ok);
471
        include XOOPS_ROOT_PATH . '/footer.php';
472
        break;
473
474
    default:
475
        redirect_header('index.php', 1, '' . _RETURNANN);
476
        break;
477
}
478