24 include_once(
"./classes/class.ilDBConnections.php");
95 define(
"ILIAS_MODULE",
"setup");
97 $this->auth = ($a_auth) ?
true :
false;
98 $this->access_mode = $a_auth_type;
101 if ($this->safe_mode = ini_get(
"safe_mode"))
108 $this->setErrorHandling(PEAR_ERROR_CALLBACK,array($this->error_obj,
'errorHandler'));
115 $this->ini_ilias_exists = $this->
init();
117 if ($this->ini_ilias_exists)
119 if ($this->ini->readVariable(
"log",
"path") !=
"")
121 $log->path = $this->ini->readVariable(
"log",
"path");
124 if ($this->ini->readVariable(
"log",
"file") !=
"")
126 $log->filename = $this->ini->readVariable(
"log",
"file");
129 if ($this->ini->readVariable(
"log",
"enabled") !=
"")
131 $log->enabled = $this->ini->readVariable(
"log",
"enabled");
144 $this->ini =
new ilIniFile($this->ini_file_path);
146 if (!$this->ini->read())
148 $this->ini->GROUPS = parse_ini_file($this->setup_defaults,
true);
149 $this->error = get_class($this).
": ".$this->ini->getError();
153 $this->setup_password = $this->ini->readVariable(
"setup",
"pass");
154 $this->default_client = $this->ini->readVariable(
"clients",
"default");
156 define(
"ILIAS_DATA_DIR",$this->ini->readVariable(
"clients",
"datadir"));
157 define(
"ILIAS_WEB_DIR",$this->ini->readVariable(
"clients",
"path"));
169 $_SESSION[
"ClientId"] = $this->client->getId();
172 if (!$this->client->create())
174 $this->error = $this->client->getError();
179 $this->ini_client_exists =
true;
194 if ($a_old_client_id != $this->client->getId())
199 $this->raiseError($this->lng->txt(
"client_id_already_exists"),$this->error_obj->MESSAGE);
204 $this->raiseError($this->lng->txt(
"save_error"),$this->error_obj->MESSAGE);
212 $this->ini_client_exists =
true;
225 $sql = explode(
"\n",trim($str));
226 for ($i=0; $i<count($sql); $i++)
228 $sql[$i] = trim($sql[$i]);
229 if ($sql[$i] !=
"" && substr($sql[$i],0,1)!=
"#")
232 if (substr($sql[$i],-1)==
";")
235 $q .=
" ".substr($sql[$i],0,-1);
256 if ($this->client->checkDatabaseExists())
258 $this->error = $this->lng->txt(
"database_exists");
263 $db = $this->db_connections->connectHost($this->client->dsn_host);
264 if (MDB2::isError(
$db))
266 $this->error =
"connection_failed";
270 if ($a_collation !=
"")
272 $sql =
"CREATE DATABASE ".$this->client->getdbName().
273 " CHARACTER SET utf8".
274 " COLLATE ".$a_collation;
278 $sql =
"CREATE DATABASE ".$this->client->getdbName();
280 $r =
$db->query($sql);
282 if (MDB2::isError($r))
284 $this->error =
"create_database_failed";
291 $this->client->db_exists =
true;
301 if (!$this->client->checkDatabaseHost())
303 $this->error =
"no_connection_to_host";
307 if (!$this->client->connect())
313 if ($this->
readDump($this->client->db, $this->SQL_FILE))
315 $this->client->db_installed =
true;
327 while( !feof( $fp ) )
345 $fp = fopen(
$file,
'r');
350 $line = trim($this->
getline($fp,
"\n"));
352 if ($line !=
"" && substr($line,0,1)!=
"#"
353 && substr($line,0,1)!=
"-")
356 if (substr($line,-1)==
";")
359 $q .=
" ".substr($line,0,-1);
361 if (mysql_errno() > 0)
363 echo
"<br />ERROR: ".mysql_error().
388 $a = @file_exists($this->INI_FILE);
400 if (is_writable($a_dir))
402 $arr[
"status"] =
true;
405 $arr[
"comment"] = getcwd();
410 $arr[
"status"] =
false;
411 $arr[
"comment"] = $this->lng->txt(
"pre_folder_write_error");
414 $arr[
"comment"] = getcwd().
": ".$arr[
"comment"];
429 if (@mkdir($a_dir.
"/crst879dldsk9d", 0774))
431 $arr[
"status"] =
true;
432 $arr[
"comment"] =
"";
434 @rmdir($a_dir.
"/crst879dldsk9d");
438 $arr[
"status"] =
false;
441 $arr[
"comment"] = getcwd().
": ".$this->lng->txt(
"pre_folder_create_error");
456 if ($sess->usesCookies)
458 $arr[
"status"] =
true;
459 $arr[
"comment"] =
"";
463 $arr[
"status"] =
false;
464 $arr[
"comment"] = $this->lng->txt(
"pre_cookies_disabled");
476 $version = phpversion();
478 $arr[
"version"] = $version;
479 $version_comp = explode(
".", $version);
480 $first = (integer) substr($version,0,1);
486 $arr[
"status"] =
false;
487 $arr[
"comment"] = $this->lng->txt(
"pre_php_version_3");
491 $arr[
"status"] =
false;
492 $arr[
"comment"] =
"PHP ".$version.
". ".$this->lng->txt(
"pre_php_version_4");
496 $arr[
"status"] =
true;
497 $arr[
"comment"] =
"PHP ".$version;
498 if ((
int)$version_comp[1] < 2 || ($version_comp[1] == 2 && $version_comp[2] == 0))
500 $arr[
"comment"].=
". ".$this->lng->txt(
"pre_php_version_5");
505 $arr[
"status"] =
true;
506 $arr[
"comment"] =
"PHP ".$version;
509 $arr[
"status"] =
true;
510 $arr[
"comment"] = $this->lng->txt(
"pre_php_version_unknown");
525 if (function_exists(
"mysql_query"))
527 $arr[
"status"] =
true;
528 $arr[
"comment"] = $this->lng->txt(
"pre_mysql_4_1_or_higher");
532 $arr[
"status"] =
false;
533 $arr[
"comment"] = $this->lng->txt(
"pre_mysql_missing");
562 if (class_exists(
"DOMDocument"))
564 $arr[
"status"] =
true;
568 $arr[
"status"] =
false;
569 $arr[
"comment"] = $this->lng->txt(
"pre_dom_missing");
583 if (class_exists(
"XSLTProcessor"))
585 $arr[
"status"] =
true;
589 $arr[
"status"] =
false;
590 $arr[
"comment"] = sprintf($this->lng->txt(
"pre_xsl_missing"),
591 "http://php.net/manual/en/book.xsl.php");
605 if (function_exists(
"imagefill") && function_exists(
"imagecolorallocate"))
607 $arr[
"status"] =
true;
611 $arr[
"status"] =
false;
612 $arr[
"comment"] = sprintf($this->lng->txt(
"pre_gd_missing"),
613 "http://php.net/manual/en/book.image.php");
627 $limit = ini_get(
"memory_limit");
630 if (is_int(strpos($limit,
"M")))
632 $limit_n = (int) $limit;
641 $arr[
"status"] =
true;
642 $arr[
"comment"] = $limit.
". ".$this->lng->txt(
"pre_memory_limit_recommend");
646 $arr[
"status"] =
false;
647 $arr[
"comment"] = $limit.
". ".$this->lng->txt(
"pre_memory_limit_too_low");
684 foreach ($this->preliminaries_result as $val)
686 if ($val[
"status"] ===
false)
688 $this->preliminaries =
false;
702 return $this->ini->readVariable(
"setup",
"pass");
712 $this->ini->setVariable(
"setup",
"pass",md5($a_password));
714 if ($this->ini->write() ==
false)
716 $this->error = $this->ini->getError();
730 if (empty($a_auth_data[
"client_id"]))
732 $this->error =
"no_client_id";
736 if (empty($a_auth_data[
"username"]))
738 $this->error =
"no_username";
742 if (empty($a_auth_data[
"password"]))
744 $this->error =
"no_password";
748 if (!$this->
newClient($a_auth_data[
"client_id"]))
750 $this->error =
"unknown_client_id";
751 unset($this->client);
755 if (!$this->client->db_exists)
757 $this->error =
"no_db_connect_consult_admin";
758 unset($this->client);
762 $q =
"SELECT usr_data.usr_id FROM usr_data ".
763 "LEFT JOIN rbac_ua ON rbac_ua.usr_id=usr_data.usr_id ".
764 "LEFT JOIN settings ON settings.value = rbac_ua.rol_id ".
765 "WHERE settings.keyword='system_role_id' ".
766 "AND usr_data.login='".$a_auth_data[
"username"].
"' ".
767 "AND usr_data.passwd='".md5($a_auth_data[
"password"]).
"'";
768 $r = $this->client->db->query($q);
772 $this->error =
"login_invalid";
779 $_SESSION[
"ClientId"] = $this->client->getId();
790 $a_password = md5($a_password);
792 if ($this->ini->readVariable(
"setup",
"pass") == $a_password)
814 $this->client =
new ilClient($a_client_id, $this->db_connections);
816 if (!$this->client->init())
818 $this->error = get_class($this).
": ".$this->client->getError();
837 if ($this->ini_client_exists)
851 if ($status[
"db"][
"status"] ===
false and $status[
"db"][
"update"] !==
true)
853 $status[
"lang"][
"status"] =
false;
854 $status[
"lang"][
"comment"] = $status[
"db"][
"comment"];
855 $status[
"contact"][
"status"] =
false;
856 $status[
"contact"][
"comment"] = $status[
"db"][
"comment"];
857 $status[
"nic"][
"status"] =
false;
858 $status[
"nic"][
"comment"] = $status[
"db"][
"comment"];
880 if (
$client->getSetting(
"setup_ok"))
882 $arr[
"status"] =
true;
883 $arr[
"comment"] = $this->lng->txt(
"setup_finished");
887 $arr[
"status"] =
false;
888 $arr[
"comment"] = $this->lng->txt(
"setup_not_finished");
901 if (
$client->ini->readVariable(
"client",
"access") ==
"1")
903 $arr[
"status"] =
true;
904 $arr[
"comment"] = $this->lng->txt(
"online");
908 $arr[
"status"] =
false;
909 $arr[
"comment"] = $this->lng->txt(
"disabled");
922 if (!$arr[
"status"] =
$client->init())
924 $arr[
"comment"] =
$client->getError();
928 $arr[
"comment"] =
"dir: /".ILIAS_WEB_DIR.
"/".
$client->getId();
941 if (!$arr[
"status"] =
$client->db_exists)
943 $arr[
"comment"] = $this->lng->txt(
"no_database");
947 if (!$arr[
"status"] =
$client->db_installed)
949 $arr[
"comment"] = $this->lng->txt(
"db_not_installed");
956 $this->lng->setDbHandler(
$client->db);
957 include_once
"../classes/class.ilDBUpdate.php";
960 if (!$arr[
"status"] = $dbupdate->getDBVersionStatus())
962 $arr[
"comment"] = $this->lng->txt(
"db_needs_update");
963 $arr[
"update"] =
true;
968 $q =
"SELECT count(*) as cnt FROM ctrl_calls";
969 $cset =
$client->db->query($q);
971 if ($crec[
"cnt"] == 0)
973 $arr[
"status"] =
false;
974 $arr[
"comment"] = $this->lng->txt(
"db_control_structure_missing");
975 $arr[
"update"] =
true;
979 $arr[
"comment"] =
"version ".$dbupdate->getCurrentVersion();
990 $installed_langs = $this->lng->getInstalledLanguages();
992 $count = count($installed_langs);
996 $arr[
"status"] =
false;
997 $arr[
"comment"] = $this->lng->txt(
"lang_none_installed");
1001 $arr[
"status"] =
true;
1002 $arr[
"comment"] = $count.
" ".$this->lng->txt(
"languages_installed");
1015 $arr[
"status"] =
true;
1016 $arr[
"comment"] = $this->lng->txt(
"filled_out");
1018 $settings =
$client->getAllSettings();
1019 $client_name =
$client->getName();
1022 if (empty($settings[
"admin_firstname"]) or empty($settings[
"admin_lastname"])
1023 or empty($settings[
"admin_street"]) or empty($settings[
"admin_zipcode"])
1024 or empty($settings[
"admin_country"]) or empty($settings[
"admin_city"])
1025 or empty($settings[
"admin_phone"]) or empty($settings[
"admin_email"])
1026 or empty($client_name) or empty($settings[
"inst_institution"]))
1028 $arr[
"status"] =
false;
1029 $arr[
"comment"] = $this->lng->txt(
"missing_data");
1033 if (!
ilUtil::is_email($settings[
"admin_email"]) and $arr[
"status"] !=
false)
1035 $arr[
"status"] =
false;
1036 $arr[
"comment"] = $this->lng->txt(
"email_not_valid");
1049 $settings =
$client->getAllSettings();
1051 if (!isset($settings[
"nic_enabled"]))
1053 $arr[
"status"] =
false;
1054 $arr[
"comment"] = $this->lng->txt(
"nic_not_disabled");
1058 $arr[
"status"] =
true;
1060 if ($settings[
"nic_enabled"] ==
"-1")
1062 $arr[
"comment"] = $this->lng->txt(
"nic_reg_failed");
1066 if (!$settings[
"nic_enabled"])
1068 $arr[
"comment"] = $this->lng->txt(
"nic_reg_disabled");
1072 $arr[
"comment"] = $this->lng->txt(
"nic_reg_enabled");
1073 if ($settings[
"inst_id"] <= 0)
1075 $arr[
"status"] =
false;
1106 return ($this->access_mode ==
"admin") ?
true :
false;
1118 if ($a_formdata[
"chk_datadir_path"] == 1)
1122 $this->error =
"create_datadir_failed";
1132 $this->error =
"create_webdir_failed";
1138 $log_path = substr($form_log_path,0,strrpos($form_log_path,
"/"));
1139 $log_file = substr($form_log_path,strlen($log_path)+1);
1141 $this->ini->setVariable(
"server",
"http_path",ILIAS_HTTP_PATH);
1143 $this->ini->setVariable(
"clients",
"datadir", $datadir_path);
1144 $this->ini->setVariable(
"tools",
"convert", preg_replace(
"/\\\\/",
"/",
ilUtil::stripSlashes($a_formdata[
"convert_path"])));
1145 $this->ini->setVariable(
"tools",
"zip", preg_replace(
"/\\\\/",
"/",
ilUtil::stripSlashes($a_formdata[
"zip_path"])));
1146 $this->ini->setVariable(
"tools",
"unzip", preg_replace(
"/\\\\/",
"/",
ilUtil::stripSlashes($a_formdata[
"unzip_path"])));
1147 $this->ini->setVariable(
"tools",
"java", preg_replace(
"/\\\\/",
"/",
ilUtil::stripSlashes($a_formdata[
"java_path"])));
1148 $this->ini->setVariable(
"tools",
"htmldoc", preg_replace(
"/\\\\/",
"/",
ilUtil::stripSlashes($a_formdata[
"htmldoc_path"])));
1150 $this->ini->setVariable(
"tools",
"vscantype", preg_replace(
"/\\\\/",
"/",
ilUtil::stripSlashes($a_formdata[
"vscanner_type"])));
1151 $this->ini->setVariable(
"tools",
"scancommand", preg_replace(
"/\\\\/",
"/",
ilUtil::stripSlashes($a_formdata[
"scan_command"])));
1152 $this->ini->setVariable(
"tools",
"cleancommand", preg_replace(
"/\\\\/",
"/",
ilUtil::stripSlashes($a_formdata[
"clean_command"])));
1153 $this->ini->setVariable(
"setup",
"pass", md5($a_formdata[
"setup_pass"]));
1154 $this->ini->setVariable(
"log",
"path", $log_path);
1155 $this->ini->setVariable(
"log",
"file", $log_file);
1156 $this->ini->setVariable(
"log",
"enabled", (isset($a_formdata[
"chk_log_status"])) ?
"0" : 1);
1158 if (!$this->ini->write())
1160 $this->error = get_class($this).
": ".$this->ini->getError();
1187 $clean_command = preg_replace(
"/\\\\/",
"/",
ilUtil::stripSlashes($a_formdata[
"clean_command"]));
1189 $this->ini->setVariable(
"tools",
"convert", $convert_path);
1190 $this->ini->setVariable(
"tools",
"zip", $zip_path);
1191 $this->ini->setVariable(
"tools",
"unzip", $unzip_path);
1192 $this->ini->setVariable(
"tools",
"java", $java_path);
1193 $this->ini->setVariable(
"tools",
"htmldoc", $htmldoc_path);
1194 $this->ini->setVariable(
"tools",
"latex", $latex_url);
1195 $this->ini->setVariable(
"tools",
"fop", $fop_path);
1196 $this->ini->setVariable(
"tools",
"vscantype", $scan_type);
1197 $this->ini->setVariable(
"tools",
"scancommand", $scan_command);
1198 $this->ini->setVariable(
"tools",
"cleancommand", $clean_command);
1201 $log_path = substr($form_log_path,0,strrpos($form_log_path,
"/"));
1202 $log_file = substr($form_log_path,strlen($log_path)+1);
1204 $this->ini->setVariable(
"log",
"path", $log_path);
1205 $this->ini->setVariable(
"log",
"file", $log_file);
1206 $this->ini->setVariable(
"log",
"enabled", (isset($a_formdata[
"chk_log_status"])) ?
"0" : 1);
1208 if (!$this->ini->write())
1210 $this->error = get_class($this).
": ".$this->ini->getError();
1225 if (!isset($a_formdata[
"chk_convert_path"]))
1230 if (($err = $this->
testConvert($convert_path)) !=
"")
1232 $this->error = $err;
1238 if (!isset($a_formdata[
"chk_zip_path"]))
1243 if (empty($zip_path))
1245 $this->error =
"no_path_zip";
1249 if (!$this->
testZip($zip_path))
1251 $this->error =
"check_failed_zip";
1257 if (!isset($a_formdata[
"chk_unzip_path"]))
1262 if (empty($unzip_path))
1264 $this->error =
"no_path_unzip";
1270 $this->error =
"check_failed_unzip";
1276 if (!isset($a_formdata[
"chk_java_path"]))
1281 if (empty($java_path))
1283 $this->error =
"no_path_java";
1289 $this->error =
"check_failed_java";
1295 if (!isset($a_formdata[
"chk_htmldoc_path"]))
1300 if (empty($htmldoc_path))
1302 $this->error =
"no_path_htmldoc";
1308 $this->error =
"check_failed_htmldoc";
1314 if (!isset($a_formdata[
"chk_latex_url"]))
1317 if (empty($latex_url))
1319 $this->error =
"no_latex_url";
1325 $this->error =
"check_failed_latex";
1343 if (empty($datadir_path))
1345 $this->error =
"no_path_datadir";
1352 if (strpos($datadir_path,$webspace_dir) !==
false)
1354 $this->error =
"datadir_webspacedir_match";
1359 if ($a_formdata[
"chk_datadir_path"] == 1)
1361 $dir_to_create = substr(strrchr($datadir_path,
"/"), 1);
1362 $dir_to_check = substr($datadir_path,0,- strlen($dir_to_create)-1);
1364 if (is_writable($datadir_path))
1366 $this->error =
"dir_exists_create";
1370 if (!is_writable($dir_to_check))
1372 $this->error =
"cannot_create_datadir_no_write_access";
1378 if (!is_writable($datadir_path))
1380 $this->error =
"cannot_create_datadir_no_write_access";
1395 if (!$a_formdata[
"setup_pass"])
1397 $this->error =
"no_setup_pass_given";
1401 if ($a_formdata[
"setup_pass"] != $a_formdata[
"setup_pass2"])
1403 $this->error =
"pass_does_not_match";
1418 if (!isset($a_formdata[
"chk_log_status"]))
1423 if (empty($log_path))
1425 $this->error =
"no_path_log";
1429 if (!@touch($log_path))
1431 $this->error =
"could_not_create_logfile";
1445 if (empty($this->error))
1478 if (trim($a_convert_path) ==
"")
1480 return "no_path_convert";
1482 if (!is_file($a_convert_path))
1484 return "check_failed_convert";
1520 if (trim($a_java_path) ==
"")
1525 if (!is_file($a_java_path))
1527 return "check_failed_java";
1549 if (trim($a_latex_url) ==
"")
1555 include_once
"class.ilHttpRequest.php";
1557 $result = @$http->downloadToString();
1558 if ((strpos((substr(
$result, 0, 5)),
"PNG") !== FALSE) || (strpos((substr(
$result, 0, 5)),
"GIF") !== FALSE))
1564 return "check_failed_latex";;
1576 if (trim($a_zip_path) ==
"")
1578 return "no_path_zip";
1580 if (!is_file($a_zip_path))
1582 return "check_failed_zip";
1629 if (trim($a_unzip_path) ==
"")
1631 return "no_path_unzip";
1633 if (!is_file($a_unzip_path))
1635 return "check_failed_unzip";
1675 if (trim($a_htmldoc_path) ==
"")
1680 if (!is_file($a_htmldoc_path))
1682 return "check_failed_htmldoc";
1692 $html =
"<html><head><title></title></head><body><p>test</p></body></html>";
1694 $html_file =
"htmldoc_test_file.html";
1696 $fp = fopen( $html_file ,
"wb");
1700 $htmldoc = $a_htmldoc_path.
" ";
1701 $htmldoc .=
"--no-toc ";
1702 $htmldoc .=
"--no-jpeg ";
1703 $htmldoc .=
"--webpage ";
1704 $htmldoc .=
"--outfile htmldoc_test_file.pdf ";
1705 $htmldoc .=
"--bodyfont Arial ";
1706 $htmldoc .=
"--charset iso-8859-15 ";
1707 $htmldoc .=
"--color ";
1708 $htmldoc .=
"--size A4 ";
1709 $htmldoc .=
"--format pdf ";
1710 $htmldoc .=
"--footer ... ";
1711 $htmldoc .=
"--header ... ";
1712 $htmldoc .=
"--left 60 ";
1714 $htmldoc .= $html_file;
1735 $this->ini->setVariable(
"tools",
"tiny_md5", md5_file(
ILIAS_ABSOLUTE_PATH .
"/Services/RTE/tiny_mce.zip"));
1736 if ($this->ini->write() ==
false)
1738 $this->error = $this->ini->getError();
1750 function unzip($a_file, $overwrite =
false)
1754 $pathinfo = pathinfo($a_file);
1755 $dir = $pathinfo[
"dirname"];
1756 $file = $pathinfo[
"basename"];
1761 $unzip = $this->ini->readVariable(
"tools",
"unzip");
1763 exec($unzipcmd, $arr);
1766 foreach($arr as $line)
1768 if(is_int(strpos($line,
"/")))
1770 $zdir = substr($line, 0, strrpos($line,
"/"));
1771 $nr = substr_count($zdir,
"/");
1775 $nr = substr_count($zdir,
"/");
1776 $zdirs[$zdir] = $nr;
1778 $zdir = substr($zdir, 0, strrpos($zdir,
"/"));
1785 foreach($zdirs as $zdir => $nr)