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 | |||
19 | $xoopsOption['checkadmin'] = true; |
||
20 | $xoopsOption['hascommon'] = true; |
||
21 | require_once './../include/common.inc.php'; |
||
22 | require_once XOOPS_ROOT_PATH . '/modules/system/admin/modulesadmin/modulesadmin.php'; |
||
23 | defined('XOOPS_INSTALL') || exit('XOOPS Installation wizard die'); |
||
24 | |||
25 | if (!@include_once XOOPS_ROOT_PATH . "/language/{$wizard->language}/global.php") { |
||
26 | include_once XOOPS_ROOT_PATH . '/language/english/global.php'; |
||
27 | } |
||
28 | if (!@include_once XOOPS_ROOT_PATH . "/modules/system/language/{$wizard->language}/admin/modulesadmin.php") { |
||
29 | include_once XOOPS_ROOT_PATH . '/modules/system/language/english/admin/modulesadmin.php'; |
||
30 | } |
||
31 | require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||
32 | require_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
||
33 | |||
34 | //$xoTheme->addStylesheet( XOOPS_URL . "/modules/" . $xoopsModule->getVar("dirname") . "/assets/css/style.css" ); |
||
35 | |||
36 | $pageHasForm = true; |
||
37 | $pageHasHelp = false; |
||
38 | |||
39 | if ($_SERVER['REQUEST_METHOD'] === 'POST') { |
||
40 | include_once XOOPS_ROOT_PATH . '/class/xoopsblock.php'; |
||
41 | include_once XOOPS_ROOT_PATH . '/kernel/module.php'; |
||
42 | include_once XOOPS_ROOT_PATH . '/include/cp_functions.php'; |
||
43 | include_once XOOPS_ROOT_PATH . '/include/version.php'; |
||
44 | // include_once './../include/modulesadmin.php'; |
||
45 | |||
46 | $config_handler = xoops_getHandler('config'); |
||
47 | $xoopsConfig = $config_handler->getConfigsByCat(XOOPS_CONF); |
||
48 | |||
49 | $msgs = array(); |
||
50 | foreach ($_REQUEST['modules'] as $dirname => $installmod) { |
||
51 | if ($installmod) { |
||
52 | $msgs[] = xoops_module_install($dirname); |
||
53 | } |
||
54 | } |
||
55 | |||
56 | $pageHasForm = false; |
||
57 | |||
58 | View Code Duplication | if (count($msgs) > 0) { |
|
0 ignored issues
–
show
|
|||
59 | $content = "<div class='x2-note successMsg'>" . INSTALLED_MODULES . "</div><ul class='log'>"; |
||
60 | foreach ($msgs as $msg) { |
||
61 | $content .= "<dt>{$msg}</dt>"; |
||
62 | } |
||
63 | $content .= '</ul>'; |
||
64 | } else { |
||
65 | $content = "<div class='x2-note confirmMsg'>" . NO_INSTALLED_MODULES . '</div>'; |
||
66 | } |
||
67 | |||
68 | // Flush cache files for cpanel GUIs |
||
69 | xoops_load('cpanel', 'system'); |
||
70 | XoopsSystemCpanel::flush(); |
||
71 | |||
72 | //Set active modules in cache folder |
||
73 | xoops_setActiveModules(); |
||
74 | } else { |
||
75 | View Code Duplication | if (!isset($GLOBALS['xoopsConfig']['language'])) { |
|
76 | $GLOBALS['xoopsConfig']['language'] = $_COOKIE['xo_install_lang']; |
||
77 | } |
||
78 | |||
79 | // Get installed modules |
||
80 | $moduleHandler = xoops_getHandler('module'); |
||
81 | $installed_mods = $moduleHandler->getObjects(); |
||
82 | $listed_mods = array(); |
||
83 | foreach ($installed_mods as $module) { |
||
84 | $listed_mods[] = $module->getVar('dirname'); |
||
85 | } |
||
86 | |||
87 | include_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
||
88 | $dirlist = XoopsLists::getModulesList(); |
||
89 | $toinstal = 0; |
||
90 | |||
91 | $javascript = ''; |
||
92 | $content = "<ul class='log'><li>"; |
||
93 | $content .= "<table class='module'>\n"; |
||
94 | // $content .= "<input type='button' name='getTotal1' id='getTotal1' value='Select All' onclick='selectAll();' /> <input type='button' name='getTotal1' id='getTotal1' value='Unselect All' onclick='unselectAll();' /><br>"; |
||
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') . ' ' . number_format(round($module->getInfo('version'), 2), 2) . ' ' . $module->getInfo('module_status') . ' (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 | |||
136 | $indexAdmin = new ModuleAdmin(); |
||
137 | echo $indexAdmin->addNavigation(basename(__FILE__)); |
||
138 | |||
139 | $indexAdmin->addItemButton(_AM_INSTALLER_SELECT_ALL, 'javascript:selectAll();', 'button_ok'); |
||
140 | |||
141 | $indexAdmin->addItemButton(_AM_INSTALLER_SELECT_NONE, 'javascript:unselectAll();', 'prune'); |
||
142 | |||
143 | echo $indexAdmin->renderButton('left', ''); |
||
144 | |||
145 | include_once dirname(__DIR__) . '/include/install_tpl.php'; |
||
146 | include_once __DIR__ . '/admin_footer.php'; |
||
147 |
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.