ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilCronClients Class Reference

Cron job class. More...

+ Inheritance diagram for ilCronClients:
+ Collaboration diagram for ilCronClients:

Public Member Functions

 ilCronClients ()
_getInstance ()
 __createLock ()
 _lockExists ()
 __readClients ()
 __startChecks ()
 __openDb ()
 __checkDBVersion ()
 __readFileDBVersion ()
 __checkAccess ()
 __ilCronClients ()
- Public Member Functions inherited from PEAR
 PEAR ($error_class=null)
 Constructor.
 _PEAR ()
 Destructor (the emulated type of...).
getStaticProperty ($class, $var)
 If you have a class that's mostly/entirely static, and you need static properties, you can use this method to simulate them.
 registerShutdownFunc ($func, $args=array())
 Use this function to register a shutdown method for static classes.
 isError ($data, $code=null)
 Tell whether a value is a PEAR error.
 setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled.
 expectError ($code= '*')
 This method is used to tell which errors you expect to get.
 popExpect ()
 This method pops one element off the expected error codes stack.
 _checkDelExpect ($error_code)
 This method checks unsets an error code if available.
 delExpect ($error_code)
 This method deletes all occurences of the specified element from the expected error codes stack.
raiseError ($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
 This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied.
throwError ($message=null, $code=null, $userinfo=null)
 Simpler form of raiseError with fewer options.
 staticPushErrorHandling ($mode, $options=null)
 staticPopErrorHandling ()
 pushErrorHandling ($mode, $options=null)
 Push a new error handler on top of the error handler options stack.
 popErrorHandling ()
 Pop the last error handler used.
 loadExtension ($ext)
 OS independant PHP extension load.

Data Fields

 $fp
- Data Fields inherited from PEAR
 $_debug = false
 $_default_error_mode = null
 $_default_error_options = null
 $_default_error_handler = ''
 $_error_class = 'PEAR_Error'
 $_expected_errors = array()

Detailed Description

Cron job class.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e
Version
Id:
class.ilCronClients.php 21365 2009-08-31 11:05:22Z smeyer

Definition at line 35 of file class.ilCronClients.php.

Member Function Documentation

ilCronClients::__checkAccess ( )

Definition at line 224 of file class.ilCronClients.php.

References $_GET, and exit.

Referenced by __readClients().

{
if($_SERVER['REQUEST_URI'])
{
if(!$this->web_enabled or ($_GET['web_pass'] !== $this->web_pass))
{
if($this->log['enabled'])
{
include_once './Services/Logging/classes/class.ilLog.php';
$this->log =& new ilLog($this->log['path'],$this->log['file']);
$this->log->write('Cron: __checkAccess() failed');
}
}
}
return true;
}

+ Here is the caller graph for this function:

ilCronClients::__checkDBVersion ( )

Definition at line 186 of file class.ilCronClients.php.

References $GLOBALS.

Referenced by __startChecks().

{
$GLOBALS["ilDB"] = $this->db;
include_once './Services/Administration/classes/class.ilSetting.php';
$setting = new ilSetting();
/*$query = "SELECT value FROM sett ings ".
"WHERE keyword = 'db_version'";
$res = $this->db->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$db_version = $row->value;
}*/
$db_version = $setting->get("db_version");
return $db_version == $this->file_version;
}

+ Here is the caller graph for this function:

ilCronClients::__createLock ( )

Definition at line 60 of file class.ilCronClients.php.

Referenced by ilCronClients().

{
$this->fp = @fopen('cron.lock','wb');
fwrite($this->fp,(string) time(),strlen((string) time()));
return true;
}

+ Here is the caller graph for this function:

ilCronClients::__ilCronClients ( )

Definition at line 247 of file class.ilCronClients.php.

{
fclose($this->fp);
}
ilCronClients::__openDb ( )

Definition at line 169 of file class.ilCronClients.php.

References MDB2\connect(), and MDB2\isError().

Referenced by __startChecks().

{
$dsn = $this->db_data['type']."://".
$this->db_data['user'].":".
$this->db_data['pass']."@".
$this->db_data['host']."/".
$this->db_data['name'];
$this->db = MDB2::connect($dsn,true);
if (MDB2::isError($this->db))
{
return false;
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCronClients::__readClients ( )

Definition at line 85 of file class.ilCronClients.php.

References $file, __checkAccess(), and __startChecks().

Referenced by ilCronClients().

{
include_once './classes/class.ilIniFile.php';
$ini_file_obj =& new ilIniFile(INI_FILE_PATH);
$ini_file_obj->read();
$this->log['enabled'] = $ini_file_obj->readVariable('log','enabled');
$this->log['path'] = $ini_file_obj->readVariable('log','path');
$this->log['file'] = $ini_file_obj->readVariable('log','file');
$this->web_enabled = $ini_file_obj->readVariable('cron','web_enabled');
$this->web_pass = $ini_file_obj->readVariable('cron','web_pass');
$this->__checkAccess();
$this->client_data = $ini_file_obj->readGroup('clients');
unset($ini_file_obj);
// open client.ini.php
// set path to directory where clients reside
$this->client_ini = array();
$dp = opendir('../'.$this->client_data['path']);
while(($file = readdir($dp)) !== false)
{
if($file == '.' or $file == '..' or $file == 'CVS')
{
continue;
}
if(@file_exists('../'.$this->client_data['path'].'/'.$file.'/'.$this->client_data['inifile']))
{
$tmp_data['path'] = '../'.$this->client_data['path'].'/'.$file.'/'.$this->client_data['inifile'];
$tmp_data['name'] = $file;
$this->client_ini[] = $tmp_data;
unset($tmp_data);
}
}
$this->__startChecks();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCronClients::__readFileDBVersion ( )

Definition at line 205 of file class.ilCronClients.php.

References $row.

Referenced by __startChecks().

{
$this->db_version = 99999;
// GET FILE VERSION
if(!$content = file('./setup/sql/dbupdate_02.php'))
{
echo 'Cannot open ./setup/sql/dbupdate_02.php';
return false;
}
foreach($content as $row)
{
if(preg_match('/^<#([0-9]+)>/',$row,$matches))
{
$this->file_version = $matches[1];
}
}
}

+ Here is the caller graph for this function:

ilCronClients::__startChecks ( )

Definition at line 130 of file class.ilCronClients.php.

References $cron_obj, $log, __checkDBVersion(), __openDb(), and __readFileDBVersion().

Referenced by __readClients().

{
foreach($this->client_ini as $client_data)
{
include_once './classes/class.ilIniFile.php';
$ini_file_obj =& new ilIniFile($client_data['path']);
$ini_file_obj->read();
$this->db_data = $ini_file_obj->readGroup('db');
if($this->__openDb())
{
include_once './setup/classes/class.ilCron.php';
$cron_obj =& new ilCron($this->db);
if($this->log['enabled'])
{
$cron_obj->initLog($this->log['path'],$this->log['file'],$client_data['name']);
}
if($this->__checkDBVersion())
{
$cron_obj->start();
}
else
{
include_once './Services/Logging/classes/class.ilLog.php';
$log =& new ilLog($this->log['path'],$this->log['file']);
$log->write('Cron: Database not up to date. Aborting');
}
$this->db->disconnect();
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

& ilCronClients::_getInstance ( )

Definition at line 51 of file class.ilCronClients.php.

References _lockExists(), and ilCronClients().

{
{
die('Instance already created');
}
return new ilCronClients();
}

+ Here is the call graph for this function:

ilCronClients::_lockExists ( )

Definition at line 68 of file class.ilCronClients.php.

References $fp.

Referenced by _getInstance().

{
if(@file_exists('cron.lock'))
{
$fp = fopen('cron.lock','r');
(int) $timest = fread($fp,filesize('cron.lock'));
if(!CRON_DEBUG and ($timest > time() - 60 * 60 * 12))
{
return true;
}
unlink('cron.lock');
}
return false;
}

+ Here is the caller graph for this function:

ilCronClients::ilCronClients ( )

Definition at line 40 of file class.ilCronClients.php.

References __createLock(), and __readClients().

Referenced by _getInstance().

{
define('INI_FILE_PATH','../ilias.ini.php');
define('CRON_DEBUG',1);
$this->__createLock();
$this->__readClients();
register_shutdown_function(array($this,'__ilCronClients'));
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilCronClients::$fp

Definition at line 37 of file class.ilCronClients.php.

Referenced by _lockExists().


The documentation for this class was generated from the following file: