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'])); } }
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)); } } // --- } } }