From 28baedd51e11edd56ea1c36cdcd0501d3a2b261e Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Mon, 5 May 2008 11:42:25 +0200 Subject: [PATCH] Removed ^M from main php files --- src/.htaccess | 2 +- src/details.php | 718 +++++++++++------------ src/index.php | 1026 ++++++++++++++++----------------- src/install.php | 1374 ++++++++++++++++++++++---------------------- src/search.php | 358 ++++++------ src/userchange.php | 138 ++--- 6 files changed, 1808 insertions(+), 1808 deletions(-) diff --git a/src/.htaccess b/src/.htaccess index 86ea177..57b3dd3 100644 --- a/src/.htaccess +++ b/src/.htaccess @@ -1 +1 @@ -Options -indexes +Options -indexes diff --git a/src/details.php b/src/details.php index 71261bb..b373b0e 100644 --- a/src/details.php +++ b/src/details.php @@ -1,360 +1,360 @@ - Shows all possible details of a syslog message - * - * All directives are explained within this file - * - * Copyright (C) 2008 Adiscon GmbH. - * - * This file is part of phpLogCon. - * - * PhpLogCon is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PhpLogCon is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with phpLogCon. If not, see . - * - * A copy of the GPL can be found in the file "COPYING" in this - * distribution - ********************************************************************* -*/ - -// *** Default includes and procedures *** // -define('IN_PHPLOGCON', true); -$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_filters.php'); - -// Include LogStream facility -include($gl_root_path . 'classes/logstream.class.php'); - -InitPhpLogCon(); -InitSourceConfigs(); -InitFrontEndDefaults(); // Only in WebFrontEnd -InitFilterHelpers(); // Helpers for frontend filtering! -// --- - -// --- Define Extra Stylesheet! -//$content['EXTRA_STYLESHEET'] = '' . "\r\n"; -//$content['EXTRA_STYLESHEET'] .= ''; -// --- - -// --- CONTENT Vars -if ( isset($_GET['uid']) ) - $content['uid_current'] = intval($_GET['uid']); -else - $content['uid_current'] = UID_UNKNOWN; - -// Copy UID for later use ... -$content['uid_fromgetrequest'] = $content['uid_current']; - -// Init Pager variables -$content['uid_first'] = UID_UNKNOWN; -$content['uid_last'] = UID_UNKNOWN; -$content['main_pagerenabled'] = false; -$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 -$content['read_direction'] = EnumReadDirection::Backward; - -// If set read direction property! -if ( isset($_GET['direction']) ) -{ - if ( $_GET['direction'] == "next" ) - { - $content['skiprecords'] = 1; - $content['read_direction'] = EnumReadDirection::Backward; - } - else if ( $_GET['direction'] == "previous" ) - { - $content['skiprecords'] = 1; - $content['read_direction'] = EnumReadDirection::Forward; - } -} - -// Init Sorting variables -$content['sorting'] = ""; -$content['searchstr'] = ""; -$content['highlightstr'] = ""; -$content['EXPAND_HIGHLIGHT'] = "false"; - -// Set Page title -$content['TITLE'] = "phpLogCon :: Details"; - -// --- BEGIN Custom Code -if ( isset($content['Sources'][$currentSourceID]) ) // && $content['uid_current'] != UID_UNKNOWN ) // && $content['Sources'][$currentSourceID]['SourceType'] == SOURCE_DISK ) -{ - // Obtain and get the Config Object - $stream_config = $content['Sources'][$currentSourceID]['ObjRef']; - - // Create LogStream Object - $stream = $stream_config->LogStreamFactory($stream_config); -// $stream->SetFilter($content['searchstr']); - - // --- Init the fields we need - foreach($fields as $mycolkey => $myfield) - { - $content['fields'][$mycolkey]['FieldID'] = $mycolkey; - $content['fields'][$mycolkey]['FieldCaption'] = $content[ $myfield['FieldCaptionID'] ]; - $content['fields'][$mycolkey]['FieldType'] = $myfield['FieldType']; - $content['fields'][$mycolkey]['DefaultWidth'] = $myfield['DefaultWidth']; - - // Append to columns array - $content['AllColumns'][] = $mycolkey; - } - // --- - - $res = $stream->Open( $content['AllColumns'], true ); - if ( $res == SUCCESS ) - { - // TODO Implement ORDER - $stream->SetReadDirection($content['read_direction']); - - // Set current ID and init Counter - $uID = $content['uid_current']; - - if ( $uID != UID_UNKNOWN ) // We know the UID, so read from where we know - $ret = $stream->Read($uID, $logArray); - else // Unknown UID, so we start from first! - $ret = $stream->ReadNext($uID, $logArray); - - // --- If set we move forward / backward! - if ( isset($content['skiprecords']) && $content['skiprecords'] >= 1 ) - { - $counter = 0; - while( $counter < $content['skiprecords'] && ($ret = $stream->ReadNext($uID, $logArray)) == SUCCESS) - { - // Increment Counter - $counter++; - } - } - // --- - - // Set new current uid! - if ( isset($uID) && $uID != UID_UNKNOWN ) - $content['uid_current'] = $uID; - - // now we know enough to set the page title! - $content['TITLE'] = "phpLogCon :: " . $content['LN_DETAILS_DETAILSFORMSG'] . " '" . $uID . "'"; - - // We found matching records, so continue - if ( $ret == SUCCESS ) - { - // --- PreChecks to be done - // Set Record Count - $content['main_recordcount'] = $stream->GetMessageCount(); - if ( $content['main_recordcount'] != -1 ) - $content['main_recordcount_found'] = true; - else - $content['main_recordcount_found'] = false; - // --- - - // Loop through fields - Copy value into fields list! We are going to use this list here - $counter = 0; - foreach($content['fields'] as $mycolkey => $myfield) - { -// // Default copy value into array! -// $content['fields'][$mycolkey]['FieldValue'] = $logArray[$mycolkey]; - - // --- Set CSS Class - if ( $counter % 2 == 0 ) - $content['fields'][$mycolkey]['cssclass'] = "line1"; - else - $content['fields'][$mycolkey]['cssclass'] = "line2"; - // --- - - // Set defaults - $content['fields'][$mycolkey]['fieldbgcolor'] = ""; - $content['fields'][$mycolkey]['hasdetails'] = "false"; - - if ( $content['fields'][$mycolkey]['FieldType'] == FILTER_TYPE_DATE ) - { - $content['fields'][$mycolkey]['fieldvalue'] = GetFormatedDate($logArray[$mycolkey]); - // TODO: Show more! - } - else if ( $content['fields'][$mycolkey]['FieldType'] == FILTER_TYPE_NUMBER ) - { - $content['fields'][$mycolkey]['fieldvalue'] = $logArray[$mycolkey]; - - // Special style classes and colours for SYSLOG_FACILITY - if ( $mycolkey == SYSLOG_FACILITY ) - { - if ( isset($logArray[$mycolkey][SYSLOG_FACILITY]) && strlen($logArray[$mycolkey][SYSLOG_FACILITY]) > 0) - { - $content['fields'][$mycolkey]['fieldbgcolor'] = 'bgcolor="' . $facility_colors[ $logArray[SYSLOG_FACILITY] ] . '" '; - $content['fields'][$mycolkey]['cssclass'] = "lineColouredBlack"; - - // Set Human readable Facility! - $content['fields'][$mycolkey]['fieldvalue'] = GetFacilityDisplayName( $logArray[$mycolkey] ); - } - else - { - // Use default colour! - $content['fields'][$mycolkey]['fieldbgcolor'] = 'bgcolor="' . $facility_colors[SYSLOG_LOCAL0] . '" '; - } - } - else if ( $mycolkey == SYSLOG_SEVERITY ) - { - if ( isset($logArray[$mycolkey][SYSLOG_SEVERITY]) && strlen($logArray[$mycolkey][SYSLOG_SEVERITY]) > 0) - { - $content['fields'][$mycolkey]['fieldbgcolor'] = 'bgcolor="' . $severity_colors[ $logArray[SYSLOG_SEVERITY] ] . '" '; - $content['fields'][$mycolkey]['cssclass'] = "lineColouredWhite"; - - // Set Human readable Facility! - $content['fields'][$mycolkey]['fieldvalue'] = GetSeverityDisplayName( $logArray[$mycolkey] ); - } - else - { - // Use default colour! - $content['fields'][$mycolkey]['fieldbgcolor'] = 'bgcolor="' . $severity_colors[SYSLOG_INFO] . '" '; - } - } - else if ( $mycolkey == SYSLOG_MESSAGETYPE ) - { - if ( isset($logArray[$mycolkey][SYSLOG_MESSAGETYPE]) ) - { - $content['fields'][$mycolkey]['fieldbgcolor'] = 'bgcolor="' . $msgtype_colors[ $logArray[SYSLOG_MESSAGETYPE] ] . '" '; - $content['fields'][$mycolkey]['cssclass'] = "lineColouredBlack"; - - // Set Human readable Facility! - $content['fields'][$mycolkey]['fieldvalue'] = GetMessageTypeDisplayName( $logArray[$mycolkey] ); - } - else - { - // Use default colour! - $content['fields'][$mycolkey]['fieldbgcolor'] = 'bgcolor="' . $msgtype_colors[IUT_Unknown] . '" '; - } - - } - } - else if ( $content['fields'][$mycolkey]['FieldType'] == FILTER_TYPE_STRING ) - { - if ( $mycolkey == SYSLOG_MESSAGE ) - $content['fields'][$mycolkey]['fieldvalue'] = GetStringWithHTMLCodes($logArray[$mycolkey]); - else // kindly copy! - $content['fields'][$mycolkey]['fieldvalue'] = $logArray[$mycolkey]; - } - - // Increment helpcounter - $counter++; - } - -//print_r ( $content['fields'] ); -//exit; - - // Enable pager if the count is above 1 or we don't know the record count! - if ( $content['main_recordcount'] > 1 || $content['main_recordcount'] == -1 ) - { - // Enable Pager in any case here! - $content['main_pagerenabled'] = true; - - // --- Handle uid_first page button - if ( $content['uid_fromgetrequest'] == $content['uid_first'] ) - $content['main_pager_first_found'] = false; - else - { - // Probe next item ! - $ret = $stream->ReadNext($uID, $tmpArray); - if ( $ret == SUCCESS ) - $content['main_pager_first_found'] = true; - else - $content['main_pager_first_found'] = false; - } - // --- - - // --- Handle uid_last page button - // Option the last UID from the stream! - $content['uid_last'] = $stream->GetLastPageUID(); - - // 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 - $content['main_pager_last_found'] = false; - // --- - - // --- Handle uid_next page button - 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 - if ( $content['main_pager_first_found'] == true && $content['uid_current'] != $content['uid_first'] ) - $content['main_pager_previous_found'] = true; - else - $content['main_pager_previous_found'] = false; - // --- - } - else // Disable pager in this case! - $content['main_pagerenabled'] = false; - - // This will enable to Main SyslogView - $content['messageenabled'] = "true"; - } - else - { - // Disable view and print error state! - $content['messageenabled'] = "false"; - - // Set error code - $content['error_code'] = $ret; - - - if ( $ret == ERROR_UNDEFINED ) - $content['detailederror'] = "Undefined error happened within the logstream."; -// else if ( $ret == ERROR_FILE_NOT_READABLE ) -// $content['detailederror'] = "Syslog file is not readable, read access may be denied. "; - else - $content['detailederror'] = "Unknown or unhandeled error occured."; - - } - } - else - { - // This will disable to Main SyslogView and show an error message - $content['messageenabled'] = "false"; - - // Set error code - $content['error_code'] = $ret; - - if ( $ret == ERROR_FILE_NOT_FOUND ) - $content['detailederror'] = "Syslog file could not be found."; - else if ( $ret == ERROR_FILE_NOT_READABLE ) - $content['detailederror'] = "Syslog file is not readable, read access may be denied. "; - else - $content['detailederror'] = "Unknown or unhandeled error occured."; - - } - - // Close file! - $stream->Close(); -} -// --- - -// --- Parsen and Output -InitTemplateParser(); -$page -> parser($content, "details.html"); -$page -> output(); -// --- - + Shows all possible details of a syslog message + * + * All directives are explained within this file + * + * Copyright (C) 2008 Adiscon GmbH. + * + * This file is part of phpLogCon. + * + * PhpLogCon is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PhpLogCon is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with phpLogCon. If not, see . + * + * A copy of the GPL can be found in the file "COPYING" in this + * distribution + ********************************************************************* +*/ + +// *** Default includes and procedures *** // +define('IN_PHPLOGCON', true); +$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_filters.php'); + +// Include LogStream facility +include($gl_root_path . 'classes/logstream.class.php'); + +InitPhpLogCon(); +InitSourceConfigs(); +InitFrontEndDefaults(); // Only in WebFrontEnd +InitFilterHelpers(); // Helpers for frontend filtering! +// --- + +// --- Define Extra Stylesheet! +//$content['EXTRA_STYLESHEET'] = '' . "\r\n"; +//$content['EXTRA_STYLESHEET'] .= ''; +// --- + +// --- CONTENT Vars +if ( isset($_GET['uid']) ) + $content['uid_current'] = intval($_GET['uid']); +else + $content['uid_current'] = UID_UNKNOWN; + +// Copy UID for later use ... +$content['uid_fromgetrequest'] = $content['uid_current']; + +// Init Pager variables +$content['uid_first'] = UID_UNKNOWN; +$content['uid_last'] = UID_UNKNOWN; +$content['main_pagerenabled'] = false; +$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 +$content['read_direction'] = EnumReadDirection::Backward; + +// If set read direction property! +if ( isset($_GET['direction']) ) +{ + if ( $_GET['direction'] == "next" ) + { + $content['skiprecords'] = 1; + $content['read_direction'] = EnumReadDirection::Backward; + } + else if ( $_GET['direction'] == "previous" ) + { + $content['skiprecords'] = 1; + $content['read_direction'] = EnumReadDirection::Forward; + } +} + +// Init Sorting variables +$content['sorting'] = ""; +$content['searchstr'] = ""; +$content['highlightstr'] = ""; +$content['EXPAND_HIGHLIGHT'] = "false"; + +// Set Page title +$content['TITLE'] = "phpLogCon :: Details"; + +// --- BEGIN Custom Code +if ( isset($content['Sources'][$currentSourceID]) ) // && $content['uid_current'] != UID_UNKNOWN ) // && $content['Sources'][$currentSourceID]['SourceType'] == SOURCE_DISK ) +{ + // Obtain and get the Config Object + $stream_config = $content['Sources'][$currentSourceID]['ObjRef']; + + // Create LogStream Object + $stream = $stream_config->LogStreamFactory($stream_config); +// $stream->SetFilter($content['searchstr']); + + // --- Init the fields we need + foreach($fields as $mycolkey => $myfield) + { + $content['fields'][$mycolkey]['FieldID'] = $mycolkey; + $content['fields'][$mycolkey]['FieldCaption'] = $content[ $myfield['FieldCaptionID'] ]; + $content['fields'][$mycolkey]['FieldType'] = $myfield['FieldType']; + $content['fields'][$mycolkey]['DefaultWidth'] = $myfield['DefaultWidth']; + + // Append to columns array + $content['AllColumns'][] = $mycolkey; + } + // --- + + $res = $stream->Open( $content['AllColumns'], true ); + if ( $res == SUCCESS ) + { + // TODO Implement ORDER + $stream->SetReadDirection($content['read_direction']); + + // Set current ID and init Counter + $uID = $content['uid_current']; + + if ( $uID != UID_UNKNOWN ) // We know the UID, so read from where we know + $ret = $stream->Read($uID, $logArray); + else // Unknown UID, so we start from first! + $ret = $stream->ReadNext($uID, $logArray); + + // --- If set we move forward / backward! + if ( isset($content['skiprecords']) && $content['skiprecords'] >= 1 ) + { + $counter = 0; + while( $counter < $content['skiprecords'] && ($ret = $stream->ReadNext($uID, $logArray)) == SUCCESS) + { + // Increment Counter + $counter++; + } + } + // --- + + // Set new current uid! + if ( isset($uID) && $uID != UID_UNKNOWN ) + $content['uid_current'] = $uID; + + // now we know enough to set the page title! + $content['TITLE'] = "phpLogCon :: " . $content['LN_DETAILS_DETAILSFORMSG'] . " '" . $uID . "'"; + + // We found matching records, so continue + if ( $ret == SUCCESS ) + { + // --- PreChecks to be done + // Set Record Count + $content['main_recordcount'] = $stream->GetMessageCount(); + if ( $content['main_recordcount'] != -1 ) + $content['main_recordcount_found'] = true; + else + $content['main_recordcount_found'] = false; + // --- + + // Loop through fields - Copy value into fields list! We are going to use this list here + $counter = 0; + foreach($content['fields'] as $mycolkey => $myfield) + { +// // Default copy value into array! +// $content['fields'][$mycolkey]['FieldValue'] = $logArray[$mycolkey]; + + // --- Set CSS Class + if ( $counter % 2 == 0 ) + $content['fields'][$mycolkey]['cssclass'] = "line1"; + else + $content['fields'][$mycolkey]['cssclass'] = "line2"; + // --- + + // Set defaults + $content['fields'][$mycolkey]['fieldbgcolor'] = ""; + $content['fields'][$mycolkey]['hasdetails'] = "false"; + + if ( $content['fields'][$mycolkey]['FieldType'] == FILTER_TYPE_DATE ) + { + $content['fields'][$mycolkey]['fieldvalue'] = GetFormatedDate($logArray[$mycolkey]); + // TODO: Show more! + } + else if ( $content['fields'][$mycolkey]['FieldType'] == FILTER_TYPE_NUMBER ) + { + $content['fields'][$mycolkey]['fieldvalue'] = $logArray[$mycolkey]; + + // Special style classes and colours for SYSLOG_FACILITY + if ( $mycolkey == SYSLOG_FACILITY ) + { + if ( isset($logArray[$mycolkey][SYSLOG_FACILITY]) && strlen($logArray[$mycolkey][SYSLOG_FACILITY]) > 0) + { + $content['fields'][$mycolkey]['fieldbgcolor'] = 'bgcolor="' . $facility_colors[ $logArray[SYSLOG_FACILITY] ] . '" '; + $content['fields'][$mycolkey]['cssclass'] = "lineColouredBlack"; + + // Set Human readable Facility! + $content['fields'][$mycolkey]['fieldvalue'] = GetFacilityDisplayName( $logArray[$mycolkey] ); + } + else + { + // Use default colour! + $content['fields'][$mycolkey]['fieldbgcolor'] = 'bgcolor="' . $facility_colors[SYSLOG_LOCAL0] . '" '; + } + } + else if ( $mycolkey == SYSLOG_SEVERITY ) + { + if ( isset($logArray[$mycolkey][SYSLOG_SEVERITY]) && strlen($logArray[$mycolkey][SYSLOG_SEVERITY]) > 0) + { + $content['fields'][$mycolkey]['fieldbgcolor'] = 'bgcolor="' . $severity_colors[ $logArray[SYSLOG_SEVERITY] ] . '" '; + $content['fields'][$mycolkey]['cssclass'] = "lineColouredWhite"; + + // Set Human readable Facility! + $content['fields'][$mycolkey]['fieldvalue'] = GetSeverityDisplayName( $logArray[$mycolkey] ); + } + else + { + // Use default colour! + $content['fields'][$mycolkey]['fieldbgcolor'] = 'bgcolor="' . $severity_colors[SYSLOG_INFO] . '" '; + } + } + else if ( $mycolkey == SYSLOG_MESSAGETYPE ) + { + if ( isset($logArray[$mycolkey][SYSLOG_MESSAGETYPE]) ) + { + $content['fields'][$mycolkey]['fieldbgcolor'] = 'bgcolor="' . $msgtype_colors[ $logArray[SYSLOG_MESSAGETYPE] ] . '" '; + $content['fields'][$mycolkey]['cssclass'] = "lineColouredBlack"; + + // Set Human readable Facility! + $content['fields'][$mycolkey]['fieldvalue'] = GetMessageTypeDisplayName( $logArray[$mycolkey] ); + } + else + { + // Use default colour! + $content['fields'][$mycolkey]['fieldbgcolor'] = 'bgcolor="' . $msgtype_colors[IUT_Unknown] . '" '; + } + + } + } + else if ( $content['fields'][$mycolkey]['FieldType'] == FILTER_TYPE_STRING ) + { + if ( $mycolkey == SYSLOG_MESSAGE ) + $content['fields'][$mycolkey]['fieldvalue'] = GetStringWithHTMLCodes($logArray[$mycolkey]); + else // kindly copy! + $content['fields'][$mycolkey]['fieldvalue'] = $logArray[$mycolkey]; + } + + // Increment helpcounter + $counter++; + } + +//print_r ( $content['fields'] ); +//exit; + + // Enable pager if the count is above 1 or we don't know the record count! + if ( $content['main_recordcount'] > 1 || $content['main_recordcount'] == -1 ) + { + // Enable Pager in any case here! + $content['main_pagerenabled'] = true; + + // --- Handle uid_first page button + if ( $content['uid_fromgetrequest'] == $content['uid_first'] ) + $content['main_pager_first_found'] = false; + else + { + // Probe next item ! + $ret = $stream->ReadNext($uID, $tmpArray); + if ( $ret == SUCCESS ) + $content['main_pager_first_found'] = true; + else + $content['main_pager_first_found'] = false; + } + // --- + + // --- Handle uid_last page button + // Option the last UID from the stream! + $content['uid_last'] = $stream->GetLastPageUID(); + + // 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 + $content['main_pager_last_found'] = false; + // --- + + // --- Handle uid_next page button + 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 + if ( $content['main_pager_first_found'] == true && $content['uid_current'] != $content['uid_first'] ) + $content['main_pager_previous_found'] = true; + else + $content['main_pager_previous_found'] = false; + // --- + } + else // Disable pager in this case! + $content['main_pagerenabled'] = false; + + // This will enable to Main SyslogView + $content['messageenabled'] = "true"; + } + else + { + // Disable view and print error state! + $content['messageenabled'] = "false"; + + // Set error code + $content['error_code'] = $ret; + + + if ( $ret == ERROR_UNDEFINED ) + $content['detailederror'] = "Undefined error happened within the logstream."; +// else if ( $ret == ERROR_FILE_NOT_READABLE ) +// $content['detailederror'] = "Syslog file is not readable, read access may be denied. "; + else + $content['detailederror'] = "Unknown or unhandeled error occured."; + + } + } + else + { + // This will disable to Main SyslogView and show an error message + $content['messageenabled'] = "false"; + + // Set error code + $content['error_code'] = $ret; + + if ( $ret == ERROR_FILE_NOT_FOUND ) + $content['detailederror'] = "Syslog file could not be found."; + else if ( $ret == ERROR_FILE_NOT_READABLE ) + $content['detailederror'] = "Syslog file is not readable, read access may be denied. "; + else + $content['detailederror'] = "Unknown or unhandeled error occured."; + + } + + // Close file! + $stream->Close(); +} +// --- + +// --- Parsen and Output +InitTemplateParser(); +$page -> parser($content, "details.html"); +$page -> output(); +// --- + ?> \ No newline at end of file diff --git a/src/index.php b/src/index.php index 24e08a9..1a4b526 100644 --- a/src/index.php +++ b/src/index.php @@ -1,514 +1,514 @@ - Loads the main PhpLogCon Site - * - * All directives are explained within this file - * - * Copyright (C) 2008 Adiscon GmbH. - * - * This file is part of phpLogCon. - * - * PhpLogCon is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PhpLogCon is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with phpLogCon. If not, see . - * - * A copy of the GPL can be found in the file "COPYING" in this - * distribution - ********************************************************************* -*/ - -// *** Default includes and procedures *** // -define('IN_PHPLOGCON', true); -$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_filters.php'); - -// Init Langauge first! -// IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/main.php' ); - -// Include LogStream facility -include($gl_root_path . 'classes/logstream.class.php'); - -InitPhpLogCon(); -InitSourceConfigs(); -InitFrontEndDefaults(); // Only in WebFrontEnd -InitFilterHelpers(); // Helpers for frontend filtering! -// --- - -// --- Define Extra Stylesheet! -$content['EXTRA_STYLESHEET'] = '' . "\r\n"; -$content['EXTRA_STYLESHEET'] .= ''; -// --- - -// --- CONTENT Vars -if ( isset($_GET['uid']) ) - $content['uid_current'] = intval($_GET['uid']); -else - $content['uid_current'] = UID_UNKNOWN; - -// 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; -$content['main_pager_first_found'] = false; -$content['main_pager_previous_found'] = false; -$content['main_pager_next_found'] = false; -$content['main_pager_last_found'] = false; - - -if ( isset($_GET['direction']) && $_GET['direction'] == "desc" ) - $content['read_direction'] = EnumReadDirection::Forward; -else - $content['read_direction'] = EnumReadDirection::Backward; - -// Init Sorting variables -$content['sorting'] = ""; -$content['searchstr'] = ""; -$content['highlightstr'] = ""; -$content['EXPAND_HIGHLIGHT'] = "false"; - - -//if ( isset($content['myserver']) ) -// $content['TITLE'] = "phpLogCon :: Home :: Server '" . $content['myserver']['Name'] . "'"; // Title of the Page -//else - $content['TITLE'] = "phpLogCon :: Home"; - -// --- BEGIN Define Helper functions -function HighLightString($highlightArray, $strmsg) -{ - if ( isset($highlightArray) ) - { - // TODO OPTIMIZE - USING FONT TAG as SPAN is HIDDEN if MESSAGE POPUP is ENABNLED! - foreach( $highlightArray as $highlightword ) - $strmsg = preg_replace( "/(" . $highlightword['highlight'] . ")/i", '\\1', $strmsg ); - } - - // return result - return $strmsg; -} - -// --- - -// --- Read and process filters from search dialog! -if ( (isset($_POST['search']) || isset($_GET['search'])) || (isset($_POST['filter']) || isset($_GET['filter'])) ) -{ - // Copy search over - if ( isset($_POST['search']) ) - $mysearch = $_POST['search']; - else if ( isset($_GET['search']) ) - $mysearch = $_GET['search']; - - if ( isset($_POST['filter']) ) - $myfilter = $_POST['filter']; - else if ( isset($_GET['filter']) ) - $myfilter = $_GET['filter']; - - // Optionally read highlight words - if ( isset($_POST['highlight']) ) - $content['highlightstr'] = $_POST['highlight']; - else if ( isset($_GET['highlight']) ) - $content['highlightstr'] = $_GET['highlight']; - -// else if ( $mysearch == $content['LN_SEARCH']) - { - // Message is just appended - if ( isset($myfilter) && strlen($myfilter) > 0 ) - $content['searchstr'] = $myfilter; - } - - if ( strlen($content['highlightstr']) > 0 ) - { - $searchArray = array("\\", "/", ".", ">"); - $replaceArray = array("\\\\", "\/", "\.", ">"); - - // user also wants to highlight words! - if ( strpos($content['highlightstr'], ",") === false) - { - - $content['highlightwords'][0]['highlight_raw'] = $content['highlightstr']; - $content['highlightwords'][0]['highlight'] = str_replace( $searchArray, $replaceArray, $content['highlightstr']); - $content['highlightwords'][0]['cssclass'] = "highlight_1"; - $content['highlightwords'][0]['htmlcode'] = '' . $content['highlightwords'][0]['highlight']. ''; - } - else - { - // Split array into words - $tmparray = explode( ",", $content['highlightstr'] ); - foreach( $tmparray as $word ) - $content['highlightwords'][]['highlight_raw'] = $word; - - // Assign other variables needed for this array entry - for ($i = 0; $i < count($content['highlightwords']); $i++) - { - $content['highlightwords'][$i]['highlight'] = str_replace( $searchArray, $replaceArray, $content['highlightwords'][$i]['highlight_raw']); - $content['highlightwords'][$i]['cssclass'] = "highlight_" . ($i+1); - $content['highlightwords'][$i]['htmlcode'] = '' . $content['highlightwords'][$i]['highlight']. ''; - } - } - - // Default expand Highlight Arrea! - $content['EXPAND_HIGHLIGHT'] = "true"; - } -} -// --- - -// --- BEGIN Custom Code -if ( isset($content['Sources'][$currentSourceID]) ) // && $content['Sources'][$currentSourceID]['SourceType'] == SOURCE_DISK ) -{ - // Obtain and get the Config Object - $stream_config = $content['Sources'][$currentSourceID]['ObjRef']; - - // Create LogStream Object - $stream = $stream_config->LogStreamFactory($stream_config); - $stream->SetFilter($content['searchstr']); - - // --- Init the fields we need - foreach($content['Columns'] as $mycolkey) - { - $content['fields'][$mycolkey]['FieldID'] = $mycolkey; - $content['fields'][$mycolkey]['FieldCaption'] = $content[ $fields[$mycolkey]['FieldCaptionID'] ]; - $content['fields'][$mycolkey]['FieldType'] = $fields[$mycolkey]['FieldType']; - $content['fields'][$mycolkey]['FieldSortable'] = $stream->IsPropertySortable($mycolkey); // $fields[$mycolkey]['Sortable']; - $content['fields'][$mycolkey]['DefaultWidth'] = $fields[$mycolkey]['DefaultWidth']; - } - // --- - - $res = $stream->Open( $content['Columns'], true ); - if ( $res == SUCCESS ) - { - // TODO Implement ORDER - - $stream->SetReadDirection($content['read_direction']); - - // Set current ID and init Counter - $uID = $content['uid_current']; - $counter = 0; - - // If uID is known, we need to init READ first - this will also seek for available records first! - if ($uID != UID_UNKNOWN) - { - // First read will also set the start position of the Stream! - $ret = $stream->Read($uID, $logArray); - } - else - $ret = $stream->ReadNext($uID, $logArray); - - // --- If Forward direction is used, we need to SKIP one entry! - if ( $ret == SUCCESS && $content['read_direction'] == EnumReadDirection::Forward ) - { - // Ok the current ID is our NEXT ID in this reading direction, so we save it! - $content['uid_next'] = $uID; - - // Skip this entry and move to the next - $stream->ReadNext($uID, $logArray); - } - // --- - - // We found matching records, so continue - if ( $ret == SUCCESS ) - { - // --- PreChecks to be done - // Set Record Count - $content['main_recordcount'] = $stream->GetMessageCount(); - if ( $content['main_recordcount'] != -1 ) - $content['main_recordcount_found'] = true; - else - $content['main_recordcount_found'] = false; - - $content['main_currentpagenumber'] = $stream->GetCurrentPageNumber(); - if ( $content['main_currentpagenumber'] >= 0 ) - $content['main_currentpagenumber_found'] = true; - else - $content['main_currentpagenumber_found'] = false; -//echo $content['main_currentpagenumber']; - // --- - - //Loop through the messages! - do - { - // --- Set CSS Class - if ( $counter % 2 == 0 ) - $content['syslogmessages'][$counter]['cssclass'] = "line1"; - else - $content['syslogmessages'][$counter]['cssclass'] = "line2"; - // --- - - // --- Copy other needed properties - $content['syslogmessages'][$counter]['MiscShowDebugGridCounter'] = $content['MiscShowDebugGridCounter']; - // --- - - // --- Now we populate the values array! - foreach($content['Columns'] as $mycolkey) - { - if ( isset($logArray[$mycolkey]) ) - { - // Set defaults - $content['syslogmessages'][$counter]['values'][$mycolkey]['FieldAlign'] = $fields[$mycolkey]['FieldAlign']; - $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldcssclass'] = $content['syslogmessages'][$counter]['cssclass']; - $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldbgcolor'] = ""; - $content['syslogmessages'][$counter]['values'][$mycolkey]['hasdetails'] = "false"; - - // Set default link - $content['syslogmessages'][$counter]['values'][$mycolkey]['detaillink'] = "#"; - - // Now handle fields types differently - if ( $content['fields'][$mycolkey]['FieldType'] == FILTER_TYPE_DATE ) - { - $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] = GetFormatedDate($logArray[$mycolkey]); - } - else if ( $content['fields'][$mycolkey]['FieldType'] == FILTER_TYPE_NUMBER ) - { - $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] = $logArray[$mycolkey]; - - // Special style classes and colours for SYSLOG_FACILITY - if ( $mycolkey == SYSLOG_FACILITY ) - { - if ( isset($logArray[$mycolkey][SYSLOG_FACILITY]) && strlen($logArray[$mycolkey][SYSLOG_FACILITY]) > 0) - { - $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldbgcolor'] = 'bgcolor="' . $facility_colors[ $logArray[SYSLOG_FACILITY] ] . '" '; - $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldcssclass'] = "lineColouredBlack"; - - // Set Human readable Facility! - $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] = GetFacilityDisplayName( $logArray[$mycolkey] ); - } - else - { - // Use default colour! - $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldbgcolor'] = 'bgcolor="' . $facility_colors[SYSLOG_LOCAL0] . '" '; - } - } - else if ( $mycolkey == SYSLOG_SEVERITY ) - { - if ( isset($logArray[$mycolkey][SYSLOG_SEVERITY]) && strlen($logArray[$mycolkey][SYSLOG_SEVERITY]) > 0) - { - $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldbgcolor'] = 'bgcolor="' . $severity_colors[ $logArray[SYSLOG_SEVERITY] ] . '" '; - $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldcssclass'] = "lineColouredWhite"; - - // Set Human readable Facility! - $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] = GetSeverityDisplayName( $logArray[$mycolkey] ); - } - else - { - // Use default colour! - $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldbgcolor'] = 'bgcolor="' . $severity_colors[SYSLOG_INFO] . '" '; - } - } - else if ( $mycolkey == SYSLOG_MESSAGETYPE ) - { - if ( isset($logArray[$mycolkey][SYSLOG_MESSAGETYPE]) ) - { - $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldbgcolor'] = 'bgcolor="' . $msgtype_colors[ $logArray[SYSLOG_MESSAGETYPE] ] . '" '; - $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldcssclass'] = "lineColouredBlack"; - - // Set Human readable Facility! - $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] = GetMessageTypeDisplayName( $logArray[$mycolkey] ); - } - else - { - // Use default colour! - $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldbgcolor'] = 'bgcolor="' . $msgtype_colors[IUT_Unknown] . '" '; - } - - } - } - else if ( $content['fields'][$mycolkey]['FieldType'] == FILTER_TYPE_STRING ) - { - // kindly copy! - $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] = $logArray[$mycolkey]; - - // Special Handling for the Syslog Message! - if ( $mycolkey == SYSLOG_MESSAGE ) - { - // Set truncasted message for display - if ( isset($logArray[SYSLOG_MESSAGE]) ) - { - $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] = GetStringWithHTMLCodes(strlen($logArray[SYSLOG_MESSAGE]) > $CFG['ViewMessageCharacterLimit'] ? substr($logArray[SYSLOG_MESSAGE], 0, $CFG['ViewMessageCharacterLimit'] ) . " ..." : $logArray[SYSLOG_MESSAGE]); - - // Enable LINK property! for this field - $content['syslogmessages'][$counter]['values'][$mycolkey]['haslink'] = true; - $content['syslogmessages'][$counter]['values'][$mycolkey]['detaillink'] = "details.php?uid=" . $uID; - } - else - { - $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] = ""; - } - - // If we need to highlight some words ^^! - if ( isset($content['highlightwords']) ) - $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] = HighLightString( $content['highlightwords'], $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] ); - - if ( isset($CFG['ViewEnableDetailPopups']) && $CFG['ViewEnableDetailPopups'] == 1 ) - { - $content['syslogmessages'][$counter]['values'][$mycolkey]['popupcaption'] = GetAndReplaceLangStr( $content['LN_GRID_POPUPDETAILS'], $logArray[SYSLOG_UID]); - $content['syslogmessages'][$counter]['values'][$mycolkey]['hasdetails'] = "true"; - - foreach($content['syslogmessages'][$counter]['values'] as $mykey => $myfield) - { - // Set Caption! - $content['syslogmessages'][$counter]['values'][$mycolkey]['messagesdetails'][]['detailfieldtitle']= $content['fields'][$mykey]['FieldCaption']; - - // Get ArrayIndex - $myIndex = count($content['syslogmessages'][$counter]['values'][$mycolkey]['messagesdetails']) - 1; - - // --- Set CSS Class - if ( $myIndex % 2 == 0 ) - $content['syslogmessages'][$counter]['values'][$mycolkey]['messagesdetails'][$myIndex]['detailscssclass'] = "line1"; - else - $content['syslogmessages'][$counter]['values'][$mycolkey]['messagesdetails'][$myIndex]['detailscssclass'] = "line2"; - // --- - - // If message field, we need to handle differently! - if ( $mykey == SYSLOG_MESSAGE ) - { - if ( isset($content['highlightwords']) ) - $content['syslogmessages'][$counter]['values'][$mycolkey]['messagesdetails'][$myIndex]['detailfieldvalue'] = HighLightString( $content['highlightwords'],GetStringWithHTMLCodes($logArray[SYSLOG_MESSAGE]) ); - else - $content['syslogmessages'][$counter]['values'][$mycolkey]['messagesdetails'][$myIndex]['detailfieldvalue'] = GetStringWithHTMLCodes($logArray[SYSLOG_MESSAGE]); - } - else // Just set field value - $content['syslogmessages'][$counter]['values'][$mycolkey]['messagesdetails'][$myIndex]['detailfieldvalue'] = $myfield['fieldvalue']; - } - } - } - } - } - } - // --- - - // Increment Counter - $counter++; - } while ($counter < $CFG['ViewEntriesPerPage'] && ($ret = $stream->ReadNext($uID, $logArray)) == SUCCESS); - -//print_r ( $content['syslogmessages'] ); - - if ( $content['main_recordcount'] == -1 || $content['main_recordcount'] > $CFG['ViewEntriesPerPage'] ) - { - // Enable Pager in any case here! - $content['main_pagerenabled'] = true; - - // --- Handle uid_next page button - if ( $content['read_direction'] == EnumReadDirection::Backward ) - { - if ( $stream->ReadNext($uID, $logArray) == SUCCESS && isset($uID) ) - { - $content['uid_next'] = $uID; - $content['main_pager_next_found'] = true; - } - else if ( $content['uid_current'] != UID_UNKNOWN ) - $content['main_pager_next_found'] = false; - } - else if ( $content['read_direction'] == EnumReadDirection::Forward ) - { - // User clicked back, so there is a next page for sure - $content['main_pager_next_found'] = true; - - // As we went back, we need to change the currend uid to the latest read one - $content['uid_current'] = $uID; - } - // --- - - // --- Handle uid_previous page button - if ( $content['uid_current'] != UID_UNKNOWN ) - { - if ( $content['read_direction'] == EnumReadDirection::Forward ) - { - if ( $ret == SUCCESS ) - { - // Try to read the next one! - $ret = $stream->ReadNext($uID, $tmp); - if ( $ret == SUCCESS ) - $content['main_pager_previous_found'] = true; - else - $content['main_pager_previous_found'] = false; - } - else - $content['main_pager_previous_found'] = false; - } - else if ( $content['read_direction'] == EnumReadDirection::Backward ) - $content['main_pager_previous_found'] = true; - } - else - $content['main_pager_previous_found'] = false; - //echo $content['uid_previous']; - // --- - - // --- Handle uid_last page button - // Option the last UID from the stream! - $content['uid_last'] = $stream->GetLastPageUID(); - - // 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 - $content['main_pager_last_found'] = false; - //echo $content['uid_last']; - // --- - - // --- Handle uid_first page button - if ( $content['uid_current'] == $content['uid_first'] ) - $content['main_pager_first_found'] = false; - else - $content['main_pager_first_found'] = true; - // --- - } - else // Disable pager in this case! - $content['main_pagerenabled'] = false; - - if ( $content['read_direction'] == EnumReadDirection::Forward ) - { - // Back Button was clicked, so we need to flip the array -// print_r( $content['syslogmessages'] ); - $content['syslogmessages'] = array_reverse ( $content['syslogmessages'] ); -// print_r( $content['syslogmessages'] ); - } - - - // This will enable to Main SyslogView - $content['syslogmessagesenabled'] = "true"; - } - } - else - { - // This will disable to Main SyslogView and show an error message - $content['syslogmessagesenabled'] = "false"; - - if ( $res == ERROR_FILE_NOT_FOUND ) - $content['detailederror'] = "Syslog file could not be found."; - else if ( $res == ERROR_FILE_NOT_READABLE ) - $content['detailederror'] = "Syslog file is not readable, read access may be denied. "; - else - $content['detailederror'] = "Unknown or unhandeled error occured."; - - } - - // Close file! - $stream->Close(); -} -// --- - -// --- Parsen and Output -InitTemplateParser(); -$page -> parser($content, "index.html"); -$page -> output(); -// --- - + Loads the main PhpLogCon Site + * + * All directives are explained within this file + * + * Copyright (C) 2008 Adiscon GmbH. + * + * This file is part of phpLogCon. + * + * PhpLogCon is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PhpLogCon is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with phpLogCon. If not, see . + * + * A copy of the GPL can be found in the file "COPYING" in this + * distribution + ********************************************************************* +*/ + +// *** Default includes and procedures *** // +define('IN_PHPLOGCON', true); +$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_filters.php'); + +// Init Langauge first! +// IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/main.php' ); + +// Include LogStream facility +include($gl_root_path . 'classes/logstream.class.php'); + +InitPhpLogCon(); +InitSourceConfigs(); +InitFrontEndDefaults(); // Only in WebFrontEnd +InitFilterHelpers(); // Helpers for frontend filtering! +// --- + +// --- Define Extra Stylesheet! +$content['EXTRA_STYLESHEET'] = '' . "\r\n"; +$content['EXTRA_STYLESHEET'] .= ''; +// --- + +// --- CONTENT Vars +if ( isset($_GET['uid']) ) + $content['uid_current'] = intval($_GET['uid']); +else + $content['uid_current'] = UID_UNKNOWN; + +// 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; +$content['main_pager_first_found'] = false; +$content['main_pager_previous_found'] = false; +$content['main_pager_next_found'] = false; +$content['main_pager_last_found'] = false; + + +if ( isset($_GET['direction']) && $_GET['direction'] == "desc" ) + $content['read_direction'] = EnumReadDirection::Forward; +else + $content['read_direction'] = EnumReadDirection::Backward; + +// Init Sorting variables +$content['sorting'] = ""; +$content['searchstr'] = ""; +$content['highlightstr'] = ""; +$content['EXPAND_HIGHLIGHT'] = "false"; + + +//if ( isset($content['myserver']) ) +// $content['TITLE'] = "phpLogCon :: Home :: Server '" . $content['myserver']['Name'] . "'"; // Title of the Page +//else + $content['TITLE'] = "phpLogCon :: Home"; + +// --- BEGIN Define Helper functions +function HighLightString($highlightArray, $strmsg) +{ + if ( isset($highlightArray) ) + { + // TODO OPTIMIZE - USING FONT TAG as SPAN is HIDDEN if MESSAGE POPUP is ENABNLED! + foreach( $highlightArray as $highlightword ) + $strmsg = preg_replace( "/(" . $highlightword['highlight'] . ")/i", '\\1', $strmsg ); + } + + // return result + return $strmsg; +} + +// --- + +// --- Read and process filters from search dialog! +if ( (isset($_POST['search']) || isset($_GET['search'])) || (isset($_POST['filter']) || isset($_GET['filter'])) ) +{ + // Copy search over + if ( isset($_POST['search']) ) + $mysearch = $_POST['search']; + else if ( isset($_GET['search']) ) + $mysearch = $_GET['search']; + + if ( isset($_POST['filter']) ) + $myfilter = $_POST['filter']; + else if ( isset($_GET['filter']) ) + $myfilter = $_GET['filter']; + + // Optionally read highlight words + if ( isset($_POST['highlight']) ) + $content['highlightstr'] = $_POST['highlight']; + else if ( isset($_GET['highlight']) ) + $content['highlightstr'] = $_GET['highlight']; + +// else if ( $mysearch == $content['LN_SEARCH']) + { + // Message is just appended + if ( isset($myfilter) && strlen($myfilter) > 0 ) + $content['searchstr'] = $myfilter; + } + + if ( strlen($content['highlightstr']) > 0 ) + { + $searchArray = array("\\", "/", ".", ">"); + $replaceArray = array("\\\\", "\/", "\.", ">"); + + // user also wants to highlight words! + if ( strpos($content['highlightstr'], ",") === false) + { + + $content['highlightwords'][0]['highlight_raw'] = $content['highlightstr']; + $content['highlightwords'][0]['highlight'] = str_replace( $searchArray, $replaceArray, $content['highlightstr']); + $content['highlightwords'][0]['cssclass'] = "highlight_1"; + $content['highlightwords'][0]['htmlcode'] = '' . $content['highlightwords'][0]['highlight']. ''; + } + else + { + // Split array into words + $tmparray = explode( ",", $content['highlightstr'] ); + foreach( $tmparray as $word ) + $content['highlightwords'][]['highlight_raw'] = $word; + + // Assign other variables needed for this array entry + for ($i = 0; $i < count($content['highlightwords']); $i++) + { + $content['highlightwords'][$i]['highlight'] = str_replace( $searchArray, $replaceArray, $content['highlightwords'][$i]['highlight_raw']); + $content['highlightwords'][$i]['cssclass'] = "highlight_" . ($i+1); + $content['highlightwords'][$i]['htmlcode'] = '' . $content['highlightwords'][$i]['highlight']. ''; + } + } + + // Default expand Highlight Arrea! + $content['EXPAND_HIGHLIGHT'] = "true"; + } +} +// --- + +// --- BEGIN Custom Code +if ( isset($content['Sources'][$currentSourceID]) ) // && $content['Sources'][$currentSourceID]['SourceType'] == SOURCE_DISK ) +{ + // Obtain and get the Config Object + $stream_config = $content['Sources'][$currentSourceID]['ObjRef']; + + // Create LogStream Object + $stream = $stream_config->LogStreamFactory($stream_config); + $stream->SetFilter($content['searchstr']); + + // --- Init the fields we need + foreach($content['Columns'] as $mycolkey) + { + $content['fields'][$mycolkey]['FieldID'] = $mycolkey; + $content['fields'][$mycolkey]['FieldCaption'] = $content[ $fields[$mycolkey]['FieldCaptionID'] ]; + $content['fields'][$mycolkey]['FieldType'] = $fields[$mycolkey]['FieldType']; + $content['fields'][$mycolkey]['FieldSortable'] = $stream->IsPropertySortable($mycolkey); // $fields[$mycolkey]['Sortable']; + $content['fields'][$mycolkey]['DefaultWidth'] = $fields[$mycolkey]['DefaultWidth']; + } + // --- + + $res = $stream->Open( $content['Columns'], true ); + if ( $res == SUCCESS ) + { + // TODO Implement ORDER + + $stream->SetReadDirection($content['read_direction']); + + // Set current ID and init Counter + $uID = $content['uid_current']; + $counter = 0; + + // If uID is known, we need to init READ first - this will also seek for available records first! + if ($uID != UID_UNKNOWN) + { + // First read will also set the start position of the Stream! + $ret = $stream->Read($uID, $logArray); + } + else + $ret = $stream->ReadNext($uID, $logArray); + + // --- If Forward direction is used, we need to SKIP one entry! + if ( $ret == SUCCESS && $content['read_direction'] == EnumReadDirection::Forward ) + { + // Ok the current ID is our NEXT ID in this reading direction, so we save it! + $content['uid_next'] = $uID; + + // Skip this entry and move to the next + $stream->ReadNext($uID, $logArray); + } + // --- + + // We found matching records, so continue + if ( $ret == SUCCESS ) + { + // --- PreChecks to be done + // Set Record Count + $content['main_recordcount'] = $stream->GetMessageCount(); + if ( $content['main_recordcount'] != -1 ) + $content['main_recordcount_found'] = true; + else + $content['main_recordcount_found'] = false; + + $content['main_currentpagenumber'] = $stream->GetCurrentPageNumber(); + if ( $content['main_currentpagenumber'] >= 0 ) + $content['main_currentpagenumber_found'] = true; + else + $content['main_currentpagenumber_found'] = false; +//echo $content['main_currentpagenumber']; + // --- + + //Loop through the messages! + do + { + // --- Set CSS Class + if ( $counter % 2 == 0 ) + $content['syslogmessages'][$counter]['cssclass'] = "line1"; + else + $content['syslogmessages'][$counter]['cssclass'] = "line2"; + // --- + + // --- Copy other needed properties + $content['syslogmessages'][$counter]['MiscShowDebugGridCounter'] = $content['MiscShowDebugGridCounter']; + // --- + + // --- Now we populate the values array! + foreach($content['Columns'] as $mycolkey) + { + if ( isset($logArray[$mycolkey]) ) + { + // Set defaults + $content['syslogmessages'][$counter]['values'][$mycolkey]['FieldAlign'] = $fields[$mycolkey]['FieldAlign']; + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldcssclass'] = $content['syslogmessages'][$counter]['cssclass']; + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldbgcolor'] = ""; + $content['syslogmessages'][$counter]['values'][$mycolkey]['hasdetails'] = "false"; + + // Set default link + $content['syslogmessages'][$counter]['values'][$mycolkey]['detaillink'] = "#"; + + // Now handle fields types differently + if ( $content['fields'][$mycolkey]['FieldType'] == FILTER_TYPE_DATE ) + { + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] = GetFormatedDate($logArray[$mycolkey]); + } + else if ( $content['fields'][$mycolkey]['FieldType'] == FILTER_TYPE_NUMBER ) + { + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] = $logArray[$mycolkey]; + + // Special style classes and colours for SYSLOG_FACILITY + if ( $mycolkey == SYSLOG_FACILITY ) + { + if ( isset($logArray[$mycolkey][SYSLOG_FACILITY]) && strlen($logArray[$mycolkey][SYSLOG_FACILITY]) > 0) + { + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldbgcolor'] = 'bgcolor="' . $facility_colors[ $logArray[SYSLOG_FACILITY] ] . '" '; + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldcssclass'] = "lineColouredBlack"; + + // Set Human readable Facility! + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] = GetFacilityDisplayName( $logArray[$mycolkey] ); + } + else + { + // Use default colour! + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldbgcolor'] = 'bgcolor="' . $facility_colors[SYSLOG_LOCAL0] . '" '; + } + } + else if ( $mycolkey == SYSLOG_SEVERITY ) + { + if ( isset($logArray[$mycolkey][SYSLOG_SEVERITY]) && strlen($logArray[$mycolkey][SYSLOG_SEVERITY]) > 0) + { + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldbgcolor'] = 'bgcolor="' . $severity_colors[ $logArray[SYSLOG_SEVERITY] ] . '" '; + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldcssclass'] = "lineColouredWhite"; + + // Set Human readable Facility! + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] = GetSeverityDisplayName( $logArray[$mycolkey] ); + } + else + { + // Use default colour! + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldbgcolor'] = 'bgcolor="' . $severity_colors[SYSLOG_INFO] . '" '; + } + } + else if ( $mycolkey == SYSLOG_MESSAGETYPE ) + { + if ( isset($logArray[$mycolkey][SYSLOG_MESSAGETYPE]) ) + { + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldbgcolor'] = 'bgcolor="' . $msgtype_colors[ $logArray[SYSLOG_MESSAGETYPE] ] . '" '; + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldcssclass'] = "lineColouredBlack"; + + // Set Human readable Facility! + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] = GetMessageTypeDisplayName( $logArray[$mycolkey] ); + } + else + { + // Use default colour! + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldbgcolor'] = 'bgcolor="' . $msgtype_colors[IUT_Unknown] . '" '; + } + + } + } + else if ( $content['fields'][$mycolkey]['FieldType'] == FILTER_TYPE_STRING ) + { + // kindly copy! + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] = $logArray[$mycolkey]; + + // Special Handling for the Syslog Message! + if ( $mycolkey == SYSLOG_MESSAGE ) + { + // Set truncasted message for display + if ( isset($logArray[SYSLOG_MESSAGE]) ) + { + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] = GetStringWithHTMLCodes(strlen($logArray[SYSLOG_MESSAGE]) > $CFG['ViewMessageCharacterLimit'] ? substr($logArray[SYSLOG_MESSAGE], 0, $CFG['ViewMessageCharacterLimit'] ) . " ..." : $logArray[SYSLOG_MESSAGE]); + + // Enable LINK property! for this field + $content['syslogmessages'][$counter]['values'][$mycolkey]['haslink'] = true; + $content['syslogmessages'][$counter]['values'][$mycolkey]['detaillink'] = "details.php?uid=" . $uID; + } + else + { + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] = ""; + } + + // If we need to highlight some words ^^! + if ( isset($content['highlightwords']) ) + $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] = HighLightString( $content['highlightwords'], $content['syslogmessages'][$counter]['values'][$mycolkey]['fieldvalue'] ); + + if ( isset($CFG['ViewEnableDetailPopups']) && $CFG['ViewEnableDetailPopups'] == 1 ) + { + $content['syslogmessages'][$counter]['values'][$mycolkey]['popupcaption'] = GetAndReplaceLangStr( $content['LN_GRID_POPUPDETAILS'], $logArray[SYSLOG_UID]); + $content['syslogmessages'][$counter]['values'][$mycolkey]['hasdetails'] = "true"; + + foreach($content['syslogmessages'][$counter]['values'] as $mykey => $myfield) + { + // Set Caption! + $content['syslogmessages'][$counter]['values'][$mycolkey]['messagesdetails'][]['detailfieldtitle']= $content['fields'][$mykey]['FieldCaption']; + + // Get ArrayIndex + $myIndex = count($content['syslogmessages'][$counter]['values'][$mycolkey]['messagesdetails']) - 1; + + // --- Set CSS Class + if ( $myIndex % 2 == 0 ) + $content['syslogmessages'][$counter]['values'][$mycolkey]['messagesdetails'][$myIndex]['detailscssclass'] = "line1"; + else + $content['syslogmessages'][$counter]['values'][$mycolkey]['messagesdetails'][$myIndex]['detailscssclass'] = "line2"; + // --- + + // If message field, we need to handle differently! + if ( $mykey == SYSLOG_MESSAGE ) + { + if ( isset($content['highlightwords']) ) + $content['syslogmessages'][$counter]['values'][$mycolkey]['messagesdetails'][$myIndex]['detailfieldvalue'] = HighLightString( $content['highlightwords'],GetStringWithHTMLCodes($logArray[SYSLOG_MESSAGE]) ); + else + $content['syslogmessages'][$counter]['values'][$mycolkey]['messagesdetails'][$myIndex]['detailfieldvalue'] = GetStringWithHTMLCodes($logArray[SYSLOG_MESSAGE]); + } + else // Just set field value + $content['syslogmessages'][$counter]['values'][$mycolkey]['messagesdetails'][$myIndex]['detailfieldvalue'] = $myfield['fieldvalue']; + } + } + } + } + } + } + // --- + + // Increment Counter + $counter++; + } while ($counter < $CFG['ViewEntriesPerPage'] && ($ret = $stream->ReadNext($uID, $logArray)) == SUCCESS); + +//print_r ( $content['syslogmessages'] ); + + if ( $content['main_recordcount'] == -1 || $content['main_recordcount'] > $CFG['ViewEntriesPerPage'] ) + { + // Enable Pager in any case here! + $content['main_pagerenabled'] = true; + + // --- Handle uid_next page button + if ( $content['read_direction'] == EnumReadDirection::Backward ) + { + if ( $stream->ReadNext($uID, $logArray) == SUCCESS && isset($uID) ) + { + $content['uid_next'] = $uID; + $content['main_pager_next_found'] = true; + } + else if ( $content['uid_current'] != UID_UNKNOWN ) + $content['main_pager_next_found'] = false; + } + else if ( $content['read_direction'] == EnumReadDirection::Forward ) + { + // User clicked back, so there is a next page for sure + $content['main_pager_next_found'] = true; + + // As we went back, we need to change the currend uid to the latest read one + $content['uid_current'] = $uID; + } + // --- + + // --- Handle uid_previous page button + if ( $content['uid_current'] != UID_UNKNOWN ) + { + if ( $content['read_direction'] == EnumReadDirection::Forward ) + { + if ( $ret == SUCCESS ) + { + // Try to read the next one! + $ret = $stream->ReadNext($uID, $tmp); + if ( $ret == SUCCESS ) + $content['main_pager_previous_found'] = true; + else + $content['main_pager_previous_found'] = false; + } + else + $content['main_pager_previous_found'] = false; + } + else if ( $content['read_direction'] == EnumReadDirection::Backward ) + $content['main_pager_previous_found'] = true; + } + else + $content['main_pager_previous_found'] = false; + //echo $content['uid_previous']; + // --- + + // --- Handle uid_last page button + // Option the last UID from the stream! + $content['uid_last'] = $stream->GetLastPageUID(); + + // 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 + $content['main_pager_last_found'] = false; + //echo $content['uid_last']; + // --- + + // --- Handle uid_first page button + if ( $content['uid_current'] == $content['uid_first'] ) + $content['main_pager_first_found'] = false; + else + $content['main_pager_first_found'] = true; + // --- + } + else // Disable pager in this case! + $content['main_pagerenabled'] = false; + + if ( $content['read_direction'] == EnumReadDirection::Forward ) + { + // Back Button was clicked, so we need to flip the array +// print_r( $content['syslogmessages'] ); + $content['syslogmessages'] = array_reverse ( $content['syslogmessages'] ); +// print_r( $content['syslogmessages'] ); + } + + + // This will enable to Main SyslogView + $content['syslogmessagesenabled'] = "true"; + } + } + else + { + // This will disable to Main SyslogView and show an error message + $content['syslogmessagesenabled'] = "false"; + + if ( $res == ERROR_FILE_NOT_FOUND ) + $content['detailederror'] = "Syslog file could not be found."; + else if ( $res == ERROR_FILE_NOT_READABLE ) + $content['detailederror'] = "Syslog file is not readable, read access may be denied. "; + else + $content['detailederror'] = "Unknown or unhandeled error occured."; + + } + + // Close file! + $stream->Close(); +} +// --- + +// --- Parsen and Output +InitTemplateParser(); +$page -> parser($content, "index.html"); +$page -> output(); +// --- + ?> \ No newline at end of file diff --git a/src/install.php b/src/install.php index fd58d56..391d9aa 100644 --- a/src/install.php +++ b/src/install.php @@ -1,687 +1,687 @@ - Installer File - * - * All directives are explained within this file - * - * Copyright (C) 2008 Adiscon GmbH. - * - * This file is part of phpLogCon. - * - * PhpLogCon is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PhpLogCon is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with phpLogCon. If not, see . - * - * A copy of the GPL can be found in the file "COPYING" in this - * distribution - ********************************************************************* -*/ - - -// *** Default includes and procedures *** // -define('IN_PHPLOGCON', true); -define('IN_PHPLOGCON_INSTALL', true); // Extra for INSTALL Script! -$gl_root_path = './'; - -// Now include necessary include files! -include($gl_root_path . 'include/functions_common.php'); -include($gl_root_path . 'include/functions_frontendhelpers.php'); - -// Init Langauge first! -IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/main.php' ); - -InitBasicPhpLogCon(); -//InitPhpLogCon(); - -// Set some static values -define('MAX_STEPS', 8); -$content['web_theme'] = "default"; -$content['user_theme'] = "default"; -$configsamplefile = $content['BASEPATH'] . "include/config.sample.php"; - -//ini_set('error_reporting', E_ERROR); // NO PHP ERROR'S! -// *** *** // - -// --- CONTENT Vars -$content['TITLE'] = "phpLogCon :: Installer Step %1"; -// --- - -// --- Read Vars -if ( isset($_GET['step']) ) -{ - $content['INSTALL_STEP'] = intval(DB_RemoveBadChars($_GET['step'])); - if ( $content['INSTALL_STEP'] > MAX_STEPS ) - $content['INSTALL_STEP'] = 1; -} -else - $content['INSTALL_STEP'] = 1; - -// Set Next Step -$content['INSTALL_NEXT_STEP'] = $content['INSTALL_STEP']; - -if ( MAX_STEPS > $content['INSTALL_STEP'] ) -{ - $content['NEXT_ENABLED'] = "true"; - $content['FINISH_ENABLED'] = "false"; - $content['INSTALL_NEXT_STEP']++; -} -else -{ - $content['NEXT_ENABLED'] = "false"; - $content['FINISH_ENABLED'] = "true"; -} -// --- - - - -// --- BEGIN Custom Code - -// --- Set Bar Image - $content['BarImagePlus'] = $gl_root_path . "images/bars/bar-middle/green_middle_17.png"; - $content['BarImageLeft'] = $gl_root_path . "images/bars/bar-middle/green_left_17.png"; - $content['BarImageRight'] = $gl_root_path . "images/bars/bar-middle/green_right_17.png"; - $content['WidthPlus'] = intval( $content['INSTALL_STEP'] * (100 / MAX_STEPS) ) - 8; - $content['WidthPlusText'] = "Installer Step " . $content['INSTALL_STEP']; -// --- - -// --- Set Title -GetAndReplaceLangStr( $content['TITLE'], $content['INSTALL_STEP'] ); -// --- - -// --- Start Setup Processing -if ( $content['INSTALL_STEP'] == 2 ) -{ - // Check if file permissions are correctly - $content['fileperm'][0]['FILE_NAME'] = $content['BASEPATH'] . "config.php"; - $content['fileperm'][0]['FILE_TYPE'] = "file"; -// $content['fileperm'][1]['FILE_NAME'] = $content['BASEPATH'] . "gamelogs/"; -// $content['fileperm'][1]['FILE_TYPE'] = "dir"; - -// Check file by file - $bSuccess = true; - for($i = 0; $i < count($content['fileperm']); $i++) - { - // --- Set CSS Class - if ( $i % 2 == 0 ) - $content['fileperm'][$i]['cssclass'] = "line1"; - else - $content['fileperm'][$i]['cssclass'] = "line2"; - // --- - - if ( $content['fileperm'][$i]['FILE_TYPE'] == "dir" ) - { - // Get Permission mask - $perms = fileperms( $content['fileperm'][$i]['FILE_NAME'] ); - - // World - $iswriteable = (($perms & 0x0004) ? true : false) && (($perms & 0x0002) ? true : false); - if ( $iswriteable ) - { - $content['fileperm'][$i]['BGCOLOR'] = "#007700"; - $content['fileperm'][$i]['ISSUCCESS'] = "Writeable"; - } - else - { - $content['fileperm'][$i]['BGCOLOR'] = "#770000"; - $content['fileperm'][$i]['ISSUCCESS'] = "NOT Writeable"; - $bSuccess = false; - } - } - else - { - if ( !is_file($content['fileperm'][$i]['FILE_NAME']) ) - { - // Try to create an empty file - touch($content['fileperm'][$i]['FILE_NAME']); - } - - if ( is_file($content['fileperm'][$i]['FILE_NAME']) ) - { - if ( is_writable($content['fileperm'][$i]['FILE_NAME']) ) - { - $content['fileperm'][$i]['BGCOLOR'] = "#007700"; - $content['fileperm'][$i]['ISSUCCESS'] = "Writeable"; - } - else - { - $content['fileperm'][$i]['BGCOLOR'] = "#770000"; - $content['fileperm'][$i]['ISSUCCESS'] = "NOT Writeable"; - $bSuccess = false; - } - } - else - { - $content['fileperm'][$i]['BGCOLOR'] = "#770000"; - $content['fileperm'][$i]['ISSUCCESS'] = "File does NOT exist!"; - $bSuccess = false; - } - } - } - - if ( !$bSuccess ) - { - $content['NEXT_ENABLED'] = "false"; - $content['RECHECK_ENABLED'] = "true"; - $content['iserror'] = "true"; - $content['errormsg'] = "One file or directory (or more) are not writeable, please check the file permissions (chmod 777)!"; - } - - // Check if sample config file is available - if ( !is_file($configsamplefile) || GetFileLength($configsamplefile) <= 0 ) - { - $content['NEXT_ENABLED'] = "false"; - $content['RECHECK_ENABLED'] = "true"; - $content['iserror'] = "true"; - $content['errormsg'] = "The sample configuration file '" . $configsamplefile . "' is missing. You have not fully uploaded phplogcon."; - } - -} -else if ( $content['INSTALL_STEP'] == 3 ) -{ - // --- Read and predefine Database options - if ( isset($_SESSION['UserDBEnabled']) ) { $content['UserDBEnabled'] = $_SESSION['UserDBEnabled']; } else { $content['UserDBEnabled'] = false; } - if ( isset($_SESSION['UserDBServer']) ) { $content['UserDBServer'] = $_SESSION['UserDBServer']; } else { $content['UserDBServer'] = "localhost"; } - if ( isset($_SESSION['UserDBPort']) ) { $content['UserDBPort'] = $_SESSION['UserDBPort']; } else { $content['UserDBPort'] = "3306"; } - if ( isset($_SESSION['UserDBName']) ) { $content['UserDBName'] = $_SESSION['UserDBName']; } else { $content['UserDBName'] = "phplogcon"; } - if ( isset($_SESSION['UserDBPref']) ) { $content['UserDBPref'] = $_SESSION['UserDBPref']; } else { $content['UserDBPref'] = "logcon_"; } - if ( isset($_SESSION['UserDBUser']) ) { $content['UserDBUser'] = $_SESSION['UserDBUser']; } else { $content['UserDBUser'] = "user"; } - if ( isset($_SESSION['UserDBPass']) ) { $content['UserDBPass'] = $_SESSION['UserDBPass']; } else { $content['UserDBPass'] = ""; } - if ( $content['UserDBEnabled'] == 1 ) - { - $content['UserDBEnabled_true'] = "checked"; - $content['UserDBEnabled_false'] = ""; - } - else - { - $content['UserDBEnabled_true'] = ""; - $content['UserDBEnabled_false'] = "checked"; - } - // --- - - // --- Read and predefine Frontend options - if ( isset($_SESSION['ViewMessageCharacterLimit']) ) { $content['ViewMessageCharacterLimit'] = $_SESSION['ViewMessageCharacterLimit']; } else { $content['ViewMessageCharacterLimit'] = 80; } - if ( isset($_SESSION['ViewEntriesPerPage']) ) { $content['ViewEntriesPerPage'] = $_SESSION['ViewEntriesPerPage']; } else { $content['ViewEntriesPerPage'] = 50; } - if ( isset($_SESSION['ViewEnableDetailPopups']) ) { $content['ViewEnableDetailPopups'] = $_SESSION['ViewEnableDetailPopups']; } else { $content['ViewEnableDetailPopups'] = 1; } - if ( $content['ViewEnableDetailPopups'] == 1 ) - { - $content['ViewEnableDetailPopups_true'] = "checked"; - $content['ViewEnableDetailPopups_false'] = ""; - } - else - { - $content['ViewEnableDetailPopups_true'] = ""; - $content['ViewEnableDetailPopups_false'] = "checked"; - } - // --- - - // Disable the bottom next button, as the Form in this step has its own button! -// $content['NEXT_ENABLED'] = "false"; - - // Check for Error Msg - if ( isset($_GET['errormsg']) ) - { - $content['iserror'] = "true"; - $content['errormsg'] = DB_RemoveBadChars( urldecode($_GET['errormsg']) ); - } -} -else if ( $content['INSTALL_STEP'] == 4 ) -{ - // --- Read Database Vars - if ( isset($_POST['UserDBEnabled']) ) - { - $_SESSION['UserDBEnabled'] = DB_RemoveBadChars($_POST['UserDBEnabled']); - if ( $_SESSION['UserDBEnabled'] == 1 ) - { - // Read vars - if ( isset($_POST['UserDBServer']) ) - $_SESSION['UserDBServer'] = DB_RemoveBadChars($_POST['UserDBServer']); - else - RevertOneStep( $content['INSTALL_STEP']-1, $content['LN_CFG_PARAMMISSING'] . $content['LN_CFG_DBSERVER'] ); - - if ( isset($_POST['UserDBPort']) ) - $_SESSION['UserDBPort'] = intval(DB_RemoveBadChars($_POST['UserDBPort'])); - else - RevertOneStep( $content['INSTALL_STEP']-1, $content['LN_CFG_PARAMMISSING'] . $content['LN_CFG_DBPORT'] ); - - if ( isset($_POST['UserDBName']) ) - $_SESSION['UserDBName'] = DB_RemoveBadChars($_POST['UserDBName']); - else - RevertOneStep( $content['INSTALL_STEP']-1, $content['LN_CFG_PARAMMISSING'] . $content['LN_CFG_DBNAME'] ); - - if ( isset($_POST['UserDBPref']) ) - $_SESSION['UserDBPref'] = DB_RemoveBadChars($_POST['UserDBPref']); - else - RevertOneStep( $content['INSTALL_STEP']-1, $content['LN_CFG_PARAMMISSING'] . $content['LN_CFG_DBPREF'] ); - - if ( isset($_POST['UserDBUser']) ) - $_SESSION['UserDBUser'] = DB_RemoveBadChars($_POST['UserDBUser']); - else - RevertOneStep( $content['INSTALL_STEP']-1, $content['LN_CFG_PARAMMISSING']. $content['LN_CFG_DBUSER'] ); - - if ( isset($_POST['UserDBPass']) ) - $_SESSION['UserDBPass'] = DB_RemoveBadChars($_POST['UserDBPass']); - else - $_SESSION['UserDBPass'] = ""; - - // Now Check database connect - $link_id = mysql_connect( $_SESSION['UserDBServer'], $_SESSION['UserDBUser'], $_SESSION['UserDBPass']); - if (!$link_id) - RevertOneStep( $content['INSTALL_STEP']-1, "Connect to " .$_SESSION['UserDBServer'] . " failed! Check Servername, Port, User and Password!
" . DB_ReturnSimpleErrorMsg() ); - - // Try to select the DB! - $db_selected = mysql_select_db($_SESSION['UserDBName'], $link_id); - if(!$db_selected) - RevertOneStep( $content['INSTALL_STEP']-1, "Cannot use database " .$_SESSION['UserDBName'] . "! If the database does not exists, create it or check access permissions!
" . DB_ReturnSimpleErrorMsg()); - } - } - // --- - - // --- Read Frontend Vars - if ( isset($_POST['ViewMessageCharacterLimit']) ) - { - $_SESSION['ViewMessageCharacterLimit'] = intval( DB_RemoveBadChars($_POST['ViewMessageCharacterLimit']) ); - if ( $_SESSION['ViewMessageCharacterLimit'] < 0 ) - $_SESSION['ViewMessageCharacterLimit'] = 80; // Fallback default! - } - else - $_SESSION['ViewMessageCharacterLimit'] = 80; // Fallback default! - - if ( isset($_POST['ViewEntriesPerPage']) ) - { - $_SESSION['ViewEntriesPerPage'] = intval( DB_RemoveBadChars($_POST['ViewEntriesPerPage']) ); - if ( $_SESSION['ViewEntriesPerPage'] < 0 ) - $_SESSION['ViewEntriesPerPage'] = 50; // Fallback default! - } - else - $_SESSION['ViewEntriesPerPage'] = 50; // Fallback default! - - if ( isset($_POST['ViewEnableDetailPopups']) ) - $_SESSION['ViewEnableDetailPopups'] = intval( DB_RemoveBadChars($_POST['ViewEnableDetailPopups']) ); - else - $_SESSION['ViewEnableDetailPopups'] = 1; // Fallback default! - // --- - - // If UserDB is disabled, skip next step! - if ( $_SESSION['UserDBEnabled'] == 0 ) - ForwardOneStep(); -} -else if ( $content['INSTALL_STEP'] == 5 ) -{ - $content['sql_sucess'] = 0; - $content['sql_failed'] = 0; - - // Import default database if user db is enabled! - if ( $_SESSION['UserDBEnabled'] == 1 ) - { - // Init $totaldbdefs - $totaldbdefs = ""; - - // Read the table GLOBAL definitions - ImportDataFile( $content['BASEPATH'] . "contrib/db_template.txt" ); - - // Process definitions ^^ - if ( strlen($totaldbdefs) <= 0 ) - { - $content['failedstatements'][ $content['sql_failed'] ]['myerrmsg'] = "Error, invalid Database Defintion File (to short!), file '" . $content['BASEPATH'] . "contrib/db_template.txt" . "'!
Maybe the file was not correctly uploaded?"; - $content['failedstatements'][ $content['sql_failed'] ]['mystatement'] = ""; - $content['sql_failed']++; - } - - // Replace stats_ with the custom one ;) - $totaldbdefs = str_replace( "`logcon_", "`" . $_SESSION["UserDBPref"], $totaldbdefs ); - - // Now split by sql command - $mycommands = split( ";\r\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'] = "Error, invalid Database Defintion File (no statements found!) in '" . $content['BASEPATH'] . "contrib/db_template.txt" . "'!
Maybe the file was not correctly uploaded, or a strange bug with your system? Contact phpLogCon forums for assistance!"; - $content['failedstatements'][ $content['sql_failed'] ]['mystatement'] = ""; - $content['sql_failed']++; - } - - // Append INSERT Statement for Config Table to set the GameVersion and Database Version ^^! - $mycommands[count($mycommands)] = "INSERT INTO `" . $_SESSION["UserDBPref"] . "config` (`name`, `value`) VALUES ('database_installedversion', '1')"; - - // --- Now execute all commands - ini_set('error_reporting', E_WARNING); // Enable Warnings! - InitPhpLogConConfigFile(); - - // 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 - $content['failedstatements'][ $content['sql_failed'] ]['cssclass'] = "line2"; - // --- - - $content['sql_failed']++; - } - else - $content['sql_sucess']++; - - // Free result - DB_FreeQuery($result); - } - } - } - else // Skip this step in this case! - ForwardOneStep(); -} -else if ( $content['INSTALL_STEP'] == 6 ) -{ - if ( $_SESSION['UserDBEnabled'] == 1 ) - { - if ( isset($_SESSION['MAIN_Username']) ) - $content['MAIN_Username'] = $_SESSION['MAIN_Username']; - else - $content['MAIN_Username'] = ""; - - $content['MAIN_Password1'] = ""; - $content['MAIN_Password2'] = ""; - - // Check for Error Msg - if ( isset($_GET['errormsg']) ) - { - $content['iserror'] = "true"; - $content['errormsg'] = DB_RemoveBadChars( urldecode($_GET['errormsg']) ); - } - } - else // NO Database means NO user management, so next step! - ForwardOneStep(); -} -else if ( $content['INSTALL_STEP'] == 7 ) -{ - if ( $_SESSION['UserDBEnabled'] == 1 ) - { - if ( isset($_POST['username']) ) - $_SESSION['MAIN_Username'] = DB_RemoveBadChars($_POST['username']); - else - RevertOneStep( $content['INSTALL_STEP']-1, "Username needs to be specified" ); - - if ( isset($_POST['password1']) ) - $_SESSION['MAIN_Password1'] = DB_RemoveBadChars($_POST['password1']); - else - $_SESSION['MAIN_Password1'] = ""; - - if ( isset($_POST['password2']) ) - $_SESSION['MAIN_Password2'] = DB_RemoveBadChars($_POST['password2']); - else - $_SESSION['MAIN_Password2'] = ""; - - if ( - strlen($_SESSION['MAIN_Password1']) <= 4 || - $_SESSION['MAIN_Password1'] != $_SESSION['MAIN_Password2'] - ) - RevertOneStep( $content['INSTALL_STEP']-1, "Either the password does not match or is to short!" ); - - // --- Now execute all commands - ini_set('error_reporting', E_WARNING); // Enable Warnings! - InitPhpLogConConfigFile(); - - // Establish DB Connection - DB_Connect(); - - // Everything is fine, lets go create the User! - CreateUserName( $_SESSION['MAIN_Username'], $_SESSION['MAIN_Password1'], 0 ); - } - - // Init Source Options - if ( isset($_SESSION['SourceType']) ) { $content['SourceType'] = $_SESSION['SourceType']; } else { $content['SourceType'] = SOURCE_DISK; } - CreateSourceTypesList($content['SourceType']); - if ( isset($_SESSION['SourceName']) ) { $content['SourceName'] = $_SESSION['SourceName']; } else { $content['SourceName'] = "My Syslog Source"; } - - // SOURCE_DISK specific - if ( isset($_SESSION['SourceLogLineType']) ) { $content['SourceLogLineType'] = $_SESSION['SourceLogLineType']; } else { $content['SourceLogLineType'] = ""; } - CreateLogLineTypesList($content['SourceLogLineType']); - if ( isset($_SESSION['SourceDiskFile']) ) { $content['SourceDiskFile'] = $_SESSION['SourceDiskFile']; } else { $content['SourceDiskFile'] = "/var/log/syslog"; } - - // SOURCE_DB specific - if ( isset($_SESSION['SourceDBType']) ) { $content['SourceDBType'] = $_SESSION['SourceDBType']; } else { $content['SourceDBType'] = DB_MYSQL; } - CreateDBTypesList($content['SourceDBType']); - if ( isset($_SESSION['SourceDBName']) ) { $content['SourceDBName'] = $_SESSION['SourceDBName']; } else { $content['SourceDBName'] = "phplogcon"; } - if ( isset($_SESSION['SourceDBTableType']) ) { $content['SourceDBTableType'] = $_SESSION['SourceDBTableType']; } else { $content['SourceDBTableType'] = "monitorware"; } - if ( isset($_SESSION['SourceDBServer']) ) { $content['SourceDBServer'] = $_SESSION['SourceDBServer']; } else { $content['SourceDBServer'] = "localhost"; } - if ( isset($_SESSION['SourceDBTableName']) ) { $content['SourceDBTableName'] = $_SESSION['SourceDBTableName']; } else { $content['SourceDBTableName'] = "systemevents"; } - if ( isset($_SESSION['SourceDBUser']) ) { $content['SourceDBUser'] = $_SESSION['SourceDBUser']; } else { $content['SourceDBUser'] = "user"; } - if ( isset($_SESSION['SourceDBPassword']) ) { $content['SourceDBPassword'] = $_SESSION['SourceDBPassword']; } else { $content['SourceDBPassword'] = ""; } - - // Check for Error Msg - if ( isset($_GET['errormsg']) ) - { - $content['iserror'] = "true"; - $content['errormsg'] = DB_RemoveBadChars( urldecode($_GET['errormsg']) ); - } -} -else if ( $content['INSTALL_STEP'] == 8 ) -{ - // Read vars - if ( isset($_POST['SourceType']) ) - $_SESSION['SourceType'] = DB_RemoveBadChars($_POST['SourceType']); - else - RevertOneStep( $content['INSTALL_STEP']-1, $content['LN_CFG_PARAMMISSING'] . $content['LN_CFG_SOURCETYPE'] ); - - if ( isset($_POST['SourceName']) ) - $_SESSION['SourceName'] = DB_RemoveBadChars($_POST['SourceName']); - else - RevertOneStep( $content['INSTALL_STEP']-1, $content['LN_CFG_PARAMMISSING'] . $content['LN_CFG_NAMEOFTHESOURCE'] ); - - // Check DISK Parameters! - if ( $_SESSION['SourceType'] == SOURCE_DISK) - { - if ( isset($_POST['SourceLogLineType']) ) - $_SESSION['SourceLogLineType'] = DB_RemoveBadChars($_POST['SourceLogLineType']); - else - RevertOneStep( $content['INSTALL_STEP']-1, $content['LN_CFG_PARAMMISSING'] . $content['LN_CFG_LOGLINETYPE'] ); - - if ( isset($_POST['SourceDiskFile']) ) - $_SESSION['SourceDiskFile'] = DB_RemoveBadChars($_POST['SourceDiskFile']); - else - RevertOneStep( $content['INSTALL_STEP']-1, $content['LN_CFG_PARAMMISSING'] . $content['LN_CFG_SYSLOGFILE'] ); - - // Check if access to the configured file is possible - if ( !is_file($_SESSION['SourceDiskFile']) ) - RevertOneStep( $content['INSTALL_STEP']-1, "Failed to open the syslog file " .$_SESSION['SourceDiskFile'] . "! Check if the file exists and phplogcon has sufficient rights to it
" ); - } - else if ( $_SESSION['SourceType'] == SOURCE_DB) - { - if ( isset($_POST['SourceDBType']) ) - $_SESSION['SourceDBType'] = DB_RemoveBadChars($_POST['SourceDBType']); - else - RevertOneStep( $content['INSTALL_STEP']-1, $content['LN_CFG_PARAMMISSING'] . $content['LN_CFG_DATABASETYPEOPTIONS'] ); - - if ( isset($_POST['SourceDBName']) ) - $_SESSION['SourceDBName'] = DB_RemoveBadChars($_POST['SourceDBName']); - else - RevertOneStep( $content['INSTALL_STEP']-1, $content['LN_CFG_PARAMMISSING'] . $content['LN_CFG_DBNAME'] ); - - if ( isset($_POST['SourceDBTableType']) ) - $_SESSION['SourceDBTableType'] = DB_RemoveBadChars($_POST['SourceDBTableType']); - else - RevertOneStep( $content['INSTALL_STEP']-1, $content['LN_CFG_PARAMMISSING'] . $content['LN_CFG_DBTABLETYPE'] ); - - if ( isset($_POST['SourceDBServer']) ) - $_SESSION['SourceDBServer'] = DB_RemoveBadChars($_POST['SourceDBServer']); - else - RevertOneStep( $content['INSTALL_STEP']-1, $content['LN_CFG_PARAMMISSING'] . $content['LN_CFG_DBSERVER'] ); - - if ( isset($_POST['SourceDBTableName']) ) - $_SESSION['SourceDBTableName'] = DB_RemoveBadChars($_POST['SourceDBTableName']); - else - RevertOneStep( $content['INSTALL_STEP']-1, $content['LN_CFG_PARAMMISSING'] . $content['LN_CFG_DBTABLENAME'] ); - - if ( isset($_POST['SourceDBUser']) ) - $_SESSION['SourceDBUser'] = DB_RemoveBadChars($_POST['SourceDBUser']); - else - RevertOneStep( $content['INSTALL_STEP']-1, $content['LN_CFG_PARAMMISSING'] . $content['LN_CFG_DBUSER'] ); - - if ( isset($_POST['SourceDBPassword']) ) - $_SESSION['SourceDBPassword'] = DB_RemoveBadChars($_POST['SourceDBPassword']); - else - $_SESSION['SourceDBPassword'] = ""; - - // TODO: Check database connectivity! - } - - // If we reached this point, we have gathered all necessary information to create our configuration file ;)! - $filebuffer = LoadDataFile($configsamplefile); - - // Start replacing existing sample configurations - $patterns[] = "/\\\$CFG\['ViewMessageCharacterLimit'\] = [0-9]{1,2};/"; - $patterns[] = "/\\\$CFG\['ViewEntriesPerPage'\] = [0-9]{1,2};/"; - $patterns[] = "/\\\$CFG\['ViewEnableDetailPopups'\] = [0-9]{1,2};/"; - $patterns[] = "/\\\$CFG\['UserDBEnabled'\] = [0-9]{1,2};/"; - $replacements[] = "\$CFG['ViewMessageCharacterLimit'] = " . $_SESSION['ViewMessageCharacterLimit'] . ";"; - $replacements[] = "\$CFG['ViewEntriesPerPage'] = " . $_SESSION['ViewEntriesPerPage'] . ";"; - $replacements[] = "\$CFG['ViewEnableDetailPopups'] = " . $_SESSION['ViewEnableDetailPopups'] . ";"; - $replacements[] = "\$CFG['UserDBEnabled'] = " . $_SESSION['UserDBEnabled'] . ";"; - - //User Database Options - if ( $_SESSION['UserDBEnabled'] == 1 ) - { - // TODO! - } - - //Add the first source! - $firstsource = "\$CFG['Sources']['Source1']['ID'] = 'Source1';\r\n" . - "\$CFG['Sources']['Source1']['Name'] = '" . $_SESSION['SourceName'] . "';\r\n" . - "\$CFG['Sources']['Source1']['SourceType'] = " . $_SESSION['SourceType'] . ";\r\n"; - if ( $_SESSION['SourceType'] == SOURCE_DISK ) - { - $firstsource .= "\$CFG['Sources']['Source1']['LogLineType'] = '" . $_SESSION['SourceLogLineType'] . "';\r\n" . - "\$CFG['Sources']['Source1']['DiskFile'] = '" . $_SESSION['SourceDiskFile'] . "';\r\n" . - ""; - } - else if ( $_SESSION['SourceType'] == SOURCE_DB ) - { - $firstsource .= "\$CFG['Sources']['Source1']['DBTableType'] = '" . $_SESSION['SourceDBTableType'] . "';\r\n" . - "\$CFG['Sources']['Source1']['DBType'] = '" . $_SESSION['SourceDBType'] . "';\r\n" . - "\$CFG['Sources']['Source1']['DBServer'] = '" . $_SESSION['SourceDBServer'] . "';\r\n" . - "\$CFG['Sources']['Source1']['DBName'] = '" . $_SESSION['SourceDBName'] . "';\r\n" . - "\$CFG['Sources']['Source1']['DBUser'] = '" . $_SESSION['SourceDBUser'] . "';\r\n" . - "\$CFG['Sources']['Source1']['DBPassword'] = '" . $_SESSION['SourceDBPassword'] . "';\r\n" . - "\$CFG['Sources']['Source1']['DBTableName'] = '" . $_SESSION['SourceDBTableName'] . "';\r\n" . - ""; - } - $patterns[] = "/\/\/ --- \%Insert Source Here\%/"; - $replacements[] = $firstsource; - - // One call to replace them all ^^ - $filebuffer = preg_replace( $patterns, $replacements, $filebuffer ); -// echo $filebuffer; - - // Create file and write config into it! - $handle = fopen( $content['BASEPATH'] . "config.php" , "w"); - if ( $handle === false ) - RevertOneStep( $content['INSTALL_STEP']-1, "Coult not create the configuration file " . $content['BASEPATH'] . "config.php" . "! Check File permissions!!!" ); - - fwrite($handle, $filebuffer); - fclose($handle); -} -// --- - - - -// --- - -// --- Parsen and Output -InitTemplateParser(); -$page -> parser($content, "install.html"); -$page -> output(); -// --- - -// --- Helper functions - -function RevertOneStep($stepback, $errormsg) -{ - header("Location: install.php?step=" . $stepback . "&errormsg=" . urlencode($errormsg) ); - exit; -} - -function ForwardOneStep() -{ - global $content; - - header("Location: install.php?step=" . ($content['INSTALL_STEP']+1) ); - exit; -} - -function LoadDataFile($szFileName) -{ - global $content; - - // Lets read the table definitions :) - $buffer = ""; - $handle = @fopen($szFileName, "r"); - if ($handle === false) - RevertOneStep( $content['INSTALL_STEP']-1, "Error reading the file " . $szFileName . "! Check if the file exists!" ); - else - { - while (!feof($handle)) - { - $buffer .= fgets($handle, 4096); - } - fclose($handle); - } - - // return file buffer! - return $buffer; -} - -function ImportDataFile($szFileName) -{ - global $content, $totaldbdefs; - - // Lets read the table definitions :) - $handle = @fopen($szFileName, "r"); - if ($handle === false) - RevertOneStep( $content['INSTALL_STEP']-1, "Error reading the default database defintion file " . $szFileName . "! Check if the file exists!!!" ); - else - { - while (!feof($handle)) - { - $buffer = fgets($handle, 4096); - - $pos = strpos($buffer, "--"); - if ($pos === false) - $totaldbdefs .= $buffer; - else if ( $pos > 2 && strlen( trim($buffer) ) > 1 ) - $totaldbdefs .= $buffer; - } - fclose($handle); - } -} - -// --- -?> + Installer File + * + * All directives are explained within this file + * + * Copyright (C) 2008 Adiscon GmbH. + * + * This file is part of phpLogCon. + * + * PhpLogCon is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PhpLogCon is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with phpLogCon. If not, see . + * + * A copy of the GPL can be found in the file "COPYING" in this + * distribution + ********************************************************************* +*/ + + +// *** Default includes and procedures *** // +define('IN_PHPLOGCON', true); +define('IN_PHPLOGCON_INSTALL', true); // Extra for INSTALL Script! +$gl_root_path = './'; + +// Now include necessary include files! +include($gl_root_path . 'include/functions_common.php'); +include($gl_root_path . 'include/functions_frontendhelpers.php'); + +// Init Langauge first! +IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/main.php' ); + +InitBasicPhpLogCon(); +//InitPhpLogCon(); + +// Set some static values +define('MAX_STEPS', 8); +$content['web_theme'] = "default"; +$content['user_theme'] = "default"; +$configsamplefile = $content['BASEPATH'] . "include/config.sample.php"; + +//ini_set('error_reporting', E_ERROR); // NO PHP ERROR'S! +// *** *** // + +// --- CONTENT Vars +$content['TITLE'] = "phpLogCon :: Installer Step %1"; +// --- + +// --- Read Vars +if ( isset($_GET['step']) ) +{ + $content['INSTALL_STEP'] = intval(DB_RemoveBadChars($_GET['step'])); + if ( $content['INSTALL_STEP'] > MAX_STEPS ) + $content['INSTALL_STEP'] = 1; +} +else + $content['INSTALL_STEP'] = 1; + +// Set Next Step +$content['INSTALL_NEXT_STEP'] = $content['INSTALL_STEP']; + +if ( MAX_STEPS > $content['INSTALL_STEP'] ) +{ + $content['NEXT_ENABLED'] = "true"; + $content['FINISH_ENABLED'] = "false"; + $content['INSTALL_NEXT_STEP']++; +} +else +{ + $content['NEXT_ENABLED'] = "false"; + $content['FINISH_ENABLED'] = "true"; +} +// --- + + + +// --- BEGIN Custom Code + +// --- Set Bar Image + $content['BarImagePlus'] = $gl_root_path . "images/bars/bar-middle/green_middle_17.png"; + $content['BarImageLeft'] = $gl_root_path . "images/bars/bar-middle/green_left_17.png"; + $content['BarImageRight'] = $gl_root_path . "images/bars/bar-middle/green_right_17.png"; + $content['WidthPlus'] = intval( $content['INSTALL_STEP'] * (100 / MAX_STEPS) ) - 8; + $content['WidthPlusText'] = "Installer Step " . $content['INSTALL_STEP']; +// --- + +// --- Set Title +GetAndReplaceLangStr( $content['TITLE'], $content['INSTALL_STEP'] ); +// --- + +// --- Start Setup Processing +if ( $content['INSTALL_STEP'] == 2 ) +{ + // Check if file permissions are correctly + $content['fileperm'][0]['FILE_NAME'] = $content['BASEPATH'] . "config.php"; + $content['fileperm'][0]['FILE_TYPE'] = "file"; +// $content['fileperm'][1]['FILE_NAME'] = $content['BASEPATH'] . "gamelogs/"; +// $content['fileperm'][1]['FILE_TYPE'] = "dir"; + +// Check file by file + $bSuccess = true; + for($i = 0; $i < count($content['fileperm']); $i++) + { + // --- Set CSS Class + if ( $i % 2 == 0 ) + $content['fileperm'][$i]['cssclass'] = "line1"; + else + $content['fileperm'][$i]['cssclass'] = "line2"; + // --- + + if ( $content['fileperm'][$i]['FILE_TYPE'] == "dir" ) + { + // Get Permission mask + $perms = fileperms( $content['fileperm'][$i]['FILE_NAME'] ); + + // World + $iswriteable = (($perms & 0x0004) ? true : false) && (($perms & 0x0002) ? true : false); + if ( $iswriteable ) + { + $content['fileperm'][$i]['BGCOLOR'] = "#007700"; + $content['fileperm'][$i]['ISSUCCESS'] = "Writeable"; + } + else + { + $content['fileperm'][$i]['BGCOLOR'] = "#770000"; + $content['fileperm'][$i]['ISSUCCESS'] = "NOT Writeable"; + $bSuccess = false; + } + } + else + { + if ( !is_file($content['fileperm'][$i]['FILE_NAME']) ) + { + // Try to create an empty file + touch($content['fileperm'][$i]['FILE_NAME']); + } + + if ( is_file($content['fileperm'][$i]['FILE_NAME']) ) + { + if ( is_writable($content['fileperm'][$i]['FILE_NAME']) ) + { + $content['fileperm'][$i]['BGCOLOR'] = "#007700"; + $content['fileperm'][$i]['ISSUCCESS'] = "Writeable"; + } + else + { + $content['fileperm'][$i]['BGCOLOR'] = "#770000"; + $content['fileperm'][$i]['ISSUCCESS'] = "NOT Writeable"; + $bSuccess = false; + } + } + else + { + $content['fileperm'][$i]['BGCOLOR'] = "#770000"; + $content['fileperm'][$i]['ISSUCCESS'] = "File does NOT exist!"; + $bSuccess = false; + } + } + } + + if ( !$bSuccess ) + { + $content['NEXT_ENABLED'] = "false"; + $content['RECHECK_ENABLED'] = "true"; + $content['iserror'] = "true"; + $content['errormsg'] = "One file or directory (or more) are not writeable, please check the file permissions (chmod 777)!"; + } + + // Check if sample config file is available + if ( !is_file($configsamplefile) || GetFileLength($configsamplefile) <= 0 ) + { + $content['NEXT_ENABLED'] = "false"; + $content['RECHECK_ENABLED'] = "true"; + $content['iserror'] = "true"; + $content['errormsg'] = "The sample configuration file '" . $configsamplefile . "' is missing. You have not fully uploaded phplogcon."; + } + +} +else if ( $content['INSTALL_STEP'] == 3 ) +{ + // --- Read and predefine Database options + if ( isset($_SESSION['UserDBEnabled']) ) { $content['UserDBEnabled'] = $_SESSION['UserDBEnabled']; } else { $content['UserDBEnabled'] = false; } + if ( isset($_SESSION['UserDBServer']) ) { $content['UserDBServer'] = $_SESSION['UserDBServer']; } else { $content['UserDBServer'] = "localhost"; } + if ( isset($_SESSION['UserDBPort']) ) { $content['UserDBPort'] = $_SESSION['UserDBPort']; } else { $content['UserDBPort'] = "3306"; } + if ( isset($_SESSION['UserDBName']) ) { $content['UserDBName'] = $_SESSION['UserDBName']; } else { $content['UserDBName'] = "phplogcon"; } + if ( isset($_SESSION['UserDBPref']) ) { $content['UserDBPref'] = $_SESSION['UserDBPref']; } else { $content['UserDBPref'] = "logcon_"; } + if ( isset($_SESSION['UserDBUser']) ) { $content['UserDBUser'] = $_SESSION['UserDBUser']; } else { $content['UserDBUser'] = "user"; } + if ( isset($_SESSION['UserDBPass']) ) { $content['UserDBPass'] = $_SESSION['UserDBPass']; } else { $content['UserDBPass'] = ""; } + if ( $content['UserDBEnabled'] == 1 ) + { + $content['UserDBEnabled_true'] = "checked"; + $content['UserDBEnabled_false'] = ""; + } + else + { + $content['UserDBEnabled_true'] = ""; + $content['UserDBEnabled_false'] = "checked"; + } + // --- + + // --- Read and predefine Frontend options + if ( isset($_SESSION['ViewMessageCharacterLimit']) ) { $content['ViewMessageCharacterLimit'] = $_SESSION['ViewMessageCharacterLimit']; } else { $content['ViewMessageCharacterLimit'] = 80; } + if ( isset($_SESSION['ViewEntriesPerPage']) ) { $content['ViewEntriesPerPage'] = $_SESSION['ViewEntriesPerPage']; } else { $content['ViewEntriesPerPage'] = 50; } + if ( isset($_SESSION['ViewEnableDetailPopups']) ) { $content['ViewEnableDetailPopups'] = $_SESSION['ViewEnableDetailPopups']; } else { $content['ViewEnableDetailPopups'] = 1; } + if ( $content['ViewEnableDetailPopups'] == 1 ) + { + $content['ViewEnableDetailPopups_true'] = "checked"; + $content['ViewEnableDetailPopups_false'] = ""; + } + else + { + $content['ViewEnableDetailPopups_true'] = ""; + $content['ViewEnableDetailPopups_false'] = "checked"; + } + // --- + + // Disable the bottom next button, as the Form in this step has its own button! +// $content['NEXT_ENABLED'] = "false"; + + // Check for Error Msg + if ( isset($_GET['errormsg']) ) + { + $content['iserror'] = "true"; + $content['errormsg'] = DB_RemoveBadChars( urldecode($_GET['errormsg']) ); + } +} +else if ( $content['INSTALL_STEP'] == 4 ) +{ + // --- Read Database Vars + if ( isset($_POST['UserDBEnabled']) ) + { + $_SESSION['UserDBEnabled'] = DB_RemoveBadChars($_POST['UserDBEnabled']); + if ( $_SESSION['UserDBEnabled'] == 1 ) + { + // Read vars + if ( isset($_POST['UserDBServer']) ) + $_SESSION['UserDBServer'] = DB_RemoveBadChars($_POST['UserDBServer']); + else + RevertOneStep( $content['INSTALL_STEP']-1, $content['LN_CFG_PARAMMISSING'] . $content['LN_CFG_DBSERVER'] ); + + if ( isset($_POST['UserDBPort']) ) + $_SESSION['UserDBPort'] = intval(DB_RemoveBadChars($_POST['UserDBPort'])); + else + RevertOneStep( $content['INSTALL_STEP']-1, $content['LN_CFG_PARAMMISSING'] . $content['LN_CFG_DBPORT'] ); + + if ( isset($_POST['UserDBName']) ) + $_SESSION['UserDBName'] = DB_RemoveBadChars($_POST['UserDBName']); + else + RevertOneStep( $content['INSTALL_STEP']-1, $content['LN_CFG_PARAMMISSING'] . $content['LN_CFG_DBNAME'] ); + + if ( isset($_POST['UserDBPref']) ) + $_SESSION['UserDBPref'] = DB_RemoveBadChars($_POST['UserDBPref']); + else + RevertOneStep( $content['INSTALL_STEP']-1, $content['LN_CFG_PARAMMISSING'] . $content['LN_CFG_DBPREF'] ); + + if ( isset($_POST['UserDBUser']) ) + $_SESSION['UserDBUser'] = DB_RemoveBadChars($_POST['UserDBUser']); + else + RevertOneStep( $content['INSTALL_STEP']-1, $content['LN_CFG_PARAMMISSING']. $content['LN_CFG_DBUSER'] ); + + if ( isset($_POST['UserDBPass']) ) + $_SESSION['UserDBPass'] = DB_RemoveBadChars($_POST['UserDBPass']); + else + $_SESSION['UserDBPass'] = ""; + + // Now Check database connect + $link_id = mysql_connect( $_SESSION['UserDBServer'], $_SESSION['UserDBUser'], $_SESSION['UserDBPass']); + if (!$link_id) + RevertOneStep( $content['INSTALL_STEP']-1, "Connect to " .$_SESSION['UserDBServer'] . " failed! Check Servername, Port, User and Password!
" . DB_ReturnSimpleErrorMsg() ); + + // Try to select the DB! + $db_selected = mysql_select_db($_SESSION['UserDBName'], $link_id); + if(!$db_selected) + RevertOneStep( $content['INSTALL_STEP']-1, "Cannot use database " .$_SESSION['UserDBName'] . "! If the database does not exists, create it or check access permissions!
" . DB_ReturnSimpleErrorMsg()); + } + } + // --- + + // --- Read Frontend Vars + if ( isset($_POST['ViewMessageCharacterLimit']) ) + { + $_SESSION['ViewMessageCharacterLimit'] = intval( DB_RemoveBadChars($_POST['ViewMessageCharacterLimit']) ); + if ( $_SESSION['ViewMessageCharacterLimit'] < 0 ) + $_SESSION['ViewMessageCharacterLimit'] = 80; // Fallback default! + } + else + $_SESSION['ViewMessageCharacterLimit'] = 80; // Fallback default! + + if ( isset($_POST['ViewEntriesPerPage']) ) + { + $_SESSION['ViewEntriesPerPage'] = intval( DB_RemoveBadChars($_POST['ViewEntriesPerPage']) ); + if ( $_SESSION['ViewEntriesPerPage'] < 0 ) + $_SESSION['ViewEntriesPerPage'] = 50; // Fallback default! + } + else + $_SESSION['ViewEntriesPerPage'] = 50; // Fallback default! + + if ( isset($_POST['ViewEnableDetailPopups']) ) + $_SESSION['ViewEnableDetailPopups'] = intval( DB_RemoveBadChars($_POST['ViewEnableDetailPopups']) ); + else + $_SESSION['ViewEnableDetailPopups'] = 1; // Fallback default! + // --- + + // If UserDB is disabled, skip next step! + if ( $_SESSION['UserDBEnabled'] == 0 ) + ForwardOneStep(); +} +else if ( $content['INSTALL_STEP'] == 5 ) +{ + $content['sql_sucess'] = 0; + $content['sql_failed'] = 0; + + // Import default database if user db is enabled! + if ( $_SESSION['UserDBEnabled'] == 1 ) + { + // Init $totaldbdefs + $totaldbdefs = ""; + + // Read the table GLOBAL definitions + ImportDataFile( $content['BASEPATH'] . "contrib/db_template.txt" ); + + // Process definitions ^^ + if ( strlen($totaldbdefs) <= 0 ) + { + $content['failedstatements'][ $content['sql_failed'] ]['myerrmsg'] = "Error, invalid Database Defintion File (to short!), file '" . $content['BASEPATH'] . "contrib/db_template.txt" . "'!
Maybe the file was not correctly uploaded?"; + $content['failedstatements'][ $content['sql_failed'] ]['mystatement'] = ""; + $content['sql_failed']++; + } + + // Replace stats_ with the custom one ;) + $totaldbdefs = str_replace( "`logcon_", "`" . $_SESSION["UserDBPref"], $totaldbdefs ); + + // Now split by sql command + $mycommands = split( ";\r\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'] = "Error, invalid Database Defintion File (no statements found!) in '" . $content['BASEPATH'] . "contrib/db_template.txt" . "'!
Maybe the file was not correctly uploaded, or a strange bug with your system? Contact phpLogCon forums for assistance!"; + $content['failedstatements'][ $content['sql_failed'] ]['mystatement'] = ""; + $content['sql_failed']++; + } + + // Append INSERT Statement for Config Table to set the GameVersion and Database Version ^^! + $mycommands[count($mycommands)] = "INSERT INTO `" . $_SESSION["UserDBPref"] . "config` (`name`, `value`) VALUES ('database_installedversion', '1')"; + + // --- Now execute all commands + ini_set('error_reporting', E_WARNING); // Enable Warnings! + InitPhpLogConConfigFile(); + + // 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 + $content['failedstatements'][ $content['sql_failed'] ]['cssclass'] = "line2"; + // --- + + $content['sql_failed']++; + } + else + $content['sql_sucess']++; + + // Free result + DB_FreeQuery($result); + } + } + } + else // Skip this step in this case! + ForwardOneStep(); +} +else if ( $content['INSTALL_STEP'] == 6 ) +{ + if ( $_SESSION['UserDBEnabled'] == 1 ) + { + if ( isset($_SESSION['MAIN_Username']) ) + $content['MAIN_Username'] = $_SESSION['MAIN_Username']; + else + $content['MAIN_Username'] = ""; + + $content['MAIN_Password1'] = ""; + $content['MAIN_Password2'] = ""; + + // Check for Error Msg + if ( isset($_GET['errormsg']) ) + { + $content['iserror'] = "true"; + $content['errormsg'] = DB_RemoveBadChars( urldecode($_GET['errormsg']) ); + } + } + else // NO Database means NO user management, so next step! + ForwardOneStep(); +} +else if ( $content['INSTALL_STEP'] == 7 ) +{ + if ( $_SESSION['UserDBEnabled'] == 1 ) + { + if ( isset($_POST['username']) ) + $_SESSION['MAIN_Username'] = DB_RemoveBadChars($_POST['username']); + else + RevertOneStep( $content['INSTALL_STEP']-1, "Username needs to be specified" ); + + if ( isset($_POST['password1']) ) + $_SESSION['MAIN_Password1'] = DB_RemoveBadChars($_POST['password1']); + else + $_SESSION['MAIN_Password1'] = ""; + + if ( isset($_POST['password2']) ) + $_SESSION['MAIN_Password2'] = DB_RemoveBadChars($_POST['password2']); + else + $_SESSION['MAIN_Password2'] = ""; + + if ( + strlen($_SESSION['MAIN_Password1']) <= 4 || + $_SESSION['MAIN_Password1'] != $_SESSION['MAIN_Password2'] + ) + RevertOneStep( $content['INSTALL_STEP']-1, "Either the password does not match or is to short!" ); + + // --- Now execute all commands + ini_set('error_reporting', E_WARNING); // Enable Warnings! + InitPhpLogConConfigFile(); + + // Establish DB Connection + DB_Connect(); + + // Everything is fine, lets go create the User! + CreateUserName( $_SESSION['MAIN_Username'], $_SESSION['MAIN_Password1'], 0 ); + } + + // Init Source Options + if ( isset($_SESSION['SourceType']) ) { $content['SourceType'] = $_SESSION['SourceType']; } else { $content['SourceType'] = SOURCE_DISK; } + CreateSourceTypesList($content['SourceType']); + if ( isset($_SESSION['SourceName']) ) { $content['SourceName'] = $_SESSION['SourceName']; } else { $content['SourceName'] = "My Syslog Source"; } + + // SOURCE_DISK specific + if ( isset($_SESSION['SourceLogLineType']) ) { $content['SourceLogLineType'] = $_SESSION['SourceLogLineType']; } else { $content['SourceLogLineType'] = ""; } + CreateLogLineTypesList($content['SourceLogLineType']); + if ( isset($_SESSION['SourceDiskFile']) ) { $content['SourceDiskFile'] = $_SESSION['SourceDiskFile']; } else { $content['SourceDiskFile'] = "/var/log/syslog"; } + + // SOURCE_DB specific + if ( isset($_SESSION['SourceDBType']) ) { $content['SourceDBType'] = $_SESSION['SourceDBType']; } else { $content['SourceDBType'] = DB_MYSQL; } + CreateDBTypesList($content['SourceDBType']); + if ( isset($_SESSION['SourceDBName']) ) { $content['SourceDBName'] = $_SESSION['SourceDBName']; } else { $content['SourceDBName'] = "phplogcon"; } + if ( isset($_SESSION['SourceDBTableType']) ) { $content['SourceDBTableType'] = $_SESSION['SourceDBTableType']; } else { $content['SourceDBTableType'] = "monitorware"; } + if ( isset($_SESSION['SourceDBServer']) ) { $content['SourceDBServer'] = $_SESSION['SourceDBServer']; } else { $content['SourceDBServer'] = "localhost"; } + if ( isset($_SESSION['SourceDBTableName']) ) { $content['SourceDBTableName'] = $_SESSION['SourceDBTableName']; } else { $content['SourceDBTableName'] = "systemevents"; } + if ( isset($_SESSION['SourceDBUser']) ) { $content['SourceDBUser'] = $_SESSION['SourceDBUser']; } else { $content['SourceDBUser'] = "user"; } + if ( isset($_SESSION['SourceDBPassword']) ) { $content['SourceDBPassword'] = $_SESSION['SourceDBPassword']; } else { $content['SourceDBPassword'] = ""; } + + // Check for Error Msg + if ( isset($_GET['errormsg']) ) + { + $content['iserror'] = "true"; + $content['errormsg'] = DB_RemoveBadChars( urldecode($_GET['errormsg']) ); + } +} +else if ( $content['INSTALL_STEP'] == 8 ) +{ + // Read vars + if ( isset($_POST['SourceType']) ) + $_SESSION['SourceType'] = DB_RemoveBadChars($_POST['SourceType']); + else + RevertOneStep( $content['INSTALL_STEP']-1, $content['LN_CFG_PARAMMISSING'] . $content['LN_CFG_SOURCETYPE'] ); + + if ( isset($_POST['SourceName']) ) + $_SESSION['SourceName'] = DB_RemoveBadChars($_POST['SourceName']); + else + RevertOneStep( $content['INSTALL_STEP']-1, $content['LN_CFG_PARAMMISSING'] . $content['LN_CFG_NAMEOFTHESOURCE'] ); + + // Check DISK Parameters! + if ( $_SESSION['SourceType'] == SOURCE_DISK) + { + if ( isset($_POST['SourceLogLineType']) ) + $_SESSION['SourceLogLineType'] = DB_RemoveBadChars($_POST['SourceLogLineType']); + else + RevertOneStep( $content['INSTALL_STEP']-1, $content['LN_CFG_PARAMMISSING'] . $content['LN_CFG_LOGLINETYPE'] ); + + if ( isset($_POST['SourceDiskFile']) ) + $_SESSION['SourceDiskFile'] = DB_RemoveBadChars($_POST['SourceDiskFile']); + else + RevertOneStep( $content['INSTALL_STEP']-1, $content['LN_CFG_PARAMMISSING'] . $content['LN_CFG_SYSLOGFILE'] ); + + // Check if access to the configured file is possible + if ( !is_file($_SESSION['SourceDiskFile']) ) + RevertOneStep( $content['INSTALL_STEP']-1, "Failed to open the syslog file " .$_SESSION['SourceDiskFile'] . "! Check if the file exists and phplogcon has sufficient rights to it
" ); + } + else if ( $_SESSION['SourceType'] == SOURCE_DB) + { + if ( isset($_POST['SourceDBType']) ) + $_SESSION['SourceDBType'] = DB_RemoveBadChars($_POST['SourceDBType']); + else + RevertOneStep( $content['INSTALL_STEP']-1, $content['LN_CFG_PARAMMISSING'] . $content['LN_CFG_DATABASETYPEOPTIONS'] ); + + if ( isset($_POST['SourceDBName']) ) + $_SESSION['SourceDBName'] = DB_RemoveBadChars($_POST['SourceDBName']); + else + RevertOneStep( $content['INSTALL_STEP']-1, $content['LN_CFG_PARAMMISSING'] . $content['LN_CFG_DBNAME'] ); + + if ( isset($_POST['SourceDBTableType']) ) + $_SESSION['SourceDBTableType'] = DB_RemoveBadChars($_POST['SourceDBTableType']); + else + RevertOneStep( $content['INSTALL_STEP']-1, $content['LN_CFG_PARAMMISSING'] . $content['LN_CFG_DBTABLETYPE'] ); + + if ( isset($_POST['SourceDBServer']) ) + $_SESSION['SourceDBServer'] = DB_RemoveBadChars($_POST['SourceDBServer']); + else + RevertOneStep( $content['INSTALL_STEP']-1, $content['LN_CFG_PARAMMISSING'] . $content['LN_CFG_DBSERVER'] ); + + if ( isset($_POST['SourceDBTableName']) ) + $_SESSION['SourceDBTableName'] = DB_RemoveBadChars($_POST['SourceDBTableName']); + else + RevertOneStep( $content['INSTALL_STEP']-1, $content['LN_CFG_PARAMMISSING'] . $content['LN_CFG_DBTABLENAME'] ); + + if ( isset($_POST['SourceDBUser']) ) + $_SESSION['SourceDBUser'] = DB_RemoveBadChars($_POST['SourceDBUser']); + else + RevertOneStep( $content['INSTALL_STEP']-1, $content['LN_CFG_PARAMMISSING'] . $content['LN_CFG_DBUSER'] ); + + if ( isset($_POST['SourceDBPassword']) ) + $_SESSION['SourceDBPassword'] = DB_RemoveBadChars($_POST['SourceDBPassword']); + else + $_SESSION['SourceDBPassword'] = ""; + + // TODO: Check database connectivity! + } + + // If we reached this point, we have gathered all necessary information to create our configuration file ;)! + $filebuffer = LoadDataFile($configsamplefile); + + // Start replacing existing sample configurations + $patterns[] = "/\\\$CFG\['ViewMessageCharacterLimit'\] = [0-9]{1,2};/"; + $patterns[] = "/\\\$CFG\['ViewEntriesPerPage'\] = [0-9]{1,2};/"; + $patterns[] = "/\\\$CFG\['ViewEnableDetailPopups'\] = [0-9]{1,2};/"; + $patterns[] = "/\\\$CFG\['UserDBEnabled'\] = [0-9]{1,2};/"; + $replacements[] = "\$CFG['ViewMessageCharacterLimit'] = " . $_SESSION['ViewMessageCharacterLimit'] . ";"; + $replacements[] = "\$CFG['ViewEntriesPerPage'] = " . $_SESSION['ViewEntriesPerPage'] . ";"; + $replacements[] = "\$CFG['ViewEnableDetailPopups'] = " . $_SESSION['ViewEnableDetailPopups'] . ";"; + $replacements[] = "\$CFG['UserDBEnabled'] = " . $_SESSION['UserDBEnabled'] . ";"; + + //User Database Options + if ( $_SESSION['UserDBEnabled'] == 1 ) + { + // TODO! + } + + //Add the first source! + $firstsource = "\$CFG['Sources']['Source1']['ID'] = 'Source1';\r\n" . + "\$CFG['Sources']['Source1']['Name'] = '" . $_SESSION['SourceName'] . "';\r\n" . + "\$CFG['Sources']['Source1']['SourceType'] = " . $_SESSION['SourceType'] . ";\r\n"; + if ( $_SESSION['SourceType'] == SOURCE_DISK ) + { + $firstsource .= "\$CFG['Sources']['Source1']['LogLineType'] = '" . $_SESSION['SourceLogLineType'] . "';\r\n" . + "\$CFG['Sources']['Source1']['DiskFile'] = '" . $_SESSION['SourceDiskFile'] . "';\r\n" . + ""; + } + else if ( $_SESSION['SourceType'] == SOURCE_DB ) + { + $firstsource .= "\$CFG['Sources']['Source1']['DBTableType'] = '" . $_SESSION['SourceDBTableType'] . "';\r\n" . + "\$CFG['Sources']['Source1']['DBType'] = '" . $_SESSION['SourceDBType'] . "';\r\n" . + "\$CFG['Sources']['Source1']['DBServer'] = '" . $_SESSION['SourceDBServer'] . "';\r\n" . + "\$CFG['Sources']['Source1']['DBName'] = '" . $_SESSION['SourceDBName'] . "';\r\n" . + "\$CFG['Sources']['Source1']['DBUser'] = '" . $_SESSION['SourceDBUser'] . "';\r\n" . + "\$CFG['Sources']['Source1']['DBPassword'] = '" . $_SESSION['SourceDBPassword'] . "';\r\n" . + "\$CFG['Sources']['Source1']['DBTableName'] = '" . $_SESSION['SourceDBTableName'] . "';\r\n" . + ""; + } + $patterns[] = "/\/\/ --- \%Insert Source Here\%/"; + $replacements[] = $firstsource; + + // One call to replace them all ^^ + $filebuffer = preg_replace( $patterns, $replacements, $filebuffer ); +// echo $filebuffer; + + // Create file and write config into it! + $handle = fopen( $content['BASEPATH'] . "config.php" , "w"); + if ( $handle === false ) + RevertOneStep( $content['INSTALL_STEP']-1, "Coult not create the configuration file " . $content['BASEPATH'] . "config.php" . "! Check File permissions!!!" ); + + fwrite($handle, $filebuffer); + fclose($handle); +} +// --- + + + +// --- + +// --- Parsen and Output +InitTemplateParser(); +$page -> parser($content, "install.html"); +$page -> output(); +// --- + +// --- Helper functions + +function RevertOneStep($stepback, $errormsg) +{ + header("Location: install.php?step=" . $stepback . "&errormsg=" . urlencode($errormsg) ); + exit; +} + +function ForwardOneStep() +{ + global $content; + + header("Location: install.php?step=" . ($content['INSTALL_STEP']+1) ); + exit; +} + +function LoadDataFile($szFileName) +{ + global $content; + + // Lets read the table definitions :) + $buffer = ""; + $handle = @fopen($szFileName, "r"); + if ($handle === false) + RevertOneStep( $content['INSTALL_STEP']-1, "Error reading the file " . $szFileName . "! Check if the file exists!" ); + else + { + while (!feof($handle)) + { + $buffer .= fgets($handle, 4096); + } + fclose($handle); + } + + // return file buffer! + return $buffer; +} + +function ImportDataFile($szFileName) +{ + global $content, $totaldbdefs; + + // Lets read the table definitions :) + $handle = @fopen($szFileName, "r"); + if ($handle === false) + RevertOneStep( $content['INSTALL_STEP']-1, "Error reading the default database defintion file " . $szFileName . "! Check if the file exists!!!" ); + else + { + while (!feof($handle)) + { + $buffer = fgets($handle, 4096); + + $pos = strpos($buffer, "--"); + if ($pos === false) + $totaldbdefs .= $buffer; + else if ( $pos > 2 && strlen( trim($buffer) ) > 1 ) + $totaldbdefs .= $buffer; + } + fclose($handle); + } +} + +// --- +?> diff --git a/src/search.php b/src/search.php index 7781006..7ce45ae 100644 --- a/src/search.php +++ b/src/search.php @@ -1,179 +1,179 @@ - www.phplogcon.org <- - * ----------------------------------------------------------------- - * Main Index File - * - * -> Loads the main PhpLogCon Site - * - * All directives are explained within this file - * - * Copyright (C) 2008 Adiscon GmbH. - * - * This file is part of phpLogCon. - * - * PhpLogCon is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PhpLogCon is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with phpLogCon. If not, see . - * - * A copy of the GPL can be found in the file "COPYING" in this - * distribution. - ********************************************************************* -*/ - -// *** Default includes and procedures *** // -define('IN_PHPLOGCON', true); -$gl_root_path = './'; -include($gl_root_path . 'include/functions_common.php'); -include($gl_root_path . 'include/functions_frontendhelpers.php'); -include($gl_root_path . 'include/functions_filters.php'); - -InitPhpLogCon(); -InitSourceConfigs(); -InitFrontEndDefaults(); // Only in WebFrontEnd - -// Init Langauge first! -// IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/main.php' ); - -// Helpers for frontend filtering! -InitFilterHelpers(); -// *** *** // - -// --- Extra Javascript? -$content['EXTRA_JAVASCRIPT'] = ""; -// --- - -// --- CONTENT Vars - -// Init Sorting variables -$content['searchstr'] = ""; - -// --- - -//if ( isset($content['myserver']) ) -// $content['TITLE'] = "phpLogCon :: Home :: Server '" . $content['myserver']['Name'] . "'"; // Title of the Page -//else - $content['TITLE'] = "phpLogCon :: Search"; -// --- - -// --- BEGIN Custom Code - -if ( (isset($_POST['search']) || isset($_GET['search'])) ) -{ - // Copy search over - if ( isset($_POST['search']) ) - $mysearch = $_POST['search']; - else if ( isset($_GET['search']) ) - $mysearch = $_GET['search']; - - // Evaluate search now - if ( $mysearch == $content['LN_SEARCH_PERFORMADVANCED']) - { - if ( isset($_GET['filter_datemode']) ) - { - $filters['filter_datemode'] = intval($_GET['filter_datemode']); - if ( $filters['filter_datemode'] == DATEMODE_RANGE ) - { - // Read range values - if ( isset($_GET['filter_daterange_from_year']) ) - $filters['filter_daterange_from_year'] = intval($_GET['filter_daterange_from_year']); - if ( isset($_GET['filter_daterange_from_month']) ) - $filters['filter_daterange_from_month'] = intval($_GET['filter_daterange_from_month']); - if ( isset($_GET['filter_daterange_from_day']) ) - $filters['filter_daterange_from_day'] = intval($_GET['filter_daterange_from_day']); - if ( isset($_GET['filter_daterange_to_year']) ) - $filters['filter_daterange_to_year'] = intval($_GET['filter_daterange_to_year']); - if ( isset($_GET['filter_daterange_to_month']) ) - $filters['filter_daterange_to_month'] = intval($_GET['filter_daterange_to_month']); - if ( isset($_GET['filter_daterange_to_day']) ) - $filters['filter_daterange_to_day'] = intval($_GET['filter_daterange_to_day']); - - // Append to searchstring - $content['searchstr'] .= "datefrom:" . $filters['filter_daterange_from_year'] . "-" . - $filters['filter_daterange_from_month'] . "-" . - $filters['filter_daterange_from_day'] . "T00:00:00 "; - $content['searchstr'] .= "dateto:" . $filters['filter_daterange_to_year'] . "-" . - $filters['filter_daterange_to_month'] . "-" . - $filters['filter_daterange_to_day'] . "T23:59:59 "; - - } - else if ( $filters['filter_datemode'] == DATEMODE_LASTX ) - { - if ( isset($_GET['filter_daterange_last_x']) ) - { - $filters['filter_daterange_last_x'] = intval($_GET['filter_daterange_last_x']); - $content['searchstr'] .= "datelastx:" . $filters['filter_daterange_last_x'] . " "; - } - } - } - - if ( isset($_GET['filter_facility']) && count($_GET['filter_facility']) < 18 ) // If we have more than 18 elements, this means all facilities are enabled - { - $tmpStr = ""; - foreach ($_GET['filter_facility'] as $tmpfacility) - { - if ( strlen($tmpStr) > 0 ) - $tmpStr .= ","; - $tmpStr .= $tmpfacility; - } - $content['searchstr'] .= "facility:" . $tmpStr . " "; - } - - if ( isset($_GET['filter_severity']) && count($_GET['filter_severity']) < 7 ) // If we have more than 7 elements, this means all facilities are enabled) - { - $tmpStr = ""; - foreach ($_GET['filter_severity'] as $tmpfacility) - { - if ( strlen($tmpStr) > 0 ) - $tmpStr .= ","; - $tmpStr .= $tmpfacility; - } - $content['searchstr'] .= "severity:" . $tmpStr . " "; - } - - // Spaces need to be converted! - if ( isset($_GET['filter_syslogtag']) && strlen($_GET['filter_syslogtag']) > 0 ) - { - if ( strpos($_GET['filter_syslogtag'], " ") === false) - $content['searchstr'] .= "syslogtag:" . $_GET['filter_syslogtag'] . " "; - else - $content['searchstr'] .= "syslogtag:" . str_replace(" ", ",", $_GET['filter_syslogtag']) . " "; - } - - // Spaces need to be converted! - if ( isset($_GET['filter_source']) && strlen($_GET['filter_source']) > 0 ) - { - if ( strpos($_GET['filter_source'], " ") === false) - $content['searchstr'] .= "source:" . $_GET['filter_source'] . " "; - else - $content['searchstr'] .= "source:" . str_replace(" ", ",", $_GET['filter_source']) . " "; - } - - // Message is just appended - if ( isset($_GET['filter_message']) && strlen($_GET['filter_message']) > 0 ) - $content['searchstr'] .= $_GET['filter_message']; - } - - // Redirect to the index page now! - RedirectPage( "index.php?filter=" . urlencode( trim($content['searchstr']) ) . "&search=Search"); -} - -// --- - -// --- Parsen and Output -InitTemplateParser(); -$page -> parser($content, "search.html"); -$page -> output(); -// --- - -?> + www.phplogcon.org <- + * ----------------------------------------------------------------- + * Main Index File + * + * -> Loads the main PhpLogCon Site + * + * All directives are explained within this file + * + * Copyright (C) 2008 Adiscon GmbH. + * + * This file is part of phpLogCon. + * + * PhpLogCon is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PhpLogCon is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with phpLogCon. If not, see . + * + * A copy of the GPL can be found in the file "COPYING" in this + * distribution. + ********************************************************************* +*/ + +// *** Default includes and procedures *** // +define('IN_PHPLOGCON', true); +$gl_root_path = './'; +include($gl_root_path . 'include/functions_common.php'); +include($gl_root_path . 'include/functions_frontendhelpers.php'); +include($gl_root_path . 'include/functions_filters.php'); + +InitPhpLogCon(); +InitSourceConfigs(); +InitFrontEndDefaults(); // Only in WebFrontEnd + +// Init Langauge first! +// IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/main.php' ); + +// Helpers for frontend filtering! +InitFilterHelpers(); +// *** *** // + +// --- Extra Javascript? +$content['EXTRA_JAVASCRIPT'] = ""; +// --- + +// --- CONTENT Vars + +// Init Sorting variables +$content['searchstr'] = ""; + +// --- + +//if ( isset($content['myserver']) ) +// $content['TITLE'] = "phpLogCon :: Home :: Server '" . $content['myserver']['Name'] . "'"; // Title of the Page +//else + $content['TITLE'] = "phpLogCon :: Search"; +// --- + +// --- BEGIN Custom Code + +if ( (isset($_POST['search']) || isset($_GET['search'])) ) +{ + // Copy search over + if ( isset($_POST['search']) ) + $mysearch = $_POST['search']; + else if ( isset($_GET['search']) ) + $mysearch = $_GET['search']; + + // Evaluate search now + if ( $mysearch == $content['LN_SEARCH_PERFORMADVANCED']) + { + if ( isset($_GET['filter_datemode']) ) + { + $filters['filter_datemode'] = intval($_GET['filter_datemode']); + if ( $filters['filter_datemode'] == DATEMODE_RANGE ) + { + // Read range values + if ( isset($_GET['filter_daterange_from_year']) ) + $filters['filter_daterange_from_year'] = intval($_GET['filter_daterange_from_year']); + if ( isset($_GET['filter_daterange_from_month']) ) + $filters['filter_daterange_from_month'] = intval($_GET['filter_daterange_from_month']); + if ( isset($_GET['filter_daterange_from_day']) ) + $filters['filter_daterange_from_day'] = intval($_GET['filter_daterange_from_day']); + if ( isset($_GET['filter_daterange_to_year']) ) + $filters['filter_daterange_to_year'] = intval($_GET['filter_daterange_to_year']); + if ( isset($_GET['filter_daterange_to_month']) ) + $filters['filter_daterange_to_month'] = intval($_GET['filter_daterange_to_month']); + if ( isset($_GET['filter_daterange_to_day']) ) + $filters['filter_daterange_to_day'] = intval($_GET['filter_daterange_to_day']); + + // Append to searchstring + $content['searchstr'] .= "datefrom:" . $filters['filter_daterange_from_year'] . "-" . + $filters['filter_daterange_from_month'] . "-" . + $filters['filter_daterange_from_day'] . "T00:00:00 "; + $content['searchstr'] .= "dateto:" . $filters['filter_daterange_to_year'] . "-" . + $filters['filter_daterange_to_month'] . "-" . + $filters['filter_daterange_to_day'] . "T23:59:59 "; + + } + else if ( $filters['filter_datemode'] == DATEMODE_LASTX ) + { + if ( isset($_GET['filter_daterange_last_x']) ) + { + $filters['filter_daterange_last_x'] = intval($_GET['filter_daterange_last_x']); + $content['searchstr'] .= "datelastx:" . $filters['filter_daterange_last_x'] . " "; + } + } + } + + if ( isset($_GET['filter_facility']) && count($_GET['filter_facility']) < 18 ) // If we have more than 18 elements, this means all facilities are enabled + { + $tmpStr = ""; + foreach ($_GET['filter_facility'] as $tmpfacility) + { + if ( strlen($tmpStr) > 0 ) + $tmpStr .= ","; + $tmpStr .= $tmpfacility; + } + $content['searchstr'] .= "facility:" . $tmpStr . " "; + } + + if ( isset($_GET['filter_severity']) && count($_GET['filter_severity']) < 7 ) // If we have more than 7 elements, this means all facilities are enabled) + { + $tmpStr = ""; + foreach ($_GET['filter_severity'] as $tmpfacility) + { + if ( strlen($tmpStr) > 0 ) + $tmpStr .= ","; + $tmpStr .= $tmpfacility; + } + $content['searchstr'] .= "severity:" . $tmpStr . " "; + } + + // Spaces need to be converted! + if ( isset($_GET['filter_syslogtag']) && strlen($_GET['filter_syslogtag']) > 0 ) + { + if ( strpos($_GET['filter_syslogtag'], " ") === false) + $content['searchstr'] .= "syslogtag:" . $_GET['filter_syslogtag'] . " "; + else + $content['searchstr'] .= "syslogtag:" . str_replace(" ", ",", $_GET['filter_syslogtag']) . " "; + } + + // Spaces need to be converted! + if ( isset($_GET['filter_source']) && strlen($_GET['filter_source']) > 0 ) + { + if ( strpos($_GET['filter_source'], " ") === false) + $content['searchstr'] .= "source:" . $_GET['filter_source'] . " "; + else + $content['searchstr'] .= "source:" . str_replace(" ", ",", $_GET['filter_source']) . " "; + } + + // Message is just appended + if ( isset($_GET['filter_message']) && strlen($_GET['filter_message']) > 0 ) + $content['searchstr'] .= $_GET['filter_message']; + } + + // Redirect to the index page now! + RedirectPage( "index.php?filter=" . urlencode( trim($content['searchstr']) ) . "&search=Search"); +} + +// --- + +// --- Parsen and Output +InitTemplateParser(); +$page -> parser($content, "search.html"); +$page -> output(); +// --- + +?> diff --git a/src/userchange.php b/src/userchange.php index 4a4a36e..8a8a933 100644 --- a/src/userchange.php +++ b/src/userchange.php @@ -1,69 +1,69 @@ - www.phplogcon.org <- - * ----------------------------------------------------------------- - * Main Index File - * - * -> Loads the main PhpLogCon Site - * - * All directives are explained within this file - * - * Copyright (C) 2008 Adiscon GmbH. - * - * This file is part of phpLogCon. - * - * PhpLogCon is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * PhpLogCon is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with phpLogCon. If not, see . - * - * A copy of the GPL can be found in the file "COPYING" in this - * distribution. - ********************************************************************* -*/ - -// *** Default includes and procedures *** // -define('IN_PHPLOGCON', true); -$gl_root_path = './'; -include($gl_root_path . 'include/functions_common.php'); -include($gl_root_path . 'include/functions_frontendhelpers.php'); - -InitPhpLogCon(); -InitFrontEndDefaults(); // Only in WebFrontEnd -// *** *** // - -// --- BEGIN Custom Code -if ( isset($_SERVER['HTTP_REFERER']) ) - $szRedir = $_SERVER['HTTP_REFERER']; -else - $szRedir = "index.php"; // Default - - -if ( isset($_GET['op']) ) -{ - if ( $_GET['op'] == "changestyle" ) - { - if ( VerifyTheme($_GET['stylename']) ) - $_SESSION['CUSTOM_THEME'] = $_GET['stylename']; - } - - if ( $_GET['op'] == "changelang" ) - { - if ( VerifyLanguage($_GET['langcode']) ) - $_SESSION['CUSTOM_LANG'] = $_GET['langcode']; - } -} - -// Final redirect -RedirectPage( $szRedir ); -// --- -?> + www.phplogcon.org <- + * ----------------------------------------------------------------- + * Main Index File + * + * -> Loads the main PhpLogCon Site + * + * All directives are explained within this file + * + * Copyright (C) 2008 Adiscon GmbH. + * + * This file is part of phpLogCon. + * + * PhpLogCon is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * PhpLogCon is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with phpLogCon. If not, see . + * + * A copy of the GPL can be found in the file "COPYING" in this + * distribution. + ********************************************************************* +*/ + +// *** Default includes and procedures *** // +define('IN_PHPLOGCON', true); +$gl_root_path = './'; +include($gl_root_path . 'include/functions_common.php'); +include($gl_root_path . 'include/functions_frontendhelpers.php'); + +InitPhpLogCon(); +InitFrontEndDefaults(); // Only in WebFrontEnd +// *** *** // + +// --- BEGIN Custom Code +if ( isset($_SERVER['HTTP_REFERER']) ) + $szRedir = $_SERVER['HTTP_REFERER']; +else + $szRedir = "index.php"; // Default + + +if ( isset($_GET['op']) ) +{ + if ( $_GET['op'] == "changestyle" ) + { + if ( VerifyTheme($_GET['stylename']) ) + $_SESSION['CUSTOM_THEME'] = $_GET['stylename']; + } + + if ( $_GET['op'] == "changelang" ) + { + if ( VerifyLanguage($_GET['langcode']) ) + $_SESSION['CUSTOM_LANG'] = $_GET['langcode']; + } +} + +// Final redirect +RedirectPage( $szRedir ); +// --- +?>