Completed
Push — master ( 38bf19...25ce06 )
by Michael
02:36
created

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
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
$myts = MyTextSanitizer::getInstance();// MyTextSanitizer object
25
require XOOPS_ROOT_PATH . '/modules/adslight/include/gtickets.php';
26
include XOOPS_ROOT_PATH . '/modules/adslight/class/classifiedstree.php';
27
//include XOOPS_ROOT_PATH . '/class/module.errorhandler.php';
0 ignored issues
show
Unused Code Comprehensibility introduced by
40% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
28
//include_once __DIR__ . '/include/functions.php';
29
// include_once XOOPS_ROOT_PATH."/class/captcha/xoopscaptcha.php";
30
31
//@todo replace XOOPS ErrorHander (deprecated)
32
//$erh = new ErrorHandler; //ErrorHandler object
33
34
$module_id     = $xoopsModule->getVar('mid');
35
$groups        = ($xoopsUser instanceof XoopsUser) ? $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...
36
$gperm_handler = xoops_getHandler('groupperm');
37
$perm_itemid   = XoopsRequest::getInt('item_id', 0, 'POST');
38
39
if (!$gperm_handler->checkRight('adslight_submit', $perm_itemid, $groups, $module_id)) {
40
    redirect_header(XOOPS_URL . '/index.php', 3, _NOPERM);
41
}
42
43
$premium = $gperm_handler->checkRight('adslight_premium', $perm_itemid, $groups, $module_id) ? 1 : 0;
44
45
//include_once XOOPS_ROOT_PATH . '/modules/adslight/class/utilities.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
include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
47
include_once XOOPS_ROOT_PATH . '/modules/adslight/class/classifiedstree.php';
48
$mytree = new ClassifiedsTree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid');
49
50
if (!$xoopsUser instanceof XoopsUser) {
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...
51
    redirect_header(XOOPS_URL . '/user.php', 2, _ADS_MUSTREGFIRST);
52
}
53
54
if (!empty($_POST['submit'])) {
55
    $howlong = $xoopsModuleConfig['adslight_howlong'];
56
57
    if (!$xoopsGTicket->check(true, 'token')) {
58
        redirect_header(XOOPS_URL . '/', 3, $xoopsGTicket->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 ('' == XoopsRequest::getString('title', '', 'POST')) {
67
        //@todo - replace this with new error handler
68
//        $erh->show('1001'); //'0001' => 'Could not connect to the forums database.',
69
        $modHandler      = xoops_getModuleHandler('module');
70
        $myModule = $modHandler->getByDirname('adslight');
71
        $myModule->setErrors('Could not connect to the database.');
72
    }
73
74
    $cid       = XoopsRequest::getInt('cid', 0, 'POST');
75
    $cat_perms = AdslightUtilities::getMyItemIds('adslight_submit');
76
    if (!in_array($cid, $cat_perms)) {
77
        redirect_header(XOOPS_URL, 2, _NOPERM);
78
    }
79
80
    $title = $myts->addSlashes($_POST['title']);
81
    //    $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...
82
    $status    = (int)$status;
83
    $expire    = $myts->addSlashes($_POST['expire']);
84
    $type      = $myts->addSlashes($_POST['type']);
85
    $desctext  = $myts->displayTarea($_POST['desctext'], 1, 1, 1);
86
    $tel       = $myts->addSlashes($_POST['tel']);
87
    $price     = str_replace(array(' '), '', $_POST['price']);
88
    $typeprice = $myts->addSlashes($_POST['typeprice']);
89
    $typeusure = $myts->addSlashes($_POST['typeusure']);
90
    $date      = $myts->addSlashes($_POST['date']);
91
    $email     = $myts->addSlashes($_POST['email']);
92
    $submitter = $myts->addSlashes($_POST['submitter']);
93
    $usid      = $myts->addSlashes($_POST['usid']);
94
    $town      = $myts->addSlashes($_POST['town']);
95
    $country   = $myts->addSlashes($_POST['country']);
96
    $contactby = $myts->addSlashes($_POST['contactby']);
97
    $premium   = $myts->addSlashes($_POST['premium']);
98
    $valid     = $myts->addSlashes($_POST['valid']);
99
    $date      = time();
100
    $newid     = $xoopsDB->genId($xoopsDB->prefix('adslight_listing') . '_lid_seq');
101
102
    $sql = sprintf("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')",
103
                   $xoopsDB->prefix('adslight_listing'), $newid, $cid, $title, $status, $expire, $type, $desctext, $tel, $price, $typeprice, $typeusure, $date, $email, $submitter, $usid, $town,
104
                   $country, $contactby, $premium, $valid);
105
    //@todo - replace error handler code below...
106
    // $xoopsDB->query($sql) || $erh->show('0013'); //            '0013' => 'Could not query the database.', // <br>Error: ' . mysql_error() . '',
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...
107
    $success = $xoopsDB->query($sql);
108 View Code Duplication
    if (!$success) {
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...
109
        $modHandler      = xoops_getModuleHandler('module');
110
        $myModule = $modHandler->getByDirname('adslight');
111
        $myModule->setErrors('Could not query the database.');
112
    }
113
114
    $lid = $xoopsDB->getInsertId();
115
116 View Code Duplication
    if ('Yes' === $valid) {
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...
117
        $notification_handler = xoops_getHandler('notification');
118
        //$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...
119
        $tags                    = array();
120
        $tags['TITLE']           = $title;
121
        $tags['ADDED_TO_CAT']    = _ADSLIGHT_ADDED_TO_CAT;
122
        $tags['RECIEVING_NOTIF'] = _ADSLIGHT_RECIEVING_NOTIF;
123
        $tags['ERROR_NOTIF']     = _ADSLIGHT_ERROR_NOTIF;
124
        $tags['WEBMASTER']       = _ADSLIGHT_WEBMASTER;
125
        $tags['HELLO']           = _ADSLIGHT_HELLO;
126
        $tags['FOLLOW_LINK']     = _ADSLIGHT_FOLLOW_LINK;
127
        $tags['TYPE']            = AdslightUtilities::getNameType($type);
128
        $tags['LINK_URL']        = XOOPS_URL . '/modules/adslight/viewads.php?' . '&lid=' . $lid;
129
        $sql                     = 'SELECT title FROM ' . $xoopsDB->prefix('adslight_categories') . ' WHERE cid=' . addslashes($cid);
130
        $result2                 = $xoopsDB->query($sql);
131
        $row                     = $xoopsDB->fetchArray($result2);
132
        $tags['CATEGORY_TITLE']  = $row['title'];
133
        $tags['CATEGORY_URL']    = XOOPS_URL . '/modules/adslight/viewcats.php?cid="' . addslashes($cid);
134
        $notification_handler    = xoops_getHandler('notification');
135
        $notification_handler->triggerEvent('global', 0, 'new_listing', $tags);
136
        $notification_handler->triggerEvent('category', $cid, 'new_listing', $tags);
137
        $notification_handler->triggerEvent('listing', $lid, 'new_listing', $tags);
138
    } else {
139
        $tags                   = array();
140
        $subject                = '' . _ADSLIGHT_NEW_WAITING_SUBJECT . '';
141
        $tags['TITLE']          = $title;
142
        $tags['DESCTEXT']       = $desctext;
143
        $tags['ADMIN']          = _ADSLIGHT_ADMIN;
144
        $tags['NEW_WAITING']    = _ADSLIGHT_NEW_WAITING;
145
        $tags['PLEASE_CHECK']   = _ADSLIGHT_PLEASE_CHECK;
146
        $tags['WEBMASTER']      = _ADSLIGHT_WEBMASTER;
147
        $tags['HELLO']          = _ADSLIGHT_HELLO;
148
        $tags['FOLLOW_LINK']    = _ADSLIGHT_FOLLOW_LINK;
149
        $tags['TYPE']           = AdslightUtilities::getNameType($type);
150
        $tags['NEED_TO_LOGIN']  = _ADSLIGHT_NEED_TO_LOGIN;
151
        $tags['ADMIN_LINK']     = XOOPS_URL . '/modules/adslight/admin/validate_ads.php';
152
        $sql                    = 'SELECT title FROM ' . $xoopsDB->prefix('adslight_categories') . ' WHERE cid=' . addslashes($cid);
153
        $result2                = $xoopsDB->query($sql);
154
        $row                    = $xoopsDB->fetchArray($result2);
155
        $tags['CATEGORY_TITLE'] = $row['title'];
156
        $tags['NEWAD']          = _ADSLIGHT_NEWAD;
157
158
        $mail =& xoops_getMailer();
159
        //@todo - add check to see if directory (and file) exists, otherwise use english
160
        $mail->setTemplateDir(XOOPS_ROOT_PATH . '/modules/adslight/language/' . $xoopsConfig['language'] . '/mail_template/');
161
        $mail->setTemplate('listing_notify_admin.tpl');
162
        $mail->useMail();
163
        $mail->multimailer->isHTML(true);
164
        $mail->setFromName($xoopsConfig['sitename']);
165
        $mail->setFromEmail($xoopsConfig['adminmail']);
166
        $mail->setToEmails($xoopsConfig['adminmail']);
167
        $mail->setSubject($subject);
168
        $mail->assign($tags);
169
        $mail->send();
170
        echo $mail->getErrors();
171
    }
172
173
    $addphotonow = XoopsRequest::getInt('addphotonow', 0, 'POST');
174 View Code Duplication
    if ($addphotonow) {
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...
175
        //$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...
176
        redirect_header("view_photos.php?lid=$lid&uid=$usid", 3, _ADSLIGHT_ADSADDED);
177
    } else {
178
        redirect_header('index.php', 3, _ADSLIGHT_ADSADDED);
179
    }
180
} else {
181
    $GLOBALS['xoopsOption']['template_main'] = 'adslight_addlisting.tpl';
182
    include XOOPS_ROOT_PATH . '/header.php';
183
    include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
184
185
    $cid          = XoopsRequest::getInt('cide', 0, 'GET');
186
    $cat_moderate = XoopsRequest::getInt('cat_moderate', 0, 'POST');
187
    $howlong      = $xoopsModuleConfig['adslight_howlong'];
188
    $member_usid  = $xoopsUser->getVar('uid', 'E');
189
    $member_email = $xoopsUser->getVar('email', 'E');
190
    $member_uname = $xoopsUser->getVar('uname', 'E');
191
192
    $result  = $xoopsDB->query('SELECT id_type, nom_type FROM ' . $xoopsDB->prefix('adslight_type') . ' ORDER BY nom_type');
193
    $result1 = $xoopsDB->query('SELECT id_price, nom_price FROM ' . $xoopsDB->prefix('adslight_price') . ' ORDER BY id_price');
194
    $result3 = $xoopsDB->query('SELECT id_usure, nom_usure FROM ' . $xoopsDB->prefix('adslight_usure') . ' ORDER BY id_usure');
195
196
    ob_start();
197
    $form = new XoopsThemeForm(_ADSLIGHT_ADD_LISTING, 'submitform', 'add.php');
198
    $form->setExtra('enctype="multipart/form-data"');
199
200
    $GLOBALS['xoopsGTicket']->addTicketXoopsFormElement($form, __LINE__, 1800, 'token');
201
202
    //@todo - this "if" code doesn't do anything, what should happen for premium accounts?
203 View Code Duplication
    if ($cat_moderate) {
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...
204
        if ($premium != '0') {
205
            echo '';
206
        } else {
207
            echo '';
208
        }
209
    } else {
210
        if ($premium != '0') {
211
            echo '';
212
        } else {
213
            echo '';
214
        }
215
    }
216
217 View Code Duplication
    if ('1' == $xoopsModuleConfig['adslight_diff_name']) {
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...
218
        $form->addElement(new XoopsFormText(_ADSLIGHT_SUBMITTER, 'submitter', 50, 50, $member_uname), true);
219
    } else {
220
        $form->addElement(new XoopsFormLabel(_ADSLIGHT_SUBMITTER, $member_uname));
221
        $form->addElement(new XoopsFormHidden('submitter', $member_uname), true);
222
    }
223 View Code Duplication
    if ('1' == $xoopsModuleConfig['adslight_diff_email']) {
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...
224
        $form->addElement(new XoopsFormText(_ADSLIGHT_EMAIL, 'email', 50, 50, $member_email), true);
225
    } else {
226
        $form->addElement(new XoopsFormLabel(_ADSLIGHT_EMAIL, $member_email));
227
        $form->addElement(new XoopsFormHidden('email', $member_email), true);
228
    }
229
    $form->addElement(new XoopsFormText(_ADSLIGHT_TOWN, 'town', 50, 50, ''), false);
230 View Code Duplication
    if ('1' == $xoopsModuleConfig['adslight_use_country']) {
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...
231
        $form->addElement(new XoopsFormText(_ADSLIGHT_COUNTRY, 'country', 50, 50, ''), false);
232
    } else {
233
        $form->addElement(new XoopsFormHidden('country', ''), false);
234
    }
235
    $form->addElement(new XoopsFormText(_ADSLIGHT_TEL, 'tel', 50, 50, ''), false);
236
237
    // $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...
238
    $cid       = 1;
239
    $cat_perms = AdslightUtilities::getMyItemIds('adslight_submit');
240
    if (is_array($cat_perms) && count($cat_perms) > 0) {
241
        if (!in_array($cid, $cat_perms)) {
242
            redirect_header(XOOPS_URL . '/modules/adslight/index.php', 3, _NOPERM);
243
        }
244
245
        // Category select box
246
        ob_start();
247
        $mytree->makeMySelBox('title', 'title', $cid, 'cid');
248
        $form->addElement(new XoopsFormLabel(_ADSLIGHT_CAT3, ob_get_contents()), true);
249
        ob_end_clean();
250
251
        $category = $xoopsDB->query('SELECT title, cat_moderate FROM ' . $xoopsDB->prefix('adslight_categories') . ' WHERE cid=' . $xoopsDB->escape($cid) . '');
252
253
        list($cat_title, $cat_moderate) = $xoopsDB->fetchRow($category);
254
255 View Code Duplication
        if ('1' == $premium) {
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...
256
            $radio        = new XoopsFormRadio(_ADSLIGHT_STATUS, 'status', '');
257
            $options['0'] = _ADSLIGHT_ACTIVE;
258
            $options['1'] = _ADSLIGHT_INACTIVE;
259
            $radio->addOptionArray($options);
260
            $form->addElement($radio, true);
261
        } else {
262
            $form->addElement(new XoopsFormHidden('status', '0'), true);
263
        }
264
265 View Code Duplication
        if ($premium == 1) {
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...
266
            $form->addElement(new XoopsFormText(_ADSLIGHT_HOW_LONG, 'expire', 3, 3, $xoopsModuleConfig['adslight_howlong']), true);
267
        } else {
268
            $form->addElement(new XoopsFormLabel(_ADSLIGHT_WILL_LAST, $xoopsModuleConfig['adslight_howlong']));
269
            $form->addElement(new XoopsFormHidden('expire', $xoopsModuleConfig['adslight_howlong']), false);
270
        }
271
272
        // Type
273
        $type_form = new XoopsFormSelect(_ADSLIGHT_TYPE, 'type', '', '1');
274
        while (list($nom_type, $id_type) = $xoopsDB->fetchRow($result)) {
275
            $type_form->addOption($nom_type, $id_type);
276
        }
277
278
        // State of Object
279
        $usure_form = new XoopsFormSelect(_ADSLIGHT_TYPE_USURE, 'typeusure', '', '1');
280
        while (list($nom_usure, $id_usure) = $xoopsDB->fetchRow($result3)) {
281
            $usure_form->addOption($nom_usure, $id_usure);
282
        }
283
284
        $form->addElement($type_form, true);
285
        $form->addElement($usure_form, true);
286
287
        $form->addElement(new XoopsFormText(_ADSLIGHT_TITLE2, 'title', 40, 50, ''), true);
288
289
        $form->addElement(AdslightUtilities::getEditor(_ADSLIGHT_DESC, 'desctext', '', '100%', 40), true);
290
291
//        $form->addElement(new XoopsFormEditor(_ADSLIGHT_DESC, $xoopsModuleConfig['adslightEditorUser'], $options, $nohtml = FALSE, $onfailure = 'textarea'));
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...
292
//        $optionsTrayNote->addElement($bodynote);
293
294
295
        $form->addElement(new XoopsFormText(_ADSLIGHT_PRICE2, 'price', 40, 50, ''), true);
296
297
        // Price Type
298
        $sel_form = new XoopsFormSelect(_ADSLIGHT_PRICETYPE, 'typeprice', '', '1');
299
        while (list($nom_price, $id_price) = $xoopsDB->fetchRow($result1)) {
300
            $sel_form->addOption($nom_price, $id_price);
301
        }
302
303
        $form->addElement($sel_form);
304
305
        $contactby_form = new XoopsFormSelect(_ADSLIGHT_CONTACTBY, 'contactby', '', '1');
306
        $contactby_form->addOption(1, _ADSLIGHT_CONTACT_BY_EMAIL);
307
        $contactby_form->addOption(2, _ADSLIGHT_CONTACT_BY_PM);
308
        $contactby_form->addOption(3, _ADSLIGHT_CONTACT_BY_BOTH);
309
        $contactby_form->addOption(4, _ADSLIGHT_CONTACT_BY_PHONE);
310
        $form->addElement($contactby_form, true);
311
        $form->addElement(new XoopsFormRadioYN(_ADSLIGHT_ADD_PHOTO_NOW, 'addphotonow', 1));
312
        /*
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...
313
                if ('1' == $xoopsModuleConfig["adslight_use_captcha"]) {
314
                    $form->addElement(new XoopsFormCaptcha(_ADSLIGHT_CAPTCHA, "xoopscaptcha", false), true);
315
                }
316
        */
317 View Code Duplication
        if ('0' != $premium) {
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...
318
            $form->addElement(new XoopsFormHidden('premium', 'yes'), false);
319
        } else {
320
            $form->addElement(new XoopsFormHidden('premium', 'no'), false);
321
        }
322
323 View Code Duplication
        if ('1' == $cat_moderate) {
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...
324
            $form->addElement(new XoopsFormHidden('valid', 'No'), false);
325
            $form->addElement(new XoopsFormHidden('cat_moderate', '1'), false);
326
        } else {
327
            $form->addElement(new XoopsFormHidden('valid', 'Yes'), false);
328
        }
329
        $form->addElement(new XoopsFormHidden('usid', $member_usid), false);
330
        $form->addElement(new XoopsFormHidden('date', time()), false);
331
        $form->addElement(new XoopsFormButton('', 'submit', _ADSLIGHT_SUBMIT, 'submit'));
332
        $form->display();
333
        $xoopsTpl->assign('submit_form', ob_get_contents());
334
        ob_end_clean();
335
    } else {    // User can't see any category
336
        redirect_header(XOOPS_URL . '/index.php', 3, _NOPERM);
337
    }
338
    include XOOPS_ROOT_PATH . '/footer.php';
339
}
340