Added support to select character encoding in HTML Header.

This will enable Loganalyzer to output and display UTF-8 encoded logs for example.
The default encoding is ISO-8859-1, it can be switched in the general admin options,
or by adding the $CFG['HeaderDefaultEncoding'] configuration variable into
config.php, possible values are ENC_ISO_8859_1 and ENC_UTF8 for now.
The encoding support can be extended by adding new encoding definitions into
include/constats_general.php.
This commit is contained in:
Andre Lorbach 2011-02-11 13:31:04 +01:00
parent a54591535c
commit 566c669006
10 changed files with 48 additions and 3 deletions

View File

@ -172,6 +172,7 @@ if ( isset($_POST['op']) )
if ( isset ($_POST['InjectBodyFooter']) ) { $content['InjectBodyFooter'] = $_POST['InjectBodyFooter']; }
if ( isset ($_POST['PhplogconLogoUrl']) ) { $content['PhplogconLogoUrl'] = $_POST['PhplogconLogoUrl']; }
if ( isset ($_POST['UseProxyServerForRemoteQueries']) ) { $content['UseProxyServerForRemoteQueries'] = $_POST['UseProxyServerForRemoteQueries']; }
if ( isset ($_POST['HeaderDefaultEncoding']) ) { $content['HeaderDefaultEncoding'] = $_POST['HeaderDefaultEncoding']; }
// Save configuration variables now
SaveGeneralSettingsIntoDB();
@ -309,6 +310,22 @@ foreach ( $content['SOURCES'] as &$mySource )
}
// ---
// --- Init for DefaultEncoding field!
// copy Sources Array
$content['ENCODINGS'] = $encodings;
// if ( !isset($content['DefaultSourceID']) ) { $content['DefaultSourceID'] = ''; }
foreach ( $content['ENCODINGS'] as &$myEncoding)
{
$myEncoding['DisplayName'] = $myEncoding['ID'];
if ( $myEncoding['ID'] == $content['HeaderDefaultEncoding'] )
$myEncoding['selected'] = "selected";
else
$myEncoding['selected'] = "";
}
// ---
// Do if User wants extra options
if ( $content['ENABLEUSEROPTIONS'] )
{

View File

@ -86,6 +86,7 @@ $CFG['PopupMenuTimeout'] = 3000; // This variable defines the default timeout
$CFG['PhplogconLogoUrl'] = ""; // Put an Url to a custom toplogo you want to use.
$CFG['InlineOnlineSearchIcons'] = 1; // Show online search icons
$CFG['UseProxyServerForRemoteQueries'] = "";// If empty no proxy server will be used. If set to a proxy server url like 127.0.0.1:8080, LogAnalyzer will use this server for url queries like the updatecheck.
$CFG['HeaderDefaultEncoding'] = ENC_ISO_8859_1; // Set default character encoding
// ---
// --- Custom HTML Code

View File

@ -216,4 +216,10 @@ $msgtype_colors[IUT_SMTPLISTENER] = "#CCE4DE";
$msgtype_colors[IUT_WEBSERVERLOG] = "#E1FBD0";
// ---
// Supported Encodings
define('ENC_ISO_8859_1', "ISO-8859-1");
define('ENC_UTF8', "utf-8");
$encodings[ENC_ISO_8859_1] = array("ID" => ENC_ISO_8859_1);
$encodings[ENC_UTF8] = array("ID" => ENC_UTF8);
?>

View File

@ -75,7 +75,6 @@ $content['SHOW_DONATEBUTTON'] = true; // Default = true!
// PreInit overall user variables
$content['EXTRA_PHPLOGCON_LOGO'] = $content['BASEPATH'] . "images/main/Header-Logo.png";
$content['EXTRA_METATAGS'] = "";
//$content['EXTRA_METATAGS'] .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
$content['EXTRA_JAVASCRIPT'] = "";
$content['EXTRA_STYLESHEET'] = "";
$content['EXTRA_HTMLHEAD'] = "";
@ -905,6 +904,10 @@ function InitConfigurationValues()
$content['UseProxyServerForRemoteQueries'] = ""; // Init Option
// ---
// --- Read Encoding Option, and set default!
$content['HeaderDefaultEncoding'] = GetConfigSetting("HeaderDefaultEncoding", ENC_ISO_8859_1);
// ---
// Init main langauge file now!
IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/main.php' );
@ -1089,12 +1092,15 @@ function GetStringWithHTMLCodes($myStr)
function InitTemplateParser()
{
global $page, $gl_root_path;
global $page, $gl_root_path, $content;
// -----------------------------------------------
// Create Template Object and set some variables for the templates
// -----------------------------------------------
$page = new Template();
$page -> set_path ( $gl_root_path . "templates/" );
// Append correct Character encoding to HTML Header
$content['EXTRA_METATAGS'] .= '<meta http-equiv="Content-Type" content="text/html; charset=' . $content['HeaderDefaultEncoding'] . '" />';
}
function VerifyLanguage( $mylang )
@ -1570,6 +1576,7 @@ function SaveGeneralSettingsIntoDB($bForceStripSlahes = false)
WriteConfigValue( "MiscDebugToSyslog", true, null, null,$bForceStripSlahes );
WriteConfigValue( "MiscMaxExecutionTime", true, null, null,$bForceStripSlahes );
WriteConfigValue( "UseProxyServerForRemoteQueries", true, null, null,$bForceStripSlahes );
WriteConfigValue( "HeaderDefaultEncoding", true, null, null,$bForceStripSlahes );
// Custom HTML Code
WriteConfigValue( "InjectHtmlHeader", true, null, null,$bForceStripSlahes );

View File

@ -109,6 +109,7 @@ $content['LN_ADMIN_PHPLOGCON_LOGOURL'] = "Optionale LogAnalyzer-Logo-URL. Bitte
$content['LN_ADMIN_ERROR_READONLY'] = "This is a READONLY User, you are not allowed to perform any change operations.";
$content['LN_ADMIN_ERROR_NOTALLOWEDTOEDIT'] = "You are not allowed to edit this configuration item.";
$content['LN_ADMIN_USEPROXYSERVER'] = "Leave empty if you do not want to use a proxy server! If set to valid proxy server (for example '127.0.0.1:8080'), LogAnalyzer will use this server for remote queries like the update check feature.";
$content['LN_ADMIN_DEFAULTENCODING'] = "Default character encoding";
// User Center
$content['LN_USER_CENTER'] = "Benutzer Optionen";

View File

@ -109,6 +109,7 @@ $content['LN_ADMIN_PHPLOGCON_LOGOURL'] = "Optional LogAnalyzer Logo URL. Leave e
$content['LN_ADMIN_ERROR_READONLY'] = "This is a READONLY User, you are not allowed to perform any change operations.";
$content['LN_ADMIN_ERROR_NOTALLOWEDTOEDIT'] = "You are not allowed to edit this configuration item.";
$content['LN_ADMIN_USEPROXYSERVER'] = "Leave empty if you do not want to use a proxy server! If set to valid proxy server (for example '127.0.0.1:8080'), LogAnalyzer will use this server for remote queries like the update check feature.";
$content['LN_ADMIN_DEFAULTENCODING'] = "Default character encoding";
// User Center
$content['LN_USER_CENTER'] = "User Options";

View File

@ -109,6 +109,7 @@ $content['LN_ADMIN_PHPLOGCON_LOGOURL'] = "Optional LogAnalyzer Logo URL. Leave e
$content['LN_ADMIN_ERROR_READONLY'] = "This is a READONLY User, you are not allowed to perform any change operations.";
$content['LN_ADMIN_ERROR_NOTALLOWEDTOEDIT'] = "You are not allowed to edit this configuration item.";
$content['LN_ADMIN_USEPROXYSERVER'] = "Leave empty if you do not want to use a proxy server! If set to valid proxy server (for example '127.0.0.1:8080'), LogAnalyzer will use this server for remote queries like the update check feature.";
$content['LN_ADMIN_DEFAULTENCODING'] = "Default character encoding";
// User Center
$content['LN_USER_CENTER'] = "User Options";

View File

@ -109,6 +109,7 @@ $content['LN_ADMIN_PHPLOGCON_LOGOURL'] = "Optional LogAnalyzer Logo URL. Leave e
$content['LN_ADMIN_ERROR_READONLY'] = "This is a READONLY User, you are not allowed to perform any change operations.";
$content['LN_ADMIN_ERROR_NOTALLOWEDTOEDIT'] = "You are not allowed to edit this configuration item.";
$content['LN_ADMIN_USEPROXYSERVER'] = "Leave empty if you do not want to use a proxy server! If set to valid proxy server (for example '127.0.0.1:8080'), LogAnalyzer will use this server for remote queries like the update check feature.";
$content['LN_ADMIN_DEFAULTENCODING'] = "Default character encoding";
// User Center
$content['LN_USER_CENTER'] = "User Options";

View File

@ -280,6 +280,16 @@
<td align="left" class="cellmenu2_naked"><b>{LN_ADMIN_USEPROXYSERVER}</b></td>
<td align="left" class="line1" colspan="2"><input type="text" name="UseProxyServerForRemoteQueries" size="85" maxlength="255" value="{UseProxyServerForRemoteQueries}" {DISABLE_GLOBALEDIT_FORMCONTROL}></td>
</tr>
<tr>
<td align="left" class="cellmenu2"><b>{LN_ADMIN_DEFAULTENCODING}</b></td>
<td align="left" class="line1" colspan="2">
<select id="HeaderDefaultEncoding" name="HeaderDefaultEncoding" size="1" {DISABLE_GLOBALEDIT_FORMCONTROL}>
<!-- BEGIN ENCODINGS -->
<option {selected} value="{ID}">{DisplayName}</option>
<!-- END ENCODINGS -->
</select>
</td>
</tr>
<tr>
<td align="left" class="cellmenu2"><b>{LN_GEN_DEBUGUSERLOGIN}</b></td>
<td align="left" class="line2" colspan="2"><input type="checkbox" name="DebugUserLogin" value="yes" {DebugUserLogin_checked} {DISABLE_GLOBALEDIT_FORMCONTROL}></td>

View File

@ -1,7 +1,7 @@
<table width="100%" border="0" cellspacing="1" cellpadding="0" class="mainfooter">
<tr>
<td align="center" class="line0" valign="_top">Made by <a href="http://www.adiscon.com" target="_blank">Adiscon GmbH</a> (2008)</td>
<td align="center" class="line0" valign="_top">Made by <a href="http://www.adiscon.com" target="_blank">Adiscon GmbH</a> (2008-2011)</td>
<td align="center" class="line1" valign="_top">
&nbsp;<a href="http://loganalyzer.adiscon.com" target="_blank">Adiscon LogAnalyzer</A> Version {BUILDNUMBER}
</td>