Completed
Push — master ( c036f6...46c35c )
by Michael
01:16
created

admin/uninstall.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
 * See the enclosed file license.txt for licensing information.
4
 * If you did not receive this file, get it at http://www.gnu.org/licenses/gpl-2.0.html
5
 *
6
 * @copyright   XOOPS Project (https://xoops.org)
7
 * @license     http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License (GPL)
8
 * @package     installer
9
 * @since       2.3.0
10
 * @author      Haruki Setoyama  <[email protected]>
11
 * @author      Kazumi Ono <[email protected]>
12
 * @author      Skalpa Keo <[email protected]>
13
 * @author      Taiwen Jiang <[email protected]>
14
 * @author      DuGris (aka L. JEN) <[email protected]>
15
 **/
16
include_once __DIR__ . '/admin_header.php';
17
xoops_cp_header();
18
$xoopsOption['checkadmin'] = true;
19
$xoopsOption['hascommon']  = true;
20
require_once './../include/common.inc.php';
21
require_once XOOPS_ROOT_PATH . '/modules/system/admin/modulesadmin/modulesadmin.php';
22
defined('XOOPS_INSTALL') || die('XOOPS Installation wizard die');
23
24
if (!@include_once XOOPS_ROOT_PATH . "/language/{$wizard->language}/global.php") {
25
    include_once XOOPS_ROOT_PATH . '/language/english/global.php';
26
}
27
if (!@include_once XOOPS_ROOT_PATH . "/modules/system/language/{$wizard->language}/admin/modulesadmin.php") {
28
    include_once XOOPS_ROOT_PATH . '/modules/system/language/english/admin/modulesadmin.php';
29
}
30
require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
31
require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
32
33
//$xoTheme->addStylesheet( XOOPS_URL . "/modules/" . $xoopsModule->getVar("dirname") . "/assets/css/style.css" );
34
35
$pageHasForm = true;
36
$pageHasHelp = false;
37
38
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
39
    include_once XOOPS_ROOT_PATH . '/class/xoopsblock.php';
40
    include_once XOOPS_ROOT_PATH . '/kernel/module.php';
41
    include_once XOOPS_ROOT_PATH . '/include/cp_functions.php';
42
    include_once XOOPS_ROOT_PATH . '/include/version.php';
43
    //    include_once './../include/modulesadmin.php';
44
45
    $config_handler = xoops_getHandler('config');
46
    $xoopsConfig    = $config_handler->getConfigsByCat(XOOPS_CONF);
47
48
    $msgs = array();
49
    foreach ($_REQUEST['modules'] as $dirname => $installmod) {
50
        if ($installmod) {
51
            $msgs[] = xoops_module_uninstall($dirname);
52
        }
53
    }
54
55
    $pageHasForm = false;
56
57 View Code Duplication
    if (count($msgs) > 0) {
0 ignored issues
show
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...
58
        $content = "<div class='x2-note successMsg'>" . UNINSTALLED_MODULES . "</div><ul class='log'>";
59
        foreach ($msgs as $msg) {
60
            $content .= "<dt>{$msg}</dt>";
61
        }
62
        $content .= '</ul>';
63
    } else {
64
        $content = "<div class='x2-note confirmMsg'>" . NO_INSTALLED_MODULES . '</div>';
65
    }
66
67
    // Flush cache files for cpanel GUIs
68
    xoops_load('cpanel', 'system');
69
    XoopsSystemCpanel::flush();
70
71
    //Set active modules in cache folder
72
    xoops_setActiveModules();
73
} else {
74 View Code Duplication
    if (!isset($GLOBALS['xoopsConfig']['language'])) {
75
        $GLOBALS['xoopsConfig']['language'] = $_COOKIE['xo_install_lang'];
76
    }
77
78
    // Get installed modules
79
    $moduleHandler  = xoops_getHandler('module');
80
    $installed_mods = $moduleHandler->getObjects();
81
    $listed_mods    = array();
82
    foreach ($installed_mods as $module) {
83
        $listed_mods[] = $module->getVar('dirname');
84
    }
85
86
    include_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
87
    $dirlist  = XoopsLists::getModulesList();
88
    $toinstal = 0;
89
90
    $javascript = '';
91
    $content    = "<ul class='log'><li>";
92
    $content .= "<table class='module'>\n";
93
    //remove System module and itself from the list of modules that can be uninstalled
94
    $dirlist = array_diff($dirlist, array('system', 'moduleinstaller'));
95 View Code Duplication
    foreach ($dirlist as $file) {
96
        clearstatcache();
97
        if (in_array($file, $listed_mods)) {
98
            $value = 0;
99
            $style = '';
100
            if (in_array($file, $wizard->configs['modules'])) {
101
                $value = 1;
102
                $style = " style='background-color:#E6EFC2;'";
103
            }
104
105
            $file   = trim($file);
106
            $module = $moduleHandler->create();
107
            if (!$module->loadInfo($file, false)) {
108
                continue;
109
            }
110
111
            $form     = new XoopsThemeForm('', 'modules', 'index.php', 'post', true);
112
            $moduleYN = new XoopsFormRadioYN('', 'modules[' . $module->getInfo('dirname') . ']', $value, _YES, _NO);
113
            $moduleYN->setExtra("onclick='selectModule(\"" . $file . "\", this)'");
114
            $form->addElement($moduleYN);
115
116
            $content .= "<tr id='" . $file . "'" . $style . ">\n";
117
            $content .= "    <td class='img' ><img src='" . XOOPS_URL . '/modules/' . $module->getInfo('dirname') . '/' . $module->getInfo('image') . "' alt='" . $module->getInfo('name') . "'/></td>\n";
118
            $content .= '    <td>';
119
            $content .= '        ' . $module->getInfo('name') . '&nbsp;' . number_format(round($module->getInfo('version'), 2), 2) . '&nbsp;' . $module->getInfo('module_status') . '&nbsp;(folder: /' . $module->getInfo('dirname') . ')';
120
            $content .= '        <br>' . $module->getInfo('description');
121
            $content .= "    </td>\n";
122
            $content .= "    <td class='yesno'>";
123
            $content .= $moduleYN->render();
124
            $content .= "    </td></tr>\n";
125
            ++$toinstal;
126
        }
127
    }
128
    $content .= '</table>';
129
    $content .= "</li></ul><script type='text/javascript'>" . $javascript . '</script>';
130 View Code Duplication
    if ($toinstal == 0) {
131
        $pageHasForm = false;
132
        $content     = "<div class='x2-note confirmMsg'>" . NO_MODULES_FOUND . '</div>';
133
    }
134
}
135
$indexAdmin = new ModuleAdmin();
136
echo $indexAdmin->addNavigation(basename(__FILE__));
137
138
$indexAdmin->addItemButton(_AM_INSTALLER_SELECT_ALL, 'javascript:selectAll();', 'button_ok');
139
140
$indexAdmin->addItemButton(_AM_INSTALLER_SELECT_NONE, 'javascript:unselectAll();', 'prune');
141
142
echo $indexAdmin->renderButton('left', '');
143
144
include_once dirname(__DIR__) . '/include/install_tpl.php';
145
include_once __DIR__ . '/admin_footer.php';
146