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",
"type",$a_str);
384 $val = $this->ini->readVariable(
"db",
"type");
401 return ILIAS_DATA_DIR.
"/".$this->
getId();
427 $db = $this->db_connections->connectHost($this->dsn_host);
431 $this->error = $db->getMessage().
" - ".$db->getUserInfo().
" - ".$lng->txt(
"db_error_please_check");
445 $db = $this->db_connections->connectDB($this->dsn);
457 if($a_keep_connection)
478 include_once
'./Services/Administration/classes/class.ilSetting.php';
480 return $set->get($a_keyword);
490 include_once
'./Services/Administration/classes/class.ilSetting.php';
492 return $set->getAll();
504 include_once
'./Services/Administration/classes/class.ilSetting.php';
506 $set->set($a_key, $a_val);
517 $inst_id = (empty($settings[
"inst_id"])) ?
"0" : $settings[
"inst_id"];
522 "&inst_id=".rawurlencode($inst_id).
523 "&hostname=".rawurlencode($_SERVER[
"SERVER_NAME"]).
524 "&ipadr=".rawurlencode($_SERVER[
"SERVER_ADDR"]).
525 "&server_port=".rawurlencode($_SERVER[
"SERVER_PORT"]).
526 "&server_software=".rawurlencode($_SERVER[
"SERVER_SOFTWARE"]).
527 "&inst_name=".rawurlencode($this->ini->readVariable(
"client",
"name")).
528 "&inst_info=".rawurlencode($this->ini->readVariable(
"client",
"description")).
529 "&institution=".rawurlencode($settings[
"inst_institution"]).
530 "&http_path=".rawurlencode(ILIAS_HTTP_PATH).
531 "&contact_firstname=".rawurlencode($settings[
"admin_firstname"]).
532 "&contact_lastname=".rawurlencode($settings[
"admin_lastname"]).
533 "&contact_title=".rawurlencode($settings[
"admin_title"]).
534 "&contact_position=".rawurlencode($settings[
"admin_position"]).
535 "&contact_institution=".rawurlencode($settings[
"admin_institution"]).
536 "&contact_street=".rawurlencode($settings[
"admin_street"]).
537 "&contact_pcode=".rawurlencode($settings[
"admin_zipcode"]).
538 "&contact_city=".rawurlencode($settings[
"admin_city"]).
539 "&contact_country=".rawurlencode($settings[
"admin_country"]).
540 "&contact_phone=".rawurlencode($settings[
"admin_phone"]).
541 "&contact_email=".rawurlencode($settings[
"admin_email"]).
542 "&nic_key=".rawurlencode($this->
getNICkey()).
543 "&version=".rawurlencode($settings[
"ilias_version"]);
565 if((
bool)$settings[
'proxy_status'] && strlen($settings[
'proxy_host']) && strlen($settings[
'proxy_port']))
567 $proxy_options = array(
568 'proxy_host' => $settings[
'proxy_host'],
569 'proxy_port' => $settings[
'proxy_port']
574 $proxy_options = array();
577 include_once(
'HTTP/Request.php');
579 $req =
new HTTP_Request($url, $proxy_options);
582 $response = $req->getResponseBody();
583 $response = explode(
"\n", $response);
585 $this->nic_status = $response;
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();