XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
admin.php
Go to the documentation of this file.
1 <?php
2 // $Id: admin.php 9586 2012-05-23 21:24:19Z beckmi $
3 // ------------------------------------------------------------------------ //
4 // XOOPS - PHP Content Management System //
5 // Copyright (c) 2000 XOOPS.org //
6 // <http://www.xoops.org/> //
7 // ------------------------------------------------------------------------ //
8 // This program is free software; you can redistribute it and/or modify //
9 // it under the terms of the GNU General Public License as published by //
10 // the Free Software Foundation; either version 2 of the License, or //
11 // (at your option) any later version. //
12 // //
13 // You may not change or alter any portion of this comment or credits //
14 // of supporting developers from this source code or any supporting //
15 // source code which is considered copyrighted (c) material of the //
16 // original comment or credit authors. //
17 // //
18 // This program is distributed in the hope that it will be useful, //
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
21 // GNU General Public License for more details. //
22 // //
23 // You should have received a copy of the GNU General Public License //
24 // along with this program; if not, write to the Free Software //
25 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
26 // ------------------------------------------------------------------------ //
27 // Author: Kazumi Ono (AKA onokazu) //
28 // URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ //
29 // Project: The XOOPS Project //
30 // ------------------------------------------------------------------------- //
31 
32 
33 // Include header
34 include 'header.php';
35 
36 if ( isset($fct) && $fct == 'users' ) {
37  $xoopsOption['pagetype'] = 'user';
38 }
39 
40 $error = false;
41 if ($admintest != 0) {
42  if (isset($fct) && $fct != '') {
43  $fct = preg_replace("/[^a-z0-9_\-]/i", "", $fct);
44  if ( file_exists( XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar( 'dirname', 'n' ) . '/admin/' . $fct . '/xoops_version.php' ) ) {
45  // Load language file
46  system_loadLanguage( $fct, $xoopsModule->getVar( 'dirname', 'n' ) );
47  // Include Configuration file
48  require XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar( 'dirname', 'n' ) . '/admin/' . $fct . '/xoops_version.php';
49  // Get System permission handler
50  $sysperm_handler =& xoops_gethandler('groupperm');
51 
52  $category = !empty($modversion['category']) ? intval($modversion['category']) : 0;
53  unset($modversion);
54 
55  if ($category > 0) {
56  $group = $xoopsUser->getGroups();
57  if ( in_array( XOOPS_GROUP_ADMIN, $group) || false != $sysperm_handler->checkRight( 'system_admin', $category, $group, $xoopsModule->getVar('mid') ) ) {
58  if ( file_exists( XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar( 'dirname', 'n' ) . '/admin/' . $fct . '/main.php' ) ) {
59  include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar( 'dirname', 'n' ) . '/admin/' . $fct . '/main.php';
60  } else {
61  $error = true;
62  }
63  } else {
64  $error = true;
65  }
66  } elseif ($fct == 'version') {
67  if ( file_exists( XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar( 'dirname', 'n' ) . '/admin/version/main.php' ) ) {
68  include_once XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar( 'dirname', 'n' ) . '/admin/version/main.php';
69  } else {
70  $error = true;
71  }
72  } else {
73  $error = true;
74  }
75  } else {
76  $error = true;
77  }
78  } else {
79  $error = true;
80  }
81 }
82 
83 if (false != $error) {
84 
85  $op = system_CleanVars ( $_REQUEST, 'op', '', 'string' );
86  if ( $op == 'system_activate') {
87  $part = system_CleanVars ( $_REQUEST, 'type', '', 'string' );
89 
90  $criteria = new Criteria('conf_name', 'active_' . $part);
91  $configs = $config_handler->getConfigs( $criteria );
92  foreach ($configs as $conf) {
93  if ( $conf->getVar('conf_name') == 'active_' . $part) {
94  $conf->setVar('conf_value', !$conf->getVar('conf_value') );
95  $config_handler->insertConfig($conf);
96  }
97  }
98  exit;
99  }
100  // Define main template
101  $xoopsOption['template_main'] = 'system_index.html';
102  xoops_cp_header();
103  // Define Stylesheet
104  $xoTheme->addStylesheet( XOOPS_URL . '/modules/system/css/admin.css' );
105  // Define scripts
106  $xoTheme->addScript('browse.php?Frameworks/jquery/jquery.js');
107  $xoTheme->addScript('modules/system/js/admin.js');
108  // Define Breadcrumb and tips
109  $xoBreadCrumb->addLink( _AM_SYSTEM_CONFIG );
111  $xoBreadCrumb->render();
112  $groups = $xoopsUser->getGroups();
113  $all_ok = false;
114  if (!in_array(XOOPS_GROUP_ADMIN, $groups)) {
115  $sysperm_handler =& xoops_gethandler('groupperm');
116  $ok_syscats = $sysperm_handler->getItemIds('system_admin', $groups);
117  } else {
118  $all_ok = true;
119  }
120 
121  xoops_load('xoopslists');
122 
123  $admin_dir = XOOPS_ROOT_PATH . '/modules/system/admin';
124  $dirlist = XoopsLists::getDirListAsArray($admin_dir);
125  $inactive_section = array( 'blocksadmin', 'groups', 'modulesadmin', 'preferences', 'tplsets');
126  foreach($dirlist as $directory) {
127  if ( file_exists( $admin_dir . '/' . $directory . '/xoops_version.php' ) ) {
128 
129  require $admin_dir . '/' . $directory . '/xoops_version.php';
130 
131  if ($modversion['hasAdmin']) {
132 
133  if ( xoops_getModuleOption('active_' . $directory) ) {
134  $category = isset($modversion['category']) ? intval($modversion['category']) : 0;
135  if ( false != $all_ok || in_array($modversion['category'], $ok_syscats)) {
136  $menu['file'] = $directory;
137  $menu['title'] = trim($modversion['name']);
138  $menu['desc'] = str_replace('<br />', ' ', $modversion['description']);
139  $menu['icon'] = $modversion['image'];
140  $menu['status'] = true;
141  }
142  } else {
143  $category = isset($modversion['category']) ? intval($modversion['category']) : 0;
144  if ( false != $all_ok || in_array($modversion['category'], $ok_syscats)) {
145  $menu['file'] = $directory;
146  $menu['title'] = trim($modversion['name']);
147  $menu['desc'] = str_replace('<br />', ' ', $modversion['description']);
148  $menu['icon'] = $modversion['image'];
149  $menu['status'] = false;
150  }
151  }
152  if (!in_array($directory, $inactive_section)) {
153  $menu['used'] = true;
154  }
155  if ( false != $all_ok || in_array($modversion['category'], $ok_syscats)) {
156  switch ( $directory ) {
157  case 'avatars':
158  $avatar_handler = xoops_getHandler('avatar');
159  $avatar = $avatar_handler->getCount();
160  $menu['infos'] = sprintf(_AM_SYSTEM_AVATAR_INFO, $avatar);
161  break;
162  case 'banners':
163  $banner_handler =& xoops_getModuleHandler( 'banner', 'system' );
164  $banner = $banner_handler->getCount();
165  $menu['infos'] = sprintf(_AM_SYSTEM_BANNER_INFO, $banner);
166  break;
167  case 'comments':
168  $comment_handler =& xoops_gethandler('comment');
169  $comment = $comment_handler->getCount();
170  $menu['infos'] = sprintf(_AM_SYSTEM_COMMENT_INFO, $comment);
171  break;
172  case 'groups':
173  $groups_Handler =& xoops_getModuleHandler( 'group', 'system' );
174  $groups = $groups_Handler->getCount();
175  $menu['infos'] = sprintf(_AM_SYSTEM_GROUP_INFO, $groups);
176  break;
177  case 'images':
179  $img = $imgcat_handler->getCount();
180  $menu['infos'] = sprintf(_AM_SYSTEM_IMG_INFO, $img);
181  break;
182  case 'smilies':
183  $smilies_Handler =& xoops_getModuleHandler( 'smilies', 'system' );
184  $smilies = $smilies_Handler->getCount();
185  $menu['infos'] = sprintf(_AM_SYSTEM_SMILIES_INFO, $smilies);
186  break;
187  case 'userrank':
188  $userrank_Handler =& xoops_getModuleHandler( 'userrank', 'system' );
189  $userrank = $userrank_Handler->getCount();
190  $menu['infos'] = sprintf(_AM_SYSTEM_RANKS_INFO, $userrank);
191  break;
192  case 'users':
193  $member_handler =& xoops_getModuleHandler('users', 'system');
194  $member = $member_handler->getCount();
195  $menu['infos'] = sprintf(_AM_SYSTEM_USERS_INFO, $member);
196  break;
197  }
198  }
199  $xoopsTpl->append_by_ref( 'menu', $menu );
200  unset( $menu );
201  }
202  unset($modversion);
203  }
204  }
205  unset($dirlist);
206  xoops_cp_footer();
207 }
208 
209 ?>