/**
  * connect to client database
  * @return	boolean	true on success
  */
 function connect()
 {
     // check parameters
     // To support oracle tnsnames.ora dbname is not required
     if (!$this->getdbHost() || !$this->getdbUser()) {
         $this->error = "empty_fields";
         return false;
     }
     /*
     if (!$this->getdbHost() || !$this->getdbName() || !$this->getdbUser())
     {
     	$this->error = "empty_fields";
     	return false;
     }
     */
     include_once "./Services/Database/classes/class.ilDBWrapperFactory.php";
     $this->db = ilDBWrapperFactory::getWrapper($this->getdbType(), $this->ini->readVariable("db", "inactive_mysqli"));
     $this->db->setDBUser($this->getdbUser());
     $this->db->setDBPort($this->getdbPort());
     $this->db->setDBPassword($this->getdbPass());
     $this->db->setDBHost($this->getdbHost());
     $this->db->setDBName($this->getdbName());
     $con = $this->db->connect(true);
     if (!$con) {
         $this->error = "Database connection failed.";
         return false;
     }
     $GLOBALS["ilDB"] = $this->db;
     $this->db_exists = true;
     return true;
 }
 /**
  * initialise database object $ilDB
  *
  */
 protected static function initDatabase()
 {
     // build dsn of database connection and connect
     require_once "./Services/Database/classes/class.ilDBWrapperFactory.php";
     $ilDB = ilDBWrapperFactory::getWrapper(IL_DB_TYPE);
     $ilDB->initFromIniFile();
     $ilDB->connect();
     self::initGlobal("ilDB", $ilDB);
 }
 function __buildAuth()
 {
     if (!is_object($this->db)) {
         require_once "./Services/Database/classes/class.ilDBWrapperFactory.php";
         $ilDB = ilDBWrapperFactory::getWrapper();
         $ilDB->initFromIniFile();
         $ilDB->connect();
         $this->db = $ilDB;
     }
     $GLOBALS["ilDB"] = $this->db;
     $this->init->initSettings();
     $this->init->buildHTTPPath();
     include_once './Services/Administration/classes/class.ilSetting.php';
     $set = new ilSetting();
     /*$query = "SELECT * FROM sett ings WHERE ".
     			" keyword = ".$this->db->quote("cas_server")." OR ".
     			" keyword = ".$this->db->quote("cas_port")." OR ".
     			" keyword = ".$this->db->quote("cas_uri");
     		$res = $this->db->query($query);
     		$cas_set = array();
     		while ($rec = $res->fetchRow(DB_FETCHMODE_ASSOC))
     		{
     			$cas_set[$rec["keyword"]] = $rec["value"];
     		}*/
     $cas_set["cas_server"] = $set->get("cas_server");
     $cas_set["cas_port"] = $set->get("cas_port");
     $cas_set["cas_uri"] = $set->get("cas_uri");
     $auth_params = array("server_version" => CAS_VERSION_2_0, "server_hostname" => $cas_set["cas_server"], "server_port" => $cas_set["cas_port"], "server_uri" => $cas_set["cas_uri"]);
     include_once "Services/CAS/classes/class.ilCASAuth.php";
     $this->auth = new ilCASAuth($auth_params);
     // HTTP path will return full path to server.php directory
     phpCAS::setFixedServiceURL(ILIAS_HTTP_PATH . "/webservice/soap/server.php");
     return true;
 }
 /**
  * initialise database object $ilDB
  *
  */
 function initDatabase()
 {
     global $ilDB, $ilClientIniFile;
     // build dsn of database connection and connect
     require_once "./Services/Database/classes/class.ilDBWrapperFactory.php";
     $ilDB = ilDBWrapperFactory::getWrapper(IL_DB_TYPE);
     $ilDB->initFromIniFile();
     $ilDB->connect();
     $GLOBALS['ilDB'] = $ilDB;
 }
 private function getClientInfo($init, $client_dir)
 {
     global $ilDB;
     $ini_file = "./" . $client_dir . "/client.ini.php";
     // get settings from ini file
     require_once "./Services/Init/classes/class.ilIniFile.php";
     $ilClientIniFile = new ilIniFile($ini_file);
     $ilClientIniFile->read();
     if ($ilClientIniFile->ERROR != "") {
         return false;
     }
     $client_id = $ilClientIniFile->readVariable('client', 'name');
     if ($ilClientIniFile->variableExists('client', 'expose')) {
         $client_expose = $ilClientIniFile->readVariable('client', 'expose');
         if ($client_expose == "0") {
             return false;
         }
     }
     // build dsn of database connection and connect
     require_once "./Services/Database/classes/class.ilDBWrapperFactory.php";
     $ilDB = ilDBWrapperFactory::getWrapper($ilClientIniFile->readVariable("db", "type"), $ilClientIniFile->readVariable("db", "inactive_mysqli"));
     $ilDB->initFromIniFile($ilClientIniFile);
     if ($ilDB->connect(true)) {
         $GLOBALS['ilDB'] = $ilDB;
         require_once "Services/Administration/classes/class.ilSetting.php";
         $settings = new ilSetting();
         $GLOBALS["ilSetting"] = $settings;
         // workaround to determine http path of client
         define("IL_INST_ID", $settings->get("inst_id", 0));
         $settings->access = $ilClientIniFile->readVariable("client", "access");
         $settings->description = $ilClientIniFile->readVariable("client", "description");
         $settings->session = min((int) ini_get("session.gc_maxlifetime"), (int) $ilClientIniFile->readVariable("session", "expire"));
         $settings->language = $ilClientIniFile->readVariable("language", "default");
         $settings->clientid = basename($client_dir);
         //pathinfo($client_dir, PATHINFO_FILENAME);
         $settings->default_show_users_online = $settings->get("show_users_online");
         $settings->default_hits_per_page = $settings->get("hits_per_page");
         $skin = $ilClientIniFile->readVariable("layout", "skin");
         $style = $ilClientIniFile->readVariable("layout", "style");
         $settings->default_skin_style = $skin . ":" . $style;
         return $settings;
     }
     return null;
 }
 function __buildDSN()
 {
     include_once './Services/Init/classes/class.ilIniFile.php';
     // get ilias ini file
     $this->ilias_ini =& new ilIniFile('./ilias.ini.php');
     $this->ilias_ini->read();
     if (!@file_exists("./" . $this->ilias_ini->readVariable('clients', 'path') . "/" . $this->getClient() . "/client.ini.php")) {
         $this->__setMessageCode('Client');
         $this->__setMessage('Client does not exist');
         return false;
     }
     $this->ini =& new ilIniFile("./" . $this->ilias_ini->readVariable('clients', 'path') . "/" . $this->getClient() . "/client.ini.php");
     $this->ini->read();
     include_once "./Services/Database/classes/class.ilDBWrapperFactory.php";
     $this->db = ilDBWrapperFactory::getWrapper($this->ini->readVariable("db", "type"), $this->ini->readVariable("db", "inactive_mysqli"));
     $this->db->setDBUser($this->ini->readVariable("db", "user"));
     $this->db->setDBPassword($this->ini->readVariable("db", "pass"));
     $this->db->setDBName($this->ini->readVariable("db", "name"));
     $this->db->setDBHost($this->ini->readVariable("db", "host"));
     $this->dsn = $this->db->getDSN();
     return true;
 }