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";
179 include_once(
"./Services/Database/classes/class.ilDBWrapperFactory.php");
181 $this->db->setDBUser($this->getdbUser());
182 $this->db->setDBPort($this->getdbPort());
183 $this->db->setDBPassword($this->getdbPass());
184 $this->db->setDBHost($this->getdbHost());
185 $this->db->setDBName($this->getdbName());
188 $con = $this->db->connect(
true);
193 $this->error =
"Database connection failed.";
198 $this->db_exists =
true;
209 if(method_exists($a_db,
'loadModule'))
211 $a_db->loadModule(
'Manager');
213 if(!$tables = $a_db->listTables())
219 if (in_array(
"object_data",$tables) and in_array(
"object_reference",$tables) and in_array(
"usr_data",$tables) and in_array(
"rbac_ua",$tables))
221 $this->db_installed =
true;
224 $this->db_installed =
false;
237 $this->dsn_host = array(
239 'hostspec' => $this->getdbHost(),
240 'username' => $this->getdbUser(),
241 'port' => $this->getdbPort(),
242 'password' => $this->getdbPass(),
245 $this->dsn = $this->dsn = array(
247 'hostspec' => $this->getdbHost(),
248 'username' => $this->getdbUser(),
249 'port' => $this->getdbPort(),
250 'password' => $this->getdbPass(),
251 'service' => $this->getdbName()
258 if (trim($this->getdbPort()) !=
"")
260 $db_port_str =
":".$this->getdbPort();
262 $this->dsn_host =
"mysql://".$this->getdbUser().
":".$this->getdbPass().
"@".$this->getdbHost().$db_port_str;
263 $this->dsn =
"mysql://".$this->getdbUser().
":".$this->getdbPass().
"@".$this->getdbHost().$db_port_str.
"/".$this->getdbName();
274 $this->ini->setVariable(
"db",
"host",$a_str);
284 return $this->ini->readVariable(
"db",
"host");
293 $this->ini->setVariable(
"db",
"name",$a_str);
302 return $this->ini->readVariable(
"db",
"name");
311 $this->ini->setVariable(
"db",
"user",$a_str);
320 return $this->ini->readVariable(
"db",
"user");
329 return $this->ini->readVariable(
"db",
"port");
338 $this->ini->setVariable(
"db",
"port",$a_str);
347 $this->ini->setVariable(
"db",
"pass",$a_str);
356 return $this->ini->readVariable(
"db",
"pass");
365 $this->ini->setVariable(
"db",
"type",$a_str);
374 $val = $this->ini->readVariable(
"db",
"type");
391 return ILIAS_DATA_DIR.
"/".$this->
getId();
417 $db = $this->db_connections->connectHost($this->dsn_host);
422 $this->error = $db->getMessage().
" - ".$lng->txt(
"db_error_please_check");
436 $db = $this->db_connections->connectDB($this->dsn);
463 include_once
'./Services/Administration/classes/class.ilSetting.php';
465 return $set->get($a_keyword);
475 include_once
'./Services/Administration/classes/class.ilSetting.php';
477 return $set->getAll();
489 include_once
'./Services/Administration/classes/class.ilSetting.php';
491 $set->set($a_key, $a_val);
502 $inst_id = (empty($settings[
"inst_id"])) ?
"0" : $settings[
"inst_id"];
507 "&inst_id=".rawurlencode($inst_id).
508 "&hostname=".rawurlencode($_SERVER[
"SERVER_NAME"]).
509 "&ipadr=".rawurlencode($_SERVER[
"SERVER_ADDR"]).
510 "&server_port=".rawurlencode($_SERVER[
"SERVER_PORT"]).
511 "&server_software=".rawurlencode($_SERVER[
"SERVER_SOFTWARE"]).
512 "&inst_name=".rawurlencode($this->ini->readVariable(
"client",
"name")).
513 "&inst_info=".rawurlencode($this->ini->readVariable(
"client",
"description")).
514 "&institution=".rawurlencode($settings[
"inst_institution"]).
515 "&http_path=".rawurlencode(ILIAS_HTTP_PATH).
516 "&contact_firstname=".rawurlencode($settings[
"admin_firstname"]).
517 "&contact_lastname=".rawurlencode($settings[
"admin_lastname"]).
518 "&contact_title=".rawurlencode($settings[
"admin_title"]).
519 "&contact_position=".rawurlencode($settings[
"admin_position"]).
520 "&contact_institution=".rawurlencode($settings[
"admin_institution"]).
521 "&contact_street=".rawurlencode($settings[
"admin_street"]).
522 "&contact_pcode=".rawurlencode($settings[
"admin_zipcode"]).
523 "&contact_city=".rawurlencode($settings[
"admin_city"]).
524 "&contact_country=".rawurlencode($settings[
"admin_country"]).
525 "&contact_phone=".rawurlencode($settings[
"admin_phone"]).
526 "&contact_email=".rawurlencode($settings[
"admin_email"]).
527 "&nic_key=".rawurlencode($this->
getNICkey()).
528 "&version=".rawurlencode($settings[
"ilias_version"]);
551 $conn = @fopen($url,
"r");
563 $input.= fgets($conn, 4096);
567 $line = explode(
"\n",$input);
572 $this->nic_status =
$ret;
587 mt_srand((
double)microtime()*1000000);
588 $nic_key = md5(str_replace(
".",
"",$_SERVER[
"SERVER_ADDR"]) +
589 mt_rand(100000,999999));
593 $this->nic_key = $nic_key;
605 $this->nic_key = $this->
getSetting(
"nic_key");
607 if (empty($this->nic_key))
612 return $this->nic_key;
623 $this->ini->setVariable(
"language",
"default",$a_lang_key);
635 $error = $this->error;
649 function delete ($a_ini =
true, $a_db =
false, $a_files =
false)
653 unlink(CLIENT_WEB_DIR.
"/client.ini.php");
654 $msg[] =
"ini_deleted";
657 if ($a_db ===
true and $this->db_exists)
659 $this->db->query(
"DROP DATABASE ".$this->
getDbName());
660 $msg[] =
"db_deleted";
663 if ($a_files ===
true and file_exists(CLIENT_WEB_DIR) and is_dir(CLIENT_WEB_DIR))
668 $msg[] =
"files_deleted";
684 $this->error =
"could_not_create_base_data_dir :".$this->getDataDir();
691 $this->error =
"could_not_create_mail_data_dir :".$this->getDataDir().
"/mail";
697 $this->error =
"could_not_create_lm_data_dir :".$this->getDataDir().
"/lm_data";
703 $this->error =
"could_not_create_forum_data_dir :".$this->getDataDir().
"/forum";
709 $this->error =
"could_not_create_files_data_dir :".$this->getDataDir().
"/files";
716 $this->error =
"could_not_create_base_webspace_dir :".$this->getWebspaceDir();
723 $this->error =
"could_not_create_lm_webspace_dir :".$this->getWebspaceDir().
"/lm_data";
729 $this->error =
"could_not_create_usr_images_webspace_dir :".$this->getWebspaceDir().
"/usr_images";
735 $this->error =
"could_not_create_mobs_webspace_dir :".$this->getWebspaceDir().
"/mobs";
741 $this->error =
"could_not_create_css_webspace_dir :".$this->getWebspaceDir().
"/css";
746 if (!$this->ini->write())
748 $this->error = get_class($this).
": ".$this->ini->getError();