32 include_once 
'PEAR.php';
 
   33 include_once 
'MDB2.php';
 
   42                 define(
'INI_FILE_PATH',
'../ilias.ini.php');
 
   43                 define(
'CRON_DEBUG',1);
 
   47                 register_shutdown_function(array($this,
'__ilCronClients'));
 
   55                         die(
'Instance already created');
 
   62                 $this->fp = @fopen(
'cron.lock',
'wb');
 
   63                 fwrite($this->fp,(
string) time(),strlen((
string) time()));
 
   70                 if(@file_exists(
'cron.lock'))
 
   72                         $fp = fopen(
'cron.lock',
'r');
 
   74                         (int) $timest = fread(
$fp,filesize(
'cron.lock'));
 
   76                         if(!CRON_DEBUG and ($timest > time() - 60 * 60 * 12))
 
   87                 include_once 
'./classes/class.ilIniFile.php';
 
   89                 $ini_file_obj =& 
new ilIniFile(INI_FILE_PATH);
 
   91                 $ini_file_obj->read();
 
   93                 $this->log[
'enabled'] = $ini_file_obj->readVariable(
'log',
'enabled');
 
   94                 $this->log[
'path'] = $ini_file_obj->readVariable(
'log',
'path');
 
   95                 $this->log[
'file'] = $ini_file_obj->readVariable(
'log',
'file');
 
   97                 $this->web_enabled = $ini_file_obj->readVariable(
'cron',
'web_enabled');
 
   98                 $this->web_pass = $ini_file_obj->readVariable(
'cron',
'web_pass');
 
  102                 $this->client_data = $ini_file_obj->readGroup(
'clients');
 
  103                 unset($ini_file_obj);
 
  109                 $this->client_ini = array();
 
  110                 $dp = opendir(
'../'.$this->client_data[
'path']);
 
  111                 while((
$file = readdir($dp)) !== 
false)
 
  117                         if(@file_exists(
'../'.$this->client_data[
'path'].
'/'.
$file.
'/'.$this->client_data[
'inifile']))
 
  119                                 $tmp_data[
'path'] = 
'../'.$this->client_data[
'path'].
'/'.
$file.
'/'.$this->client_data[
'inifile'];
 
  120                                 $tmp_data[
'name'] = 
$file;
 
  122                                 $this->client_ini[] = $tmp_data;
 
  132                 foreach($this->client_ini as $client_data)
 
  134                         include_once 
'./classes/class.ilIniFile.php';
 
  136                         $ini_file_obj =& 
new ilIniFile($client_data[
'path']);
 
  138                         $ini_file_obj->read();
 
  139                         $this->db_data = $ini_file_obj->readGroup(
'db');
 
  145                                 include_once 
'./setup/classes/class.ilCron.php';
 
  148                                 if($this->log[
'enabled'])
 
  150                                         $cron_obj->initLog($this->log[
'path'],$this->log[
'file'],$client_data[
'name']);
 
  159                                         include_once 
'./Services/Logging/classes/class.ilLog.php';
 
  161                                         $log =& 
new ilLog($this->log[
'path'],$this->log[
'file']);
 
  162                                         $log->write(
'Cron: Database not up to date. Aborting');
 
  164                                 $this->db->disconnect();
 
  171                 $dsn = $this->db_data[
'type'].
"://".
 
  172                         $this->db_data[
'user'].
":".
 
  173                         $this->db_data[
'pass'].
"@".
 
  174                         $this->db_data[
'host'].
"/".
 
  175                         $this->db_data[
'name'];
 
  189                 include_once 
'./Services/Administration/classes/class.ilSetting.php';
 
  200                 $db_version = $setting->get(
"db_version");
 
  202                 return $db_version == $this->file_version;
 
  207                 $this->db_version = 99999;
 
  210                 if(!$content = file(
'./setup/sql/dbupdate_02.php'))
 
  212                         echo 
'Cannot open ./setup/sql/dbupdate_02.php';
 
  215                 foreach($content as 
$row)
 
  217                         if(preg_match(
'/^<#([0-9]+)>/',$row,$matches))
 
  219                                 $this->file_version = $matches[1];
 
  226                 if($_SERVER[
'REQUEST_URI'])
 
  228                         if(!$this->web_enabled or (
$_GET[
'web_pass'] !== $this->web_pass))
 
  230                                 if($this->log[
'enabled'])
 
  232                                         include_once 
'./Services/Logging/classes/class.ilLog.php';
 
  234                                         $this->log =& 
new ilLog($this->log[
'path'],$this->log[
'file']);
 
  236                                         $this->log->write(
'Cron: __checkAccess() failed');