egroupware_official/phpgwapi/cron/asyncservices.php

61 lines
3.0 KiB
PHP
Raw Normal View History

2003-04-28 01:19:49 +02:00
#!/usr/bin/php -q
<?php
/**************************************************************************\
2004-05-05 10:30:48 +02:00
* eGroupWare API - Timed Asynchron Services for eGroupWare *
2003-04-28 01:19:49 +02:00
* Written by Ralf Becker <RalfBecker@outdoor-training.de> *
2004-05-05 10:30:48 +02:00
* Class for creating cron-job like timed calls of eGroupWare methods *
2003-04-28 01:19:49 +02:00
* -------------------------------------------------------------------------*
2004-05-05 10:30:48 +02:00
* This library is part of the eGroupWare API *
* http://www.egroupware.org/ *
2003-04-28 01:19:49 +02:00
* ------------------------------------------------------------------------ *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, *
* or any later version. *
* This library 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 Lesser General Public License for more details. *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
\**************************************************************************/
/* $Id$ */
2004-05-05 10:33:12 +02:00
$path_to_phpgroupware = '../..'; // need to be adapted if this script is moved somewhere else
$_GET['domain'] = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : 'default';
2003-04-28 01:19:49 +02:00
$GLOBALS['phpgw_info']['flags'] = array(
'currentapp' => 'login',
'noapi' => True // this stops header.inc.php to include phpgwapi/inc/function.inc.php
2003-04-28 01:19:49 +02:00
);
2003-09-06 12:11:00 +02:00
if (!is_readable($path_to_phpgroupware.'/header.inc.php'))
{
echo "asyncservice.php: Could not find '$path_to_phpgroupware/header.inc.php', exiting !!!\n";
exit(1);
}
2003-04-28 01:19:49 +02:00
include($path_to_phpgroupware.'/header.inc.php');
unset($GLOBALS['phpgw_info']['flags']['noapi']);
2003-04-28 01:19:49 +02:00
$db_type = $GLOBALS['phpgw_domain'][$_GET['domain']]['db_type'];
2003-09-06 12:11:00 +02:00
if (!isset($GLOBALS['phpgw_domain'][$_GET['domain']]) || empty($db_type))
{
echo "asyncservice.php: Domain '$_GET[domain]' is not configured or renamed, exiting !!!\n";
exit(1);
}
if (!extension_loaded($db_type) && !dl($db_type.'.so'))
{
2003-09-06 12:11:00 +02:00
echo "asyncservice.php: Extension '$db_type' is not loaded and can't be loaded via dl('$db_type.so') !!!\n";
}
2003-04-28 01:19:49 +02:00
2003-09-06 12:11:00 +02:00
$GLOBALS['phpgw_info']['server']['sessions_type'] = 'db'; // no php4-sessions availible for cgi
include(PHPGW_API_INC.'/functions.inc.php');
$num = ExecMethod('phpgwapi.asyncservice.check_run','crontab');
2003-04-28 01:19:49 +02:00
// if the following comment got removed, you will get an email from cron for every check performed
//echo date('Y/m/d H:i:s ').$_GET['domain'].': '.($num ? "$num job(s) executed" : 'Nothing to execute')."\n";
2003-04-28 01:19:49 +02:00
$GLOBALS['phpgw']->common->phpgw_exit();