Passed
Push — master ( df5caf...cd5737 )
by Michael
02:02
created

main.php ➔ index()   F

Complexity

Conditions 42
Paths > 20000

Size

Total Lines 259
Code Lines 176

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 42
eloc 176
nc 26426400
nop 0
dl 0
loc 259
rs 2
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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 31 and the first side effect is on line 25.

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
23
use Xmf\Request;
0 ignored issues
show
Bug introduced by
The type Xmf\Request was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
24
25
require_once __DIR__ . '/admin_header.php';
26
27
$op = Request::getString('op', 'liste');
28
29
#  function Index
30
#####################################################
31
function index()
32
{
33
    global $xoopsDB, $xoopsConfig, $xoopsModule, $myts, $desctext, $moduleDirName;
34
    //    require_once XOOPS_ROOT_PATH."/modules/adslight/class/classifiedstree.php";
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% 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...
35
    $mytree = new ClassifiedsTree($xoopsDB->prefix('adslight_categories'), 'cid', 'pid');
0 ignored issues
show
Bug introduced by
The type ClassifiedsTree was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
Unused Code introduced by
The assignment to $mytree is dead and can be removed.
Loading history...
36
37
    //    require_once __DIR__ . '/admin_header.php';
0 ignored issues
show
Unused Code Comprehensibility introduced by
45% 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...
38
    //  require_once("adsligh_rsslib.php");
0 ignored issues
show
Unused Code Comprehensibility introduced by
84% 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...
39
40
    xoops_cp_header();
0 ignored issues
show
Bug introduced by
The function xoops_cp_header was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

40
    /** @scrutinizer ignore-call */ 
41
    xoops_cp_header();
Loading history...
41
    //    loadModuleAdminMenu(0, "");
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...
42
43
    echo "<table width=\"50%\" border=\"0\" cellspacing=\"8\" cellpadding=\"0\">\n" . "  <tr>\n" . '    <td class="top">';
44
45
    /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
47% of this comment could be valid code. Did you maybe forget this after debugging?

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

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

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

Loading history...
46
    /// Test Release ///
47
    $resultat_site = "http://www.i-luc.fr/release/release.html";
48
    $page1 = implode("", file("$resultat_site"));
49
    if (preg_match("1.07",$page1)) { echo "<table class='outer' border=0 cellspacing=5 cellpadding=0><tr><td width=40>";
50
      echo "<img src='../assets/images/admin/info_button_32.png' border=0 alt=\"._AM_ADSLIGHT_RELEASEOK.\" ></td><td>";
51
      echo "<span style='color: #00B4C4'><b>"._AM_ADSLIGHT_RELEASEOK."- AdsLigh 1.07</b></span>";
52
      echo "</td></tr></table><br>";
53
54
    } else {
55
56
      echo "<table class='outer' border=0 cellspacing=5 cellpadding=0><tr><td width=40>";
57
      echo "<img src='../assets/images/admin/error_button_32.png' border=0 alt=\"._AM_ADSLIGHT_RELEASEDOWNLOAD.\" ></td><td>";
58
      echo "<span style='color: #FE0101'><b>"._AM_ADSLIGHT_RELEASEISNOTOK."</b></span><br>";
59
      echo "<a href='http://www.i-luc.fr/adslight/modules/TDMDownloads/visit.php?cid=1&lid=3'>"._AM_ADSLIGHT_RELEASEDOWNLOAD." > AdsLight 1.08</a></td></tr></table><br>";
60
61
      }
62
      */
63
64
    ///////// Il y a [..] Annonces en attente d'être approuvées //////
65
    $result  = $xoopsDB->query('SELECT lid FROM ' . $xoopsDB->prefix('adslight_listing') . " WHERE valid='No'");
66
    $numrows = $xoopsDB->getRowsNum($result);
67
    if ($numrows > 0) {
68
        echo "<table class='outer' border=0 cellspacing=5 cellpadding=0><tr><td width=40>";
69
        echo "<img src='../assets/images/admin/error_button.png' border=0 ></td><td>";
70
        echo "<span style='color:#00B4C4;'><b>" . _AM_ADSLIGHT_THEREIS . "</b></span> <b>$numrows</b> <span style='color:#00B4C4;'>" . _AM_ADSLIGHT_WAIT . '</b></span>';
71
        echo '</td></tr></table><br>';
72
    } else {
73
        echo "<table class='outer' width='50%' border='0'><tr><td width=40>";
74
        echo "<img src='../assets/images/admin/search_button_green_32.png' border=0 alt=\"._AM_ADSLIGHT_RELEASEOK.\" ></td><td>";
75
        echo "<span style='color: #00B4C4;'><b>" . _AM_ADSLIGHT_NOANNVAL . '</b></span>';
76
        echo '</td></tr></table><br>';
77
    }
78
79
    //// Center menu
80
81
    /// Annonces
82
83
    echo '<table width="50%" border="0" class="outer">
84
                  <tr><th align="left">' . _AM_ADSLIGHT_ADSMENU_TITLE . '</th></tr>
85
86
                 <tr class="odd"><td><img src="../assets/images/admin/report_go.png" border=0 >
87
                  <a href="' . XOOPS_URL . '/modules/adslight/admin/validate_ads.php">' . _AM_ADSLIGHT_ADSMENU_VALIDADS . '</a>
0 ignored issues
show
Bug introduced by
The constant XOOPS_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
88
                  </td></tr>
89
90
                 <tr class="even"><td><img src="../assets/images/admin/report_magnify.png" border=0 >
91
                  <a href="' . XOOPS_URL . '/modules/adslight/admin/view_ads.php">' . _AM_ADSLIGHT_ADSMENU_VIEWADS . '</a>
92
                  </td></tr>
93
94
                  <tr class="odd"><td><img src="../assets/images/admin/report_add.png" border=0 >
95
                  <a href="' . XOOPS_URL . '/modules/adslight/admin/modify_ads.php">' . _AM_ADSLIGHT_ADS_MODIFADS . '</a>
96
                  </td></tr>
97
98
              </table><br>';
99
100
    echo '<table width="50%" border="0" class="outer">
101
                  <tr colspan="2"><th align="left">' . _AM_ADSLIGHT_ADSMENU_PLUGIN . '</th></tr>
102
103
                 <tr class="odd">
104
                 <td>
105
                 <strong>Plugin Waiting Module :</strong> <a href="http://sourceforge.net/projects/adslight/files/Plugins%20AdsLight/Plugin%20Waiting%20Module/">Download</a><br><br>
106
                 <strong>Plugin Sitemap Module :</strong> <a href="http://sourceforge.net/projects/adslight/files/Plugins%20AdsLight/Plugin%20Sitemap%20Module/">Download</a><br><br>
107
                <strong>Plugin Waiting Rssfit :</strong> <a href="http://sourceforge.net/projects/adslight/files/Plugins%20AdsLight/Plugin%20Waiting%20Rssfit/">Download</a><br><br>
108
                <strong>Plugin Xpayment :</strong> <a href="https://sourceforge.net/projects/adslight/files/Plugins%20AdsLight/Plugin%20xpayment%20Module/">Download</a><br><br>
109
                 </td>
110
                  </tr>
111
                  <tr class="even">
112
                 <td>
113
                 <a href="mailto:[email protected]?subject=Plugin for AdsLight">' . _AM_ADSLIGHT_SEND_PLUGIN . '</a> |
114
                 <a href="mailto:[email protected]?subject=Translation for AdsLight">' . _AM_ADSLIGHT_SEND_TRANSLATION . '</a>
115
                 </td>
116
                  </tr>
117
118
                  </table><br>';
119
120
    echo '<table width="50%" border="0" class="outer">
121
                  <tr colspan="2"><th align="left">' . _AM_ADSLIGHT_ADSMENU_NEW . '</th></tr>
122
123
                 <tr class="odd">
124
                 <td>' . _AM_ADSLIGHT_ADSMENU_NEWTXT . '</td>
125
126
                  </tr>
127
                  </table><br>';
128
129
    /*
130
 ////   RSS AdsLight Forum
131
132
          echo '<table width="50%" border="0" class="outer">
133
                  <tr><th align="left">'._AM_ADSLIGHT_MENURSSFORUM_TITLE.'</th></tr>
134
                  <tr class="even"><td width="300">';
135
136
137
    $url = _AM_ADSLIGHT_MENURSSFORUM_URL;
138
          echo RSS_DisplayForum($url, 5, false, true);
139
140
141
          echo '</td></tr>
142
                  <tr class="odd"><td><img src="../assets/images/admin/user_go.png" border=0 >
143
                  <a href="'._AM_ADSLIGHT_MENURSSFORUM_LINK1.'">'._AM_ADSLIGHT_MENURSSFORUM_GOFORUM.'</a>  |
144
145
                  <img src="../assets/images/admin/vcard_add.png" border=0 >
146
                  <a href="'._AM_ADSLIGHT_MENURSSFORUM_LINK2.'">'._AM_ADSLIGHT_MENURSSFORUM_SUBSCRIT.'</a>  |
147
                  </td></tr>
148
                  </table>';
149
150
 ////   RSS AdsLight News
151
152
        echo '<table width="50%" border="0" class="outer">
153
                <tr><th align="left">'._AM_ADSLIGHT_MENURSS_TITLE.'</th></tr>';
154
155
                  $url = "http://www.i-luc.fr/adslight/backend.php";
156
        echo RSS_Display($url, 3, false, true);
157
158
159
            echo '</table><br>
160
161
*/
162
    echo '</td>
163
          <td valign="top">';
164
165
    ////// Right Menu Admin
166
167
    /// Statistiques
168
    $Num1 = $xoopsDB->getRowsNum($xoopsDB->query('SELECT * FROM ' . $xoopsDB->prefix('adslight_listing') . "  WHERE (valid='Yes' AND status!='1')"));
169
    $Num2 = $xoopsDB->getRowsNum($xoopsDB->query('SELECT * FROM ' . $xoopsDB->prefix('adslight_categories') . ''));
170
    $Num3 = $xoopsDB->getRowsNum($xoopsDB->query('SELECT * FROM ' . $xoopsDB->prefix('users') . "  WHERE (level = '1')"));
171
    $Num4 = $xoopsDB->getRowsNum($xoopsDB->query('SELECT * FROM ' . $xoopsDB->prefix('xoopscomments') . "  WHERE (com_status = '2')"));
172
173
    echo '<table width=100 border="0" class="outer"><tr>
174
                <th align="left">' . _AM_ADSLIGHT_STAT_TITLE . '</th></tr>
175
176
                  <tr class="odd"><td>
177
                  <b>' . $Num1 . '</b> ' . _AM_ADSLIGHT_STAT_NUM1 . '
178
                  </td></tr>
179
180
181
                 <tr class="even"><td>
182
                 <b>' . $Num2 . '</b> ' . _AM_ADSLIGHT_STAT_NUM2 . '
183
                 </td></tr>
184
185
                  <tr class="odd"><td>
186
                  <b>' . $Num3 . '</b> ' . _AM_ADSLIGHT_STAT_NUM3 . '
187
                  </td></tr>
188
189
                 <tr class="odd"><td>
190
                 <b>' . $Num4 . '</b> ' . _AM_ADSLIGHT_STAT_NUM4 . '
191
                 </td></tr>
192
193
                  </table><br>';
194
195
    /// Menu Catégories
196
    echo '<table width=100 border="0" class="outer"><tr>
197
                   <th width="50%" align="left">' . _AM_ADSLIGHT_CATMENU_TITLE . '</th></tr>
198
199
                  <tr class="odd"><td><img src="../assets/images/admin/chart_organisation_add.png" border=0 >
200
                  <a href="' . XOOPS_URL . '/modules/adslight/admin/category.php?op=AdsNewCat&cid=0">' . _AM_ADSLIGHT_CATMENU_CATEGORY . '</a>
201
                  </td></tr>
202
203
                  <tr class="even"><td><img src="../assets/images/admin/chart_organisation.png" border=0 >
204
                  <a href="' . XOOPS_URL . '/modules/adslight/admin/map.php">' . _AM_ADSLIGHT_CATMENU_MODIFCAT . '</a>
205
                  </td></tr>
206
207
          </table><br>';
208
209
    /// Menu Gestion
210
    echo '<table width=100 border="0" class="outer"><tr>
211
                <th align="left">' . _AM_ADSLIGHT_USERMENU_TITLE . '</th></tr>
212
213
                  <tr class="odd"><td><img src="../assets/images/admin/email_forward.png" border=0 >
214
                  <a href="' . XOOPS_URL . '/modules/system/admin.php?fct=mailusers">' . _AM_ADSLIGHT_USERMENU_SENDMAIL . '</a>
215
                  </td></tr>
216
217
                  <tr class="even"><td><img src="../assets/images/admin/comment_user.png" border=0 >
218
                  <a href="' . XOOPS_URL . '/modules/system/admin.php?fct=comments">' . _AM_ADSLIGHT_USERMENU_COMMENT . '</a>
219
                  </td></tr>
220
221
                 <tr class="odd"><td><img src="../assets/images/admin/web_layout.png" border=0 >
222
                 <a href="' . XOOPS_URL . '/modules/system/admin.php?fct=banners">' . _AM_ADSLIGHT_USERMENU_BAMMIER . '</a>
223
                 </td></tr>
224
225
                  </table><br>';
226
227
    /// Menu Downloads
228
    echo '<table width=100 border="0" class="outer"><tr>
229
                <th align="left">' . _AM_ADSLIGHT_DOWNLOADS_TITLE . '</th></tr>
230
231
                  <tr class="odd"><td><img src="../assets/images/admin/brick.png" border=0 >
232
                  <a href="http://sourceforge.net/projects/adslight/files/Plugins%20AdsLight/">' . _AM_ADSLIGHT_DOWNLOADS_PLUGINS . '</a>
233
                  </td></tr>
234
235
                  <!-- <tr class="even"><td><img src="../assets/images/admin/world.png" border=0 >
236
                  <a href="http://www.i-luc.fr/adslight/modules/TDMDownloads/index.php">' . _AM_ADSLIGHT_DOWNLOADS_MAPS . '</a>
237
                  </td></tr> -->
238
239
                  </table><br>';
240
241
    /// Menu Devellopement
242
    echo '<table width=100 border="0" class="outer">
243
244
                  <tr><th align="left">' . _AM_ADSLIGHT_DEVLLP_TITLE . '</th></tr>
245
246
                 <tr class="odd"><td><img src="../assets/images/admin/page_white_code.png" border=0 >
247
                 <a href="mailto:[email protected]?subject=Hack AdsLight">' . _AM_ADSLIGHT_DEVLLP_HACK . '</a>
248
                 </td></tr>
249
250
                 <tr class="even"><td><img src="../assets/images/admin/page_white_world.png" border=0 >
251
                 <a href="mailto:[email protected]?subject=Traduction AdsLight">' . _AM_ADSLIGHT_DEVLLP_TRANSLATE . '</a>
252
                 </td></tr>
253
254
                  <tr class="odd"><td><img src="../assets/images/admin/page_white_text.png" border=0 >
255
                  <a href="mailto:[email protected]?subject=Correction AdsLight">' . _AM_ADSLIGHT_DEVLLP_CORRECTION . '</a>
256
                  </td></tr>
257
258
                  <tr class="even"><td><img src="../assets/images/admin/page_white_flash.png" border=0 >
259
                  <a href="mailto:[email protected]?subject=Correction AdsLight">' . _AM_ADSLIGHT_DEVLLP_MAPFLASH . '</a>
260
                  </td></tr>
261
262
              <!--  <tr class="odd"><td><img src="../assets/images/admin/group.png" border=0 >
263
                  <a href="' . XOOPS_URL . '/modules/adslight/admin/support_forum.php">' . _AM_ADSLIGHT_DEVLLP_FORUM . '</a>
264
                  </td></tr> -->
265
266
                  </table><br>';
267
268
    /// Faire un don
269
    /*    echo '<table width=100 border="0" class="outer">
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...
270
271
                  <tr><th align="left">'._AM_ADSLIGHT_DONATE_TITLE.'</th></tr>
272
273
                 <tr class="odd"><td width=100>
274
                 '._AM_ADSLIGHT_DONATE.'
275
                 </td></tr>
276
277
                 <tr class="even"><td><div class='center;'>
278
                 '._AM_ADSLIGHT_DONATE_LOGO.'
279
                 </div></td></tr>
280
281
                  </table><br>';  */
282
283
    ////// AND Right Menu Admin /////
284
    echo '</td>
285
            </tr>
286
                </table>';
287
288
    xoops_cp_footer();
0 ignored issues
show
Bug introduced by
The function xoops_cp_footer was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

288
    /** @scrutinizer ignore-call */ 
289
    xoops_cp_footer();
Loading history...
289
}
290
291
#  function CopyXml
292
#####################################################
293
function copyXml()
294
{
295
    $adslight_maps = $GLOBALS['xoopsModuleConfig']['adslight_maps_set'];
296
297
    $indexFile = XOOPS_ROOT_PATH . "/modules/adslight/maps/{$adslight_maps}/datas.xml";
0 ignored issues
show
Bug introduced by
The constant XOOPS_ROOT_PATH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
298
    copy($indexFile, XOOPS_ROOT_PATH . '/modules/adslight/datas.xml');
299
300
    redirect_header('index.php', 3, _AM_ADSLIGHT_ANNVALID);
0 ignored issues
show
Bug introduced by
The function redirect_header was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

300
    /** @scrutinizer ignore-call */ 
301
    redirect_header('index.php', 3, _AM_ADSLIGHT_ANNVALID);
Loading history...
301
}
302
303
#####################################################
304
#####################################################
305
//@todo REMOVE THIS ASAP. This code is extremely unsafe
306
foreach ($_POST as $k => $v) {
307
    ${$k} = $v;
308
}
309
310
$pa  = Request::getString('pa', '', 'GET');
311
$lid = Request::getInt('lid', 0);
312
$op  = Request::getString('op', '');
313
314
switch ($op) {
315
    case 'CopyXml':
316
        copyXml();
317
        break;
318
    default:
319
        index();
320
        break;
321
}
322