diff --git a/conlite/includes/pseudo-cron.inc.php b/conlite/includes/pseudo-cron.inc.php index 9187c53..a57981c 100644 --- a/conlite/includes/pseudo-cron.inc.php +++ b/conlite/includes/pseudo-cron.inc.php @@ -1,55 +1,56 @@ Configuration:"; - echo "\nPC_cronTab = ".$PC_cronTab; - echo "\nPC_writeDir = ".$PC_writeDir; - echo "\nPC_jobDir = ".$PC_jobDir; - echo "\nPC_reqDir = ".$PC_reqDir; - echo "\nPC_useLog = ".$PC_useLog; - echo "\n"; + echo "
Configuration:";
+    echo "\nPC_cronTab = " . $PC_cronTab;
+    echo "\nPC_writeDir = " . $PC_writeDir;
+    echo "\nPC_jobDir = " . $PC_jobDir;
+    echo "\nPC_reqDir = " . $PC_reqDir;
+    echo "\nPC_useLog = " . $PC_useLog;
+    echo "\n";
 }
 
 global $bJobRunned;
@@ -172,276 +167,308 @@ $bJobRunned = false;
 chdir($PC_jobDir);
 $PC_jobs = parseCronFile($PC_cronTab, $PC_debug);
 
-for ($i=0;$i";
-
+if ($PC_debug)
+    echo "\n
"; function logMessage($msg, $PC_writeDir, $PC_useLog, $PC_debug) { + $oCronLog = new cCronJob(); + $oCronLog->useCronLog($PC_useLog); + $oCronLog->logMessages($msg); + unset($oCronLog); - if ($PC_useLog==1) { - $logfile = $PC_writeDir."pseudo-cron.log"; - - if (is_writable($logfile)) - { - $file = fopen($logfile,"ab"); - if ($msg[strlen($msg)-1]!="\n") { - $msg.="\r\n"; - } - if ($PC_debug) echo $msg; - fputs($file,date("r",time())." ".$msg); - fclose($file); - } - } + if ($PC_debug) { + echo $msg; + } } function lTrimZeros($number) { - while ($number[0]=='0') { - $number = substr($number,1); - } - return $number; + while ($number[0] == '0') { + $number = substr($number, 1); + } + return $number; } function parseElement($element, &$targetArray, $numberOfElements) { - $subelements = explode(",",$element); - for ($i=0;$i<$numberOfElements;$i++) { - $targetArray[$i] = $subelements[0]=="*"; - } + $subelements = explode(",", $element); + for ($i = 0; $i < $numberOfElements; $i++) { + $targetArray[$i] = $subelements[0] == "*"; + } - for ($i=0;$i$lastActual) { - logMessage("Running ".$job[PC_CRONLINE], $PC_writeDir, $PC_useLog, $PC_debug); - logMessage(" Last run: ".date("r",$lastActual), $PC_writeDir, $PC_useLog, $PC_debug); - logMessage(" Last scheduled: ".date("r",$lastScheduled), $PC_writeDir, $PC_useLog, $PC_debug); - markLastRun($job[PC_CMD], $lastScheduled, $PC_writeDir); + //echo "LastSch: " . $lastScheduled . " ::: LastAct: " . $lastActual . "\n"; - if ($PC_debug) { - echo getcwd(); - include($PC_jobDir.$job[PC_CMD]); // display errors only when debugging - } else { - if (is_object($sess)) - { - $sess->freeze(); - } - @include($PC_jobDir.$job[PC_CMD]); // any error messages are supressed - if (is_object($sess)) - { - $sess->thaw(); - } - } - logMessage("Completed ".$job[PC_CRONLINE], $PC_writeDir, $PC_useLog, $PC_debug); - return true; - } else { - if ($PC_debug) { - logMessage("Skipping ".$job[PC_CRONLINE], $PC_writeDir, $PC_useLog, $PC_debug); - logMessage(" Last run: ".date("r",$lastActual), $PC_writeDir, $PC_useLog, $PC_debug); - logMessage(" Last scheduled: ".date("r",$lastScheduled), $PC_writeDir, $PC_useLog, $PC_debug); - logMessage("Completed ".$job[PC_CRONLINE], $PC_writeDir, $PC_useLog, $PC_debug); - } - return false; - } + if ($lastScheduled > $lastActual) { + logMessage("Running " . $job[PC_CRONLINE], $PC_writeDir, $PC_useLog, $PC_debug); + logMessage(" Last run: " . date("r", $lastActual), $PC_writeDir, $PC_useLog, $PC_debug); + logMessage(" Last scheduled: " . date("r", $lastScheduled), $PC_writeDir, $PC_useLog, $PC_debug); + markLastRun($job[PC_CMD], $lastScheduled, $PC_writeDir); + + if ($PC_debug) { + echo getcwd(); + include($PC_jobDir . $job[PC_CMD]); // display errors only when debugging + } else { + if (is_object($sess)) { + $sess->freeze(); + } + @include($PC_jobDir . $job[PC_CMD]); // any error messages are supressed + if (is_object($sess)) { + $sess->thaw(); + } + } + logMessage("Completed " . $job[PC_CRONLINE], $PC_writeDir, $PC_useLog, $PC_debug); + return true; + } else { + if ($PC_debug) { + logMessage("Skipping " . $job[PC_CRONLINE], $PC_writeDir, $PC_useLog, $PC_debug); + logMessage(" Last run: " . date("r", $lastActual), $PC_writeDir, $PC_useLog, $PC_debug); + logMessage(" Last scheduled: " . date("r", $lastScheduled), $PC_writeDir, $PC_useLog, $PC_debug); + logMessage("Completed " . $job[PC_CRONLINE], $PC_writeDir, $PC_useLog, $PC_debug); + } + return false; + } } function parseCronFile($PC_cronTabFile, $PC_debug) { - $file = @file($PC_cronTabFile); - $job = Array(); - $jobs = Array(); - for ($i=0;$i +class cCronJob { + + protected $_sCronTabFileName = "crontab.txt"; + protected $_sCronTabLocalFileName = "crontab.local.txt"; + protected $_sLogFileName = "pseudo-cron.log"; + protected $_sJobDir; + protected $_sCronDir; + protected $_sLogDir; + private $_bUseLog; + + public function __construct() { + $this->_sJobDir = cRegistry::getConfigValue('path', 'conlite') . cRegistry::getConfigValue('path', 'cronjobs'); + $this->_sCronDir = cRegistry::getConfigValue('path', 'conlite_cronlog'); + $this->_sLogDir = cRegistry::getConfigValue('path', 'conlite_logs'); + } + + public function runJob() { + + } + + public function useCronLog($bUse = TRUE) { + $this->_bUseLog = boolval($bUse); + } + + public function logMessages($sMsg) { + if (!$this->_bUseLog) { + return; + } + if (is_dir($this->_sLogDir) && is_writable($this->_sLogDir)) { + $logfile = $this->_sLogDir . $this->_sLogFileName; + } else if (is_dir($this->_sCronDir) && is_writable($this->_sCronDir)) { + $logfile = $this->_sCronDir . $this->_sLogFileName; + } else { + cWarning(__FILE__, __LINE__, "PseudoCron: Cannot write cronlog file!"); + return; + } + + if ($sMsg[strlen($sMsg) - 1] != "\n") { + $sMsg .= "\r\n"; + } + file_put_contents($logfile, $sMsg, FILE_APPEND); + } + +} +?> \ No newline at end of file diff --git a/conlite/includes/startup.php b/conlite/includes/startup.php index 0391f1b..bec43d0 100644 --- a/conlite/includes/startup.php +++ b/conlite/includes/startup.php @@ -71,7 +71,7 @@ if (!defined('CL_ENVIRONMENT')) { */ if (!defined('CL_VERSION')) { - define('CL_VERSION', '2.0.0RC3'); + define('CL_VERSION', '2.0.1'); } diff --git a/conlite/main.php b/conlite/main.php index b2a8be7..5dcd6a6 100644 --- a/conlite/main.php +++ b/conlite/main.php @@ -64,7 +64,7 @@ cInclude ("includes", 'cfg_language_de.inc.php'); if ($cfg["use_pseudocron"] == true) { /* Include cronjob-Emulator, but only for frame 1 */ - if($frame == 1) { + if($frame == 4) { $sess->freeze(); $oldpwd = getcwd(); diff --git a/data/.directory b/data/.directory deleted file mode 100644 index 6d9ec88..0000000 --- a/data/.directory +++ /dev/null @@ -1,4 +0,0 @@ -[Dolphin] -Timestamp=2016,9,20,14,43,24 -Version=3 -ViewMode=1 diff --git a/data/config/production/config.misc.php b/data/config/production/config.misc.php index 020e4f1..60f3119 100644 --- a/data/config/production/config.misc.php +++ b/data/config/production/config.misc.php @@ -47,7 +47,7 @@ $cfg['datetag'] = '$Date: 2015-11-09 22:02:55 +0100 (Mon, 09 Nov 2015) $'; /* Backend timeout */ $cfg["backend"]["timeout"] = 60; -$cfg["develop"]["show_errors"] = true; +$cfg["develop"]["show_errors"] = false; $cfg["develop"]["show_deprecated"] = false; /* Use Pseudo-Cron? */ diff --git a/data/config/production/config.path.php b/data/config/production/config.path.php index 887e166..49a7d93 100644 --- a/data/config/production/config.path.php +++ b/data/config/production/config.path.php @@ -54,15 +54,15 @@ $cfg['path']['temp'] = $cfg['path']['data'].'temp/'; $cfg['path']['cache'] = $cfg['path']['data'].'cache/'; $cfg['path']['config'] = $cfg['path']['data'].'config/'; $cfg['path']['logs'] = $cfg['path']['data'].'logs/'; -$cfg['path']['backup'] = $cfg['path']['data'].'backup/'; -//$cfg['path']['cronlog'] = $cfg['path']['data'].'cronlog/'; +$cfg['path']['backup'] = $cfg['path']['data'].'backup/'; +$cfg['path']['cronlog'] = $cfg['path']['data'].'cronlog/'; //$cfg['path']['locale'] = $cfg['path']['data'].'locale/'; $cfg['path']['conlite_temp'] = $cfg['path']['frontend']. '/' .$cfg['path']['temp']; $cfg['path']['conlite_cache'] = $cfg['path']['frontend']. '/' .$cfg['path']['cache']; $cfg['path']['conlite_logs'] = $cfg['path']['frontend']. '/' .$cfg['path']['logs']; -$cfg['path']['conlite_backup'] = $cfg['path']['frontend']. '/' .$cfg['path']['backup']; -//$cfg['path']['conlite_cronlog'] = $cfg['path']['frontend']. '/' .$cfg['path']['cronlog']; +$cfg['path']['conlite_backup'] = $cfg['path']['frontend']. '/' .$cfg['path']['backup']; +$cfg['path']['conlite_cronlog'] = $cfg['path']['frontend']. '/' .$cfg['path']['cronlog']; //$cfg['path']['conlite_locale'] = $cfg['path']['frontend']. '/' .$cfg['path']['locale']; $cfg['path']['repository'] = $cfg["path"]['plugins'] . 'repository/'; diff --git a/conlite/cronjobs/crontab.txt b/data/cronlog/crontab.txt similarity index 100% rename from conlite/cronjobs/crontab.txt rename to data/cronlog/crontab.txt diff --git a/data/cronlog/index.php b/data/cronlog/index.php new file mode 100644 index 0000000..ef8b776 --- /dev/null +++ b/data/cronlog/index.php @@ -0,0 +1,4 @@ +