Passed
Push — master ( 5e790e...222087 )
by Michael
03:14
created
1
<?php
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
$myts = \MyTextSanitizer::getInstance();// MyTextSanitizer object
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...
28
//require XOOPS_ROOT_PATH . '/modules/adslight/include/gtickets.php';
29
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...
30
//require_once __DIR__ . '/include/functions.php';
0 ignored issues
show
Unused Code Comprehensibility introduced by
39% 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...
31
// require_once XOOPS_ROOT_PATH . '/class/captcha/xoopscaptcha.php';
32
33
$module_id = $xoopsModule->getVar('mid');
34
$groups    = ($GLOBALS['xoopsUser'] instanceof \XoopsUser) ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS;
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...
The constant XOOPS_GROUP_ANONYMOUS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
35
/** @var XoopsGroupPermHandler $gpermHandler */
36
$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

36
$gpermHandler = /** @scrutinizer ignore-call */ xoops_getHandler('groupperm');
Loading history...
37
$perm_itemid  = Request::getInt('item_id', 0, 'POST');
38
39
if (!$gpermHandler->checkRight('adslight_submit', $perm_itemid, $groups, $module_id)) {
40
    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

40
    /** @scrutinizer ignore-call */ 
41
    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...
41
}
42
43
$premium = $gpermHandler->checkRight('adslight_premium', $perm_itemid, $groups, $module_id) ? 1 : 0;
44
45
//require_once XOOPS_ROOT_PATH . '/modules/adslight/class/Utility.php';
0 ignored issues
show
Unused Code Comprehensibility introduced by
38% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
46
require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
47
require_once XOOPS_ROOT_PATH . '/modules/adslight/class/classifiedstree.php';
48
$mytree = new Adslight\ClassifiedsTree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid');
49
50
if (!$GLOBALS['xoopsUser'] instanceof \XoopsUser) {
51
    redirect_header(XOOPS_URL . '/user.php', 2, _MA_ADSLIGHT_MUSTREGFIRST);
52
}
53
54
if (Request::hasVar('submit', 'POST')) {
55
    $howlong = $GLOBALS['xoopsModuleConfig']['adslight_howlong'];
56
57
    if (!$GLOBALS['xoopsSecurity']->check(true, $_REQUEST['token'])) {
58
        redirect_header(XOOPS_URL . '/', 3, $GLOBALS['xoopsSecurity']->getErrors());
59
    }
60
61
    //    xoops_load("xoopscaptcha");
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% 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...
62
    //    $xoopsCaptcha = XoopsCaptcha::getInstance();
0 ignored issues
show
Unused Code Comprehensibility introduced by
46% 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...
63
    //    if ( !$xoopsCaptcha->verify() ) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% 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...
64
    //        redirect_header( XOOPS_URL . "/modules/adslight/index.php", 2, $xoopsCaptcha->getMessage() );
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...
65
    //    }
66
    if (Request::hasVar('submit', 'POST')) {
67
        $moduleHandler = xoops_getHandler('module');
68
        $myModule      = $moduleHandler->getByDirname('adslight');
69
        $myModule->setErrors('Could not connect to the database.');
70
    }
71
72
    $cid       = Request::getInt('cid', 0, 'POST');
73
    $cat_perms = Adslight\Utility::getMyItemIds('adslight_submit');
74
    if (!in_array($cid, $cat_perms)) {
75
        redirect_header(XOOPS_URL, 2, _NOPERM);
76
    }
77
78
    $title = Request::getString('title', '', 'POST');
79
    //    $status    = $myts->addSlashes($_POST["status"]);
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% 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...
80
    $status    = (int)$status;
81
    $expire    = Request::getString('expire', '', 'POST');
82
    $type      = Request::getString('type', '', 'POST');
83
    $desctext  = Request::getText('desctext', '', 'POST'); // $myts->displayTarea($_POST['desctext'], 1, 1, 1);
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% 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...
84
    $tel       = Request::getString('tel', '', 'POST');
85
    $price     = str_replace([' '], '', Request::getFloat('price', 0, 'POST'));
86
    $typeprice = Request::getString('typeprice', '', 'POST');
87
    $typeusure = Request::getString('typeusure', '', 'POST');
88
    $date      = Request::getInt('date', 0, 'POST');
89
    $email     = Request::getString('email', '', 'POST');
90
    $submitter = Request::getString('submitter', '', 'POST');
91
    $usid      = Request::getString('usid', '', 'POST');
92
    $town      = Request::getString('town', '', 'POST');
93
    $country   = Request::getString('country', 0, 'POST');
94
    $contactby = Request::getString('contactby', '', 'POST');
95
    $premium   = Request::getString('premium', '', 'POST');
96
    $valid     = Request::getString('valid', '', 'POST');
97
    $date      = time();
98
    $newid     = $xoopsDB->genId($xoopsDB->prefix('adslight_listing') . '_lid_seq');
99
100
    $sql     = sprintf(
101
        "INSERT INTO %s (lid, cid, title, STATUS, EXPIRE, type, desctext, tel, price, typeprice, typeusure, DATE, email, submitter, usid, town, country, contactby, premium, valid) VALUES (%u, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
102
                       $xoopsDB->prefix('adslight_listing'),
103
        $newid,
104
        $cid,
105
        $title,
106
        $status,
107
        $expire,
108
        $type,
109
        $desctext,
110
        $tel,
111
        $price,
112
        $typeprice,
113
        $typeusure,
114
        $date,
115
        $email,
116
        $submitter,
117
        $usid,
118
        $town,
119
        $country,
120
        $contactby,
121
        $premium,
122
        $valid
123
    );
124
    $success = $xoopsDB->query($sql);
125
    if (!$success) {
126
        $moduleHandler = xoops_getHandler('module');
127
        $myModule      = $moduleHandler->getByDirname('adslight');
128
        $myModule->setErrors('Could not query the database.');
129
    }
130
131
    $lid = $xoopsDB->getInsertId();
132
133
    if ('Yes' === $valid) {
134
        /** @var XoopsNotificationHandler $notificationHandler */
135
        $notificationHandler = xoops_getHandler('notification');
136
        //$lid = $xoopsDB->getInsertId();
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% 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...
137
        $tags                    = [];
138
        $tags['TITLE']           = $title;
139
        $tags['ADDED_TO_CAT']    = _ADSLIGHT_ADDED_TO_CAT;
140
        $tags['RECIEVING_NOTIF'] = _ADSLIGHT_RECIEVING_NOTIF;
141
        $tags['ERROR_NOTIF']     = _ADSLIGHT_ERROR_NOTIF;
142
        $tags['WEBMASTER']       = _ADSLIGHT_WEBMASTER;
143
        $tags['HELLO']           = _ADSLIGHT_HELLO;
144
        $tags['FOLLOW_LINK']     = _ADSLIGHT_FOLLOW_LINK;
145
        $tags['TYPE']            = Adslight\Utility::getNameType($type);
146
        $tags['LINK_URL']        = XOOPS_URL . '/modules/adslight/viewads.php?' . '&lid=' . $lid;
147
        $sql                     = 'SELECT title FROM ' . $xoopsDB->prefix('adslight_categories') . ' WHERE cid=' . addslashes($cid);
148
        $result2                 = $xoopsDB->query($sql);
149
        $row                     = $xoopsDB->fetchArray($result2);
150
        $tags['CATEGORY_TITLE']  = $row['title'];
151
        $tags['CATEGORY_URL']    = XOOPS_URL . '/modules/adslight/viewcats.php?cid="' . addslashes($cid);
152
        /** @var XoopsNotificationHandler $notificationHandler */
153
        $notificationHandler = xoops_getHandler('notification');
154
        $notificationHandler->triggerEvent('global', 0, 'new_listing', $tags);
155
        $notificationHandler->triggerEvent('category', $cid, 'new_listing', $tags);
156
        $notificationHandler->triggerEvent('listing', $lid, 'new_listing', $tags);
157
    } else {
158
        $tags                   = [];
159
        $subject                = '' . _ADSLIGHT_NEW_WAITING_SUBJECT . '';
160
        $tags['TITLE']          = $title;
161
        $tags['DESCTEXT']       = $desctext;
162
        $tags['ADMIN']          = _ADSLIGHT_ADMIN;
163
        $tags['NEW_WAITING']    = _ADSLIGHT_NEW_WAITING;
164
        $tags['PLEASE_CHECK']   = _ADSLIGHT_PLEASE_CHECK;
165
        $tags['WEBMASTER']      = _ADSLIGHT_WEBMASTER;
166
        $tags['HELLO']          = _ADSLIGHT_HELLO;
167
        $tags['FOLLOW_LINK']    = _ADSLIGHT_FOLLOW_LINK;
168
        $tags['TYPE']           = Adslight\Utility::getNameType($type);
169
        $tags['NEED_TO_LOGIN']  = _ADSLIGHT_NEED_TO_LOGIN;
170
        $tags['ADMIN_LINK']     = XOOPS_URL . '/modules/adslight/admin/validate_ads.php';
171
        $sql                    = 'SELECT title FROM ' . $xoopsDB->prefix('adslight_categories') . ' WHERE cid=' . addslashes($cid);
172
        $result2                = $xoopsDB->query($sql);
173
        $row                    = $xoopsDB->fetchArray($result2);
174
        $tags['CATEGORY_TITLE'] = $row['title'];
175
        $tags['NEWAD']          = _ADSLIGHT_NEWAD;
176
177
        $mail = xoops_getMailer();
0 ignored issues
show
The function xoops_getMailer 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

177
        $mail = /** @scrutinizer ignore-call */ xoops_getMailer();
Loading history...
178
        //@todo - add check to see if directory (and file) exists, otherwise use english
179
        $mail->setTemplateDir(XOOPS_ROOT_PATH . '/modules/adslight/language/' . $xoopsConfig['language'] . '/mail_template/');
180
        $mail->setTemplate('listing_notify_admin.tpl');
181
        $mail->useMail();
182
        $mail->multimailer->isHTML(true);
183
        $mail->setFromName($xoopsConfig['sitename']);
184
        $mail->setFromEmail($xoopsConfig['adminmail']);
185
        $mail->setToEmails($xoopsConfig['adminmail']);
186
        $mail->setSubject($subject);
187
        $mail->assign($tags);
188
        $mail->send();
189
        echo $mail->getErrors();
190
    }
191
192
    $addphotonow = Request::getInt('addphotonow', 0, 'POST');
193
    if ($addphotonow) {
194
        //$lid = $xoopsDB->getInsertId();
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% 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...
195
        redirect_header("view_photos.php?lid=$lid&uid=$usid", 3, _ADSLIGHT_ADSADDED);
196
    } else {
197
        redirect_header('index.php', 3, _ADSLIGHT_ADSADDED);
198
    }
199
} else {
200
    $GLOBALS['xoopsOption']['template_main'] = 'adslight_addlisting.tpl';
201
    include XOOPS_ROOT_PATH . '/header.php';
202
    require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
203
204
    $cid          = Request::getInt('cide', 0, 'GET');
205
    $cat_moderate = Request::getInt('cat_moderate', 0, 'POST');
206
    $howlong      = $GLOBALS['xoopsModuleConfig']['adslight_howlong'];
207
    $member_usid  = $GLOBALS['xoopsUser']->getVar('uid', 'E');
208
    $member_email = $GLOBALS['xoopsUser']->getVar('email', 'E');
209
    $member_uname = $GLOBALS['xoopsUser']->getVar('uname', 'E');
210
211
    $result  = $xoopsDB->query('SELECT id_type, nom_type FROM ' . $xoopsDB->prefix('adslight_type') . ' ORDER BY nom_type');
212
    $result1 = $xoopsDB->query('SELECT id_price, nom_price FROM ' . $xoopsDB->prefix('adslight_price') . ' ORDER BY id_price');
213
    $result3 = $xoopsDB->query('SELECT id_usure, nom_usure FROM ' . $xoopsDB->prefix('adslight_usure') . ' ORDER BY id_usure');
214
215
    ob_start();
216
    $form = new \XoopsThemeForm(_ADSLIGHT_ADD_LISTING, 'submitform', 'add.php', 'post', true);
0 ignored issues
show
The type XoopsThemeForm 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...
217
    $form->setExtra('enctype="multipart/form-data"');
218
219
    //    $GLOBALS['xoopsGTicket']->addTicketXoopsFormElement($form, __LINE__, 1800, 'token');
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% 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...
220
221
    //@todo - this 'if' code doesn't do anything, what should happen for premium accounts?
222
    if ($cat_moderate) {
223
        if ('0' != $premium) {
224
            echo '';
225
        } else {
226
            echo '';
227
        }
228
    } else {
229
        if ('0' != $premium) {
230
            echo '';
231
        } else {
232
            echo '';
233
        }
234
    }
235
236
    if ('1' == $GLOBALS['xoopsModuleConfig']['adslight_diff_name']) {
237
        $form->addElement(new \XoopsFormText(_ADSLIGHT_SUBMITTER, 'submitter', 50, 50, $member_uname), true);
0 ignored issues
show
The type XoopsFormText 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...
238
    } else {
239
        $form->addElement(new \XoopsFormLabel(_ADSLIGHT_SUBMITTER, $member_uname));
0 ignored issues
show
The type XoopsFormLabel 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...
240
        $form->addElement(new \XoopsFormHidden('submitter', $member_uname), true);
0 ignored issues
show
The type XoopsFormHidden 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...
241
    }
242
    if ('1' == $GLOBALS['xoopsModuleConfig']['adslight_diff_email']) {
243
        $form->addElement(new \XoopsFormText(_ADSLIGHT_EMAIL, 'email', 50, 50, $member_email), true);
244
    } else {
245
        $form->addElement(new \XoopsFormLabel(_ADSLIGHT_EMAIL, $member_email));
246
        $form->addElement(new \XoopsFormHidden('email', $member_email), true);
247
    }
248
    $form->addElement(new \XoopsFormText(_ADSLIGHT_TOWN, 'town', 50, 50, ''), false);
249
    if ('1' == $GLOBALS['xoopsModuleConfig']['adslight_use_country']) {
250
        $form->addElement(new \XoopsFormText(_ADSLIGHT_COUNTRY, 'country', 50, 50, ''), false);
251
    } else {
252
        $form->addElement(new \XoopsFormHidden('country', ''), false);
253
    }
254
    $form->addElement(new \XoopsFormText(_ADSLIGHT_TEL, 'tel', 50, 50, ''), false);
255
256
    // $cat_id = $_GET['cid'];
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% 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...
257
    $cid       = 1;
258
    $cat_perms = Adslight\Utility::getMyItemIds('adslight_submit');
259
    if (is_array($cat_perms) && count($cat_perms) > 0) {
260
        if (!in_array($cid, $cat_perms)) {
261
            redirect_header(XOOPS_URL . '/modules/adslight/index.php', 3, _NOPERM);
262
        }
263
264
        // Category select box
265
        ob_start();
266
        $mytree->makeMySelBox('title', 'title', $cid, 'cid');
0 ignored issues
show
'cid' 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

266
        $mytree->makeMySelBox('title', 'title', $cid, /** @scrutinizer ignore-type */ 'cid');
Loading history...
267
        $form->addElement(new \XoopsFormLabel(_ADSLIGHT_CAT3, ob_get_contents()), true);
268
        ob_end_clean();
269
270
        $category = $xoopsDB->query('SELECT title, cat_moderate FROM ' . $xoopsDB->prefix('adslight_categories') . " WHERE cid='" . $xoopsDB->escape($cid) . "'");
271
272
        list($cat_title, $cat_moderate) = $xoopsDB->fetchRow($category);
273
274
        if ('1' == $premium) {
275
            $radio        = new \XoopsFormRadio(_ADSLIGHT_STATUS, 'status', '');
0 ignored issues
show
The type XoopsFormRadio 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...
276
            $options['0'] = _ADSLIGHT_ACTIVE;
277
            $options['1'] = _ADSLIGHT_INACTIVE;
278
            $radio->addOptionArray($options);
279
            $form->addElement($radio, true);
280
        } else {
281
            $form->addElement(new \XoopsFormHidden('status', '0'), true);
282
        }
283
284
        if (1 == $premium) {
285
            $form->addElement(new \XoopsFormText(_ADSLIGHT_HOW_LONG, 'expire', 3, 3, $GLOBALS['xoopsModuleConfig']['adslight_howlong']), true);
286
        } else {
287
            $form->addElement(new \XoopsFormLabel(_ADSLIGHT_WILL_LAST, $GLOBALS['xoopsModuleConfig']['adslight_howlong']));
288
            $form->addElement(new \XoopsFormHidden('expire', $GLOBALS['xoopsModuleConfig']['adslight_howlong']), false);
289
        }
290
291
        // Type
292
        $type_form = new \XoopsFormSelect(_ADSLIGHT_TYPE, 'type', '', '1');
0 ignored issues
show
The type XoopsFormSelect 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...
293
        while (false !== (list($nom_type, $id_type) = $xoopsDB->fetchRow($result))) {
294
            $type_form->addOption($nom_type, $id_type);
295
        }
296
297
        // State of Object
298
        $usure_form = new \XoopsFormSelect(_ADSLIGHT_TYPE_USURE, 'typeusure', '', '1');
299
        while (false !== (list($nom_usure, $id_usure) = $xoopsDB->fetchRow($result3))) {
300
            $usure_form->addOption($nom_usure, $id_usure);
301
        }
302
303
        $form->addElement($type_form, true);
304
        $form->addElement($usure_form, true);
305
306
        $form->addElement(new \XoopsFormText(_ADSLIGHT_TITLE2, 'title', 40, 50, ''), true);
307
308
        $form->addElement(Adslight\Utility::getEditor(_ADSLIGHT_DESC, 'desctext', '', '100%', 40), true);
309
310
        //        $form->addElement(new \XoopsFormEditor(_ADSLIGHT_DESC, $GLOBALS['xoopsModuleConfig']['adslightEditorUser'], $options, $nohtml = FALSE, $onfailure = 'textarea'));
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% 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...
311
        //        $optionsTrayNote->addElement($bodynote);
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% 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...
312
313
        $form->addElement(new \XoopsFormText(_ADSLIGHT_PRICE2, 'price', 40, 50, ''), true);
314
315
        // Price Type
316
        $sel_form = new \XoopsFormSelect(_ADSLIGHT_PRICETYPE, 'typeprice', '', '1');
317
        while (false !== (list($nom_price, $id_price) = $xoopsDB->fetchRow($result1))) {
318
            $sel_form->addOption($nom_price, $id_price);
319
        }
320
321
        $form->addElement($sel_form);
322
323
        $contactby_form = new \XoopsFormSelect(_ADSLIGHT_CONTACTBY, 'contactby', '', '1');
324
        $contactby_form->addOption(1, _ADSLIGHT_CONTACT_BY_EMAIL);
325
        $contactby_form->addOption(2, _ADSLIGHT_CONTACT_BY_PM);
326
        $contactby_form->addOption(3, _ADSLIGHT_CONTACT_BY_BOTH);
327
        $contactby_form->addOption(4, _ADSLIGHT_CONTACT_BY_PHONE);
328
        $form->addElement($contactby_form, true);
329
        $form->addElement(new \XoopsFormRadioYN(_ADSLIGHT_ADD_PHOTO_NOW, 'addphotonow', 1));
0 ignored issues
show
The type XoopsFormRadioYN 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...
330
        /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% 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...
331
                if ('1' == $GLOBALS['xoopsModuleConfig']["adslight_use_captcha"]) {
332
                    $form->addElement(new \XoopsFormCaptcha(_ADSLIGHT_CAPTCHA, "xoopscaptcha", false), true);
333
                }
334
        */
335
        if ('0' != $premium) {
336
            $form->addElement(new \XoopsFormHidden('premium', 'yes'), false);
337
        } else {
338
            $form->addElement(new \XoopsFormHidden('premium', 'no'), false);
339
        }
340
341
        if ('1' == $cat_moderate) {
342
            $form->addElement(new \XoopsFormHidden('valid', 'No'), false);
343
            $form->addElement(new \XoopsFormHidden('cat_moderate', '1'), false);
344
        } else {
345
            $form->addElement(new \XoopsFormHidden('valid', 'Yes'), false);
346
        }
347
        $form->addElement(new \XoopsFormHidden('usid', $member_usid), false);
348
        $form->addElement(new \XoopsFormHidden('date', time()), false);
349
        $form->addElement(new \XoopsFormButton('', 'submit', _ADSLIGHT_SUBMIT, 'submit'));
0 ignored issues
show
The type XoopsFormButton 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...
350
        $form->display();
351
        $GLOBALS['xoopsTpl']->assign('submit_form', ob_get_contents());
352
        ob_end_clean();
353
    } else {    // User can't see any category
354
        redirect_header(XOOPS_URL . '/index.php', 3, _NOPERM);
355
    }
356
    include XOOPS_ROOT_PATH . '/footer.php';
357
}
358