From 74fd47804a7f76035c1d69579f4ae78ccc341f1c Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sat, 31 Jul 2004 19:37:58 +0000 Subject: [PATCH] fixed asyncservices to run under the windows sheduler --- admin/inc/class.uiasyncservice.inc.php | 2 +- admin/setup/phpgw_de.lang | 2 +- admin/setup/phpgw_en.lang | 2 +- phpgwapi/cron/asyncservices.php | 67 ++++++++++++++++++++++---- 4 files changed, 60 insertions(+), 13 deletions(-) diff --git a/admin/inc/class.uiasyncservice.inc.php b/admin/inc/class.uiasyncservice.inc.php index 774ab6ee07..3527fe4160 100644 --- a/admin/inc/class.uiasyncservice.inc.php +++ b/admin/inc/class.uiasyncservice.inc.php @@ -145,7 +145,7 @@ if ($async->only_fallback) { - echo '

'.lang('Under windows you can only use the fallback mode at the moment. Fallback means the jobs get only checked after each page-view !!!')."

\n"; + echo '

'.lang('Under windows you need to install the asyncservice %1manually%2 or use the fallback mode. Fallback means the jobs get only checked after each page-view !!!','','')."

\n"; } else { diff --git a/admin/setup/phpgw_de.lang b/admin/setup/phpgw_de.lang index d35c7ed4b6..f80663a81a 100644 --- a/admin/setup/phpgw_de.lang +++ b/admin/setup/phpgw_de.lang @@ -347,7 +347,7 @@ top admin de oben total records admin de Anzahl Datensätze insgesamt trust level admin de Grad des Vertrauens trust relationship admin de Vertrauensverhältnis -under windows you can only use the fallback mode at the moment. fallback means the jobs get only checked after each page-view !!! admin de Unter Windows steht im Moment nur die Ausweichmöglichkeit zur Verfügung. Bei der Ausweichmöglichkeit werden die Jobs nur nach jedem Seitenaufbau überprüft!!! +under windows you need to install the asyncservice %1manually%2 or use the fallback mode. fallback means the jobs get only checked after each page-view !!! admin de Unter Windows muß der asynchrone Service %1von Hand%2 installiert werden oder es wird nur die Ausweichmöglichkeit benutzt. Bei der Ausweichmöglichkeit werden die Jobs nur nach jedem Seitenaufbau überprüft!!! use cookies to pass sessionid admin de SitzungsId in einem Cookie speichern use pure html compliant code (not fully working yet) admin de Vollständig HTML kompatiblen Code verwenden (nicht vollständig implementiert) use theme admin de Benutztes Farbschema diff --git a/admin/setup/phpgw_en.lang b/admin/setup/phpgw_en.lang index 2396789f06..4bf3d4de35 100644 --- a/admin/setup/phpgw_en.lang +++ b/admin/setup/phpgw_en.lang @@ -341,7 +341,7 @@ top admin en top total records admin en Total records trust level admin en Trust Level trust relationship admin en Trust Relationship -under windows you can only use the fallback mode at the moment. fallback means the jobs get only checked after each page-view !!! admin en Under windows you can only use the fallback mode at the moment. Fallback means the jobs get only checked after each page-view !!! +under windows you need to install the asyncservice %1manually%2 or use the fallback mode. fallback means the jobs get only checked after each page-view !!! admin en Under windows you need to install the asyncservice %1manually%2 or use the fallback mode. Fallback means the jobs get only checked after each page-view !!! use cookies to pass sessionid admin en Use cookies to pass sessionid use pure html compliant code (not fully working yet) admin en Use pure HTML compliant code (not fully working yet) use theme admin en Use theme diff --git a/phpgwapi/cron/asyncservices.php b/phpgwapi/cron/asyncservices.php index 3861bc5534..52e14069d0 100644 --- a/phpgwapi/cron/asyncservices.php +++ b/phpgwapi/cron/asyncservices.php @@ -23,8 +23,19 @@ /* $Id$ */ - $path_to_egroupware = realpath(dirname(__FILE__).'/../..'); // need to be adapted if this script is moved somewhere else $_GET['domain'] = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : 'default'; + $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); + } $GLOBALS['phpgw_info']['flags'] = array( 'currentapp' => 'login', @@ -32,7 +43,13 @@ ); if (!is_readable($path_to_egroupware.'/header.inc.php')) { - echo "asyncservice.php: Could not find '$path_to_egroupware/header.inc.php', exiting !!!\n"; + 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); + } exit(1); } include($path_to_egroupware.'/header.inc.php'); @@ -41,20 +58,50 @@ $db_type = $GLOBALS['phpgw_domain'][$_GET['domain']]['db_type']; if (!isset($GLOBALS['phpgw_domain'][$_GET['domain']]) || empty($db_type)) { - echo "asyncservice.php: Domain '$_GET[domain]' is not configured or renamed, exiting !!!\n"; + 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); + } exit(1); } - if (!extension_loaded($db_type) && !dl($db_type.'.so')) + // some constanst for pre php4.3 + if (!defined('PHP_SHLIB_SUFFIX')) { - echo "asyncservice.php: Extension '$db_type' is not loaded and can't be loaded via dl('$db_type.so') !!!\n"; + define('PHP_SHLIB_SUFFIX',strtoupper(substr(PHP_OS, 0,3)) == 'WIN' ? 'dll' : 'so'); } - + if (!defined('PHP_SHLIB_PREFIX')) + { + define('PHP_SHLIB_PREFIX',PHP_SHLIB_SUFFIX == 'dll' ? 'php_' : ''); + } + $db_extension = PHP_SHLIB_PREFIX.$db_type.'.'.PHP_SHLIB_SUFFIX; + if (!extension_loaded($db_type) && !dl($db_extension)) + { + echo $msg = "asyncservice.php: Extension '$db_type' is not loaded and can't be loaded via dl('$db_extension') !!!\n"; + if (defined('ASYNC_LOG')) + { + $f = fopen(ASYNC_LOG,'a+'); + fwrite($f,$msg); + fclose($f); + } + } + $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'); - // 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"; + $num = ExecMethod('phpgwapi.asyncservice.check_run','crontab'); + + $msg = date('Y/m/d H:i:s ').$_GET['domain'].': '.($num ? "$num job(s) executed" : 'Nothing to execute')."\n\n"; + // 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); + } $GLOBALS['phpgw']->common->phpgw_exit();