[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 #!/usr/bin/php -q 2 <?php 3 /**************************************************************************\ 4 * eGroupWare API - Timed Asynchron Services for eGroupWare * 5 * Written by Ralf Becker <RalfBecker@outdoor-training.de> * 6 * Class for creating cron-job like timed calls of eGroupWare methods * 7 * -------------------------------------------------------------------------* 8 * This library is part of the eGroupWare API * 9 * http://www.egroupware.org/ * 10 * ------------------------------------------------------------------------ * 11 * This library is free software; you can redistribute it and/or modify it * 12 * under the terms of the GNU Lesser General Public License as published by * 13 * the Free Software Foundation; either version 2.1 of the License, * 14 * or any later version. * 15 * This library is distributed in the hope that it will be useful, but * 16 * WITHOUT ANY WARRANTY; without even the implied warranty of * 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * 18 * See the GNU Lesser General Public License for more details. * 19 * You should have received a copy of the GNU Lesser General Public License * 20 * along with this library; if not, write to the Free Software Foundation, * 21 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 22 \**************************************************************************/ 23 24 /* $Id: asyncservices.php 17954 2005-03-06 21:44:31Z ralfbecker $ */ 25 26 $_GET['domain'] = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : 'default'; 27 $path_to_egroupware = realpath(dirname(__FILE__).'/../..'); // need to be adapted if this script is moved somewhere else 28 29 // remove the comment from one of the following lines to enable loging 30 // define('ASYNC_LOG','C:\\async.log'); // Windows 31 // define('ASYNC_LOG','/tmp/async.log'); // Linux, Unix, ... 32 if (defined('ASYNC_LOG')) 33 { 34 $msg = date('Y/m/d H:i:s ').$_GET['domain'].": asyncservice started\n"; 35 $f = fopen(ASYNC_LOG,'a+'); 36 fwrite($f,$msg); 37 fclose($f); 38 } 39 40 $GLOBALS['egw_info']['flags'] = array( 41 'currentapp' => 'login', 42 'noapi' => True // this stops header.inc.php to include phpgwapi/inc/function.inc.php 43 ); 44 if (!is_readable($path_to_egroupware.'/header.inc.php')) 45 { 46 echo $msg = "asyncservice.php: Could not find '$path_to_egroupware/header.inc.php', exiting !!!\n"; 47 if (defined('ASYNC_LOG')) 48 { 49 $f = fopen(ASYNC_LOG,'a+'); 50 fwrite($f,$msg); 51 fclose($f); 52 } 53 exit(1); 54 } 55 include($path_to_egroupware.'/header.inc.php'); 56 unset($GLOBALS['egw_info']['flags']['noapi']); 57 58 $db_type = $GLOBALS['egw_domain'][$_GET['domain']]['db_type']; 59 if (!isset($GLOBALS['egw_domain'][$_GET['domain']]) || empty($db_type)) 60 { 61 echo $msg = "asyncservice.php: Domain '$_GET[domain]' is not configured or renamed, exiting !!!\n"; 62 if (defined('ASYNC_LOG')) 63 { 64 $f = fopen(ASYNC_LOG,'a+'); 65 fwrite($f,$msg); 66 fclose($f); 67 } 68 exit(1); 69 } 70 $GLOBALS['egw_info']['server']['sessions_type'] = 'db'; // no php4-sessions availible for cgi 71 72 include(PHPGW_API_INC.'/functions.inc.php'); 73 74 $num = ExecMethod('phpgwapi.asyncservice.check_run','crontab'); 75 76 $msg = date('Y/m/d H:i:s ').$_GET['domain'].': '.($num ? "$num job(s) executed" : 'Nothing to execute')."\n\n"; 77 // if the following comment got removed, you will get an email from cron for every check performed (*nix only) 78 //echo $msg; 79 80 if (defined('ASYNC_LOG')) 81 { 82 $f = fopen(ASYNC_LOG,'a+'); 83 fwrite($f,$msg); 84 fclose($f); 85 } 86 $GLOBALS['egw']->common->phpgw_exit();
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |