29 function ilClient($a_client_id, $a_db_connections)
33 $this->
id = $a_client_id;
37 $this->db_connections = $a_db_connections;
50 $this->ini =
new ilIniFile($this->ini_file_path);
53 if (!@file_exists($this->ini_file_path))
56 $this->ini->GROUPS = parse_ini_file($this->client_defaults,
true);
61 if (!$this->ini->read())
63 $this->error = get_class($this).
": ".$this->ini->getError();
69 define(
"CLIENT_DATA_DIR",ILIAS_DATA_DIR.
"/".$this->getId());
70 define (
"DEVMODE",$this->ini->readVariable(
'system',
'DEVMODE'));
71 define (
"ROOT_FOLDER_ID",$this->ini->readVariable(
'system',
'ROOT_FOLDER_ID'));
72 define (
"SYSTEM_FOLDER_ID",$this->ini->readVariable(
'system',
'SYSTEM_FOLDER_ID'));
73 define (
"ROLE_FOLDER_ID",$this->ini->readVariable(
'system',
'ROLE_FOLDER_ID'));
74 define (
"ANONYMOUS_USER_ID",13);
75 define (
"ANONYMOUS_ROLE_ID",14);
76 define (
"SYSTEM_USER_ID",6);
77 define (
"SYSTEM_ROLE_ID",2);
79 $this->db_exists = $this->
connect();
103 $this->
id = $a_client_id;
113 return $this->ini->readVariable(
"client",
"name");
122 $this->ini->setVariable(
"client",
"name",$a_str);
131 return $this->ini->readVariable(
"client",
"description");
140 $this->ini->setVariable(
"client",
"description",$a_str);
167 if (!$this->getdbHost() || !$this->getdbUser())
169 $this->error =
"empty_fields";
180 include_once(
"./Services/Database/classes/class.ilDBWrapperFactory.php");
182 $this->ini->readVariable(
"db",
"inactive_mysqli"));
183 $this->db->setDBUser($this->getdbUser());
184 $this->db->setDBPort($this->getdbPort());
185 $this->db->setDBPassword($this->getdbPass());
186 $this->db->setDBHost($this->getdbHost());
187 $this->db->setDBName($this->getdbName());
188 $con = $this->db->connect(
true);
192 $this->error =
"Database connection failed.";
197 $this->db_exists =
true;
208 if(method_exists($a_db,
'loadModule'))
210 $a_db->loadModule(
'Manager');
212 if(!$tables = $a_db->listTables())
218 if (in_array(
"object_data",$tables) and in_array(
"object_reference",$tables) and in_array(
"usr_data",$tables) and in_array(
"rbac_ua",$tables))
220 $this->db_installed =
true;
223 $this->db_installed =
false;
236 $this->dsn_host = array(
238 'hostspec' => $this->getdbHost(),
239 'username' => $this->getdbUser(),
240 'port' => $this->getdbPort(),
241 'password' => $this->getdbPass(),
244 $this->dsn = $this->dsn = array(
246 'hostspec' => $this->getdbHost(),
247 'username' => $this->getdbUser(),
248 'port' => $this->getdbPort(),
249 'password' => $this->getdbPass(),
250 'service' => $this->getdbName()
256 if (trim($this->getdbPort()) !=
"")
258 $db_port_str =
":".$this->getdbPort();
260 $this->dsn_host =
"pgsql://".$this->getdbUser().
":".$this->getdbPass().
"@".$this->getdbHost().$db_port_str;
261 $this->dsn =
"pgsql://".$this->getdbUser().
":".$this->getdbPass().
"@".$this->getdbHost().$db_port_str.
"/".$this->getdbName();
268 if (trim($this->getdbPort()) !=
"")
270 $db_port_str =
":".$this->getdbPort();
272 $this->dsn_host =
"mysql://".$this->getdbUser().
":".$this->getdbPass().
"@".$this->getdbHost().$db_port_str;
273 $this->dsn =
"mysql://".$this->getdbUser().
":".$this->getdbPass().
"@".$this->getdbHost().$db_port_str.
"/".$this->getdbName();
284 $this->ini->setVariable(
"db",
"host",$a_str);
294 return $this->ini->readVariable(
"db",
"host");
303 $this->ini->setVariable(
"db",
"name",$a_str);
312 return $this->ini->readVariable(
"db",
"name");
321 $this->ini->setVariable(
"db",
"user",$a_str);
330 return $this->ini->readVariable(
"db",
"user");
339 return $this->ini->readVariable(
"db",
"port");
348 $this->ini->setVariable(
"db",
"port",$a_str);
357 $this->ini->setVariable(
"db",
"pass",$a_str);
366 return $this->ini->readVariable(
"db",
"pass");
375 $this->ini->setVariable(
"db",
"slave_active", (
int) $a_act);
385 return (
int) $this->ini->readVariable(
"db",
"slave_active");
394 $this->ini->setVariable(
"db",
"slave_host",$a_str);
404 return $this->ini->readVariable(
"db",
"slave_host");
413 $this->ini->setVariable(
"db",
"slave_name",$a_str);
422 return $this->ini->readVariable(
"db",
"slave_name");
431 $this->ini->setVariable(
"db",
"slave_user",$a_str);
440 return $this->ini->readVariable(
"db",
"slave_user");
449 return $this->ini->readVariable(
"db",
"slave_port");
458 $this->ini->setVariable(
"db",
"slave_port",$a_str);
467 $this->ini->setVariable(
"db",
"slave_pass",$a_str);
476 return $this->ini->readVariable(
"db",
"slave_pass");
485 $this->ini->setVariable(
"db",
"type",$a_str);
494 $val = $this->ini->readVariable(
"db",
"type");
511 return ILIAS_DATA_DIR.
"/".$this->
getId();
537 $db = $this->db_connections->connectHost($this->dsn_host);
541 $this->error = $db->getMessage().
" - ".$db->getUserInfo().
" - ".$lng->txt(
"db_error_please_check");
555 $db = $this->db_connections->connectDB($this->dsn);
567 if($a_keep_connection)
588 include_once
'./Services/Administration/classes/class.ilSetting.php';
590 return $set->get($a_keyword);
600 include_once
'./Services/Administration/classes/class.ilSetting.php';
602 return $set->getAll();
614 include_once
'./Services/Administration/classes/class.ilSetting.php';
616 $set->set($a_key, $a_val);
627 $inst_id = (empty($settings[
"inst_id"])) ?
"0" : $settings[
"inst_id"];
632 "&inst_id=".rawurlencode($inst_id).
633 "&hostname=".rawurlencode($_SERVER[
"SERVER_NAME"]).
634 "&ipadr=".rawurlencode($_SERVER[
"SERVER_ADDR"]).
635 "&server_port=".rawurlencode($_SERVER[
"SERVER_PORT"]).
636 "&server_software=".rawurlencode($_SERVER[
"SERVER_SOFTWARE"]).
637 "&inst_name=".rawurlencode($this->ini->readVariable(
"client",
"name")).
638 "&inst_info=".rawurlencode($this->ini->readVariable(
"client",
"description")).
639 "&institution=".rawurlencode($settings[
"inst_institution"]).
640 "&http_path=".rawurlencode(ILIAS_HTTP_PATH).
641 "&contact_firstname=".rawurlencode($settings[
"admin_firstname"]).
642 "&contact_lastname=".rawurlencode($settings[
"admin_lastname"]).
643 "&contact_title=".rawurlencode($settings[
"admin_title"]).
644 "&contact_position=".rawurlencode($settings[
"admin_position"]).
645 "&contact_institution=".rawurlencode($settings[
"admin_institution"]).
646 "&contact_street=".rawurlencode($settings[
"admin_street"]).
647 "&contact_pcode=".rawurlencode($settings[
"admin_zipcode"]).
648 "&contact_city=".rawurlencode($settings[
"admin_city"]).
649 "&contact_country=".rawurlencode($settings[
"admin_country"]).
650 "&contact_phone=".rawurlencode($settings[
"admin_phone"]).
651 "&contact_email=".rawurlencode($settings[
"admin_email"]).
652 "&nic_key=".rawurlencode($this->
getNICkey()).
653 "&version=".rawurlencode($settings[
"ilias_version"]);
675 if((
bool)$settings[
'proxy_status'] && strlen($settings[
'proxy_host']) && strlen($settings[
'proxy_port']))
677 $proxy_options = array(
678 'proxy_host' => $settings[
'proxy_host'],
679 'proxy_port' => $settings[
'proxy_port']
684 $proxy_options = array();
687 include_once(
'HTTP/Request.php');
689 $req =
new HTTP_Request($url, $proxy_options);
692 $response = $req->getResponseBody();
693 $response = explode(
"\n", $response);
695 $this->nic_status = $response;
710 mt_srand((
double)microtime()*1000000);
711 $nic_key = md5(str_replace(
".",
"",$_SERVER[
"SERVER_ADDR"]) +
712 mt_rand(100000,999999));
716 $this->nic_key = $nic_key;
728 $this->nic_key = $this->
getSetting(
"nic_key");
730 if (empty($this->nic_key))
735 return $this->nic_key;
746 $this->ini->setVariable(
"language",
"default",$a_lang_key);
758 $error = $this->error;
772 function delete ($a_ini =
true, $a_db =
false, $a_files =
false)
776 unlink(CLIENT_WEB_DIR.
"/client.ini.php");
777 $msg[] =
"ini_deleted";
780 if ($a_db ===
true and $this->db_exists)
782 $this->db->query(
"DROP DATABASE ".$this->
getDbName());
783 $msg[] =
"db_deleted";
786 if ($a_files ===
true and file_exists(CLIENT_WEB_DIR) and is_dir(CLIENT_WEB_DIR))
791 $msg[] =
"files_deleted";
807 $this->error =
"could_not_create_base_data_dir :".$this->getDataDir();
814 $this->error =
"could_not_create_mail_data_dir :".$this->getDataDir().
"/mail";
820 $this->error =
"could_not_create_lm_data_dir :".$this->getDataDir().
"/lm_data";
826 $this->error =
"could_not_create_forum_data_dir :".$this->getDataDir().
"/forum";
832 $this->error =
"could_not_create_files_data_dir :".$this->getDataDir().
"/files";
839 $this->error =
"could_not_create_base_webspace_dir :".$this->getWebspaceDir();
846 $this->error =
"could_not_create_lm_webspace_dir :".$this->getWebspaceDir().
"/lm_data";
852 $this->error =
"could_not_create_usr_images_webspace_dir :".$this->getWebspaceDir().
"/usr_images";
858 $this->error =
"could_not_create_mobs_webspace_dir :".$this->getWebspaceDir().
"/mobs";
864 $this->error =
"could_not_create_css_webspace_dir :".$this->getWebspaceDir().
"/css";
869 if (!$this->ini->write())
871 $this->error = get_class($this).
": ".$this->ini->getError();