2003-04-28 01:19:49 +02:00
|
|
|
#!/usr/bin/php -q
|
|
|
|
<?php
|
2007-07-26 11:23:10 +02:00
|
|
|
/**
|
|
|
|
* API - Timed Asynchron Services for eGroupWare
|
|
|
|
*
|
|
|
|
* @link http://www.egroupware.org
|
|
|
|
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
|
|
|
* @copyright Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
|
|
|
*
|
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @package api
|
|
|
|
* @access public
|
|
|
|
* @version $Id$
|
|
|
|
*/
|
2003-04-28 01:19:49 +02:00
|
|
|
|
2003-07-21 20:20:45 +02:00
|
|
|
$_GET['domain'] = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : 'default';
|
2004-07-31 21:37:58 +02:00
|
|
|
$path_to_egroupware = realpath(dirname(__FILE__).'/../..'); // need to be adapted if this script is moved somewhere else
|
|
|
|
|
|
|
|
// remove the comment from one of the following lines to enable loging
|
|
|
|
// define('ASYNC_LOG','C:\\async.log'); // Windows
|
|
|
|
// define('ASYNC_LOG','/tmp/async.log'); // Linux, Unix, ...
|
|
|
|
if (defined('ASYNC_LOG'))
|
|
|
|
{
|
|
|
|
$msg = date('Y/m/d H:i:s ').$_GET['domain'].": asyncservice started\n";
|
|
|
|
$f = fopen(ASYNC_LOG,'a+');
|
|
|
|
fwrite($f,$msg);
|
|
|
|
fclose($f);
|
|
|
|
}
|
2003-04-28 01:19:49 +02:00
|
|
|
|
2005-03-06 22:44:31 +01:00
|
|
|
$GLOBALS['egw_info']['flags'] = array(
|
2003-07-21 20:20:45 +02:00
|
|
|
'currentapp' => 'login',
|
|
|
|
'noapi' => True // this stops header.inc.php to include phpgwapi/inc/function.inc.php
|
2003-04-28 01:19:49 +02:00
|
|
|
);
|
2004-05-23 21:16:15 +02:00
|
|
|
if (!is_readable($path_to_egroupware.'/header.inc.php'))
|
2003-09-06 12:11:00 +02:00
|
|
|
{
|
2004-07-31 21:37:58 +02:00
|
|
|
echo $msg = "asyncservice.php: Could not find '$path_to_egroupware/header.inc.php', exiting !!!\n";
|
|
|
|
if (defined('ASYNC_LOG'))
|
|
|
|
{
|
|
|
|
$f = fopen(ASYNC_LOG,'a+');
|
|
|
|
fwrite($f,$msg);
|
|
|
|
fclose($f);
|
|
|
|
}
|
2003-09-06 12:11:00 +02:00
|
|
|
exit(1);
|
|
|
|
}
|
2004-05-23 21:16:15 +02:00
|
|
|
include($path_to_egroupware.'/header.inc.php');
|
2005-03-06 22:44:31 +01:00
|
|
|
unset($GLOBALS['egw_info']['flags']['noapi']);
|
2003-04-28 01:19:49 +02:00
|
|
|
|
2005-03-06 22:44:31 +01:00
|
|
|
$db_type = $GLOBALS['egw_domain'][$_GET['domain']]['db_type'];
|
|
|
|
if (!isset($GLOBALS['egw_domain'][$_GET['domain']]) || empty($db_type))
|
2003-09-06 12:11:00 +02:00
|
|
|
{
|
2004-07-31 21:37:58 +02:00
|
|
|
echo $msg = "asyncservice.php: Domain '$_GET[domain]' is not configured or renamed, exiting !!!\n";
|
|
|
|
if (defined('ASYNC_LOG'))
|
|
|
|
{
|
|
|
|
$f = fopen(ASYNC_LOG,'a+');
|
|
|
|
fwrite($f,$msg);
|
|
|
|
fclose($f);
|
|
|
|
}
|
2003-09-06 12:11:00 +02:00
|
|
|
exit(1);
|
|
|
|
}
|
2003-07-21 20:20:45 +02:00
|
|
|
|
2007-07-26 11:23:10 +02:00
|
|
|
include(EGW_API_INC.'/functions.inc.php');
|
2004-07-31 21:37:58 +02:00
|
|
|
|
2003-07-21 20:20:45 +02:00
|
|
|
$num = ExecMethod('phpgwapi.asyncservice.check_run','crontab');
|
2003-04-28 01:19:49 +02:00
|
|
|
|
2007-07-26 11:23:10 +02:00
|
|
|
$msg = date('Y/m/d H:i:s ').$_GET['domain'].': '.($num === false ? 'An error occured: can not obtain semaphore!' :
|
|
|
|
($num ? "$num job(s) executed" : 'Nothing to execute'))."\n\n";
|
2004-07-31 21:37:58 +02:00
|
|
|
// if the following comment got removed, you will get an email from cron for every check performed (*nix only)
|
|
|
|
//echo $msg;
|
|
|
|
|
|
|
|
if (defined('ASYNC_LOG'))
|
|
|
|
{
|
|
|
|
$f = fopen(ASYNC_LOG,'a+');
|
|
|
|
fwrite($f,$msg);
|
|
|
|
fclose($f);
|
|
|
|
}
|
2007-07-26 11:23:10 +02:00
|
|
|
$GLOBALS['egw']->common->egw_exit();
|