Completed
Branch master (a25b3b)
by Michael
03:43 queued 01:22
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_once __DIR__ . '/include/functions.php';
0 ignored issues
show
Unused Code Comprehensibility introduced by
44% 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 XOOPS_ROOT_PATH."/class/captcha/xoopscaptcha.php";
29
30
$module_id     = $xoopsModule->getVar('mid');
31
$groups        = ($GLOBALS['xoopsUser'] instanceof XoopsUser) ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS;
0 ignored issues
show
The class XoopsUser does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

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