Search moodle.org's
Developer Documentation


/ -> install.php (source)
   1  <?php
   2  
   3  // This file is part of Moodle - http://moodle.org/
   4  //
   5  // Moodle is free software: you can redistribute it and/or modify
   6  // it under the terms of the GNU General Public License as published by
   7  // the Free Software Foundation, either version 3 of the License, or
   8  // (at your option) any later version.
   9  //
  10  // Moodle is distributed in the hope that it will be useful,
  11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13  // GNU General Public License for more details.
  14  //
  15  // You should have received a copy of the GNU General Public License
  16  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  17  
  18  /**
  19   * This script creates config.php file during installation.
  20   *
  21   * @package    core
  22   * @subpackage install
  23   * @copyright  2009 Petr Skoda (http://skodak.org)
  24   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  25   */
  26  
  27  if (isset($_REQUEST['lang'])) {
  28      $lang = preg_replace('/[^A-Za-z0-9_-]/i', '', $_REQUEST['lang']);
  29  } else {
  30      $lang = 'en';
  31  }
  32  
  33  if (isset($_REQUEST['admin'])) {
  34      $admin = preg_replace('/[^A-Za-z0-9_-]/i', '', $_REQUEST['admin']);
  35  } else {
  36      $admin = 'admin';
  37  }
  38  
  39  // If config.php exists we just created config.php and need to redirect to continue installation
  40  $configfile = './config.php';
  41  if (file_exists($configfile)) {
  42      header("Location: $admin/index.php?lang=$lang");
  43      die;
  44  }
  45  
  46  define('CLI_SCRIPT', false); // prevents some warnings later
  47  define('AJAX_SCRIPT', false); // prevents some warnings later
  48  define('CACHE_DISABLE_ALL', true); // Disables caching.. just in case.
  49  define('PHPUNIT_TEST', false);
  50  define('IGNORE_COMPONENT_CACHE', true);
  51  
  52  // Servers should define a default timezone in php.ini, but if they don't then make sure something is defined.
  53  // This is a quick hack.  Ideally we should ask the admin for a value.  See MDL-22625 for more on this.
  54  if (function_exists('date_default_timezone_set') and function_exists('date_default_timezone_get')) {
  55      @date_default_timezone_set(@date_default_timezone_get());
  56  }
  57  
  58  // make sure PHP errors are displayed - helps with diagnosing of problems
  59  @error_reporting(E_ALL);
  60  @ini_set('display_errors', '1');
  61  
  62  // Check that PHP is of a sufficient version.
  63  if (version_compare(phpversion(), '5.3.3') < 0) {
  64      $phpversion = phpversion();
  65      // do NOT localise - lang strings would not work here and we CAN not move it after installib
  66      echo "Moodle 2.5 or later requires at least PHP 5.3.3 (currently using version $phpversion).<br />";
  67      echo "Please upgrade your server software or install older Moodle version.";
  68      die;
  69  }
  70  
  71  // make sure iconv is available and actually works
  72  if (!function_exists('iconv')) {
  73      // this should not happen, this must be very borked install
  74      echo 'Moodle requires the iconv PHP extension. Please install or enable the iconv extension.';
  75      die();
  76  }
  77  
  78  if (PHP_INT_SIZE > 4) {
  79      // most probably 64bit PHP - we need a lot more memory
  80      $minrequiredmemory = '70M';
  81  } else {
  82      // 32bit PHP
  83      $minrequiredmemory = '40M';
  84  }
  85  // increase or decrease available memory - we need to make sure moodle
  86  // installs even with low memory, otherwise developers would overlook
  87  // sudden increases of memory needs ;-)
  88  @ini_set('memory_limit', $minrequiredmemory);
  89  
  90  /** Used by library scripts to check they are being called by Moodle */
  91  define('MOODLE_INTERNAL', true);
  92  
  93  require_once (__DIR__.'/lib/classes/component.php');
  94  require_once (__DIR__.'/lib/installlib.php');
  95  
  96  // TODO: add lang detection here if empty $_REQUEST['lang']
  97  
  98  // distro specific customisation
  99  $distro = null;
 100  if (file_exists('install/distrolib.php')) {
 101      require_once('install/distrolib.php');
 102      if (function_exists('distro_get_config')) {
 103          $distro = distro_get_config();
 104      }
 105  }
 106  
 107  $config = new stdClass();
 108  $config->lang = $lang;
 109  
 110  if (!empty($_POST)) {
 111      if (install_ini_get_bool('magic_quotes_gpc')) {
 112          $_POST = array_map('stripslashes', $_POST);
 113      }
 114  
 115      $config->stage = (int)$_POST['stage'];
 116  
 117      if (isset($_POST['previous'])) {
 118          $config->stage--;
 119          if (INSTALL_DATABASETYPE and !empty($distro->dbtype)) {
 120              $config->stage--;
 121          }
 122          if ($config->stage == INSTALL_ENVIRONMENT or $config->stage == INSTALL_DOWNLOADLANG) {
 123              $config->stage--;
 124          }
 125      } else if (isset($_POST['next'])) {
 126          $config->stage++;
 127      }
 128  
 129      $config->dbtype   = trim($_POST['dbtype']);
 130      $config->dbhost   = trim($_POST['dbhost']);
 131      $config->dbuser   = trim($_POST['dbuser']);
 132      $config->dbpass   = trim($_POST['dbpass']);
 133      $config->dbname   = trim($_POST['dbname']);
 134      $config->prefix   = trim($_POST['prefix']);
 135      $config->dbport   = (int)trim($_POST['dbport']);
 136      $config->dbsocket = trim($_POST['dbsocket']);
 137  
 138      if ($config->dbport <= 0) {
 139          $config->dbport = '';
 140      }
 141  
 142      $config->admin    = empty($_POST['admin']) ? 'admin' : trim($_POST['admin']);
 143  
 144      $config->dataroot = trim($_POST['dataroot']);
 145  
 146  } else {
 147      $config->stage    = INSTALL_WELCOME;
 148  
 149      $config->dbtype   = empty($distro->dbtype) ? '' : $distro->dbtype; // let distro skip dbtype selection
 150      $config->dbhost   = empty($distro->dbhost) ? 'localhost' : $distro->dbhost; // let distros set dbhost
 151      $config->dbuser   = empty($distro->dbuser) ? '' : $distro->dbuser; // let distros set dbuser
 152      $config->dbpass   = '';
 153      $config->dbname   = 'moodle';
 154      $config->prefix   = 'mdl_';
 155      $config->dbport   = empty($distro->dbport) ? '' : $distro->dbport;
 156      $config->dbsocket = empty($distro->dbsocket) ? '' : $distro->dbsocket;
 157  
 158      $config->admin    = 'admin';
 159  
 160      $config->dataroot = empty($distro->dataroot) ? null  : $distro->dataroot; // initialised later after including libs or by distro
 161  }
 162  
 163  // Fake some settings so that we can use selected functions from moodlelib.php, weblib.php and filelib.php.
 164  global $CFG;
 165  $CFG = new stdClass();
 166  $CFG->lang                 = $config->lang;
 167  $CFG->dirroot              = dirname(__FILE__);
 168  $CFG->libdir               = "$CFG->dirroot/lib";
 169  $CFG->wwwroot              = install_guess_wwwroot(); // can not be changed - ppl must use the real address when installing
 170  $CFG->httpswwwroot         = $CFG->wwwroot;
 171  $CFG->dataroot             = $config->dataroot;
 172  $CFG->tempdir              = $CFG->dataroot.'/temp';
 173  $CFG->cachedir             = $CFG->dataroot.'/cache';
 174  $CFG->localcachedir        = $CFG->dataroot.'/localcache';
 175  $CFG->admin                = $config->admin;
 176  $CFG->docroot              = 'http://docs.moodle.org';
 177  $CFG->langotherroot        = $CFG->dataroot.'/lang';
 178  $CFG->langlocalroot        = $CFG->dataroot.'/lang';
 179  $CFG->directorypermissions = isset($distro->directorypermissions) ? $distro->directorypermissions : 00777; // let distros set dir permissions
 180  $CFG->filepermissions      = ($CFG->directorypermissions & 0666);
 181  $CFG->umaskpermissions     = (($CFG->directorypermissions & 0777) ^ 0777);
 182  $CFG->running_installer    = true;
 183  $CFG->early_install_lang   = true;
 184  $CFG->ostype               = (stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin')) ? 'WINDOWS' : 'UNIX';
 185  $CFG->debug                = (E_ALL | E_STRICT);
 186  $CFG->debugdisplay         = true;
 187  $CFG->debugdeveloper       = true;
 188  
 189  // Require all needed libs
 190  require_once($CFG->libdir.'/setuplib.php');
 191  
 192  // we need to make sure we have enough memory to load all libraries
 193  $memlimit = @ini_get('memory_limit');
 194  if (!empty($memlimit) and $memlimit != -1) {
 195      if (get_real_size($memlimit) < get_real_size($minrequiredmemory)) {
 196          // do NOT localise - lang strings would not work here and we CAN not move it to later place
 197          echo "Moodle requires at least {$minrequiredmemory}B of PHP memory.<br />";
 198          echo "Please contact server administrator to fix PHP.ini memory settings.";
 199          die;
 200      }
 201  }
 202  
 203  // Continue with lib loading
 204  require_once($CFG->libdir.'/classes/text.php');
 205  require_once($CFG->libdir.'/classes/string_manager.php');
 206  require_once($CFG->libdir.'/classes/string_manager_install.php');
 207  require_once($CFG->libdir.'/classes/string_manager_standard.php');
 208  require_once($CFG->libdir.'/weblib.php');
 209  require_once($CFG->libdir.'/outputlib.php');
 210  require_once($CFG->libdir.'/dmllib.php');
 211  require_once($CFG->libdir.'/moodlelib.php');
 212  require_once($CFG->libdir .'/pagelib.php');
 213  require_once($CFG->libdir.'/deprecatedlib.php');
 214  require_once($CFG->libdir.'/adminlib.php');
 215  require_once($CFG->libdir.'/environmentlib.php');
 216  require_once($CFG->libdir.'/componentlib.class.php');
 217  require_once($CFG->dirroot.'/cache/lib.php');
 218  
 219  //point pear include path to moodles lib/pear so that includes and requires will search there for files before anywhere else
 220  //the problem is that we need specific version of quickforms and hacked excel files :-(
 221  ini_set('include_path', $CFG->libdir.'/pear' . PATH_SEPARATOR . ini_get('include_path'));
 222  //point zend include path to moodles lib/zend so that includes and requires will search there for files before anywhere else
 223  ini_set('include_path', $CFG->libdir.'/zend' . PATH_SEPARATOR . ini_get('include_path'));
 224  
 225  // Register our classloader, in theory somebody might want to replace it to load other hacked core classes.
 226  // Required because the database checks below lead to session interaction which is going to lead us to requiring autoloaded classes.
 227  if (defined('COMPONENT_CLASSLOADER')) {
 228      spl_autoload_register(COMPONENT_CLASSLOADER);
 229  } else {
 230      spl_autoload_register('core_component::classloader');
 231  }
 232  
 233  require ('version.php');
 234  $CFG->target_release = $release;
 235  
 236  \core\session\manager::init_empty_session();
 237  global $SESSION;
 238  global $USER;
 239  
 240  global $COURSE;
 241  $COURSE = new stdClass();
 242  $COURSE->id = 1;
 243  
 244  global $SITE;
 245  $SITE = $COURSE;
 246  define('SITEID', 1);
 247  
 248  $hint_dataroot = '';
 249  $hint_admindir = '';
 250  $hint_database = '';
 251  
 252  // Are we in help mode?
 253  if (isset($_GET['help'])) {
 254      install_print_help_page($_GET['help']);
 255  }
 256  
 257  //first time here? find out suitable dataroot
 258  if (is_null($CFG->dataroot)) {
 259      $CFG->dataroot = dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'moodledata';
 260  
 261      $i = 0; //safety check - dirname might return some unexpected results
 262      while(is_dataroot_insecure()) {
 263          $parrent = dirname($CFG->dataroot);
 264          $i++;
 265          if ($parrent == '/' or $parrent == '.' or preg_match('/^[a-z]:\\\?$/i', $parrent) or ($i > 100)) {
 266              $CFG->dataroot = ''; //can not find secure location for dataroot
 267              break;
 268          }
 269          $CFG->dataroot = dirname($parrent).DIRECTORY_SEPARATOR.'moodledata';
 270      }
 271      $config->dataroot = $CFG->dataroot;
 272      $config->stage    = INSTALL_WELCOME;
 273  }
 274  
 275  // now let's do the stage work
 276  if ($config->stage < INSTALL_WELCOME) {
 277      $config->stage = INSTALL_WELCOME;
 278  }
 279  if ($config->stage > INSTALL_SAVE) {
 280      $config->stage = INSTALL_SAVE;
 281  }
 282  
 283  
 284  
 285  if ($config->stage == INSTALL_SAVE) {
 286      $CFG->early_install_lang = false;
 287  
 288      $database = moodle_database::get_driver_instance($config->dbtype, 'native');
 289      if (!$database->driver_installed()) {
 290          $config->stage = INSTALL_DATABASETYPE;
 291      } else {
 292          if (function_exists('distro_pre_create_db')) { // Hook for distros needing to do something before DB creation
 293              $distro = distro_pre_create_db($database, $config->dbhost, $config->dbuser, $config->dbpass, $config->dbname, $config->prefix, array('dbpersist'=>0, 'dbport'=>$config->dbport, 'dbsocket'=>$config->dbsocket), $distro);
 294          }
 295          $hint_database = install_db_validate($database, $config->dbhost, $config->dbuser, $config->dbpass, $config->dbname, $config->prefix, array('dbpersist'=>0, 'dbport'=>$config->dbport, 'dbsocket'=>$config->dbsocket));
 296  
 297          if ($hint_database === '') {
 298              $configphp = install_generate_configphp($database, $CFG);
 299  
 300              umask(0137);
 301              if (($fh = @fopen($configfile, 'w')) !== false) {
 302                  fwrite($fh, $configphp);
 303                  fclose($fh);
 304              }
 305  
 306              if (file_exists($configfile)) {
 307                  // config created, let's continue!
 308                  redirect("$CFG->wwwroot/$config->admin/index.php?lang=$config->lang");
 309              }
 310  
 311              install_print_header($config, 'config.php',
 312                                            get_string('configurationcompletehead', 'install'),
 313                                            get_string('configurationcompletesub', 'install').get_string('configfilenotwritten', 'install'));
 314              echo '<div class="configphp"><pre>';
 315              echo p($configphp);
 316              echo '</pre></div>';
 317  
 318              install_print_footer($config);
 319              die;
 320  
 321          } else {
 322              $config->stage = INSTALL_DATABASE;
 323          }
 324      }
 325  }
 326  
 327  
 328  
 329  if ($config->stage == INSTALL_DOWNLOADLANG) {
 330      if (empty($CFG->dataroot)) {
 331          $config->stage = INSTALL_PATHS;
 332  
 333      } else if (is_dataroot_insecure()) {
 334          $hint_dataroot = get_string('pathsunsecuredataroot', 'install');
 335          $config->stage = INSTALL_PATHS;
 336  
 337      } else if (!file_exists($CFG->dataroot)) {
 338          $a = new stdClass();
 339          $a->parent = dirname($CFG->dataroot);
 340          $a->dataroot = $CFG->dataroot;
 341          if (!is_writable($a->parent)) {
 342              $hint_dataroot = get_string('pathsroparentdataroot', 'install', $a);
 343              $config->stage = INSTALL_PATHS;
 344          } else {
 345              if (!install_init_dataroot($CFG->dataroot, $CFG->directorypermissions)) {
 346                  $hint_dataroot = get_string('pathserrcreatedataroot', 'install', $a);
 347                  $config->stage = INSTALL_PATHS;
 348              }
 349          }
 350  
 351      } else if (!install_init_dataroot($CFG->dataroot, $CFG->directorypermissions)) {
 352          $hint_dataroot = get_string('pathserrcreatedataroot', 'install', array('dataroot' => $CFG->dataroot));
 353          $config->stage = INSTALL_PATHS;
 354      }
 355  
 356      if (empty($hint_dataroot) and !is_writable($CFG->dataroot)) {
 357          $hint_dataroot = get_string('pathsrodataroot', 'install');
 358          $config->stage = INSTALL_PATHS;
 359      }
 360  
 361      if ($config->admin === '' or !file_exists($CFG->dirroot.'/'.$config->admin.'/environment.xml')) {
 362          $hint_admindir = get_string('pathswrongadmindir', 'install');
 363          $config->stage = INSTALL_PATHS;
 364      }
 365  }
 366  
 367  
 368  
 369  if ($config->stage == INSTALL_DOWNLOADLANG) {
 370      // no need to download anything if en lang selected
 371      if ($CFG->lang == 'en') {
 372          $config->stage = INSTALL_DATABASETYPE;
 373      }
 374  }
 375  
 376  
 377  
 378  if ($config->stage == INSTALL_DATABASETYPE) {
 379      // skip db selection if distro package supports only one db
 380      if (!empty($distro->dbtype)) {
 381          $config->stage = INSTALL_DATABASE;
 382      }
 383  }
 384  
 385  
 386  if ($config->stage == INSTALL_DOWNLOADLANG) {
 387      $downloaderror = '';
 388  
 389      // download and install required lang packs, the lang dir has already been created in install_init_dataroot
 390      $installer = new lang_installer($CFG->lang);
 391      $results = $installer->run();
 392      foreach ($results as $langcode => $langstatus) {
 393          if ($langstatus === lang_installer::RESULT_DOWNLOADERROR) {
 394              $a       = new stdClass();
 395              $a->url  = $installer->lang_pack_url($langcode);
 396              $a->dest = $CFG->dataroot.'/lang';
 397              $downloaderror = get_string('remotedownloaderror', 'error', $a);
 398          }
 399      }
 400  
 401      if ($downloaderror !== '') {
 402          install_print_header($config, get_string('language'), get_string('langdownloaderror', 'install', $CFG->lang), $downloaderror);
 403          install_print_footer($config);
 404          die;
 405      } else {
 406          if (empty($distro->dbtype)) {
 407              $config->stage = INSTALL_DATABASETYPE;
 408          } else {
 409              $config->stage = INSTALL_DATABASE;
 410          }
 411      }
 412  
 413      // switch the string_manager instance to stop using install/lang/
 414      $CFG->early_install_lang = false;
 415      $CFG->langotherroot      = $CFG->dataroot.'/lang';
 416      $CFG->langlocalroot      = $CFG->dataroot.'/lang';
 417      get_string_manager(true);
 418  }
 419  
 420  
 421  if ($config->stage == INSTALL_DATABASE) {
 422      $CFG->early_install_lang = false;
 423  
 424      $database = moodle_database::get_driver_instance($config->dbtype, 'native');
 425  
 426      $sub = '<h3>'.$database->get_name().'</h3>'.$database->get_configuration_help();
 427  
 428      install_print_header($config, get_string('database', 'install'), get_string('databasehead', 'install'), $sub);
 429  
 430      $strdbhost   = get_string('databasehost', 'install');
 431      $strdbname   = get_string('databasename', 'install');
 432      $strdbuser   = get_string('databaseuser', 'install');
 433      $strdbpass   = get_string('databasepass', 'install');
 434      $strprefix   = get_string('dbprefix', 'install');
 435      $strdbport   = get_string('databaseport', 'install');
 436      $strdbsocket = get_string('databasesocket', 'install');
 437  
 438      echo '<div class="userinput">';
 439  
 440      $disabled = empty($distro->dbhost) ? '' : 'disabled="disabled';
 441      echo '<div class="formrow"><label for="id_dbhost" class="formlabel">'.$strdbhost.'</label>';
 442      echo '<input id="id_dbhost" name="dbhost" '.$disabled.' type="text" value="'.s($config->dbhost).'" size="50" class="forminput" />';
 443      echo '</div>';
 444  
 445      echo '<div class="formrow"><label for="id_dbname" class="formlabel">'.$strdbname.'</label>';
 446      echo '<input id="id_dbname" name="dbname" type="text" value="'.s($config->dbname).'" size="50" class="forminput" />';
 447      echo '</div>';
 448  
 449      $disabled = empty($distro->dbuser) ? '' : 'disabled="disabled';
 450      echo '<div class="formrow"><label for="id_dbuser" class="formlabel">'.$strdbuser.'</label>';
 451      echo '<input id="id_dbuser" name="dbuser" '.$disabled.' type="text" value="'.s($config->dbuser).'" size="50" class="forminput" />';
 452      echo '</div>';
 453  
 454      echo '<div class="formrow"><label for="id_dbpass" class="formlabel">'.$strdbpass.'</label>';
 455      // no password field here, the password may be visible in config.php if we can not write it to disk
 456      echo '<input id="id_dbpass" name="dbpass" type="text" value="'.s($config->dbpass).'" size="50" class="forminput" />';
 457      echo '</div>';
 458  
 459      echo '<div class="formrow"><label for="id_prefix" class="formlabel">'.$strprefix.'</label>';
 460      echo '<input id="id_prefix" name="prefix" type="text" value="'.s($config->prefix).'" size="10" class="forminput" />';
 461      echo '</div>';
 462  
 463      echo '<div class="formrow"><label for="id_prefix" class="formlabel">'.$strdbport.'</label>';
 464      echo '<input id="id_dbport" name="dbport" type="text" value="'.s($config->dbport).'" size="10" class="forminput" />';
 465      echo '</div>';
 466  
 467      if (!(stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin'))) {
 468          echo '<div class="formrow"><label for="id_dbsocket" class="formlabel">'.$strdbsocket.'</label>';
 469          echo '<input id="id_dbsocket" name="dbsocket" type="text" value="'.s($config->dbsocket).'" size="50" class="forminput" />';
 470          echo '</div>';
 471      }
 472  
 473      echo '<div class="hint">'.$hint_database.'</div>';
 474      echo '</div>';
 475      install_print_footer($config);
 476      die;
 477  }
 478  
 479  
 480  if ($config->stage == INSTALL_DATABASETYPE) {
 481      $CFG->early_install_lang = false;
 482  
 483      // Finally ask for DB type
 484      install_print_header($config, get_string('database', 'install'),
 485                                    get_string('databasetypehead', 'install'),
 486                                    get_string('databasetypesub', 'install'));
 487  
 488      $databases = array('mysqli' => moodle_database::get_driver_instance('mysqli', 'native'),
 489                         'mariadb'=> moodle_database::get_driver_instance('mariadb', 'native'),
 490                         'pgsql'  => moodle_database::get_driver_instance('pgsql',  'native'),
 491                         'oci'    => moodle_database::get_driver_instance('oci',    'native'),
 492                         'sqlsrv' => moodle_database::get_driver_instance('sqlsrv', 'native'), // MS SQL*Server PHP driver
 493                         'mssql'  => moodle_database::get_driver_instance('mssql',  'native'), // FreeTDS driver
 494                        );
 495  
 496      echo '<div class="userinput">';
 497      echo '<div class="formrow"><label class="formlabel" for="dbtype">'.get_string('dbtype', 'install').'</label>';
 498      echo '<select id="dbtype" name="dbtype" class="forminput">';
 499      $disabled = array();
 500      $options = array();
 501      foreach ($databases as $type=>$database) {
 502          if ($database->driver_installed() !== true) {
 503              $disabled[$type] = $database;
 504              continue;
 505          }
 506          echo '<option value="'.s($type).'">'.$database->get_name().'</option>';
 507      }
 508      if ($disabled) {
 509          echo '<optgroup label="'.s(get_string('notavailable')).'">';
 510          foreach ($disabled as $type=>$database) {
 511              echo '<option value="'.s($type).'" class="notavailable">'.$database->get_name().'</option>';
 512          }
 513          echo '</optgroup>';
 514      }
 515      echo '</select></div>';
 516      echo '</div>';
 517  
 518      install_print_footer($config);
 519      die;
 520  }
 521  
 522  
 523  
 524  if ($config->stage == INSTALL_ENVIRONMENT or $config->stage == INSTALL_PATHS) {
 525      $version_fail = (version_compare(phpversion(), "5.3.3") < 0);
 526      $curl_fail    = ($lang !== 'en' and !extension_loaded('curl')); // needed for lang pack download
 527      $zip_fail     = ($lang !== 'en' and !extension_loaded('zip'));  // needed for lang pack download
 528  
 529      if ($version_fail or $curl_fail or $zip_fail) {
 530          $config->stage = INSTALL_ENVIRONMENT;
 531  
 532          install_print_header($config, get_string('environmenthead', 'install'),
 533                                        get_string('errorsinenvironment', 'install'),
 534                                        get_string('environmentsub2', 'install'));
 535  
 536          echo '<div id="envresult"><dl>';
 537          if ($version_fail) {
 538              $a = (object)array('needed'=>'5.3.3', 'current'=>phpversion());
 539              echo '<dt>'.get_string('phpversion', 'install').'</dt><dd>'.get_string('environmentrequireversion', 'admin', $a).'</dd>';
 540          }
 541          if ($curl_fail) {
 542              echo '<dt>'.get_string('phpextension', 'install', 'cURL').'</dt><dd>'.get_string('environmentrequireinstall', 'admin').'</dd>';
 543          }
 544          if ($zip_fail) {
 545              echo '<dt>'.get_string('phpextension', 'install', 'Zip').'</dt><dd>'.get_string('environmentrequireinstall', 'admin').'</dd>';
 546          }
 547          echo '</dl></div>';
 548  
 549          install_print_footer($config, true);
 550          die;
 551  
 552      } else {
 553          $config->stage = INSTALL_PATHS;
 554      }
 555  }
 556  
 557  
 558  
 559  if ($config->stage == INSTALL_PATHS) {
 560      $paths = array('wwwroot'  => get_string('wwwroot', 'install'),
 561                     'dirroot'  => get_string('dirroot', 'install'),
 562                     'dataroot' => get_string('dataroot', 'install'));
 563  
 564      $sub = '<dl>';
 565      foreach ($paths as $path=>$name) {
 566          $sub .= '<dt>'.$name.'</dt><dd>'.get_string('pathssub'.$path, 'install').'</dd>';
 567      }
 568      if (!file_exists("$CFG->dirroot/admin/environment.xml")) {
 569          $sub .= '<dt>'.get_string('admindirname', 'install').'</dt><dd>'.get_string('pathssubadmindir', 'install').'</dd>';
 570      }
 571      $sub .= '</dl>';
 572  
 573      install_print_header($config, get_string('paths', 'install'), get_string('pathshead', 'install'), $sub);
 574  
 575      $strwwwroot      = get_string('wwwroot', 'install');
 576      $strdirroot      = get_string('dirroot', 'install');
 577      $strdataroot     = get_string('dataroot', 'install');
 578      $stradmindirname = get_string('admindirname', 'install');
 579  
 580      echo '<div class="userinput">';
 581      echo '<div class="formrow"><label for="id_wwwroot" class="formlabel">'.$paths['wwwroot'].'</label>';
 582      echo '<input id="id_wwwroot" name="wwwroot" type="text" value="'.s($CFG->wwwroot).'" disabled="disabled" size="70" class="forminput" />';
 583      echo '</div>';
 584  
 585      echo '<div class="formrow"><label for="id_dirroot" class="formlabel">'.$paths['dirroot'].'</label>';
 586      echo '<input id="id_dirroot" name="dirroot" type="text" value="'.s($CFG->dirroot).'" disabled="disabled" size="70"class="forminput" />';
 587      echo '</div>';
 588  
 589      echo '<div class="formrow"><label for="id_dataroot" class="formlabel">'.$paths['dataroot'].'</label>';
 590      echo '<input id="id_dataroot" name="dataroot" type="text" value="'.s($config->dataroot).'" size="70" class="forminput" />';
 591      if ($hint_dataroot !== '') {
 592          echo '<div class="hint">'.$hint_dataroot.'</div>';
 593      }
 594      echo '</div>';
 595  
 596  
 597      if (!file_exists("$CFG->dirroot/admin/environment.xml")) {
 598          echo '<div class="formrow"><label for="id_admin" class="formlabel">'.$paths['admindir'].'</label>';
 599          echo '<input id="id_admin" name="admin" type="text" value="'.s($config->admin).'" size="10" class="forminput" />';
 600          if ($hint_admindir !== '') {
 601              echo '<div class="hint">'.$hint_admindir.'</div>';
 602          }
 603          echo '</div>';
 604      }
 605  
 606      echo '</div>';
 607  
 608      install_print_footer($config);
 609      die;
 610  }
 611  
 612  
 613  
 614  $config->stage = INSTALL_WELCOME;
 615  
 616  if ($distro) {
 617      ob_start();
 618      include('install/distribution.html');
 619      $sub = ob_get_clean();
 620  
 621      install_print_header($config, get_string('language'),
 622                                    get_string('chooselanguagehead', 'install'),
 623                                    $sub);
 624  
 625  } else {
 626      install_print_header($config, get_string('language'),
 627                                    get_string('chooselanguagehead', 'install'),
 628                                    get_string('chooselanguagesub', 'install'));
 629  }
 630  
 631  $languages = get_string_manager()->get_list_of_translations();
 632  echo '<div class="userinput">';
 633  echo '<div class="formrow"><label class="formlabel" for="langselect">'.get_string('language').'</label>';
 634  echo '<select id="langselect" name="lang" class="forminput" onchange="this.form.submit()">';
 635  foreach ($languages as $name=>$value) {
 636      $selected = ($name == $CFG->lang) ? 'selected="selected"' : '';
 637      echo '<option value="'.s($name).'" '.$selected.'>'.$value.'</option>';
 638  }
 639  echo '</select></div>';
 640  echo '</div>';
 641  
 642  install_print_footer($config);
 643  die;
 644  

Search This Site: