geocache scheduled publishing and auto-archiving improvements
- set user ID for status-change logging when running cron/publish_caces - discarded obsolete lib1 cache publishing code - separate enable/disable settings for auto-archive cronjob - fixed auto-archive threshold for leap years (message is "was disabled > 1 year")
This commit is contained in:
@@ -173,7 +173,7 @@
|
||||
sql("ALTER TABLE `cache_reports` ADD INDEX `userid` (`userid`)");
|
||||
}
|
||||
|
||||
function dbv_108() // automatic email-bounce processiong
|
||||
function dbv_108() // automatic email-bounce processing
|
||||
{
|
||||
if (!sql_field_exists('user','last_email_problem'))
|
||||
sql("ALTER TABLE `user` ADD COLUMN `last_email_problem` datetime default NULL AFTER `email_problems`");
|
||||
@@ -181,7 +181,7 @@
|
||||
sql("ALTER TABLE `user` ADD COLUMN `mailing_problems` int(10) unsigned NOT NULL default '0' AFTER `last_email_problem`");
|
||||
}
|
||||
|
||||
function dbv_109() // improved email-bounce processiong
|
||||
function dbv_109() // improved email-bounce processing
|
||||
{
|
||||
if (!sql_field_exists('user','first_email_problem'))
|
||||
sql("ALTER TABLE `user` ADD COLUMN `first_email_problem` date default NULL AFTER `email_problems`");
|
||||
|
@@ -368,9 +368,10 @@
|
||||
// fill_gaps = false: continue with the last waypoint
|
||||
$opt['logic']['waypoint_pool']['fill_gaps'] = false;
|
||||
|
||||
/* Automatic system user actions
|
||||
/* Username for cronjobs or CLI tools
|
||||
* is used e.g. for cache auto-archiving and auto-publishing
|
||||
*/
|
||||
$opt['logic']['systemuser']['user'] = ''; // enter an active username to enable auto archiving
|
||||
$opt['logic']['systemuser']['user'] = '';
|
||||
|
||||
/* Purge log files - age in days (0 = keep infinite)
|
||||
*/
|
||||
@@ -437,10 +438,11 @@
|
||||
$opt['cron']['sitemaps']['generate'] = true;
|
||||
$opt['cron']['sitemaps']['submit'] = false;
|
||||
|
||||
/* Geokret cronjob
|
||||
/* other cronjobs
|
||||
*/
|
||||
|
||||
$opt['cron']['geokrety']['run'] = true;
|
||||
$opt['cron']['autoarchive']['run'] = false;
|
||||
|
||||
/* E-Mail settings
|
||||
*
|
||||
|
@@ -341,5 +341,10 @@ class login
|
||||
|
||||
return ($this->admin & $privilege) == $privilege;
|
||||
}
|
||||
|
||||
function logged_in()
|
||||
{
|
||||
return $this->userid > 0;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -1,4 +0,0 @@
|
||||
<FilesMatch "*">
|
||||
Order Deny,Allow
|
||||
Deny from All
|
||||
</FilesMatch>
|
@@ -1,60 +0,0 @@
|
||||
#!/usr/local/bin/php -q
|
||||
<?php
|
||||
/***************************************************************************
|
||||
./util/publish_caches/run_publish.php
|
||||
-------------------
|
||||
begin : Sat September 2 2006
|
||||
|
||||
For license information see doc/license.txt
|
||||
****************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
Unicode Reminder メモ
|
||||
|
||||
Ggf. muss die Location des php-Binaries angepasst werden.
|
||||
|
||||
Prueft auf wartende Caches, deren Veröffentlichungszeitpunkt
|
||||
gekommen ist und veröffentlicht sie.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
$rootpath = '../../';
|
||||
|
||||
// chdir to proper directory (needed for cronjobs)
|
||||
chdir(substr(realpath($_SERVER['PHP_SELF']), 0, strrpos(realpath($_SERVER['PHP_SELF']), '/')));
|
||||
|
||||
require_once($rootpath . 'lib/clicompatbase.inc.php');
|
||||
require_once('settings.inc.php');
|
||||
require_once($rootpath . 'lib/eventhandler.inc.php');
|
||||
|
||||
/* begin db connect */
|
||||
db_connect();
|
||||
if ($dblink === false)
|
||||
{
|
||||
echo 'Unable to connect to database';
|
||||
exit;
|
||||
}
|
||||
/* end db connect */
|
||||
|
||||
$rsPublish = sql(" SELECT `cache_id`, `user_id`
|
||||
FROM `caches`
|
||||
WHERE `status` = 5
|
||||
AND `date_activate` <= NOW()");
|
||||
|
||||
while($rPublish = sql_fetch_array($rsPublish))
|
||||
{
|
||||
$userid = $rPublish['user_id'];
|
||||
$cacheid = $rPublish['cache_id'];
|
||||
|
||||
// update cache status to active
|
||||
// will touch the last_modified date of all depending records
|
||||
sql("UPDATE `caches` SET `status`=1, `date_activate`=NULL WHERE `cache_id`='&1'", $cacheid);
|
||||
|
||||
// send events
|
||||
event_new_cache($userid);
|
||||
event_notify_new_cache($cacheid);
|
||||
}
|
||||
mysql_free_result($rsPublish);
|
||||
|
||||
?>
|
@@ -1,4 +0,0 @@
|
||||
<?php
|
||||
$debug = false;
|
||||
$debug_mailto = 'abc@xyz.de';
|
||||
?>
|
@@ -16,16 +16,18 @@ checkJob(new autoarchive());
|
||||
class autoarchive
|
||||
{
|
||||
var $name = 'autoarchive';
|
||||
var $interval = 120; // provisonal minimum interval for initial archiving
|
||||
var $interval = 120; // provisional minimum interval for initial archiving
|
||||
|
||||
|
||||
function run()
|
||||
{
|
||||
global $opt, $login;
|
||||
|
||||
if ($login->system_login($opt['logic']['systemuser']['user']))
|
||||
if ($opt['cron']['autoarchive']['run'])
|
||||
{
|
||||
if ($login->hasAdminPriv(ADMIN_USER))
|
||||
if (!$login->logged_in())
|
||||
echo $this->name . ": not logged in / no system user configured\n";
|
||||
elseif ($login->hasAdminPriv(ADMIN_USER))
|
||||
{
|
||||
$this->archive_disabled_caches();
|
||||
$this->archive_events();
|
||||
@@ -43,7 +45,7 @@ class autoarchive
|
||||
$rs = sql("SELECT `caches`.`cache_id`
|
||||
FROM `caches`
|
||||
WHERE `caches`.`status`=2 AND `caches`.`type`<>6
|
||||
AND IFNULL((SELECT MAX(`date_modified`) FROM `cache_status_modified` `csm` WHERE `csm`.`cache_id`=`caches`.`cache_id`),`caches`.`listing_last_modified`) < NOW() - INTERVAL 365 DAY
|
||||
AND IFNULL((SELECT MAX(`date_modified`) FROM `cache_status_modified` `csm` WHERE `csm`.`cache_id`=`caches`.`cache_id`),`caches`.`listing_last_modified`) < NOW() - INTERVAL 366 DAY
|
||||
GROUP BY `caches`.`cache_id`
|
||||
ORDER BY `caches`.`listing_last_modified`
|
||||
LIMIT 1"); // provisional limit for initial archiving
|
||||
@@ -68,7 +70,7 @@ class autoarchive
|
||||
WHERE `caches`.`type`=6 AND `caches`.`status`=1
|
||||
AND GREATEST(`date_hidden`,`date_created`) < NOW() - INTERVAL 35 DAY
|
||||
ORDER BY `date_hidden`
|
||||
LIMIT 1"); // provisonal limit for initial archiving
|
||||
LIMIT 1"); // provisional limit for initial archiving
|
||||
while ($rCache = sql_fetch_assoc($rs))
|
||||
{
|
||||
$this->archive_cache(
|
@@ -16,6 +16,8 @@ class publish_caches
|
||||
|
||||
function run()
|
||||
{
|
||||
global $login;
|
||||
|
||||
$rsPublish = sql("SELECT `cache_id`, `user_id` FROM `caches` WHERE `status`=5 AND NOT ISNULL(`date_activate`) AND `date_activate`<=NOW()");
|
||||
while($rPublish = sql_fetch_array($rsPublish))
|
||||
{
|
||||
@@ -23,6 +25,7 @@ class publish_caches
|
||||
$cacheid = $rPublish['cache_id'];
|
||||
|
||||
// update cache status to active
|
||||
sql("SET @STATUS_CHANGE_USER_ID='&1'", $login->userid);
|
||||
sql("UPDATE `caches` SET `status`=1, `date_activate`=NULL WHERE `cache_id`='&1'", $cacheid);
|
||||
}
|
||||
sql_free_result($rsPublish);
|
||||
|
@@ -25,6 +25,12 @@
|
||||
exit;
|
||||
}
|
||||
|
||||
// Run as system user, if possible.
|
||||
// This is relevant e.g. for publishing and for auto-archiving caches.
|
||||
if ($opt['logic']['systemuser']['user'] != '')
|
||||
if (!$login->system_login($opt['logic']['systemuser']['user']))
|
||||
die("runcron: system user login failed");
|
||||
|
||||
$modules_dir = $opt['rootpath'] . 'util2/cron/modules/';
|
||||
|
||||
$hDir = opendir($modules_dir);
|
||||
|
Reference in New Issue
Block a user