ILIAS  Release_3_10_x_branch Revision 61812
 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 ()

Data Fields

 $fp

Detailed Description

Cron job class.

Author
Stefan Meyer smeye.nosp@m.r@da.nosp@m.tabay.nosp@m..de
Version
Id:
class.ilCronClients.php 15700 2008-01-09 12:30:37Z akill

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

Member Function Documentation

ilCronClients::__checkAccess ( )

Definition at line 222 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 189 of file class.ilCronClients.php.

References $res, and DB_FETCHMODE_OBJECT.

Referenced by __startChecks().

{
$query = "SELECT value FROM settings ".
"WHERE keyword = 'db_version'";
$res = $this->db->query($query);
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$db_version = $row->value;
}
return $db_version == $this->file_version;
}

+ Here is the caller graph for this function:

ilCronClients::__createLock ( )

Definition at line 63 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 245 of file class.ilCronClients.php.

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

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

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 caller graph for this function:

ilCronClients::__readClients ( )

Definition at line 88 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 203 of file class.ilCronClients.php.

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 133 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 './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 54 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 71 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 43 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 40 of file class.ilCronClients.php.

Referenced by _lockExists().


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