Completed
Branch master (c92e39)
by Michael
02:32
created

admin/admin.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/*
3
 * You may not change or alter any portion of this comment or credits
4
 * of supporting developers from this source code or any supporting source code
5
 * which is considered copyrighted (c) material of the original comment or credit authors.
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
 */
11
12
/**
13
 * @copyright    XOOPS Project http://xoops.org/
14
 * @license      GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
15
 * @package
16
 * @since
17
 * @author       XOOPS Development Team, Kazumi Ono (AKA onokazu)
18
 */
19
20
// defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% 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...
21
22
if (isset($HTTP_POST_VARS['fct'])) {
23
    $fct = trim($HTTP_POST_VARS['fct']);
24
}
25
if (isset($HTTP_GET_VARS['fct'])) {
26
    $fct = trim($HTTP_GET_VARS['fct']);
27
}
28
if (empty($fct)) {
29
    $fct = 'preferences';
30
}
31
include __DIR__ . '/../../../mainfile.php';
32
include XOOPS_ROOT_PATH . '/include/cp_functions.php';
33
34
include_once XOOPS_ROOT_PATH . '/kernel/module.php';
35
36
$admintest = 0;
37
38
if (is_object($xoopsUser)) {
39
    $xoopsModule = XoopsModule::getByDirname('system');
40
    if (!$xoopsUser->isAdmin($xoopsModule->mid())) {
41
        redirect_header(XOOPS_URL . '/user.php', 3, _NOPERM);
42
    }
43
    $admintest = 1;
44
} else {
45
    redirect_header(XOOPS_URL . '/user.php', 3, _NOPERM);
46
}
47
48
// include system category definitions
49
include_once XOOPS_ROOT_PATH . '/modules/system/constants.php';
50
$error = false;
51
if ($admintest != 0) {
52
    if (isset($fct) && $fct != '') {
53
        if (file_exists(XOOPS_ROOT_PATH . '/modules/system/admin/' . $fct . '/xoops_version.php')) {
54
            include_once XOOPS_ROOT_PATH . '/modules/system/language/' . $xoopsConfig['language'] . '/admin.php';
55
56
            if (file_exists(XOOPS_ROOT_PATH . '/modules/system/language/' . $xoopsConfig['language'] . '/admin/' . $fct . '.php')) {
57
                include XOOPS_ROOT_PATH . '/modules/system/language/' . $xoopsConfig['language'] . '/admin/' . $fct . '.php';
58
            } elseif (file_exists(XOOPS_ROOT_PATH . '/modules/system/language/english/admin/' . $fct . '.php')) {
59
                include XOOPS_ROOT_PATH . '/modules/system/language/english/admin/' . $fct . '.php';
60
            }
61
            include XOOPS_ROOT_PATH . '/modules/system/admin/' . $fct . '/xoops_version.php';
62
            $syspermHandler = xoops_getHandler('groupperm');
63
            $category       = !empty($modversion['category']) ? (int)$modversion['category'] : 0;
64
            unset($modversion);
65
            if ($category > 0) {
66
                $groups =& $xoopsUser->getGroups();
67
                if (in_array(XOOPS_GROUP_ADMIN, $groups)
68
                    || false !== $syspermHandler->checkRight('system_admin', $category, $groups, $xoopsModule->getVar('mid'))
69
                ) {
70
                    if (file_exists("../include/{$fct}.inc.php")) {
71
                        include_once __DIR__ . "/../include/{$fct}.inc.php";
72
                    } else {
73
                        $error = true;
74
                    }
75
                } else {
76
                    $error = true;
77
                }
78
            } elseif ($fct === 'version') {
79
                if (file_exists(XOOPS_ROOT_PATH . '/modules/system/admin/version/main.php')) {
80
                    include_once XOOPS_ROOT_PATH . '/modules/system/admin/version/main.php';
81
                } else {
82
                    $error = true;
83
                }
84
            } else {
85
                $error = true;
86
            }
87
        } else {
88
            $error = true;
89
        }
90
    } else {
91
        $error = true;
92
    }
93
}
94
95
if (false != $error) {
96
    xoops_cp_header();
97
    echo '<h4>System Configuration</h4>';
98
    echo '<table class="outer" cellpadding="4" cellspacing="1">';
99
    echo '<tr>';
100
    $groups = $xoopsUser->getGroups();
101
    $all_ok = false;
102
    if (!in_array(XOOPS_GROUP_ADMIN, $groups)) {
103
        $syspermHandler = xoops_getHandler('groupperm');
104
        $ok_syscats     =& $syspermHandler->getItemIds('system_admin', $groups);
105
    } else {
106
        $all_ok = true;
107
    }
108
    $admin_dir = XOOPS_ROOT_PATH . '/modules/system/admin';
109
    $handle    = opendir($admin_dir);
110
    $counter   = 0;
111
    $class     = 'even';
112
    while ($file = readdir($handle)) {
113
        if (strtolower($file) !== 'cvs' && !preg_match('/[.]/', $file) && is_dir($admin_dir . '/' . $file)) {
114
            include $admin_dir . '/' . $file . '/xoops_version.php';
115
            if ($modversion['hasAdmin']) {
116
                $category = isset($modversion['category']) ? (int)$modversion['category'] : 0;
117
                if (false != $all_ok || in_array($modversion['category'], $ok_syscats)) {
118
                    echo "<td class='$class' align='center' valign='bottom' width='19%'>";
119
                    echo "<a href='" . XOOPS_URL . '/modules/system/admin.php?fct=' . $file . "'><b>" . trim($modversion['name']) . "</b></a>\n";
120
                    echo '</td>';
121
                    ++$counter;
122
                    $class = ($class === 'even') ? 'odd' : 'even';
123
                }
124
                if ($counter > 4) {
125
                    $counter = 0;
126
                    echo '</tr>';
127
                    echo '<tr>';
128
                }
129
            }
130
            unset($modversion);
131
        }
132
    }
133
    while ($counter < 5) {
134
        echo '<td class="' . $class . '">&nbsp;</td>';
135
        $class = ($class === 'even') ? 'odd' : 'even';
136
        ++$counter;
137
    }
138
    echo '</tr></table>';
139
    xoops_cp_footer();
140
}
141