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

modify.php (28 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 47 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
$moduleDirName = basename(__DIR__);
28
$main_lang     = '_' . strtoupper($moduleDirName);
29
//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...
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
$groups = ($GLOBALS['xoopsUser'] instanceof \XoopsUser) ? $GLOBALS['xoopsUser']->getGroups() : 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...
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...
34
/** @var XoopsGroupPermHandler $gpermHandler */
35
$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

35
$gpermHandler = /** @scrutinizer ignore-call */ xoops_getHandler('groupperm');
Loading history...
36
$perm_itemid  = Request::getInt('item_id', 0, 'POST');
37
38
//If no access
39
if (!$gpermHandler->checkRight('adslight_submit', $perm_itemid, $groups, $module_id)) {
40
    redirect_header(XOOPS_URL . '/modules/adslight/index.php', 3, _NOPERM);
0 ignored issues
show
The constant XOOPS_URL 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

40
    /** @scrutinizer ignore-call */ 
41
    redirect_header(XOOPS_URL . '/modules/adslight/index.php', 3, _NOPERM);
Loading history...
The constant _NOPERM was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
41
}
42
43
/**
44
 * @param $lid
45
 * @param $ok
46
 */
47
function listingDel($lid, $ok)
48
{
49
    global $xoopsDB, $xoopsConfig, $xoopsTheme, $xoopsLogger, $moduleDirName, $main_lang;
50
51
    $result = $xoopsDB->query('SELECT usid FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE lid=' . $xoopsDB->escape($lid));
52
    list($usid) = $xoopsDB->fetchRow($result);
53
54
    $result1 = $xoopsDB->query('SELECT url FROM ' . $xoopsDB->prefix('adslight_pictures') . ' WHERE lid=' . $xoopsDB->escape($lid));
55
56
    if ($GLOBALS['xoopsUser']) {
57
        $currentid = $GLOBALS['xoopsUser']->getVar('uid', 'E');
58
        if ($usid == $currentid) {
59
            if (1 == $ok) {
60
                while (false !== (list($purl) = $xoopsDB->fetchRow($result1))) {
61
                    if ($purl) {
62
                        $destination = XOOPS_ROOT_PATH . '/uploads/AdsLight';
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...
63
                        if (file_exists("$destination/$purl")) {
64
                            unlink("$destination/$purl");
65
                        }
66
                        $destination2 = XOOPS_ROOT_PATH . '/uploads/AdsLight/thumbs';
67
                        if (file_exists("$destination2/thumb_$purl")) {
68
                            unlink("$destination2/thumb_$purl");
69
                        }
70
                        $destination3 = XOOPS_ROOT_PATH . '/uploads/AdsLight/midsize';
71
                        if (file_exists("$destination3/resized_$purl")) {
72
                            unlink("$destination3/resized_$purl");
73
                        }
74
75
                        $xoopsDB->queryF('DELETE FROM ' . $xoopsDB->prefix('adslight_pictures') . ' WHERE lid=' . $xoopsDB->escape($lid));
76
                    }
77
                }
78
                $xoopsDB->queryF('DELETE FROM ' . $xoopsDB->prefix('adslight_listing') . ' WHERE lid=' . $xoopsDB->escape($lid));
79
                redirect_header('index.php', 1, _ADSLIGHT_ANNDEL);
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

79
                /** @scrutinizer ignore-call */ 
80
                redirect_header('index.php', 1, _ADSLIGHT_ANNDEL);
Loading history...
80
            } else {
81
                echo "<table width='100%' border='0' cellspacing='1' cellpadding='8'><tr class='bg4'><td valign='top'>\n";
82
                echo '<br><div style="text-align:center">';
83
                echo '<strong>' . _ADSLIGHT_SURDELANN . '</strong></div><br><br>';
84
            }
85
            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>';
86
            echo '</td></tr></table>';
87
        }
88
    }
89
}
90
91
/**
92
 * @param $r_lid
93
 * @param $ok
94
 */
95
function delReply($r_lid, $ok)
96
{
97
    global $xoopsDB, $xoopsConfig, $xoopsTheme, $xoopsLogger, $moduleDirName, $main_lang;
98
99
    $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 ' . $xoopsDB->prefix('adslight_listing') . ' l LEFT JOIN ' . $xoopsDB->prefix('adslight_replies') . ' r ON l.lid=r.lid  WHERE r.r_lid=' . $xoopsDB->escape($r_lid));
100
    list($usid, $r_lid, $rlid, $title, $date, $submitter, $message, $tele, $email, $r_usid) = $xoopsDB->fetchRow($result);
101
102
    if ($GLOBALS['xoopsUser']) {
103
        $currentid = $GLOBALS['xoopsUser']->getVar('uid', 'E');
104
        if ($usid == $currentid) {
105
            if (1 == $ok) {
106
                $xoopsDB->queryF('DELETE FROM ' . $xoopsDB->prefix('adslight_replies') . ' WHERE r_lid=' . $xoopsDB->escape($r_lid));
107
                redirect_header('members.php?usid=' . addslashes($usid) . '', 1, _ADSLIGHT_ANNDEL);
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

107
                /** @scrutinizer ignore-call */ 
108
                redirect_header('members.php?usid=' . addslashes($usid) . '', 1, _ADSLIGHT_ANNDEL);
Loading history...
108
            } else {
109
                echo "<table width='100%' border='0' cellspacing='1' cellpadding='8'><tr class='bg4'><td valign='top'>\n";
110
                echo '<br><div style="text-align:center">';
111
                echo '<strong>' . _ADSLIGHT_SURDELANN . '</strong></div><br><br>';
112
            }
113
            echo '[ <a href="modify.php?op=DelReply&amp;r_lid=' . addslashes($r_lid) . '&amp;ok=1">' . _ADSLIGHT_OUI . '</a> | <a href="members.php?usid=' . addslashes($usid) . '">' . _ADSLIGHT_NON . '</a> ]<br><br>';
114
            echo '</td></tr></table>';
115
        }
116
    }
117
}
118
119
/**
120
 * @param $lid
121
 */
122
function modAd($lid)
123
{
124
    global $xoopsDB, $xoopsModule, $xoopsConfig, $xoopsTheme, $myts, $xoopsLogger, $moduleDirName, $main_lang;
125
    $contactselect = '';
126
    require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.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...
127
    require_once XOOPS_ROOT_PATH . '/modules/adslight/class/Utility.php';
128
    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>";
129
130
    require_once XOOPS_ROOT_PATH . '/modules/adslight/class/classifiedstree.php';
131
    $mytree = new Adslight\ClassifiedsTree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid');
132
133
    $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 ' . $xoopsDB->prefix('adslight_listing') . ' WHERE lid=' . $xoopsDB->escape($lid));
134
    list($lid, $cide, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typeusure, $date, $email, $submitter, $usid, $town, $country, $contactby, $premium, $valid) = $xoopsDB->fetchRow($result);
135
136
    $categories = Adslight\Utility::getMyItemIds('adslight_submit');
137
    if (is_array($categories) && count($categories) > 0) {
138
        if (!in_array($cide, $categories)) {
139
            redirect_header(XOOPS_URL . '/modules/adslight/index.php', 3, _NOPERM);
0 ignored issues
show
The constant XOOPS_URL 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

139
            /** @scrutinizer ignore-call */ 
140
            redirect_header(XOOPS_URL . '/modules/adslight/index.php', 3, _NOPERM);
Loading history...
The constant _NOPERM was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
140
        }
141
    } else {    // User can't see any category
142
        redirect_header(XOOPS_URL . '/index.php', 3, _NOPERM);
143
    }
144
145
    if ($GLOBALS['xoopsUser']) {
146
        $calusern = $GLOBALS['xoopsUser']->uid();
147
        if ($usid == $calusern) {
148
            echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _ADSLIGHT_MODIFANN . '</legend><br><br>';
149
            $title    = $myts->htmlSpecialChars($title);
150
            $status   = $myts->htmlSpecialChars($status);
151
            $expire   = $myts->htmlSpecialChars($expire);
152
            $type     = $myts->htmlSpecialChars($type);
153
            $desctext = $myts->displayTarea($desctext, 1);
154
            $tel      = $myts->htmlSpecialChars($tel);
155
156
            //            $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...
157
158
            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

158
            /** @scrutinizer ignore-call */ 
159
            xoops_load('XoopsLocal');
Loading history...
159
            $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...
160
            //  For US currency with 2 numbers after the decimal comment out if you dont want 2 numbers after decimal
161
            $price = $tempXoopsLocal->number_format($price, 2, ',', ' ');
162
            //  For other countries uncomment the below line and comment out the above line
163
            //      $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...
164
165
            $typeprice  = $myts->htmlSpecialChars($typeprice);
166
            $typeusure  = $myts->htmlSpecialChars($typeusure);
167
            $submitter  = $myts->htmlSpecialChars($submitter);
168
            $town       = $myts->htmlSpecialChars($town);
169
            $country    = $myts->htmlSpecialChars($country);
170
            $contactby  = $myts->htmlSpecialChars($contactby);
171
            $premium    = $myts->htmlSpecialChars($premium);
172
            $useroffset = '';
173
            if ($GLOBALS['xoopsUser']) {
174
                $timezone   = $GLOBALS['xoopsUser']->timezone();
175
                $useroffset = (!empty($timezone)) ? $GLOBALS['xoopsUser']->timezone() : $xoopsConfig['default_TZ'];
176
            }
177
            $dates = ($useroffset * 3600) + $date;
178
            $dates = 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

178
            $dates = /** @scrutinizer ignore-call */ formatTimestamp($date, 's');
Loading history...
179
180
            echo '<form action="modify.php" method=post enctype="multipart/form-data">';
181
            echo $GLOBALS['xoopsSecurity']->getTokenHTML();
182
            echo '<table><tr class="head" border="2">
183
    <td class="head">' . _ADSLIGHT_NUMANNN . " </td><td class=\"head\" border=\"1\">$lid " . _ADSLIGHT_DU . " $dates</td>
184
    </tr><tr>";
185
186
            if ('1' == $GLOBALS['xoopsModuleConfig']['adslight_diff_name']) {
187
                echo '<td class="head">' . _ADSLIGHT_SENDBY . " </td><td class=\"head\"><input type=\"text\" name=\"submitter\" size=\"50\" value=\"$submitter\" ></td>";
188
            } else {
189
                echo '<td class="head">' . _ADSLIGHT_SENDBY . " </td><td class=\"head\"><input type=\"hidden\" name=\"submitter\" value=\"$submitter\">$submitter</td>";
190
            }
191
            echo '</tr><tr>';
192
193
            if (1 == $contactby) {
194
                $contactselect = _ADSLIGHT_CONTACT_BY_EMAIL;
195
            }
196
            if (2 == $contactby) {
197
                $contactselect = _ADSLIGHT_CONTACT_BY_PM;
198
            }
199
            if (3 == $contactby) {
200
                $contactselect = _ADSLIGHT_CONTACT_BY_BOTH;
201
            }
202
            if (4 == $contactby) {
203
                $contactselect = _ADSLIGHT_CONTACT_BY_PHONE;
204
            }
205
206
            echo " <td class='head'>" . _ADSLIGHT_CONTACTBY . " </td><td class='head'><select name=\"contactby\">
207
    <option value=\"" . $contactby . '">' . $contactselect . '</option>
208
    <option value="1">' . _ADSLIGHT_CONTACT_BY_EMAIL . '</option>
209
    <option value="2">' . _ADSLIGHT_CONTACT_BY_PM . '</option>
210
    <option value="3">' . _ADSLIGHT_CONTACT_BY_BOTH . '</option>
211
    <option value="4">' . _ADSLIGHT_CONTACT_BY_PHONE . '</option></select></td></tr>';
212
213
            if ('1' == $GLOBALS['xoopsModuleConfig']['adslight_diff_email']) {
214
                echo '<tr><td class="head">' . _ADSLIGHT_EMAIL . " </td><td class=\"head\"><input type=\"text\" name=\"email\" size=\"50\" value=\"$email\" ></td>";
215
            } else {
216
                echo '<tr><td class="head">' . _ADSLIGHT_EMAIL . " </td><td class=\"head\">$email<input type=\"hidden\" name=\"email\" value=\"$email\" ></td>";
217
            }
218
            echo '</tr><tr>
219
    <td class="head">' . _ADSLIGHT_TEL . " </td><td class=\"head\"><input type=\"text\" name=\"tel\" size=\"50\" value=\"$tel\" ></td>
220
    </tr>";
221
            echo '<tr>
222
    <td class="head">' . _ADSLIGHT_TOWN . " </td><td class=\"head\"><input type=\"text\" name=\"town\" size=\"50\" value=\"$town\" ></td>
223
    </tr>";
224
            if ('1' == $GLOBALS['xoopsModuleConfig']['adslight_use_country']) {
225
                echo '<tr>
226
    <td class="head">' . _ADSLIGHT_COUNTRY . " </td><td class=\"head\"><input type=\"text\" name=\"country\" size=\"50\" value=\"$country\" ></td>
227
    </tr>";
228
            } else {
229
                echo '<input type="hidden" name="country" value="">';
230
            }
231
232
            echo "<tr><td class='head'>" . _ADSLIGHT_STATUS . "</td><td class='head'><input type=\"radio\" name=\"status\" value=\"0\"";
233
            if ('0' == $status) {
234
                echo 'checked';
235
            }
236
            echo '>' . _ADSLIGHT_ACTIVE . '&nbsp;&nbsp; <input type="radio" name="status" value="1"';
237
            if ('1' == $status) {
238
                echo 'checked';
239
            }
240
            echo '>' . _ADSLIGHT_INACTIVE . '&nbsp;&nbsp; <input type="radio" name="status" value="2"';
241
            if ('2' == $status) {
242
                echo 'checked';
243
            }
244
            echo '>' . _ADSLIGHT_SOLD . '</td></tr>';
245
            echo '<tr>
246
    <td class="head">' . _ADSLIGHT_TITLE2 . " </td><td class=\"head\"><input type=\"text\" name=\"title\" size=\"50\" value=\"$title\" ></td>
247
    </tr>";
248
            echo '<tr><td class="head">' . _ADSLIGHT_PRICE2 . " </td><td class=\"head\"><input type=\"text\" name=\"price\" size=\"20\" value=\"$price\" > " . $GLOBALS['xoopsModuleConfig']['adslight_currency_symbol'];
249
250
            $result3 = $xoopsDB->query('SELECT nom_price, id_price FROM ' . $xoopsDB->prefix('adslight_price') . ' ORDER BY id_price');
251
            echo ' <select name="typeprice">';
252
            while (false !== (list($nom_price, $id_price) = $xoopsDB->fetchRow($result3))) {
253
                $sel = '';
254
                if ($id_price == $typeprice) {
255
                    $sel = 'selected';
256
                }
257
                echo "<option value=\"$id_price\" $sel>$nom_price</option>";
258
            }
259
            echo '</select></td></tr>';
260
            $module_id = $xoopsModule->getVar('mid');
261
            $groups    = ($GLOBALS['xoopsUser'] instanceof \XoopsUser) ? $GLOBALS['xoopsUser']->getGroups() : 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...
262
263
            /** @var XoopsGroupPermHandler $gpermHandler */
264
            $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

264
            $gpermHandler = /** @scrutinizer ignore-call */ xoops_getHandler('groupperm');
Loading history...
265
            $perm_itemid  = Request::getInt('item_id', 0, 'GET');
266
267
            //If no access
268
            if (!$gpermHandler->checkRight('adslight_premium', $perm_itemid, $groups, $module_id)) {
269
                echo "<tr>
270
    <td width='30%' class='head'>" . _ADSLIGHT_WILL_LAST . " </td><td class='head'>$expire  " . _ADSLIGHT_DAY . '</td>
271
    </tr>';
272
                echo "<input type=\"hidden\" name=\"expire\" value=\"$expire\" >";
273
            } else {
274
                echo "<tr>
275
    <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>
276
    </tr>';
277
            }
278
279
            /// Type d'annonce
280
            echo '<tr>
281
    <td class="head">' . _ADSLIGHT_TYPE . ' </td><td class="head"><select name="type">';
282
283
            $result5 = $xoopsDB->query('SELECT nom_type, id_type FROM ' . $xoopsDB->prefix('adslight_type') . ' ORDER BY nom_type');
284
            while (false !== (list($nom_type, $id_type) = $xoopsDB->fetchRow($result5))) {
285
                $sel = '';
286
                if ($id_type == $type) {
287
                    $sel = 'selected';
288
                }
289
                echo "<option value=\"$id_type\" $sel>$nom_type</option>";
290
            }
291
            echo '</select></td></tr>';
292
293
            /// Etat de l'objet
294
            echo '<tr>
295
    <td class="head">' . _ADSLIGHT_TYPE_USURE . ' </td><td class="head"><select name="typeusure">';
296
297
            $result6 = $xoopsDB->query('SELECT nom_usure, id_usure FROM ' . $xoopsDB->prefix('adslight_usure') . ' ORDER BY nom_usure');
298
            while (false !== (list($nom_usure, $id_usure) = $xoopsDB->fetchRow($result6))) {
299
                $sel = '';
300
                if ($id_usure == $typeusure) {
301
                    $sel = 'selected';
302
                }
303
                echo "<option value=\"$id_usure\" $sel>$nom_usure</option>";
304
            }
305
            echo '</select></td></tr>';
306
307
            echo '<tr>
308
    <td class="head">' . _ADSLIGHT_CAT . ' </td><td class="head">';
309
            $mytree->makeMySelBox('title', 'title', $cide, '', 'cid');
0 ignored issues
show
'' of type string is incompatible with the type integer expected by parameter $none of XoopsModules\Adslight\Cl...edsTree::makeMySelBox(). ( Ignorable by Annotation )

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

309
            $mytree->makeMySelBox('title', 'title', $cide, /** @scrutinizer ignore-type */ '', 'cid');
Loading history...
310
            echo '</td>
311
    </tr><tr>
312
    <td class="head">' . _ADSLIGHT_DESC . ' </td><td class="head">';
313
            $wysiwyg_text_area = Adslight\Utility::getEditor(_ADSLIGHT_DESC, 'desctext', $desctext, '100%', '200px');
314
            echo $wysiwyg_text_area->render();
315
            echo '</td></tr>
316
    <td colspan=2><br><input type="submit" value="' . _ADSLIGHT_MODIFANN . '" ></td>
317
    </tr></table>';
318
            echo '<input type="hidden" name="op" value="ModAdS" >';
319
320
            $module_id = $xoopsModule->getVar('mid');
321
            if (is_object($GLOBALS['xoopsUser'])) {
322
                $groups =& $GLOBALS['xoopsUser']->getGroups();
323
            } else {
324
                $groups = XOOPS_GROUP_ANONYMOUS;
325
            }
326
            /** @var XoopsGroupPermHandler $gpermHandler */
327
            $gpermHandler = xoops_getHandler('groupperm');
328
            $perm_itemid  = Request::getInt('item_id', 0, 'POST');
329
            //If no access
330
            if (!$gpermHandler->checkRight('adslight_premium', $perm_itemid, $groups, $module_id)) {
331
                if ('1' == $GLOBALS['xoopsModuleConfig']['adslight_moderated']) {
332
                    echo '<input type="hidden" name="valid" value="No" >';
333
                    echo '<br>' . _ADSLIGHT_MODIFBEFORE . '<br>';
334
                } else {
335
                    echo '<input type="hidden" name="valid" value="Yes" >';
336
                }
337
            } else {
338
                echo '<input type="hidden" name="valid" value="Yes" >';
339
            }
340
            echo "<input type=\"hidden\" name=\"lid\" value=\"$lid\" >";
341
            echo "<input type=\"hidden\" name=\"premium\" value=\"$premium\" >";
342
            echo "<input type=\"hidden\" name=\"date\" value=\"$date\" >
343
    " . $GLOBALS['xoopsSecurity']->getTokenHTML('token') . '';
344
            echo '</form><br></fieldset><br>';
345
        }
346
    }
347
}
348
349
/**
350
 * @param $lid
351
 * @param $cat
352
 * @param $title
353
 * @param $status
354
 * @param $expire
355
 * @param $type
356
 * @param $desctext
357
 * @param $tel
358
 * @param $price
359
 * @param $typeprice
360
 * @param $typeusure
361
 * @param $date
362
 * @param $email
363
 * @param $submitter
364
 * @param $town
365
 * @param $country
366
 * @param $contactby
367
 * @param $premium
368
 * @param $valid
369
 */
370
function modAdS($lid, $cat, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typeusure, $date, $email, $submitter, $town, $country, $contactby, $premium, $valid)
371
{
372
    global $xoopsDB, $xoopsConfig, $myts, $xoopsLogger, $moduleDirName, $main_lang;
373
374
    if (!$GLOBALS['xoopsSecurity']->check(true, $_REQUEST['token'])) {
375
        redirect_header(XOOPS_URL . '/modules/adslight/index.php', 3, $GLOBALS['xoopsSecurity']->getErrors());
0 ignored issues
show
The constant XOOPS_URL 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

375
        /** @scrutinizer ignore-call */ 
376
        redirect_header(XOOPS_URL . '/modules/adslight/index.php', 3, $GLOBALS['xoopsSecurity']->getErrors());
Loading history...
376
    }
377
    $title     = $myts->addSlashes($title);
378
    $status    = $myts->addSlashes($status);
379
    $expire    = $myts->addSlashes($expire);
380
    $type      = $myts->addSlashes($type);
381
    $desctext  = $myts->displayTarea($desctext, 1, 1, 1, 1, 1);
382
    $tel       = $myts->addSlashes($tel);
383
    $price     = str_replace([' '], '', $price);
384
    $typeprice = $myts->addSlashes($typeprice);
385
    $typeusure = $myts->addSlashes($typeusure);
386
    $submitter = $myts->addSlashes($submitter);
387
    $town      = $myts->addSlashes($town);
388
    $country   = $myts->addSlashes($country);
389
    $contactby = $myts->addSlashes($contactby);
390
    $premium   = $myts->addSlashes($premium);
391
392
    $xoopsDB->query('UPDATE '
393
                    . $xoopsDB->prefix('adslight_listing')
394
                    . " 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");
395
396
    redirect_header('index.php', 1, _ADSLIGHT_ANNMOD2);
397
}
398
399
####################################################
400
foreach ($_POST as $k => $v) {
401
    ${$k} = $v;
402
}
403
$ok = Request::getString('ok', '', 'GET');
404
405
if (!Request::hasVar('lid', 'POST') && Request::hasVar('lid', 'GET')) {
406
    $lid = Request::getInt('lid', 0, 'GET');
407
}
408
if (!Request::hasVar('r_lid', 'POST') && Request::hasVar('r_lid', 'GET')) {
409
    $r_lid = Request::getInt('r_lid', '', 'GET');
410
}
411
if (!Request::hasVar('op', 'POST') && Request::hasVar('op', 'GET')) {
412
    $op = Request::getString('op', '', 'GET');
413
}
414
switch ($op) {
415
416
    case 'ModAd':
417
        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...
418
        modAd($lid);
419
        include XOOPS_ROOT_PATH . '/footer.php';
420
        break;
421
422
    case 'ModAdS':
423
        modAdS($lid, $cid, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typeusure, $date, $email, $submitter, $town, $country, $contactby, $premium, $valid);
424
        break;
425
426
    case 'ListingDel':
427
        include XOOPS_ROOT_PATH . '/header.php';
428
        listingDel($lid, $ok);
429
        include XOOPS_ROOT_PATH . '/footer.php';
430
        break;
431
432
    case 'DelReply':
433
        include XOOPS_ROOT_PATH . '/header.php';
434
        delReply($r_lid, $ok);
435
        include XOOPS_ROOT_PATH . '/footer.php';
436
        break;
437
438
    default:
439
        redirect_header('index.php', 1, '' . _RETURNANN);
440
        break;
441
}
442