52 $this->
id = $a_client_id;
53 $this->ini_file_path = ILIAS_ABSOLUTE_PATH .
"/" . ILIAS_WEB_DIR .
"/" . $this->
getId() .
"/client.ini.php";
56 $this->db_connections = $a_db_connections;
59 $this->client_defaults = ILIAS_ABSOLUTE_PATH .
"/setup/client.master.ini.php";
69 require_once(
'./setup/classes/class.ilDbSetup.php');
72 if (is_null($this->db_setup)) {
79 return \ilDbSetup::getNewInstanceForClient($this);
89 $this->ini =
new ilIniFile($this->ini_file_path);
92 if (!@file_exists($this->ini_file_path)) {
94 $this->ini->GROUPS = parse_ini_file($this->client_defaults,
true);
100 if (!$this->ini->read()) {
101 $this->error = get_class($this) .
": " . $this->ini->getError();
107 define(
"CLIENT_WEB_DIR", ILIAS_ABSOLUTE_PATH .
"/" . ILIAS_WEB_DIR .
"/" . $this->
getId());
108 define(
"CLIENT_DATA_DIR", ILIAS_DATA_DIR .
"/" . $this->
getId());
109 define(
"DEVMODE", $this->ini->readVariable(
'system',
'DEVMODE'));
110 define(
"ROOT_FOLDER_ID", $this->ini->readVariable(
'system',
'ROOT_FOLDER_ID'));
111 define(
"SYSTEM_FOLDER_ID", $this->ini->readVariable(
'system',
'SYSTEM_FOLDER_ID'));
112 define(
"ROLE_FOLDER_ID", $this->ini->readVariable(
'system',
'ROLE_FOLDER_ID'));
113 define(
"ANONYMOUS_USER_ID", 13);
114 define(
"ANONYMOUS_ROLE_ID", 14);
115 define(
"SYSTEM_USER_ID", 6);
116 define(
"SYSTEM_ROLE_ID", 2);
118 $this->db_exists = $this->
getDBSetup()->isConnectable();
120 if ($this->db_exists) {
121 $this->db_installed = $this->
getDBSetup()->isDatabaseInstalled();
154 $this->
id = $a_client_id;
155 $this->webspace_dir = ILIAS_ABSOLUTE_PATH .
"/" . ILIAS_WEB_DIR .
"/" .
$this->id;
164 return $this->ini->readVariable(
"client",
"name");
173 $this->ini->setVariable(
"client",
"name", $a_str);
182 return $this->ini->readVariable(
"client",
"description");
191 $this->ini->setVariable(
"client",
"description", $a_str);
218 if (!$this->getdbHost() || !$this->getdbUser()) {
219 $this->error =
"empty_fields";
224 include_once(
"./Services/Database/classes/class.ilDBWrapperFactory.php");
225 $this->db = ilDBWrapperFactory::getWrapper($this->getdbType());
226 $this->db->setDBUser($this->getdbUser());
227 $this->db->setDBPort($this->getdbPort());
228 $this->db->setDBPassword($this->getdbPass());
229 $this->db->setDBHost($this->getdbHost());
230 $this->db->setDBName($this->getdbName());
231 $con = $this->db->connect(
true);
234 $this->error =
"Database connection failed.";
239 if (
$GLOBALS[
"DIC"]->offsetExists(
"ilDB")) {
240 $GLOBALS[
"DIC"]->offsetUnset(
"ilDB");
247 $this->db_exists =
true;
258 if (method_exists($a_db,
'loadModule')) {
259 $a_db->loadModule(
'Manager');
261 if (!$tables = $a_db->listTables()) {
266 if (in_array(
"object_data", $tables)
and in_array(
"object_reference", $tables)
and in_array(
"usr_data", $tables)
and in_array(
"rbac_ua", $tables)) {
267 $this->db_installed =
true;
270 $this->db_installed =
false;
282 if (trim($this->getdbPort()) !=
"") {
283 $db_port_str =
":" . $this->getdbPort();
285 $this->dsn_host =
"pgsql://" . $this->getdbUser() .
":" . $this->getdbPass() .
"@" . $this->getdbHost() . $db_port_str;
286 $this->dsn =
"pgsql://" . $this->getdbUser() .
":" . $this->getdbPass() .
"@" . $this->getdbHost() . $db_port_str .
"/" . $this->getdbName();
293 if (trim($this->getdbPort()) !=
"") {
294 $db_port_str =
":" . $this->getdbPort();
296 $this->dsn_host =
"mysql://" . $this->getdbUser() .
":" . $this->getdbPass() .
"@" . $this->getdbHost() . $db_port_str;
297 $this->dsn =
"mysql://" . $this->getdbUser() .
":" . $this->getdbPass() .
"@" . $this->getdbHost() . $db_port_str .
"/" . $this->getdbName();
308 $this->ini->setVariable(
"db",
"host", $a_str);
318 return $this->ini->readVariable(
"db",
"host");
327 $this->ini->setVariable(
"db",
"name", $a_str);
336 return $this->ini->readVariable(
"db",
"name");
345 $this->ini->setVariable(
"db",
"user", $a_str);
354 return $this->ini->readVariable(
"db",
"user");
363 return $this->ini->readVariable(
"db",
"port");
372 $this->ini->setVariable(
"db",
"port", $a_str);
381 $this->ini->setVariable(
"db",
"pass", $a_str);
390 return $this->ini->readVariable(
"db",
"pass");
399 $this->ini->setVariable(
"db",
"slave_active", (
int) $a_act);
409 return (
int) $this->ini->readVariable(
"db",
"slave_active");
418 $this->ini->setVariable(
"db",
"slave_host", $a_str);
428 return $this->ini->readVariable(
"db",
"slave_host");
437 $this->ini->setVariable(
"db",
"slave_name", $a_str);
446 return $this->ini->readVariable(
"db",
"slave_name");
455 $this->ini->setVariable(
"db",
"slave_user", $a_str);
464 return $this->ini->readVariable(
"db",
"slave_user");
473 return $this->ini->readVariable(
"db",
"slave_port");
482 $this->ini->setVariable(
"db",
"slave_port", $a_str);
491 $this->ini->setVariable(
"db",
"slave_pass", $a_str);
500 return $this->ini->readVariable(
"db",
"slave_pass");
509 $this->ini->setVariable(
"db",
"type", $a_str);
518 $val = $this->ini->readVariable(
"db",
"type");
532 return ILIAS_DATA_DIR .
"/" . $this->
getId();
541 return ILIAS_ABSOLUTE_PATH .
"/" . ILIAS_WEB_DIR .
"/" . $this->
getId();
554 $db = $this->db_connections->connectDB($this->dsn);
555 if (MDB2::isError(
$db)) {
564 if ($a_keep_connection) {
590 if (!$this->
getDBSetup()->isDatabaseInstalled() || !$ilDB) {
593 include_once
'./Services/Administration/classes/class.ilSetting.php';
596 return $set->get($a_keyword);
606 include_once
'./Services/Administration/classes/class.ilSetting.php';
608 return $set->getAll();
620 include_once
'./Services/Administration/classes/class.ilSetting.php';
622 $set->set($a_key, $a_val);
633 $inst_id = (empty($settings[
"inst_id"])) ?
"0" : $settings[
"inst_id"];
640 "&inst_id=" . rawurlencode($inst_id) .
641 "&hostname=" . rawurlencode(
$_SERVER[
"SERVER_NAME"]) .
642 "&inst_name=" . rawurlencode($this->ini->readVariable(
"client",
"name")) .
643 "&inst_info=" . rawurlencode($this->ini->readVariable(
"client",
"description")) .
644 "&http_path=" . rawurlencode(ILIAS_HTTP_PATH) .
645 "&contact_firstname=" . rawurlencode($settings[
"admin_firstname"]) .
646 "&contact_lastname=" . rawurlencode($settings[
"admin_lastname"]) .
647 "&contact_email=" . rawurlencode($settings[
"admin_email"]) .
648 "&nic_key=" . rawurlencode($this->
getNICkey());
672 require_once(__DIR__ .
"/../../Services/WebServices/Curl/classes/class.ilCurlConnection.php");
674 $this->
setError(
"CURL-extension not loaded.");
683 if ((
bool) $settings[
'proxy_status'] && strlen($settings[
'proxy_host']) && strlen($settings[
'proxy_port'])) {
684 $req->setOpt(CURLOPT_HTTPPROXYTUNNEL,
true);
685 $req->setOpt(CURLOPT_PROXY, $settings[
"proxy_host"]);
686 $req->setOpt(CURLOPT_PROXYPORT, $settings[
"proxy_port"]);
689 $req->setOpt(CURLOPT_HEADER, 1);
690 $req->setOpt(CURLOPT_RETURNTRANSFER, 1);
691 $req->setOpt(CURLOPT_CONNECTTIMEOUT, $socket_timeout);
692 $req->setOpt(CURLOPT_MAXREDIRS, $max_redirects);
696 $response_body =
$req->getResponseBody();
699 if (
$info[
"http_code"] !=
"200") {
700 $this->
setError(
"Could not connect to NIC-Server at '" .
$url .
"'");
704 $this->nic_status = explode(
"\n", $response_body);
721 mt_srand((
double) microtime() * 1000000);
722 $nic_key = md5(str_replace(
".",
"",
$_SERVER[
"SERVER_ADDR"]) +
723 mt_rand(100000, 999999));
727 $this->nic_key = $nic_key;
739 $this->nic_key = $this->
getSetting(
"nic_key");
741 if (empty($this->nic_key)) {
745 return $this->nic_key;
756 $this->ini->setVariable(
"language",
"default", $a_lang_key);
782 $this->error = $error_message;
793 public function delete($a_ini =
true, $a_db =
false, $a_files =
false)
795 if ($a_ini ===
true and file_exists(ILIAS_ABSOLUTE_PATH .
"/" . ILIAS_WEB_DIR .
"/" . $this->
getId() .
"/client.ini.php")) {
796 unlink(CLIENT_WEB_DIR .
"/client.ini.php");
797 $msg[] =
"ini_deleted";
800 if ($a_db ===
true and $this->db_exists) {
801 $this->db->query(
"DROP DATABASE " . $this->
getDbName());
802 $msg[] =
"db_deleted";
805 if ($a_files ===
true and file_exists(CLIENT_WEB_DIR)
and is_dir(CLIENT_WEB_DIR)) {
809 $msg[] =
"files_deleted";
824 $this->error =
"could_not_create_base_data_dir :" . $this->
getDataDir();
830 $this->error =
"could_not_create_mail_data_dir :" . $this->
getDataDir() .
"/mail";
835 $this->error =
"could_not_create_lm_data_dir :" . $this->
getDataDir() .
"/lm_data";
840 $this->error =
"could_not_create_forum_data_dir :" . $this->
getDataDir() .
"/forum";
845 $this->error =
"could_not_create_files_data_dir :" . $this->
getDataDir() .
"/files";
851 $this->error =
"could_not_create_base_webspace_dir :" . $this->
getWebspaceDir();
857 $this->error =
"could_not_create_lm_webspace_dir :" . $this->
getWebspaceDir() .
"/lm_data";
862 $this->error =
"could_not_create_usr_images_webspace_dir :" . $this->
getWebspaceDir() .
"/usr_images";
867 $this->error =
"could_not_create_mobs_webspace_dir :" . $this->
getWebspaceDir() .
"/mobs";
872 $this->error =
"could_not_create_css_webspace_dir :" . $this->
getWebspaceDir() .
"/css";
877 if (!$this->ini->write()) {
878 $this->error = get_class($this) .
": " . $this->ini->getError();
setDSN()
set the dsn and dsn_host
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
getDbSlaveName()
get name of slave database
setDescription($a_str)
set client description
isInstalledDB(&$a_db)
check if client db is installed
setDbHost($a_str)
set the host
setSetting($a_key, $a_val)
write one value to settings table public
getDbPass()
get db password
setName($a_str)
set client name
getDbName()
get name of database
__construct($a_client_id, $a_db_connections)
ilClient constructor.
setDbType($a_str)
set the type of database
getDbSlaveHost()
get db slave host
connect()
connect to client database
getError()
get error message and clear error var
setDefaultLanguage($a_lang_key)
setId($a_client_id)
set client id
getNICkey()
get nic_key public
setDbUser($a_str)
set db user
getDescription()
get client description
setDbName($a_str)
set the name of database
setDbPass($a_str)
set db password
setNICkey()
set nic_key generate nic_key if nic_key field in cust table is empty.
checkDatabaseExists($a_keep_connection=false)
check database connection with database name
getURLStringForNIC($a_nic_url)
static getNewInstanceForClient(\ilClient $client)
getDbSlavePort()
get slave db port
init()
init client load client.ini and set some constants
setDbSlavePass($a_str)
set slave db password
setDbSlaveUser($a_str)
set slave db user
setDbSlaveName($a_str)
set the name of slave database
static _isCurlExtensionLoaded()
Check if curl extension is loaded.
setDbSlaveActive($a_act)
set the slave active
getDbSlaveActive()
get slave active
getDbSlaveUser()
get slave db user
getAllSettings()
read all values from settings table public
getDbType()
get type of database
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
setDbSlaveHost($a_str)
set the slave host
getDataDir()
get client datadir path
getWebspaceDir()
get client webspacedir path
setDbPort($a_str)
set db port
getSetting($a_keyword)
read one value from settings table
static getLogger($a_component_id)
Get component logger.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
create()
create a new client and its subdirectories
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
getDbSlavePass()
get slave db password
updateNIC($a_nic_url)
Connect to ILIAS-NIC.
setDbSlavePort($a_str)
set slave db port