Completed
Push — master ( 25afc0...5e32b7 )
by Michael
03:05
created

index.php ➔ returnBytes()   C

Complexity

Conditions 8
Paths 8

Size

Total Lines 23
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 8
eloc 18
nc 8
nop 2
dl 0
loc 23
rs 6.1403
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 43 and the first side effect is on line 31.

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
// XOOPS - PHP Content Management System                      //
5
// Copyright (c) 2000-2016 XOOPS.org                           //
6
// <http://xoops.org/>                             //
7
// ------------------------------------------------------------------------ //
8
// This program is free software; you can redistribute it and/or modify     //
9
// it under the terms of the GNU General Public License as published by     //
10
// the Free Software Foundation; either version 2 of the License, or        //
11
// (at your option) any later version.                                      //
12
// //
13
// You may not change or alter any portion of this comment or credits       //
14
// of supporting developers from this source code or any supporting         //
15
// source code which is considered copyrighted (c) material of the          //
16
// original comment or credit authors.                                      //
17
// //
18
// This program is distributed in the hope that it will be useful,          //
19
// but WITHOUT ANY WARRANTY; without even the implied warranty of           //
20
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
21
// GNU General Public License for more details.                             //
22
// //
23
// You should have received a copy of the GNU General Public License        //
24
// along with this program; if not, write to the Free Software              //
25
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
26
// ------------------------------------------------------------------------ //
27
// Author: Kazumi Ono (AKA onokazu)                                          //
28
// URL: http://www.myweb.ne.jp/, http://xoops.org/, http://jp.xoops.org/ //
29
// Project: XOOPS Project                                                    //
30
// ------------------------------------------------------------------------- //
31
include_once __DIR__ . '/admin_header.php';
32
include_once __DIR__ . '/../class/utilities.php';
33
mod_loadFunctions('stats', 'newbb');
34
35
$attach_path = $GLOBALS['xoops']->path($GLOBALS['xoopsModuleConfig']['dir_attachments'] . '/');
36
$thumb_path  = $attach_path . 'thumbs/';
37
$folder      = array($attach_path, $thumb_path);
38
39
/**
40
 * @param $path
41
 * @return bool|string
42
 */
43
function newbb_admin_getPathStatus($path = '')
44
{
45
    if ('' === $path) {
46
        return false;
47
    }
48
    if (@is_writable($path)) {
49
        $path_status = '';
50
    } elseif (!@is_dir($path)) {
51
        $path_status = _AM_NEWBB_NOTAVAILABLE . " <a href=index.php?op=createdir&amp;path=$path>" . _AM_NEWBB_CREATETHEDIR . '</a>';
52
    } else {
53
        $path_status = _AM_NEWBB_NOTWRITABLE . " <a href=index.php?op=setperm&amp;path=$path>" . _AM_NEWBB_SETMPERM . '</a>';
54
    }
55
56
    return $path_status;
57
}
58
59
/**
60
 * @param       $target
61
 * @param  int  $mode
62
 * @return bool
63
 */
64
function newbb_admin_mkdir($target, $mode = 0777)
65
{
66
    $target = str_replace('..', '', $target);
67
68
    // http://www.php.net/manual/en/function.mkdir.php
69
    return is_dir($target) || (newbb_admin_mkdir(dirname($target), $mode) && mkdir($target, $mode));
70
}
71
72
/**
73
 * @param       $target
74
 * @param  int  $mode
75
 * @return bool
76
 */
77
function newbb_admin_chmod($target, $mode = 0777)
78
{
79
    $target = str_replace('..', '', $target);
80
81
    return @chmod($target, $mode);
82
}
83
84
/**
85
 * @return array
86
 */
87
function newbb_getImageLibs()
0 ignored issues
show
Coding Style introduced by
newbb_getImageLibs uses the super-global variable $GLOBALS which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
88
{
89
    $imageLibs = array();
90
    unset($output, $status);
91 View Code Duplication
    if ($GLOBALS['xoopsModuleConfig']['image_lib'] == 1 || $GLOBALS['xoopsModuleConfig']['image_lib'] == 0) {
0 ignored issues
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...
92
        $path = empty($GLOBALS['xoopsModuleConfig']['path_magick']) ? '' : $GLOBALS['xoopsModuleConfig']['path_magick'] . '/';
93
        @exec($path . 'convert -version', $output, $status);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
94
        if (empty($status) && !empty($output) && preg_match("/imagemagick[ \t]+([0-9\.]+)/i", $output[0], $matches)) {
95
            $imageLibs['imagemagick'] = $matches[0];
96
        }
97
98
        unset($output, $status);
99
    }
100 View Code Duplication
    if ($GLOBALS['xoopsModuleConfig']['image_lib'] == 2 || $GLOBALS['xoopsModuleConfig']['image_lib'] == 0) {
0 ignored issues
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...
101
        $path = empty($GLOBALS['xoopsModuleConfig']['path_netpbm']) ? '' : $GLOBALS['xoopsModuleConfig']['path_netpbm'] . '/';
102
        @exec($path . 'jpegtopnm -version 2>&1', $output, $status);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
103
        if (empty($status) && !empty($output) && preg_match("/netpbm[ \t]+([0-9\.]+)/i", $output[0], $matches)) {
104
            $imageLibs['netpbm'] = $matches[0];
105
        }
106
        unset($output, $status);
107
    }
108
109
    $GDfuncList = get_extension_funcs('gd');
110
    ob_start();
111
    @phpinfo(INFO_MODULES);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
112
    $output = ob_get_contents();
113
    ob_end_clean();
114
    $matches[1] = '';
0 ignored issues
show
Bug introduced by
The variable $matches does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
115
    $gdversion  = '';
116
    if (preg_match("/GD Version[ \t]*(<[^>]+>[ \t]*)+([^<>]+)/s", $output, $matches)) {
117
        $gdversion = $matches[2];
118
    }
119
    if ($GDfuncList) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $GDfuncList of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
120
        if (in_array('imagegd2', $GDfuncList, true)) {
121
            $imageLibs['gd2'] = $gdversion;
122
        } else {
123
            $imageLibs['gd1'] = $gdversion;
124
        }
125
    }
126
127
    return $imageLibs;
128
}
129
130
$op = XoopsRequest::getCmd('op', '', 'GET'); // (isset($_GET['op']))? $_GET['op'] : "";
0 ignored issues
show
Unused Code Comprehensibility introduced by
81% 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...
131
132
switch ($op) {
133 View Code Duplication
    case 'createdir':
0 ignored issues
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...
134
        $path = XoopsRequest::getString('path', '', 'GET');// $_GET['path'];
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...
135
        $res  = newbb_admin_mkdir($path);
136
        $msg  = $res ? _AM_NEWBB_DIRCREATED : _AM_NEWBB_DIRNOTCREATED;
137
        redirect_header('index.php', 2, $msg . ': ' . $path);
138
        break;
139
140 View Code Duplication
    case 'setperm':
0 ignored issues
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...
141
        $path = XoopsRequest::getString('path', '', 'GET');// $_GET['path'];
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...
142
        $res  = newbb_admin_chmod($path, 0777);
143
        $msg  = $res ? _AM_NEWBB_PERMSET : _AM_NEWBB_PERMNOTSET;
144
        redirect_header('index.php', 2, $msg . ': ' . $path);
145
        break;
146
147
    case 'senddigest':
148
        $digestHandler = xoops_getModuleHandler('digest', 'newbb');
149
        $res           = $digestHandler->process(true);
150
        $msg           = $res ? _AM_NEWBB_DIGEST_FAILED : _AM_NEWBB_DIGEST_SENT;
151
        redirect_header('index.php', 2, $msg);
152
        break;
153
154
    case 'default':
155
    default:
156
        xoops_cp_header();
157
158
        echo '<fieldset>';
159
        $imageLibs     = newbb_getImageLibs();
160
    /** @var XoopsModuleHandler $moduleHandler */
161
    $moduleHandler = xoops_getHandler('module');
162
        $reportHandler = xoops_getModuleHandler('report', 'newbb');
163
164
        $isOK = false;
165
        // START irmtfan add a poll_module config
166
        //XOOPS_POLL
167
        $xoopspoll = $moduleHandler->getByDirname($GLOBALS['xoopsModuleConfig']['poll_module']);
168
        if (is_object($xoopspoll)) {
169
            $isOK = $xoopspoll->getVar('isactive');
170
        }
171
        /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% 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...
172
        else {
173
            //Umfrage
174
            $xoopspoll = &$moduleHandler->getByDirname('umfrage');
175
            if (is_object($xoopspoll)) $isOK = $xoopspoll->getVar('isactive');
176
        }
177
        */
178
        // END irmtfan add a poll_module config
179
180
        $memlimit_iniphp    = returnBytes(@ini_get('memory_limit'));
181
        $postmaxsize_iniphp = returnBytes(@ini_get('post_max_size'));
182
        if ($postmaxsize_iniphp < $memlimit_iniphp) {
183
            $uploadlimit = sprintf(_AM_NEWBB_MEMLIMITOK, returnBytes($postmaxsize_iniphp, true));
184
            $uploadfarbe = 'Green';
185
        } else {
186
            $uploadlimit = _AM_NEWBB_MEMLIMITTOLARGE;
187
            $uploadfarbe = 'Red';
188
        }
189
190
        $indexAdmin->addInfoBox(_AM_NEWBB_PREFERENCES);
191
        // START irmtfan better poll module display link and version - check if xoops poll module is available
192
        if ($isOK) {
193
            $pollLink = _AM_NEWBB_AVAILABLE . ': ';
194
            $pollLink .= "<a href=\"" . XOOPS_URL . '/modules/' . $xoopspoll->getVar('dirname') . "/admin/index.php\"";
195
            $pollLink .= " alt=\"" . $xoopspoll->getVar('name') . ' ' . _VERSION . ' (' . $xoopspoll->getInfo('version') . ") \"";
196
            $pollLink .= " title=\"" . $xoopspoll->getVar('name') . ' ' . _VERSION . ' (' . $xoopspoll->getInfo('version') . ") \"";
197
            $pollLink .= '>' . '(' . $xoopspoll->getVar('name') . ')</a>';
198
        } else {
199
            $pollLink = _AM_NEWBB_NOTAVAILABLE;
200
        }
201
        $indexAdmin->addInfoBoxLine(_AM_NEWBB_PREFERENCES, '<infotext>' . _AM_NEWBB_POLLMODULE . ': %s' . '</infotext>', $pollLink, 'Green');
202
        // END irmtfan better poll module display link and version - check if xoops poll module is available
203
        $indexAdmin->addInfoBoxLine(_AM_NEWBB_PREFERENCES, '<infotext>' . _AM_NEWBB_IMAGEMAGICK . ' %s' . '</infotext>',
204
                                    array_key_exists('imagemagick', $imageLibs) ? _AM_NEWBB_AUTODETECTED . $imageLibs['imagemagick'] : _AM_NEWBB_NOTAVAILABLE, 'Green');
205
        $indexAdmin->addInfoBoxLine(_AM_NEWBB_PREFERENCES, '<infotext>' . 'NetPBM' . ': %s' . '</infotext>',
206
                                    array_key_exists('netpbm', $imageLibs) ? _AM_NEWBB_AUTODETECTED . $imageLibs['netpbm'] : _AM_NEWBB_NOTAVAILABLE, 'Green');
207
        $indexAdmin->addInfoBoxLine(_AM_NEWBB_PREFERENCES, '<infotext>' . _AM_NEWBB_GDLIB1 . ' %s' . '</infotext>',
208
                                    array_key_exists('gd1', $imageLibs) ? _AM_NEWBB_AUTODETECTED . $imageLibs['gd1'] : _AM_NEWBB_NOTAVAILABLE, 'Red');
209
        $indexAdmin->addInfoBoxLine(_AM_NEWBB_PREFERENCES, '<infotext>' . _AM_NEWBB_GDLIB2 . ' %s' . '</infotext>',
210
                                    array_key_exists('gd2', $imageLibs) ? _AM_NEWBB_AUTODETECTED . $imageLibs['gd2'] : _AM_NEWBB_NOTAVAILABLE, 'Green');
211
        $indexAdmin->addInfoBoxLine(_AM_NEWBB_PREFERENCES, '<infotext>' . _AM_NEWBB_UPLOAD . ' %s' . '</infotext>', $uploadlimit, $uploadfarbe);
212
213
        $indexAdmin->addInfoBox(_AM_NEWBB_BOARDSUMMARY);
214
        $indexAdmin->addInfoBoxLine(_AM_NEWBB_BOARDSUMMARY, '<infolabel>' . _AM_NEWBB_TOTALTOPICS . ': %s' . '</infolabel>', getTotalTopics(), 'Green');
215
        $indexAdmin->addInfoBoxLine(_AM_NEWBB_BOARDSUMMARY, '<infolabel>' . _AM_NEWBB_TOTALPOSTS . ': %s' . '</infolabel>', getTotalPosts(), 'Green');
216
        $indexAdmin->addInfoBoxLine(_AM_NEWBB_BOARDSUMMARY, '<infolabel>' . _AM_NEWBB_TOTALVIEWS . ': %s' . '</infolabel>', getTotalViews(), 'Green');
217
218
        $indexAdmin->addInfoBox(_AM_NEWBB_REPORT);
219
        $indexAdmin->addInfoBoxLine(_AM_NEWBB_REPORT, '<infolabel>' . _AM_NEWBB_REPORT_PENDING . ': %s' . '</infolabel>', $reportHandler->getCount(new Criteria('report_result', 0)), 'Green');
220
        $indexAdmin->addInfoBoxLine(_AM_NEWBB_REPORT, '<infolabel>' . _AM_NEWBB_REPORT_PROCESSED . ': %s' . '</infolabel>', $reportHandler->getCount(new Criteria('report_result', 1)), 'Green');
221
222
        //        foreach (array_keys($folder) as $i) {
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...
223
        //            if (!newbb_admin_getPathStatus($folder[$i]) == '') {
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% 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...
224
        //                $indexAdmin->addConfigBoxLine($folder[$i] . ' ' . newbb_admin_getPathStatus($folder[$i]), 'folder');
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...
225
        //            } else {
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...
226
        //                $indexAdmin->addConfigBoxLine($folder[$i], 'folder');
0 ignored issues
show
Unused Code Comprehensibility introduced by
79% 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...
227
        //            }
228
        //            $indexAdmin->addConfigBoxLine(array($folder[$i], '755'), 'chmod');
0 ignored issues
show
Unused Code Comprehensibility introduced by
80% 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...
229
        //        }
230
231
        //        $indexAdmin = new ModuleAdmin();
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...
232
        foreach (array_keys($GLOBALS['uploadFolders']) as $i) {
233
            NewbbUtilities::prepareFolder($uploadFolders[$i]);
234
            $indexAdmin->addConfigBoxLine($uploadFolders[$i], 'folder');
235
            //    $indexAdmin->addConfigBoxLine(array($folder[$i], '777'), 'chmod');
0 ignored issues
show
Unused Code Comprehensibility introduced by
80% 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...
236
        }
237
238
        echo $indexAdmin->addNavigation(basename(__FILE__));
239
        echo $indexAdmin->renderIndex();
240
241
        echo '</fieldset>';
242
        include_once __DIR__ . '/admin_footer.php';
243
        break;
244
}
245
mod_clearCacheFile('config', 'newbb');
246
mod_clearCacheFile('permission', 'newbb');
247
248
/**
249
 * @param             $sizeAsString
250
 * @param  bool       $b
251
 * @return int|string
252
 */
253
function returnBytes($sizeAsString, $b = false)
254
{
255
    if ($b === false) {
256
        switch (substr($sizeAsString, -1)) {
257
            case 'M':
258
            case 'm':
259
                return (int)$sizeAsString * 1048576;
260
            case 'K':
261
            case 'k':
262
                return (int)$sizeAsString * 1024;
263
            case 'G':
264
            case 'g':
265
                return (int)$sizeAsString * 1073741824;
266
            default:
267
                return $sizeAsString;
268
        }
269
    } else {
270
        $base   = log($sizeAsString) / log(1024);
271
        $suffix = array('', 'KB', 'MB', 'GB', 'TB');
272
273
        return round(pow(1024, $base - floor($base))) . ' ' . $suffix[(int)floor($base)];
274
    }
275
}
276