private function CreateLineParser()
 {
     // We need to include Line Parser on demand!
     global $gl_root_path;
     require_once $gl_root_path . 'classes/logstreamlineparser.class.php';
     // Probe if file exists then include it!
     $strIncludeFile = $gl_root_path . 'classes/logstreamlineparser' . $this->LineParserType . '.class.php';
     $strClassName = "LogStreamLineParser" . $this->LineParserType;
     if (is_file($strIncludeFile)) {
         require_once $strIncludeFile;
         // TODO! Create Parser based on Source Config!
         //return LineParser Instance
         return new $strClassName();
     } else {
         DieWithErrorMsg("Couldn't locate LineParser include file '" . $strIncludeFile . "'");
     }
 }
 function load_file($fname)
 {
     if (@is_file($fname)) {
         return join('', file($fname));
     } else {
         // BEGIN DELTA MOD
         DieWithErrorMsg("Could not find the template <B>" . $fname . "</B>");
         // END DELTA MOD
     }
 }
function DB_PrintError($MyErrorMsg, $DieOrNot)
{
    global $content, $n, $HTTP_COOKIE_VARS, $errdesc, $errno, $linesep;
    $errdesc = mysql_error();
    $errno = mysql_errno();
    // Define global variable so we know an error has occured!
    if (!defined('PHPLOGCON_INERROR')) {
        define('PHPLOGCON_INERROR', true);
    }
    $errormsg = "Database error: {$MyErrorMsg} {$linesep}";
    $errormsg .= "mysql error: {$errdesc} {$linesep}";
    $errormsg .= "mysql error number: {$errno} {$linesep}";
    $errormsg .= "Date: " . date("d.m.Y @ H:i") . $linesep;
    $errormsg .= "Script: " . getenv("REQUEST_URI") . $linesep;
    $errormsg .= "Referer: " . getenv("HTTP_REFERER") . $linesep;
    if ($DieOrNot == true) {
        DieWithErrorMsg("{$linesep}" . $errormsg);
    } else {
        OutputDebugMessage("DB_PrintError: {$errormsg}", DEBUG_ERROR);
        if (!isset($content['detailederror'])) {
            $content['detailederror_code'] = ERROR_DB_QUERYFAILED;
            $content['detailederror'] = GetErrorMessage(ERROR_DB_QUERYFAILED);
        } else {
            $content['detailederror'] .= "<br><br>" . GetErrorMessage(ERROR_DB_QUERYFAILED);
        }
        // Append SQL Detail Error
        $content['detailederror'] .= "<br><br>" . $errormsg;
    }
}
Example #4
0
// *** Default includes	and procedures *** //
define('IN_PHPLOGCON', true);
define('IN_PHPLOGCON_INSTALL', true);
// Extra for INSTALL Script!
define('STEPSCRIPTNAME', "install.php");
// Helper variable for the STEP helper functions
$gl_root_path = './';
// Now include necessary include files!
include $gl_root_path . 'include/functions_common.php';
include $gl_root_path . 'include/functions_frontendhelpers.php';
include $gl_root_path . 'include/functions_installhelpers.php';
// Init Langauge first!
IncludeLanguageFile($gl_root_path . '/lang/' . $LANG . '/main.php');
InitBasicPhpLogCon();
if (InitPhpLogConConfigFile(false)) {
    DieWithErrorMsg($content['LN_INSTALL_ERRORINSTALLED']);
}
// Set some static values
define('MAX_STEPS', 8);
$content['web_theme'] = "default";
$content['user_theme'] = "default";
$configsamplefile = $content['BASEPATH'] . "include/config.sample.php";
$content['HeaderDefaultEncoding'] = ENC_ISO_8859_1;
// Set Default encoding!
// New Set Font settingdefaults
InitFontSettings();
//ini_set('error_reporting', E_ALL); // DEBUG ENABLE
// ***					*** //
// --- CONTENT Vars
$content['TITLE'] = "LogAnalyzer :: " . $content['LN_INSTALL_TITLE'];
// ---
Example #5
0
include $gl_root_path . 'include/functions_installhelpers.php';
// This site can not require LOGIN
define('IS_NOLOGINPAGE', true);
$content['IS_NOLOGINPAGE'] = true;
InitPhpLogCon();
InitSourceConfigs();
InitFrontEndDefaults();
// Only in WebFrontEnd
// --- PreCheck if conversion is allowed!
if (GetConfigSetting("UserDBEnabled", false) && GetConfigSetting("UserDBConvertAllowed", false)) {
    // Setup static values
    define('MAX_STEPS', 6);
    $content['web_theme'] = "default";
    $content['user_theme'] = "default";
} else {
    DieWithErrorMsg($content['LN_CONVERT_ERRORINSTALLED']);
}
// ---
// --- CONTENT Vars
$content['TITLE'] = "LogAnalyzer :: " . $content['LN_CONVERT_TITLE'];
// ---
// --- Read Vars
if (isset($_GET['step'])) {
    $content['CONVERT_STEP'] = intval(DB_RemoveBadChars($_GET['step']));
    if ($content['CONVERT_STEP'] > MAX_STEPS) {
        $content['CONVERT_STEP'] = 1;
    }
} else {
    $content['CONVERT_STEP'] = 1;
}
// Set Next Step
function RedirectResult($szMsg, $newpage)
{
    global $content;
    if (defined('PHPLOGCON_INERROR')) {
        DieWithErrorMsg(GetAndReplaceLangStr($content["LN_ERROR_REDIRECTABORTED"], $newpage));
    }
    // Perform redirect!
    header("Location: result.php?msg=" . urlencode($szMsg) . "&redir=" . urlencode($newpage));
    exit;
}
Example #7
0
function CleanData($optParam1, $optParam2, $optParam3, $optParam4)
{
    global $content, $gl_root_path;
    // Get Source reference!
    $mySource = $content['Sources'][$content['SOURCEID']];
    // Check Source Type
    if ($mySource['SourceType'] == SOURCE_DB || $mySource['SourceType'] == SOURCE_PDO) {
        // Include LogStream facility
        include $gl_root_path . 'classes/logstream.class.php';
        //Debug Output
        PrintHTMLDebugInfo(DEBUG_INFO, "CleanData", GetAndReplaceLangStr($content["LN_CMD_CLEANINGDATAFOR"], $mySource['Name']));
        // Create LogStream Object
        $stream = $mySource['ObjRef']->LogStreamFactory($mySource['ObjRef']);
        $res = $stream->Verify();
        if ($res == SUCCESS) {
            // Gather Database Stats
            $content['ROWCOUNT'] = $stream->GetLogStreamTotalRowCount();
            if (isset($content['ROWCOUNT'])) {
                //Debug Output
                PrintHTMLDebugInfo(DEBUG_INFO, "CleanData", GetAndReplaceLangStr($content["LN_CMD_ROWSFOUND"], $content['ROWCOUNT'], $mySource['Name']));
                if ($optParam1 != NULL) {
                    if ($optParam1 == "all") {
                        $timestamp = 0;
                    } else {
                        if ($optParam1 == "olderthan" && $optParam2 != NULL) {
                            // Take current time and subtract Seconds
                            $nSecondsSubtract = intval($optParam2);
                            $timestamp = time() - $nSecondsSubtract;
                        } else {
                            if ($optParam1 == "date" && $optParam2 != NULL && $optParam3 != NULL && $optParam4 != NULL) {
                                // Generate Timestamp
                                $timestamp = mktime(0, 0, 0, intval($optParam2), intval($optParam3), intval($optParam4));
                            } else {
                                // Print error and die!
                                DieWithErrorMsg($content["LN_CMD_WRONGSUBOPORMISSING"]);
                            }
                        }
                    }
                    // Continue with delete only if $timestamp is set!
                    if (isset($timestamp)) {
                        //Debug Output
                        PrintHTMLDebugInfo(DEBUG_INFO, "CleanData", GetAndReplaceLangStr($content["LN_CMD_DELETINGOLDERTHEN"], date("Y-m-d", $timestamp)));
                        // Now perform the data cleanup!
                        $content['affectedrows'] = $stream->CleanupLogdataByDate($timestamp);
                        if (isset($content['affectedrows'])) {
                            //Debug Output
                            PrintHTMLDebugInfo(DEBUG_INFO, "CleanData", GetAndReplaceLangStr($content["LN_CMD_DELETEDROWS"], $content['affectedrows']));
                        } else {
                            // Print error and die!
                            DieWithErrorMsg(GetAndReplaceLangStr($content["LN_CMD_FAILEDTOCLEANDATA"], $mySource['Name']));
                        }
                    }
                } else {
                    // Print error and die!
                    DieWithErrorMsg($content["LN_CMD_SUBPARAM1MISSING"]);
                }
            } else {
                // Print error and die!
                DieWithErrorMsg(GetAndReplaceLangStr($content["LN_CMD_COULDNOTGETROWCOUNT"], $mySource['Name']));
            }
        } else {
            // Print error and die!
            $szErroMsg = GetAndReplaceLangStr($content["LN_SOURCES_ERROR_WITHINSOURCE"], $mySource['Name'], GetErrorMessage($res));
            if (isset($extraErrorDescription)) {
                $szErroMsg .= "\r\n\r\n" . GetAndReplaceLangStr($content['LN_SOURCES_ERROR_EXTRAMSG'], $extraErrorDescription);
            }
            DieWithErrorMsg($szErroMsg);
        }
    } else {
        // Print error and die!
        DieWithErrorMsg(GetAndReplaceLangStr($content["LN_SOURCES_ERROR_NOCLEARSUPPORT"], $content['SOURCEID']));
    }
}
Example #8
0
function RunReport()
{
    global $content, $gl_root_path;
    // Get Reference to report!
    $myReport = $content['REPORTS'][$content['reportid']];
    // Get reference to savedreport
    $mySavedReport = $myReport['SAVEDREPORTS'][$content['savedreportid']];
    // Get Objectreference to report
    $myReportObj = $myReport["ObjRef"];
    // Set SavedReport Settings!
    $myReportObj->InitFromSavedReport($mySavedReport);
    //Debug Output
    PrintHTMLDebugInfo(DEBUG_INFO, "RunReport", GetAndReplaceLangStr($content["LN_CMD_RUNREPORT"], $mySavedReport['customTitle']));
    // Perform check
    $res = $myReportObj->verifyDataSource();
    if ($res != SUCCESS) {
        // Print error and die!
        $szError = GetAndReplaceLangStr($content['LN_GEN_ERROR_REPORTGENFAILED'], $mySavedReport['customTitle'], GetAndReplaceLangStr(GetErrorMessage($res), $mySavedReport['sourceid']));
        if (isset($extraErrorDescription)) {
            $szError .= "<br><br>" . GetAndReplaceLangStr($content['LN_SOURCES_ERROR_EXTRAMSG'], $extraErrorDescription);
        }
        DieWithErrorMsg($szError);
    } else {
        // Call processing part now!
        $res = $myReportObj->startDataProcessing();
        if ($res != SUCCESS) {
            DieWithErrorMsg(GetAndReplaceLangStr($content['LN_GEN_ERROR_REPORTGENFAILED'], $mySavedReport['customTitle'], GetErrorMessage($res)));
        } else {
            // --- Perform report output
            // Init IncludePath
            $reportIncludePath = $myReportObj->GetReportIncludePath();
            // Include Custom language file if available
            $myReportObj->InitReportLanguageFile($reportIncludePath);
            // Init template Parser
            $page = new Template();
            $page->set_path($reportIncludePath);
            // Parse template
            $page->parser($content, $myReportObj->GetBaseFileName());
            // Output the result
            $res = $myReportObj->OutputReport($page->result(), $szErrorStr);
            if ($res == SUCCESS && $myReportObj->GetOutputTarget() != REPORT_TARGET_STDOUT) {
                //Debug Output
                PrintHTMLDebugInfo(DEBUG_INFO, "RunReport", GetAndReplaceLangStr($content["LN_GEN_SUCCESS_REPORTWASGENERATED_DETAILS"], $szErrorStr));
            } else {
                if ($res == ERROR) {
                    // Debug Error
                    PrintHTMLDebugInfo(DEBUG_ERROR, "RunReport", GetAndReplaceLangStr($content["LN_GEN_ERROR_REPORTFAILEDTOGENERATE"], $szErrorStr));
                }
            }
            // ---
        }
    }
}