Dieser Commit ist enthalten in:
Ursprung
9608191e88
Commit
34cbb15b4f
8 geänderte Dateien mit 351 neuen und 324 gelöschten Zeilen
|
@ -1,55 +1,56 @@
|
|||
<?php
|
||||
/***************************************************************************
|
||||
|
||||
pseudo-cron v1.2.1.con // modified version for contenido
|
||||
(c) 2003 Kai Blankenhorn
|
||||
www.bitfolge.de/en
|
||||
kaib@bitfolge.de
|
||||
/* * *************************************************************************
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
pseudo-cron v1.2.1.con // modified version for contenido
|
||||
(c) 2003 Kai Blankenhorn
|
||||
www.bitfolge.de/en
|
||||
kaib@bitfolge.de
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
****************************************************************************
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
* ***************************************************************************
|
||||
|
||||
|
||||
Usually regular tasks like backup up the site's database are run using cron
|
||||
jobs. With cron jobs, you can exactly plan when a certain command is to be
|
||||
executed. But most homepage owners can't create cron jobs on their web
|
||||
server - providers demand some extra money for that.
|
||||
The only thing that's certain to happen quite regularly on a web page are
|
||||
page requests. This is where pseudo-cron comes into play: With every page
|
||||
request it checks if any cron jobs should have been run since the previous
|
||||
request. If there are, they are run and logged.
|
||||
Usually regular tasks like backup up the site's database are run using cron
|
||||
jobs. With cron jobs, you can exactly plan when a certain command is to be
|
||||
executed. But most homepage owners can't create cron jobs on their web
|
||||
server - providers demand some extra money for that.
|
||||
The only thing that's certain to happen quite regularly on a web page are
|
||||
page requests. This is where pseudo-cron comes into play: With every page
|
||||
request it checks if any cron jobs should have been run since the previous
|
||||
request. If there are, they are run and logged.
|
||||
|
||||
Pseudo-cron uses a syntax very much like the Unix cron's one. For an
|
||||
overview of the syntax used, see a page of the UNIXGEEKS. The syntax
|
||||
pseudo-cron uses is different from the one described on that page in
|
||||
the following points:
|
||||
Pseudo-cron uses a syntax very much like the Unix cron's one. For an
|
||||
overview of the syntax used, see a page of the UNIXGEEKS. The syntax
|
||||
pseudo-cron uses is different from the one described on that page in
|
||||
the following points:
|
||||
|
||||
- there is no user column
|
||||
- the executed command has to be an include()able file (which may contain further PHP code)
|
||||
|
||||
|
||||
All job definitions are made in a text file on the server with a
|
||||
user-definable name. A valid command line in this file is, for example:
|
||||
All job definitions are made in a text file on the server with a
|
||||
user-definable name. A valid command line in this file is, for example:
|
||||
|
||||
* 2 1,15 * * samplejob.inc.php
|
||||
* 2 1,15 * * samplejob.inc.php
|
||||
|
||||
This runs samplejob.inc.php at 2am on the 1st and 15th of each month.
|
||||
This runs samplejob.inc.php at 2am on the 1st and 15th of each month.
|
||||
|
||||
|
||||
Features:
|
||||
Features:
|
||||
- runs any PHP script
|
||||
- periodical or time-controlled script execution
|
||||
- logs all executed jobs
|
||||
|
@ -57,7 +58,7 @@ Features:
|
|||
- follow Unix cron syntax for crontabs
|
||||
|
||||
|
||||
Usage:
|
||||
Usage:
|
||||
- Modify the variables in the config section below to match your server.
|
||||
- Write a PHP script that does the job you want to be run regularly. Be
|
||||
sure that any paths in it are relative to the script that will run
|
||||
|
@ -66,33 +67,33 @@ Usage:
|
|||
- Wait for the next scheduled run :)
|
||||
|
||||
|
||||
Note:
|
||||
You can log messages to pseudo-cron's log file by calling
|
||||
Note:
|
||||
You can log messages to pseudo-cron's log file by calling
|
||||
logMessage("log a message", $PC_writeDir, $PC_useLog, $PC_debug);
|
||||
|
||||
|
||||
Changelog:
|
||||
Changelog:
|
||||
|
||||
v1.2.1.con 11-28-03
|
||||
v1.2.1.con 11-28-03
|
||||
changed: removed all global variables
|
||||
changed: renamed intern variables
|
||||
changed: intern function calls
|
||||
changed: extended debug information
|
||||
modified by horwath@opensa.org
|
||||
|
||||
v1.2.1 02-03-03
|
||||
v1.2.1 02-03-03
|
||||
fixed: jobs may be run too often under certain conditions
|
||||
added: global debug switch
|
||||
changed: typo in imagecron.php which prevented it from working
|
||||
|
||||
|
||||
v1.2 01-31-03
|
||||
v1.2 01-31-03
|
||||
added: more documentation
|
||||
changed: log file should now be easier to use
|
||||
changed: log file name
|
||||
|
||||
|
||||
v1.1 01-29-03
|
||||
v1.1 01-29-03
|
||||
changed: renamed pseudo-cron.php to pseudo-cron.inc.php
|
||||
fixed: comments at the end of a line don't work
|
||||
fixed: empty lines in crontab file create nonsense jobs
|
||||
|
@ -101,37 +102,31 @@ v1.1 01-29-03
|
|||
added: day of week abbreviations may now be used (three letters, english)
|
||||
|
||||
|
||||
v1.0 01-17-03
|
||||
v1.0 01-17-03
|
||||
inital release
|
||||
|
||||
***************************************************************************/
|
||||
* ************************************************************************* */
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
if (!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
|
||||
/****************************************/
|
||||
/* * ************************************* */
|
||||
/* config section */
|
||||
/****************************************/
|
||||
/* * ************************************* */
|
||||
|
||||
// || PLEASE NOTE:
|
||||
// || all paths used here and in cron scripts
|
||||
// || must be absolute or relative to the script which includes pseudo-cron.inc.php!
|
||||
|
||||
// the file that contains the job descriptions
|
||||
// for a description of the format, see http://www.unixgeeks.org/security/newbie/unix/cron-1.html
|
||||
// and http://www.bitfolge.de/pseudocron
|
||||
$PC_cronTab = $cfg["path"]["contenido"].$cfg['path']['cronjobs']."crontab.txt";
|
||||
$PC_localCronTab = $cfg["path"]["contenido"].$cfg['path']['cronjobs']."crontab.local.txt";
|
||||
$PC_cronTab = $cfg['path']['conlite_cronlog'] . "crontab.txt";
|
||||
$PC_localCronTab = $cfg['path']['conlite_cronlog'] . "crontab.local.txt";
|
||||
|
||||
// the directory where the script can store information on completed jobs and its log file
|
||||
// include trailing slash
|
||||
$PC_writeDir = $cfg["path"]["contenido"].$cfg['path']['cronjobs'];
|
||||
|
||||
// the directory where the script can store information on completed jobs and its log file
|
||||
// include trailing slash
|
||||
$PC_jobDir = $cfg["path"]["contenido"].$cfg['path']['cronjobs'];
|
||||
$PC_writeDir = $cfg['path']['conlite_cronlog'];
|
||||
$PC_jobDir = $cfg['path']['conlite'] . $cfg['path']['cronjobs'];
|
||||
|
||||
// store directory information
|
||||
$PC_reqDir = getcwd();
|
||||
|
@ -143,9 +138,9 @@ $PC_useLog = 1;
|
|||
// DO NOT use this on live servers!
|
||||
$PC_debug = false;
|
||||
|
||||
/****************************************/
|
||||
/* * ************************************* */
|
||||
/* don't change anything here */
|
||||
/****************************************/
|
||||
/* * ************************************* */
|
||||
|
||||
define("PC_MINUTE", 1);
|
||||
define("PC_HOUR", 2);
|
||||
|
@ -157,11 +152,11 @@ define("PC_CRONLINE", 8);
|
|||
|
||||
if ($PC_debug) {
|
||||
echo "<pre>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 "\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";
|
||||
}
|
||||
|
||||
|
@ -172,71 +167,63 @@ $bJobRunned = false;
|
|||
chdir($PC_jobDir);
|
||||
$PC_jobs = parseCronFile($PC_cronTab, $PC_debug);
|
||||
|
||||
for ($i=0;$i<count($PC_jobs);$i++) {
|
||||
for ($i = 0; $i < count($PC_jobs); $i++) {
|
||||
$bJobRunned = true;
|
||||
runJob($PC_jobs[$i], $PC_jobDir, $PC_writeDir, $PC_useLog, $PC_debug);
|
||||
}
|
||||
|
||||
$PC_jobs = parseCronFile($PC_localCronTab, $PC_debug);
|
||||
for ($i=0;$i<count($PC_jobs);$i++) {
|
||||
for ($i = 0; $i < count($PC_jobs); $i++) {
|
||||
$bJobRunned = true;
|
||||
runJob($PC_jobs[$i], $PC_jobDir, $PC_writeDir, $PC_useLog, $PC_debug);
|
||||
}
|
||||
chdir($PC_reqDir);
|
||||
|
||||
if ($PC_debug) echo "\n</pre>";
|
||||
|
||||
if ($PC_debug)
|
||||
echo "\n</pre>";
|
||||
|
||||
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);
|
||||
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<count($subelements);$i++) {
|
||||
if (preg_match("~^(\\*|([0-9]{1,2})(-([0-9]{1,2}))?)(/([0-9]{1,2}))?$~",$subelements[$i],$matches)) {
|
||||
if ($matches[1]=="*") {
|
||||
for ($i = 0; $i < count($subelements); $i++) {
|
||||
if (preg_match("~^(\\*|([0-9]{1,2})(-([0-9]{1,2}))?)(/([0-9]{1,2}))?$~", $subelements[$i], $matches)) {
|
||||
if ($matches[1] == "*") {
|
||||
$matches[2] = 0; // from
|
||||
$matches[4] = $numberOfElements; //to
|
||||
} elseif (!array_key_exists(4,$matches) || $matches[4]=="") {
|
||||
} elseif (!array_key_exists(4, $matches) || $matches[4] == "") {
|
||||
$matches[4] = $matches[2];
|
||||
}
|
||||
if (array_key_exists(5, $matches))
|
||||
{
|
||||
if ($matches[5][0]!="/") {
|
||||
if (array_key_exists(5, $matches)) {
|
||||
if ($matches[5][0] != "/") {
|
||||
$matches[6] = 1; // step
|
||||
}
|
||||
} else {
|
||||
$matches[6] = 1; // step
|
||||
}
|
||||
for ($j=lTrimZeros($matches[2]);$j<=lTrimZeros($matches[4]);$j+=lTrimZeros($matches[6])) {
|
||||
for ($j = lTrimZeros($matches[2]); $j <= lTrimZeros($matches[4]); $j += lTrimZeros($matches[6])) {
|
||||
$targetArray[$j] = TRUE;
|
||||
}
|
||||
}
|
||||
|
@ -245,22 +232,23 @@ function parseElement($element, &$targetArray, $numberOfElements) {
|
|||
|
||||
function decDate(&$dateArr, $amount, $unit, $PC_debug) {
|
||||
|
||||
if ($PC_debug) echo sprintf("Decreasing from %02d.%02d. %02d:%02d by %d %6s ",$dateArr[mday],$dateArr[mon],$dateArr[hours],$dateArr[minutes],$amount,$unit);
|
||||
if ($unit=="mday") {
|
||||
if ($PC_debug)
|
||||
echo sprintf("Decreasing from %02d.%02d. %02d:%02d by %d %6s ", $dateArr[mday], $dateArr[mon], $dateArr[hours], $dateArr[minutes], $amount, $unit);
|
||||
if ($unit == "mday") {
|
||||
$dateArr["hours"] = 23;
|
||||
$dateArr["minutes"] = 59;
|
||||
$dateArr["seconds"] = 59;
|
||||
$dateArr["mday"] -= $amount;
|
||||
$dateArr["wday"] -= $amount % 7;
|
||||
if ($dateArr["wday"]<0) {
|
||||
$dateArr["wday"]+=7;
|
||||
if ($dateArr["wday"] < 0) {
|
||||
$dateArr["wday"] += 7;
|
||||
}
|
||||
if ($dateArr["mday"]<1) {
|
||||
$dateArr["mon"]--;
|
||||
if ($dateArr["mday"] < 1) {
|
||||
$dateArr["mon"] --;
|
||||
switch ($dateArr["mon"]) {
|
||||
case 0:
|
||||
$dateArr["mon"] = 12;
|
||||
$dateArr["year"]--;
|
||||
$dateArr["year"] --;
|
||||
// fall through
|
||||
case 1:
|
||||
case 3:
|
||||
|
@ -282,23 +270,24 @@ function decDate(&$dateArr, $amount, $unit, $PC_debug) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
} elseif ($unit=="hour") {
|
||||
if ($dateArr["hours"]==0) {
|
||||
decDate($dateArr, 1, "mday",$PC_debug);
|
||||
} elseif ($unit == "hour") {
|
||||
if ($dateArr["hours"] == 0) {
|
||||
decDate($dateArr, 1, "mday", $PC_debug);
|
||||
} else {
|
||||
$dateArr["minutes"] = 59;
|
||||
$dateArr["seconds"] = 59;
|
||||
$dateArr["hours"]--;
|
||||
$dateArr["hours"] --;
|
||||
}
|
||||
} elseif ($unit=="minute") {
|
||||
if ($dateArr["minutes"]==0) {
|
||||
decDate($dateArr, 1, "hour",$PC_debug);
|
||||
} elseif ($unit == "minute") {
|
||||
if ($dateArr["minutes"] == 0) {
|
||||
decDate($dateArr, 1, "hour", $PC_debug);
|
||||
} else {
|
||||
$dateArr["seconds"] = 59;
|
||||
$dateArr["minutes"]--;
|
||||
$dateArr["minutes"] --;
|
||||
}
|
||||
}
|
||||
if ($PC_debug) echo sprintf("to %02d.%02d. %02d:%02d\n",$dateArr[mday],$dateArr[mon],$dateArr[hours],$dateArr[minutes]);
|
||||
if ($PC_debug)
|
||||
echo sprintf("to %02d.%02d. %02d:%02d\n", $dateArr[mday], $dateArr[mon], $dateArr[hours], $dateArr[minutes]);
|
||||
}
|
||||
|
||||
function getLastScheduledRunTime($job, $PC_debug) {
|
||||
|
@ -306,37 +295,34 @@ function getLastScheduledRunTime($job, $PC_debug) {
|
|||
$dateArr = getdate();
|
||||
$minutesBack = 0;
|
||||
while (
|
||||
$minutesBack<525600 AND
|
||||
(!$job[PC_MINUTE][$dateArr["minutes"]] OR
|
||||
!$job[PC_HOUR][$dateArr["hours"]] OR
|
||||
(!$job[PC_DOM][$dateArr["mday"]] OR !$job[PC_DOW][$dateArr["wday"]]) OR
|
||||
!$job[PC_MONTH][$dateArr["mon"]])
|
||||
$minutesBack < 525600 AND ( !$job[PC_MINUTE][$dateArr["minutes"]] OR ! $job[PC_HOUR][$dateArr["hours"]] OR ( !$job[PC_DOM][$dateArr["mday"]] OR ! $job[PC_DOW][$dateArr["wday"]]) OR ! $job[PC_MONTH][$dateArr["mon"]])
|
||||
) {
|
||||
if (!$job[PC_DOM][$dateArr["mday"]] OR !$job[PC_DOW][$dateArr["wday"]]) {
|
||||
decDate($dateArr,1,"mday",$PC_debug);
|
||||
$minutesBack+=1440;
|
||||
if (!$job[PC_DOM][$dateArr["mday"]] OR ! $job[PC_DOW][$dateArr["wday"]]) {
|
||||
decDate($dateArr, 1, "mday", $PC_debug);
|
||||
$minutesBack += 1440;
|
||||
continue;
|
||||
}
|
||||
if (!$job[PC_HOUR][$dateArr["hours"]]) {
|
||||
decDate($dateArr,1,"hour",$PC_debug);
|
||||
$minutesBack+=60;
|
||||
decDate($dateArr, 1, "hour", $PC_debug);
|
||||
$minutesBack += 60;
|
||||
continue;
|
||||
}
|
||||
if (!$job[PC_MINUTE][$dateArr["minutes"]]) {
|
||||
decDate($dateArr,1,"minute",$PC_debug);
|
||||
decDate($dateArr, 1, "minute", $PC_debug);
|
||||
$minutesBack++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ($PC_debug) print_r($dateArr);
|
||||
if ($PC_debug)
|
||||
print_r($dateArr);
|
||||
|
||||
return mktime($dateArr["hours"],$dateArr["minutes"],0,$dateArr["mon"],$dateArr["mday"],$dateArr["year"]);
|
||||
return mktime($dateArr["hours"], $dateArr["minutes"], 0, $dateArr["mon"], $dateArr["mday"], $dateArr["year"]);
|
||||
}
|
||||
|
||||
function getJobFileName($jobname, $PC_writeDir) {
|
||||
|
||||
$jobfile = $PC_writeDir.urlencode($jobname).".job";
|
||||
$jobfile = $PC_writeDir . urlencode($jobname) . ".job";
|
||||
return $jobfile;
|
||||
}
|
||||
|
||||
|
@ -344,8 +330,8 @@ function getLastActialRunTime($jobname, $PC_writeDir) {
|
|||
|
||||
$jobfile = getJobFileName($jobname, $PC_writeDir);
|
||||
if (file_exists($jobfile)) {
|
||||
$file = fopen($jobfile,"rb");
|
||||
$lastRun = fgets($file,100);
|
||||
$file = fopen($jobfile, "rb");
|
||||
$lastRun = fgets($file, 100);
|
||||
fclose($file);
|
||||
if (is_numeric($lastRun)) {
|
||||
return $lastRun;
|
||||
|
@ -354,23 +340,21 @@ function getLastActialRunTime($jobname, $PC_writeDir) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
function markLastRun($jobname, $lastRun, $PC_writeDir)
|
||||
{
|
||||
function markLastRun($jobname, $lastRun, $PC_writeDir) {
|
||||
|
||||
$jobfile = getJobFileName($jobname, $PC_writeDir);
|
||||
|
||||
if ($file = @fopen($jobfile,"w"))
|
||||
{
|
||||
fputs($file,$lastRun);
|
||||
if ($file = @fopen($jobfile, "w")) {
|
||||
fputs($file, $lastRun);
|
||||
fclose($file);
|
||||
} else {
|
||||
//echo "Could not write into file $jobfile - permission denied.";
|
||||
}
|
||||
}
|
||||
|
||||
function runJob($job, $PC_jobDir, $PC_writeDir, $PC_useLog, $PC_debug=false) {
|
||||
global $cfg, $sess;
|
||||
if(!is_writable($PC_writeDir)) {
|
||||
function runJob($job, $PC_jobDir, $PC_writeDir, $PC_useLog, $PC_debug = false) {
|
||||
global $cfg, $sess, $PC_logDir;
|
||||
if (!is_writable($PC_writeDir)) {
|
||||
return false;
|
||||
}
|
||||
$extjob = Array();
|
||||
|
@ -384,34 +368,34 @@ function runJob($job, $PC_jobDir, $PC_writeDir, $PC_useLog, $PC_debug=false) {
|
|||
$lastActual = getLastActialRunTime($job[PC_CMD], $PC_writeDir);
|
||||
$lastScheduled = getLastScheduledRunTime($extjob, $PC_debug);
|
||||
|
||||
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);
|
||||
//echo "LastSch: " . $lastScheduled . " ::: LastAct: " . $lastActual . "\n";
|
||||
|
||||
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
|
||||
include($PC_jobDir . $job[PC_CMD]); // display errors only when debugging
|
||||
} else {
|
||||
if (is_object($sess))
|
||||
{
|
||||
if (is_object($sess)) {
|
||||
$sess->freeze();
|
||||
}
|
||||
@include($PC_jobDir.$job[PC_CMD]); // any error messages are supressed
|
||||
if (is_object($sess))
|
||||
{
|
||||
@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);
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
@ -422,26 +406,69 @@ function parseCronFile($PC_cronTabFile, $PC_debug) {
|
|||
$file = @file($PC_cronTabFile);
|
||||
$job = Array();
|
||||
$jobs = Array();
|
||||
for ($i=0;$i<count($file);$i++) {
|
||||
if ($file[$i][0]!='#') {
|
||||
for ($i = 0; $i < count($file); $i++) {
|
||||
if ($file[$i][0] != '#') {
|
||||
// old regex, without dow abbreviations:
|
||||
// if (preg_match("~^([-0-9,/*]+)\\s+([-0-9,/*]+)\\s+([-0-9,/*]+)\\s+([-0-9,/*]+)\\s+([-0-7,/*]+|Sun|Mon|Tue|Wen|Thu|Fri|Sat)\\s+([^#]*)(#.*)?$~i",$file[$i],$job)) {
|
||||
if (preg_match("~^([-0-9,/*]+)\\s+([-0-9,/*]+)\\s+([-0-9,/*]+)\\s+([-0-9,/*]+)\\s+([-0-7,/*]+|(-|/|Sun|Mon|Tue|Wed|Thu|Fri|Sat)+)\\s+([^#]*)(#.*)?$~i",$file[$i],$job)) {
|
||||
if (preg_match("~^([-0-9,/*]+)\\s+([-0-9,/*]+)\\s+([-0-9,/*]+)\\s+([-0-9,/*]+)\\s+([-0-7,/*]+|(-|/|Sun|Mon|Tue|Wed|Thu|Fri|Sat)+)\\s+([^#]*)(#.*)?$~i", $file[$i], $job)) {
|
||||
$jobNumber = count($jobs);
|
||||
$jobs[$jobNumber] = $job;
|
||||
if ($jobs[$jobNumber][PC_DOW][0]!='*' AND !is_numeric($jobs[$jobNumber][PC_DOW])) {
|
||||
if ($jobs[$jobNumber][PC_DOW][0] != '*' AND ! is_numeric($jobs[$jobNumber][PC_DOW])) {
|
||||
$jobs[$jobNumber][PC_DOW] = str_replace(
|
||||
Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat"),
|
||||
Array(0,1,2,3,4,5,6),
|
||||
$jobs[$jobNumber][PC_DOW]);
|
||||
Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"), Array(0, 1, 2, 3, 4, 5, 6), $jobs[$jobNumber][PC_DOW]);
|
||||
}
|
||||
$jobs[$jobNumber][PC_CMD] = trim($job[PC_CMD]);
|
||||
$jobs[$jobNumber][PC_CRONLINE] = $file[$i];
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($PC_debug) var_dump($jobs);
|
||||
if ($PC_debug)
|
||||
var_dump($jobs);
|
||||
return $jobs;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
|
@ -71,7 +71,7 @@ if (!defined('CL_ENVIRONMENT')) {
|
|||
*/
|
||||
if (!defined('CL_VERSION')) {
|
||||
|
||||
define('CL_VERSION', '2.0.0RC3');
|
||||
define('CL_VERSION', '2.0.1');
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
[Dolphin]
|
||||
Timestamp=2016,9,20,14,43,24
|
||||
Version=3
|
||||
ViewMode=1
|
|
@ -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? */
|
||||
|
|
|
@ -55,14 +55,14 @@ $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']['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_cronlog'] = $cfg['path']['frontend']. '/' .$cfg['path']['cronlog'];
|
||||
//$cfg['path']['conlite_locale'] = $cfg['path']['frontend']. '/' .$cfg['path']['locale'];
|
||||
|
||||
$cfg['path']['repository'] = $cfg["path"]['plugins'] . 'repository/';
|
||||
|
|
4
trunk/data/cronlog/index.php
Normale Datei
4
trunk/data/cronlog/index.php
Normale Datei
|
@ -0,0 +1,4 @@
|
|||
<?php
|
||||
header("Location:/index.php");
|
||||
exit;
|
||||
?>
|
Laden …
In neuem Issue referenzieren