[ Index ]

PHP Cross Reference of phpBB-3.1.12-deutsch

title

Body

[close]

/install/ -> index.php (source)

   1  <?php
   2  /**
   3  *
   4  * This file is part of the phpBB Forum Software package.
   5  *
   6  * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7  * @license GNU General Public License, version 2 (GPL-2.0)
   8  *
   9  * For full copyright and license information, please see
  10  * the docs/CREDITS.txt file.
  11  *
  12  */
  13  
  14  /**#@+
  15  * @ignore
  16  */
  17  define('IN_PHPBB', true);
  18  define('IN_INSTALL', true);
  19  /**#@-*/
  20  
  21  $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../';
  22  $phpEx = substr(strrchr(__FILE__, '.'), 1);
  23  
  24  if (version_compare(PHP_VERSION, '5.3.3') < 0)
  25  {
  26      die('You are running an unsupported PHP version. Please upgrade to PHP 5.3.3 or higher before trying to install phpBB 3.1');
  27  }
  28  
  29  function phpbb_require_updated($path, $optional = false)
  30  {
  31      global $phpbb_root_path, $table_prefix;
  32  
  33      $new_path = $phpbb_root_path . 'install/update/new/' . $path;
  34      $old_path = $phpbb_root_path . $path;
  35  
  36      if (file_exists($new_path))
  37      {
  38          require($new_path);
  39      }
  40      else if (!$optional || file_exists($old_path))
  41      {
  42          require($old_path);
  43      }
  44  }
  45  
  46  function phpbb_include_updated($path, $optional = false)
  47  {
  48      global $phpbb_root_path;
  49  
  50      $new_path = $phpbb_root_path . 'install/update/new/' . $path;
  51      $old_path = $phpbb_root_path . $path;
  52  
  53      if (file_exists($new_path))
  54      {
  55          include($new_path);
  56      }
  57      else if (!$optional || file_exists($old_path))
  58      {
  59          include($old_path);
  60      }
  61  }
  62  
  63  phpbb_require_updated('includes/startup.' . $phpEx);
  64  
  65  // Try to override some limits - maybe it helps some...
  66  @set_time_limit(0);
  67  $mem_limit = @ini_get('memory_limit');
  68  if (!empty($mem_limit))
  69  {
  70      $unit = strtolower(substr($mem_limit, -1, 1));
  71      $mem_limit = (int) $mem_limit;
  72  
  73      if ($unit == 'k')
  74      {
  75          $mem_limit = floor($mem_limit / 1024);
  76      }
  77      else if ($unit == 'g')
  78      {
  79          $mem_limit *= 1024;
  80      }
  81      else if (is_numeric($unit))
  82      {
  83          $mem_limit = floor((int) ($mem_limit . $unit) / 1048576);
  84      }
  85      $mem_limit = max(128, $mem_limit) . 'M';
  86  }
  87  else
  88  {
  89      $mem_limit = '128M';
  90  }
  91  @ini_set('memory_limit', $mem_limit);
  92  
  93  // In case $phpbb_adm_relative_path is not set (in case of an update), use the default.
  94  $phpbb_adm_relative_path = (isset($phpbb_adm_relative_path)) ? $phpbb_adm_relative_path : 'adm/';
  95  $phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : $phpbb_root_path . $phpbb_adm_relative_path;
  96  
  97  // Include essential scripts
  98  phpbb_require_updated('phpbb/class_loader.' . $phpEx);
  99  
 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&amp;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 . "&amp;sub=$option&amp;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 '<meta http-equiv="X-UA-Compatible" content="IE=edge">';
 637          echo '<title>' . $lang['INST_ERR_FATAL'] . '</title>';
 638          echo '<link href="' . htmlspecialchars($phpbb_admin_path) . 'style/admin.css" rel="stylesheet" type="text/css" media="screen" />';
 639          echo '</head>';
 640          echo '<body id="errorpage">';
 641          echo '<div id="wrap">';
 642          echo '    <div id="page-header">';
 643          echo '    </div>';
 644          echo '    <div id="page-body">';
 645          echo '        <div id="acp">';
 646          echo '        <div class="panel">';
 647          echo '            <span class="corners-top"><span></span></span>';
 648          echo '            <div id="content">';
 649          echo '                <h1>' . $lang['INST_ERR_FATAL'] . '</h1>';
 650          echo '        <p>' . $lang['INST_ERR_FATAL'] . "</p>\n";
 651          echo '        <p>' . basename($file) . ' [ ' . $line . " ]</p>\n";
 652          echo '        <p><b>' . $error . "</b></p>\n";
 653          echo '            </div>';
 654          echo '            <span class="corners-bottom"><span></span></span>';
 655          echo '        </div>';
 656          echo '        </div>';
 657          echo '    </div>';
 658          echo '    <div id="page-footer">';
 659          echo '        Powered by <a href="https://www.phpbb.com/">phpBB</a>&reg; Forum Software &copy; phpBB Limited';
 660          echo '    </div>';
 661          echo '</div>';
 662          echo '</body>';
 663          echo '</html>';
 664  
 665          if (!empty($db) && is_object($db))
 666          {
 667              $db->sql_close();
 668          }
 669  
 670          exit_handler();
 671      }
 672  
 673      /**
 674      * Output an error message for a database related problem
 675      * If skip is true, return and continue execution, else exit
 676      */
 677  	function db_error($error, $sql, $line, $file, $skip = false)
 678      {
 679          global $lang, $db, $template;
 680  
 681          if ($skip)
 682          {
 683              $template->assign_block_vars('checks', array(
 684                  'S_LEGEND'    => true,
 685                  'LEGEND'    => $lang['INST_ERR_FATAL'],
 686              ));
 687  
 688              $template->assign_block_vars('checks', array(
 689                  'TITLE'        => basename($file) . ' [ ' . $line . ' ]',
 690                  'RESULT'    => '<b style="color:red">' . $error . '</b><br />&#187; SQL:' . $sql,
 691              ));
 692  
 693              return;
 694          }
 695  
 696          $template->set_filenames(array(
 697              'body' => 'install_error.html')
 698          );
 699          $this->page_header();
 700          $this->generate_navigation();
 701  
 702          $template->assign_vars(array(
 703              'MESSAGE_TITLE'        => $lang['INST_ERR_FATAL_DB'],
 704              'MESSAGE_TEXT'        => '<p>' . basename($file) . ' [ ' . $line . ' ]</p><p>SQL : ' . $sql . '</p><p><b>' . $error . '</b></p>',
 705          ));
 706  
 707          // Rollback if in transaction
 708          if ($db->get_transaction())
 709          {
 710              $db->sql_transaction('rollback');
 711          }
 712  
 713          $this->page_footer();
 714      }
 715  
 716      /**
 717      * Generate the relevant HTML for an input field and the associated label and explanatory text
 718      */
 719  	function input_field($name, $type, $value = '', $options = '')
 720      {
 721          global $lang;
 722          $tpl_type = explode(':', $type);
 723          $tpl = '';
 724  
 725          switch ($tpl_type[0])
 726          {
 727              case 'text':
 728              case 'password':
 729              // HTML5 text-like input types
 730              case 'color':
 731              case 'date':
 732              case 'time':
 733              case 'datetime':
 734              case 'datetime-local':
 735              case 'email':
 736              case 'month':
 737              case 'number':
 738              case 'range':
 739              case 'search':
 740              case 'tel':
 741              case 'url':
 742              case 'week':
 743  
 744                  $size = (int) $tpl_type[1];
 745                  $maxlength = (int) $tpl_type[2];
 746                  $autocomplete = (isset($options['autocomplete']) && $options['autocomplete'] == 'off') ? ' autocomplete="off"' : '';
 747  
 748                  $tpl = '<input id="' . $name . '" type="' . $tpl_type[0] . '"' . (($size) ? ' size="' . $size . '"' : '') . ' maxlength="' . (($maxlength) ? $maxlength : 255) . '" name="' . $name . '"' . $autocomplete . ' value="' . $value . '" />';
 749              break;
 750  
 751              case 'textarea':
 752                  $rows = (int) $tpl_type[1];
 753                  $cols = (int) $tpl_type[2];
 754  
 755                  $tpl = '<textarea id="' . $name . '" name="' . $name . '" rows="' . $rows . '" cols="' . $cols . '">' . $value . '</textarea>';
 756              break;
 757  
 758              case 'radio':
 759                  $key_yes    = ($value) ? ' checked="checked" id="' . $name . '"' : '';
 760                  $key_no        = (!$value) ? ' checked="checked" id="' . $name . '"' : '';
 761  
 762                  $tpl_type_cond = explode('_', $tpl_type[1]);
 763                  $type_no = ($tpl_type_cond[0] == 'disabled' || $tpl_type_cond[0] == 'enabled') ? false : true;
 764  
 765                  $tpl_no = '<label><input type="radio" name="' . $name . '" value="0"' . $key_no . ' class="radio" /> ' . (($type_no) ? $lang['NO'] : $lang['DISABLED']) . '</label>';
 766                  $tpl_yes = '<label><input type="radio" name="' . $name . '" value="1"' . $key_yes . ' class="radio" /> ' . (($type_no) ? $lang['YES'] : $lang['ENABLED']) . '</label>';
 767  
 768                  $tpl = ($tpl_type_cond[0] == 'yes' || $tpl_type_cond[0] == 'enabled') ? $tpl_yes . '&nbsp;&nbsp;' . $tpl_no : $tpl_no . '&nbsp;&nbsp;' . $tpl_yes;
 769              break;
 770  
 771              case 'select':
 772                  // @codingStandardsIgnoreStart
 773                  eval('$s_options = ' . str_replace('{VALUE}', $value, $options) . ';');
 774                  // @codingStandardsIgnoreEnd
 775                  $tpl = '<select id="' . $name . '" name="' . $name . '">' . $s_options . '</select>';
 776              break;
 777  
 778              case 'custom':
 779                  // @codingStandardsIgnoreStart
 780                  eval('$tpl = ' . str_replace('{VALUE}', $value, $options) . ';');
 781                  // @codingStandardsIgnoreEnd
 782              break;
 783  
 784              default:
 785              break;
 786          }
 787  
 788          return $tpl;
 789      }
 790  
 791      /**
 792      * Generate the drop down of available language packs
 793      */
 794  	function inst_language_select($default = '')
 795      {
 796          global $phpbb_root_path, $phpEx;
 797  
 798          $dir = @opendir($phpbb_root_path . 'language');
 799  
 800          if (!$dir)
 801          {
 802              $this->error('Unable to access the language directory', __LINE__, __FILE__);
 803          }
 804  
 805          while ($file = readdir($dir))
 806          {
 807              $path = $phpbb_root_path . 'language/' . $file;
 808  
 809              if ($file == '.' || $file == '..' || is_link($path) || is_file($path) || $file == 'CVS')
 810              {
 811                  continue;
 812              }
 813  
 814              if (file_exists($path . '/iso.txt'))
 815              {
 816                  list($displayname, $localname) = @file($path . '/iso.txt');
 817                  $lang[$localname] = $file;
 818              }
 819          }
 820          closedir($dir);
 821  
 822          @asort($lang);
 823          @reset($lang);
 824  
 825          $user_select = '';
 826          foreach ($lang as $displayname => $filename)
 827          {
 828              $selected = (strtolower($default) == strtolower($filename)) ? ' selected="selected"' : '';
 829              $user_select .= '<option value="' . $filename . '"' . $selected . '>' . ucwords($displayname) . '</option>';
 830          }
 831  
 832          return $user_select;
 833      }
 834  }


Generated: Thu Jan 11 00:25:41 2018 Cross-referenced by PHPXref 0.7.1