ILIAS  eassessment Revision 61809
 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.1.3', '<'))
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 
828  if ($status["db"]["status"] === false and $status["db"]["update"] !== true)
829  {
830  //$status["sess"]["status"] = false;
831  //$status["sess"]["comment"] = $status["db"]["comment"];
832  $status["lang"]["status"] = false;
833  $status["lang"]["comment"] = $status["db"]["comment"];
834  $status["contact"]["status"] = false;
835  $status["contact"]["comment"] = $status["db"]["comment"];
836  $status["nic"]["status"] = false;
837  $status["nic"]["comment"] = $status["db"]["comment"];
838  }
839  else
840  {
841  //$status["sess"] = $this->checkClientSessionSettings($client);
842  $status["lang"] = $this->checkClientLanguages($client);
843  $status["contact"] = $this->checkClientContact($client);
844  $status["nic"] = $this->checkClientNIC($client);
845  $status["finish"] = $this->checkFinish($client);
846  $status["access"] = $this->checkAccess($client);
847  }
848 
849  //return value
850  return $status;
851  }
852 
858  function checkFinish(&$client)
859  {
860  if ($client->getSetting("setup_ok"))
861  {
862  $arr["status"] = true;
863  //$arr["comment"] = $this->lng->txt("setup_finished");
864  }
865  else
866  {
867  $arr["status"] = false;
868  $arr["comment"] = $this->lng->txt("setup_not_finished");
869  }
870 
871  return $arr;
872  }
873 
879  function checkAccess(&$client)
880  {
881  if ($client->ini->readVariable("client","access") == "1")
882  {
883  $arr["status"] = true;
884  $arr["comment"] = $this->lng->txt("online");
885  }
886  else
887  {
888  $arr["status"] = false;
889  $arr["comment"] = $this->lng->txt("disabled");
890  }
891 
892  return $arr;
893  }
894 
901  {
902  if (!$arr["status"] = $client->init())
903  {
904  $arr["comment"] = $client->getError();
905  }
906  else
907  {
908  //$arr["comment"] = "dir: /".ILIAS_WEB_DIR."/".$client->getId();
909  }
910 
911  return $arr;
912  }
913 
920  {
921  if (!$arr["status"] = $client->db_exists)
922  {
923  $arr["comment"] = $this->lng->txt("no_database");
924  return $arr;
925  }
926 
927  if (!$arr["status"] = $client->db_installed)
928  {
929  $arr["comment"] = $this->lng->txt("db_not_installed");
930  return $arr;
931  }
932 
933  // TODO: move this to client class!!
934  $client->setup_ok = (bool) $client->getSetting("setup_ok");
935 
936  //$this->lng->setDbHandler($client->db);
937  include_once "./Services/Database/classes/class.ilDBUpdate.php";
938  $ilDB = $client->db;
939  $this->lng->setDbHandler($client->db);
940  $dbupdate = new ilDBUpdate($client->db);
941 
942  if (!$arr["status"] = $dbupdate->getDBVersionStatus())
943  {
944  $arr["comment"] = $this->lng->txt("db_needs_update");
945  $arr["update"] = true;
946  return $arr;
947  }
948  else if ($dbupdate->hotfixAvailable())
949  {
950  $arr["status"] = false;
951  $arr["comment"] = $this->lng->txt("hotfix_available");
952  $arr["update"] = true;
953  return $arr;
954  }
955 
956  // check control information
957 
958  $cset = $ilDB->query("SELECT count(*) as cnt FROM ctrl_calls");
959  $crec = $ilDB->fetchAssoc($cset);
960  if ($crec["cnt"] == 0)
961  {
962  $arr["status"] = false;
963  $arr["comment"] = $this->lng->txt("db_control_structure_missing");
964  $arr["update"] = true;
965  return $arr;
966  }
967 
968  //$arr["comment"] = "version ".$dbupdate->getCurrentVersion();
969  return $arr;
970  }
971 
977  function checkClientSessionSettings(&$client, $a_as_bool = false)
978  {
979  require_once('Services/Authentication/classes/class.ilSessionControl.php');
980 
981  global $ilDB;
982  $db = $ilDB;
983 
985 
986  $query = "SELECT keyword, value FROM settings WHERE ".$db->in('keyword', $fields, false, 'text');
987  $res = $db->query($query);
988 
989  $rows = array();
990  while($row = $res->fetchRow(DB_FETCHMODE_ASSOC))
991  {
992  if( $row['value'] != '' )
993  $rows[] = $row;
994  else break;
995  }
996 
997  if (count($rows) != count($fields))
998  {
999  if($a_as_bool) return false;
1000  $arr["status"] = false;
1001  $arr["comment"] = $this->lng->txt("session_management_not_configured");
1002  }
1003  else
1004  {
1005  if($a_as_bool) return true;
1006  $arr["status"] = true;
1007  $arr["comment"] = $this->lng->txt("session_management_configured");
1008  }
1009 
1010  return $arr;
1011  }
1012 
1019  {
1020  $installed_langs = $this->lng->getInstalledLanguages();
1021 
1022  $count = count($installed_langs);
1023 
1024  if ($count < 1)
1025  {
1026  $arr["status"] = false;
1027  $arr["comment"] = $this->lng->txt("lang_none_installed");
1028  }
1029  else
1030  {
1031  $arr["status"] = true;
1032  //$arr["comment"] = $count." ".$this->lng->txt("languages_installed");
1033  }
1034 
1035  return $arr;
1036  }
1037 
1044  {
1045  $arr["status"] = true;
1046  //$arr["comment"] = $this->lng->txt("filled_out");
1047 
1048  $settings = $client->getAllSettings();
1049  $client_name = $client->getName();
1050 
1051  // check required fields
1052  if (empty($settings["admin_firstname"]) or empty($settings["admin_lastname"]) or
1053  empty($settings["admin_email"]) or empty($client_name))
1054  {
1055  $arr["status"] = false;
1056  $arr["comment"] = $this->lng->txt("missing_data");
1057  }
1058 
1059  // admin email
1060  if (!ilUtil::is_email($settings["admin_email"]) and $arr["status"] != false)
1061  {
1062  $arr["status"] = false;
1063  $arr["comment"] = $this->lng->txt("email_not_valid");
1064  }
1065 
1066  return $arr;
1067  }
1068 
1075  {
1076  $settings = $client->getAllSettings();
1077 
1078  if (!isset($settings["nic_enabled"]))
1079  {
1080  $arr["status"] = false;
1081  $arr["comment"] = $this->lng->txt("nic_not_disabled");
1082  return $arr;
1083  }
1084 
1085  $arr["status"] = true;
1086 
1087  if ($settings["nic_enabled"] == "-1")
1088  {
1089  $arr["comment"] = $this->lng->txt("nic_reg_failed");
1090  return $arr;
1091  }
1092 
1093  if (!$settings["nic_enabled"])
1094  {
1095  $arr["comment"] = $this->lng->txt("nic_reg_disabled");
1096  }
1097  else
1098  {
1099  $arr["comment"] = $this->lng->txt("nic_reg_enabled");
1100  if ($settings["inst_id"] <= 0)
1101  {
1102  $arr["status"] = false;
1103  }
1104  }
1105 
1106  return $arr;
1107  }
1108 
1113  function isInstalled()
1114  {
1115  return $this->ini_ilias_exists;
1116  }
1117 
1122  function isAuthenticated()
1123  {
1124  return $this->auth;
1125  }
1126 
1131  function isAdmin()
1132  {
1133  return ($this->access_mode == "admin") ? true : false;
1134  }
1135 
1141  function saveMasterSetup($a_formdata)
1142  {
1143  $datadir_path = preg_replace("/\\\\/","/",ilFile::deleteTrailingSlash(ilUtil::stripSlashes($a_formdata["datadir_path"])));
1144 
1145  if ($a_formdata["chk_datadir_path"] == 1) // mode create dir
1146  {
1147  if (!ilUtil::makeDir($datadir_path))
1148  {
1149  $this->error = "create_datadir_failed";
1150  return false;
1151  }
1152  }
1153 
1154  // create webspace dir if it does not exist
1155  if (!@file_exists(ILIAS_ABSOLUTE_PATH."/".$this->ini->readVariable("clients","path")) and !@is_dir(ILIAS_ABSOLUTE_PATH."/".$this->ini->readVariable("clients","path")))
1156  {
1157  if (!ilUtil::makeDir(ILIAS_ABSOLUTE_PATH."/".$this->ini->readVariable("clients","path")))
1158  {
1159  $this->error = "create_webdir_failed";
1160  return false;
1161  }
1162  }
1163 
1164  $form_log_path = preg_replace("/\\\\/","/",ilFile::deleteTrailingSlash(ilUtil::stripSlashes($a_formdata["log_path"])));
1165  $log_path = substr($form_log_path,0,strrpos($form_log_path,"/"));
1166  $log_file = substr($form_log_path,strlen($log_path)+1);
1167 
1168  $this->ini->setVariable("server","http_path",ILIAS_HTTP_PATH);
1169  $this->ini->setVariable("server","absolute_path",ILIAS_ABSOLUTE_PATH);
1170  $this->ini->setVariable("server","timezone",preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["time_zone"])));
1171  $this->ini->setVariable("clients", "datadir", $datadir_path);
1172  $this->ini->setVariable("tools", "convert", preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["convert_path"])));
1173  $this->ini->setVariable("tools", "zip", preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["zip_path"])));
1174  $this->ini->setVariable("tools", "unzip", preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["unzip_path"])));
1175  $this->ini->setVariable("tools", "java", preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["java_path"])));
1176  $this->ini->setVariable("tools", "htmldoc", preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["htmldoc_path"])));
1177  $this->ini->setVariable("tools", "mkisofs", preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["mkisofs_path"])));
1178  $this->ini->setVariable("tools", "latex", ilUtil::stripSlashes($a_formdata["latex_url"]));
1179  $this->ini->setVariable("tools", "vscantype", preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["vscanner_type"])));
1180  $this->ini->setVariable("tools", "scancommand", preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["scan_command"])));
1181  $this->ini->setVariable("tools", "cleancommand", preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["clean_command"])));
1182  $this->ini->setVariable("setup", "pass", md5($a_formdata["setup_pass"]));
1183  $this->ini->setVariable("log", "path", $log_path);
1184  $this->ini->setVariable("log", "file", $log_file);
1185  $this->ini->setVariable("log", "enabled", (isset($a_formdata["chk_log_status"])) ? "0" : 1);
1186 
1187  if (!$this->ini->write())
1188  {
1189  $this->error = get_class($this).": ".$this->ini->getError();
1190  return false;
1191  }
1192 
1193  // everything is fine. so we authenticate the user and set access mode to 'admin'
1194  $_SESSION["auth"] = true;
1195  $_SESSION["access_mode"] = "admin";
1196 
1197  return true;
1198  }
1199 
1205  function updateMasterSettings($a_formdata)
1206  {
1207  $convert_path = preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["convert_path"]));
1208  $zip_path = preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["zip_path"]));
1209  $unzip_path = preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["unzip_path"]));
1210  $java_path = preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["java_path"]));
1211  $htmldoc_path = preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["htmldoc_path"]));
1212  $mkisofs_path = preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["mkisofs_path"]));
1213  $latex_url = ilUtil::stripSlashes($a_formdata["latex_url"]);
1214  $fop_path = preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["fop_path"]));
1215  $scan_type = preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["vscanner_type"]));
1216  $scan_command = preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["scan_command"]));
1217  $clean_command = preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["clean_command"]));
1218 
1219  $this->ini->setVariable("tools", "convert", $convert_path);
1220  $this->ini->setVariable("tools", "zip", $zip_path);
1221  $this->ini->setVariable("tools", "unzip", $unzip_path);
1222  $this->ini->setVariable("tools", "java", $java_path);
1223  $this->ini->setVariable("tools", "htmldoc", $htmldoc_path);
1224  $this->ini->setVariable("tools", "mkisofs", $mkisofs_path);
1225  $this->ini->setVariable("tools", "latex", $latex_url);
1226  $this->ini->setVariable("tools", "fop", $fop_path);
1227  $this->ini->setVariable("tools", "vscantype", $scan_type);
1228  $this->ini->setVariable("tools", "scancommand", $scan_command);
1229  $this->ini->setVariable("tools", "cleancommand", $clean_command);
1230 
1231  $form_log_path = preg_replace("/\\\\/","/",ilFile::deleteTrailingSlash(ilUtil::stripSlashes($a_formdata["log_path"])));
1232  $log_path = substr($form_log_path,0,strrpos($form_log_path,"/"));
1233  $log_file = substr($form_log_path,strlen($log_path)+1);
1234 
1235  $this->ini->setVariable("log", "path", $log_path);
1236  $this->ini->setVariable("log", "file", $log_file);
1237  $this->ini->setVariable("log", "enabled", ($a_formdata["chk_log_status"]) ? "0" : 1);
1238  $this->ini->setVariable("server","timezone",preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["time_zone"])));
1239 
1240  if (!$this->ini->write())
1241  {
1242  $this->error = get_class($this).": ".$this->ini->getError();
1243  return false;
1244  }
1245 
1246  return true;
1247  }
1248 
1254  function checkToolsSetup($a_formdata)
1255  {
1256  // convert path
1257  if (!isset($a_formdata["chk_convert_path"]))
1258  {
1259  // convert backslashes to forwardslashes
1260  $convert_path = preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["convert_path"]));
1261 
1262  if (($err = $this->testConvert($convert_path)) != "")
1263  {
1264  $this->error = $err;
1265  return false;
1266  }
1267  }
1268 
1269  // zip path
1270  if (!isset($a_formdata["chk_zip_path"]))
1271  {
1272  // convert backslashes to forwardslashes
1273  $zip_path = preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["zip_path"]));
1274 
1275  if (empty($zip_path))
1276  {
1277  $this->error = "no_path_zip";
1278  return false;
1279  }
1280 
1281  if (!$this->testZip($zip_path))
1282  {
1283  $this->error = "check_failed_zip";
1284  return false;
1285  }
1286  }
1287 
1288  // unzip path
1289  if (!isset($a_formdata["chk_unzip_path"]))
1290  {
1291  // convert backslashes to forwardslashes
1292  $unzip_path = preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["unzip_path"]));
1293 
1294  if (empty($unzip_path))
1295  {
1296  $this->error = "no_path_unzip";
1297  return false;
1298  }
1299 
1300  if (!$this->testUnzip($unzip_path))
1301  {
1302  $this->error = "check_failed_unzip";
1303  return false;
1304  }
1305  }
1306 
1307  // java path
1308  if (!isset($a_formdata["chk_java_path"]))
1309  {
1310  // convert backslashes to forwardslashes
1311  $java_path = preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["java_path"]));
1312 
1313  if (empty($java_path))
1314  {
1315  $this->error = "no_path_java";
1316  return false;
1317  }
1318 
1319  if (!$this->testJava($java_path))
1320  {
1321  $this->error = "check_failed_java";
1322  return false;
1323  }
1324  }
1325 
1326  // htmldoc path
1327  if (!isset($a_formdata["chk_htmldoc_path"]))
1328  {
1329  // convert backslashes to forwardslashes
1330  $htmldoc_path = preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["htmldoc_path"]));
1331 
1332  if (empty($htmldoc_path))
1333  {
1334  $this->error = "no_path_htmldoc";
1335  return false;
1336  }
1337 
1338  if (!$this->testHtmldoc($htmldoc_path))
1339  {
1340  $this->error = "check_failed_htmldoc";
1341  return false;
1342  }
1343  }
1344  if (!isset($a_formdata["chk_mkisofs_path"]))
1345  {
1346  // convert backslashes to forwardslashes
1347  $mkisofs_path = preg_replace("/\\\\/","/",ilUtil::stripSlashes($a_formdata["mkisofs_path"]));
1348 
1349  if (empty($mkisofs_path))
1350  {
1351  $this->error = "no_path_mkisofs";
1352  return false;
1353  }
1354 
1355  if (!$this->testHtmldoc($mkisofs_path))
1356  {
1357  $this->error = "check_failed_mkisofs";
1358  return false;
1359  }
1360  }
1361 
1362  // latex url
1363  if (!isset($a_formdata["chk_latex_url"]))
1364  {
1365  $latex_url = ilUtil::stripSlashes($a_formdata["latex_url"]);
1366  if (empty($latex_url))
1367  {
1368  $this->error = "no_latex_url";
1369  return false;
1370  }
1371 
1372  if (!$this->testLatex($latex_url))
1373  {
1374  $this->error = "check_failed_latex";
1375  return false;
1376  }
1377  }
1378 
1379  return true;
1380  }
1381 
1387  function checkDataDirSetup($a_formdata)
1388  {
1389  // remove trailing slash & convert backslashes to forwardslashes
1390  $datadir_path = preg_replace("/\\\\/","/",ilFile::deleteTrailingSlash(ilUtil::stripSlashes($a_formdata["datadir_path"])));
1391 
1392  if (empty($datadir_path))
1393  {
1394  $this->error = "no_path_datadir";
1395  return false;
1396  }
1397 
1398  $webspace_dir = ILIAS_ABSOLUTE_PATH . "/data";
1399 
1400  // datadir may not point to webspace dir or to any place under webspace_dir
1401  if (strpos($datadir_path,$webspace_dir) !== false)
1402  {
1403  $this->error = "datadir_webspacedir_match";
1404  return false;
1405  }
1406 
1407  // create dir
1408  if ($a_formdata["chk_datadir_path"] == 1)
1409  {
1410  $dir_to_create = substr(strrchr($datadir_path, "/"), 1);
1411  $dir_to_check = substr($datadir_path,0,- strlen($dir_to_create)-1);
1412 
1413  if (is_writable($datadir_path))
1414  {
1415  $this->error = "dir_exists_create";
1416  return false;
1417  }
1418 
1419  if (!is_writable($dir_to_check))
1420  {
1421  $this->error = "cannot_create_datadir_no_write_access";
1422  return false;
1423  }
1424  }
1425  else // check set target dir
1426  {
1427  if (!is_writable($datadir_path))
1428  {
1429  $this->error = "cannot_create_datadir_no_write_access";
1430  return false;
1431  }
1432  }
1433 
1434  return true;
1435  }
1436 
1442  function checkPasswordSetup($a_formdata)
1443  {
1444  if (!$a_formdata["setup_pass"])
1445  {
1446  $this->error = "no_setup_pass_given";
1447  return false;
1448  }
1449 
1450  if ($a_formdata["setup_pass"] != $a_formdata["setup_pass2"])
1451  {
1452  $this->error = "pass_does_not_match";
1453  return false;
1454  }
1455 
1456  return true;
1457  }
1458 
1464  function checkLogSetup($a_formdata)
1465  {
1466  // log path
1467  if (!$a_formdata["chk_log_status"])
1468  {
1469  // remove trailing slash & convert backslashes to forwardslashes
1470  $log_path = preg_replace("/\\\\/","/",ilFile::deleteTrailingSlash(ilUtil::stripSlashes($a_formdata["log_path"])));
1471 
1472  if (empty($log_path))
1473  {
1474  $this->error = "no_path_log";
1475  return false;
1476  }
1477 
1478  if (!@touch($log_path))
1479  {
1480  $this->error = "could_not_create_logfile";
1481  return false;
1482  }
1483  }
1484 
1485  return true;
1486  }
1487 
1492  function getError()
1493  {
1494  if (empty($this->error))
1495  {
1496  return false;
1497  }
1498 
1499  $error = $this->error;
1500  $this->error = "";
1501 
1502  return $error;
1503  }
1504 
1510  function _ilSetup()
1511  {
1512  //if ($this->ini->readVariable("db","type") != "")
1513  //{
1514  // $this->db->disconnect();
1515  //}
1516  return true;
1517  }
1518 
1525  function testConvert($a_convert_path)
1526  {
1527  if (trim($a_convert_path) == "")
1528  {
1529  return "no_path_convert";
1530  }
1531  if (!is_file($a_convert_path))
1532  {
1533  return "check_failed_convert";
1534  }
1535 
1536  return "";
1537 
1538 /*
1539  // generate gif with convert
1540  if (file_exists(ILIAS_ABSOLUTE_PATH."/images/test.gif"))
1541  {
1542  unlink(ILIAS_ABSOLUTE_PATH."/images/test.gif");
1543  }
1544 
1545  system($a_convert_path." ".ILIAS_ABSOLUTE_PATH."/setup/test/test.jpg GIF:".ILIAS_ABSOLUTE_PATH."/setup/test/test.gif");
1546 
1547  // check wether convert generated file
1548  if (file_exists(ILIAS_ABSOLUTE_PATH."/setup/test/test.gif"))
1549  {
1550  unlink(ILIAS_ABSOLUTE_PATH."/setup/test/test.gif");
1551  return true;
1552  }
1553  else
1554  {
1555  return false;
1556  }
1557 */
1558  }
1559 
1566  function testJava ($a_java_path)
1567  {
1568  // java is optional, so empty path is ok
1569  if (trim($a_java_path) == "")
1570  {
1571  return "";
1572  }
1573 
1574  if (!is_file($a_java_path))
1575  {
1576  return "check_failed_java";
1577  }
1578 
1579  return "";
1580 /*
1581  exec($a_java_path, $out, $back);
1582 
1583  unset($out);
1584 
1585  return ($back != 1) ? false : true;
1586 */
1587  }
1588 
1595  function testLatex($a_latex_url)
1596  {
1597  // latex is optional, so empty path is ok
1598  if (trim($a_latex_url) == "")
1599  {
1600  return "";
1601  }
1602 
1603  // open the URL
1604  include_once "./setup/classes/class.ilHttpRequest.php";
1605  $http = new ilHttpRequest(ilUtil::stripSlashes($a_latex_url) . "?x_0");
1606  $result = @$http->downloadToString();
1607  if ((strpos((substr($result, 0, 5)), "PNG") !== FALSE) || (strpos((substr($result, 0, 5)), "GIF") !== FALSE))
1608  {
1609  return "";
1610  }
1611  else
1612  {
1613  return "check_failed_latex";;
1614  }
1615  }
1616 
1623  function testZip ($a_zip_path)
1624  {
1625  if (trim($a_zip_path) == "")
1626  {
1627  return "no_path_zip";
1628  }
1629  if (!is_file($a_zip_path))
1630  {
1631  return "check_failed_zip";
1632  }
1633 
1634  return "";
1635 /*
1636  // create test file and run zip
1637  $fp = fopen(ILIAS_ABSOLUTE_PATH."/test.dat", "w");
1638 
1639  fwrite($fp, "test");
1640  fclose($fp);
1641 
1642  if (file_exists(ILIAS_ABSOLUTE_PATH."/test.dat"))
1643  {
1644  $curDir = getcwd();
1645  chdir(ILIAS_ABSOLUTE_PATH);
1646 
1647  $zipCmd = $a_zip_path." -m zip_test_file.zip test.dat";
1648 
1649  exec($zipCmd);
1650 
1651  chdir($curDir);
1652 
1653  }
1654 
1655  // check wether zip generated test file or not
1656  if (file_exists(ILIAS_ABSOLUTE_PATH."/zip_test_file.zip"))
1657  {
1658  unlink(ILIAS_ABSOLUTE_PATH."/zip_test_file.zip");
1659  return true;
1660  }
1661  else
1662  {
1663  unlink(ILIAS_ABSOLUTE_PATH."/test.dat");
1664  return false;
1665  }
1666 */
1667  }
1668 
1669 
1676  function testUnzip ($a_unzip_path)
1677  {
1678  if (trim($a_unzip_path) == "")
1679  {
1680  return "no_path_unzip";
1681  }
1682  if (!is_file($a_unzip_path))
1683  {
1684  return "check_failed_unzip";
1685  }
1686 
1687  return "";
1688 /*
1689  $curDir = getcwd();
1690 
1691  chdir(ILIAS_ABSOLUTE_PATH);
1692 
1693  if (file_exists(ILIAS_ABSOLUTE_PATH."/unzip_test_file.zip"))
1694  {
1695  $unzipCmd = $a_unzip_path." unzip_test_file.zip";
1696  exec($unzipCmd);
1697  }
1698 
1699  chdir($curDir);
1700 
1701  // check wether unzip extracted the test file or not
1702  if (file_exists(ILIAS_ABSOLUTE_PATH."/unzip_test_file.txt"))
1703  {
1704  unlink(ILIAS_ABSOLUTE_PATH."/unzip_test_file.txt");
1705 
1706  return true;
1707  }
1708  else
1709  {
1710  return false;
1711  }
1712 */
1713  }
1714 
1721  function testHtmldoc($a_htmldoc_path)
1722  {
1723  // java is optional, so empty path is ok
1724  if (trim($a_htmldoc_path) == "")
1725  {
1726  return "";
1727  }
1728 
1729  if (!is_file($a_htmldoc_path))
1730  {
1731  return "check_failed_htmldoc";
1732  }
1733 
1734  return "";
1735 
1736 
1737  $curDir = getcwd();
1738 
1739  chdir(ILIAS_ABSOLUTE_PATH);
1740 
1741  $html = "<html><head><title></title></head><body><p>test</p></body></html>";
1742 
1743  $html_file = "htmldoc_test_file.html";
1744 
1745  $fp = fopen( $html_file ,"wb");
1746  fwrite($fp, $html);
1747  fclose($fp);
1748 
1749  $htmldoc = $a_htmldoc_path." ";
1750  $htmldoc .= "--no-toc ";
1751  $htmldoc .= "--no-jpeg ";
1752  $htmldoc .= "--webpage ";
1753  $htmldoc .= "--outfile htmldoc_test_file.pdf ";
1754  $htmldoc .= "--bodyfont Arial ";
1755  $htmldoc .= "--charset iso-8859-15 ";
1756  $htmldoc .= "--color ";
1757  $htmldoc .= "--size A4 "; // --landscape
1758  $htmldoc .= "--format pdf ";
1759  $htmldoc .= "--footer ... ";
1760  $htmldoc .= "--header ... ";
1761  $htmldoc .= "--left 60 ";
1762  // $htmldoc .= "--right 200 ";
1763  $htmldoc .= $html_file;
1764  exec($htmldoc);
1765 
1766  unlink(ILIAS_ABSOLUTE_PATH."/".$html_file);
1767 
1768  chdir($curDir);
1769 
1770  if (file_exists(ILIAS_ABSOLUTE_PATH."/htmldoc_test_file.pdf"))
1771  {
1772  unlink(ILIAS_ABSOLUTE_PATH."/htmldoc_test_file.pdf");
1773  return true;
1774  }
1775  else
1776  {
1777  return false;
1778  }
1779  }
1780 
1781 
1788  function unzip($a_file, $overwrite = false)
1789  {
1790  //global $ilias;
1791 
1792  $pathinfo = pathinfo($a_file);
1793  $dir = $pathinfo["dirname"];
1794  $file = $pathinfo["basename"];
1795 
1796  // unzip
1797  $cdir = getcwd();
1798  chdir($dir);
1799  $unzip = $this->ini->readVariable("tools","unzip");
1800  $unzipcmd = $unzip." -Z -1 ".ilUtil::escapeShellArg($file);
1801  exec($unzipcmd, $arr);
1802  $zdirs = array();
1803 
1804  foreach($arr as $line)
1805  {
1806  if(is_int(strpos($line, "/")))
1807  {
1808  $zdir = substr($line, 0, strrpos($line, "/"));
1809  $nr = substr_count($zdir, "/");
1810  //echo $zdir." ".$nr."<br>";
1811  while ($zdir != "")
1812  {
1813  $nr = substr_count($zdir, "/");
1814  $zdirs[$zdir] = $nr; // collect directories
1815  //echo $dir." ".$nr."<br>";
1816  $zdir = substr($zdir, 0, strrpos($zdir, "/"));
1817  }
1818  }
1819  }
1820 
1821  asort($zdirs);
1822 
1823  foreach($zdirs as $zdir => $nr) // create directories
1824  {
1825  ilUtil::createDirectory($zdir);
1826  }
1827 
1828  // real unzip
1829  if ($overvwrite)
1830  {
1831  $unzipcmd = $unzip." ".ilUtil::escapeShellArg($file);
1832  }
1833  else
1834  {
1835  $unzipcmd = $unzip." -o ".ilUtil::escapeShellArg($file);
1836  }
1837  exec($unzipcmd);
1838 
1839  chdir($cdir);
1840  }
1841 
1847  function setSessionSettings($session_settings)
1848  {
1849  require_once('Services/Authentication/classes/class.ilSessionControl.php');
1850 
1851  $db = $this->client->getDB();
1852 
1853  $setting_fields = ilSessionControl::getSettingFields();
1854 
1855  $i = 0;
1856  foreach($setting_fields as $field)
1857  {
1858  if( isset($session_settings[$field]) )
1859  {
1860  $query = "SELECT keyword FROM settings WHERE module = %s AND keyword = %s";
1861  $res = $db->queryF($query,
1862  array('text', 'text'), array('common', $field));
1863 
1864  $row = array();
1865  while($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) break;
1866 
1867  if( count($row) > 0 )
1868  {
1869  $db->update(
1870  'settings',
1871  array(
1872  'value' => array('text', $session_settings[$field])
1873  ),
1874  array(
1875  'module' => array('text', 'common'),
1876  'keyword' => array('text', $field)
1877  )
1878  );
1879  }
1880  else
1881  {
1882  $db->insert(
1883  'settings',
1884  array(
1885  'module' => array('text', 'common'),
1886  'keyword' => array('text', $field),
1887  'value' => array('text', $session_settings[$field])
1888  )
1889  );
1890  }
1891 
1892  $i++;
1893  }
1894  }
1895 
1896  if($i < 4) $message = $this->lng->txt("session_settings_not_saved");
1897  else $message = $this->lng->txt("settings_saved");
1898 
1899  ilUtil::sendInfo($message);
1900  }
1901 
1908  {
1909  require_once('Services/Authentication/classes/class.ilSessionControl.php');
1910 
1911  $db = $this->client->getDB();
1912 
1913  $setting_fields = ilSessionControl::getSettingFields();
1914 
1915  $query = "SELECT * FROM settings WHERE module = %s " .
1916  "AND ".$db->in('keyword', $setting_fields, false, 'text');
1917 
1918  $res = $db->queryF($query, array('text'), array('common'));
1919 
1920  $session_settings = array();
1921  while($row = $res->fetchRow(DB_FETCHMODE_ASSOC))
1922  {
1923  $session_settings[$row['keyword']] = $row['value'];
1924  }
1925 
1926  foreach( $setting_fields as $field )
1927  {
1928  if( !isset($session_settings[$field]) )
1929  {
1930  $value = 1;
1931 
1932  switch($field)
1933  {
1934  case 'session_max_count':
1935 
1937  break;
1938 
1939  case 'session_min_idle':
1940 
1942  break;
1943 
1944  case 'session_max_idle':
1945 
1947  break;
1948 
1949  case 'session_max_idle_after_first_request':
1950 
1952  break;
1953 
1954  case 'session_allow_client_maintenance':
1955 
1957  break;
1958  }
1959 
1960  $session_settings[$field] = $value;
1961  }
1962  }
1963 
1964  return $session_settings;
1965  }
1966 
1967 } // END class.ilSetup
1968 
1970 {
1971  public function current()
1972  {
1973  return parent::getFileName();
1974  }
1975 
1976  public function valid()
1977  {
1978  if(!parent::valid())
1979  {
1980  return false;
1981  }
1982  if($this->isFile() and substr(parent::getFileName(),-4) == '.xml')
1983  {
1984  return false;
1985  }
1986  if($this->isFile() and substr(parent::getFileName(),-8) != '_inserts')
1987  {
1988  return true;
1989  }
1990  parent::next();
1991  return $this->valid();
1992  }
1993 
1994  public function rewind()
1995  {
1996  parent::rewind();
1997  }
1998 }
1999 ?>