Passed
Pull Request — master (#18)
by Michael
02:21
created

ServerStats::getServerStats()   A

Complexity

Conditions 5
Paths 12

Size

Total Lines 54
Code Lines 28

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 28
nc 12
nop 0
dl 0
loc 54
rs 9.1608
c 0
b 0
f 0

How to fix   Long Method   

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
2
3
namespace XoopsModules\Tag\Common;
4
5
/*
6
 You may not change or alter any portion of this comment or credits
7
 of supporting developers from this source code or any supporting source code
8
 which is considered copyrighted (c) material of the original comment or credit authors.
9
10
 This program is distributed in the hope that it will be useful,
11
 but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
 */
14
15
/**
16
 * @copyright   XOOPS Project (https://xoops.org)
17
 * @license     http://www.fsf.org/copyleft/gpl.html GNU public license
18
 * @author      mamba <[email protected]>
19
 */
20
21
use XoopsModules\Tag;
22
23
/**
24
 * Trait ServerStats
25
 * @package XoopsModules\Tag\Common
26
 */
27
trait ServerStats
28
{
29
    /**
30
     * serverStats()
31
     *
32
     * @return string
33
     */
34
    public static function getServerStats()
35
    {
36
        //mb    $wfdownloads = WfdownloadsWfdownloads::getInstance();
37
        $moduleDirName      = basename(dirname(dirname(__DIR__)));
38
        $moduleDirNameUpper = mb_strtoupper($moduleDirName);
39
        /** @var Tag\Helper $helper */
40
        $helper = Tag\Helper::getInstance();
41
        $helper->loadLanguage('common');
42
43
        //        xoops_loadLanguage('common', $moduleDirName);
44
        $html = '';
45
        //        $sql   = 'SELECT metavalue';
46
        //        $sql   .= ' FROM ' . $GLOBALS['xoopsDB']->prefix('wfdownloads_meta');
47
        //        $sql   .= " WHERE metakey='version' LIMIT 1";
48
        //        $query = $GLOBALS['xoopsDB']->query($sql);
49
        //        list($meta) = $GLOBALS['xoopsDB']->fetchRow($query);
50
        $html .= "<fieldset><legend style='font-weight: bold; color: #900;'>" . constant('CO_' . $moduleDirNameUpper . '_IMAGEINFO') . "</legend>\n";
51
        $html .= "<div style='padding: 8px;'>\n";
52
        //        $html .= '<div>' . constant('CO_' . $moduleDirNameUpper . '_METAVERSION') . $meta . "</div>\n";
53
        //        $html .= "<br>\n";
54
        //        $html .= "<br>\n";
55
        $html .= '<div>' . constant('CO_' . $moduleDirNameUpper . '_SPHPINI') . "</div>\n";
56
        $html .= "<ul>\n";
57
58
        $gdlib = function_exists('gd_info') ? '<span style="color: green;">' . constant('CO_' . $moduleDirNameUpper . '_GDON') . '</span>' : '<span style="color: red;">' . constant('CO_' . $moduleDirNameUpper . '_GDOFF') . '</span>';
59
        $html  .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS') . $gdlib;
60
        if (function_exists('gd_info')) {
61
            if (true === ($gdlib = gd_info())) {
62
                $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_GDLIBVERSION') . '<b>' . $gdlib['GD Version'] . '</b>';
63
            }
64
        }
65
        //
66
        //    $safemode = ini_get('safe_mode') ? constant('CO_' . $moduleDirNameUpper . '_ON') . constant('CO_' . $moduleDirNameUpper . '_SAFEMODEPROBLEMS : constant('CO_' . $moduleDirNameUpper . '_OFF');
67
        //    $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SAFEMODESTATUS . $safemode;
68
        //
69
        //    $registerglobals = (!ini_get('register_globals')) ? "<span style=\"color: green;\">" . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>' : "<span style=\"color: red;\">" . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>';
70
        //    $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_REGISTERGLOBALS . $registerglobals;
71
        //
72
        $downloads = ini_get('file_uploads') ? '<span style="color: green;">' . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>' : '<span style="color: red;">' . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>';
73
        $html      .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS') . $downloads;
74
75
        $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MAXUPLOADSIZE') . ' <b><span style="color: blue;">' . ini_get('upload_max_filesize') . "</span></b>\n";
76
        $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MAXPOSTSIZE') . ' <b><span style="color: blue;">' . ini_get('post_max_size') . "</span></b>\n";
77
        $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MEMORYLIMIT') . ' <b><span style="color: blue;">' . ini_get('memory_limit') . "</span></b>\n";
78
        $html .= "</ul>\n";
79
        $html .= "<ul>\n";
80
        $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SERVERPATH') . ' <b>' . XOOPS_ROOT_PATH . "</b>\n";
81
        $html .= "</ul>\n";
82
        $html .= "<br>\n";
83
        $html .= constant('CO_' . $moduleDirNameUpper . '_UPLOADPATHDSC') . "\n";
84
        $html .= '</div>';
85
        $html .= '</fieldset><br>';
86
87
        return $html;
88
    }
89
}
90