mirror of
https://github.com/rsyslog/loganalyzer.git
synced 2025-09-26 11:19:26 +02:00
Hardened db logstream classes against invalid parameters.
Debug Messages are now printed well formated below the site content Fixed pager in detail page
This commit is contained in:
parent
8cf3ab5eb8
commit
88ff746e49
@ -121,6 +121,7 @@ class LogStreamDB extends LogStream {
|
||||
{
|
||||
if ($this->_dbhandle)
|
||||
mysql_close($this->_dbhandle);
|
||||
$this->_dbhandle = null;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@ -242,7 +243,7 @@ class LogStreamDB extends LogStream {
|
||||
}
|
||||
}
|
||||
|
||||
if ( $ret == SUCCESS )
|
||||
if ( $ret == SUCCESS && $this->_arrProperties != null )
|
||||
{
|
||||
// Init and set variables
|
||||
foreach ( $this->_arrProperties as $property )
|
||||
|
||||
@ -288,8 +288,11 @@ class LogStreamDisk extends LogStream {
|
||||
|
||||
// Init variables dynamically
|
||||
$line = '';
|
||||
foreach ( $this->_arrProperties as $property )
|
||||
$arrProperitesOut[$property] = '';
|
||||
if ( $this->_arrProperties != null )
|
||||
{
|
||||
foreach ( $this->_arrProperties as $property )
|
||||
$arrProperitesOut[$property] = '';
|
||||
}
|
||||
|
||||
do {
|
||||
$pos = -1;
|
||||
|
||||
@ -271,7 +271,7 @@ class LogStreamPDO extends LogStream {
|
||||
}
|
||||
}
|
||||
|
||||
if ( $ret == SUCCESS )
|
||||
if ( $ret == SUCCESS && $this->_arrProperties != null )
|
||||
{
|
||||
// Init and set variables
|
||||
foreach ( $this->_arrProperties as $property )
|
||||
|
||||
@ -64,6 +64,8 @@ else
|
||||
$content['uid_fromgetrequest'] = $content['uid_current'];
|
||||
|
||||
// Init Pager variables
|
||||
$content['uid_previous'] = UID_UNKNOWN;
|
||||
$content['uid_next'] = UID_UNKNOWN;
|
||||
$content['uid_first'] = UID_UNKNOWN;
|
||||
$content['uid_last'] = UID_UNKNOWN;
|
||||
$content['main_pagerenabled'] = false;
|
||||
@ -71,11 +73,13 @@ $content['main_pager_first_found'] = false;
|
||||
$content['main_pager_previous_found'] = false;
|
||||
$content['main_pager_next_found'] = false;
|
||||
$content['main_pager_last_found'] = false;
|
||||
// ---
|
||||
|
||||
// Set Default reading direction
|
||||
// --- If set read direction property!
|
||||
|
||||
// Set direction default
|
||||
$content['read_direction'] = EnumReadDirection::Backward;
|
||||
|
||||
// If set read direction property!
|
||||
if ( isset($_GET['direction']) )
|
||||
{
|
||||
if ( $_GET['direction'] == "next" )
|
||||
@ -88,7 +92,12 @@ if ( isset($_GET['direction']) )
|
||||
$content['skiprecords'] = 1;
|
||||
$content['read_direction'] = EnumReadDirection::Forward;
|
||||
}
|
||||
else if ( $_GET['direction'] == "desc" )
|
||||
{
|
||||
$content['read_direction'] = EnumReadDirection::Forward;
|
||||
}
|
||||
}
|
||||
// ---
|
||||
|
||||
// Init Sorting variables
|
||||
$content['sorting'] = "";
|
||||
@ -122,7 +131,7 @@ if ( isset($content['Sources'][$currentSourceID]) ) // && $content['uid_current'
|
||||
$res = $stream->Open( $content['AllColumns'], true );
|
||||
if ( $res == SUCCESS )
|
||||
{
|
||||
// TODO Implement ORDER
|
||||
// Set Read direction
|
||||
$stream->SetReadDirection($content['read_direction']);
|
||||
|
||||
// Set current ID and init Counter
|
||||
@ -279,9 +288,9 @@ if ( isset($content['Sources'][$currentSourceID]) ) // && $content['uid_current'
|
||||
{
|
||||
// Enable Pager in any case here!
|
||||
$content['main_pagerenabled'] = true;
|
||||
/*
|
||||
|
||||
// --- Handle uid_first page button
|
||||
if ( $content['uid_fromgetrequest'] == $content['uid_first'] )
|
||||
if ( $content['uid_fromgetrequest'] == $content['uid_first'] && $content['read_direction'] != EnumReadDirection::Forward )
|
||||
$content['main_pager_first_found'] = false;
|
||||
else
|
||||
{
|
||||
@ -293,32 +302,71 @@ if ( isset($content['Sources'][$currentSourceID]) ) // && $content['uid_current'
|
||||
$content['main_pager_first_found'] = false;
|
||||
}
|
||||
// ---
|
||||
*/
|
||||
|
||||
// --- Handle uid_last page button
|
||||
// Option the last UID from the stream!
|
||||
$content['uid_last'] = $stream->GetLastPageUID();
|
||||
$content['uid_first'] = $stream->GetFirstPageUID();
|
||||
|
||||
// --- Handle uid_first page button
|
||||
if ( $content['uid_current'] == $content['uid_first'] )
|
||||
// --- Handle uid_first and uid_previousbutton
|
||||
if ( $content['uid_current'] == $content['uid_first'] || !$content['main_pager_first_found'] )
|
||||
{
|
||||
$content['main_pager_first_found'] = false;
|
||||
$content['main_pager_previous_found'] = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$content['main_pager_first_found'] = true;
|
||||
$content['main_pager_previous_found'] = true;
|
||||
}
|
||||
// ---
|
||||
|
||||
|
||||
// if we found a last uid, and if it is not the current one (which means we already are on the last page ;)!
|
||||
if ( $content['uid_last'] != -1 && $content['uid_last'] != $content['uid_current'])
|
||||
$content['main_pager_last_found'] = true;
|
||||
else
|
||||
// --- Handle uid_next and uid_last button
|
||||
if ( $content['uid_current'] == $content['uid_last'] )
|
||||
{
|
||||
$content['main_pager_next_found'] = false;
|
||||
$content['main_pager_last_found'] = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$content['main_pager_next_found'] = true;
|
||||
$content['main_pager_last_found'] = true;
|
||||
}
|
||||
// ---
|
||||
|
||||
/*
|
||||
// if we found a last uid, and if it is not the current one (which means we already are on the last page ;)!
|
||||
if ( $content['read_direction'] == EnumReadDirection::Forward )
|
||||
{
|
||||
if ( $content['uid_last'] != UID_UNKNOWN )
|
||||
$content['main_pager_last_found'] = true;
|
||||
else
|
||||
$content['main_pager_last_found'] = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $content['uid_last'] != $content['uid_current'])
|
||||
$content['main_pager_last_found'] = true;
|
||||
else
|
||||
$content['main_pager_last_found'] = false;
|
||||
}
|
||||
// ---
|
||||
|
||||
// --- Handle uid_next page button
|
||||
if ( $content['uid_current'] != $content['uid_last'] )
|
||||
$content['main_pager_next_found'] = true;
|
||||
if ( $content['read_direction'] == EnumReadDirection::Forward )
|
||||
{
|
||||
if ( $content['uid_current'] != UID_UNKNOWN )
|
||||
$content['main_pager_next_found'] = true;
|
||||
else
|
||||
$content['main_pager_next_found'] = false;
|
||||
}
|
||||
else
|
||||
$content['main_pager_next_found'] = false;
|
||||
{
|
||||
if ( $content['uid_current'] != $content['uid_last'] )
|
||||
$content['main_pager_next_found'] = true;
|
||||
else
|
||||
$content['main_pager_next_found'] = false;
|
||||
}
|
||||
// ---
|
||||
|
||||
// --- Handle uid_previous page button
|
||||
@ -327,6 +375,9 @@ if ( isset($content['Sources'][$currentSourceID]) ) // && $content['uid_current'
|
||||
else
|
||||
$content['main_pager_previous_found'] = false;
|
||||
// ---
|
||||
|
||||
*/
|
||||
|
||||
}
|
||||
else // Disable pager in this case!
|
||||
$content['main_pagerenabled'] = false;
|
||||
|
||||
@ -234,13 +234,17 @@ function GetFormatedDate($evttimearray)
|
||||
|
||||
function OutputDebugMessage($szDbg, $szDbgLevel = DEBUG_INFO)
|
||||
{
|
||||
global $content;
|
||||
|
||||
// Check if we should print the Error!
|
||||
if ( GetConfigSetting("MiscShowDebugMsg", 0, CFGLEVEL_USER) == 1 )
|
||||
{
|
||||
print("<table width=\"600\" align=\"center\" class=\"with_border\">");
|
||||
print("<tr><td valign='top'><B>Debugmessage:</B> </td>");
|
||||
print("<td>" . $szDbg . "</td></tr>");
|
||||
print("</table><br>");
|
||||
$content['DEBUGMSG'][] = array(
|
||||
"DBGLEVEL" => $szDbgLevel,
|
||||
"DBGLEVELTXT" => GetDebugModeString($szDbgLevel),
|
||||
"DBGLEVELBG" => GetDebugBgColor($szDbgLevel),
|
||||
"DBGMSG" => "$szDbg"
|
||||
);
|
||||
}
|
||||
|
||||
// Check if the user wants to syslog the error!
|
||||
@ -250,6 +254,63 @@ function OutputDebugMessage($szDbg, $szDbgLevel = DEBUG_INFO)
|
||||
}
|
||||
}
|
||||
|
||||
function GetDebugBgColor( $szDebugMode )
|
||||
{
|
||||
global $severity_colors;
|
||||
|
||||
switch ( $szDebugMode )
|
||||
{
|
||||
case DEBUG_ULTRADEBUG:
|
||||
$szReturn = $severity_colors[SYSLOG_DEBUG];
|
||||
break;
|
||||
case DEBUG_DEBUG:
|
||||
$szReturn = $severity_colors[SYSLOG_INFO];
|
||||
break;
|
||||
case DEBUG_INFO:
|
||||
$szReturn = $severity_colors[SYSLOG_NOTICE];
|
||||
break;
|
||||
case DEBUG_WARN:
|
||||
$szReturn = $severity_colors[SYSLOG_WARNING];
|
||||
break;
|
||||
case DEBUG_ERROR:
|
||||
$szReturn = $severity_colors[SYSLOG_ERR];
|
||||
break;
|
||||
default:
|
||||
$szReturn = $severity_colors[SYSLOG_NOTICE];
|
||||
}
|
||||
|
||||
// Return string result
|
||||
return $szReturn;
|
||||
}
|
||||
|
||||
function GetDebugModeString( $szDebugMode )
|
||||
{
|
||||
switch ( $szDebugMode )
|
||||
{
|
||||
case DEBUG_ULTRADEBUG:
|
||||
$szReturn = STR_DEBUG_ULTRADEBUG;
|
||||
break;
|
||||
case DEBUG_DEBUG:
|
||||
$szReturn = STR_DEBUG_DEBUG;
|
||||
break;
|
||||
case DEBUG_INFO:
|
||||
$szReturn = STR_DEBUG_INFO;
|
||||
break;
|
||||
case DEBUG_WARN:
|
||||
$szReturn = STR_DEBUG_WARN;
|
||||
break;
|
||||
case DEBUG_ERROR:
|
||||
$szReturn = STR_DEBUG_ERROR;
|
||||
break;
|
||||
default:
|
||||
$szReturn = STR_DEBUG_INFO;
|
||||
}
|
||||
|
||||
// Return string result
|
||||
return $szReturn;
|
||||
}
|
||||
|
||||
|
||||
function GetPriorityFromDebugLevel( $DebugLevel )
|
||||
{
|
||||
switch ( $DebugLevel )
|
||||
|
||||
@ -100,6 +100,9 @@ $content['LN_ERROR_DB_DBFIELDNOTFOUND'] = "Database Field mapping for at least o
|
||||
$content['LN_WARNING_DBUPGRADE'] = "Database Upgrade required";
|
||||
$content['LN_WARNING_DBUPGRADE_TEXT'] = "The current installed database version is '%1'.<br>An update to version '%2' is available.";
|
||||
$content['LN_ERROR_REDIRECTABORTED'] = 'Automatic redirect to the <a href="%1">page</a> was aborted, as an internal error occured. Please see the error details above and contact our support forums if you need assistance.';
|
||||
$content['LN_DEBUGLEVEL'] = "Debug Level";
|
||||
$content['LN_DEBUGMESSAGE'] = "Debug Message";
|
||||
|
||||
|
||||
// Topmenu Entries
|
||||
$content['LN_MENU_SEARCH'] = "Search";
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
<td class="cellmenu2" nowrap><B>Pager: </B></td>
|
||||
<td class="line0" width="20" nowrap>
|
||||
<!-- IF main_pager_first_found="true" -->
|
||||
<a href="?{additional_url_sortingonly}&uid={uid_first}" target="_top"><img src="{MENU_PAGER_BEGIN}" width="16" height="16" alt="{LN_GEN_FIRSTPAGE}" title="{LN_GEN_FIRSTPAGE}"></a>
|
||||
<a href="?{additional_url_sortingonly}&uid=-1{additional_url}" target="_top"><img src="{MENU_PAGER_BEGIN}" width="16" height="16" alt="{LN_GEN_FIRSTPAGE}" title="{LN_GEN_FIRSTPAGE}"></a>
|
||||
<!-- ENDIF main_pager_first_found="true" -->
|
||||
<!-- IF main_pager_first_found!="true" -->
|
||||
<img src="{MENU_PAGER_BEGIN_GREY}" width="16" height="16">
|
||||
@ -31,7 +31,7 @@
|
||||
|
||||
<td class="line1" width="20" nowrap>
|
||||
<!-- IF main_pager_previous_found="true" -->
|
||||
<a href="?{additional_url_sortingonly}&uid={uid_current}&direction=previous" target="_top"><img src="{MENU_PAGER_PREVIOUS}" width="16" alt="{LN_GEN_PREVIOUSPAGE}" title="{LN_GEN_PREVIOUSPAGE}"></a>
|
||||
<a href="?{additional_url_sortingonly}&uid={uid_current}&direction=previous{additional_url}" target="_top"><img src="{MENU_PAGER_PREVIOUS}" width="16" alt="{LN_GEN_PREVIOUSPAGE}" title="{LN_GEN_PREVIOUSPAGE}"></a>
|
||||
<!-- ENDIF main_pager_previous_found="true" -->
|
||||
<!-- IF main_pager_previous_found!="true" -->
|
||||
<img src="{MENU_PAGER_PREVIOUS_GREY}" width="16" height="16">
|
||||
@ -44,7 +44,7 @@
|
||||
|
||||
<td class="line0" width="20" nowrap>
|
||||
<!-- IF main_pager_next_found="true" -->
|
||||
<a href="?{additional_url_sortingonly}&uid={uid_current}&direction=next" target="_top"><img src="{MENU_PAGER_NEXT}" width="16" alt="{LN_GEN_NEXTPAGE}" title="{LN_GEN_NEXTPAGE}"></a>
|
||||
<a href="?{additional_url_sortingonly}&uid={uid_current}&direction=next{additional_url}" target="_top"><img src="{MENU_PAGER_NEXT}" width="16" alt="{LN_GEN_NEXTPAGE}" title="{LN_GEN_NEXTPAGE}"></a>
|
||||
<!-- ENDIF main_pager_next_found="true" -->
|
||||
<!-- IF main_pager_next_found!="true" -->
|
||||
<img src="{MENU_PAGER_NEXT_GREY}" width="16" height="16">
|
||||
@ -53,7 +53,7 @@
|
||||
|
||||
<td class="line1" width="20" nowrap>
|
||||
<!-- IF main_pager_last_found="true" -->
|
||||
<a href="?{additional_url_sortingonly}&uid={uid_last}" target="_top"><img src="{MENU_PAGER_END}" width="16" alt="{LN_GEN_LASTPAGE}" title="{LN_GEN_LASTPAGE}"></a>
|
||||
<a href="?{additional_url_sortingonly}&uid=-1&direction=desc{additional_url}" target="_top"><img src="{MENU_PAGER_END}" width="16" alt="{LN_GEN_LASTPAGE}" title="{LN_GEN_LASTPAGE}"></a>
|
||||
<!-- ENDIF main_pager_last_found="true" -->
|
||||
<!-- IF main_pager_last_found!="true" -->
|
||||
<img src="{MENU_PAGER_END_GREY}" width="16" height="16">
|
||||
|
||||
@ -35,6 +35,22 @@
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
<!-- BEGIN DEBUGMSG -->
|
||||
<table width="100%" border="0" cellspacing="1" cellpadding="2" align="center" class="with_border">
|
||||
<tr>
|
||||
<td nowrap align="left" nowrap valign="top" class="cellmenu1_naked">{LN_DEBUGLEVEL}</td>
|
||||
<td align="center" nowrap valign="top" class="cellmenu1_naked" width="100%">{LN_DEBUGMESSAGE}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td nowrap align="center" nowrap valign="top" class="lineColouredWhite" bgcolor="{DBGLEVELBG}"><B>{DBGLEVELTXT}</B></td>
|
||||
<td align="left" nowrap valign="middle" class="line1">
|
||||
<div id="SearchCode">{DBGMSG}</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- END DEBUGMSG -->
|
||||
|
||||
{EXTRA_FOOTER}
|
||||
</body>
|
||||
</html>
|
||||
@ -160,12 +160,12 @@
|
||||
<!-- ENDIF ViewEnableAutoReloadSeconds_visible="true" -->
|
||||
|
||||
<!-- IF main_recordcount_found="true" -->
|
||||
<td nowrap width="125" class="cellmenu2">{LN_GEN_RECORDCOUNT}:</td>
|
||||
<td nowrap width="130" class="cellmenu2">{LN_GEN_RECORDCOUNT}:</td>
|
||||
<td nowrap width="50" class="line2"><B>{main_recordcount}</B></td>
|
||||
<!-- ENDIF main_recordcount_found="true" -->
|
||||
|
||||
<!-- IF main_pagerenabled="true" -->
|
||||
<td nowrap width="115" class="cellmenu2">{LN_GEN_PAGERSIZE}:</td>
|
||||
<td nowrap width="120" class="cellmenu2">{LN_GEN_PAGERSIZE}:</td>
|
||||
<td nowrap width="50" class="line2">
|
||||
<form action="userchange.php" method="get" name="pageingsize">
|
||||
<input type="hidden" name="op" value="changepagesize">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user