4 include_once(
"./setup/classes/class.ilDBConnections.php");
76 define(
"ILIAS_MODULE",
"setup");
78 $this->auth = ($a_auth) ?
true :
false;
79 $this->access_mode = $a_auth_type;
82 if ($this->safe_mode = ini_get(
"safe_mode"))
96 $this->ini_ilias_exists = $this->
init();
98 if ($this->ini_ilias_exists)
100 if ($this->ini->readVariable(
"log",
"path") !=
"")
102 $log->path = $this->ini->readVariable(
"log",
"path");
105 if ($this->ini->readVariable(
"log",
"file") !=
"")
107 $log->filename = $this->ini->readVariable(
"log",
"file");
110 if ($this->ini->readVariable(
"log",
"enabled") !=
"")
112 $log->enabled = $this->ini->readVariable(
"log",
"enabled");
124 $this->client = $a_cl;
145 $this->ini =
new ilIniFile($this->ini_file_path);
147 if (!$this->ini->read())
149 $this->ini->GROUPS = parse_ini_file($this->setup_defaults,
true);
150 $this->error = get_class($this).
": ".$this->ini->getError();
154 $this->setup_password = $this->ini->readVariable(
"setup",
"pass");
155 $this->default_client = $this->ini->readVariable(
"clients",
"default");
157 define(
"ILIAS_DATA_DIR",$this->ini->readVariable(
"clients",
"datadir"));
158 define(
"ILIAS_WEB_DIR",$this->ini->readVariable(
"clients",
"path"));
170 $_SESSION[
"ClientId"] = $this->client->getId();
173 if (!$this->client->create())
175 $this->error = $this->client->getError();
180 $this->ini_client_exists =
true;
195 if ($a_old_client_id != $this->client->getId())
200 $this->
raiseError($this->lng->txt(
"client_id_already_exists"),$this->error_obj->MESSAGE);
205 $this->
raiseError($this->lng->txt(
"save_error"),$this->error_obj->MESSAGE);
213 $this->ini_client_exists =
true;
224 if ($this->client->checkDatabaseExists())
226 $this->error = $this->lng->txt(
"database_exists");
230 $this->client->getDB()->connectHost(
true);
233 $db = $this->client->getDB();
236 $this->error =
"connection_failed";
240 $r =
$db->createDatabase($this->client->getdbName(),
241 "utf8", $a_collation);
245 $this->error =
"create_database_failed";
252 $this->client->db_exists =
true;
268 if (!$this->client->connect())
274 if ($this->
readDump($this->client->db, $this->SQL_FILE))
276 $this->client->db_installed =
true;
288 while( !feof( $fp ) )
307 if (
$db->getDBType() ==
"mysql")
309 $fp = fopen(
$file,
'r');
314 $line = trim($this->
getline($fp,
"\n"));
316 if ($line !=
"" && substr($line,0,1)!=
"#"
317 && substr($line,0,1)!=
"-")
320 if (substr($line,-1)==
";")
323 $q .=
" ".substr($line,0,-1);
325 if (mysql_errno() > 0)
327 echo
"<br />ERROR: ".mysql_error().
344 #echo 'Start Memory: '.memory_get_usage().' peak: '.memory_get_peak_usage();
345 if (
$db->getDBType() ==
"oracle")
347 if(@is_dir(
'./setup/sql/ilDBTemplate'))
349 include_once
'./Services/Database/classes/class.ilArrayTableDataParser.php';
350 include_once
'./classes/class.ilSaxParserException.php';
354 eval(file_get_contents(
'./setup/sql/ilDBTemplate/'.$file));
358 #$parser = new ilSimpleXMLTableDataParser('./setup/sql/ilDBTemplate/'.$file.'.xml');
359 $parser->startParsing();
360 #echo 'Table: '.$file.', memory: '.memory_get_peak_usage().' peak: '.memory_get_peak_usage().'<br />';flush();
371 include_once(
"./setup/sql/ilDBTemplate.php");
372 setupILIASDatabase();
375 #echo 'Start Memory: '.memory_get_usage().' peak: '.memory_get_peak_usage();
386 $a = @file_exists($this->INI_FILE);
398 if (is_writable(
"."))
400 $arr[
"status"] =
true;
403 $arr[
"comment"] = getcwd();
408 $arr[
"status"] =
false;
409 $arr[
"comment"] = $this->lng->txt(
"pre_folder_write_error");
412 $arr[
"comment"] = getcwd().
": ".$arr[
"comment"];
427 if (@mkdir($a_dir.
"/crst879dldsk9d", 0774))
429 $arr[
"status"] =
true;
430 $arr[
"comment"] =
"";
432 @rmdir($a_dir.
"/crst879dldsk9d");
436 $arr[
"status"] =
false;
439 $arr[
"comment"] = getcwd().
": ".$this->lng->txt(
"pre_folder_create_error");
454 if ($sess->usesCookies)
456 $arr[
"status"] =
true;
457 $arr[
"comment"] =
"";
461 $arr[
"status"] =
false;
462 $arr[
"comment"] = $this->lng->txt(
"pre_cookies_disabled");
474 $version = PHP_VERSION;
476 $arr[
"status"] =
true;
477 $arr[
"comment"] =
"PHP ".$version;
478 if (version_compare($version,
'5.1.3',
'<'))
480 $arr[
"status"] =
false;
481 $arr[
"comment"] =
"PHP ".$version.
". ".$this->lng->txt(
"pre_php_version_too_low");
495 if (function_exists(
"mysql_query"))
497 $arr[
"status"] =
true;
498 $arr[
"comment"] = $this->lng->txt(
"pre_mysql_4_1_or_higher");
502 $arr[
"status"] =
false;
503 $arr[
"comment"] = $this->lng->txt(
"pre_mysql_missing");
532 if (class_exists(
"DOMDocument"))
534 $arr[
"status"] =
true;
538 $arr[
"status"] =
false;
539 $arr[
"comment"] = $this->lng->txt(
"pre_dom_missing");
553 if (class_exists(
"XSLTProcessor"))
555 $arr[
"status"] =
true;
559 $arr[
"status"] =
false;
560 $arr[
"comment"] = sprintf($this->lng->txt(
"pre_xsl_missing"),
561 "http://php.net/manual/en/book.xsl.php");
575 if (function_exists(
"imagefill") && function_exists(
"imagecolorallocate"))
577 $arr[
"status"] =
true;
581 $arr[
"status"] =
false;
582 $arr[
"comment"] = sprintf($this->lng->txt(
"pre_gd_missing"),
583 "http://php.net/manual/en/book.image.php");
597 $limit = ini_get(
"memory_limit");
600 if (is_int(strpos($limit,
"M")))
602 $limit_n = (int) $limit;
611 $arr[
"status"] =
true;
612 $arr[
"comment"] = $limit.
". ".$this->lng->txt(
"pre_memory_limit_recommend");
616 $arr[
"status"] =
false;
617 $arr[
"comment"] = $limit.
". ".$this->lng->txt(
"pre_memory_limit_too_low");
654 foreach ($this->preliminaries_result as $val)
656 if ($val[
"status"] ===
false)
658 $this->preliminaries =
false;
672 return $this->ini->readVariable(
"setup",
"pass");
682 $this->ini->setVariable(
"setup",
"pass",md5($a_password));
684 if ($this->ini->write() ==
false)
686 $this->error = $this->ini->getError();
702 if (empty($a_auth_data[
"client_id"]))
704 $this->error =
"no_client_id";
708 if (empty($a_auth_data[
"username"]))
710 $this->error =
"no_username";
714 if (empty($a_auth_data[
"password"]))
716 $this->error =
"no_password";
720 if (!$this->
newClient($a_auth_data[
"client_id"]))
722 $this->error =
"unknown_client_id";
723 unset($this->client);
727 if (!$this->client->db_exists)
729 $this->error =
"no_db_connect_consult_admin";
730 unset($this->client);
734 $s1 = $this->client->db->query(
"SELECT value from settings WHERE keyword = ".
735 $this->client->db->quote(
'system_role_id',
'text'));
736 $r1 = $this->client->db->fetchAssoc($s1);
737 $system_role_id = $r1[
"value"];
738 $q =
"SELECT usr_data.usr_id FROM usr_data ".
739 "LEFT JOIN rbac_ua ON rbac_ua.usr_id=usr_data.usr_id ".
740 "WHERE rbac_ua.rol_id = ".$this->client->db->quote((
int) $system_role_id,
'integer').
" ".
741 "AND usr_data.login=".$this->client->db->quote($a_auth_data[
"username"],
'text').
" ".
742 "AND usr_data.passwd=".$this->client->db->quote(md5($a_auth_data[
"password"]),
'text');
744 $r = $this->client->db->query(
$q);
748 $this->error =
"login_invalid";
755 $_SESSION[
"ClientId"] = $this->client->getId();
766 $a_password = md5($a_password);
768 if ($this->ini->readVariable(
"setup",
"pass") == $a_password)
790 $this->client =
new ilClient($a_client_id, $this->db_connections);
792 if (!$this->client->init())
795 $this->error = get_class($this).
": ".$this->client->getError();
814 if ($this->ini_client_exists)
828 if ($status[
"db"][
"status"] ===
false and $status[
"db"][
"update"] !==
true)
830 $status[
"lang"][
"status"] =
false;
831 $status[
"lang"][
"comment"] = $status[
"db"][
"comment"];
832 $status[
"contact"][
"status"] =
false;
833 $status[
"contact"][
"comment"] = $status[
"db"][
"comment"];
834 $status[
"nic"][
"status"] =
false;
835 $status[
"nic"][
"comment"] = $status[
"db"][
"comment"];
857 if (
$client->getSetting(
"setup_ok"))
859 $arr[
"status"] =
true;
864 $arr[
"status"] =
false;
865 $arr[
"comment"] = $this->lng->txt(
"setup_not_finished");
878 if (
$client->ini->readVariable(
"client",
"access") ==
"1")
880 $arr[
"status"] =
true;
881 $arr[
"comment"] = $this->lng->txt(
"online");
885 $arr[
"status"] =
false;
886 $arr[
"comment"] = $this->lng->txt(
"disabled");
899 if (!$arr[
"status"] =
$client->init())
901 $arr[
"comment"] =
$client->getError();
918 if (!$arr[
"status"] =
$client->db_exists)
920 $arr[
"comment"] = $this->lng->txt(
"no_database");
924 if (!$arr[
"status"] =
$client->db_installed)
926 $arr[
"comment"] = $this->lng->txt(
"db_not_installed");
934 include_once
"./Services/Database/classes/class.ilDBUpdate.php";
936 $this->lng->setDbHandler(
$client->db);
939 if (!$arr[
"status"] = $dbupdate->getDBVersionStatus())
941 $arr[
"comment"] = $this->lng->txt(
"db_needs_update");
942 $arr[
"update"] =
true;
945 else if ($dbupdate->hotfixAvailable())
947 $arr[
"status"] =
false;
948 $arr[
"comment"] = $this->lng->txt(
"hotfix_available");
949 $arr[
"update"] =
true;
955 $cset =
$ilDB->query(
"SELECT count(*) as cnt FROM ctrl_calls");
956 $crec =
$ilDB->fetchAssoc($cset);
957 if ($crec[
"cnt"] == 0)
959 $arr[
"status"] =
false;
960 $arr[
"comment"] = $this->lng->txt(
"db_control_structure_missing");
961 $arr[
"update"] =
true;
976 $installed_langs = $this->lng->getInstalledLanguages();
978 $count = count($installed_langs);
982 $arr[
"status"] =
false;
983 $arr[
"comment"] = $this->lng->txt(
"lang_none_installed");
987 $arr[
"status"] =
true;
1001 $arr[
"status"] =
true;
1004 $settings =
$client->getAllSettings();
1005 $client_name =
$client->getName();
1008 if (empty($settings[
"admin_firstname"]) or empty($settings[
"admin_lastname"]) or
1009 empty($settings[
"admin_email"]) or empty($client_name))
1011 $arr[
"status"] =
false;
1012 $arr[
"comment"] = $this->lng->txt(
"missing_data");
1016 if (!
ilUtil::is_email($settings[
"admin_email"]) and $arr[
"status"] !=
false)
1018 $arr[
"status"] =
false;
1019 $arr[
"comment"] = $this->lng->txt(
"email_not_valid");
1032 $settings =
$client->getAllSettings();
1034 if (!isset($settings[
"nic_enabled"]))
1036 $arr[
"status"] =
false;
1037 $arr[
"comment"] = $this->lng->txt(
"nic_not_disabled");
1041 $arr[
"status"] =
true;
1043 if ($settings[
"nic_enabled"] ==
"-1")
1045 $arr[
"comment"] = $this->lng->txt(
"nic_reg_failed");
1049 if (!$settings[
"nic_enabled"])
1051 $arr[
"comment"] = $this->lng->txt(
"nic_reg_disabled");
1055 $arr[
"comment"] = $this->lng->txt(
"nic_reg_enabled");
1056 if ($settings[
"inst_id"] <= 0)
1058 $arr[
"status"] =
false;
1089 return ($this->access_mode ==
"admin") ?
true :
false;
1101 if ($a_formdata[
"chk_datadir_path"] == 1)
1105 $this->error =
"create_datadir_failed";
1115 $this->error =
"create_webdir_failed";
1121 $log_path = substr($form_log_path,0,strrpos($form_log_path,
"/"));
1122 $log_file = substr($form_log_path,strlen($log_path)+1);
1124 $this->ini->setVariable(
"server",
"http_path",ILIAS_HTTP_PATH);
1126 $this->ini->setVariable(
"server",
"timezone",preg_replace(
"/\\\\/",
"/",
ilUtil::stripSlashes($a_formdata[
"time_zone"])));
1127 $this->ini->setVariable(
"clients",
"datadir", $datadir_path);
1128 $this->ini->setVariable(
"tools",
"convert", preg_replace(
"/\\\\/",
"/",
ilUtil::stripSlashes($a_formdata[
"convert_path"])));
1129 $this->ini->setVariable(
"tools",
"zip", preg_replace(
"/\\\\/",
"/",
ilUtil::stripSlashes($a_formdata[
"zip_path"])));
1130 $this->ini->setVariable(
"tools",
"unzip", preg_replace(
"/\\\\/",
"/",
ilUtil::stripSlashes($a_formdata[
"unzip_path"])));
1131 $this->ini->setVariable(
"tools",
"java", preg_replace(
"/\\\\/",
"/",
ilUtil::stripSlashes($a_formdata[
"java_path"])));
1132 $this->ini->setVariable(
"tools",
"htmldoc", preg_replace(
"/\\\\/",
"/",
ilUtil::stripSlashes($a_formdata[
"htmldoc_path"])));
1133 $this->ini->setVariable(
"tools",
"mkisofs", preg_replace(
"/\\\\/",
"/",
ilUtil::stripSlashes($a_formdata[
"mkisofs_path"])));
1135 $this->ini->setVariable(
"tools",
"vscantype", preg_replace(
"/\\\\/",
"/",
ilUtil::stripSlashes($a_formdata[
"vscanner_type"])));
1136 $this->ini->setVariable(
"tools",
"scancommand", preg_replace(
"/\\\\/",
"/",
ilUtil::stripSlashes($a_formdata[
"scan_command"])));
1137 $this->ini->setVariable(
"tools",
"cleancommand", preg_replace(
"/\\\\/",
"/",
ilUtil::stripSlashes($a_formdata[
"clean_command"])));
1138 $this->ini->setVariable(
"setup",
"pass", md5($a_formdata[
"setup_pass"]));
1139 $this->ini->setVariable(
"log",
"path", $log_path);
1140 $this->ini->setVariable(
"log",
"file", $log_file);
1141 $this->ini->setVariable(
"log",
"enabled", (isset($a_formdata[
"chk_log_status"])) ?
"0" : 1);
1143 if (!$this->ini->write())
1145 $this->error = get_class($this).
": ".$this->ini->getError();
1173 $clean_command = preg_replace(
"/\\\\/",
"/",
ilUtil::stripSlashes($a_formdata[
"clean_command"]));
1175 $this->ini->setVariable(
"tools",
"convert", $convert_path);
1176 $this->ini->setVariable(
"tools",
"zip", $zip_path);
1177 $this->ini->setVariable(
"tools",
"unzip", $unzip_path);
1178 $this->ini->setVariable(
"tools",
"java", $java_path);
1179 $this->ini->setVariable(
"tools",
"htmldoc", $htmldoc_path);
1180 $this->ini->setVariable(
"tools",
"mkisofs", $mkisofs_path);
1181 $this->ini->setVariable(
"tools",
"latex", $latex_url);
1182 $this->ini->setVariable(
"tools",
"fop", $fop_path);
1183 $this->ini->setVariable(
"tools",
"vscantype", $scan_type);
1184 $this->ini->setVariable(
"tools",
"scancommand", $scan_command);
1185 $this->ini->setVariable(
"tools",
"cleancommand", $clean_command);
1188 $log_path = substr($form_log_path,0,strrpos($form_log_path,
"/"));
1189 $log_file = substr($form_log_path,strlen($log_path)+1);
1191 $this->ini->setVariable(
"log",
"path", $log_path);
1192 $this->ini->setVariable(
"log",
"file", $log_file);
1193 $this->ini->setVariable(
"log",
"enabled", ($a_formdata[
"chk_log_status"]) ?
"0" : 1);
1194 $this->ini->setVariable(
"server",
"timezone",preg_replace(
"/\\\\/",
"/",
ilUtil::stripSlashes($a_formdata[
"time_zone"])));
1196 if (!$this->ini->write())
1198 $this->error = get_class($this).
": ".$this->ini->getError();
1213 if (!isset($a_formdata[
"chk_convert_path"]))
1220 $this->error =
$err;
1226 if (!isset($a_formdata[
"chk_zip_path"]))
1231 if (empty($zip_path))
1233 $this->error =
"no_path_zip";
1237 if (!$this->
testZip($zip_path))
1239 $this->error =
"check_failed_zip";
1245 if (!isset($a_formdata[
"chk_unzip_path"]))
1250 if (empty($unzip_path))
1252 $this->error =
"no_path_unzip";
1258 $this->error =
"check_failed_unzip";
1264 if (!isset($a_formdata[
"chk_java_path"]))
1269 if (empty($java_path))
1271 $this->error =
"no_path_java";
1277 $this->error =
"check_failed_java";
1283 if (!isset($a_formdata[
"chk_htmldoc_path"]))
1288 if (empty($htmldoc_path))
1290 $this->error =
"no_path_htmldoc";
1296 $this->error =
"check_failed_htmldoc";
1300 if (!isset($a_formdata[
"chk_mkisofs_path"]))
1305 if (empty($mkisofs_path))
1307 $this->error =
"no_path_mkisofs";
1313 $this->error =
"check_failed_mkisofs";
1319 if (!isset($a_formdata[
"chk_latex_url"]))
1322 if (empty($latex_url))
1324 $this->error =
"no_latex_url";
1330 $this->error =
"check_failed_latex";
1348 if (empty($datadir_path))
1350 $this->error =
"no_path_datadir";
1357 if (strpos($datadir_path,$webspace_dir) !==
false)
1359 $this->error =
"datadir_webspacedir_match";
1364 if ($a_formdata[
"chk_datadir_path"] == 1)
1366 $dir_to_create = substr(strrchr($datadir_path,
"/"), 1);
1367 $dir_to_check = substr($datadir_path,0,- strlen($dir_to_create)-1);
1369 if (is_writable($datadir_path))
1371 $this->error =
"dir_exists_create";
1375 if (!is_writable($dir_to_check))
1377 $this->error =
"cannot_create_datadir_no_write_access";
1383 if (!is_writable($datadir_path))
1385 $this->error =
"cannot_create_datadir_no_write_access";
1400 if (!$a_formdata[
"setup_pass"])
1402 $this->error =
"no_setup_pass_given";
1406 if ($a_formdata[
"setup_pass"] != $a_formdata[
"setup_pass2"])
1408 $this->error =
"pass_does_not_match";
1423 if (!$a_formdata[
"chk_log_status"])
1428 if (empty($log_path))
1430 $this->error =
"no_path_log";
1434 if (!@touch($log_path))
1436 $this->error =
"could_not_create_logfile";
1450 if (empty($this->error))
1483 if (trim($a_convert_path) ==
"")
1485 return "no_path_convert";
1487 if (!is_file($a_convert_path))
1489 return "check_failed_convert";
1525 if (trim($a_java_path) ==
"")
1530 if (!is_file($a_java_path))
1532 return "check_failed_java";
1554 if (trim($a_latex_url) ==
"")
1560 include_once
"./setup/classes/class.ilHttpRequest.php";
1562 $result = @$http->downloadToString();
1563 if ((strpos((substr(
$result, 0, 5)),
"PNG") !== FALSE) || (strpos((substr(
$result, 0, 5)),
"GIF") !== FALSE))
1569 return "check_failed_latex";;
1581 if (trim($a_zip_path) ==
"")
1583 return "no_path_zip";
1585 if (!is_file($a_zip_path))
1587 return "check_failed_zip";
1634 if (trim($a_unzip_path) ==
"")
1636 return "no_path_unzip";
1638 if (!is_file($a_unzip_path))
1640 return "check_failed_unzip";
1680 if (trim($a_htmldoc_path) ==
"")
1685 if (!is_file($a_htmldoc_path))
1687 return "check_failed_htmldoc";
1697 $html =
"<html><head><title></title></head><body><p>test</p></body></html>";
1699 $html_file =
"htmldoc_test_file.html";
1701 $fp = fopen( $html_file ,
"wb");
1705 $htmldoc = $a_htmldoc_path.
" ";
1706 $htmldoc .=
"--no-toc ";
1707 $htmldoc .=
"--no-jpeg ";
1708 $htmldoc .=
"--webpage ";
1709 $htmldoc .=
"--outfile htmldoc_test_file.pdf ";
1710 $htmldoc .=
"--bodyfont Arial ";
1711 $htmldoc .=
"--charset iso-8859-15 ";
1712 $htmldoc .=
"--color ";
1713 $htmldoc .=
"--size A4 ";
1714 $htmldoc .=
"--format pdf ";
1715 $htmldoc .=
"--footer ... ";
1716 $htmldoc .=
"--header ... ";
1717 $htmldoc .=
"--left 60 ";
1719 $htmldoc .= $html_file;
1744 function unzip($a_file, $overwrite =
false)
1748 $pathinfo = pathinfo($a_file);
1749 $dir = $pathinfo[
"dirname"];
1750 $file = $pathinfo[
"basename"];
1755 $unzip = $this->ini->readVariable(
"tools",
"unzip");
1757 exec($unzipcmd, $arr);
1760 foreach($arr as $line)
1762 if(is_int(strpos($line,
"/")))
1764 $zdir = substr($line, 0, strrpos($line,
"/"));
1765 $nr = substr_count($zdir,
"/");
1769 $nr = substr_count($zdir,
"/");
1770 $zdirs[$zdir] = $nr;
1772 $zdir = substr($zdir, 0, strrpos($zdir,
"/"));
1779 foreach($zdirs as $zdir => $nr)
1804 return parent::getFileName();
1809 if(!parent::valid())
1813 if($this->isFile() and substr(parent::getFileName(),-4) ==
'.xml')
1817 if($this->isFile() and substr(parent::getFileName(),-8) !=
'_inserts')
1822 return $this->
valid();