ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilSetup.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./setup/classes/class.ilDBConnections.php");
5 
15 class ilSetup extends PEAR
16 {
17  var $ini; // ini file object
18  var $ini_file_path; // full path to setup.ini, containing the client list
19  var $error = ""; // error text
20 
21  var $ini_ilias_exists = false; // control flag ilias.ini
22  var $ini_client_exists = false; // control flag client.ini
23 
24  var $setup_defaults; // ilias.master.ini
25  var $ilias_nic_server = "http://www.ilias.de/ilias-nic/index.php"; // URL to ilias nic server
26 
27  var $preliminaries_result = array(); // preliminaries check results
28  var $preliminaries = true; //
29 
35  var $SQL_FILE = "./setup/sql/ilias3.sql";
36 
42  var $dsn = "";
43 
49  var $db;
50 
51  var $setup_password; // master setup password
52  var $default_client; // client id of default client
53 
54  var $safe_mode; // safe mode enabled (true) or disabled (false)
55  var $safe_mode_exec_dir; // contains exec_dir_path
56 
57  var $auth; // current user is authenticated? (true)
58  var $access_mode; // if "admin", admin functions are enabled
59 
60 
67  function ilSetup($a_auth,$a_auth_type)
68  {
69  global $log, $lng;
70 
71  $this->PEAR();
72  $this->lng = $lng;
73 
74  $this->db_connections = new ilDBConnections();
75 
76  define("ILIAS_MODULE","setup");
77 
78  $this->auth = ($a_auth) ? true : false;
79  $this->access_mode = $a_auth_type;
80 
81  // safe mode status & exec_dir
82  if ($this->safe_mode = ini_get("safe_mode"))
83  {
84  $this->safe_mode_exec_dir = ilFile::deleteTrailingSlash(ini_get("safe_mode_exec_dir"));
85  }
86 
87  // Error Handling
88  $this->error_obj = new ilErrorHandling();
89  $this->setErrorHandling(PEAR_ERROR_CALLBACK,array($this->error_obj,'errorHandler'));
90 
91  // set path to ilias.ini
92  $this->ini_file_path = ILIAS_ABSOLUTE_PATH."/ilias.ini.php";
93  $this->setup_defaults = ILIAS_ABSOLUTE_PATH."/setup/ilias.master.ini.php";
94 
95  // init setup.ini
96  $this->ini_ilias_exists = $this->init();
97 
98  if ($this->ini_ilias_exists)
99  {
100  if ($this->ini->readVariable("log","path") != "")
101  {
102  $log->path = $this->ini->readVariable("log","path");
103  }
104 
105  if ($this->ini->readVariable("log","file") != "")
106  {
107  $log->filename = $this->ini->readVariable("log","file");
108  }
109 
110  if ($this->ini->readVariable("log","enabled") != "")
111  {
112  $log->enabled = $this->ini->readVariable("log","enabled");
113  }
114  }
115  }
116 
122  function setClient($a_cl)
123  {
124  $this->client = $a_cl;
125  }
126 
132  function getClient()
133  {
134  return $this->client;
135  }
136 
142  function init()
143  {
144  // load data from setup.ini file
145  $this->ini = new ilIniFile($this->ini_file_path);
146 
147  if (!$this->ini->read())
148  {
149  $this->ini->GROUPS = parse_ini_file($this->setup_defaults,true);
150  $this->error = get_class($this).": ".$this->ini->getError();
151  return false;
152  }
153 
154  $this->setup_password = $this->ini->readVariable("setup","pass");
155  $this->default_client = $this->ini->readVariable("clients","default");
156 
157  define("ILIAS_DATA_DIR",$this->ini->readVariable("clients","datadir"));
158  define("ILIAS_WEB_DIR",$this->ini->readVariable("clients","path"));
159 
160  return true;
161  }
162 
167  function saveNewClient()
168  {
169  // save client id to session
170  $_SESSION["ClientId"] = $this->client->getId();
171 
172  // create client
173  if (!$this->client->create())
174  {
175  $this->error = $this->client->getError();
176  return false;
177  }
178 
179  //everything okay
180  $this->ini_client_exists = true;
181 
182  return true;
183  }
184 
190  function updateNewClient($a_old_client_id)
191  {
192  return true;
193  //var_dump("<pre>",$this->client,"</pre>");exit;
194 
195  if ($a_old_client_id != $this->client->getId())
196  {
197  // check for existing client dir
198  if (file_exists(ILIAS_ABSOLUTE_PATH."/".ILIAS_WEB_DIR."/".$this->client->getId()))
199  {
200  $this->raiseError($this->lng->txt("client_id_already_exists"),$this->error_obj->MESSAGE);
201  }
202 
203  if (!$this->saveNewClient())
204  {
205  $this->raiseError($this->lng->txt("save_error"),$this->error_obj->MESSAGE);
206  }
207 
208  ilUtil::delDir(ILIAS_ABSOLUTE_PATH."/".ILIAS_WEB_DIR."/".$a_old_client_id);
209  ilUtil::delDir(ILIAS_DATA_DIR."/".$a_old_client_id);
210  }
211 
212  //everything okay
213  $this->ini_client_exists = true;
214 
215  return true;
216  }
217 
222  function createDatabase($a_collation = "")
223  {
224  if ($this->client->checkDatabaseExists())
225  {
226  $this->error = $this->lng->txt("database_exists");
227  return false;
228  }
229 
230  $this->client->getDB()->connectHost(true);
231 
232  //create database
233  $db = $this->client->getDB();
234  if (MDB2::isError($db))
235  {
236  $this->error = "connection_failed";
237  return false;
238  }
239 
240  $r = $db->createDatabase($this->client->getdbName(),
241  "utf8", $a_collation);
242 
243  if (MDB2::isError($r))
244  {
245  $this->error = "create_database_failed";
246  return false;
247  }
248 
249  //database is created, now disconnect and reconnect
250  $db->disconnect();
251 
252  $this->client->db_exists = true;
253  return true;
254  }
255 
260  function installDatabase()
261  {
262 /* if (!$this->client->checkDatabaseHost())
263  {
264  $this->error = "no_connection_to_host";
265  return false;
266  }*/
267 
268  if (!$this->client->connect())
269  {
270  return false;
271  }
272 
273  //take sql dump an put it in
274  if ($this->readDump($this->client->db, $this->SQL_FILE))
275  {
276  $this->client->db_installed = true;
277  return true;
278  }
279  else
280  {
281  return false;
282  }
283  }
284 
285  function getline( $fp, $delim )
286  {
287  $result = "";
288  while( !feof( $fp ) )
289  {
290  $tmp = fgetc( $fp );
291  if( $tmp == $delim )
292  return $result;
293  $result .= $tmp;
294  }
295  return $result;
296  }
297 
304  function readDump($db, $file)
305  {
306  // mysql (old procedure)
307  if ($db->getDBType() == "mysql")
308  {
309  $fp = fopen($file, 'r');
310 
311  while(!feof($fp))
312  {
313  //$line = trim(fgets($fp, 200000));
314  $line = trim($this->getline($fp, "\n"));
315 
316  if ($line != "" && substr($line,0,1)!="#"
317  && substr($line,0,1)!="-")
318  {
319  //take line per line, until last char is ";"
320  if (substr($line,-1)==";")
321  {
322  //query is complete
323  $q .= " ".substr($line,0,-1);
324  $r = $db->query($q);
325  if (mysql_errno() > 0)
326  {
327  echo "<br />ERROR: ".mysql_error().
328  "<br />SQL: $q";
329  return false;
330  }
331  unset($q);
332  unset($line);
333  } //if
334  else
335  {
336  $q .= " ".$line;
337  } //else
338  } //if
339  } //for
340 
341  fclose($fp);
342  }
343 
344  #echo 'Start Memory: '.memory_get_usage().' peak: '.memory_get_peak_usage();
345  if ($db->getDBType() == "oracle")
346  {
347  if(@is_dir('./setup/sql/ilDBTemplate'))
348  {
349  include_once './Services/Database/classes/class.ilArrayTableDataParser.php';
350  include_once './classes/class.ilSaxParserException.php';
351  $reader = new tmpDirectoyIterator('./setup/sql/ilDBTemplate');
352  foreach($reader as $file)
353  {
354  eval(file_get_contents('./setup/sql/ilDBTemplate/'.$file));
355  try
356  {
357  $parser = new ilArrayTableDataParser('./setup/sql/ilDBTemplate/'.$file.'_inserts');
358  #$parser = new ilSimpleXMLTableDataParser('./setup/sql/ilDBTemplate/'.$file.'.xml');
359  $parser->startParsing();
360  #echo 'Table: '.$file.', memory: '.memory_get_peak_usage().' peak: '.memory_get_peak_usage().'<br />';flush();
361 
362  }
363  catch(ilSaxParserException $e)
364  {
365  die($e);
366  }
367  }
368  }
369  else
370  {
371  include_once("./setup/sql/ilDBTemplate.php");
372  setupILIASDatabase();
373  }
374  }
375  #echo 'Start Memory: '.memory_get_usage().' peak: '.memory_get_peak_usage();
376  return true;
377  }
378 
379 
385  {
386  $a = @file_exists($this->INI_FILE);
387  return $a;
388  }
389 
395  function checkWritable()
396  {
397  clearstatcache();
398  if (is_writable("."))
399  {
400  $arr["status"] = true;
401  //$cdir = getcwd();
402  //chdir("..");
403  $arr["comment"] = getcwd();
404  //chdir($cdir);
405  }
406  else
407  {
408  $arr["status"] = false;
409  $arr["comment"] = $this->lng->txt("pre_folder_write_error");
410  //$cdir = getcwd();
411  //chdir("..");
412  $arr["comment"] = getcwd().": ".$arr["comment"];
413  //chdir($cdir);
414  }
415 
416  return $arr;
417  }
418 
424  function checkCreatable($a_dir = ".")
425  {
426  clearstatcache();
427  if (@mkdir($a_dir."/crst879dldsk9d", 0774))
428  {
429  $arr["status"] = true;
430  $arr["comment"] = "";
431 
432  @rmdir($a_dir."/crst879dldsk9d");
433  }
434  else
435  {
436  $arr["status"] = false;
437  //$cdir = getcwd();
438  //chdir("..");
439  $arr["comment"] = getcwd().": ".$this->lng->txt("pre_folder_create_error");
440  //chdir($cdir);
441  }
442 
443  return $arr;
444  }
445 
451  {
452  global $sess;
453 
454  if ($sess->usesCookies)
455  {
456  $arr["status"] = true;
457  $arr["comment"] = "";
458  }
459  else
460  {
461  $arr["status"] = false;
462  $arr["comment"] = $this->lng->txt("pre_cookies_disabled");
463  }
464 
465  return $arr;
466  }
467 
472  function checkPHPVersion()
473  {
474  $version = PHP_VERSION;
475 
476  $arr["status"] = true;
477  $arr["comment"] = "PHP ".$version;
478  if (version_compare($version, '5.2.6', '<'))
479  {
480  $arr["status"] = false;
481  $arr["comment"] = "PHP ".$version.". ".$this->lng->txt("pre_php_version_too_low");
482  }
483 
484  return $arr;
485  }
486 
491  function checkMySQL()
492  {
493  global $ilDB;
494 
495  if (function_exists("mysql_query"))
496  {
497  $arr["status"] = true;
498  $arr["comment"] = $this->lng->txt("pre_mysql_4_1_or_higher");
499  }
500  else
501  {
502  $arr["status"] = false;
503  $arr["comment"] = $this->lng->txt("pre_mysql_missing");
504  }
505 
506  return $arr;
507  }
508 
513  function checkAuth()
514  {
515  if ($_SESSION["auth"] === true)
516  {
517  return true;
518  }
519 
520  return false;
521  }
522 
523 
528  function checkDom()
529  {
530  global $ilDB;
531 
532  if (class_exists("DOMDocument"))
533  {
534  $arr["status"] = true;
535  }
536  else
537  {
538  $arr["status"] = false;
539  $arr["comment"] = $this->lng->txt("pre_dom_missing");
540  }
541 
542  return $arr;
543  }
544 
549  function checkXsl()
550  {
551  global $ilDB;
552 
553  if (class_exists("XSLTProcessor"))
554  {
555  $arr["status"] = true;
556  }
557  else
558  {
559  $arr["status"] = false;
560  $arr["comment"] = sprintf($this->lng->txt("pre_xsl_missing"),
561  "http://php.net/manual/en/book.xsl.php");
562  }
563 
564  return $arr;
565  }
566 
571  function checkGd()
572  {
573  global $ilDB;
574 
575  if (function_exists("imagefill") && function_exists("imagecolorallocate"))
576  {
577  $arr["status"] = true;
578  }
579  else
580  {
581  $arr["status"] = false;
582  $arr["comment"] = sprintf($this->lng->txt("pre_gd_missing"),
583  "http://php.net/manual/en/book.image.php");
584  }
585 
586  return $arr;
587  }
588 
593  function checkMemoryLimit()
594  {
595  global $ilDB;
596 
597  $limit = ini_get("memory_limit");
598 
599  $limit_ok = true;
600  if (is_int(strpos($limit, "M")))
601  {
602  $limit_n = (int) $limit;
603  if ($limit_n < 40)
604  {
605  $limit_ok = false;
606  }
607  }
608 
609  if ($limit_ok)
610  {
611  $arr["status"] = true;
612  $arr["comment"] = $limit.". ".$this->lng->txt("pre_memory_limit_recommend");
613  }
614  else
615  {
616  $arr["status"] = false;
617  $arr["comment"] = $limit.". ".$this->lng->txt("pre_memory_limit_too_low");
618  }
619 
620  return $arr;
621  }
622 
631  {
632  $a = array();
633  $a["php"] = $this->checkPHPVersion();
634 // $a["mysql"] = $this->checkMySQL();
635  $a["root"] = $this->checkWritable();
636  $a["folder_create"] = $this->checkCreatable();
637  $a["cookies_enabled"] = $this->checkCookiesEnabled();
638  $a["dom"] = $this->checkDom();
639  $a["xsl"] = $this->checkXsl();
640  $a["gd"] = $this->checkGd();
641  $a["memory"] = $this->checkMemoryLimit();
642 
643  return $a;
644  }
645 
651  {
652  $this->preliminaries_result = $this->queryPreliminaries();
653 
654  foreach ($this->preliminaries_result as $val)
655  {
656  if ($val["status"] === false)
657  {
658  $this->preliminaries = false;
659  return false;
660  }
661  }
662 
663  return true;
664  }
665 
670  function getPassword ()
671  {
672  return $this->ini->readVariable("setup","pass");
673  }
674 
680  function setPassword ($a_password)
681  {
682  $this->ini->setVariable("setup","pass",md5($a_password));
683 
684  if ($this->ini->write() == false)
685  {
686  $this->error = $this->ini->getError();
687  return false;
688  }
689 
690  return true;
691  }
692 
698  function loginAsClient($a_auth_data)
699  {
700  global $ilDB;
701 
702  if (empty($a_auth_data["client_id"]))
703  {
704  $this->error = "no_client_id";
705  return false;
706  }
707 
708  if (empty($a_auth_data["username"]))
709  {
710  $this->error = "no_username";
711  return false;
712  }
713 
714  if (empty($a_auth_data["password"]))
715  {
716  $this->error = "no_password";
717  return false;
718  }
719 
720  if (!$this->newClient($a_auth_data["client_id"]))
721  {
722  $this->error = "unknown_client_id";
723  unset($this->client);
724  return false;
725  }
726 
727  if (!$this->client->db_exists)
728  {
729  $this->error = "no_db_connect_consult_admin";
730  unset($this->client);
731  return false;
732  }
733 
734  $s1 = $this->client->db->query("SELECT value from settings WHERE keyword = ".
735  $this->client->db->quote('system_role_id','text'));
736  $r1 = $this->client->db->fetchAssoc($s1);
737  $system_role_id = $r1["value"];
738  $q = "SELECT usr_data.usr_id FROM usr_data ".
739  "LEFT JOIN rbac_ua ON rbac_ua.usr_id=usr_data.usr_id ".
740  "WHERE rbac_ua.rol_id = ".$this->client->db->quote((int) $system_role_id,'integer')." ".
741  "AND usr_data.login=".$this->client->db->quote($a_auth_data["username"],'text')." ".
742  "AND usr_data.passwd=".$this->client->db->quote(md5($a_auth_data["password"]),'text');
743 
744  $r = $this->client->db->query($q);
745 
746  if (!$r->numRows())
747  {
748  $this->error = "login_invalid";
749  return false;
750  }
751 
752  // all checks passed -> user valid
753  $_SESSION["auth"] = true;
754  $_SESSION["access_mode"] = "client";
755  $_SESSION["ClientId"] = $this->client->getId();
756  return true;
757  }
758 
764  function loginAsAdmin($a_password)
765  {
766  $a_password = md5($a_password);
767 
768  if ($this->ini->readVariable("setup","pass") == $a_password)
769  {
770  $_SESSION["auth"] = true;
771  $_SESSION["access_mode"] = "admin";
772  return true;
773  }
774 
775  return false;
776  }
777 
783  function newClient($a_client_id = 0)
784  {
785  if (!$this->isInstalled())
786  {
787  return false;
788  }
789 
790  $this->client = new ilClient($a_client_id, $this->db_connections);
791 
792  if (!$this->client->init())
793  {
794 //echo "<br>noclientinit";
795  $this->error = get_class($this).": ".$this->client->getError();
796  $_SESSION["ClientId"] = "";
797  return false;
798  }
799 
800  $_SESSION["ClientId"] = $a_client_id;
801 
802  return true;
803  }
804 
810  function getStatus ($client = 0)
811  {
812  if (!is_object($client))
813  {
814  if ($this->ini_client_exists)
815  {
817  }
818  else
819  {
820  $client = new ilClient(0, $this->db_connections);
821  }
822  }
823 
824  $status = array();
825  $status["ini"] = $this->checkClientIni($client); // check this one
826  $status["db"] = $this->checkClientDatabase($client);
827  if ($status["db"]["status"] === false and $status["db"]["update"] !== true)
828  {
829  //$status["sess"]["status"] = false;
830  //$status["sess"]["comment"] = $status["db"]["comment"];
831  $status["lang"]["status"] = false;
832  $status["lang"]["comment"] = $status["db"]["comment"];
833  $status["contact"]["status"] = false;
834  $status["contact"]["comment"] = $status["db"]["comment"];
835  $status["nic"]["status"] = false;
836  $status["nic"]["comment"] = $status["db"]["comment"];
837  }
838  else
839  {
840  //$status["sess"] = $this->checkClientSessionSettings($client);
841  $status["lang"] = $this->checkClientLanguages($client);
842  $status["contact"] = $this->checkClientContact($client);
843  $status["nic"] = $this->checkClientNIC($client);
844  $status["finish"] = $this->checkFinish($client);
845  $status["access"] = $this->checkAccess($client);
846  }
847 
848  //return value
849  return $status;
850  }
851 
857  function checkFinish(&$client)
858  {
859  if ($client->getSetting("setup_ok"))
860  {
861  $arr["status"] = true;
862  //$arr["comment"] = $this->lng->txt("setup_finished");
863  }
864  else
865  {
866  $arr["status"] = false;
867  $arr["comment"] = $this->lng->txt("setup_not_finished");
868  }
869 
870  return $arr;
871  }
872 
878  function checkAccess(&$client)
879  {
880  if ($client->ini->readVariable("client","access") == "1")
881  {
882  $arr["status"] = true;
883  $arr["comment"] = $this->lng->txt("online");
884  }
885  else
886  {
887  $arr["status"] = false;
888  $arr["comment"] = $this->lng->txt("disabled");
889  }
890 
891  return $arr;
892  }
893 
900  {
901  if (!$arr["status"] = $client->init())
902  {
903  $arr["comment"] = $client->getError();
904  }
905  else
906  {
907  //$arr["comment"] = "dir: /".ILIAS_WEB_DIR."/".$client->getId();
908  }
909 
910  return $arr;
911  }
912 
919  {
920  if (!$arr["status"] = $client->db_exists)
921  {
922  $arr["comment"] = $this->lng->txt("no_database");
923  return $arr;
924  }
925 
926  if (!$arr["status"] = $client->db_installed)
927  {
928  $arr["comment"] = $this->lng->txt("db_not_installed");
929  return $arr;
930  }
931 
932  // TODO: move this to client class!!
933  $client->setup_ok = (bool) $client->getSetting("setup_ok");
934 
935  //$this->lng->setDbHandler($client->db);
936  include_once "./Services/Database/classes/class.ilDBUpdate.php";
937  $ilDB = $client->db;
938  $this->lng->setDbHandler($client->db);
939  $dbupdate = new ilDBUpdate($client->db);
940 
941  if (!$arr["status"] = $dbupdate->getDBVersionStatus())
942  {
943  $arr["comment"] = $this->lng->txt("db_needs_update");
944  $arr["update"] = true;
945  return $arr;
946  }
947  else if ($dbupdate->hotfixAvailable())
948  {
949  $arr["status"] = false;
950  $arr["comment"] = $this->lng->txt("hotfix_available");
951  $arr["update"] = true;
952  return $arr;
953  }
954 
955  // check control information
956 
957  $cset = $ilDB->query("SELECT count(*) as cnt FROM ctrl_calls");
958  $crec = $ilDB->fetchAssoc($cset);
959  if ($crec["cnt"] == 0)
960  {
961  $arr["status"] = false;
962  $arr["comment"] = $this->lng->txt("db_control_structure_missing");
963  $arr["update"] = true;
964  return $arr;
965  }
966 
967  //$arr["comment"] = "version ".$dbupdate->getCurrentVersion();
968  return $arr;
969  }
970 
976  function checkClientSessionSettings(&$client, $a_as_bool = false)
977  {
978  require_once('Services/Authentication/classes/class.ilSessionControl.php');
979 
980  global $ilDB;
981  $db = $ilDB;
982 
984 
985  $query = "SELECT keyword, value FROM settings WHERE ".$db->in('keyword', $fields, false, 'text');
986  $res = $db->query($query);
987 
988  $rows = array();
989  while($row = $res->fetchRow(DB_FETCHMODE_ASSOC))
990  {
991  if( $row['value'] != '' )
992  $rows[] = $row;
993  else break;
994  }
995 
996  if (count($rows) != count($fields))
997  {
998  if($a_as_bool) return false;
999  $arr["status"] = false;
1000  $arr["comment"] = $this->lng->txt("session_management_not_configured");
1001  }
1002  else
1003  {
1004  if($a_as_bool) return true;
1005  $arr["status"] = true;
1006  $arr["comment"] = $this->lng->txt("session_management_configured");
1007  }
1008 
1009  return $arr;
1010  }
1011 
1018  {
1019  $installed_langs = $this->lng->getInstalledLanguages();
1020 
1021  $count = count($installed_langs);
1022 
1023  if ($count < 1)
1024  {
1025  $arr["status"] = false;
1026  $arr["comment"] = $this->lng->txt("lang_none_installed");
1027  }
1028  else
1029  {
1030  $arr["status"] = true;
1031  //$arr["comment"] = $count." ".$this->lng->txt("languages_installed");
1032  }
1033 
1034  return $arr;
1035  }
1036 
1043  {
1044  $arr["status"] = true;
1045  //$arr["comment"] = $this->lng->txt("filled_out");
1046 
1047  $settings = $client->getAllSettings();
1048  $client_name = $client->getName();
1049 
1050  // check required fields
1051  if (empty($settings["admin_firstname"]) or empty($settings["admin_lastname"]) or
1052  empty($settings["admin_email"]) or empty($client_name))
1053  {
1054  $arr["status"] = false;
1055  $arr["comment"] = $this->lng->txt("missing_data");
1056  }
1057 
1058  // admin email
1059  if (!ilUtil::is_email($settings["admin_email"]) and $arr["status"] != false)
1060  {
1061  $arr["status"] = false;
1062  $arr["comment"] = $this->lng->txt("email_not_valid");
1063  }
1064 
1065  return $arr;
1066  }
1067 
1074  {
1075  $settings = $client->getAllSettings();
1076 
1077  if (!isset($settings["nic_enabled"]))
1078  {
1079  $arr["status"] = false;
1080  $arr["comment"] = $this->lng->txt("nic_not_disabled");
1081  return $arr;
1082  }
1083 
1084  $arr["status"] = true;
1085 
1086  if ($settings["nic_enabled"] == "-1")
1087  {
1088  $arr["comment"] = $this->lng->txt("nic_reg_failed");
1089  return $arr;
1090  }
1091 
1092  if (!$settings["nic_enabled"])
1093  {
1094  $arr["comment"] = $this->lng->txt("nic_reg_disabled");
1095  }
1096  else
1097  {
1098  $arr["comment"] = $this->lng->txt("nic_reg_enabled");
1099  if ($settings["inst_id"] <= 0)
1100  {
1101  $arr["status"] = false;
1102  }
1103  }
1104 
1105  return $arr;
1106  }
1107 
1112  function isInstalled()
1113  {
1114  return $this->ini_ilias_exists;
1115  }
1116 
1121  function isAuthenticated()
1122  {
1123  return $this->auth;
1124  }
1125 
1130  function isAdmin()
1131  {
1132  return ($this->access_mode == "admin") ? true : false;
1133  }
1134 
1140  function saveMasterSetup($a_formdata)
1141  {
1142  $datadir_path = preg_replace("/\\\\/","/",ilFile::deleteTrailingSlash(ilUtil::stripSlashes($a_formdata["datadir_path"])));
1143 
1144  if ($a_formdata["chk_datadir_path"] == 1) // mode create dir
1145  {
1146  if (!ilUtil::makeDir($datadir_path))
1147  {
1148  $this->error = "create_datadir_failed";
1149  return false;
1150  }
1151  }
1152 
1153  // create webspace dir if it does not exist
1154  if (!@file_exists(ILIAS_ABSOLUTE_PATH."/".$this->ini->readVariable("clients","path")) and !@is_dir(ILIAS_ABSOLUTE_PATH."/".$this->ini->readVariable("clients","path")))
1155  {
1156  if (!ilUtil::makeDir(ILIAS_ABSOLUTE_PATH."/".$this->ini->readVariable("clients","path")))
1157  {
1158  $this->error = "create_webdir_failed";
1159  return false;
1160  }
1161  }
1162 
1163  $form_log_path = preg_replace("/\\\\/","/",ilFile::deleteTrailingSlash(ilUtil::stripSlashes($a_formdata["log_path"])));
1164  $log_path = substr($form_log_path,0,strrpos($form_log_path,"/"));
1165  $log_file = substr($form_log_path,strlen($log_path)+1);
1166 
1167  $this->ini->setVariable("server","http_path",ILIAS_HTTP_PATH);
1168  $this->ini->setVariable("server","absolute_path",ILIAS_ABSOLUTE_PATH);
1169  $this->ini->setVariable("server","timezone",preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["time_zone"])));
1170  $this->ini->setVariable("clients", "datadir", $datadir_path);
1171  $this->ini->setVariable("tools", "convert", preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["convert_path"])));
1172  $this->ini->setVariable("tools", "zip", preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["zip_path"])));
1173  $this->ini->setVariable("tools", "unzip", preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["unzip_path"])));
1174  $this->ini->setVariable("tools", "java", preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["java_path"])));
1175  $this->ini->setVariable("tools", "htmldoc", preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["htmldoc_path"])));
1176  $this->ini->setVariable("tools", "mkisofs", preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["mkisofs_path"])));
1177  $this->ini->setVariable("tools", "latex", ilUtil::stripSlashes($a_formdata["latex_url"]));
1178  $this->ini->setVariable("tools", "vscantype", preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["vscanner_type"])));
1179  $this->ini->setVariable("tools", "scancommand", preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["scan_command"])));
1180  $this->ini->setVariable("tools", "cleancommand", preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["clean_command"])));
1181  $this->ini->setVariable("setup", "pass", md5($a_formdata["setup_pass"]));
1182  $this->ini->setVariable("log", "path", $log_path);
1183  $this->ini->setVariable("log", "file", $log_file);
1184  $this->ini->setVariable("log", "enabled", ($a_formdata["chk_log_status"]) ? "0" : 1);
1185 
1186  if (!$this->ini->write())
1187  {
1188  $this->error = get_class($this).": ".$this->ini->getError();
1189  return false;
1190  }
1191 
1192  // everything is fine. so we authenticate the user and set access mode to 'admin'
1193  $_SESSION["auth"] = true;
1194  $_SESSION["access_mode"] = "admin";
1195 
1196  return true;
1197  }
1198 
1204  function updateMasterSettings($a_formdata)
1205  {
1206  $convert_path = preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["convert_path"]));
1207  $zip_path = preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["zip_path"]));
1208  $unzip_path = preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["unzip_path"]));
1209  $java_path = preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["java_path"]));
1210  $htmldoc_path = preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["htmldoc_path"]));
1211  $mkisofs_path = preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["mkisofs_path"]));
1212  $latex_url = ilUtil::stripSlashes($a_formdata["latex_url"]);
1213  $fop_path = preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["fop_path"]));
1214  $scan_type = preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["vscanner_type"]));
1215  $scan_command = preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["scan_command"]));
1216  $clean_command = preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["clean_command"]));
1217 
1218  $this->ini->setVariable("tools", "convert", $convert_path);
1219  $this->ini->setVariable("tools", "zip", $zip_path);
1220  $this->ini->setVariable("tools", "unzip", $unzip_path);
1221  $this->ini->setVariable("tools", "java", $java_path);
1222  $this->ini->setVariable("tools", "htmldoc", $htmldoc_path);
1223  $this->ini->setVariable("tools", "mkisofs", $mkisofs_path);
1224  $this->ini->setVariable("tools", "latex", $latex_url);
1225  $this->ini->setVariable("tools", "fop", $fop_path);
1226  $this->ini->setVariable("tools", "vscantype", $scan_type);
1227  $this->ini->setVariable("tools", "scancommand", $scan_command);
1228  $this->ini->setVariable("tools", "cleancommand", $clean_command);
1229 
1230  $form_log_path = preg_replace("/\\\\/","/",ilFile::deleteTrailingSlash(ilUtil::stripSlashes($a_formdata["log_path"])));
1231  $log_path = substr($form_log_path,0,strrpos($form_log_path,"/"));
1232  $log_file = substr($form_log_path,strlen($log_path)+1);
1233 
1234  $this->ini->setVariable("log", "path", $log_path);
1235  $this->ini->setVariable("log", "file", $log_file);
1236  $this->ini->setVariable("log", "enabled", ($a_formdata["chk_log_status"]) ? "0" : 1);
1237  $this->ini->setVariable("server","timezone",preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["time_zone"])));
1238 
1239  if (!$this->ini->write())
1240  {
1241  $this->error = get_class($this).": ".$this->ini->getError();
1242  return false;
1243  }
1244 
1245  return true;
1246  }
1247 
1253  function checkToolsSetup($a_formdata)
1254  {
1255  // convert path
1256  if (!isset($a_formdata["chk_convert_path"]))
1257  {
1258  // convert backslashes to forwardslashes
1259  $convert_path = preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["convert_path"]));
1260 
1261  if (($err = $this->testConvert($convert_path)) != "")
1262  {
1263  $this->error = $err;
1264  return false;
1265  }
1266  }
1267 
1268  // zip path
1269  if (!isset($a_formdata["chk_zip_path"]))
1270  {
1271  // convert backslashes to forwardslashes
1272  $zip_path = preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["zip_path"]));
1273 
1274  if (empty($zip_path))
1275  {
1276  $this->error = "no_path_zip";
1277  return false;
1278  }
1279 
1280  if (!$this->testZip($zip_path))
1281  {
1282  $this->error = "check_failed_zip";
1283  return false;
1284  }
1285  }
1286 
1287  // unzip path
1288  if (!isset($a_formdata["chk_unzip_path"]))
1289  {
1290  // convert backslashes to forwardslashes
1291  $unzip_path = preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["unzip_path"]));
1292 
1293  if (empty($unzip_path))
1294  {
1295  $this->error = "no_path_unzip";
1296  return false;
1297  }
1298 
1299  if (!$this->testUnzip($unzip_path))
1300  {
1301  $this->error = "check_failed_unzip";
1302  return false;
1303  }
1304  }
1305 
1306  // java path
1307  if (!isset($a_formdata["chk_java_path"]))
1308  {
1309  // convert backslashes to forwardslashes
1310  $java_path = preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["java_path"]));
1311 
1312  if (empty($java_path))
1313  {
1314  $this->error = "no_path_java";
1315  return false;
1316  }
1317 
1318  if (!$this->testJava($java_path))
1319  {
1320  $this->error = "check_failed_java";
1321  return false;
1322  }
1323  }
1324 
1325  // htmldoc path
1326  if (!isset($a_formdata["chk_htmldoc_path"]))
1327  {
1328  // convert backslashes to forwardslashes
1329  $htmldoc_path = preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["htmldoc_path"]));
1330 
1331  if (empty($htmldoc_path))
1332  {
1333  $this->error = "no_path_htmldoc";
1334  return false;
1335  }
1336 
1337  if (!$this->testHtmldoc($htmldoc_path))
1338  {
1339  $this->error = "check_failed_htmldoc";
1340  return false;
1341  }
1342  }
1343  if (!isset($a_formdata["chk_mkisofs_path"]))
1344  {
1345  // convert backslashes to forwardslashes
1346  $mkisofs_path = preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["mkisofs_path"]));
1347 
1348  if (empty($mkisofs_path))
1349  {
1350  $this->error = "no_path_mkisofs";
1351  return false;
1352  }
1353 
1354  if (!$this->testHtmldoc($mkisofs_path))
1355  {
1356  $this->error = "check_failed_mkisofs";
1357  return false;
1358  }
1359  }
1360 
1361  // latex url
1362  if (!isset($a_formdata["chk_latex_url"]))
1363  {
1364  $latex_url = ilUtil::stripSlashes($a_formdata["latex_url"]);
1365  if (empty($latex_url))
1366  {
1367  $this->error = "no_latex_url";
1368  return false;
1369  }
1370 
1371  if (!$this->testLatex($latex_url))
1372  {
1373  $this->error = "check_failed_latex";
1374  return false;
1375  }
1376  }
1377 
1378  return true;
1379  }
1380 
1386  function checkDataDirSetup($a_formdata)
1387  {
1388  // remove trailing slash & convert backslashes to forwardslashes
1389  $datadir_path = preg_replace("/\\\\/","/",ilFile::deleteTrailingSlash(ilUtil::stripSlashes($a_formdata["datadir_path"])));
1390 
1391  if (empty($datadir_path))
1392  {
1393  $this->error = "no_path_datadir";
1394  return false;
1395  }
1396 
1397  $webspace_dir = ILIAS_ABSOLUTE_PATH . "/data";
1398 
1399  // datadir may not point to webspace dir or to any place under webspace_dir
1400  if (strpos($datadir_path,$webspace_dir) !== false)
1401  {
1402  $this->error = "datadir_webspacedir_match";
1403  return false;
1404  }
1405 
1406  // create dir
1407  if ($a_formdata["chk_datadir_path"] == 1)
1408  {
1409  $dir_to_create = substr(strrchr($datadir_path, "/"), 1);
1410  $dir_to_check = substr($datadir_path,0,- strlen($dir_to_create)-1);
1411 
1412  if (is_writable($datadir_path))
1413  {
1414  $this->error = "dir_exists_create";
1415  return false;
1416  }
1417 
1418  if (!is_writable($dir_to_check))
1419  {
1420  $this->error = "cannot_create_datadir_no_write_access";
1421  return false;
1422  }
1423  }
1424  else // check set target dir
1425  {
1426  if (!is_writable($datadir_path))
1427  {
1428  $this->error = "cannot_create_datadir_no_write_access";
1429  return false;
1430  }
1431  }
1432 
1433  return true;
1434  }
1435 
1441  function checkPasswordSetup($a_formdata)
1442  {
1443  if (!$a_formdata["setup_pass"])
1444  {
1445  $this->error = "no_setup_pass_given";
1446  return false;
1447  }
1448 
1449  if ($a_formdata["setup_pass"] != $a_formdata["setup_pass2"])
1450  {
1451  $this->error = "pass_does_not_match";
1452  return false;
1453  }
1454 
1455  return true;
1456  }
1457 
1463  function checkLogSetup($a_formdata)
1464  {
1465  // log path
1466  if (!$a_formdata["chk_log_status"])
1467  {
1468  // remove trailing slash & convert backslashes to forwardslashes
1469  $log_path = preg_replace("/\\\\/","/",ilFile::deleteTrailingSlash(ilUtil::stripSlashes($a_formdata["log_path"])));
1470 
1471  if (empty($log_path))
1472  {
1473  $this->error = "no_path_log";
1474  return false;
1475  }
1476 
1477  if (!@touch($log_path))
1478  {
1479  $this->error = "could_not_create_logfile";
1480  return false;
1481  }
1482  }
1483 
1484  return true;
1485  }
1486 
1491  function getError()
1492  {
1493  if (empty($this->error))
1494  {
1495  return false;
1496  }
1497 
1498  $error = $this->error;
1499  $this->error = "";
1500 
1501  return $error;
1502  }
1503 
1509  function _ilSetup()
1510  {
1511  //if ($this->ini->readVariable("db","type") != "")
1512  //{
1513  // $this->db->disconnect();
1514  //}
1515  return true;
1516  }
1517 
1524  function testConvert($a_convert_path)
1525  {
1526  if (trim($a_convert_path) == "")
1527  {
1528  return "no_path_convert";
1529  }
1530  if (!is_file($a_convert_path))
1531  {
1532  return "check_failed_convert";
1533  }
1534 
1535  return "";
1536 
1537 /*
1538  // generate gif with convert
1539  if (file_exists(ILIAS_ABSOLUTE_PATH."/images/test.gif"))
1540  {
1541  unlink(ILIAS_ABSOLUTE_PATH."/images/test.gif");
1542  }
1543 
1544  system($a_convert_path." ".ILIAS_ABSOLUTE_PATH."/setup/test/test.jpg GIF:".ILIAS_ABSOLUTE_PATH."/setup/test/test.gif");
1545 
1546  // check wether convert generated file
1547  if (file_exists(ILIAS_ABSOLUTE_PATH."/setup/test/test.gif"))
1548  {
1549  unlink(ILIAS_ABSOLUTE_PATH."/setup/test/test.gif");
1550  return true;
1551  }
1552  else
1553  {
1554  return false;
1555  }
1556 */
1557  }
1558 
1565  function testJava ($a_java_path)
1566  {
1567  // java is optional, so empty path is ok
1568  if (trim($a_java_path) == "")
1569  {
1570  return "";
1571  }
1572 
1573  if (!is_file($a_java_path))
1574  {
1575  return "check_failed_java";
1576  }
1577 
1578  return "";
1579 /*
1580  exec($a_java_path, $out, $back);
1581 
1582  unset($out);
1583 
1584  return ($back != 1) ? false : true;
1585 */
1586  }
1587 
1594  function testLatex($a_latex_url)
1595  {
1596  // latex is optional, so empty path is ok
1597  if (trim($a_latex_url) == "")
1598  {
1599  return "";
1600  }
1601 
1602  // open the URL
1603  include_once "./setup/classes/class.ilHttpRequest.php";
1604  $http = new ilHttpRequest(ilUtil::stripSlashes($a_latex_url) . "?x_0");
1605  $result = @$http->downloadToString();
1606  if ((strpos((substr($result, 0, 5)), "PNG") !== FALSE) || (strpos((substr($result, 0, 5)), "GIF") !== FALSE))
1607  {
1608  return "";
1609  }
1610  else
1611  {
1612  return "check_failed_latex";;
1613  }
1614  }
1615 
1622  function testZip ($a_zip_path)
1623  {
1624  if (trim($a_zip_path) == "")
1625  {
1626  return "no_path_zip";
1627  }
1628  if (!is_file($a_zip_path))
1629  {
1630  return "check_failed_zip";
1631  }
1632 
1633  return "";
1634 /*
1635  // create test file and run zip
1636  $fp = fopen(ILIAS_ABSOLUTE_PATH."/test.dat", "w");
1637 
1638  fwrite($fp, "test");
1639  fclose($fp);
1640 
1641  if (file_exists(ILIAS_ABSOLUTE_PATH."/test.dat"))
1642  {
1643  $curDir = getcwd();
1644  chdir(ILIAS_ABSOLUTE_PATH);
1645 
1646  $zipCmd = $a_zip_path." -m zip_test_file.zip test.dat";
1647 
1648  exec($zipCmd);
1649 
1650  chdir($curDir);
1651 
1652  }
1653 
1654  // check wether zip generated test file or not
1655  if (file_exists(ILIAS_ABSOLUTE_PATH."/zip_test_file.zip"))
1656  {
1657  unlink(ILIAS_ABSOLUTE_PATH."/zip_test_file.zip");
1658  return true;
1659  }
1660  else
1661  {
1662  unlink(ILIAS_ABSOLUTE_PATH."/test.dat");
1663  return false;
1664  }
1665 */
1666  }
1667 
1668 
1675  function testUnzip ($a_unzip_path)
1676  {
1677  if (trim($a_unzip_path) == "")
1678  {
1679  return "no_path_unzip";
1680  }
1681  if (!is_file($a_unzip_path))
1682  {
1683  return "check_failed_unzip";
1684  }
1685 
1686  return "";
1687 /*
1688  $curDir = getcwd();
1689 
1690  chdir(ILIAS_ABSOLUTE_PATH);
1691 
1692  if (file_exists(ILIAS_ABSOLUTE_PATH."/unzip_test_file.zip"))
1693  {
1694  $unzipCmd = $a_unzip_path." unzip_test_file.zip";
1695  exec($unzipCmd);
1696  }
1697 
1698  chdir($curDir);
1699 
1700  // check wether unzip extracted the test file or not
1701  if (file_exists(ILIAS_ABSOLUTE_PATH."/unzip_test_file.txt"))
1702  {
1703  unlink(ILIAS_ABSOLUTE_PATH."/unzip_test_file.txt");
1704 
1705  return true;
1706  }
1707  else
1708  {
1709  return false;
1710  }
1711 */
1712  }
1713 
1720  function testHtmldoc($a_htmldoc_path)
1721  {
1722  // java is optional, so empty path is ok
1723  if (trim($a_htmldoc_path) == "")
1724  {
1725  return "";
1726  }
1727 
1728  if (!is_file($a_htmldoc_path))
1729  {
1730  return "check_failed_htmldoc";
1731  }
1732 
1733  return "";
1734 
1735 
1736  $curDir = getcwd();
1737 
1738  chdir(ILIAS_ABSOLUTE_PATH);
1739 
1740  $html = "<html><head><title></title></head><body><p>test</p></body></html>";
1741 
1742  $html_file = "htmldoc_test_file.html";
1743 
1744  $fp = fopen( $html_file ,"wb");
1745  fwrite($fp, $html);
1746  fclose($fp);
1747 
1748  $htmldoc = $a_htmldoc_path." ";
1749  $htmldoc .= "--no-toc ";
1750  $htmldoc .= "--no-jpeg ";
1751  $htmldoc .= "--webpage ";
1752  $htmldoc .= "--outfile htmldoc_test_file.pdf ";
1753  $htmldoc .= "--bodyfont Arial ";
1754  $htmldoc .= "--charset iso-8859-15 ";
1755  $htmldoc .= "--color ";
1756  $htmldoc .= "--size A4 "; // --landscape
1757  $htmldoc .= "--format pdf ";
1758  $htmldoc .= "--footer ... ";
1759  $htmldoc .= "--header ... ";
1760  $htmldoc .= "--left 60 ";
1761  // $htmldoc .= "--right 200 ";
1762  $htmldoc .= $html_file;
1763  exec($htmldoc);
1764 
1765  unlink(ILIAS_ABSOLUTE_PATH."/".$html_file);
1766 
1767  chdir($curDir);
1768 
1769  if (file_exists(ILIAS_ABSOLUTE_PATH."/htmldoc_test_file.pdf"))
1770  {
1771  unlink(ILIAS_ABSOLUTE_PATH."/htmldoc_test_file.pdf");
1772  return true;
1773  }
1774  else
1775  {
1776  return false;
1777  }
1778  }
1779 
1780 
1787  function unzip($a_file, $overwrite = false)
1788  {
1789  //global $ilias;
1790 
1791  $pathinfo = pathinfo($a_file);
1792  $dir = $pathinfo["dirname"];
1793  $file = $pathinfo["basename"];
1794 
1795  // unzip
1796  $cdir = getcwd();
1797  chdir($dir);
1798  $unzip = $this->ini->readVariable("tools","unzip");
1799  $unzipcmd = $unzip." -Z -1 ".ilUtil::escapeShellArg($file);
1800  exec($unzipcmd, $arr);
1801  $zdirs = array();
1802 
1803  foreach($arr as $line)
1804  {
1805  if(is_int(strpos($line, "/")))
1806  {
1807  $zdir = substr($line, 0, strrpos($line, "/"));
1808  $nr = substr_count($zdir, "/");
1809  //echo $zdir." ".$nr."<br>";
1810  while ($zdir != "")
1811  {
1812  $nr = substr_count($zdir, "/");
1813  $zdirs[$zdir] = $nr; // collect directories
1814  //echo $dir." ".$nr."<br>";
1815  $zdir = substr($zdir, 0, strrpos($zdir, "/"));
1816  }
1817  }
1818  }
1819 
1820  asort($zdirs);
1821 
1822  foreach($zdirs as $zdir => $nr) // create directories
1823  {
1824  ilUtil::createDirectory($zdir);
1825  }
1826 
1827  // real unzip
1828  if ($overvwrite)
1829  {
1830  $unzipcmd = $unzip." ".ilUtil::escapeShellArg($file);
1831  }
1832  else
1833  {
1834  $unzipcmd = $unzip." -o ".ilUtil::escapeShellArg($file);
1835  }
1836  exec($unzipcmd);
1837 
1838  chdir($cdir);
1839  }
1840 
1846  function setSessionSettings($session_settings)
1847  {
1848  require_once('Services/Authentication/classes/class.ilSessionControl.php');
1849 
1850  $db = $this->client->getDB();
1851 
1852  $setting_fields = ilSessionControl::getSettingFields();
1853 
1854  $i = 0;
1855  foreach($setting_fields as $field)
1856  {
1857  if( isset($session_settings[$field]) )
1858  {
1859  $query = "SELECT keyword FROM settings WHERE module = %s AND keyword = %s";
1860  $res = $db->queryF($query,
1861  array('text', 'text'), array('common', $field));
1862 
1863  $row = array();
1864  while($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) break;
1865 
1866  if( count($row) > 0 )
1867  {
1868  $db->update(
1869  'settings',
1870  array(
1871  'value' => array('text', $session_settings[$field])
1872  ),
1873  array(
1874  'module' => array('text', 'common'),
1875  'keyword' => array('text', $field)
1876  )
1877  );
1878  }
1879  else
1880  {
1881  $db->insert(
1882  'settings',
1883  array(
1884  'module' => array('text', 'common'),
1885  'keyword' => array('text', $field),
1886  'value' => array('text', $session_settings[$field])
1887  )
1888  );
1889  }
1890 
1891  $i++;
1892  }
1893  }
1894 
1895  if($i < 4) $message = $this->lng->txt("session_settings_not_saved");
1896  else $message = $this->lng->txt("settings_saved");
1897 
1898  ilUtil::sendInfo($message);
1899  }
1900 
1907  {
1908  require_once('Services/Authentication/classes/class.ilSessionControl.php');
1909 
1910  $db = $this->client->getDB();
1911 
1912  $setting_fields = ilSessionControl::getSettingFields();
1913 
1914  $query = "SELECT * FROM settings WHERE module = %s " .
1915  "AND ".$db->in('keyword', $setting_fields, false, 'text');
1916 
1917  $res = $db->queryF($query, array('text'), array('common'));
1918 
1919  $session_settings = array();
1920  while($row = $res->fetchRow(DB_FETCHMODE_ASSOC))
1921  {
1922  $session_settings[$row['keyword']] = $row['value'];
1923  }
1924 
1925  foreach( $setting_fields as $field )
1926  {
1927  if( !isset($session_settings[$field]) )
1928  {
1929  $value = 1;
1930 
1931  switch($field)
1932  {
1933  case 'session_max_count':
1934 
1936  break;
1937 
1938  case 'session_min_idle':
1939 
1941  break;
1942 
1943  case 'session_max_idle':
1944 
1946  break;
1947 
1948  case 'session_max_idle_after_first_request':
1949 
1951  break;
1952 
1953  case 'session_allow_client_maintenance':
1954 
1956  break;
1957  }
1958 
1959  $session_settings[$field] = $value;
1960  }
1961  }
1962 
1963  return $session_settings;
1964  }
1965 
1966 } // END class.ilSetup
1967 
1969 {
1970  public function current()
1971  {
1972  return parent::getFileName();
1973  }
1974 
1975  public function valid()
1976  {
1977  if(!parent::valid())
1978  {
1979  return false;
1980  }
1981  if($this->isFile() and substr(parent::getFileName(),-4) == '.xml')
1982  {
1983  return false;
1984  }
1985  if($this->isFile() and substr(parent::getFileName(),-8) != '_inserts')
1986  {
1987  return true;
1988  }
1989  parent::next();
1990  return $this->valid();
1991  }
1992 
1993  public function rewind()
1994  {
1995  parent::rewind();
1996  }
1997 }
1998 ?>