Verzeichnisstruktur phpBB-3.0.0
- Veröffentlicht
- 12.12.2007
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
index.php
001 <?php
002 /**
003 *
004 * @package acp
005 * @version $Id$
006 * @copyright (c) 2005 phpBB Group
007 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
008 *
009 */
010
011 /**
012 */
013 define('IN_PHPBB', true);
014 define('ADMIN_START', true);
015 define('NEED_SID', true);
016
017 // Include files
018 $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../';
019 $phpEx = substr(strrchr(__FILE__, '.'), 1);
020 require($phpbb_root_path . 'common.' . $phpEx);
021 require($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
022 require($phpbb_root_path . 'includes/functions_module.' . $phpEx);
023
024 // Start session management
025 $user->session_begin();
026 $auth->acl($user->data);
027 $user->setup('acp/common');
028 // End session management
029
030 // Have they authenticated (again) as an admin for this session?
031 if (!isset($user->data['session_admin']) || !$user->data['session_admin'])
032 {
033 login_box('', $user->lang['LOGIN_ADMIN_CONFIRM'], $user->lang['LOGIN_ADMIN_SUCCESS'], true, false);
034 }
035
036 // Is user any type of admin? No, then stop here, each script needs to
037 // check specific permissions but this is a catchall
038 if (!$auth->acl_get('a_'))
039 {
040 trigger_error('NO_ADMIN');
041 }
042
043 // We define the admin variables now, because the user is now able to use the admin related features...
044 define('IN_ADMIN', true);
045 $phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : './';
046
047 // Some oft used variables
048 $safe_mode = (@ini_get('safe_mode') || @strtolower(ini_get('safe_mode')) == 'on') ? true : false;
049 $file_uploads = (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on') ? true : false;
050 $module_id = request_var('i', '');
051 $mode = request_var('mode', '');
052
053 // Set custom template for admin area
054 $template->set_custom_template($phpbb_admin_path . 'style', 'admin');
055 $template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style');
056
057 // the acp template is never stored in the database
058 $user->theme['template_storedb'] = false;
059
060 // Instantiate new module
061 $module = new p_master();
062
063 // Instantiate module system and generate list of available modules
064 $module->list_modules('acp');
065
066 // Select the active module
067 $module->set_active($module_id, $mode);
068
069 // Assign data to the template engine for the list of modules
070 // We do this before loading the active module for correct menu display in trigger_error
071 $module->assign_tpl_vars(append_sid("{$phpbb_admin_path}index.$phpEx"));
072
073 // Load and execute the relevant module
074 $module->load_active();
075
076 // Generate the page
077 adm_page_header($module->get_page_title());
078
079 $template->set_filenames(array(
080 'body' => $module->get_tpl_name(),
081 ));
082
083 adm_page_footer();
084
085 /**
086 * Header for acp pages
087 */
088 function adm_page_header($page_title)
089 {
090 global $config, $db, $user, $template;
091 global $phpbb_root_path, $phpbb_admin_path, $phpEx, $SID, $_SID;
092
093 if (defined('HEADER_INC'))
094 {
095 return;
096 }
097
098 define('HEADER_INC', true);
099
100 // gzip_compression
101 if ($config['gzip_compress'])
102 {
103 if (@extension_loaded('zlib') && !headers_sent())
104 {
105 ob_start('ob_gzhandler');
106 }
107 }
108
109 $template->assign_vars(array(
110 'PAGE_TITLE' => $page_title,
111 'USERNAME' => $user->data['username'],
112
113 'SID' => $SID,
114 '_SID' => $_SID,
115 'SESSION_ID' => $user->session_id,
116 'ROOT_PATH' => $phpbb_admin_path,
117
118 'U_LOGOUT' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=logout'),
119 'U_ADM_INDEX' => append_sid("{$phpbb_admin_path}index.$phpEx"),
120 'U_INDEX' => append_sid("{$phpbb_root_path}index.$phpEx"),
121
122 'T_IMAGES_PATH' => "{$phpbb_root_path}images/",
123 'T_SMILIES_PATH' => "{$phpbb_root_path}{$config['smilies_path']}/",
124 'T_AVATAR_PATH' => "{$phpbb_root_path}{$config['avatar_path']}/",
125 'T_AVATAR_GALLERY_PATH' => "{$phpbb_root_path}{$config['avatar_gallery_path']}/",
126 'T_ICONS_PATH' => "{$phpbb_root_path}{$config['icons_path']}/",
127 'T_RANKS_PATH' => "{$phpbb_root_path}{$config['ranks_path']}/",
128 'T_UPLOAD_PATH' => "{$phpbb_root_path}{$config['upload_path']}/",
129
130 'ICON_MOVE_UP' => '<img src="' . $phpbb_admin_path . 'images/icon_up.gif" alt="' . $user->lang['MOVE_UP'] . '" title="' . $user->lang['MOVE_UP'] . '" />',
131 'ICON_MOVE_UP_DISABLED' => '<img src="' . $phpbb_admin_path . 'images/icon_up_disabled.gif" alt="' . $user->lang['MOVE_UP'] . '" title="' . $user->lang['MOVE_UP'] . '" />',
132 'ICON_MOVE_DOWN' => '<img src="' . $phpbb_admin_path . 'images/icon_down.gif" alt="' . $user->lang['MOVE_DOWN'] . '" title="' . $user->lang['MOVE_DOWN'] . '" />',
133 'ICON_MOVE_DOWN_DISABLED' => '<img src="' . $phpbb_admin_path . 'images/icon_down_disabled.gif" alt="' . $user->lang['MOVE_DOWN'] . '" title="' . $user->lang['MOVE_DOWN'] . '" />',
134 'ICON_EDIT' => '<img src="' . $phpbb_admin_path . 'images/icon_edit.gif" alt="' . $user->lang['EDIT'] . '" title="' . $user->lang['EDIT'] . '" />',
135 'ICON_EDIT_DISABLED' => '<img src="' . $phpbb_admin_path . 'images/icon_edit_disabled.gif" alt="' . $user->lang['EDIT'] . '" title="' . $user->lang['EDIT'] . '" />',
136 'ICON_DELETE' => '<img src="' . $phpbb_admin_path . 'images/icon_delete.gif" alt="' . $user->lang['DELETE'] . '" title="' . $user->lang['DELETE'] . '" />',
137 'ICON_DELETE_DISABLED' => '<img src="' . $phpbb_admin_path . 'images/icon_delete_disabled.gif" alt="' . $user->lang['DELETE'] . '" title="' . $user->lang['DELETE'] . '" />',
138 'ICON_SYNC' => '<img src="' . $phpbb_admin_path . 'images/icon_sync.gif" alt="' . $user->lang['RESYNC'] . '" title="' . $user->lang['RESYNC'] . '" />',
139 'ICON_SYNC_DISABLED' => '<img src="' . $phpbb_admin_path . 'images/icon_sync_disabled.gif" alt="' . $user->lang['RESYNC'] . '" title="' . $user->lang['RESYNC'] . '" />',
140
141 'S_USER_LANG' => $user->lang['USER_LANG'],
142 'S_CONTENT_DIRECTION' => $user->lang['DIRECTION'],
143 'S_CONTENT_ENCODING' => 'UTF-8',
144 'S_CONTENT_FLOW_BEGIN' => ($user->lang['DIRECTION'] == 'ltr') ? 'left' : 'right',
145 'S_CONTENT_FLOW_END' => ($user->lang['DIRECTION'] == 'ltr') ? 'right' : 'left',
146 ));
147
148 // application/xhtml+xml not used because of IE
149 header('Content-type: text/html; charset=UTF-8');
150
151 header('Cache-Control: private, no-cache="set-cookie"');
152 header('Expires: 0');
153 header('Pragma: no-cache');
154
155 return;
156 }
157
158 /**
159 * Page footer for acp pages
160 */
161 function adm_page_footer($copyright_html = true)
162 {
163 global $db, $config, $template, $user, $auth, $cache;
164 global $starttime, $phpbb_root_path, $phpbb_admin_path, $phpEx;
165
166 // Output page creation time
167 if (defined('DEBUG'))
168 {
169 $mtime = explode(' ', microtime());
170 $totaltime = $mtime[0] + $mtime[1] - $starttime;
171
172 if (!empty($_REQUEST['explain']) && $auth->acl_get('a_') && defined('DEBUG_EXTRA') && method_exists($db, 'sql_report'))
173 {
174 $db->sql_report('display');
175 }
176
177 $debug_output = sprintf('Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . (($config['gzip_compress']) ? 'On' : 'Off') . (($user->load) ? ' | Load : ' . $user->load : ''), $totaltime);
178
179 if ($auth->acl_get('a_') && defined('DEBUG_EXTRA'))
180 {
181 if (function_exists('memory_get_usage'))
182 {
183 if ($memory_usage = memory_get_usage())
184 {
185 global $base_memory_usage;
186 $memory_usage -= $base_memory_usage;
187 $memory_usage = ($memory_usage >= 1048576) ? round((round($memory_usage / 1048576 * 100) / 100), 2) . ' ' . $user->lang['MB'] : (($memory_usage >= 1024) ? round((round($memory_usage / 1024 * 100) / 100), 2) . ' ' . $user->lang['KB'] : $memory_usage . ' ' . $user->lang['BYTES']);
188
189 $debug_output .= ' | Memory Usage: ' . $memory_usage;
190 }
191 }
192
193 $debug_output .= ' | <a href="' . build_url() . '&explain=1">Explain</a>';
194 }
195 }
196
197 $template->assign_vars(array(
198 'DEBUG_OUTPUT' => (defined('DEBUG')) ? $debug_output : '',
199 'TRANSLATION_INFO' => (!empty($user->lang['TRANSLATION_INFO'])) ? $user->lang['TRANSLATION_INFO'] : '',
200 'S_COPYRIGHT_HTML' => $copyright_html,
201 'VERSION' => $config['version'])
202 );
203
204 $template->display('body');
205
206 garbage_collection();
207 exit_handler();
208 }
209
210 /**
211 * Generate back link for acp pages
212 */
213 function adm_back_link($u_action)
214 {
215 global $user;
216 return '<br /><br /><a href="' . $u_action . '">« ' . $user->lang['BACK_TO_PREV'] . '</a>';
217 }
218
219 /**
220 * Build select field options in acp pages
221 */
222 function build_select($option_ary, $option_default = false)
223 {
224 global $user;
225
226 $html = '';
227 foreach ($option_ary as $value => $title)
228 {
229 $selected = ($option_default !== false && $value == $option_default) ? ' selected="selected"' : '';
230 $html .= '<option value="' . $value . '"' . $selected . '>' . $user->lang[$title] . '</option>';
231 }
232
233 return $html;
234 }
235
236 /**
237 * Build radio fields in acp pages
238 */
239 function h_radio($name, &$input_ary, $input_default = false, $id = false, $key = false)
240 {
241 global $user;
242
243 $html = '';
244 $id_assigned = false;
245 foreach ($input_ary as $value => $title)
246 {
247 $selected = ($input_default !== false && $value == $input_default) ? ' checked="checked"' : '';
248 $html .= '<label><input type="radio" name="' . $name . '"' . (($id && !$id_assigned) ? ' id="' . $id . '"' : '') . ' value="' . $value . '"' . $selected . (($key) ? ' accesskey="' . $key . '"' : '') . ' class="radio" /> ' . $user->lang[$title] . '</label>';
249 $id_assigned = true;
250 }
251
252 return $html;
253 }
254
255 /**
256 * Build configuration template for acp configuration pages
257 */
258 function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars)
259 {
260 global $user, $module;
261
262 $tpl = '';
263 $name = 'config[' . $config_key . ']';
264
265 switch ($tpl_type[0])
266 {
267 case 'text':
268 case 'password':
269 $size = (int) $tpl_type[1];
270 $maxlength = (int) $tpl_type[2];
271
272 $tpl = '<input id="' . $key . '" type="' . $tpl_type[0] . '"' . (($size) ? ' size="' . $size . '"' : '') . ' maxlength="' . (($maxlength) ? $maxlength : 255) . '" name="' . $name . '" value="' . $new[$config_key] . '" />';
273 break;
274
275 case 'dimension':
276 $size = (int) $tpl_type[1];
277 $maxlength = (int) $tpl_type[2];
278
279 $tpl = '<input id="' . $key . '" type="text"' . (($size) ? ' size="' . $size . '"' : '') . ' maxlength="' . (($maxlength) ? $maxlength : 255) . '" name="config[' . $config_key . '_width]" value="' . $new[$config_key . '_width'] . '" /> x <input type="text"' . (($size) ? ' size="' . $size . '"' : '') . ' maxlength="' . (($maxlength) ? $maxlength : 255) . '" name="config[' . $config_key . '_height]" value="' . $new[$config_key . '_height'] . '" />';
280 break;
281
282 case 'textarea':
283 $rows = (int) $tpl_type[1];
284 $cols = (int) $tpl_type[2];
285
286 $tpl = '<textarea id="' . $key . '" name="' . $name . '" rows="' . $rows . '" cols="' . $cols . '">' . $new[$config_key] . '</textarea>';
287 break;
288
289 case 'radio':
290 $key_yes = ($new[$config_key]) ? ' checked="checked"' : '';
291 $key_no = (!$new[$config_key]) ? ' checked="checked"' : '';
292
293 $tpl_type_cond = explode('_', $tpl_type[1]);
294 $type_no = ($tpl_type_cond[0] == 'disabled' || $tpl_type_cond[0] == 'enabled') ? false : true;
295
296 $tpl_no = '<label><input type="radio" name="' . $name . '" value="0"' . $key_no . ' class="radio" /> ' . (($type_no) ? $user->lang['NO'] : $user->lang['DISABLED']) . '</label>';
297 $tpl_yes = '<label><input type="radio" id="' . $key . '" name="' . $name . '" value="1"' . $key_yes . ' class="radio" /> ' . (($type_no) ? $user->lang['YES'] : $user->lang['ENABLED']) . '</label>';
298
299 $tpl = ($tpl_type_cond[0] == 'yes' || $tpl_type_cond[0] == 'enabled') ? $tpl_yes . $tpl_no : $tpl_no . $tpl_yes;
300 break;
301
302 case 'select':
303 case 'custom':
304
305 $return = '';
306
307 if (isset($vars['method']))
308 {
309 $call = array($module->module, $vars['method']);
310 }
311 else if (isset($vars['function']))
312 {
313 $call = $vars['function'];
314 }
315 else
316 {
317 break;
318 }
319
320 if (isset($vars['params']))
321 {
322 $args = array();
323 foreach ($vars['params'] as $value)
324 {
325 switch ($value)
326 {
327 case '{CONFIG_VALUE}':
328 $value = $new[$config_key];
329 break;
330
331 case '{KEY}':
332 $value = $key;
333 break;
334 }
335
336 $args[] = $value;
337 }
338 }
339 else
340 {
341 $args = array($new[$config_key], $key);
342 }
343
344 $return = call_user_func_array($call, $args);
345
346 if ($tpl_type[0] == 'select')
347 {
348 $tpl = '<select id="' . $key . '" name="' . $name . '">' . $return . '</select>';
349 }
350 else
351 {
352 $tpl = $return;
353 }
354
355 break;
356
357 default:
358 break;
359 }
360
361 if (isset($vars['append']))
362 {
363 $tpl .= $vars['append'];
364 }
365
366 return $tpl;
367 }
368
369 /**
370 * Going through a config array and validate values, writing errors to $error.
371 */
372 function validate_config_vars($config_vars, &$cfg_array, &$error)
373 {
374 global $phpbb_root_path, $user;
375
376 foreach ($config_vars as $config_name => $config_definition)
377 {
378 if (!isset($cfg_array[$config_name]) || strpos($config_name, 'legend') !== false)
379 {
380 continue;
381 }
382
383 if (!isset($config_definition['validate']))
384 {
385 continue;
386 }
387
388 // Validate a bit. ;) String is already checked through request_var(), therefore we do not check this again
389 switch ($config_definition['validate'])
390 {
391 case 'bool':
392 $cfg_array[$config_name] = ($cfg_array[$config_name]) ? 1 : 0;
393 break;
394
395 case 'int':
396 $cfg_array[$config_name] = (int) $cfg_array[$config_name];
397 break;
398
399 // Absolute path
400 case 'script_path':
401 if (!$cfg_array[$config_name])
402 {
403 break;
404 }
405
406 $destination = str_replace('\\', '/', $cfg_array[$config_name]);
407
408 if ($destination !== '/')
409 {
410 // Adjust destination path (no trailing slash)
411 if (substr($destination, -1, 1) == '/')
412 {
413 $destination = substr($destination, 0, -1);
414 }
415
416 $destination = str_replace(array('../', './'), '', $destination);
417
418 if ($destination[0] != '/')
419 {
420 $destination = '/' . $destination;
421 }
422 }
423
424 $cfg_array[$config_name] = trim($destination);
425
426 break;
427
428 // Absolute path
429 case 'lang':
430 if (!$cfg_array[$config_name])
431 {
432 break;
433 }
434
435 $cfg_array[$config_name] = basename($cfg_array[$config_name]);
436
437 if (!file_exists($phpbb_root_path . 'language/' . $cfg_array[$config_name] . '/'))
438 {
439 $error[] = $user->lang['WRONG_DATA_LANG'];
440 }
441 break;
442
443 // Relative path (appended $phpbb_root_path)
444 case 'rpath':
445 case 'rwpath':
446 if (!$cfg_array[$config_name])
447 {
448 break;
449 }
450
451 $destination = $cfg_array[$config_name];
452
453 // Adjust destination path (no trailing slash)
454 if (substr($destination, -1, 1) == '/' || substr($destination, -1, 1) == '\\')
455 {
456 $destination = substr($destination, 0, -1);
457 }
458
459 $destination = str_replace(array('../', '..\\', './', '.\\'), '', $destination);
460 if ($destination && ($destination[0] == '/' || $destination[0] == "\\"))
461 {
462 $destination = '';
463 }
464
465 $cfg_array[$config_name] = trim($destination);
466
467 // Path being relative (still prefixed by phpbb_root_path), but with the ability to escape the root dir...
468 case 'path':
469 case 'wpath':
470
471 if (!$cfg_array[$config_name])
472 {
473 break;
474 }
475
476 $cfg_array[$config_name] = trim($cfg_array[$config_name]);
477
478 // Make sure no NUL byte is present...
479 if (strpos($cfg_array[$config_name], "\0") !== false || strpos($cfg_array[$config_name], '%00') !== false)
480 {
481 $cfg_array[$config_name] = '';
482 break;
483 }
484
485 if (!file_exists($phpbb_root_path . $cfg_array[$config_name]))
486 {
487 $error[] = sprintf($user->lang['DIRECTORY_DOES_NOT_EXIST'], $cfg_array[$config_name]);
488 }
489
490 if (file_exists($phpbb_root_path . $cfg_array[$config_name]) && !is_dir($phpbb_root_path . $cfg_array[$config_name]))
491 {
492 $error[] = sprintf($user->lang['DIRECTORY_NOT_DIR'], $cfg_array[$config_name]);
493 }
494
495 // Check if the path is writable
496 if ($config_definition['validate'] == 'wpath' || $config_definition['validate'] == 'rwpath')
497 {
498 if (file_exists($phpbb_root_path . $cfg_array[$config_name]) && !@is_writable($phpbb_root_path . $cfg_array[$config_name]))
499 {
500 $error[] = sprintf($user->lang['DIRECTORY_NOT_WRITABLE'], $cfg_array[$config_name]);
501 }
502 }
503
504 break;
505 }
506 }
507
508 return;
509 }
510
511 ?>