49 function ilClient($a_client_id, $a_db_connections)
53 $this->
id = $a_client_id;
57 $this->db_connections = $a_db_connections;
70 $this->ini =
new ilIniFile($this->ini_file_path);
73 if (!@file_exists($this->ini_file_path))
75 $this->ini->GROUPS = parse_ini_file($this->client_defaults,
true);
80 if (!$this->ini->read())
82 $this->error = get_class($this).
": ".$this->ini->getError();
88 define(
"CLIENT_DATA_DIR",ILIAS_DATA_DIR.
"/".$this->getId());
89 define (
"DEVMODE",$this->ini->readVariable(
'system',
'DEVMODE'));
90 define (
"ROOT_FOLDER_ID",$this->ini->readVariable(
'system',
'ROOT_FOLDER_ID'));
91 define (
"SYSTEM_FOLDER_ID",$this->ini->readVariable(
'system',
'SYSTEM_FOLDER_ID'));
92 define (
"ROLE_FOLDER_ID",$this->ini->readVariable(
'system',
'ROLE_FOLDER_ID'));
93 define (
"ANONYMOUS_USER_ID",13);
94 define (
"ANONYMOUS_ROLE_ID",14);
95 define (
"SYSTEM_USER_ID",6);
96 define (
"SYSTEM_ROLE_ID",2);
98 $this->db_exists = $this->
connect();
100 if ($this->db_exists)
123 $this->
id = $a_client_id;
133 return $this->ini->readVariable(
"client",
"name");
142 $this->ini->setVariable(
"client",
"name",$a_str);
151 return $this->ini->readVariable(
"client",
"description");
160 $this->ini->setVariable(
"client",
"description",$a_str);
168 return mysql_get_server_info();
181 $version = explode(
".", $this->getMysqlVersion());
182 if ((
int)$version[0] >= 5 ||
183 ((
int)$version[0] == 4 && (
int)$version[1] >= 1))
198 if (!$this->getdbHost() || !$this->getdbName() || !$this->getdbUser())
200 $this->error =
"empty_fields";
222 $this->db = $this->db_connections->connectDB($this->dsn);
225 if (MDB2::isError($this->db))
227 $this->error = $this->db->getMessage().
"! not_connected_to_db";
237 $this->db->query(
"SET NAMES utf8");
238 $this->db->query(
"SET SESSION SQL_MODE = ''");
241 $this->db_exists =
true;
253 $r = $a_db->query($q);
259 $tables[] = implode($row);
263 if (in_array(
"object_data",$tables) and in_array(
"object_reference",$tables) and in_array(
"usr_data",$tables) and in_array(
"rbac_ua",$tables))
265 $this->db_installed =
true;
269 $this->db_installed =
false;
279 $this->dsn_host =
"mysql://".$this->getdbUser().
":".$this->getdbPass().
"@".$this->getdbHost();
280 $this->dsn =
"mysql://".$this->getdbUser().
":".$this->getdbPass().
"@".$this->getdbHost().
"/".$this->getdbName();
289 $this->ini->setVariable(
"db",
"host",$a_str);
299 return $this->ini->readVariable(
"db",
"host");
308 $this->ini->setVariable(
"db",
"name",$a_str);
317 return $this->ini->readVariable(
"db",
"name");
326 $this->ini->setVariable(
"db",
"user",$a_str);
335 return $this->ini->readVariable(
"db",
"user");
344 $this->ini->setVariable(
"db",
"pass",$a_str);
353 return $this->ini->readVariable(
"db",
"pass");
362 return ILIAS_DATA_DIR.
"/".$this->
getId();
383 $db = $this->db_connections->connectHost($this->dsn_host);
385 if (MDB2::isError($db))
388 $this->error = $db->getMessage().
" - ".$lng->txt(
"db_error_please_check");
402 $db = $this->db_connections->connectDB($this->dsn);
404 if (MDB2::isError($db))
419 $this->db = $this->db_connections->connectDB($this->dsn);
430 $q =
"SELECT value FROM settings WHERE keyword='".$a_keyword.
"'";
431 $r = $this->db->query($q);
438 if ($r->numRows() > 0)
440 $row = $r->fetchRow();
461 $q =
"SELECT * FROM settings";
462 $r = $this->db->query($q);
466 $arr[$row[
"keyword"]] = $row[
"value"];
486 $q =
"REPLACE INTO settings (keyword,value) VALUES ('".$a_key.
"', '".$a_val.
"')";
487 $r = $this->db->query($q);
489 $set = $this->db->query(
"SELECT * FROM settings WHERE keyword = '".$a_key.
"'");
492 if ($a_key ==
"setup_ok")
515 $inst_id = (empty($settings[
"inst_id"])) ?
"0" : $settings[
"inst_id"];
520 "&inst_id=".rawurlencode($inst_id).
521 "&hostname=".rawurlencode($_SERVER[
"SERVER_NAME"]).
522 "&ipadr=".rawurlencode($_SERVER[
"SERVER_ADDR"]).
523 "&server_port=".rawurlencode($_SERVER[
"SERVER_PORT"]).
524 "&server_software=".rawurlencode($_SERVER[
"SERVER_SOFTWARE"]).
525 "&inst_name=".rawurlencode($this->ini->readVariable(
"client",
"name")).
526 "&inst_info=".rawurlencode($this->ini->readVariable(
"client",
"description")).
527 "&institution=".rawurlencode($settings[
"inst_institution"]).
528 "&http_path=".rawurlencode(ILIAS_HTTP_PATH).
529 "&contact_firstname=".rawurlencode($settings[
"admin_firstname"]).
530 "&contact_lastname=".rawurlencode($settings[
"admin_lastname"]).
531 "&contact_title=".rawurlencode($settings[
"admin_title"]).
532 "&contact_position=".rawurlencode($settings[
"admin_position"]).
533 "&contact_institution=".rawurlencode($settings[
"admin_institution"]).
534 "&contact_street=".rawurlencode($settings[
"admin_street"]).
535 "&contact_pcode=".rawurlencode($settings[
"admin_zipcode"]).
536 "&contact_city=".rawurlencode($settings[
"admin_city"]).
537 "&contact_country=".rawurlencode($settings[
"admin_country"]).
538 "&contact_phone=".rawurlencode($settings[
"admin_phone"]).
539 "&contact_email=".rawurlencode($settings[
"admin_email"]).
540 "&nic_key=".rawurlencode($this->
getNICkey()).
541 "&version=".rawurlencode($settings[
"ilias_version"]);
564 $conn =fopen($url,
"r");
576 $input.= fgets($conn, 4096);
580 $line = explode(
"\n",$input);
585 $this->nic_status =
$ret;
600 mt_srand((
double)microtime()*1000000);
601 $nic_key = md5(str_replace(
".",
"",$_SERVER[
"SERVER_ADDR"]) +
602 mt_rand(100000,999999));
606 $this->nic_key = $nic_key;
618 $this->nic_key = $this->
getSetting(
"nic_key");
620 if (empty($this->nic_key))
625 return $this->nic_key;
636 $this->ini->setVariable(
"language",
"default",$a_lang_key);
648 $error = $this->error;
662 function delete ($a_ini =
true, $a_db =
false, $a_files =
false)
666 unlink(CLIENT_WEB_DIR.
"/client.ini.php");
667 $msg[] =
"ini_deleted";
670 if ($a_db ===
true and $this->db_exists)
672 $this->db->query(
"DROP DATABASE ".$this->
getDbName());
673 $msg[] =
"db_deleted";
676 if ($a_files ===
true and file_exists(CLIENT_WEB_DIR) and is_dir(CLIENT_WEB_DIR))
681 $msg[] =
"files_deleted";
697 $this->error =
"could_not_create_base_data_dir :".$this->getDataDir();
704 $this->error =
"could_not_create_mail_data_dir :".$this->getDataDir().
"/mail";
710 $this->error =
"could_not_create_lm_data_dir :".$this->getDataDir().
"/lm_data";
716 $this->error =
"could_not_create_forum_data_dir :".$this->getDataDir().
"/forum";
722 $this->error =
"could_not_create_files_data_dir :".$this->getDataDir().
"/files";
729 $this->error =
"could_not_create_base_webspace_dir :".$this->getWebspaceDir();
736 $this->error =
"could_not_create_lm_webspace_dir :".$this->getWebspaceDir().
"/lm_data";
742 $this->error =
"could_not_create_usr_images_webspace_dir :".$this->getWebspaceDir().
"/usr_images";
748 $this->error =
"could_not_create_mobs_webspace_dir :".$this->getWebspaceDir().
"/mobs";
754 $this->error =
"could_not_create_css_webspace_dir :".$this->getWebspaceDir().
"/css";
759 if (!$this->ini->write())
761 $this->error = get_class($this).
": ".$this->ini->getError();