From 371e394d8663991ad0f4997c7d83093f1e4af8ba Mon Sep 17 00:00:00 2001 From: Geert Hauwaerts Date: Sat, 27 Mar 2010 22:20:57 +0000 Subject: [PATCH] - First step toward multi-tenancy (multi branding in 1 instance) - Created branding config. - Adjusted some defaults. git-svn-id: http://www.observium.org/svn/observer/trunk@1050 61d68cd4-352d-0410-923a-c4978735b2b8 --- config.php.default | 52 ++++++++++++++++++++++++++++----------- html/index.php | 33 +++++++++++++++++++++---- includes/defaults.inc.php | 1 + 3 files changed, 66 insertions(+), 20 deletions(-) diff --git a/config.php.default b/config.php.default index c3b941e97d..991bf7bd64 100755 --- a/config.php.default +++ b/config.php.default @@ -18,8 +18,6 @@ $config['observer_log'] = $config['install_dir'] . "/observer.log"; ### Default community $config['community'] = "public"; -$config['base_url'] = "http://observer2.as8681.net"; - ### Authentication model $config['auth_mechanism'] = "mysql"; # default, other options: ldap, http-auth #$config['http_auth_guest'] = "guest"; # remember to configure this user if you use http-auth @@ -42,25 +40,49 @@ $config['snmpget'] = "/usr/bin/snmpget"; $config['snmpbulkwalk'] = "/usr/bin/snmpbulkwalk"; $config['snmpset'] = "/usr/bin/snmpset"; +### Application information. Multi-Tenant aware. +$config['branding'] = array( + + # The default branding. + 'default' => array( + 'base_url' => "http://observer.example.com", + 'mydomain' => "example.com", + 'page_title' => "ObserverNMS", + 'title_image' => "images/observer-logo.gif", + 'stylesheet' => "css/styles.css", + 'mono_font' => "DejaVuSansMono", + 'header_color' => "#133A7B", + 'favicon' => "images/observer-icon.png", + 'page_gen' => 1, + 'footer' => "", + ), + + # Example branding for a specifc URL. + 'observer.branding.com' => array( + 'base_url' => "http://observer.branding.com", + 'mydomain' => "branding.com", + 'page_title' => "ObserverNMS", + 'title_image' => "images/observer-logo.gif", + 'stylesheet' => "css/styles.css", + 'mono_font' => "DejaVuSansMono", + 'header_color' => "#133A7B", + 'favicon' => "images/observer-icon.png", + 'page_gen' => 0, + 'footer' => "My Branding Company - Slogan!", + ), +); + +### E-Mail information. +$config['email_default'] = "observer@example.com"; +$config['email_from'] = "Observer "; +$config['email_headers'] = "From: " . $config['email_from'] . "\r\n"; + ### List of networks to allow scanning-based discovery $config['nets'] = array ("89.21.224.0/19", "212.9.12.0/24", "212.9.13.0/24"); -### Your company domain name and specifics -$config['mydomain'] = "jerseytelecom.com"; -$config['page_title'] = "JT Observer"; -$config['title_image'] = "images/observer-logo.gif"; -$config['stylesheet'] = "css/styles.css"; -$config['mono_font'] = "DejaVuSansMono"; -$config['header_color'] = "#133A7B"; -$config['favicon'] = "images/observer-icon.png"; - $config['page_refresh'] = "0"; ## Refresh the page every xx seconds $config['front_page'] = "pages/front/default.php"; -$config['email_default'] = "adama@as8681.net"; -$config['email_from'] = "Observer "; -$config['email_headers'] = "From: " . $config['email_from'] . "\r\n"; - $config['login_message'] = "Unauthorised access or use shall render the user liable to criminal and/or civil prosecution."; ### What should we warn about? diff --git a/html/index.php b/html/index.php index 668e3b5d19..e5d3135300 100755 --- a/html/index.php +++ b/html/index.php @@ -25,6 +25,22 @@ if($debug) { $week = time() - (7 * 24 * 60 * 60); $month = time() - (31 * 24 * 60 * 60); $year = time() - (365 * 24 * 60 * 60); + + + # Load the settings for Multi-Tenancy. + if (is_array($config['branding'])) { + if ($config['branding'][$_SERVER['SERVER_NAME']]) { + foreach ($config['branding'][$_SERVER['SERVER_NAME']] as $confitem => $confval) { + eval("\$config['" . $confitem . "'] = \$confval;"); + } + } else { + foreach ($config['branding']['default'] as $confitem => $confval) { + eval("\$config['" . $confitem . "'] = \$confval;"); + } + } + } else { + echo "Please check config.php.default and adjust your settings to reflect the new Multi-Tenancy configuration."; + } ?> @@ -142,17 +158,24 @@ function popUp(URL) { '; ?> diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 40ee46f63e..344b4f33f0 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -31,6 +31,7 @@ $config['frong_page'] = "default.php"; $config['page_title'] = "ObserverNMS"; $config['syslog_age'] = "1 month"; $config['timestamp_format'] = 'd-m-Y H:i:s'; +$config['page_gen'] = 1; ### Cosmetics