fixed command line report generator, can now run from any location

This commit is contained in:
Andre Lorbach 2009-12-23 16:52:39 +01:00
parent 9d4d676471
commit eabc43bc92
3 changed files with 28 additions and 2 deletions

View File

@ -1184,7 +1184,7 @@ function CreateCronCommand( $myReportID, $mySavedReportID = null )
if ( isset($mySavedReportID) )
{
$pos = strpos( strtoupper($_SERVER['SERVER_SOFTWARE']), "WIN32");
$pos = strpos( strtoupper(PHP_OS), "WIN");
if ($pos !== false)
{
// Running on Windows

View File

@ -35,6 +35,31 @@
define('IN_PHPLOGCON', true);
$gl_root_path = './../';
// --- IMPORTANT, read the script filename from argv!
// Operation argv
if ( isset($_SERVER["argv"][0]) )
$myscriptname = $_SERVER["argv"][0];
else
die( "Error, this script can only be run from the command prompt." );
// Extract OS!
$pos = strpos( strtoupper(PHP_OS), "WIN");
if ($pos !== false) // Running on Windows
{
// Extract Global root path from scriptname
$gl_root_path = substr( $myscriptname, 0, strrpos($myscriptname, "\\")+1 );
$gl_root_path = str_replace("\\", "/", $gl_root_path);
}
else // Running on LINUX
{
// Extract Global root path from scriptname
$gl_root_path = substr( $myscriptname, 0, strrpos($myscriptname, "/")+1 );
}
// Remove cron folder as well!
$gl_root_path = str_replace("cron/", "", $gl_root_path);
// ---
// Now include necessary include files!
include_once($gl_root_path . 'include/functions_common.php');
include_once($gl_root_path . 'include/functions_frontendhelpers.php');
@ -92,7 +117,7 @@ function RunReport()
// Call processing part now!
$res = $myReportObj->startDataProcessing();
if ( $res != SUCCESS )
DieWithErrorMsg( GetAndReplaceLangStr( $content['LN_GEN_ERROR_REPORTGENFAILED'], $mySavedReport['customTitle'], GetErrorMessage($res) );
DieWithErrorMsg( GetAndReplaceLangStr($content['LN_GEN_ERROR_REPORTGENFAILED'], $mySavedReport['customTitle'], GetErrorMessage($res)) );
else
{
// --- Perform report output

View File

@ -357,6 +357,7 @@ $content['LN_ORACLE_WHOIS'] = "WHOIS Lookup for '%1' value '%2'";
$content['LN_CMD_SAVEDREPORTIDNOTFOUND'] = "Invalid SavedReport ID '%1'";
$content['LN_CMD_NOREPORTID'] = "Missing Report ID";
$content['LN_CMD_NOSAVEDREPORTID'] = "Missing SavedReport ID";
$content['LN_CMD_NOCMDPROMPT'] = "Error, this script can only be run from the command prompt.";
?>