예제 #1
0
 static function processForm()
 {
     global $string, $cfg_encrypt_salt;
     self::$cfg_company = $_POST['company_name'];
     //check admin database user name and password and create the connection
     self::$cfg_db_host = $_POST['mysql_db_host'];
     self::$cfg_db_charset = $_POST['mysql_db_charset'];
     self::$cfg_page_charset = $_POST['page_charset'];
     self::$cfg_db_port = $_POST['mysql_db_port'];
     self::$cfg_db_name = $_POST['mysql_db_name'];
     self::$db_admin_username = $_POST['mysql_admin_user'];
     self::$db_admin_passwd = $_POST['mysql_admin_pass'];
     self::$cfg_web_host = $_POST['web_host'];
     self::$cfg_db_basename = $_POST['mysql_baseusername'];
     self::$cfg_SysAdmin_username = $_POST['SysAdmin_username'];
     self::$cfg_short_date = $_POST['cfg_short_date'];
     self::$cfg_long_date_time = $_POST['cfg_long_date_time'];
     self::$cfg_short_date_time = $_POST['cfg_short_date_time'];
     self::$cfg_long_date_php = $_POST['cfg_long_date_php'];
     self::$cfg_short_date_php = $_POST['cfg_short_date_php'];
     self::$cfg_long_time_php = $_POST['cfg_long_time_php'];
     self::$cfg_short_time_php = $_POST['cfg_short_time_php'];
     self::$cfg_timezone = $_POST['cfg_timezone'];
     self::$cfg_tmpdir = $_POST['tmpdir'];
     if (self::$cfg_long_date_time == "%d/%m/%Y %H:%i") {
         self::$cfg_tablesorter_date_time = 'uk';
     } else {
         self::$cfg_tablesorter_date_time = 'us';
     }
     //Authentication
     if (isset($_POST['useLti'])) {
         self::$cfg_auth_lti = true;
     } else {
         self::$cfg_auth_lti = false;
     }
     if (isset($_POST['useInternal'])) {
         self::$cfg_auth_internal = true;
     } else {
         self::$cfg_auth_internal = false;
     }
     if (isset($_POST['useGuest'])) {
         self::$cfg_auth_guest = true;
     } else {
         self::$cfg_auth_guest = false;
     }
     if (isset($_POST['useImpersonation'])) {
         self::$cfg_auth_impersonation = true;
     } else {
         self::$cfg_auth_impersonation = false;
     }
     if (isset($_POST['useLdap'])) {
         self::$cfg_auth_ldap = true;
     } else {
         self::$cfg_auth_ldap = false;
     }
     //LDAP
     self::$cfg_ldap_server = $_POST['ldap_server'];
     self::$cfg_ldap_search_dn = $_POST['ldap_search_dn'];
     self::$cfg_ldap_bind_rdn = $_POST['ldap_bind_rdn'];
     self::$cfg_ldap_bind_password = $_POST['ldap_bind_password'];
     if (self::$cfg_ldap_server != '') {
         self::$cfg_auth_ldap = true;
     } else {
         self::$cfg_auth_ldap = false;
     }
     self::$cfg_ldap_user_prefix = $_POST['ldap_user_prefix'];
     //LDAP for lookup
     self::$cfg_lookup_ldap_server = $_POST['ldap_lookup_server'];
     self::$cfg_lookup_ldap_search_dn = $_POST['ldap_lookup_search_dn'];
     self::$cfg_lookup_ldap_bind_rdn = $_POST['ldap_lookup_bind_rdn'];
     self::$cfg_lookup_ldap_bind_password = $_POST['ldap_lookup_bind_password'];
     self::$cfg_lookup_ldap_user_prefix = $_POST['ldap_lookup_user_prefix'];
     //ASSISTANCE
     self::$cfg_support_email = $_POST['support_email'];
     self::$emergency_support_numbers = 'array(';
     for ($i = 1; $i <= 3; $i++) {
         if ($_POST["emergency_support{$i}"] != '') {
             self::$emergency_support_numbers .= "'" . $_POST["emergency_support{$i}"] . "'=>'" . $_POST["emergency_support_number{$i}"] . "', ";
         }
     }
     self::$emergency_support_numbers = rtrim(self::$emergency_support_numbers, ', ');
     self::$emergency_support_numbers .= ')';
     //Other settings
     self::$cfg_labsecuritytype = $_POST['labsecuritytype'];
     self::$cfg_interactivequestions = $_POST['interactivequestions'];
     // Check we can write to the config file first if not passwords will be lost!
     $rogo_path = str_ireplace('/install/index.php', '', normalise_path($_SERVER['SCRIPT_FILENAME']));
     if (file_exists($rogo_path . '/config/config.inc.php')) {
         if (!is_writable($rogo_path . '/config/config.inc.php')) {
             self::displayError(array(300 => 'Could not write config file!'));
         }
     } elseif (!is_writable($rogo_path . '/config')) {
         self::displayError(array(300 => 'Could not write config file!'));
     }
     //CREATE and populate DB
     self::$db = new mysqli(self::$cfg_db_host, self::$db_admin_username, self::$db_admin_passwd, '', self::$cfg_db_port);
     if (mysqli_connect_error()) {
         self::displayError(array('001' => mysqli_connect_error()));
     }
     self::$db->set_charset(self::$cfg_db_charset);
     //create salt as this is needed to generate the passwords that are created in the next function rather than created during config file settings
     $salt = '';
     $characters = 'abcdefghijklmnopqrstuvwxzyABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
     for ($i = 0; $i < 16; $i++) {
         $salt .= substr($characters, rand(0, 61), 1);
     }
     $cfg_encrypt_salt = $salt;
     $configObj = Config::get_instance();
     $authentication = array(array('internaldb', array('table' => '', 'username_col' => '', 'passwd_col' => '', 'id_col' => '', 'sql_extra' => '', 'encrypt' => 'SHA-512', 'encrypt_salt' => $cfg_encrypt_salt), 'Internal Database'));
     $configObj->set('authentication', $authentication);
     InstallUtils::checkDBUsers();
     self::createDatabase(self::$cfg_db_name, self::$cfg_db_charset);
     //LOAD help if requested
     if (isset($_POST['loadHelp'])) {
         self::loadHelp();
     }
     //Write out the config file
     self::writeConfigFile();
     if (!is_array(self::$warnings)) {
         echo "<p style=\"margin-left:10px\">" . $string['installed'] . "</p>\n";
         echo "<p style=\"margin-left:10px\">" . $string['deleteinstall'] . "</p>\n";
         echo "<p style=\"margin-left:10px\"><input type=\"button\" class=\"ok\" name=\"home\" value=\"" . $string['staffhomepage'] . "\" onclick=\"window.location='../index.php'\" /></p>\n";
     } else {
         self::displayWarnings();
     }
 }