Completed
Branch master (71f789)
by Michael
02:35
created

options.php ➔ listingModUsure()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 34
Code Lines 27

Duplication

Lines 28
Ratio 82.35 %

Importance

Changes 0
Metric Value
cc 1
eloc 27
nc 1
nop 1
dl 28
loc 34
rs 8.8571
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 28 and the first side effect is on line 22.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/*
3
-------------------------------------------------------------------------
4
                     ADSLIGHT 2 : Module for Xoops
5
6
        Redesigned and ameliorate By Luc Bizet user at www.frxoops.org
7
        Started with the Classifieds module and made MANY changes
8
        Website : http://www.luc-bizet.fr
9
        Contact : [email protected]
10
-------------------------------------------------------------------------
11
             Original credits below Version History
12
##########################################################################
13
#                    Classified Module for Xoops                         #
14
#  By John Mordo user jlm69 at www.xoops.org and www.jlmzone.com         #
15
#      Started with the MyAds module and made MANY changes               #
16
##########################################################################
17
 Original Author: Pascal Le Boustouller
18
 Author Website : [email protected]
19
 Licence Type   : GPL
20
-------------------------------------------------------------------------
21
*/
22
include_once __DIR__ . '/admin_header.php';
23
24
$op = XoopsRequest::getCmd('op', 'liste');
25
26
#  function Index
27
#####################################################
28
function index()
0 ignored issues
show
Best Practice introduced by
The function index() has been defined more than once; this definition is ignored, only the first definition in admin/main.php (L29-287) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
29
{
30
    global $xoopsDB, $xoopsConfig, $xoopsModule, $myts, $moduleDirName, $admin_lang;
1 ignored issue
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
31
    include_once __DIR__ . '/header.php';
32
    xoops_cp_header();
33
    //    loadModuleAdminMenu(2, "");
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...
34
    echo $adminObject->addNavigation(basename(__FILE__));
0 ignored issues
show
Bug introduced by
The variable $adminObject does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
35
    // Ajouter un type
36
    echo "<table width='100%' border='0' cellspacing='1' cellpadding='8' style='border: 2px solid #DFE0E0;'><tr class='bg4'><td valign='top'>\n";
37
    echo "<form method=\"post\" action=\"options.php\">
38
        <b>" . _AM_ADSLIGHT_ADDTYPE . '</b><br><br>
39
        ' . _AM_ADSLIGHT_TYPE . "   <input type=\"text\" name=\"type\" size=\"30\" maxlength=\"100\">
40
        <input type=\"hidden\" name=\"op\" value=\"ListingAddType\">
41
        <input type=\"submit\" value=\"" . _AM_ADSLIGHT_ADD . "\">
42
        </form>";
43
    echo '<br>';
44
45
    // Modifier un type
46
    list($numrows) = $xoopsDB->fetchRow($xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_type') . ''));
47 View Code Duplication
    if ($numrows > 0) {
1 ignored issue
show
Duplication introduced by
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...
48
        echo "<form method=\"post\" action=\"options.php\">
49
             <b>" . _AM_ADSLIGHT_MODTYPE . '</b></font><br><br>';
50
        $result2 = $xoopsDB->query('SELECT id_type, nom_type FROM ' . $xoopsDB->prefix('adslight_type') . ' ORDER BY nom_type');
51
        echo '' . _AM_ADSLIGHT_TYPE . " <select name=\"id_type\">";
52
53
        while (list($id_type, $nom_type) = $xoopsDB->fetchRow($result2)) {
54
            $nom_type = $myts->htmlSpecialChars($nom_type);
55
            echo "<option value=\"$id_type\">$nom_type</option>";
56
        }
57
        echo "</select>
58
            <input type=\"hidden\" name=\"op\" value=\"ListingModType\">
59
            <input type=\"submit\" value=\"" . _AM_ADSLIGHT_MODIF . "\">
60
            </form>";
61
        echo '</td></tr></table>';
62
        echo '<br>';
63
    }
64
65
    // Ajouter un type de prix
66
    echo "<table width='100%' border='0' cellspacing='1' cellpadding='8' style='border: 2px solid #DFE0E0;'><tr class='bg4'><td valign='top'>\n";
67
    echo "<form method=\"post\" action=\"options.php\">
68
        <b>" . _AM_ADSLIGHT_ADDPRICE . '</b><br><br>
69
        ' . _AM_ADSLIGHT_TYPE . "   <input type=\"text\" name=\"type\" size=\"30\" maxlength=\"100\">
70
        <input type=\"hidden\" name=\"op\" value=\"ListingAddPrice\">
71
        <input type=\"submit\" value=\"" . _AM_ADSLIGHT_ADD . "\">
72
        </form>";
73
    echo '<br>';
74
75
    // Modifier un type de prix
76
    list($numrows) = $xoopsDB->fetchRow($xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_price') . ''));
77 View Code Duplication
    if ($numrows > 0) {
1 ignored issue
show
Duplication introduced by
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...
78
        echo "<form method=\"post\" action=\"options.php\">
79
            <b>" . _AM_ADSLIGHT_MODPRICE . '</b></font><br><br>';
80
        $result3 = $xoopsDB->query('SELECT id_price, nom_price FROM ' . $xoopsDB->prefix('adslight_price') . ' ORDER BY nom_price');
81
        echo '' . _AM_ADSLIGHT_TYPE . " <select name=\"id_price\">";
82
83
        while (list($id_price, $nom_price) = $xoopsDB->fetchRow($result3)) {
84
            $nom_price = $myts->htmlSpecialChars($nom_price);
85
            echo "<option value=\"$id_price\">$nom_price</option>";
86
        }
87
        echo "</select>
88
            <input type=\"hidden\" name=\"op\" value=\"ListingModPrice\">
89
            <input type=\"submit\" value=\"" . _AM_ADSLIGHT_MODIF . "\">
90
            </form>";
91
        echo '</td></tr></table>';
92
        echo '<br>';
93
    }
94
95
    // Ajouter un type d'usure
96
    echo "<table width='100%' border='0' cellspacing='1' cellpadding='8' style='border: 2px solid #DFE0E0;'><tr class='bg4'><td valign='top'>\n";
97
    echo "<form method=\"post\" action=\"options.php\">
98
        <b>" . _AM_ADSLIGHT_ADDUSURE . '</b><br><br>
99
        ' . _AM_ADSLIGHT_TYPE . "   <input type=\"text\" name=\"type\" size=\"30\" maxlength=\"100\">
100
        <input type=\"hidden\" name=\"op\" value=\"ListingAddUsure\">
101
        <input type=\"submit\" value=\"" . _AM_ADSLIGHT_ADD . "\">
102
        </form>";
103
    echo '<br>';
104
105
    // Modifier un type d'usure
106
    list($numrows) = $xoopsDB->fetchRow($xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_usure') . ''));
107 View Code Duplication
    if ($numrows > 0) {
1 ignored issue
show
Duplication introduced by
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...
108
        echo "<form method=\"post\" action=\"options.php\">
109
            <b>" . _AM_ADSLIGHT_MODUSURE . '</b></font><br><br>';
110
        $result8 = $xoopsDB->query('SELECT id_usure, nom_usure FROM ' . $xoopsDB->prefix('adslight_usure') . ' ORDER BY nom_usure');
111
        echo '' . _AM_ADSLIGHT_TYPE . " <select name=\"id_usure\">";
112
113
        while (list($id_usure, $nom_usure) = $xoopsDB->fetchRow($result8)) {
114
            $nom_usure = $myts->htmlSpecialChars($nom_usure);
115
            echo "<option value=\"$id_usure\">$nom_usure</option>";
116
        }
117
        echo "</select>
118
            <input type=\"hidden\" name=\"op\" value=\"ListingModUsure\">
119
            <input type=\"submit\" value=\"" . _AM_ADSLIGHT_MODIF . "\">
120
            </form>";
121
        echo '</td></tr></table>';
122
        echo '<br>';
123
    }
124
125
    xoops_cp_footer();
126
}
127
128
#  function listingAddType
129
#####################################################
130
/**
131
 * @param $type
132
 */
133 View Code Duplication
function listingAddType($type)
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in 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...
134
{
135
    global $xoopsDB, $xoopsConfig, $myts, $moduleDirName, $admin_lang;
1 ignored issue
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
136
137
    list($numrows) = $xoopsDB->fetchRow($xoopsDB->query('SELECT  COUNT(*)  FROM ' . $xoopsDB->prefix('adslight_type') . " WHERE nom_type='$type'"));
138
    if ($numrows > 0) {
139
        include_once __DIR__ . '/header.php';
140
        xoops_cp_header();
141
        //    loadModuleAdminMenu(2, "");
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...
142
143
        echo "<table width='100%' border='0' cellspacing='1' cellpadding='8' style='border: 2px solid #DFE0E0;'><tr class='bg4'><td valign='top'>\n";
144
        echo '<br><div style="text-align:center;"><b>' . _AM_ADSLIGHT_ERRORTYPE . " $nom_type " . _AM_ADSLIGHT_EXIST . '</b></div><br><br>';
0 ignored issues
show
Bug introduced by
The variable $nom_type does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
145
        echo "<form method=\"post\" action=\"options.php\">
146
            <b>" . _AM_ADSLIGHT_ADDTYPE . '</b><br><br>
147
            ' . _AM_ADSLIGHT_TYPE . "<input type=\"text\" name=\"type\" size=\"30\" maxlength=\"100\" />
148
            <input type=\"hidden\" name=\"op\" value=\"ListingAddType\" />
149
            <input type=\"submit\" value=\"" . _AM_ADSLIGHT_ADD . "\" />
150
            </form>";
151
        echo '</td></tr></table>';
152
        xoops_cp_footer();
153
    } else {
154
        $type = $myts->htmlSpecialChars($type);
155
156
        if ($type == '') {
157
            $type = '! ! ? ! !';
158
        }
159
        $xoopsDB->query('insert into ' . $xoopsDB->prefix('adslight_type') . " values (NULL, '$type')");
160
161
        redirect_header('options.php', 1, _AM_ADSLIGHT_ADDTYPE2);
162
    }
163
}
164
165
#  function listingModType
166
#####################################################
167
/**
168
 * @param $id_type
169
 */
170
function listingModType($id_type)
171
{
172
    global $xoopsDB, $xoopsConfig, $xoopsModule, $myts, $moduleDirName, $admin_lang;
1 ignored issue
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
173
    include_once __DIR__ . '/header.php';
174
    xoops_cp_header();
175
    $id_type = (int)$id_type;
176
    //    loadModuleAdminMenu(2, "");
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...
177
    echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_MODTYPE . '</legend>';
178
    $result = $xoopsDB->query('SELECT id_type, nom_type FROM ' . $xoopsDB->prefix('adslight_type') . " WHERE id_type=$id_type");
179
    list($id_type, $nom_type) = $xoopsDB->fetchRow($result);
180
181
    $nom_type = $myts->htmlSpecialChars($nom_type);
182
183
    echo "<form action=\"options.php\" method=\"post\">"
184
         . ''
185
         . _AM_ADSLIGHT_TYPE
186
         . " <input type=\"text\" name=\"nom_type\" value=\"$nom_type\" size=\"51\" maxlength=\"50\" /><br>"
187
         . "<input type=\"hidden\" name=\"id_type\" value=\"$id_type\" />"
188
         . "<input type=\"hidden\" name=\"op\" value=\"ListingModTypeS\" />"
189
         . "<table border=\"0\"><tr><td>"
190
         . "<input type=\"submit\" value=\""
191
         . _AM_ADSLIGHT_SAVMOD
192
         . "\" /></form>"
193
         . "<form action=\"options.php\" method=\"post\">"
194
         . "<input type=\"hidden\" name=\"id_type\" value=\"$id_type\" />"
195
         . "<input type=\"hidden\" name=\"op\" value=\"ListingDelType\" />"
196
         . "<input type=\"submit\" value=\""
197
         . _AM_ADSLIGHT_DEL
198
         . "\" /></form></td></tr></table>";
199
200
    echo '</td></tr></table>';
201
    xoops_cp_footer();
202
}
203
204
#  function listingModTypeS
205
#####################################################
206
/**
207
 * @param $id_type
208
 * @param $nom_type
209
 */
210 View Code Duplication
function listingModTypeS($id_type, $nom_type)
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in 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...
211
{
212
    global $xoopsDB, $xoopsConfig, $myts, $moduleDirName, $admin_lang;
1 ignored issue
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
213
214
    $id_type  = (int)$id_type;
215
    $nom_type = $myts->htmlSpecialChars($nom_type);
216
217
    $xoopsDB->query('UPDATE ' . $xoopsDB->prefix('adslight_type') . " SET nom_type='$nom_type' WHERE id_type='$id_type'");
218
219
    redirect_header('options.php', 1, _AM_ADSLIGHT_TYPEMOD);
220
}
221
222
#  function listingDelType
223
#####################################################
224
/**
225
 * @param $id_type
226
 */
227 View Code Duplication
function listingDelType($id_type)
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in 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...
228
{
229
    global $xoopsDB, $moduleDirName, $admin_lang;
1 ignored issue
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
230
231
    $id_type = (int)$id_type;
232
233
    $xoopsDB->query('DELETE FROM ' . $xoopsDB->prefix('adslight_type') . " WHERE id_type='$id_type'");
234
235
    redirect_header('options.php', 1, _AM_ADSLIGHT_TYPEDEL);
236
}
237
238
#  function listingAddPrice
239
#####################################################
240
/**
241
 * @param $type
242
 */
243 View Code Duplication
function listingAddPrice($type)
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in 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...
244
{
245
    global $xoopsDB, $xoopsConfig, $myts, $moduleDirName, $admin_lang;
1 ignored issue
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
246
247
    list($numrows) = $xoopsDB->fetchRow($xoopsDB->query('SELECT  COUNT(*)  FROM ' . $xoopsDB->prefix('adslight_price') . " WHERE nom_price='$type'"));
248
    if ($numrows > 0) {
249
        include_once __DIR__ . '/header.php';
250
        xoops_cp_header();
251
        //    loadModuleAdminMenu(2, "");
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...
252
253
        echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_MODANN . '</legend>';
254
        echo '<br><div style="text-align:center;"><b>' . _AM_ADSLIGHT_ERRORPRICE . " $nom_price " . _AM_ADSLIGHT_EXIST . '</b></div><br><br>';
0 ignored issues
show
Bug introduced by
The variable $nom_price does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
255
        echo "<form method=\"post\" action=\"options.php\">
256
            <b>" . _AM_ADSLIGHT_ADDPRICE . '</b><br><br>
257
            ' . _AM_ADSLIGHT_TYPE . "   <input type=\"text\" name=\"type\" size=\"30\" maxlength=\"100\">
258
            <input type=\"hidden\" name=\"op\" value=\"ListingAddPrice\">
259
            <input type=\"submit\" value=\"" . _AM_ADSLIGHT_ADD . "\">
260
            </form>";
261
        echo '</td></tr></table>';
262
        xoops_cp_footer();
263
    } else {
264
        $type = $myts->htmlSpecialChars($type);
265
        if ($type == '') {
266
            $type = '! ! ? ! !';
267
        }
268
        $xoopsDB->query('insert into ' . $xoopsDB->prefix('adslight_price') . " values (NULL, '$type')");
269
270
        redirect_header('options.php', 1, _AM_ADSLIGHT_ADDPRICE2);
271
    }
272
}
273
274
#  function listingModPrice
275
#####################################################
276
/**
277
 * @param $id_price
278
 */
279 View Code Duplication
function listingModPrice($id_price)
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in 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...
280
{
281
    global $xoopsDB, $xoopsConfig, $xoopsModule, $myts, $moduleDirName, $admin_lang;
1 ignored issue
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
282
283
    include_once __DIR__ . '/header.php';
284
    xoops_cp_header();
285
    //    loadModuleAdminMenu(2, "");
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...
286
    echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_MODPRICE . '</legend>';
287
    echo '<b>' . _AM_ADSLIGHT_MODPRICE . '</b><br><br>';
288
    $id_price = (int)$id_price;
289
    $result   = $xoopsDB->query('SELECT nom_price FROM ' . $xoopsDB->prefix('adslight_price') . " WHERE id_price=$id_price");
290
    list($nom_price) = $xoopsDB->fetchRow($result);
291
292
    $nom_price = $myts->htmlSpecialChars($nom_price);
293
294
    echo "<form action=\"options.php\" method=\"post\">"
295
         . ''
296
         . _AM_ADSLIGHT_TYPE
297
         . " <input type=\"text\" name=\"nom_price\" value=\"$nom_price\" size=\"51\" maxlength=\"50\"><br>"
298
         . "<input type=\"hidden\" name=\"id_price\" value=\"$id_price\">"
299
         . "<input type=\"hidden\" name=\"op\" value=\"ListingModPriceS\">"
300
         . "<table border=\"0\"><tr><td>"
301
         . "<input type=\"submit\" value=\""
302
         . _AM_ADSLIGHT_SAVMOD
303
         . "\"></form>"
304
         . "<form action=\"options.php\" method=\"post\">"
305
         . "<input type=\"hidden\" name=\"id_price\" value=\"$id_price\">"
306
         . "<input type=\"hidden\" name=\"op\" value=\"ListingDelPrice\">"
307
         . "<input type=\"submit\" value=\""
308
         . _AM_ADSLIGHT_DEL
309
         . "\"></form></td></tr></table>";
310
311
    echo '</td></tr></table>';
312
    xoops_cp_footer();
313
}
314
315
#  function listingModPriceS
316
#####################################################
317
/**
318
 * @param $id_price
319
 * @param $nom_price
320
 */
321 View Code Duplication
function listingModPriceS($id_price, $nom_price)
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in 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...
322
{
323
    global $xoopsDB, $xoopsConfig, $myts, $moduleDirName, $admin_lang;
1 ignored issue
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
324
325
    $id_price  = (int)$id_price;
326
    $nom_price = $myts->htmlSpecialChars($nom_price);
327
    $xoopsDB->query('UPDATE ' . $xoopsDB->prefix('adslight_price') . " SET nom_price='{$nom_price}' WHERE id_price='{$id_price}'");
328
    redirect_header('options.php', 1, _AM_ADSLIGHT_PRICEMOD);
329
}
330
331
#  function listingDelPrice
332
#####################################################
333
/**
334
 * @param $id_price
335
 */
336 View Code Duplication
function listingDelPrice($id_price)
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in 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...
337
{
338
    global $xoopsDB, $moduleDirName, $admin_lang;
1 ignored issue
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
339
340
    $xoopsDB->query('DELETE FROM ' . $xoopsDB->prefix('adslight_price') . " WHERE id_price='{$id_price}'");
341
    redirect_header('options.php', 1, _AM_ADSLIGHT_PRICEDEL);
342
}
343
344
#  function listingAddUsure
345
#####################################################
346
/**
347
 * @param $type
348
 */
349 View Code Duplication
function listingAddUsure($type)
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in 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...
350
{
351
    global $xoopsDB, $xoopsConfig, $myts, $moduleDirName, $admin_lang;
1 ignored issue
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
352
353
    list($numrows) = $xoopsDB->fetchRow($xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('adslight_usure') . " WHERE nom_usure='$type'"));
354
    if ($numrows > 0) {
355
        include_once __DIR__ . '/header.php';
356
        xoops_cp_header();
357
        //    loadModuleAdminMenu(2, "");
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...
358
359
        echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_MODANN . '</legend>';
360
        echo '<br><div style="text-align:center;"><b>' . _AM_ADSLIGHT_ERRORUSURE . " $nom_usure " . _AM_ADSLIGHT_EXIST . '</b></div><br><br>';
0 ignored issues
show
Bug introduced by
The variable $nom_usure does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
361
        echo "<form method=\"post\" action=\"options.php\">
362
            <b>" . _AM_ADSLIGHT_ADDUSURE . '</b><br><br>
363
            ' . _AM_ADSLIGHT_TYPE . "   <input type=\"text\" name=\"type\" size=\"30\" maxlength=\"100\">
364
            <input type=\"hidden\" name=\"op\" value=\"ListingAddUsure\">
365
            <input type=\"submit\" value=\"" . _AM_ADSLIGHT_ADD . "\">
366
            </form>";
367
        echo '</td></tr></table>';
368
        xoops_cp_footer();
369
    } else {
370
        $type = $myts->htmlSpecialChars($type);
371
        if ('' == $type) {
372
            $type = '! ! ? ! !';
373
        }
374
        $xoopsDB->query('INSERT INTO ' . $xoopsDB->prefix('adslight_usure') . " VALUES (NULL, '$type')");
375
        redirect_header('options.php', 1, _AM_ADSLIGHT_ADDUSURE2);
376
    }
377
}
378
379
#  function listingModUsure
380
#####################################################
381
/**
382
 * @param $id_usure
383
 */
384 View Code Duplication
function listingModUsure($id_usure)
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in 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...
385
{
386
    global $xoopsDB, $xoopsConfig, $xoopsModule, $myts, $moduleDirName, $admin_lang;
1 ignored issue
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
387
388
    include_once __DIR__ . '/header.php';
389
    xoops_cp_header();
390
    //    loadModuleAdminMenu(2, "");
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...
391
    echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_ADSLIGHT_MODUSURE . '</legend>';
392
    echo '<b>' . _AM_ADSLIGHT_MODUSURE . '</b><br><br>';
393
    $result9 = $xoopsDB->query('SELECT nom_usure FROM ' . $xoopsDB->prefix('adslight_usure') . " WHERE id_usure=$id_usure");
394
    list($nom_usure) = $xoopsDB->fetchRow($result9);
395
396
    $nom_usure = $myts->htmlSpecialChars($nom_usure);
397
398
    echo "<form action=\"options.php\" method=\"post\">"
399
         . ''
400
         . _AM_ADSLIGHT_USURE
401
         . " <input type=\"text\" name=\"nom_usure\" value=\"$nom_usure\" size=\"51\" maxlength=\"50\"><br>"
402
         . "<input type=\"hidden\" name=\"id_usure\" value=\"$id_usure\">"
403
         . "<input type=\"hidden\" name=\"op\" value=\"ListingModUsureS\">"
404
         . "<table border=\"0\"><tr><td>"
405
         . "<input type=\"submit\" value=\""
406
         . _AM_ADSLIGHT_SAVMOD
407
         . "\"></form>"
408
         . "<form action=\"options.php\" method=\"post\">"
409
         . "<input type=\"hidden\" name=\"id_usure\" value=\"$id_usure\">"
410
         . "<input type=\"hidden\" name=\"op\" value=\"ListingDelUsure\">"
411
         . "<input type=\"submit\" value=\""
412
         . _AM_ADSLIGHT_DEL
413
         . "\"></form></td></tr></table>";
414
415
    echo '</td></tr></table>';
416
    xoops_cp_footer();
417
}
418
419
#  function listingModUsureS
420
#####################################################
421
/**
422
 * @param $id_usure
423
 * @param $nom_usure
424
 */
425 View Code Duplication
function listingModUsureS($id_usure, $nom_usure)
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in 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...
426
{
427
    global $xoopsDB, $xoopsConfig, $myts, $moduleDirName, $admin_lang;
1 ignored issue
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
428
429
    $nom_usure = $myts->htmlSpecialChars($nom_usure);
430
431
    $xoopsDB->query('UPDATE ' . $xoopsDB->prefix('adslight_usure') . " SET nom_usure='$nom_usure' WHERE id_usure='$id_usure'");
432
433
    redirect_header('options.php', 1, _AM_ADSLIGHT_USUREMOD);
434
}
435
436
#  function listingDelUsure
437
#####################################################
438
/**
439
 * @param $id_usure
440
 */
441 View Code Duplication
function listingDelUsure($id_usure)
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in 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...
442
{
443
    global $xoopsDB, $moduleDirName, $admin_lang;
1 ignored issue
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
444
445
    $id_usure = (int)$id_usure;
446
    $xoopsDB->query('DELETE FROM ' . $xoopsDB->prefix('adslight_usure') . " WHERE id_usure='{$id_usure}'");
447
448
    redirect_header('options.php', 1, _AM_ADSLIGHT_USUREDEL);
449
}
450
451
#####################################################
452
#####################################################
453
//@todo REMOVE THIS ASAP. This code is extremely unsafe
454
foreach ($_POST as $k => $v) {
455
    ${$k} = $v;
456
}
457
458
$pa  = XoopsRequest::getString('pa', '', 'GET');
459
$lid = XoopsRequest::getInt('lid', 0);
460
$op  = XoopsRequest::getCmd('op', '');
461
462
switch ($op) {
463
    case 'ListingDelPrice':
464
        listingDelPrice($id_price);
465
        break;
466
    case 'ListingModPrice':
467
        listingModPrice($id_price);
468
        break;
469
    case 'ListingModPriceS':
470
        listingModPriceS($id_price, $nom_price);
471
        break;
472
    case 'ListingAddPrice':
473
        listingAddPrice($type);
474
        break;
475
    case 'ListingDelUsure':
476
        listingDelUsure($id_usure);
477
        break;
478
    case 'ListingModUsure':
479
        listingModUsure($id_usure);
480
        break;
481
    case 'ListingModUsureS':
482
        listingModUsureS($id_usure, $nom_usure);
483
        break;
484
    case 'ListingAddUsure':
485
        listingAddUsure($type);
486
        break;
487
    case 'ListingDelType':
488
        listingDelType($id_type);
489
        break;
490
    case 'ListingModType':
491
        listingModType($id_type);
492
        break;
493
    case 'ListingModTypeS':
494
        listingModTypeS($id_type, $nom_type);
495
        break;
496
    case 'ListingAddType':
497
        listingAddType($type);
498
        break;
499
    default:
500
        index();
501
        break;
502
}
503