ona  18.1.1
About: OpenNetAdmin provides a database managed inventory of your IP network (with Web and CLI interface).
  Fossies Dox: ona-18.1.1.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

config.inc.php
Go to the documentation of this file.
1 <?php
2 
4 // This is the site configuration file. //
5 // //
6 // It is not intended that this file be edited. Any //
7 // user configurations should be in the local config or //
8 // in the database table sys_config //
9 // //
11 
12 // Used in PHP for include files and such
13 // Prefix.. each .php file should have already set $base and $include
14 // if it is written correctly. We assume that is the case.
17 
18 $onabase = dirname($base);
19 
20 
21 //$baseURL = preg_replace('+' . dirname($_SERVER['DOCUMENT_ROOT']) . '+', '', $base);
22 //$baseURL = preg_replace('+/$+', '', $baseURL);
23 
24 // Used in URL links
25 $baseURL=dirname($_SERVER['SCRIPT_NAME']); $baseURL = rtrim($baseURL, '/');
26 $images = "{$baseURL}/images";
27 
28 // help URL location
29 $_ENV['help_url'] = "http://opennetadmin.com/docs/";
30 
31 
32 // Get any query info
33 parse_str($_SERVER['QUERY_STRING']);
34 
35 
36 
37 // Many of these settings serve as defaults. They can be overridden by the settings in
38 // the table "sys_config"
39 $conf = array (
40  /* General Setup */
41  // Database Context
42  // For possible values see the $ona_contexts() array in the database_settings.inc.php file
43  "default_context" => 'DEFAULT',
44 
45  /* Used in header.php */
46  "title" => 'OpenNetAdmin :: ',
47  "meta_description" => '',
48  "meta_keywords" => '',
49  "html_headers" => '',
50 
51  /* Include Files: HTML */
52  "html_style_sheet" => "$include/html_style_sheet.inc.php",
53  "html_desktop" => "$include/html_desktop.inc.php",
54  "loading_icon" => "<br><center><img src=\"{$images}/loading.gif\"></center><br>",
55 
56  /* Include Files: Functions */
57  "inc_functions" => "$include/functions_general.inc.php",
58  "inc_functions_gui" => "$include/functions_gui.inc.php",
59  "inc_functions_db" => "$include/functions_db.inc.php",
60  "inc_functions_auth" => "$include/functions_auth.inc.php",
61  "inc_db_sessions" => "$include/adodb_sessions.inc.php",
62  "inc_adodb" => "$include/adodb/adodb.inc.php",
63  "inc_adodb_xml" => "$include/adodb/adodb-xmlschema03.inc.php",
64  "inc_xajax_stuff" => "$include/xajax_setup.inc.php",
65  "inc_diff" => "$include/DifferenceEngine.php",
66 
67  /* Settings for dcm.pl */
68  "dcm_module_dir" => "$base/modules",
69  "plugin_dir" => "$base/local/plugins",
70 
71  /* Defaults for some user definable options normally in sys_config table */
72  "debug" => "2",
73  "syslog" => "0",
74  "stdout" => "0",
75  "log_to_db" => "0",
76  "logfile" => "/var/log/ona.log",
77 
78  /* The output charset to be used in htmlentities() and htmlspecialchars() filtering */
79  "charset" => "utf8",
80  "php_charset" => "UTF-8",
81 
82  // enable the setting of the database character set using the "set name 'charset'" SQL command
83  // This should work for mysql and postgres but may not work for Oracle.
84  // it will be set to the value in 'charset' above.
85  "set_db_charset" => TRUE,
86 );
87 
88 
89 // Read in the version file to our conf variable
90 // It must have a v<majornum>.<minornum>, no number padding, to match the check version code.
91 if (file_exists($base.'/../VERSION')) { $conf['version'] = trim(file_get_contents($base.'/../VERSION')); }
92 
93 // The $self array is used to store globally available temporary data.
94 // Think of it as a cache or an easy way to pass data around ;)
95 // I've tried to define the entries that are commonly used:
96 $self = array (
97  // Error messages will often get stored in here
98  "error" => "",
99 
100  // All sorts of things get cached in here to speed things up
101  "cache" => array(),
102 
103  // Get's automatically set to 1 if we're using HTTPS/SSL
104  "secure" => 0,
105 );
106 // If the server port is 443 then this is a secure page
107 // This is basically used to put a padlock icon on secure pages.
108 if ($_SERVER['SERVER_PORT'] == 443) { $self['secure'] = 1; }
109 
110 
111 
112 
114 // STYLE SHEET STUFF //
116 
117 
118 // Colors
119 $color['bg'] = '#FFFFFF';
120 $color['content_bg'] = '#FFFFFF';
121 $color['bar_bg'] = '#D3DBFF';
122 $color['border'] = '#555555'; //#1A1A1A
123 $color['form_bg'] = '#FFEFB6';
124 
125 $color['font_default'] = '#000000';
126 $color['font_title'] = '#4E4E4E';
127 $color['font_subtitle'] = '#5A5A5A';
128 $color['font_error'] = '#E35D5D';
129 
130 $color['link'] = '#6B7DD1';
131 $color['vlink'] = '#6B7DD1';
132 $color['alink'] = '#6B7DD1';
133 $color['link_nav'] = '#0048FF'; // was '#7E8CD7';
134 $color['link_act'] = '#FF8000'; // was '#EB8F1F';
135 $color['link_domain'] = 'green'; // was '#5BA65B';
136 
137 $color['button_normal'] = '#FFFFFF';
138 $color['button_hover'] = '#E0E0E0';
139 
140 // Define some colors for the subnet map:
141 $color['bgcolor_map_host'] = '#BFD2FF';
142 $color['bgcolor_map_subnet'] = '#CCBFFF';
143 $color['bgcolor_map_selected'] = '#FBFFB6';
144 $color['bgcolor_map_empty'] = '#FFFFFF';
145 
146 // Much of this configuration is required here since
147 // a lot of it's used in xajax calls before a web page is created.
148 $color['menu_bar_bg'] = '#F3F1FF';
149 $color['menu_header_bg'] = '#FFFFFF';
150 $color['menu_item_bg'] = '#F3F1FF';
151 $color['menu_header_text'] = '#436976';
152 $color['menu_item_text'] = '#436976';
153 $color['menu_item_selected_bg']= '#B1C6E3';
154 $color['menu_header_bg'] = '#B1C6E3';
155 
156 
157 // Style variables (used in PHP in various places)
158 $style['font-family'] = "Arial, Sans-Serif";
159 $style['borderT'] = "border-top: 1px solid {$color['border']};";
160 $style['borderB'] = "border-bottom: 1px solid {$color['border']};";
161 $style['borderL'] = "border-left: 1px solid {$color['border']};";
162 $style['borderR'] = "border-right: 1px solid {$color['border']};";
163 
164 // Include the localized configuration settings
165 // MP: this may not be needed now that "user" configs are in the database
166 @include("{$base}/local/config/config.inc.php");
167 
168 // Include the basic system functions
169 // any $conf settings used in this "require" should not be user adjusted in the sys_config table
170 require_once($conf['inc_functions']);
171 
172 // Include the basic database functions
173 require_once($conf['inc_functions_db']);
174 
175 // Include the localized Database settings
176 $dbconffile = "{$base}/local/config/database_settings.inc.php";
177 if (file_exists($dbconffile)) {
178  if (substr(exec("php -l $dbconffile"), 0, 28) == "No syntax errors detected in") {
179  @include($dbconffile);
180  } else {
181  echo "Syntax error in your DB config file: {$dbconffile}<br>Please check that it contains a valid PHP formatted array, or check that you have the php cli tools installed.<br>You can perform this check maually using the command 'php -l {$dbconffile}'.";
182  exit;
183  }
184 } else {
185  require_once($base.'/../install/install.php');
187 }
188 
189 // Check to see if the run_install file exists.
190 // If it does, run the install process.
191 if (file_exists($base.'/local/config/run_install') or @$runinstaller or @$install_submit == 'Y') {
192  // Process the install script
193  require_once($base.'/../install/install.php');
194  exit;
195 }
196 
197 // Set multibyte encoding to UTF-8
198 if (@function_exists('mb_internal_encoding')) {
199  mb_internal_encoding("UTF-8");
200 } else {
201  printmsg("INFO => Missing 'mb_internal_encoding' function. Please install PHP 'mbstring' functions for proper UTF-8 encoding.", 0);
202 }
203 
204 // If we dont have a ona_context set in the cookie, lets set a cookie with the default context
205 if (!isset($_COOKIE['ona_context_name'])) { $_COOKIE['ona_context_name'] = $conf['default_context']; setcookie("ona_context_name", $conf['default_context']); }
206 
207 // (Re)Connect to the DB now.
208 global $onadb;
209 $onadb = db_pconnect('', $_COOKIE['ona_context_name']);
210 
211 // Load the actual user config from the database table sys_config
212 // These will override any of the defaults set above
213 list($status, $rows, $records) = db_get_records($onadb, 'sys_config', 'name like "%"', 'name');
214 foreach ($records as $record) {
215  printmsg("INFO => Loaded config item from database: {$record['name']}=''{$record['value']}''",5);
216  $conf[$record['name']] = $record['value'];
217 }
218 
219 // Include functions that replace the default session handler with one that uses MySQL as a backend
220 require_once($conf['inc_db_sessions']);
221 
222 // Include the GUI functions
223 require_once($conf['inc_functions_gui']);
224 
225 // Include the AUTH functions
226 require_once($conf['inc_functions_auth']);
227 
228 // Start the session handler (this calls a function defined in functions_general)
229 startSession();
230 
231 // Set session inactivity threshold
232 ini_set("session.gc_maxlifetime", $conf['cookie_life']);
233 
234 // if search_results_per_page is in the session, set the $conf variable to it. this fixes the /rows command
235 if (isset($_SESSION['search_results_per_page'])) $conf['search_results_per_page'] = $_SESSION['search_results_per_page'];
236 
237 // Set up our page to https if requested for our URL links
238 if (@($conf['force_https'] == 1) or ($_SERVER['SERVER_PORT'] == 443)) {
239  $https = "https://{$_SERVER['SERVER_NAME']}";
240 }
241 else {
242  if ($_SERVER['SERVER_PORT'] != 80) {
243  $https = "http://{$_SERVER['SERVER_NAME']}:{$_SERVER['SERVER_PORT']}";
244  } else {
245  $https = "http://{$_SERVER['SERVER_NAME']}";
246  }
247 }
248 
249 // DON'T put whitespace at the beginning or end of included files!!!
250 ?>
$base
$base
Definition: config.inc.php:15
$include
$include
Definition: config.inc.php:16
$record
$record['display_name']
Definition: app_advanced_search.inc.php:12
exit
exit
Definition: config.inc.php:186
db_get_records
db_get_records($dbh=0, $table="", $where="", $order="", $rows=-1, $offset=-1)
Definition: functions_db.inc.php:891
$status
$status
Definition: install.php:12
$_ENV
$_ENV['help_url']
Definition: config.inc.php:29
$onadb
if(!isset($_COOKIE['ona_context_name'])) global $onadb
Definition: config.inc.php:205
db_pconnect
db_pconnect($type, $context_name)
Definition: functions_db.inc.php:90
$baseURL
$baseURL
Definition: config.inc.php:25
printmsg
if(6<=$conf['debug']) printmsg($msg="", $debugLevel=0)
Definition: functions_general.inc.php:48
$images
$images
Definition: config.inc.php:26
$_SESSION
$_SESSION['ona']['auth']
Definition: login.php:14
$style
$style['font-family']
Definition: config.inc.php:158
$self
if(file_exists($base.'/../VERSION')) $self
Definition: config.inc.php:96
$conf
$conf
Definition: config.inc.php:39
$onabase
$onabase
Definition: config.inc.php:18
$color
if($_SERVER['SERVER_PORT']==443) $color['bg']
Definition: config.inc.php:119
startSession
startSession()
Definition: functions_general.inc.php:1221
$dbconffile
$dbconffile
Definition: config.inc.php:176