1: <?php
2: /**
3: * XOOPS control panel functions
4: *
5: * You may not change or alter any portion of this comment or credits
6: * of supporting developers from this source code or any supporting source code
7: * which is considered copyrighted (c) material of the original comment or credit authors.
8: * This program is distributed in the hope that it will be useful,
9: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11: *
12: * @copyright (c) 2000-2021 XOOPS Project (https://xoops.org)
13: * @license GNU GPL 2 (https://www.gnu.org/licenses/gpl-2.0.html)
14: * @package kernel
15: * @since 2.0.0
16: */
17:
18: define('XOOPS_CPFUNC_LOADED', 1);
19:
20: /**
21: * CP Header
22: *
23: */
24: function xoops_cp_header()
25: {
26: xoops_load('cpanel', 'system');
27: $cpanel = XoopsSystemCpanel::getInstance();
28: $cpanel->gui->header();
29: }
30:
31: /**
32: * CP Footer
33: *
34: */
35: function xoops_cp_footer()
36: {
37: xoops_load('cpanel', 'system');
38: $cpanel = XoopsSystemCpanel::getInstance();
39: $cpanel->gui->footer();
40: }
41:
42: /**
43: * Open Table: DO NOT USE
44: *
45: * We need these because theme files will not be included
46: *
47: */
48: function openTable()
49: {
50: echo "<table width='100%' border='0' cellspacing='1' cellpadding='8' style='border: 2px solid #2F5376;'><tr class='bg4'><td valign='top'>\n";
51: }
52:
53: /**
54: * Cloe Table : NO NOT USE
55: *
56: */
57: function closeTable()
58: {
59: echo '</td></tr></table>';
60: }
61:
62: /**
63: * Enclose Items in a table : DO NOT USE
64: *
65: * @param string $title
66: * @param string $content
67: */
68: function themecenterposts($title, $content)
69: {
70: echo '<table cellpadding="4" cellspacing="1" width="98%" class="outer"><tr><td class="head">' . $title . '</td></tr><tr><td><br>' . $content . '<br></td></tr></table>';
71: }
72:
73: /**
74: * Text Form : DO NOT USE
75: *
76: * @param mixed $url
77: * @param mixed $value
78: * @return mixed
79: */
80: function myTextForm($url, $value)
81: {
82: return '<form action="' . $url . '" method="post"><input type="submit" value="' . $value . '" /></form>';
83: }
84:
85: /**
86: * Enter description here...
87: *
88: * @return mixed
89: */
90: function xoopsfwrite()
91: {
92: if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
93: return false;
94: } else {
95: }
96: if (!$GLOBALS['xoopsSecurity']->checkReferer()) {
97: return false;
98: } else {
99: }
100:
101: return true;
102: }
103:
104: /**
105: * Xoops Module Menu
106: * @deprecated
107: * @return mixed
108: */
109: function xoops_module_get_admin_menu()
110: {
111: $GLOBALS['xoopsLogger']->addDeprecated('Function ' . __FUNCTION__ . ' is deprecated, should not be used any longer');
112: /************************************************************
113: * Based on:
114: * - PHP Layers Menu 1.0.7(c)2001,2002 Marco Pratesi <pratesi@telug.it>
115: * - TreeMenu 1.1 - Bjorge Dijkstra <bjorge@gmx.net>
116: ************************************************************
117: * - php code Optimized by DuGris
118: ************************************************************/
119:
120: $left = 105;
121: $top = 135;
122: $js = '';
123: $moveLayers = '';
124: $shutdown = '';
125: $firstleveltable = '';
126: $menu_layers = '';
127: /** @var XoopsModuleHandler $module_handler */
128: $module_handler = xoops_getHandler('module');
129: $criteria = new CriteriaCompo();
130: $criteria->add(new Criteria('hasadmin', 1));
131: $criteria->add(new Criteria('isactive', 1));
132: $criteria->setSort('mid');
133: $mods = $module_handler->getObjects($criteria);
134:
135: foreach ($mods as $mod) {
136: $mid = $mod->getVar('mid');
137: $module_name = $mod->getVar('name');
138: $module_url = "\".XOOPS_URL.\"/modules/" . $mod->getVar('dirname') . '/' . trim($mod->getInfo('adminindex'));
139: $module_img = "<img class='admin_layer_img' src='\".XOOPS_URL.\"/modules/" . $mod->getVar('dirname') . '/' . $mod->getInfo('image') . "' alt='' />";
140: $module_desc = "<strong>\"._VERSION.\":</strong> " . round($mod->getVar('version') / 100, 2) . "<br><strong>\"._DESCRIPTION.\":</strong> " . $mod->getInfo('description');
141:
142: $top += 15;
143: $js .= "\nfunction popUpL" . $mid . "() {\n shutdown();\n popUp('L" . $mid . "',true);}";
144: $moveLayers .= "\n setleft('L" . $mid . "'," . $left . ");\n settop('L" . $mid . "'," . $top . ');';
145: $shutdown .= "\n popUp('L" . $mid . "',false);";
146: $firstleveltable .= "$" . 'xoops_admin_menu_ft[' . $mid . "] = \"<a href='" . $module_url . "' title='" . $module_name . "' onmouseover='moveLayerY(\\\"L" . $mid . "\\\", currentY, event) ; popUpL" . $mid . "(); ' >" . $module_img . "</a><br>\";\n";
147: $menu_layers .= "\n<div id='L" . $mid . "' style='position: absolute; visibility: hidden; z-index:1000;' >\n<table class='admin_layer' cellpadding='0' cellspacing='0'>\n<tr><th nowrap='nowrap'>" . $module_name . "</th></tr>\n<tr><td class='even' nowrap='nowrap'>";
148:
149: $adminmenu = $mod->getAdminMenu();
150:
151: if ($mod->getVar('hasnotification') || ($mod->getInfo('config') && \is_array($mod->getInfo('config'))) || ($mod->getInfo('comments') && \is_array($mod->getInfo('comments')))) {
152: $adminmenu[] = array(
153: 'link' => '".XOOPS_URL."/modules/system/admin.php?fct=preferences&amp;op=showmod&amp;mod=' . $mid,
154: 'title' => _PREFERENCES,
155: 'absolute' => true);
156: }
157: if (count($adminmenu) != 0) {
158: $currenttarget = '';
159: foreach ($adminmenu as $menuitem) {
160: $menu_link = trim($menuitem['link']);
161: $menu_title = trim($menuitem['title']);
162: $menu_target = isset($menuitem['target']) ? " target='" . trim($menuitem['target']) . "'" : '';
163: if (isset($menuitem['absolute']) && $menuitem['absolute']) {
164: $menu_link = empty($menu_link) ? '#' : $menu_link;
165: } else {
166: $menu_link = empty($menu_link) ? '#' : "\".XOOPS_URL.\"/modules/" . $mod->getVar('dirname') . '/' . $menu_link;
167: }
168:
169: $menu_layers .= "\n<img src='\".XOOPS_URL.\"/images/pointer.gif' width='8' height='8' alt='' />&nbsp;<a href='" . $menu_link . "'" . $menu_target . " onmouseover='popUpL" . $mid . "' >" . $menu_title . "</a><br>\n";
170: }
171: }
172:
173: $menu_layers .= "\n<div style='margin-top: 5px; font-size: smaller; text-align: right;'><a href='#' onmouseover='shutdown();'>[" . _CLOSE . "]</a></div></td></tr><tr><th style='font-size: smaller; text-align: left;'>" . $module_img . '<br>' . $module_desc . "</th></tr></table></div>\n";
174: }
175: $menu_layers .= "\n<script language='JavaScript' type='text/javascript'>\n<!--\nmoveLayers();\nloaded = 1;\n// -->\n</script>\n";
176: $content = '<' . "?php\n";
177: $content .= "\$xoops_admin_menu_js = \"" . $js . "\n\";\n\n";
178: $content .= "\$xoops_admin_menu_ml = \"" . $moveLayers . "\n\";\n\n";
179: $content .= "\$xoops_admin_menu_sd = \"" . $shutdown . "\n\";\n\n";
180: $content .= $firstleveltable . "\n";
181: $content .= "\$xoops_admin_menu_dv = \"" . $menu_layers . "\";\n";
182: $content .= "\n?" . '>';
183:
184: return $content;
185: }
186:
187: /**
188: * Xoops Module Write Admin Menu
189: *
190: * @param string $content
191: * @return bool
192: */
193: function xoops_module_write_admin_menu($content)
194: {
195: $GLOBALS['xoopsLogger']->addDeprecated('Function ' . __FUNCTION__ . ' is deprecated, should not be used any longer');
196: if (!xoopsfwrite()) {
197: return false;
198: }
199: $filename = XOOPS_CACHE_PATH . '/adminmenu.php';
200: if (!$file = fopen($filename, 'w')) {
201: echo 'failed open file';
202:
203: return false;
204: }
205: if (fwrite($file, $content) == -1) {
206: echo 'failed write file';
207:
208: return false;
209: }
210: fclose($file);
211:
212: // write index.php file in cache folder
213: // file is delete after clear_cache (smarty)
214: xoops_write_index_file(XOOPS_CACHE_PATH);
215:
216: return true;
217: }
218:
219: /**
220: * Xoops Write Index File
221: *
222: * @param string $path
223: * @return bool
224: */
225: function xoops_write_index_file($path = '')
226: {
227: if (empty($path)) {
228: return false;
229: }
230: if (!xoopsfwrite()) {
231: return false;
232: }
233:
234: $path = substr($path, -1) === '/' ? substr($path, 0, -1) : $path;
235: $filename = $path . '/index.php';
236: if (file_exists($filename)) {
237: return true;
238: }
239: if (!$file = fopen($filename, 'w')) {
240: echo 'failed open file';
241:
242: return false;
243: }
244: if (fwrite($file, "<?php\nheader('HTTP/1.0 404 Not Found');\n") == -1) {
245:
246: echo 'failed write file';
247:
248: return false;
249: }
250: fclose($file);
251:
252: return true;
253: }
254: