root/admin/admin_board.php

Revision 305, 8.2 kB (checked in by Nafania, 2 years ago)

--

Line 
1 <?php
2 /***************************************************************************</span>
3 <span class="code-comment"> *                              admin_board.php
4  *                            -------------------
5  *   begin                : Thursday, Jul 12, 2001
6  *   copyright            : (C) 2001 The phpBB Group
7  *   email                : support@phpbb.com
8  *
9  *   $Id: admin_board.php,v 1.51.2.11 2005/10/30 15:17:13 acydburn Exp $
10  *
11  *
12  ***************************************************************************/
13
14 if( !empty($setmodules) )</span>
15 <span class="code-keyword">{
16     $file = basename(__FILE__);
17     $module['general']['configuration'] = $file;
18      return;
19 }
20
21 define('IN_PHPBB', 1);</span>
22 <span class="code-lang">
23 function return_bytes($val) {
24     $val = trim($val);
25     $last = strtolower(substr($val, -1));
26     switch( $last ) {
27         case 'g':
28             $val = $val * 1024 * 1024 * 1024;
29         break;
30         case 'm':
31             $val = $val * 1024 * 1024;
32         break;
33         case 'k':
34             $val = $val * 1024;
35         break;
36     }
37
38     return (int) $val;
39 }
40
41 $modes = array();
42
43 $root_path = './../';</span>
44 <span class="code-lang">require($root_path . 'extension.inc');
45 require('./pagestart.' . $phpEx);
46 include($root_path . 'include/functions_selects.'.$phpEx);
47 include($root_path . 'include/functions_admin.'.$phpEx);
48 include($root_path . 'include/functions_check.'.$phpEx);
49 include($root_path . 'languages/lang_' . $config['default_lang'] . '/lang_merge.' . $phpEx);
50
51 $mode = request_var('mode', 'settings');
52 $submit = (isset($_POST['submit'])) ? true : false;</span>
53 <span class="code-lang">
54 if ( isset($_REQUEST['config']) ) {
55     if ( is_array($_REQUEST['config']) ) {
56         foreach ( $_REQUEST['config'] AS $key => $val ) {
57             if ( is_array($val) ) {
58                 foreach ( $val AS $_key => $_val ) {
59                     $result = ( isset($_REQUEST['config'][$key][$_key]) ? trim(htmlspecialchars($_REQUEST['config'][$key][$_key])) : '' );
60                     $result = (STRIP) ? stripslashes($result) : $result;
61                     $cfg_array[$key][$_key] = $result;
62                 }
63             }
64             else {
65                 $result = ( isset($_REQUEST['config'][$key]) ? trim(htmlspecialchars($_REQUEST['config'][$key])) : '' );
66                 $cfg_array[$key] = (STRIP) ? stripslashes($result) : $result;
67             }
68         }
69     }
70     else {
71         $cfg_array[$key] = request_var('config', array( ''=>'') );
72     }
73 }
74 else {
75     $cfg_array = $config;
76 }
77
78
79 $include_dir = $root_path . 'include/acp/config/';</span>
80 <span class="code-lang">
81 if ( $dir = opendir($include_dir) ) {
82     $valid_modes = array();
83     $load_modules = true;
84
85     while ( false !== ($file = readdir($dir)) ) {
86         if ( $file != '.' && $file != '..' && !is_dir($file) ) {
87             $file = substr($file, 0, strpos($file, '.php'));
88             $valid_modes[] = $file;
89             @include($root_path . 'languages/lang_' . $config['default_lang'] . '/lang_admin_' . $file . '.php');
90             require($include_dir . $file . '.php');
91         }
92     }
93
94     unset($load_modules);
95 }
96 else {
97     trigger_error('cant_open_dir');
98 }
99
100 if ( !in_array($mode, $valid_modes) ) {
101     trigger_error('invalid_mode');
102 }
103 else {
104     @include($root_path . 'languages/lang_' . $config['default_lang'] . '/lang_admin_' . $mode . '.php');
105     require($include_dir . $mode . '.php');
106 }
107
108 $error = array();
109 validate_config_vars($display_vars['vars'], $cfg_array, $error);
110 // Do not write values if there is an error
111 if (sizeof($error))</span>
112 <span class="code-keyword">{
113     $submit = false;
114 }
115 $prev_config_name = '';
116 // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to...
117 foreach ($display_vars['vars'] as $config_name => $null)</span>
118 <span class="code-keyword">{
119     //it's an array config value
120     $config_name_replaced = $config_name;
121     if ( strpos($config_name, '[') !== false ) {
122         $config_name_replaced = preg_replace('/\[(.*?)\]/', '', $config_name);
123
124         preg_match('/\[(.*?)\]/', $config_name, $matches);
125
126         if ( $config_name_replaced == $prev_config_name ) {
127             $new_config[$config_name_replaced][$matches[1]] = ( isset($cfg_array[$config_name_replaced][$matches[1]]) ? $cfg_array[$config_name_replaced][$matches[1]] : '' );
128         }
129     }
130
131     if ( $config_name_replaced == $prev_config_name ) {
132         continue;
133     }
134
135     $prev_config_name = $config_name_replaced;
136
137     if (!isset($cfg_array[$config_name_replaced]) || strpos($config_name_replaced, 'legend') !== false)
138     {
139         continue;
140     }
141
142     $new_config[$config_name_replaced] = $config_value = $cfg_array[$config_name_replaced];
143
144     if ($submit)
145     {
146         set_config($config_name_replaced, $config_value);
147     }
148 }
149
150 foreach ( $modes AS $_mode => $mode_name ) {
151
152     $mode_name = ( isset($lang[$mode_name]) ? $lang[$mode_name] : $mode_name );
153
154     $template->assign_block_vars('modes_row', array(
155         'U_MODE' => append_sid('admin_board.' . $phpEx '?mode=' . $_mode),
156         'MODE_NAME' => $mode_name,
157         'ACTIVE' => ( $_mode == $mode )
158     ));
159 }
160
161 $title = ( isset($lang[$display_vars['title']]) ? $lang[$display_vars['title']] : $display_vars['title'] );
162 $title_explain = ( isset($lang[$display_vars['title'] . '_explain']) ? $lang[$display_vars['title'] . '_explain'] : '' );
163 $s_form_action = 'admin_board.' . $phpEx . ( $mode ? '?mode=' . $mode : '' );
164
165 $template->assign_vars(array(</span>
166 <span class="code-lang">    'L_TITLE'            => $title,
167     'L_TITLE_EXPLAIN'    => $title_explain,
168
169     'S_ERROR'            => (sizeof($error)) ? true : false,
170     'ERROR_MSG'            => implode('<br />', $error),
171
172     'U_ACTION'            => append_sid($s_form_action),)
173 );
174
175 if ( $submit ) {
176     $ret_url = 'admin_board.' . $phpEx . ( $mode ? '?mode=' . $mode : '' );
177
178      $message = $lang['config_updated'] . "<br /><br />" . sprintf($lang['click_return_config'], "<a href=\"" . append_sid($ret_url) . "\">", "</a>") . "<br /><br />" . sprintf($lang['click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>");
179
180      trigger_error($message);
181 }
182
183 $i = 0;
184
185 // Output relevant page
186 foreach ($display_vars['vars'] as $config_key => $vars)</span>
187 <span class="code-keyword">{
188
189
190     if (!is_array($vars) && strpos($config_key, 'legend') === false)
191     {
192         continue;
193     }
194
195     if (strpos($config_key, 'legend') !== false)
196     {
197         $type = explode(':', $vars);
198         $legend = ( isset($type[0]) ? $type[0] : '' );
199         $legend_explain = ( isset($type[1]) ? $type[1] : '' );
200
201         $template->assign_block_vars('options', array(
202             'S_LEGEND'        => true,
203             'LEGEND'        => (isset($lang[$legend])) ? $lang[$legend] : $legend,
204             'LEGEND_EXPLAIN'        => (isset($lang[$legend_explain])) ? $lang[$legend_explain] : '' )
205         );
206
207         continue;
208     }
209
210     $type = explode(':', $vars['type']);
211     $db_store = ( isset($vars['db_store']) ? $vars['db_store']: '' );
212
213     $l_explain = '';
214     if ($vars['explain'] && isset($vars['lang_explain']))
215     {
216         $l_explain = (isset($lang[$vars['lang_explain']])) ? $lang[$vars['lang_explain']] : $vars['lang_explain'];
217     }
218     else if ($vars['explain'])
219     {
220         $l_explain = (isset($lang[$vars['lang'] . '_explain'])) ? $lang[$vars['lang'] . '_explain'] : '';
221     }
222
223     if ( isset($vars['explain_sprintf']) ) {
224         $args = array($l_explain);
225         $args = array_merge($args, $vars['explain_sprintf']);
226         $l_explain = call_user_func_array('sprintf', $args);
227     }
228
229     $config_key_replaced = $config_key;
230     if ( strpos($config_key, '[') !== false ) {
231         $config_key_replaced = preg_replace('/\[(.*?)\]/', '', $config_key);
232     }
233
234     if ( $db_store == 'array' ) {
235          if ( !is_array($config[$config_key_replaced]) ) {
236              $ary_val = @unserialize($config[$config_key_replaced]);
237              if ( is_array($ary_val) ) {
238                 switch ( $config_key_replaced ) {
239                     case 'user_limit_ary_allow_download':
240                      case 'user_limit_ary_torrents':
241                      case 'points_settings':
242                          foreach ( $ary_val AS $_key => $_val ) {
243                              $config[$config_key_replaced . '[' . $_key . ']'] = $_val;
244                          }
245                      break;
246
247                      default:
248                          $config[$config_key_replaced] = $ary_val;
249                      break;
250                 }
251             }
252         }
253     }
254
255     $content = build_cfg_template($type, $config_key, $config, $config_key, $vars);
256
257     if (empty($content))
258     {
259         continue;
260     }
261
262     $template->assign_block_vars('options', array(
263         'KEY'            => $config_key,
264         'TITLE'            => (isset($lang[$vars['lang']])) ? $lang[$vars['lang']] : $vars['lang'],
265         'S_EXPLAIN'        => $vars['explain'],
266         'TITLE_EXPLAIN'    => $l_explain,
267         'CONTENT'        => $content,
268
269         'ROW_CLASS' => ( $i % 2 ? $theme['td_class1'] : $theme['td_class2'] )
270     ));
271
272     ++$i;
273
274     unset($display_vars['vars'][$config_key]);
275 }
276
277 $template->set_filenames(array(</span>
278 <span class="code-lang">        "body" => "../admin/board_config_body.tpl")
279 );
280
281 $template->display('body');</span>
282 <span class="code-lang">
283 include('./page_footer_admin.'.$phpEx);
284
285 ?>
Note: See TracBrowser for help on using the browser.