Verzeichnisstruktur phpBB-3.1.0
- Veröffentlicht
- 27.10.2014
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 * This file is part of the phpBB Forum Software package.
005 *
006 * @copyright (c) phpBB Limited <https://www.phpbb.com>
007 * @license GNU General Public License, version 2 (GPL-2.0)
008 *
009 * For full copyright and license information, please see
010 * the docs/CREDITS.txt file.
011 *
012 */
013
014 /**#@+
015 * @ignore
016 */
017 define('IN_PHPBB', true);
018 define('IN_INSTALL', true);
019 /**#@-*/
020
021 $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../';
022 $phpEx = substr(strrchr(__FILE__, '.'), 1);
023
024 if (version_compare(PHP_VERSION, '5.3.3') < 0)
025 {
026 die('You are running an unsupported PHP version. Please upgrade to PHP 5.3.3 or higher before trying to install phpBB 3.1');
027 }
028
029 function phpbb_require_updated($path, $optional = false)
030 {
031 global $phpbb_root_path, $table_prefix;
032
033 $new_path = $phpbb_root_path . 'install/update/new/' . $path;
034 $old_path = $phpbb_root_path . $path;
035
036 if (file_exists($new_path))
037 {
038 require($new_path);
039 }
040 else if (!$optional || file_exists($old_path))
041 {
042 require($old_path);
043 }
044 }
045
046 function phpbb_include_updated($path, $optional = false)
047 {
048 global $phpbb_root_path;
049
050 $new_path = $phpbb_root_path . 'install/update/new/' . $path;
051 $old_path = $phpbb_root_path . $path;
052
053 if (file_exists($new_path))
054 {
055 include($new_path);
056 }
057 else if (!$optional || file_exists($old_path))
058 {
059 include($old_path);
060 }
061 }
062
063 phpbb_require_updated('includes/startup.' . $phpEx);
064
065 // Try to override some limits - maybe it helps some...
066 @set_time_limit(0);
067 $mem_limit = @ini_get('memory_limit');
068 if (!empty($mem_limit))
069 {
070 $unit = strtolower(substr($mem_limit, -1, 1));
071 $mem_limit = (int) $mem_limit;
072
073 if ($unit == 'k')
074 {
075 $mem_limit = floor($mem_limit / 1024);
076 }
077 else if ($unit == 'g')
078 {
079 $mem_limit *= 1024;
080 }
081 else if (is_numeric($unit))
082 {
083 $mem_limit = floor((int) ($mem_limit . $unit) / 1048576);
084 }
085 $mem_limit = max(128, $mem_limit) . 'M';
086 }
087 else
088 {
089 $mem_limit = '128M';
090 }
091 @ini_set('memory_limit', $mem_limit);
092
093 // In case $phpbb_adm_relative_path is not set (in case of an update), use the default.
094 $phpbb_adm_relative_path = (isset($phpbb_adm_relative_path)) ? $phpbb_adm_relative_path : 'adm/';
095 $phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_root_path . $phpbb_adm_relative_path;
096
097 // Include essential scripts
098 phpbb_require_updated('phpbb/class_loader.' . $phpEx);
099
100 phpbb_require_updated('includes/functions.' . $phpEx);
101
102 phpbb_require_updated('includes/functions_content.' . $phpEx, true);
103
104 phpbb_include_updated('includes/functions_admin.' . $phpEx);
105 phpbb_include_updated('includes/utf/utf_normalizer.' . $phpEx);
106 phpbb_include_updated('includes/utf/utf_tools.' . $phpEx);
107 phpbb_require_updated('includes/functions_install.' . $phpEx);
108
109 // Setup class loader first
110 $phpbb_class_loader_new = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}install/update/new/phpbb/", $phpEx);
111 $phpbb_class_loader_new->register();
112 $phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx);
113 $phpbb_class_loader->register();
114 $phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx);
115 $phpbb_class_loader_ext->register();
116
117 // Set up container
118 $phpbb_config_php_file = new \phpbb\config_php_file($phpbb_root_path, $phpEx);
119 $phpbb_container_builder = new \phpbb\di\container_builder($phpbb_config_php_file, $phpbb_root_path, $phpEx);
120 $phpbb_container_builder->set_use_extensions(false);
121 $phpbb_container_builder->set_dump_container(false);
122 $phpbb_container_builder->set_use_custom_pass(false);
123 $phpbb_container_builder->set_inject_config(false);
124 $phpbb_container_builder->set_compile_container(false);
125
126 $other_config_path = $phpbb_root_path . 'install/update/new/config/';
127 $config_path = file_exists($other_config_path . 'services.yml') ? $other_config_path : $phpbb_root_path . 'config/';
128 $phpbb_container_builder->set_config_path($config_path);
129
130 $phpbb_container_builder->set_custom_parameters(array(
131 'core.root_path' => $phpbb_root_path,
132 'core.adm_relative_path' => $phpbb_adm_relative_path,
133 'core.php_ext' => $phpEx,
134 'core.table_prefix' => '',
135 'cache.driver.class' => 'phpbb\cache\driver\file',
136 ));
137
138 $phpbb_container = $phpbb_container_builder->get_container();
139 $phpbb_container->register('dbal.conn.driver')->setSynthetic(true);
140 $phpbb_container->compile();
141
142 $phpbb_class_loader->set_cache($phpbb_container->get('cache.driver'));
143 $phpbb_class_loader_ext->set_cache($phpbb_container->get('cache.driver'));
144
145 $phpbb_dispatcher = $phpbb_container->get('dispatcher');
146 $request = $phpbb_container->get('request');
147
148 // make sure request_var uses this request instance
149 request_var('', 0, false, false, $request); // "dependency injection" for a function
150
151 // Try and load an appropriate language if required
152 $language = basename($request->variable('language', ''));
153
154 if ($request->header('Accept-Language') && !$language)
155 {
156 $accept_lang_ary = explode(',', strtolower($request->header('Accept-Language')));
157 foreach ($accept_lang_ary as $accept_lang)
158 {
159 // Set correct format ... guess full xx_yy form
160 $accept_lang = substr($accept_lang, 0, 2) . '_' . substr($accept_lang, 3, 2);
161
162 if (file_exists($phpbb_root_path . 'language/' . $accept_lang) && is_dir($phpbb_root_path . 'language/' . $accept_lang))
163 {
164 $language = $accept_lang;
165 break;
166 }
167 else
168 {
169 // No match on xx_yy so try xx
170 $accept_lang = substr($accept_lang, 0, 2);
171 if (file_exists($phpbb_root_path . 'language/' . $accept_lang) && is_dir($phpbb_root_path . 'language/' . $accept_lang))
172 {
173 $language = $accept_lang;
174 break;
175 }
176 }
177 }
178 }
179
180 // No appropriate language found ... so let's use the first one in the language
181 // dir, this may or may not be English
182 if (!$language)
183 {
184 $dir = @opendir($phpbb_root_path . 'language');
185
186 if (!$dir)
187 {
188 die('Unable to access the language directory');
189 exit;
190 }
191
192 while (($file = readdir($dir)) !== false)
193 {
194 $path = $phpbb_root_path . 'language/' . $file;
195
196 if (!is_file($path) && !is_link($path) && file_exists($path . '/iso.txt'))
197 {
198 $language = $file;
199 break;
200 }
201 }
202 closedir($dir);
203 }
204
205 if (!file_exists($phpbb_root_path . 'language/' . $language) || !is_dir($phpbb_root_path . 'language/' . $language))
206 {
207 die('No language found!');
208 }
209
210 // And finally, load the relevant language files
211 $load_lang_files = array('common', 'acp/common', 'acp/board', 'install', 'posting');
212 $new_path = $phpbb_root_path . 'install/update/new/language/' . $language . '/';
213 $old_path = $phpbb_root_path . 'language/' . $language . '/';
214
215 // NOTE: we can not use "phpbb_include_updated" as the files uses vars which would be required
216 // to be global while loading.
217 foreach ($load_lang_files as $lang_file)
218 {
219 if (file_exists($new_path . $lang_file . '.' . $phpEx))
220 {
221 include($new_path . $lang_file . '.' . $phpEx);
222 }
223 else
224 {
225 include($old_path . $lang_file . '.' . $phpEx);
226 }
227 }
228
229 // usually we would need every single constant here - and it would be consistent. For 3.0.x, use a dirty hack... :(
230
231 // Define needed constants
232 define('CHMOD_ALL', 7);
233 define('CHMOD_READ', 4);
234 define('CHMOD_WRITE', 2);
235 define('CHMOD_EXECUTE', 1);
236
237 $mode = $request->variable('mode', 'overview');
238 $sub = $request->variable('sub', '');
239
240 // Set PHP error handler to ours
241 set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler');
242
243 $user = new \phpbb\user('\phpbb\datetime');
244 $auth = new \phpbb\auth\auth();
245
246 // Add own hook handler, if present. :o
247 if (file_exists($phpbb_root_path . 'includes/hooks/index.' . $phpEx))
248 {
249 require($phpbb_root_path . 'includes/hooks/index.' . $phpEx);
250 $phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display')));
251
252 $phpbb_hook_finder = $phpbb_container->get('hook_finder');
253 foreach ($phpbb_hook_finder->find() as $hook)
254 {
255 @include($phpbb_root_path . 'includes/hooks/' . $hook . '.' . $phpEx);
256 }
257 }
258 else
259 {
260 $phpbb_hook = false;
261 }
262
263 // Set some standard variables we want to force
264 $config = new \phpbb\config\config(array(
265 'load_tplcompile' => '1'
266 ));
267
268 $symfony_request = $phpbb_container->get('symfony_request');
269 $phpbb_filesystem = $phpbb_container->get('filesystem');
270 $phpbb_path_helper = $phpbb_container->get('path_helper');
271 $template = new \phpbb\template\twig\twig($phpbb_path_helper, $config, $user, new \phpbb\template\context());
272 $paths = array($phpbb_root_path . 'install/update/new/adm/style', $phpbb_admin_path . 'style');
273 $paths = array_filter($paths, 'is_dir');
274 $template->set_custom_style(array(
275 array(
276 'name' => 'adm',
277 'ext_path' => 'adm/style/',
278 ),
279 ), $paths);
280
281 $path = array_shift($paths);
282
283 $template->assign_var('T_ASSETS_PATH', $path . '/../../assets');
284 $template->assign_var('T_TEMPLATE_PATH', $path);
285
286 $install = new module();
287
288 $install->create('install', "index.$phpEx", $mode, $sub);
289 $install->load();
290
291 // Generate the page
292 $install->page_header();
293 $install->generate_navigation();
294
295 $template->set_filenames(array(
296 'body' => $install->get_tpl_name())
297 );
298
299 $install->page_footer();
300
301 class module
302 {
303 var $id = 0;
304 var $type = 'install';
305 var $module_ary = array();
306 var $filename;
307 var $module_url = '';
308 var $tpl_name = '';
309 var $mode;
310 var $sub;
311
312 /**
313 * Private methods, should not be overwritten
314 */
315 function create($module_type, $module_url, $selected_mod = false, $selected_submod = false)
316 {
317 global $db, $config, $phpEx, $phpbb_root_path;
318
319 $module = array();
320
321 // Grab module information using Bart's "neat-o-module" system (tm)
322 $dir = @opendir('.');
323
324 if (!$dir)
325 {
326 $this->error('Unable to access the installation directory', __LINE__, __FILE__);
327 }
328
329 $setmodules = 1;
330 while (($file = readdir($dir)) !== false)
331 {
332 if (preg_match('#^install_(.*?)\.' . $phpEx . '$#', $file))
333 {
334 include($file);
335 }
336 }
337 closedir($dir);
338
339 unset($setmodules);
340
341 if (!sizeof($module))
342 {
343 $this->error('No installation modules found', __LINE__, __FILE__);
344 }
345
346 // Order to use and count further if modules get assigned to the same position or not having an order
347 $max_module_order = 1000;
348
349 foreach ($module as $row)
350 {
351 // Module order not specified or module already assigned at this position?
352 if (!isset($row['module_order']) || isset($this->module_ary[$row['module_order']]))
353 {
354 $row['module_order'] = $max_module_order;
355 $max_module_order++;
356 }
357
358 $this->module_ary[$row['module_order']]['name'] = $row['module_title'];
359 $this->module_ary[$row['module_order']]['filename'] = $row['module_filename'];
360 $this->module_ary[$row['module_order']]['subs'] = $row['module_subs'];
361 $this->module_ary[$row['module_order']]['stages'] = $row['module_stages'];
362
363 if (strtolower($selected_mod) == strtolower($row['module_title']))
364 {
365 $this->id = (int) $row['module_order'];
366 $this->filename = (string) $row['module_filename'];
367 $this->module_url = (string) $module_url;
368 $this->mode = (string) $selected_mod;
369 // Check that the sub-mode specified is valid or set a default if not
370 if (is_array($row['module_subs']))
371 {
372 $this->sub = strtolower((in_array(strtoupper($selected_submod), $row['module_subs'])) ? $selected_submod : $row['module_subs'][0]);
373 }
374 else if (is_array($row['module_stages']))
375 {
376 $this->sub = strtolower((in_array(strtoupper($selected_submod), $row['module_stages'])) ? $selected_submod : $row['module_stages'][0]);
377 }
378 else
379 {
380 $this->sub = '';
381 }
382 }
383 } // END foreach
384 } // END create
385
386 /**
387 * Load and run the relevant module if applicable
388 */
389 function load($mode = false, $run = true)
390 {
391 global $phpbb_root_path, $phpEx;
392
393 if ($run)
394 {
395 if (!empty($mode))
396 {
397 $this->mode = $mode;
398 }
399
400 $module = $this->filename;
401 if (!class_exists($module))
402 {
403 $this->error('Module "' . htmlspecialchars($module) . '" not accessible.', __LINE__, __FILE__);
404 }
405 $this->module = new $module($this);
406
407 if (method_exists($this->module, 'main'))
408 {
409 $this->module->main($this->mode, $this->sub);
410 }
411 }
412 }
413
414 /**
415 * Output the standard page header
416 */
417 function page_header()
418 {
419 if (defined('HEADER_INC'))
420 {
421 return;
422 }
423
424 define('HEADER_INC', true);
425 global $template, $lang, $stage, $phpbb_admin_path, $path;
426
427 $template->assign_vars(array(
428 'L_CHANGE' => $lang['CHANGE'],
429 'L_COLON' => $lang['COLON'],
430 'L_INSTALL_PANEL' => $lang['INSTALL_PANEL'],
431 'L_SELECT_LANG' => $lang['SELECT_LANG'],
432 'L_SKIP' => $lang['SKIP'],
433 'PAGE_TITLE' => $this->get_page_title(),
434 'T_IMAGE_PATH' => htmlspecialchars($phpbb_admin_path) . 'images/',
435 'T_JQUERY_LINK' => $path . '/../../assets/javascript/jquery.min.js',
436
437 'S_CONTENT_DIRECTION' => $lang['DIRECTION'],
438 'S_CONTENT_FLOW_BEGIN' => ($lang['DIRECTION'] == 'ltr') ? 'left' : 'right',
439 'S_CONTENT_FLOW_END' => ($lang['DIRECTION'] == 'ltr') ? 'right' : 'left',
440 'S_CONTENT_ENCODING' => 'UTF-8',
441
442 'S_USER_LANG' => $lang['USER_LANG'],
443 )
444 );
445
446 header('Content-type: text/html; charset=UTF-8');
447 header('Cache-Control: private, no-cache="set-cookie"');
448 header('Expires: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
449
450 return;
451 }
452
453 /**
454 * Output the standard page footer
455 */
456 function page_footer()
457 {
458 global $db, $template;
459
460 $template->display('body');
461
462 // Close our DB connection.
463 if (!empty($db) && is_object($db))
464 {
465 $db->sql_close();
466 }
467
468 if (function_exists('exit_handler'))
469 {
470 exit_handler();
471 }
472 }
473
474 /**
475 * Returns desired template name
476 */
477 function get_tpl_name()
478 {
479 return $this->module->tpl_name . '.html';
480 }
481
482 /**
483 * Returns the desired page title
484 */
485 function get_page_title()
486 {
487 global $lang;
488
489 if (!isset($this->module->page_title))
490 {
491 return '';
492 }
493
494 return (isset($lang[$this->module->page_title])) ? $lang[$this->module->page_title] : $this->module->page_title;
495 }
496
497 /**
498 * Generate an HTTP/1.1 header to redirect the user to another page
499 * This is used during the installation when we do not have a database available to call the normal redirect function
500 * @param string $page The page to redirect to relative to the installer root path
501 */
502 function redirect($page)
503 {
504 global $request;
505
506 // HTTP_HOST is having the correct browser url in most cases...
507 $server_name = strtolower(htmlspecialchars_decode($request->header('Host', $request->server('SERVER_NAME'))));
508 $server_port = $request->server('SERVER_PORT', 0);
509 $secure = $request->is_secure() ? 1 : 0;
510
511 $script_name = htmlspecialchars_decode($request->server('PHP_SELF'));
512 if (!$script_name)
513 {
514 $script_name = htmlspecialchars_decode($request->server('REQUEST_URI'));
515 }
516
517 // Replace backslashes and doubled slashes (could happen on some proxy setups)
518 $script_name = str_replace(array('\\', '//'), '/', $script_name);
519 $script_path = trim(dirname($script_name));
520
521 $url = (($secure) ? 'https://' : 'http://') . $server_name;
522
523 if ($server_port && (($secure && $server_port <> 443) || (!$secure && $server_port <> 80)))
524 {
525 // HTTP HOST can carry a port number...
526 if (strpos($server_name, ':') === false)
527 {
528 $url .= ':' . $server_port;
529 }
530 }
531
532 $url .= $script_path . '/' . $page;
533 header('Location: ' . $url);
534 exit;
535 }
536
537 /**
538 * Generate the navigation tabs
539 */
540 function generate_navigation()
541 {
542 global $lang, $template, $phpEx, $language;
543
544 if (is_array($this->module_ary))
545 {
546 @ksort($this->module_ary);
547 foreach ($this->module_ary as $cat_ary)
548 {
549 $cat = $cat_ary['name'];
550 $l_cat = (!empty($lang['CAT_' . $cat])) ? $lang['CAT_' . $cat] : preg_replace('#_#', ' ', $cat);
551 $cat = strtolower($cat);
552 $url = $this->module_url . "?mode=$cat&language=$language";
553
554 if ($this->mode == $cat)
555 {
556 $template->assign_block_vars('t_block1', array(
557 'L_TITLE' => $l_cat,
558 'S_SELECTED' => true,
559 'U_TITLE' => $url,
560 ));
561
562 if (is_array($this->module_ary[$this->id]['subs']))
563 {
564 $subs = $this->module_ary[$this->id]['subs'];
565 foreach ($subs as $option)
566 {
567 $l_option = (!empty($lang['SUB_' . $option])) ? $lang['SUB_' . $option] : preg_replace('#_#', ' ', $option);
568 $option = strtolower($option);
569 $url = $this->module_url . '?mode=' . $this->mode . "&sub=$option&language=$language";
570
571 $template->assign_block_vars('l_block1', array(
572 'L_TITLE' => $l_option,
573 'S_SELECTED' => ($this->sub == $option),
574 'U_TITLE' => $url,
575 ));
576 }
577 }
578
579 if (is_array($this->module_ary[$this->id]['stages']))
580 {
581 $subs = $this->module_ary[$this->id]['stages'];
582 $matched = false;
583 foreach ($subs as $option)
584 {
585 $l_option = (!empty($lang['STAGE_' . $option])) ? $lang['STAGE_' . $option] : preg_replace('#_#', ' ', $option);
586 $option = strtolower($option);
587 $matched = ($this->sub == $option) ? true : $matched;
588
589 $template->assign_block_vars('l_block2', array(
590 'L_TITLE' => $l_option,
591 'S_SELECTED' => ($this->sub == $option),
592 'S_COMPLETE' => !$matched,
593 ));
594 }
595 }
596 }
597 else
598 {
599 $template->assign_block_vars('t_block1', array(
600 'L_TITLE' => $l_cat,
601 'S_SELECTED' => false,
602 'U_TITLE' => $url,
603 ));
604 }
605 }
606 }
607 }
608
609 /**
610 * Output an error message
611 * If skip is true, return and continue execution, else exit
612 */
613 function error($error, $line, $file, $skip = false)
614 {
615 global $lang, $db, $template, $phpbb_admin_path;
616
617 if ($skip)
618 {
619 $template->assign_block_vars('checks', array(
620 'S_LEGEND' => true,
621 'LEGEND' => $lang['INST_ERR'],
622 ));
623
624 $template->assign_block_vars('checks', array(
625 'TITLE' => basename($file) . ' [ ' . $line . ' ]',
626 'RESULT' => '<b style="color:red">' . $error . '</b>',
627 ));
628
629 return;
630 }
631
632 echo '<!DOCTYPE html>';
633 echo '<html dir="ltr">';
634 echo '<head>';
635 echo '<meta charset="utf-8">';
636 echo '<title>' . $lang['INST_ERR_FATAL'] . '</title>';
637 echo '<link href="' . htmlspecialchars($phpbb_admin_path) . 'style/admin.css" rel="stylesheet" type="text/css" media="screen" />';
638 echo '</head>';
639 echo '<body id="errorpage">';
640 echo '<div id="wrap">';
641 echo ' <div id="page-header">';
642 echo ' </div>';
643 echo ' <div id="page-body">';
644 echo ' <div id="acp">';
645 echo ' <div class="panel">';
646 echo ' <span class="corners-top"><span></span></span>';
647 echo ' <div id="content">';
648 echo ' <h1>' . $lang['INST_ERR_FATAL'] . '</h1>';
649 echo ' <p>' . $lang['INST_ERR_FATAL'] . "</p>\n";
650 echo ' <p>' . basename($file) . ' [ ' . $line . " ]</p>\n";
651 echo ' <p><b>' . $error . "</b></p>\n";
652 echo ' </div>';
653 echo ' <span class="corners-bottom"><span></span></span>';
654 echo ' </div>';
655 echo ' </div>';
656 echo ' </div>';
657 echo ' <div id="page-footer">';
658 echo ' Powered by <a href="https://www.phpbb.com/">phpBB</a>® Forum Software © phpBB Limited';
659 echo ' </div>';
660 echo '</div>';
661 echo '</body>';
662 echo '</html>';
663
664 if (!empty($db) && is_object($db))
665 {
666 $db->sql_close();
667 }
668
669 exit_handler();
670 }
671
672 /**
673 * Output an error message for a database related problem
674 * If skip is true, return and continue execution, else exit
675 */
676 function db_error($error, $sql, $line, $file, $skip = false)
677 {
678 global $lang, $db, $template;
679
680 if ($skip)
681 {
682 $template->assign_block_vars('checks', array(
683 'S_LEGEND' => true,
684 'LEGEND' => $lang['INST_ERR_FATAL'],
685 ));
686
687 $template->assign_block_vars('checks', array(
688 'TITLE' => basename($file) . ' [ ' . $line . ' ]',
689 'RESULT' => '<b style="color:red">' . $error . '</b><br />» SQL:' . $sql,
690 ));
691
692 return;
693 }
694
695 $template->set_filenames(array(
696 'body' => 'install_error.html')
697 );
698 $this->page_header();
699 $this->generate_navigation();
700
701 $template->assign_vars(array(
702 'MESSAGE_TITLE' => $lang['INST_ERR_FATAL_DB'],
703 'MESSAGE_TEXT' => '<p>' . basename($file) . ' [ ' . $line . ' ]</p><p>SQL : ' . $sql . '</p><p><b>' . $error . '</b></p>',
704 ));
705
706 // Rollback if in transaction
707 if ($db->get_transaction())
708 {
709 $db->sql_transaction('rollback');
710 }
711
712 $this->page_footer();
713 }
714
715 /**
716 * Generate the relevant HTML for an input field and the associated label and explanatory text
717 */
718 function input_field($name, $type, $value = '', $options = '')
719 {
720 global $lang;
721 $tpl_type = explode(':', $type);
722 $tpl = '';
723
724 switch ($tpl_type[0])
725 {
726 case 'text':
727 case 'password':
728 // HTML5 text-like input types
729 case 'color':
730 case 'date':
731 case 'time':
732 case 'datetime':
733 case 'datetime-local':
734 case 'email':
735 case 'month':
736 case 'number':
737 case 'range':
738 case 'search':
739 case 'tel':
740 case 'url':
741 case 'week':
742
743 $size = (int) $tpl_type[1];
744 $maxlength = (int) $tpl_type[2];
745 $autocomplete = (isset($options['autocomplete']) && $options['autocomplete'] == 'off') ? ' autocomplete="off"' : '';
746
747 $tpl = '<input id="' . $name . '" type="' . $tpl_type[0] . '"' . (($size) ? ' size="' . $size . '"' : '') . ' maxlength="' . (($maxlength) ? $maxlength : 255) . '" name="' . $name . '"' . $autocomplete . ' value="' . $value . '" />';
748 break;
749
750 case 'textarea':
751 $rows = (int) $tpl_type[1];
752 $cols = (int) $tpl_type[2];
753
754 $tpl = '<textarea id="' . $name . '" name="' . $name . '" rows="' . $rows . '" cols="' . $cols . '">' . $value . '</textarea>';
755 break;
756
757 case 'radio':
758 $key_yes = ($value) ? ' checked="checked" id="' . $name . '"' : '';
759 $key_no = (!$value) ? ' checked="checked" id="' . $name . '"' : '';
760
761 $tpl_type_cond = explode('_', $tpl_type[1]);
762 $type_no = ($tpl_type_cond[0] == 'disabled' || $tpl_type_cond[0] == 'enabled') ? false : true;
763
764 $tpl_no = '<label><input type="radio" name="' . $name . '" value="0"' . $key_no . ' class="radio" /> ' . (($type_no) ? $lang['NO'] : $lang['DISABLED']) . '</label>';
765 $tpl_yes = '<label><input type="radio" name="' . $name . '" value="1"' . $key_yes . ' class="radio" /> ' . (($type_no) ? $lang['YES'] : $lang['ENABLED']) . '</label>';
766
767 $tpl = ($tpl_type_cond[0] == 'yes' || $tpl_type_cond[0] == 'enabled') ? $tpl_yes . ' ' . $tpl_no : $tpl_no . ' ' . $tpl_yes;
768 break;
769
770 case 'select':
771 // @codingStandardsIgnoreStart
772 eval('$s_options = ' . str_replace('{VALUE}', $value, $options) . ';');
773 // @codingStandardsIgnoreEnd
774 $tpl = '<select id="' . $name . '" name="' . $name . '">' . $s_options . '</select>';
775 break;
776
777 case 'custom':
778 // @codingStandardsIgnoreStart
779 eval('$tpl = ' . str_replace('{VALUE}', $value, $options) . ';');
780 // @codingStandardsIgnoreEnd
781 break;
782
783 default:
784 break;
785 }
786
787 return $tpl;
788 }
789
790 /**
791 * Generate the drop down of available language packs
792 */
793 function inst_language_select($default = '')
794 {
795 global $phpbb_root_path, $phpEx;
796
797 $dir = @opendir($phpbb_root_path . 'language');
798
799 if (!$dir)
800 {
801 $this->error('Unable to access the language directory', __LINE__, __FILE__);
802 }
803
804 while ($file = readdir($dir))
805 {
806 $path = $phpbb_root_path . 'language/' . $file;
807
808 if ($file == '.' || $file == '..' || is_link($path) || is_file($path) || $file == 'CVS')
809 {
810 continue;
811 }
812
813 if (file_exists($path . '/iso.txt'))
814 {
815 list($displayname, $localname) = @file($path . '/iso.txt');
816 $lang[$localname] = $file;
817 }
818 }
819 closedir($dir);
820
821 @asort($lang);
822 @reset($lang);
823
824 $user_select = '';
825 foreach ($lang as $displayname => $filename)
826 {
827 $selected = (strtolower($default) == strtolower($filename)) ? ' selected="selected"' : '';
828 $user_select .= '<option value="' . $filename . '"' . $selected . '>' . ucwords($displayname) . '</option>';
829 }
830
831 return $user_select;
832 }
833 }
834