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