// --- Init for DefaultView field! // copy Views Array $content['USER_VIEWS'] = $content['Views']; $userViewID = GetConfigSetting('DefaultViewsID', $content['DefaultViewsID'], CFGLEVEL_USER); foreach ($content['USER_VIEWS'] as &$myView) { if ($myView['ID'] == $userViewID) { $myView['selected'] = "selected"; } else { $myView['selected'] = ""; } } // --- // --- Init for DefaultSource field! // copy Sources Array $content['USER_SOURCES'] = $content['Sources']; $userSourceID = GetConfigSetting('DefaultSourceID', $content['DefaultSourceID'], CFGLEVEL_USER); foreach ($content['USER_SOURCES'] as &$mySource) { if ($mySource['ID'] == $userSourceID) { $mySource['selected'] = "selected"; } else { $mySource['selected'] = ""; } } // --- } // --- BEGIN CREATE TITLE $content['TITLE'] = InitPageTitle(); $content['TITLE'] .= " :: " . $content['LN_ADMINMENU_GENOPT']; // --- END CREATE TITLE // --- Parsen and Output InitTemplateParser();
function GetFormatedDate($evttimearray) { global $content; if (is_array($evttimearray)) { if (GetConfigSetting("ViewUseTodayYesterday", 0, CFGLEVEL_USER) == 1 && (date('m', $evttimearray[EVTIME_TIMESTAMP]) == date('m') && date('Y', $evttimearray[EVTIME_TIMESTAMP]) == date('Y'))) { if (date('d', $evttimearray[EVTIME_TIMESTAMP]) == date('d')) { return "Today " . date("H:i:s", $evttimearray[EVTIME_TIMESTAMP]); } else { if (date('d', $evttimearray[EVTIME_TIMESTAMP] + 86400) == date('d')) { return "Yesterday " . date("H:i:s", $evttimearray[EVTIME_TIMESTAMP]); } } } // Copy to local variable $nMyTimeStamp = $evttimearray[EVTIME_TIMESTAMP]; } else { $nMyTimeStamp = strtotime($evttimearray); if ($nMyTimeStamp === FALSE) { // Could not convert into timestamp so return original! return $evttimearray; } } // Reach return normal format! return $szDateFormatted = date("Y-m-d H:i:s", $nMyTimeStamp); }
/** * Implementation of ApplyFilters which can be used by all LogStream Classes! * This function performs a check on the filters and actually triggers the * syslog parsers as well. */ public function ApplyFilters($myResults, &$arrProperitesOut) { // IF result was unsuccessfull, return success - nothing we can do here. if ($myResults >= ERROR) { return SUCCESS; } // Evaluation default is true $bFinalEval = true; // Process all filters if ($this->_filters != null) { // Loop through set properties foreach ($arrProperitesOut as $propertyname => $propertyvalue) { // TODO: NOT SURE IF THIS WILL WORK ON NUMBERS AND OTHER TYPES RIGHT NOW if (array_key_exists($propertyname, $this->_filters) && isset($propertyvalue)) { // Perform first loop to determine the bEval Default foreach ($this->_filters[$propertyname] as $myfilter) { if ($myfilter[FILTER_TYPE] == FILTER_TYPE_NUMBER || $myfilter[FILTER_TYPE] == FILTER_TYPE_STRING && $myfilter[FILTER_MODE] & FILTER_MODE_INCLUDE && $propertyname != SYSLOG_MESSAGE) { $bEval = false; break; // IF found one INCLUDE or NUMERIC filter, the default has to be false! } else { $bEval = true; } } // Extra var needed for number checks! $bIsOrFilter = false; // If enabled we need to check for numbereval later $bOrFilter = false; // Perform second loop through all filters, to perform filtering foreach ($this->_filters[$propertyname] as $myfilter) { switch ($myfilter[FILTER_TYPE]) { case FILTER_TYPE_STRING: // Only filter if value is non zero if (strlen($propertyvalue) > 0 && strlen($myfilter[FILTER_VALUE]) > 0) { // If Syslog message, we have AND handling! if ($propertyname == SYSLOG_MESSAGE) { // Include Filter if ($myfilter[FILTER_MODE] & FILTER_MODE_INCLUDE) { if (stripos($propertyvalue, $myfilter[FILTER_VALUE]) === false) { $bEval = false; } } else { if ($myfilter[FILTER_MODE] & FILTER_MODE_EXCLUDE) { if (stripos($propertyvalue, $myfilter[FILTER_VALUE]) !== false) { $bEval = false; } } } } else { // Include Filter if ($myfilter[FILTER_MODE] & FILTER_MODE_INCLUDE) { // Set isOrFilter to true in this case $bIsOrFilter = true; if ($myfilter[FILTER_MODE] & FILTER_MODE_SEARCHFULL) { if (strtolower($propertyvalue) == strtolower($myfilter[FILTER_VALUE])) { $bOrFilter = true; } } else { if (stripos($propertyvalue, $myfilter[FILTER_VALUE]) !== false) { $bOrFilter = true; } } } else { if ($myfilter[FILTER_MODE] & FILTER_MODE_EXCLUDE) { if ($myfilter[FILTER_MODE] & FILTER_MODE_SEARCHFULL) { if (strtolower($propertyvalue) == strtolower($myfilter[FILTER_VALUE])) { $bEval = false; } } else { if (stripos($propertyvalue, $myfilter[FILTER_VALUE]) !== false) { $bEval = false; } } } } break; } } else { // Either filter value or property value was empty! // This means we have no match $bEval = false; } break; case FILTER_TYPE_NUMBER: $bIsOrFilter = true; // Default is set to TRUE if (is_numeric($arrProperitesOut[$propertyname])) { if ($myfilter[FILTER_MODE] & FILTER_MODE_INCLUDE) { if ($myfilter[FILTER_VALUE] == $arrProperitesOut[$propertyname]) { $bOrFilter = true; } else { $bOrFilter = false; } } else { if ($myfilter[FILTER_MODE] & FILTER_MODE_EXCLUDE) { if ($myfilter[FILTER_VALUE] == $arrProperitesOut[$propertyname]) { $bOrFilter = false; } else { $bOrFilter = true; } } } } else { // If wanted, we treat this filter as a success! if (GetConfigSetting("TreatNotFoundFiltersAsTrue", 0, CFGLEVEL_USER) == 1) { $bOrFilter = true; } else { $bOrFilter = false; } } break; case FILTER_TYPE_DATE: // Get Log TimeStamp $nLogTimeStamp = $arrProperitesOut[$propertyname][EVTIME_TIMESTAMP]; if ($myfilter[FILTER_DATEMODE] == DATEMODE_LASTX) { // Get current timestamp $nNowTimeStamp = time(); if ($myfilter[FILTER_VALUE] == DATE_LASTX_HOUR) { $nLastXTime = 60 * 60; } else { if ($myfilter[FILTER_VALUE] == DATE_LASTX_12HOURS) { $nLastXTime = 60 * 60 * 12; } else { if ($myfilter[FILTER_VALUE] == DATE_LASTX_24HOURS) { $nLastXTime = 60 * 60 * 24; } else { if ($myfilter[FILTER_VALUE] == DATE_LASTX_7DAYS) { $nLastXTime = 60 * 60 * 24 * 7; } else { if ($myfilter[FILTER_VALUE] == DATE_LASTX_31DAYS) { $nLastXTime = 60 * 60 * 24 * 31; } else { // WTF default? $nLastXTime = 86400; } } } } } // If Nowtime + LastX is higher then the log timestamp, the this logline is to old for us. if ($nNowTimeStamp - $nLastXTime > $nLogTimeStamp) { $bEval = false; } } else { if ($myfilter[FILTER_DATEMODE] == DATEMODE_RANGE_FROM) { // Get filter timestamp! $nFromTimeStamp = GetTimeStampFromTimeString($myfilter[FILTER_VALUE]); // If logtime is smaller then FromTime, then the Event is outside of our scope! if ($nLogTimeStamp < $nFromTimeStamp) { $bEval = false; } } else { if ($myfilter[FILTER_DATEMODE] == DATEMODE_RANGE_TO) { // Get filter timestamp! // echo $myfilter[FILTER_VALUE]; $nToTimeStamp = GetTimeStampFromTimeString($myfilter[FILTER_VALUE]); // If logtime is smaller then FromTime, then the Event is outside of our scope! if ($nLogTimeStamp > $nToTimeStamp) { $bEval = false; } } else { if ($myfilter[FILTER_DATEMODE] == DATEMODE_RANGE_DATE) { // Get filter timestamp! // echo $myfilter[FILTER_VALUE]; $nDateTimeStamp = GetTimeStampFromTimeString($myfilter[FILTER_VALUE]); // If not on logfile day, the Event is outside of our scope! if ($nLogTimeStamp < $nDateTimeStamp || $nLogTimeStamp > $nDateTimeStamp + 86400) { $bEval = false; } } } } } break; default: // TODO! break; } // If was number filter, we apply it the evaluation. if ($bIsOrFilter) { // Fixed binary comparison to | instead of &! $bEval |= $bOrFilter; //echo "!" . $bOrFilter . "-" . $bEval . "!<br>"; } // else // $bEval &= $bOrFilter; } // Combine filters with AND $bFinalEval &= $bEval; } } // Check if evaluation was successfull if (!$bFinalEval) { // unmatching filter, reset property array foreach ($this->_arrProperties as $property) { $arrProperitesOut[$property] = ''; } // return error! return ERROR_FILTER_NOT_MATCH; } // Reached this point means filters did match! return SUCCESS; } else { // No filters at all means success! return SUCCESS; } }
function InitPhpLogConConfigFile($bHandleMissing = true) { // Needed to make global global $CFG, $gl_root_path, $content; // Bugfix for race conditions, clear file stats cache! clearstatcache(); if (file_exists($gl_root_path . 'config.php') && GetFileLength($gl_root_path . 'config.php') > 0) { // Include the main config include_once $gl_root_path . 'config.php'; // Easier DB Access $tblPref = GetConfigSetting("UserDBPref", "logcon"); define('DB_CONFIG', $tblPref . "config"); define('DB_GROUPS', $tblPref . "groups"); define('DB_GROUPMEMBERS', $tblPref . "groupmembers"); define('DB_FIELDS', $tblPref . "fields"); define('DB_SEARCHES', $tblPref . "searches"); define('DB_SOURCES', $tblPref . "sources"); define('DB_USERS', $tblPref . "users"); define('DB_VIEWS', $tblPref . "views"); define('DB_CHARTS', $tblPref . "charts"); define('DB_MAPPINGS', $tblPref . "dbmappings"); define('DB_SAVEDREPORTS', $tblPref . "savedreports"); // Legacy support for old columns definition format! if (isset($CFG['Columns']) && is_array($CFG['Columns'])) { AppendLegacyColumns(); } // --- Now Copy all entries into content variable foreach ($CFG as $key => $value) { $content[$key] = $value; } // --- // For MiscShowPageRenderStats if (GetConfigSetting("MiscShowPageRenderStats", 1)) { $content['ShowPageRenderStats'] = "true"; InitPageRenderStats(); } // return result return true; } else { // if handled ourselfe, we die in CheckForInstallPhp. if ($bHandleMissing == true) { // Check for installscript! CheckForInstallPhp(); } else { return false; } } }
// --- Init for DefaultFont field! // copy Fonts Array $content['USER_FONTS'] = $content['fonts']; $DefaultFont = GetConfigSetting('DefaultFont', $content['DefaultFont'], CFGLEVEL_USER); foreach ($content['USER_FONTS'] as &$myFont) { if ($myFont['Name'] == $DefaultFont) { $myFont['selected'] = "selected"; } else { $myFont['selected'] = ""; } } // --- // --- Init for DefaultFontSize field! // copy Fontsizes Array $content['USER_FONTSIZES'] = $content['fontsizes']; $DefaultFontSize = GetConfigSetting('DefaultFontSize', $content['DefaultFontSize'], CFGLEVEL_USER); foreach ($content['USER_FONTSIZES'] as $myFontKey => &$myFontSize) { if ($myFontKey == $DefaultFontSize) { $myFontSize['selected'] = "selected"; } else { $myFontSize['selected'] = ""; } } // --- } // --- BEGIN CREATE TITLE $content['TITLE'] = InitPageTitle(); $content['TITLE'] .= " :: " . $content['LN_ADMINMENU_GENOPT']; // --- END CREATE TITLE // --- Parsen and Output InitTemplateParser();
InitSourceConfigs(); InitFrontEndDefaults(); // Only in WebFrontEnd // Init admin langauge file now! IncludeLanguageFile($gl_root_path . '/lang/' . $LANG . '/admin.php'); // *** *** // // --- BEGIN Custom Code if (isset($content['database_forcedatabaseupdate']) && $content['database_forcedatabaseupdate'] == "yes") { if (isset($_GET['op'])) { if ($_GET['op'] == "upgrade") { // Lets start the uodating! $content['UPGRADE_RUNNING'] = "1"; $content['sql_sucess'] = 0; $content['sql_failed'] = 0; $totaldbdefs = ""; $tblPref = GetConfigSetting("UserDBPref", "logcon"); // +1 so we start at the right DB Version! for ($i = $content['database_installedversion'] + 1; $i <= $content['database_internalversion']; $i++) { $myfilename = "db_update_v" . $i . ".txt"; // Lets read the table definitions :) $handle = @fopen($content['BASEPATH'] . "include/" . $myfilename, "r"); if ($handle === false) { $content['ISERROR'] = "true"; $content['ERROR_MSG'] = GetAndReplaceLangStr($content['LN_DBUPGRADE_DBFILENOTFOUND'], $myfilename); } else { while (!feof($handle)) { $buffer = fgets($handle, 4096); $pos = strpos($buffer, "--"); if ($pos === false) { $totaldbdefs .= $buffer; } else {
} // Replace stats_ with the custom one ;) $totaldbdefs = str_replace("`logcon_", "`" . GetConfigSetting("UserDBPref"), $totaldbdefs); // Now split by sql command $mycommands = split(";\n", $totaldbdefs); // // check for different linefeed // if ( count($mycommands) <= 1 ) // $mycommands = split( ";\n", $totaldbdefs ); //Still only one? Abort if (count($mycommands) <= 1) { $content['failedstatements'][$content['sql_failed']]['myerrmsg'] = GetAndReplaceLangStr($content['LN_INSTALL_ERRORINSQLCOMMANDS'], $content['BASEPATH'] . "include/db_template.txt"); $content['failedstatements'][$content['sql_failed']]['mystatement'] = ""; $content['sql_failed']++; } // Append INSERT Statement for Config Table to set the Database Version ^^! $mycommands[count($mycommands)] = "INSERT INTO `" . GetConfigSetting("UserDBPref") . "config` (`propname`, `propvalue`, `is_global`) VALUES ('database_installedversion', '" . $content['database_internalversion'] . "', 1)"; // --- Now execute all commands ini_set('error_reporting', E_WARNING); // Enable Warnings! // Establish DB Connection DB_Connect(); for ($i = 0; $i < count($mycommands); $i++) { if (strlen(trim($mycommands[$i])) > 1) { $result = DB_Query($mycommands[$i], false); if ($result == FALSE) { $content['failedstatements'][$content['sql_failed']]['myerrmsg'] = DB_ReturnSimpleErrorMsg(); $content['failedstatements'][$content['sql_failed']]['mystatement'] = $mycommands[$i]; // --- Set CSS Class if ($content['sql_failed'] % 2 == 0) { $content['failedstatements'][$content['sql_failed']]['cssclass'] = "line1"; } else {
function InitFontSettings() { global $content; // --- Set dynamic stylesheet options like Font Type and Sizes if (strpos($_SERVER['HTTP_USER_AGENT'], "Windows") !== false) { // Use other default on Windows $userdefaultfont = GetConfigSetting("DefaultFont", "Trebuchet MS", CFGLEVEL_USER); } else { $userdefaultfont = GetConfigSetting("DefaultFont", "Arial", CFGLEVEL_USER); } $userdefaultfontsize = GetConfigSetting("DefaultFontSize", "100", CFGLEVEL_USER); /* Set Defaults if not set already! */ if (strlen($userdefaultfont) <= 0) { $userdefaultfont = "Arial"; } if (strlen($userdefaultfontsize) <= 0) { $userdefaultfontsize = "100"; } $content['DYN_STYLESHEET'] = '<style> body, td, select, input, .ui-widget, .ui-widget-content { font-family: ' . $userdefaultfont . ', Verdana, Arial, Helvetica, sans-serif; font-size: ' . $userdefaultfontsize / 10 * 1.1 . 'px; } a, .linksize { font-size: ' . $userdefaultfontsize / 10 * 1.1 . 'px; } .ui-menu, .title { font-size: ' . $userdefaultfontsize / 10 * 1.3 . 'px; } .ui-button, .ErrorMsg, .topmenu2 { font-size: ' . $userdefaultfontsize / 10 * 1.2 . 'px; } </style>'; // --- }
private function CreateSQLWhereClause() { if ($this->_filters != null) { global $dbmapping; $szTableType = $this->_logStreamConfigObj->DBTableType; // Reset WhereClause $this->_SQLwhereClause = ""; // --- Build Query Array $arrayQueryProperties = $this->_arrProperties; if (isset($this->_arrFilterProperties) && $this->_arrFilterProperties != null) { foreach ($this->_arrFilterProperties as $filterproperty) { if ($this->_arrProperties == null || !in_array($filterproperty, $this->_arrProperties)) { $arrayQueryProperties[] = $filterproperty; } } } // --- // Loop through all available properties foreach ($arrayQueryProperties as $propertyname) { // If the property exists in the filter array, we have something to filter for ^^! if (array_key_exists($propertyname, $this->_filters)) { // Process all filters foreach ($this->_filters[$propertyname] as $myfilter) { // Only perform if database mapping is available for this filter! if (isset($dbmapping[$szTableType]['DBMAPPINGS'][$propertyname])) { switch ($myfilter[FILTER_TYPE]) { case FILTER_TYPE_STRING: // --- Either make a LIKE or a equal query! if ($myfilter[FILTER_MODE] & FILTER_MODE_SEARCHFULL) { // Set addnot to nothing $addnod = ""; // --- Check if user wants to include or exclude! if ($myfilter[FILTER_MODE] & FILTER_MODE_INCLUDE) { $szSearchBegin = " = '"; $szSearchEnd = "' "; } else { $szSearchBegin = " <> '"; $szSearchEnd = "' "; } // --- } else { if ($myfilter[FILTER_MODE] & FILTER_MODE_SEARCHREGEX) { //REGEXP Supported by MYSQL if ($this->_logStreamConfigObj->DBType == DB_MYSQL) { // --- Check if user wants to include or exclude! if ($myfilter[FILTER_MODE] & FILTER_MODE_INCLUDE) { $addnod = " "; } else { $addnod = " NOT"; } // --- $szSearchBegin = "REGEXP '"; $szSearchEnd = "' "; } else { if ($this->_logStreamConfigObj->DBType == DB_PGSQL) { // --- Check if user wants to include or exclude! if ($myfilter[FILTER_MODE] & FILTER_MODE_INCLUDE) { $addnod = " "; } else { $addnod = " !"; } // --- $szSearchBegin = "~* '"; $szSearchEnd = "' "; } else { // --- Check if user wants to include or exclude! if ($myfilter[FILTER_MODE] & FILTER_MODE_INCLUDE) { $addnod = " "; } else { $addnod = " NOT"; } // --- // Database Layer does not support REGEXP $szSearchBegin = "LIKE '%"; $szSearchEnd = "%' "; } } } else { // --- Check if user wants to include or exclude! if ($myfilter[FILTER_MODE] & FILTER_MODE_INCLUDE) { $addnod = ""; } else { $addnod = " NOT"; } // --- $szSearchBegin = " LIKE '%"; $szSearchEnd = "%' "; } } // --- // --- If Syslog message, we have AND handling, otherwise OR! if ($propertyname == SYSLOG_MESSAGE) { $addor = " AND "; } else { // If we exclude filters, we need to combine with AND if ($myfilter[FILTER_MODE] & FILTER_MODE_INCLUDE) { $addor = " OR "; } else { $addor = " AND "; } } // --- // Not create LIKE Filters if (isset($tmpfilters[$propertyname])) { $tmpfilters[$propertyname][FILTER_VALUE] .= $addor . $dbmapping[$szTableType]['DBMAPPINGS'][$propertyname] . $addnod . $szSearchBegin . DB_RemoveBadChars($myfilter[FILTER_VALUE], $this->_logStreamConfigObj->DBType) . $szSearchEnd; } else { $tmpfilters[$propertyname][FILTER_TYPE] = FILTER_TYPE_STRING; $tmpfilters[$propertyname][FILTER_VALUE] = $dbmapping[$szTableType]['DBMAPPINGS'][$propertyname] . $addnod . $szSearchBegin . DB_RemoveBadChars($myfilter[FILTER_VALUE], $this->_logStreamConfigObj->DBType) . $szSearchEnd; } break; case FILTER_TYPE_NUMBER: // --- Check if user wants to include or exclude! if ($myfilter[FILTER_MODE] & FILTER_MODE_EXCLUDE) { // Add to filterset $szArrayKey = $propertyname . "-NOT"; if (isset($tmpfilters[$szArrayKey])) { $tmpfilters[$szArrayKey][FILTER_VALUE] .= ", " . $myfilter[FILTER_VALUE]; } else { $tmpfilters[$szArrayKey][FILTER_TYPE] = FILTER_TYPE_NUMBER; $tmpfilters[$szArrayKey][FILTER_VALUE] = $dbmapping[$szTableType]['DBMAPPINGS'][$propertyname] . " NOT IN (" . DB_RemoveBadChars($myfilter[FILTER_VALUE], $this->_logStreamConfigObj->DBType); } } else { // Add to filterset if (isset($tmpfilters[$propertyname])) { $tmpfilters[$propertyname][FILTER_VALUE] .= ", " . $myfilter[FILTER_VALUE]; } else { $tmpfilters[$propertyname][FILTER_TYPE] = FILTER_TYPE_NUMBER; $tmpfilters[$propertyname][FILTER_VALUE] = $dbmapping[$szTableType]['DBMAPPINGS'][$propertyname] . " IN (" . DB_RemoveBadChars($myfilter[FILTER_VALUE], $this->_logStreamConfigObj->DBType); } } // --- break; case FILTER_TYPE_DATE: if (isset($tmpfilters[$propertyname])) { $tmpfilters[$propertyname][FILTER_VALUE] .= " AND "; } else { $tmpfilters[$propertyname][FILTER_VALUE] = ""; $tmpfilters[$propertyname][FILTER_TYPE] = FILTER_TYPE_DATE; } if ($myfilter[FILTER_DATEMODE] == DATEMODE_LASTX) { // Get current timestamp $nNowTimeStamp = time(); if ($myfilter[FILTER_VALUE] == DATE_LASTX_HOUR) { $nNowTimeStamp -= 60 * 60; } else { if ($myfilter[FILTER_VALUE] == DATE_LASTX_12HOURS) { $nNowTimeStamp -= 60 * 60 * 12; } else { if ($myfilter[FILTER_VALUE] == DATE_LASTX_24HOURS) { $nNowTimeStamp -= 60 * 60 * 24; } else { if ($myfilter[FILTER_VALUE] == DATE_LASTX_7DAYS) { $nNowTimeStamp -= 60 * 60 * 24 * 7; } else { if ($myfilter[FILTER_VALUE] == DATE_LASTX_31DAYS) { $nNowTimeStamp -= 60 * 60 * 24 * 31; } else { // Set filter to unknown and Abort in this case! $tmpfilters[$propertyname][FILTER_TYPE] = FILTER_TYPE_UNKNOWN; break; } } } } } // Append filter $tmpfilters[$propertyname][FILTER_VALUE] .= $dbmapping[$szTableType]['DBMAPPINGS'][$propertyname] . " > '" . date("Y-m-d H:i:s", $nNowTimeStamp) . "'"; } else { if ($myfilter[FILTER_DATEMODE] == DATEMODE_RANGE_FROM) { // Obtain Event struct for the time! $myeventtime = GetEventTime($myfilter[FILTER_VALUE]); $tmpfilters[$propertyname][FILTER_VALUE] .= $dbmapping[$szTableType]['DBMAPPINGS'][$propertyname] . " > '" . date("Y-m-d H:i:s", $myeventtime[EVTIME_TIMESTAMP]) . "'"; } else { if ($myfilter[FILTER_DATEMODE] == DATEMODE_RANGE_TO) { // Obtain Event struct for the time! $myeventtime = GetEventTime($myfilter[FILTER_VALUE]); $tmpfilters[$propertyname][FILTER_VALUE] .= $dbmapping[$szTableType]['DBMAPPINGS'][$propertyname] . " < '" . date("Y-m-d H:i:s", $myeventtime[EVTIME_TIMESTAMP]) . "'"; } else { if ($myfilter[FILTER_DATEMODE] == DATEMODE_RANGE_DATE) { // Obtain Event struct for the time! $myeventtime = GetEventTime($myfilter[FILTER_VALUE]); $tmpfilters[$propertyname][FILTER_VALUE] .= $dbmapping[$szTableType]['DBMAPPINGS'][$propertyname] . " > '" . date("Y-m-d H:i:s", $myeventtime[EVTIME_TIMESTAMP]) . "' AND " . $dbmapping[$szTableType]['DBMAPPINGS'][$propertyname] . " < '" . date("Y-m-d H:i:s", $myeventtime[EVTIME_TIMESTAMP] + 86400) . "'"; } } } } break; default: // Nothing to do! break; } } else { // Check how to treat not found db mappings / filters if (GetConfigSetting("TreatNotFoundFiltersAsTrue", 0, CFGLEVEL_USER) == 0) { return ERROR_DB_DBFIELDNOTFOUND; } } } } } // Check and combine all filters now! if (isset($tmpfilters)) { // Append filters foreach ($tmpfilters as $tmpfilter) { // Init WHERE or Append AND if (strlen($this->_SQLwhereClause) > 0) { $this->_SQLwhereClause .= " AND "; } else { $this->_SQLwhereClause = " WHERE "; } switch ($tmpfilter[FILTER_TYPE]) { case FILTER_TYPE_STRING: $this->_SQLwhereClause .= "( " . $tmpfilter[FILTER_VALUE] . ") "; break; case FILTER_TYPE_NUMBER: $this->_SQLwhereClause .= $tmpfilter[FILTER_VALUE] . ") "; break; case FILTER_TYPE_DATE: $this->_SQLwhereClause .= $tmpfilter[FILTER_VALUE]; break; default: // Should not happen, wrong filters! // We add a dummy into the where clause, just as a place holder $this->_SQLwhereClause .= " 1=1 "; break; } } } //echo $this->_SQLwhereClause; //$dbmapping[$szTableType][SYSLOG_UID] } else { // No filters means nothing to do! return SUCCESS; } }
// This will disable to Main SyslogView and show an error message $content['error_occured'] = true; $content['error_details'] = GetErrorMessage($res); if (isset($extraErrorDescription)) { $content['error_details'] .= "\n\n" . GetAndReplaceLangStr($content['LN_SOURCES_ERROR_EXTRAMSG'], $extraErrorDescription); } } // Close file! $stream->Close(); } else { $content['error_occured'] = true; $content['error_details'] = GetAndReplaceLangStr($content['LN_GEN_ERROR_SOURCENOTFOUND'], $currentSourceID); } } if ($content['error_occured']) { // Use JpGraph to display errors! $myError = new JpGraphErrObjectImg(); $myError->SetTitle($content['LN_GEN_ERRORDETAILS']); if (GetConfigSetting("MiscShowDebugMsg", 0, CFGLEVEL_USER) == 1) { $myError->Raise($content['error_details'] . "\n\nDebug Details: \n" . var_export($content['DEBUGMSG'], true), true); } else { $myError->Raise($content['error_details'], true); } // Exit in any case exit; } // --- // --- Output the image //$graph->Stroke(); $graph->StrokeCSIM(basename(__FILE__), '', 0); // ---
function AddContextLinks(&$sourceTxt) { global $szTLDDomains; // Return if not enabled! if (GetConfigSetting("EnableIPAddressResolve", 0, CFGLEVEL_USER) == 1) { // Search for IP's and Add Reverse Lookup first! $sourceTxt = preg_replace('/([^\\[])\\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b/ie', "'\\1\\2.\\3.\\4.\\5' . ReverseResolveIP('\\2.\\3.\\4.\\5', '<font class=\"highlighted\"> {', '} </font>')", $sourceTxt); } // check if user disabled Context Links. if (GetConfigSetting("EnableContextLinks", 1, CFGLEVEL_USER) == 0) { return; } // Create if not set! if (!isset($szTLDDomains)) { CreateTopLevelDomainSearch(); } // Create Search Array $search = array('/\\.([\\w\\d\\_\\-]+)\\.(' . $szTLDDomains . ')([^a-zA-Z0-9\\.])/ie', '/(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/ie'); // Create Replace Array $replace = array("'.' . InsertLookupLink(\"\", \"\\1.\\2\", \"\", \"\\3\")", "InsertLookupLink(\"\\1.\\2.\\3.\\4\", \"\", \"\", \"\")"); // Replace and return! $sourceTxt = preg_replace($search, $replace, $sourceTxt); //echo $outTxt . " <br>" ; //return $outTxt; }
function AddOnClickMenu(&$fieldGridItem, $fieldType, $FieldID) { global $content, $fields, $myStrCharLimit; // Set OnClick Menu for SYSLOG_SYSLOGTAG $fieldGridItem['hasbuttons'] = true; // Set Field Caption if (isset($content['fields'][$FieldID]['FieldCaption']) && strlen($content['fields'][$FieldID]['FieldCaption']) > 0) { $szFieldDisplayName = $content['fields'][$FieldID]['FieldCaption']; } else { $szFieldDisplayName = $FieldID; } // Set FieldSearch Value if ($fieldType == FILTER_TYPE_STRING && isset($fieldGridItem['encodedfieldvalue'])) { $szEncodedFieldValue = urlencode($fieldGridItem['encodedfieldvalue']); } else { $szEncodedFieldValue = $fieldGridItem['fieldvalue']; } // Set FieldSearchName if (isset($fields[$FieldID]['SearchField'])) { $szSearchFieldName = $fields[$FieldID]['SearchField']; } else { $szSearchFieldName = $FieldID; } // Menu Option to append filter if (strlen($content['searchstr']) > 0) { $fieldGridItem['buttons'][] = array('ButtonUrl' => '?filter=' . urlencode($content['searchstr']) . '+' . $szSearchFieldName . '%3A%3D' . $szEncodedFieldValue . '&search=Search' . $content['additional_url_sourceonly'], 'ButtonTarget' => '_top', 'ButtonAppendUrl' => true, 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_ADDTOFILTER'], $fieldGridItem['fieldvalue']), 'IconSource' => $content['MENU_BULLET_GREEN']); $fieldGridItem['buttons'][] = array('ButtonUrl' => '?filter=' . urlencode($content['searchstr']) . '+' . $szSearchFieldName . '%3A-%3D' . $szEncodedFieldValue . '&search=Search' . $content['additional_url_sourceonly'], 'ButtonTarget' => '_top', 'ButtonAppendUrl' => true, 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_EXCLUDEFILTER'], $fieldGridItem['fieldvalue']), 'IconSource' => $content['MENU_BULLET_GREEN']); } // More Menu entries $fieldGridItem['buttons'][] = array('ButtonUrl' => '?filter=' . $szSearchFieldName . '%3A%3D' . $szEncodedFieldValue . '&search=Search' . $content['additional_url_sourceonly'], 'ButtonTarget' => '_top', 'ButtonAppendUrl' => true, 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_FILTERFORONLY'], $fieldGridItem['fieldvalue']), 'IconSource' => $content['MENU_BULLET_BLUE']); $fieldGridItem['buttons'][] = array('ButtonUrl' => '?filter=' . $szSearchFieldName . '%3A-%3D' . $szEncodedFieldValue . '&search=Search' . $content['additional_url_sourceonly'], 'ButtonTarget' => '_top', 'ButtonAppendUrl' => true, 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_SHOWALLBUT'], $fieldGridItem['fieldvalue']), 'IconSource' => $content['MENU_BULLET_BLUE']); // Add Online Search Button if (isset($fields[$FieldID]['SearchOnline']) && $fields[$FieldID]['SearchOnline'] && strlen($fieldGridItem['fieldvalue']) > 0) { $fieldGridItem['buttons'][] = array('ButtonUrl' => 'http://kb.monitorware.com/kbsearch.php?sa=Search&origin=phplogcon&oid=' . $FieldID . '&q=' . $szEncodedFieldValue, 'ButtonTarget' => '_top', 'ButtonAppendUrl' => true, 'DisplayName' => $content['LN_VIEW_SEARCHFOR'] . " " . $szFieldDisplayName . " '" . $fieldGridItem['fieldvalue'] . "'", 'IconSource' => $content['MENU_NETWORK']); if (GetConfigSetting("InlineOnlineSearchIcons", 1, CFGLEVEL_USER) == 1) { // Enable SearchOnline Icon $fieldGridItem['searchonline'] = true; $fieldGridItem['SearchOnlineUrl'] = 'http://kb.monitorware.com/kbsearch.php?sa=Search&origin=phplogcon&oid=' . $FieldID . '&q=' . $szEncodedFieldValue; } } // Search for links within the fieldcontent! if ($fieldType == FILTER_TYPE_STRING && preg_match("#([\\w]+?://[\\w\\#\$%&~/.\\-;:=,?@\\[\\]+]*)#is", $fieldGridItem['rawfieldvalue'], $szLink) >= 1) { $fieldGridItem['buttons'][] = array('ButtonUrl' => $szLink[0], 'ButtonTarget' => '_blank', 'ButtonAppendUrl' => false, 'DisplayName' => GetAndReplaceLangStr($content['LN_VIEW_VISITLINK'], strlen($szLink[0]) > $myStrCharLimit ? substr($szLink[0], 0, $myStrCharLimit) . "..." : $szLink[0]), 'IconSource' => $content['MENU_NETWORK']); } }
function DebugLDAPErrorAndDie($szErrorMsg, $szLdapFilter) { global $content; // Add extra debug if wanted! if (GetConfigSetting("MiscShowDebugMsg", 0, CFGLEVEL_USER) == 1) { $szErrorMsg .= "</br></br>LDAPBind DN: " . $content['LDAPBindDN'] . "</br>Search Filter: " . $szLdapFilter . "</br><pre>Session Array: </br>" . var_export($_SESSION, true) . "</pre>"; } // USER NOT FOUND DieWithFriendlyErrorMsg($szErrorMsg); }
function parser($vars = '', $filename = '') { // BEGIN DELTA MOD // For MiscShowPageRenderStats if (GetConfigSetting("MiscShowPageRenderStats", 1, CFGLEVEL_USER) == 1) { FinishPageRenderStats($vars); } // END DELTA MOD if ($filename) { $this->filename = $filename; } if ($vars) { $this->vars = $vars; } if (!isset($this->template)) { $fname = $this->path . $this->filename . $this->extension; $this->template = $this->load_file($fname); } $this->page = $this->template_parser($this->template, $this->vars, $this->path, $this->extension); }
function GetRowsAffected() { // --- Abort in this case! if (GetConfigSetting("UserDBEnabled", false) == false) { return; } // --- return mysql_affected_rows(); }
include $gl_root_path . 'include/functions_filters.php'; // Include LogStream facility // include($gl_root_path . 'classes/logstream.class.php'); // Set PAGE to be ADMINPAGE! define('IS_ADMINPAGE', true); $content['IS_ADMINPAGE'] = true; InitPhpLogCon(); InitSourceConfigs(); InitFrontEndDefaults(); // Only in WebFrontEnd InitFilterHelpers(); // Helpers for frontend filtering! // Init admin langauge file now! IncludeLanguageFile($gl_root_path . '/lang/' . $LANG . '/admin.php'); // Configureable now! $content['REDIRSECONDS'] = GetConfigSetting("AdminChangeWaitTime", 2, CFGLEVEL_USER); // *** *** // // --- CONTENT Vars if (isset($_GET['redir'])) { $content['EXTRA_METATAGS'] = '<meta HTTP-EQUIV="REFRESH" CONTENT="' . $content['REDIRSECONDS'] . '; URL=' . urldecode($_GET['redir']) . '">'; $content['SZREDIR'] = urldecode($_GET['redir']); } else { $_GET['redir'] = "index.php"; } if (isset($_GET['msg'])) { $content['SZMSG'] = DB_StripSlahes($_GET['msg']); } else { $content['SZMSG'] = $content["LN_ADMIN_UNKNOWNSTATE"]; } $content['TITLE'] = "LogAnalyzer - Redirecting to '" . $content['SZREDIR'] . "' in " . $content['REDIRSECONDS'] . " seconds"; // Title of the Page
// Skip this entry and move to the next $stream->ReadNext($uID, $logArray); } } } else { // This will disable to Main SyslogView and show an error message $content['error_occured'] = true; $content['error_details'] = $content['LN_ERROR_NORECORDS']; } // --- // We found matching records, so continue if ($ret == SUCCESS) { //Loop through the messages! do { // --- Extra stuff for suppressing messages if (GetConfigSetting("SuppressDuplicatedMessages", 0, CFGLEVEL_USER) == 1 && isset($logArray[SYSLOG_MESSAGE])) { if (!isset($szLastMessage)) { // Only set lastmgr $szLastMessage = $logArray[SYSLOG_MESSAGE]; } else { // Skip if same msg if ($szLastMessage == $logArray[SYSLOG_MESSAGE]) { // Set last mgr $szLastMessage = $logArray[SYSLOG_MESSAGE]; // Skip entry continue; } } } // --- // --- Now we populate the values array!