From 0256ace8442d0c7777e998efa44b519ebeb9ba08 Mon Sep 17 00:00:00 2001 From: Andre Lorbach Date: Wed, 22 Oct 2008 16:06:56 +0200 Subject: [PATCH] Added new options to inject custom html code into the header and footer area. This also includes a database version upgrade --- src/admin/index.php | 4 ++++ src/include/config.sample.php | 6 ++++++ src/include/db_update_v6.txt | 6 ++++++ src/include/functions_common.php | 30 +++++++++++++++++++++++++--- src/include/functions_db.php | 12 ++++++++--- src/lang/en/admin.php | 3 +++ src/templates/admin/admin_index.html | 18 ++++++++++++++--- src/templates/include_footer.html | 1 + src/templates/include_header.html | 2 ++ 9 files changed, 73 insertions(+), 9 deletions(-) create mode 100644 src/include/db_update_v6.txt diff --git a/src/admin/index.php b/src/admin/index.php index fbbdea9..8ccaa9d 100644 --- a/src/admin/index.php +++ b/src/admin/index.php @@ -150,6 +150,10 @@ if ( isset($_POST['op']) ) if ( isset ($_POST['SearchCustomButtonCaption']) ) { $content['SearchCustomButtonCaption'] = $_POST['SearchCustomButtonCaption']; } if ( isset ($_POST['SearchCustomButtonSearch']) ) { $content['SearchCustomButtonSearch'] = $_POST['SearchCustomButtonSearch']; } + if ( isset ($_POST['InjectHtmlHeader']) ) { $content['InjectHtmlHeader'] = $_POST['InjectHtmlHeader']; } + if ( isset ($_POST['InjectBodyHeader']) ) { $content['InjectBodyHeader'] = $_POST['InjectBodyHeader']; } + if ( isset ($_POST['InjectBodyFooter']) ) { $content['InjectBodyFooter'] = $_POST['InjectBodyFooter']; } + // Save configuration variables now SaveGeneralSettingsIntoDB(); } diff --git a/src/include/config.sample.php b/src/include/config.sample.php index b7a606c..c2a9dd3 100644 --- a/src/include/config.sample.php +++ b/src/include/config.sample.php @@ -85,6 +85,12 @@ $CFG['TreatNotFoundFiltersAsTrue'] = 0; // If you filter / search for messages, $CFG['PopupMenuTimeout'] = 3000; // This variable defines the default timeout value for popup menus in milliseconds. (those menus which popup when you click on the value of a field. // --- +// --- Custom HTML Code +$CFG['InjectHtmlHeader'] = ""; // Use this variable to inject custom html into the html area! +$CFG['InjectBodyHeader'] = ""; // Use this variable to inject custom html into the begin of the area! +$CFG['InjectBodyFooter'] = ""; // Use this variable to inject custom html into the end of the area! +// --- + // --- Define which fields you want to see //$CFG['ShowMessage'] = true; // If enabled, the Message column will be appended to the columns list. //Eventlog based fields: $CFG['Columns'] = array ( SYSLOG_DATE, SYSLOG_HOST, SYSLOG_EVENT_LOGTYPE, SYSLOG_EVENT_SOURCE, /*SYSLOG_EVENT_CATEGORY, */SYSLOG_EVENT_ID, SYSLOG_MESSAGE ); diff --git a/src/include/db_update_v6.txt b/src/include/db_update_v6.txt new file mode 100644 index 0000000..687b5c4 --- /dev/null +++ b/src/include/db_update_v6.txt @@ -0,0 +1,6 @@ +-- New Database Structure Updates +ALTER TABLE `logcon_config` ADD `propvalue_text` TEXT NOT NULL AFTER `propvalue` ; + +-- Insert data + +-- Updated Data diff --git a/src/include/functions_common.php b/src/include/functions_common.php index 0b73195..1edfe1a 100644 --- a/src/include/functions_common.php +++ b/src/include/functions_common.php @@ -75,6 +75,9 @@ $content['SHOW_DONATEBUTTON'] = true; // Default = true! $content['EXTRA_METATAGS'] = ""; $content['EXTRA_JAVASCRIPT'] = ""; $content['EXTRA_STYLESHEET'] = ""; +$content['EXTRA_HTMLHEAD'] = ""; +$content['EXTRA_HEADER'] = ""; +$content['EXTRA_FOOTER'] = ""; $content['CURRENTURL'] = ""; // --- @@ -685,8 +688,14 @@ function InitConfigurationValues() { for($i = 0; $i < count($rows); $i++) { - $CFG[ $rows[$i]['propname'] ] = $rows[$i]['propvalue']; - $content[ $rows[$i]['propname'] ] = $rows[$i]['propvalue']; + // Obtain the right value + if ( isset($rows[$i]['propvalue_text']) && strlen($rows[$i]['propvalue_text']) > 0 ) + $myValue = $rows[$i]['propvalue_text']; + else + $myValue = $rows[$i]['propvalue']; + + $CFG[ $rows[$i]['propname'] ] = $myValue; + $content[ $rows[$i]['propname'] ] = $myValue; } } } @@ -777,7 +786,7 @@ function InitConfigurationValues() $_SESSION['AUTORELOAD_ID'] = 0; } - // Theme Handling + // --- Theme Handling if ( !isset($content['web_theme']) ) { $content['web_theme'] = GetConfigSetting("ViewDefaultTheme", "default", CFGLEVEL_USER); } if ( isset($_SESSION['CUSTOM_THEME']) && VerifyTheme($_SESSION['CUSTOM_THEME']) ) $content['user_theme'] = $_SESSION['CUSTOM_THEME']; @@ -786,6 +795,16 @@ function InitConfigurationValues() // Init Theme About Info ^^ InitThemeAbout($content['user_theme']); + // --- + + // --- Handle HTML Injection stuff + if ( strlen(GetConfigSetting("InjectHtmlHeader", false)) > 0 ) + $content['EXTRA_HTMLHEAD'] .= $CFG['InjectHtmlHeader']; + if ( strlen(GetConfigSetting("InjectBodyHeader", false)) > 0 ) + $content['EXTRA_HEADER'] .= $CFG['InjectBodyHeader']; + if ( strlen(GetConfigSetting("InjectBodyFooter", false)) > 0 ) + $content['EXTRA_FOOTER'] .= $CFG['InjectBodyFooter']; + // --- // Init main langauge file now! IncludeLanguageFile( $gl_root_path . '/lang/' . $LANG . '/main.php' ); @@ -1349,6 +1368,11 @@ function SaveGeneralSettingsIntoDB() WriteConfigValue( "DebugUserLogin", true ); WriteConfigValue( "MiscDebugToSyslog", true ); WriteConfigValue( "MiscMaxExecutionTime", true ); + + // Custom HTML Code + WriteConfigValue( "InjectHtmlHeader", true ); + WriteConfigValue( "InjectBodyHeader", true ); + WriteConfigValue( "InjectBodyFooter", true ); } function SaveUserGeneralSettingsIntoDB() diff --git a/src/include/functions_db.php b/src/include/functions_db.php index 52a981c..b39afd1 100644 --- a/src/include/functions_db.php +++ b/src/include/functions_db.php @@ -45,7 +45,7 @@ $errdesc = ""; $errno = 0; // --- Current Database Version, this is important for automated database Updates! -$content['database_internalversion'] = "5"; // Whenever incremented, a database upgrade is needed +$content['database_internalversion'] = "6"; // Whenever incremented, a database upgrade is needed $content['database_installedversion'] = "0"; // 0 is default which means Prior Versioning Database // --- @@ -361,13 +361,19 @@ function WriteConfigValue($szPropName, $is_global = true, $userid = false, $grou if ( !isset($rows) ) { // New Entry - $result = DB_Query("INSERT INTO " . DB_CONFIG . " (propname, propvalue, is_global) VALUES ( '" . $szPropName . "', '" . $szDbValue . "', " . $is_global . ")"); + if ( strlen($szDbValue) < 255 ) + $result = DB_Query("INSERT INTO " . DB_CONFIG . " (propname, propvalue, is_global) VALUES ( '" . $szPropName . "', '" . $szDbValue . "', " . $is_global . ")"); + else + $result = DB_Query("INSERT INTO " . DB_CONFIG . " (propname, propvalue_text, is_global) VALUES ( '" . $szPropName . "', '" . $szDbValue . "', " . $is_global . ")"); DB_FreeQuery($result); } else { // Update Entry - $result = DB_Query("UPDATE " . DB_CONFIG . " SET propvalue = '" . $szDbValue . "' WHERE propname = '" . $szPropName . "' AND is_global = " . $is_global); + if ( strlen($szDbValue) < 255 ) + $result = DB_Query("UPDATE " . DB_CONFIG . " SET propvalue = '" . $szDbValue . "', propvalue_text = '' WHERE propname = '" . $szPropName . "' AND is_global = " . $is_global); + else + $result = DB_Query("UPDATE " . DB_CONFIG . " SET propvalue_text = '" . $szDbValue . "', propvalue = '' WHERE propname = '" . $szPropName . "' AND is_global = " . $is_global); DB_FreeQuery($result); } } diff --git a/src/lang/en/admin.php b/src/lang/en/admin.php index 2a488f6..ec035e7 100644 --- a/src/lang/en/admin.php +++ b/src/lang/en/admin.php @@ -92,6 +92,9 @@ $content['LN_ADMIN_GLOBALONLY'] = "Global Options Only"; $content['LN_GEN_DEBUGTOSYSLOG'] = "Send Debug to local syslog server"; $content['LN_GEN_POPUPMENUTIMEOUT'] = "Popupmenu Timeout in milli seconds"; $content['LN_ADMIN_SCRIPTTIMEOUT'] = "PHP Script Timeout in seconds"; +$content['LN_GEN_INJECTHTMLHEADER'] = "Inject this html code into the <head> area."; +$content['LN_GEN_INJECTBODYHEADER'] = "Inject this html code at the beginning of the <body> area."; +$content['LN_GEN_INJECTBODYFOOTER'] = "Inject this html code at the end <body> area."; // User Center $content['LN_USER_CENTER'] = "User Options"; diff --git a/src/templates/admin/admin_index.html b/src/templates/admin/admin_index.html index d90cbc9..1c16c45 100644 --- a/src/templates/admin/admin_index.html +++ b/src/templates/admin/admin_index.html @@ -108,7 +108,6 @@ - {LN_GEN_PREPENDTITLE} @@ -245,12 +244,25 @@ {LN_GEN_DEBUGUSERLOGIN} - + {LN_GEN_DEBUGTOSYSLOG} - + + + {LN_GEN_INJECTHTMLHEADER} + + + + {LN_GEN_INJECTBODYHEADER} + + + + {LN_GEN_INJECTBODYFOOTER} + + + diff --git a/src/templates/include_footer.html b/src/templates/include_footer.html index e1d9da3..73bfa0e 100644 --- a/src/templates/include_footer.html +++ b/src/templates/include_footer.html @@ -35,5 +35,6 @@ +{EXTRA_FOOTER} \ No newline at end of file diff --git a/src/templates/include_header.html b/src/templates/include_header.html index 74073b3..d6a5723 100644 --- a/src/templates/include_header.html +++ b/src/templates/include_header.html @@ -11,8 +11,10 @@ {EXTRA_JAVASCRIPT} + {EXTRA_HTMLHEAD} +{EXTRA_HEADER}