1<?php
2
3/**
4 * Observium
5 *
6 *   This file is part of Observium.
7 *
8 * @package    observium
9 * @subpackage definitions
10 * @copyright  (C) 2006-2013 Adam Armstrong, (C) 2013-2019 Observium Limited
11 *
12 */
13
14/////////////////////////////////////////////////////////
15//  NO CHANGES TO THIS FILE, IT IS NOT USER-EDITABLE   //
16/////////////////////////////////////////////////////////
17//               YES, THAT MEANS YOU                   //
18/////////////////////////////////////////////////////////
19
20// Always set locale to EN, because we use parsing strings
21setlocale(LC_ALL, 'C');
22putenv('LC_ALL=C');
23// Use default charset UTF-8
24ini_set('default_charset', 'UTF-8');
25
26// Flags (mostly used in snmp and network functions, only 2^bit)
27// Bits 0-3 common flags
28define('OBS_QUOTES_STRIP',         1); // Strip ALL quotes from string
29define('OBS_QUOTES_TRIM',          2); // Trim quotes only from begin/end of string
30define('OBS_ESCAPE',               4); // Escape strings or output
31define('OBS_DECODE_UTF8',          8); // Decode ascii coded chars in string as correct UTF-8
32
33// Bits 4-15 snmp flags
34define('OBS_SNMP_NUMERIC',        16); // Use numeric OIDs  (-On)
35define('OBS_SNMP_NUMERIC_INDEX',  32); // Use numeric index (-Ob)
36define('OBS_SNMP_CONCAT',         64); // Concatenate multiline snmp variable (newline chars removed)
37define('OBS_SNMP_ENUM',          128); // Don't enumerate SNMP values
38define('OBS_SNMP_HEX',           256); // Force HEX output (-Ox) and disable use of DISPLAY-HINT information when assigning values (-Ih).
39define('OBS_SNMP_TABLE',         512); // Force Program Like output (-OX)
40define('OBS_SNMP_DISPLAY_HINT', 1024); // Disables the use of DISPLAY-HINT information when assigning values (-Ih). This would then require providing the raw value.
41define('OBS_SNMP_TIMETICKS',    2048); // Force TimeTicks values as raw numbers (-Ot)
42define('OBS_SNMP_ASCII',        4096); // Force all string values as ASCII strings
43#define('OBS_',                 8192); // Reserved
44#define('OBS_',                16384); // Reserved
45#define('OBS_',                32768); // Reserved
46define('OBS_SNMP_ALL',               OBS_QUOTES_TRIM | OBS_QUOTES_STRIP);    // Set of common snmp options
47define('OBS_SNMP_ALL_MULTILINE',     OBS_QUOTES_TRIM | OBS_SNMP_CONCAT);     // Set of common snmp options with concatenate multiline snmp variable
48define('OBS_SNMP_ALL_ASCII',         OBS_QUOTES_TRIM | OBS_SNMP_ASCII);      // Set of common snmp options with forcing string values as ASCII strings
49define('OBS_SNMP_ALL_HEX',           OBS_SNMP_ALL | OBS_SNMP_HEX);           // Set of common snmp options forcing HEX output
50define('OBS_SNMP_ALL_ENUM',          OBS_SNMP_ALL | OBS_SNMP_ENUM);          // Set of common snmp options without enumerating values
51define('OBS_SNMP_ALL_NUMERIC',       OBS_SNMP_ALL | OBS_SNMP_NUMERIC);       // Set of common snmp options with numeric OIDs
52define('OBS_SNMP_ALL_NUMERIC_INDEX', OBS_SNMP_ALL | OBS_SNMP_NUMERIC_INDEX); // Set of common snmp options with numeric indexes
53define('OBS_SNMP_ALL_TABLE',         OBS_SNMP_ALL | OBS_SNMP_TABLE);         // Set of common snmp options with Program Like (help for MAC parse in indexes)
54define('OBS_SNMP_ALL_TIMETICKS',     OBS_SNMP_ALL | OBS_SNMP_TIMETICKS);     // Set of common snmp options with TimeTicks as raw numbers
55
56// Bits 16-19 network flags
57define('OBS_DNS_A',            65536); // Use only IPv4 dns queries
58define('OBS_DNS_AAAA',        131072); // Use only IPv6 dns queries
59define('OBS_DNS_ALL',          OBS_DNS_A | OBS_DNS_AAAA); // Use both IPv4/IPv6 dns queries
60define('OBS_PING_SKIP',       262144); // Skip device isPingable checks
61#define('OBS_',               524288); // Reserved
62
63// Permission levels flags
64define('OBS_PERMIT_ACCESS',        1); // Can access (ie: logon)
65define('OBS_PERMIT_READ',          2); // Can read basic data
66define('OBS_PERMIT_SECURE',        4); // Can read secure data
67define('OBS_PERMIT_EDIT',          8); // Can edit
68define('OBS_PERMIT_ADMIN',        16); // Can add/remove
69define('OBS_PERMIT_ALL', OBS_PERMIT_ACCESS | OBS_PERMIT_READ | OBS_PERMIT_SECURE | OBS_PERMIT_EDIT | OBS_PERMIT_ADMIN); // Permit all
70
71// Configuration view levels
72define('OBS_CONFIG_BASIC',          1); // 0001: Basic view, 0001
73define('OBS_CONFIG_ADVANCED',       3); // 0011: Advanced view, includes basic
74define('OBS_CONFIG_EXPERT',         7); // 0111: Expert view, includes advanced and basic
75
76// Common regex patterns
77define('OBS_PATTERN_START', '%(?:^|[\s\"\(=])');    // Begining of any pattern, matched string can start from newline, space, double quote, opening parenthesis, equal sign
78define('OBS_PATTERN_END',   '(?:[\s\"\),]|\:\ |$)%i'); // End of any pattern, matched string can ended with endline, space, double quote, closing parenthesis, comma
79define('OBS_PATTERN_END_U', OBS_PATTERN_END . 'u'); // ++Unicode
80
81// IPv4 string in group \1 or 'ipv4'
82define('OBS_PATTERN_IPV4',      '(?<ipv4>(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9]))');
83define('OBS_PATTERN_IPV4_FULL', OBS_PATTERN_START . OBS_PATTERN_IPV4 . OBS_PATTERN_END);
84// IPv4 netmask string in group \1 or 'ipv4_mask'
85define('OBS_PATTERN_IPV4_MASK',  '(?<ipv4_mask>(?:0|128|192|224|240|248|252|254)\.0\.0\.0|255\.(?:0|128|192|224|240|248|252|254)\.0\.0|255\.255\.(?:0|128|192|224|240|248|252|254)\.0|255\.255\.255\.(?:0|128|192|224|240|248|252|254|255))');
86// IPv4 inverse netmask string in group \1 or 'ipv4_inverse_mask'
87define('OBS_PATTERN_IPV4_INVERSE_MASK', '(?<ipv4_inverse_mask>(?:255|127|63|31|15|7|3|1|0)\.255\.255\.255|0\.(?:255|127|63|31|15|7|3|1|0)\.255\.255|0\.0\.(?:255|127|63|31|15|7|3|1|0)\.255|0\.0\.0\.(?:255|127|63|31|15|7|3|1|0))');
88// IPv4 network string in group \1 or 'ipv4_network', additionally 'ipv4', 'ipv4_prefix' or 'ipv4_mask' or 'ipv4_inverse_mask'
89define('OBS_PATTERN_IPV4_NET',  '(?<ipv4_network>' . OBS_PATTERN_IPV4 . '\/(?:(?<ipv4_prefix>3[0-2]|[1-2][0-9]|[0-9])|' . OBS_PATTERN_IPV4_MASK . '|' . OBS_PATTERN_IPV4_INVERSE_MASK . '))');
90define('OBS_PATTERN_IPV4_NET_FULL', OBS_PATTERN_START . OBS_PATTERN_IPV4_NET . OBS_PATTERN_END);
91
92// IPv6 string in group \1 or 'ipv6'
93define('OBS_PATTERN_IPV6',      '(?<ipv6>(?:(?:(?:[a-f\d]{1,4}:){5}[a-f\d]{1,4}|(?:[a-f\d]{1,4}:){4}:[a-f\d]{1,4}|(?:[a-f\d]{1,4}:){3}(?::[a-f\d]{1,4}){1,2}|(?:[a-f\d]{1,4}:){2}(?::[a-f\d]{1,4}){1,3}|[a-f\d]{1,4}:(?::[a-f\d]{1,4}){1,4}|(?:[a-f\d]{1,4}:){1,5}|:(?::[a-f\d]{1,4}){1,5}|:):(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])|(?:[a-f\d]{1,4}:){7}[a-f\d]{1,4}|(?:[a-f\d]{1,4}:){6}:[a-f\d]{1,4}|(?:[a-f\d]{1,4}:){5}(?::[a-f\d]{1,4}){1,2}|(?:[a-f\d]{1,4}:){4}(?::[a-f\d]{1,4}){1,3}|(?:[a-f\d]{1,4}:){3}(?::[a-f\d]{1,4}){1,4}|(?:[a-f\d]{1,4}:){2}(?::[a-f\d]{1,4}){1,5}|[a-f\d]{1,4}:(?::[a-f\d]{1,4}){1,6}|(?:[a-f\d]{1,4}:){1,7}:|:(?::[a-f\d]{1,4}){1,7}|::))');
94define('OBS_PATTERN_IPV6_FULL', OBS_PATTERN_START . OBS_PATTERN_IPV6 . OBS_PATTERN_END);
95// IPv6 network string in group \1 or 'ipv6_network', additionally 'ipv6', 'ipv6_prefix'
96define('OBS_PATTERN_IPV6_NET',  '(?<ipv6_network>' . OBS_PATTERN_IPV6 . '\/(?<ipv6_prefix>12[0-8]|1[0-1][0-9]|[0-9]{1,2}))');
97define('OBS_PATTERN_IPV6_NET_FULL', OBS_PATTERN_START . OBS_PATTERN_IPV6_NET . OBS_PATTERN_END);
98
99// IPv4 or IPv6 string in group \1 or 'ip'
100define('OBS_PATTERN_IP',        '(?<ip>' . OBS_PATTERN_IPV4 . '|' . OBS_PATTERN_IPV6 . ')');
101define('OBS_PATTERN_IP_FULL',   OBS_PATTERN_START . OBS_PATTERN_IP . OBS_PATTERN_END);
102
103// MAC string in group \1 or 'mac'
104define('OBS_PATTERN_MAC',       '(?<mac>(?:[a-f\d]{1,2}(?:\:[a-f\d]{1,2}){5}|[a-f\d]{2}(?:\-[a-f\d]{2}){5}|[a-f\d]{2}(?:\ [a-f\d]{2}){5}|[a-f\d]{4}(?:\.[a-f\d]{4}){2}|(?:0x)?[a-f\d]{12}))');
105define('OBS_PATTERN_MAC_FULL',  OBS_PATTERN_START . OBS_PATTERN_MAC . OBS_PATTERN_END);
106
107// FQDN string in group \1 or 'domain'
108//define('OBS_PATTERN_FQDN',      '(?<domain>(?:(?:(?:xn--)?[a-z0-9_]+(?:\-[a-z0-9_]+)*\.)+(?:[a-z]{2,}|xn--[a-z0-9]{4,}))|localhost)'); // Alternative, less correct
109//define('OBS_PATTERN_FQDN',      '(?<domain>(?:(?:(?=[a-z0-9\-_]{1,63}\.)(?:xn--)?[a-z0-9_]+(?:\-[a-z0-9_]+)*\.)+(?:[a-z]{2,63}|xn--[a-z0-9]{4,}))|localhost)'); // Punicode, Non-unicode
110define('OBS_PATTERN_FQDN',      '(?<domain>(?:(?:(?=[\p{L}\d\-_]{1,63}\.)(?:xn--)?[\p{L}\d_]+(?:\-[\p{L}\d_]+)*\.)+(?:[\p{L}]{2,63}|xn--[a-z\d]{4,}))|localhost)');
111define('OBS_PATTERN_FQDN_FULL', OBS_PATTERN_START . OBS_PATTERN_FQDN . OBS_PATTERN_END_U);
112
113// pattern for email only (without Name, ie: user@domain.name)
114// Email string in group \1 or 'email', additional groups: 'user', 'domain'
115define('OBS_PATTERN_EMAIL',     '(?<email>(?<user>[\p{L}\d\.\'_\%\+\-]{1,63}|\"[\p{L}\d\.\'_\%\+\-\ \\\\]{1,63}\")@' . OBS_PATTERN_FQDN . ')');
116define('OBS_PATTERN_EMAIL_FULL', OBS_PATTERN_START . OBS_PATTERN_EMAIL . OBS_PATTERN_END_U);
117// pattern for Full email with Name (ie: "My Name" <user@domain.name>), but name is optional
118// Long Email string in group \1 or 'email_long', additional groups: 'name', 'email', 'user', 'domain'
119define('OBS_PATTERN_EMAIL_LONG', '(?<email_long>(?<name>[\"\'][\p{L}\d\.\'_\%\+\-\ \\\\]+[\"\']|(?:[\p{L}\d\.\'_\%\+\-]+\ )*[\p{L}\d\.\'_\%\+\-]+)?\s*<' . OBS_PATTERN_EMAIL . '>)');
120define('OBS_PATTERN_EMAIL_LONG_FULL', OBS_PATTERN_START . OBS_PATTERN_EMAIL_LONG . OBS_PATTERN_END_U);
121
122//define('OBS_PATTERN_URL',       '(?<url>(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@|\d{1,3}(?:\.\d{1,3}){3}|(?:(?:[a-z\d\x{00a1}-\x{ffff}]+-?)*[a-z\d\x{00a1}-\x{ffff}]+)(?:\.(?:[a-z\d\x{00a1}-\x{ffff}]+-?)*[a-z\d\x{00a1}-\x{ffff}]+)*(?:\.[a-z\x{00a1}-\x{ffff}]{2,6}))(?::\d+)?(?:[^\s]*)?)');
123//define('OBS_PATTERN_URL_FULL',  OBS_PATTERN_START . OBS_PATTERN_URL . OBS_PATTERN_END_U);
124
125// Json flags
126define('OBS_JSON_BIGINT_AS_STRING', version_compare(PHP_VERSION, '5.4.0', '>=') && !(defined('JSON_C_VERSION') && PHP_INT_SIZE > 4)); // Check if BIGINT supported
127$json_encode = defined('JSON_UNESCAPED_UNICODE') ? JSON_UNESCAPED_UNICODE : 0;
128$json_encode = defined('JSON_PRESERVE_ZERO_FRACTION') ? $json_encode | JSON_PRESERVE_ZERO_FRACTION : $json_encode;
129$json_decode = OBS_JSON_BIGINT_AS_STRING ? JSON_BIGINT_AS_STRING : 0;
130define('OBS_JSON_ENCODE', $json_encode);
131define('OBS_JSON_DECODE', $json_decode);
132unset($json_encode, $json_decode);
133
134// Detect encrypt module
135if (PHP_VERSION_ID >= 70200 && check_extension_exists('sodium'))
136{
137  // Libsodium is part of php since 7.2
138  define('OBS_ENCRYPT', TRUE);
139  define('OBS_ENCRYPT_MODULE', 'sodium');
140}
141else if (check_extension_exists('mcrypt'))
142{
143  // Older php can use mcrypt (not supported since php 7.2)
144  define('OBS_ENCRYPT', TRUE);
145  define('OBS_ENCRYPT_MODULE', 'mcrypt');
146} else {
147  // No encrypt modules found
148  define('OBS_ENCRYPT', FALSE);
149}
150//var_dump(OBS_ENCRYPT);
151
152// Always use "enhanced algorithm" for rounding float numbers in JSON/serialize
153ini_set('serialize_precision', -1);
154
155// Use more accurate math
156if (function_exists('bcadd'))
157{
158  // BC Math
159  define('OBS_MATH', 'bc');
160}
161elseif (defined('GMP_VERSION'))
162{
163  // GMP (gmp have troubles with convert float numbers)
164  define('OBS_MATH', 'gmp');
165} else {
166  // Fallback to php math
167  define('OBS_MATH', 'php');
168}
169//var_dump(OBS_MATH);
170
171// Minimum supported versions
172define('OBS_MIN_PHP_VERSION',   '5.6.26'); // PHP
173define('OBS_MIN_MYSQL_VERSION', '5.1.59'); // MySQL, really 5.6+
174
175// Set QUIET
176define('OBS_QUIET', isset($options['q']));
177
178// Set DEBUG
179if (isset($options['d']))
180{
181  // CLI
182  echo("DEBUG!\n");
183  define('OBS_DEBUG', count($options['d'])); // -d == 1, -dd == 2..
184  ini_set('display_errors', 1);
185  ini_set('display_startup_errors', 1);
186  if (OBS_DEBUG > 1)
187  {
188    //ini_set('error_reporting', E_ALL ^ E_NOTICE); // FIXME, too many warnings ;)
189    ini_set('error_reporting', E_ALL ^ E_NOTICE ^ E_WARNING);
190  } else {
191    ini_set('error_reporting', E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR); // Only various errors
192  }
193}
194else if ($debug_web_requested = (isset($_REQUEST['debug']) && $_REQUEST['debug']) ||
195                                (isset($_SERVER['PATH_INFO']) && strpos($_SERVER['PATH_INFO'], 'debug')) ||
196                                (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], 'debug')))
197{
198  // WEB
199
200  // Note, for security reasons set OBS_DEBUG constant in WUI moved to auth module
201  if (isset($config['web_debug_unprivileged']) && $config['web_debug_unprivileged'])
202  {
203    define('OBS_DEBUG', 1);
204
205    ini_set('display_errors', 1);
206    ini_set('display_startup_errors', 1);
207    //ini_set('error_reporting', E_ALL ^ E_NOTICE);
208    ini_set('error_reporting', E_ALL ^ E_NOTICE ^ E_WARNING);
209  } // else not set anything before auth
210
211} else {
212  define('OBS_DEBUG', 0);
213  ini_set('display_errors', 0);
214  ini_set('display_startup_errors', 0);
215  //ini_set('error_reporting', 0); // Use default php config
216}
217ini_set('log_errors', 1);
218//$debug = OBS_DEBUG; // DEBUG. Temporary fallback to old variable
219
220//
221// Unit test not used sql connect and does not include includes/sql-config.inc.php
222if (defined('__PHPUNIT_PHAR__'))
223{
224  // Base dir, if it's not set in config
225  if (!isset($config['install_dir']))
226  {
227    $config['install_dir'] = realpath(dirname(__FILE__) . '/..');
228  }
229  if (!defined('OBS_DB_SKIP'))
230  {
231    define('OBS_DB_SKIP', TRUE);
232  }
233  // In phpunit, autoload not work
234  set_include_path(dirname(__FILE__) . "/../libs/pear" . PATH_SEPARATOR . get_include_path());
235  require("Net/IPv4.php");
236  require("Net/IPv6.php");
237  require("Console/Color2.php");
238  //print_warning("WARNING. In PHP Unit tests can skip MySQL connect. But If you test mysql functions, check your configs.");
239} else {
240  define('OBS_DB_SKIP', FALSE);
241}
242
243// Set default Include path
244set_include_path($config['install_dir'] . "/libs/pear" . PATH_SEPARATOR . // Still required Pear path
245                 $config['install_dir'] . "/libs"      . PATH_SEPARATOR .
246                 get_include_path());
247
248// Load random_compat (for PHP 5.x)
249require_once("random_compat/random.php");
250
251// Load hash-compat (for < PHP 5.6)
252require_once("hash-compat/hash_equals.php");
253
254// Debug nicer functions
255if (OBS_DEBUG || strlen($_SERVER['REMOTE_ADDR']))
256{
257  // Nicer for print_vars(), for WUI loaded always,
258  // Required php tokenizer extension!
259  if (!function_exists('rt') && function_exists('token_get_all') &&
260      is_file($config['install_dir']."/libs/ref.inc.php"))
261  {
262    include($config['install_dir']."/libs/ref.inc.php");
263  }
264}
265
266// Community specific definition
267if (is_file($config['install_dir'].'/includes/definitions/definitions.dat'))
268{
269  //var_dump($config);
270  $config_tmp = file_get_contents($config['install_dir'].'/includes/definitions/definitions.dat');
271  $config_tmp = gzuncompress($config_tmp);
272  $config_tmp = unserialize($config_tmp);
273  //var_dump($config_tmp);
274  if (is_array($config_tmp) && isset($config_tmp['os'])) // Simple check for passed correct data
275  {
276    $config = array_merge($config, $config_tmp);
277  }
278  unset($config_tmp);
279}
280
281$definition_files = array('os',           // OS definitions
282                          'wui',          // Web UI specific definitions
283                          'graphtypes',   // Graph Type definitions
284                          'rrdtypes',     // RRD Type definitions
285                          'entities',     // Entity type definitions
286                          'rewrites',     // Rewriting array definitions
287                          'mibs',         // MIB definitions
288                          'models',       // Hardware model definitions (leave it after os and rewrites)
289                          'vendors',      // Vendor/manufacturer definitions
290                          'geo',          // Geolocation api definitions
291                          'vm',           // Virtual Machine definitions
292                          'transports',   // Alerting transport definitions
293                          'apps',         // Apps system definitions
294                          );
295
296foreach ($definition_files as $file)
297{
298  $file = $config['install_dir'].'/includes/definitions/'.$file.'.inc.php';
299  if (is_file($file))
300  {
301    include($file);
302  }
303}
304
305unset($definition_files, $file); // Clean
306
307// Alert Graphs
308## FIXME - this is ugly
309## Merge it in to entities, since that's what it is!
310
311$config['alert_graphs']['port']['ifInOctets_rate']       = array('type' => 'port_bits', 'id' => '@port_id');
312$config['alert_graphs']['port']['ifOutOctets_rate']      = array('type' => 'port_bits', 'id' => '@port_id');
313$config['alert_graphs']['port']['ifInOctets_perc']       = array('type' => 'port_percent', 'id' => '@port_id');
314$config['alert_graphs']['port']['ifOutOctets_perc']      = array('type' => 'port_percent', 'id' => '@port_id');
315$config['alert_graphs']['mempool']['mempool_perc']       = array('type' => 'mempool_usage', 'id' => '@mempool_id');
316$config['alert_graphs']['sensor']['sensor_value']        = array('type' => 'sensor_graph', 'id' => '@sensor_id');
317$config['alert_graphs']['sensor']['sensor_event']        = array('type' => 'sensor_graph', 'id' => '@sensor_id');
318$config['alert_graphs']['status']['status_event']        = array('type' => 'status_graph', 'id' => '@status_id');
319$config['alert_graphs']['status']['status_state']        = array('type' => 'status_graph', 'id' => '@status_id');
320
321$config['alert_graphs']['processor']['processor_usage']  = array('type' => 'processor_usage', 'id' => '@processor_id');
322$config['alert_graphs']['storage']['storage_perc']  = array('type' => 'storage_usage', 'id' => '@storage_id');
323
324// IP types
325
326$config['ip_types']['unspecified']    = array('networks' => array('0.0.0.0', '::/128'),
327                                              'name'     => 'Unspecified', 'subtext' => 'Example: ::/128, 0.0.0.0',
328                                              'descr'    => 'This address may only be used as a source address by an initialising host before it has learned its own address. Example: ::/128, 0.0.0.0');
329$config['ip_types']['loopback']       = array('networks' => array('127.0.0.0/8', '::1/128'),
330                                              'name'     => 'Loopback', 'subtext' => 'Example: ::1/128, 127.0.0.1',
331                                              'descr'    => 'This address is used when a host talks to itself. Example: ::1/128, 127.0.0.1');
332$config['ip_types']['private']        = array('networks' => array('10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', 'fc00::/7'),
333                                              'name'     => 'Private Local Addresses', 'subtext' => 'Example: fdf8:f53b:82e4::53, 192.168.0.1',
334                                              'descr'    => 'These addresses are reserved for local use in home and enterprise environments and are not public address space. Example: fdf8:f53b:82e4::53, 192.168.0.1');
335$config['ip_types']['multicast']      = array('networks' => array('224.0.0.0/4', 'ff00::/8'),
336                                              'name'     => 'Multicast', 'subtext' => 'Example: ff01:0:0:0:0:0:0:2, 224.0.0.1',
337                                              'descr'    => 'These addresses are used to identify multicast groups. Example: ff01:0:0:0:0:0:0:2, 224.0.0.1');
338$config['ip_types']['link-local']     = array('networks' => array('169.254.0.0/16', 'fe80::/10'),
339                                              'name'     => 'Link-Local Addresses', 'subtext' => 'Example: fe80::200:5aee:feaa:20a2, 169.254.3.1',
340                                              'descr'    => 'These addresses are used on a single link or a non-routed common access network, such as an Ethernet LAN. Example: fe80::200:5aee:feaa:20a2, 169.254.3.1');
341$config['ip_types']['ipv4mapped']     = array('networks' => array('::ffff/96'),
342                                              'name'     => 'IPv6 IPv4-Mapped', 'subtext' => '::ffff:192.0.2.47',
343                                              'descr'    => 'These addresses are used to embed IPv4 addresses in an IPv6 address. Example: ::ffff:192.0.2.47');
344$config['ip_types']['6to4']           = array('networks' => array('192.88.99.0/24', '2002::/16'),
345                                              'name'     => 'IPv6 6to4', 'subtext' => 'Example: 2002:cb0a:3cdd:1::1, 192.88.99.1',
346                                              'descr'    => 'A 6to4 gateway adds its IPv4 address to this 2002::/16, creating a unique /48 prefix. Example: 2002:cb0a:3cdd:1::1, 192.88.99.1');
347$config['ip_types']['documentation']  = array('networks' => array('192.0.2.0/24', '198.51.100.0/24', '203.0.113.0/24', '2001:db8::/32'),
348                                              'name'     => 'Documentation', 'subtext' => 'Example: 2001:db8:8:4::2, 203.0.113.1',
349                                              'descr'    => 'These addresses are used in examples and documentation. Example: 2001:db8:8:4::2, 203.0.113.1');
350$config['ip_types']['teredo']         = array('networks' => array('2001:0000::/32'),
351                                              'name'     => 'IPv6 Teredo', 'subtext' => 'Example: 2001:0000:4136:e378:8000:63bf:3fff:fdd2',
352                                              'descr'    => 'This is a mapped address allowing IPv6 tunneling through IPv4 NATs. The address is formed using the Teredo prefix, the servers unique IPv4 address, flags describing the type of NAT, the obfuscated client port and the client IPv4 address, which is probably a private address. Example: 2001:0000:4136:e378:8000:63bf:3fff:fdd2');
353$config['ip_types']['benchmark']      = array('networks' => array('198.18.0.0/15', '2001:0002::/48'),
354                                              'name'     => 'Benchmarking', 'subtext' => 'Example: 2001:0002:6c::430, 198.18.0.1',
355                                              'descr'    => 'These addresses are reserved for use in documentation. Example: 2001:0002:6c::430, 198.18.0.1');
356$config['ip_types']['orchid']         = array('networks' => array('2001:0010::/28', '2001:0020::/28'),
357                                              'name'     => 'IPv6 Orchid', 'subtext' => 'Example: 2001:10:240:ab::a',
358                                              'descr'    => 'These addresses are used for a fixed-term experiment. Example: 2001:10:240:ab::a');
359$config['ip_types']['reserved']       = array(//'networks' => array(),
360                                              'name'     => 'Reserved',
361                                              'descr'    => 'Reserved address space');
362$config['ip_types']['broadcast']      = array(//'networks' => array(),
363                                              'name'     => 'IPv4 Broadcast', 'subtext' => 'Example: 255.255.255.255',
364                                              'descr'    => 'IPv4 broadcast address. Example: 255.255.255.255');
365$config['ip_types']['anycast']        = array(//'networks' => array(),
366                                              'name'     => 'Anycast',
367                                              'descr'    => 'Anycast is a network addressing and routing methodology in which a single destination address has multiple routing paths to two or more endpoint destinations.');
368// Keep this at last!
369$config['ip_types']['unicast']        = array('networks' => array('2000::/3'), // 'networks' => array('0.0.0.0/0', '2000::/3'),'
370                                              'name'     => 'Global Unicast', 'subtext' => 'Example: 2a02:408:7722::, 80.94.60.2', 'disabled' => 1,
371                                              'descr'    => 'Global Unicast addresses. Example: 2a02:408:7722::, 80.94.60.2');
372
373// Syslog colour and name translation
374
375$config['syslog']['priorities'][0] = array('name' => 'emergency',     'color' => '#D94640', 'label-class' => 'inverse',    'row-class' => 'error');
376$config['syslog']['priorities'][1] = array('name' => 'alert',         'color' => '#D94640', 'label-class' => 'delayed',    'row-class' => 'error');
377$config['syslog']['priorities'][2] = array('name' => 'critical',      'color' => '#D94640', 'label-class' => 'error',      'row-class' => 'error');
378$config['syslog']['priorities'][3] = array('name' => 'error',         'color' => '#E88126', 'label-class' => 'error',      'row-class' => 'error');
379$config['syslog']['priorities'][4] = array('name' => 'warning',       'color' => '#F2CA3F', 'label-class' => 'warning',    'row-class' => 'warning');
380$config['syslog']['priorities'][5] = array('name' => 'notification',  'color' => '#107373', 'label-class' => 'success',    'row-class' => 'recovery');
381$config['syslog']['priorities'][6] = array('name' => 'informational', 'color' => '#499CA6', 'label-class' => 'primary',    'row-class' => ''); //'row-class' => 'info');
382$config['syslog']['priorities'][7] = array('name' => 'debugging',     'color' => '#5AA637', 'label-class' => 'suppressed', 'row-class' => 'suppressed');
383
384for ($i = 8; $i < 16; $i++)
385{
386  $config['syslog']['priorities'][$i] = array('name' => 'other',        'color' => '#D2D8F9', 'label-class' => 'disabled',   'row-class' => 'disabled');
387}
388
389// https://tools.ietf.org/html/draft-ietf-netmod-syslog-model-14
390$config['syslog']['facilities'][0]  = array('name' => 'kern',     'descr' => 'kernel messages');
391$config['syslog']['facilities'][1]  = array('name' => 'user',     'descr' => 'user-level messages');
392$config['syslog']['facilities'][2]  = array('name' => 'mail',     'descr' => 'mail system');
393$config['syslog']['facilities'][3]  = array('name' => 'daemon',   'descr' => 'system daemons');
394$config['syslog']['facilities'][4]  = array('name' => 'auth',     'descr' => 'security/authorization messages');
395$config['syslog']['facilities'][5]  = array('name' => 'syslog',   'descr' => 'messages generated internally by syslogd');
396$config['syslog']['facilities'][6]  = array('name' => 'lpr',      'descr' => 'line printer subsystem');
397$config['syslog']['facilities'][7]  = array('name' => 'news',     'descr' => 'network news subsystem');
398$config['syslog']['facilities'][8]  = array('name' => 'uucp',     'descr' => 'UUCP subsystem');
399$config['syslog']['facilities'][9]  = array('name' => 'cron',     'descr' => 'clock daemon');
400$config['syslog']['facilities'][10] = array('name' => 'authpriv', 'descr' => 'security/authorization messages');
401$config['syslog']['facilities'][11] = array('name' => 'ftp',      'descr' => 'FTP daemon');
402$config['syslog']['facilities'][12] = array('name' => 'ntp',      'descr' => 'NTP subsystem');
403$config['syslog']['facilities'][13] = array('name' => 'audit',    'descr' => 'log audit');
404$config['syslog']['facilities'][14] = array('name' => 'console',  'descr' => 'log alert');
405$config['syslog']['facilities'][15] = array('name' => 'cron2',    'descr' => 'clock daemon');
406$config['syslog']['facilities'][16] = array('name' => 'local0',   'descr' => 'local use 0 (local0)');
407$config['syslog']['facilities'][17] = array('name' => 'local1',   'descr' => 'local use 1 (local1)');
408$config['syslog']['facilities'][18] = array('name' => 'local2',   'descr' => 'local use 2 (local2)');
409$config['syslog']['facilities'][19] = array('name' => 'local3',   'descr' => 'local use 3 (local3)');
410$config['syslog']['facilities'][20] = array('name' => 'local4',   'descr' => 'local use 4 (local4)');
411$config['syslog']['facilities'][21] = array('name' => 'local5',   'descr' => 'local use 5 (local5)');
412$config['syslog']['facilities'][22] = array('name' => 'local6',   'descr' => 'local use 6 (local6)');
413$config['syslog']['facilities'][23] = array('name' => 'local7',   'descr' => 'local use 7 (local7)');
414
415// Possible transports for net-snmp, used for enumeration in several functions
416$config['snmp']['transports'] = array('udp', 'udp6', 'tcp', 'tcp6');
417
418// 'count' is min total errors count, after which autodisable this MIB/oid pair
419// 'rate' is min total rate (per poll), after which autodisable this MIB/oid pair
420// note, rate not fully correct after server reboot (it will less than really)
421$config['snmp']['errorcodes'][0]    = array('reason' => 'OK',
422                                            'msg'    => '');
423
424// [1-99] Non critical
425$config['snmp']['errorcodes'][1]    = array('reason' => 'Empty response',           // exitcode = 0, but not have any data
426                                            'count'  => 288,                        // 288 with rate 1/poll ~ 1 day
427                                            'rate'   => 0.9,
428                                            'msg'    => '');
429$config['snmp']['errorcodes'][2]    = array('reason' => 'Request not completed',    // Snmp output return correct data, but stopped by some reason (timeout, network error)
430                                            'msg'    => '');
431$config['snmp']['errorcodes'][3]    = array('reason' => 'Too long response',        // Not empty output, but exitcode = 1 and runtime > 10
432                                            'msg'    => '');
433$config['snmp']['errorcodes'][4]    = array('reason' => 'Too big max-repetition in GETBULK', // Not empty output, but exitcode = 2 and stderr "Reason: (tooBig)"
434                                            'count'  => 2880,                       // 2880 with rate 1/poll ~ 10 day
435                                            'rate'   => 0.9,
436                                            'msg'    => '');
437
438// [900-999] Critical errors, but this is incorrect auth or config or missed files on client side
439$config['snmp']['errorcodes'][900]  = array('reason' => 'isSNMPable',               // Device up/down test, not used for counting
440                                            'msg'    => '');
441$config['snmp']['errorcodes'][991]  = array('reason' => 'Authentication failure',   // Snmp auth errors
442                                            'msg'    => '');
443$config['snmp']['errorcodes'][995]  = array('reason' => 'Incorrect arguments',      // Incorrect arguments passed to snmpcmd
444                                            'msg'    => '');
445$config['snmp']['errorcodes'][996]  = array('reason' => 'MIB or oid not found',     // MIB module or oid not found in specified dirs
446                                            'msg'    => '');
447$config['snmp']['errorcodes'][997]  = array('reason' => 'Wrong .index in mibs dir', // This is common net-snmp bug, require delete all .index files
448                                            'msg'    => '');
449$config['snmp']['errorcodes'][998]  = array('reason' => 'MIB or oid disabled',      // MIB or oid disabled
450                                            'msg'    => '');
451$config['snmp']['errorcodes'][999]  = array('reason' => 'Unknown',                  // Some unidentified error
452                                            'count'  => 288,                        // 288 with rate 1.95/poll ~ 12 hours
453                                            'rate'   => 0.9,
454                                            'msg'    => '');
455
456// [1000-1xxx] Critical errors on device side, can autodisable
457$config['snmp']['errorcodes'][1000] = array('reason' => 'Failed response',          // Any critical error in snmp output, which not return useful data
458                                            'count'  => 70,                         // errors in every poll run, disable after ~ 6 hours
459                                            'rate'   => 0.9,
460                                            'msg'    => '');
461//$config['snmp']['errorcodes'][1001] = array('reason' => 'Authentication failure',   // Snmp auth errors
462//                                            'count'  => 25,                         // errors in every poll run, disable after ~ 1.5 hour
463//                                            'rate'   => 0.9,
464//                                            'msg'    => '');
465$config['snmp']['errorcodes'][1002] = array('reason' => 'Request timeout',          // Cmd exit by timeout
466                                            'count'  => 25,                         // errors in every poll run, disable after ~ 1.5 hour
467                                            'rate'   => 0.9,
468                                            'msg'    => '');
469
470
471// IPMI user levels (used in GUI, first entry = default if unset)
472
473$config['ipmi']['userlevels']['USER']          = array('text' => 'User');
474$config['ipmi']['userlevels']['OPERATOR']      = array('text' => 'Operator');
475$config['ipmi']['userlevels']['ADMINISTRATOR'] = array('text' => 'Administrator');
476$config['ipmi']['userlevels']['CALLBACK']      = array('text' => 'Callback');
477
478// IPMI interfaces (used in GUI, first entry = default if unset)
479
480$config['ipmi']['interfaces']['lan']     = array('text' => 'IPMI v1.5 LAN Interface');
481$config['ipmi']['interfaces']['lanplus'] = array('text' => 'IPMI v2.0 RMCP+ LAN Interface');
482$config['ipmi']['interfaces']['imb']     = array('text' => 'Intel IMB Interface');
483$config['ipmi']['interfaces']['open']    = array('text' => 'Linux OpenIPMI Interface');
484
485// RANCID OS map (for config generation script)
486$config['rancid']['os_map']['arista_eos'] = 'arista';
487//$config['rancid']['os_map']['avocent']    = 'avocent';
488//$config['rancid']['os_map']['ciena-waveserveros']   = 'ciena-ws';
489$config['rancid']['os_map']['cyclades']   = 'avocent';
490$config['rancid']['os_map']['f5']         = 'f5'; // Only for <= v10
491$config['rancid']['os_map']['fortigate']  = 'fortigate';
492$config['rancid']['os_map']['ftos']       = 'force10';
493$config['rancid']['os_map']['ios']        = 'cisco';
494$config['rancid']['os_map']['iosxe']      = 'cisco';
495$config['rancid']['os_map']['iosxr']      = 'cisco-xr';
496$config['rancid']['os_map']['asa']        = 'cisco';
497$config['rancid']['os_map']['pixos']      = 'cisco';
498$config['rancid']['os_map']['nxos']       = 'cisco-nx';
499$config['rancid']['os_map']['ironware']   = 'foundry';
500//$config['rancid']['os_map']['procurve']   = 'hp'; // v3 only
501$config['rancid']['os_map']['junos']      = 'juniper';
502$config['rancid']['os_map']['screenos']   = 'netscreen';
503$config['rancid']['os_map']['opengear']   = 'opengear';
504$config['rancid']['os_map']['routeros']   = 'mikrotik';
505$config['rancid']['os_map']['pfsense']    = 'pfsense';
506$config['rancid']['os_map']['netscaler']  = 'netscaler';
507// Rancid v3.0+ specific os map
508//$config['rancid']['os_map_3']['adtran-aos']            = 'adtran';
509$config['rancid']['os_map_3']['arbos']                 = 'arbor';
510$config['rancid']['os_map_3']['powerconnect-fastpath'] = 'dell';
511$config['rancid']['os_map_3']['powerconnect-radlan']   = 'dell';
512$config['rancid']['os_map_3']['dnos6']                 = 'dell';
513$config['rancid']['os_map_3']['enterasys']             = 'enterasys';
514$config['rancid']['os_map_3']['xos']                   = 'extreme';
515//$config['rancid']['os_map_3']['juniper-srx']           = 'juniper-srx'; // SRX in junos..
516$config['rancid']['os_map_3']['mrvos']                 = 'mrv';
517$config['rancid']['os_map_3']['seos']                  = 'redback';
518// Rancid v3.2+ specific os map
519//$config['rancid']['os_map_3.2']['wlc']                 = 'cisco-wlc4';
520$config['rancid']['os_map_3.2']['wlc']                 = 'cisco-wlc5';
521$config['rancid']['os_map_3.2']['panos']               = 'paloalto';
522$config['rancid']['os_map_3.2']['procurve']            = 'hp';
523// Rancid v3.3+ specific os map
524$config['rancid']['os_map_3.3']['ciena-waveserveros']  = 'ciena-ws';
525$config['rancid']['os_map_3.3']['steelhead']           = 'riverbed';
526// Rancid v3.4+ specific os map
527$config['rancid']['os_map_3.4']['a10-ax']              = 'a10';
528$config['rancid']['os_map_3.4']['a10-ex']              = 'a10';
529// Rancid v3.5+ specific os map
530$config['rancid']['os_map_3.5']['edgemax']             = 'edgemax';
531//$config['rancid']['os_map_3.5']['f5']                  = 'bigip'; // v11+
532// Rancid v3.7+ specific os map
533$config['rancid']['os_map_3.7']['ciscosb']             = 'cisco-sb';
534//$config['rancid']['os_map_3.7']['wlc']                 = 'cisco-wlc8';
535$config['rancid']['os_map_3.7']['timos']               = 'sros'; // Classic CLI (TiMOS)
536// Rancid v3.8+ specific os map
537$config['rancid']['os_map_3.8']['cisco-firepower']     = 'fxos';
538$config['rancid']['os_map_3.8']['vrp']                 = 'vrp';
539//$config['rancid']['os_map_3.8']['f5']                  = 'bigip13'; // v13+
540//$config['rancid']['os_map_3.8']['timos']               = 'sros-md'; // MD-CLI (TiMOS) 7750 SR and 7950 XRS routers
541// Rancid v3.9+ specific os map
542//$config['rancid']['os_map_3.9']['arrcus']                 = 'arcos'; // We not support this OS
543
544
545# Enable these (in config.php) if you added the powerconnect addon to your RANCID install
546#$config['rancid']['os_map']['powerconnect-fastpath'] = 'dell';
547#$config['rancid']['os_map']['powerconnect-radlan']   = 'dell';
548#$config['rancid']['os_map']['dnos6']                 = 'dell';
549
550//////////////////////////////////////////////////////////////////////////
551// No changes below this line // (no changes above it either, remember? //
552//////////////////////////////////////////////////////////////////////////
553
554// Include DB functions
555
556define('OBS_DB_LINK', 'observium_link'); // Global variable name for DB link identifier, required for mysqli
557$config['db_extension'] = strtolower($config['db_extension']);
558switch ($config['db_extension'])
559{
560  case 'mysql':
561    define('OBS_DB_EXTENSION', $config['db_extension']);
562    print_error("MySQL extension is deprecated since PHP 5.5, we unsupported it anymore. Use mysqli extension instead!");
563    break;
564  case 'mysqli':
565  default:
566    define('OBS_DB_EXTENSION', 'mysqli');
567}
568require_once($config['install_dir'] . "/includes/db.inc.php");
569
570include($config['install_dir'].'/includes/definitions/version.inc.php');
571
572// Set default paths.
573$config['install_dir'] = rtrim($config['install_dir'], ' /');
574if (!isset($config['html_dir'])) { $config['html_dir'] = $config['install_dir'] . '/html'; }
575else                             { $config['html_dir'] = rtrim($config['html_dir'], ' /'); }
576if (!isset($config['rrd_dir']))  { $config['rrd_dir']  = $config['install_dir'] . '/rrd'; }
577else                             { $config['rrd_dir']  = rtrim($config['rrd_dir'], ' /'); }
578
579// Fix RRD Directory path to always have a trailing slash so that it works nicely with rrdcached
580//$config['rrd_dir'] = fix_path_slash($config['rrd_dir']);
581
582if (!isset($config['log_dir']))       { $config['log_dir']      = $config['install_dir'] . '/logs'; }
583else                                  { $config['log_dir']      = rtrim($config['log_dir'], ' /'); }
584if (!isset($config['log_file']))      { $config['log_file']     = $config['log_dir'] . '/observium.log'; } // FIXME should not be absolute path, look for where it is used
585if (!isset($config['temp_dir']))      { $config['temp_dir']     = '/tmp'; }
586else                                  { $config['temp_dir']     = rtrim($config['temp_dir'], ' /'); }
587if (!isset($config['mib_dir']))       { $config['mib_dir']      = $config['install_dir'] . '/mibs'; }
588else                                  { $config['mib_dir']      = rtrim($config['mib_dir'], ' /'); }
589if (!isset($config['template_dir']))  { $config['template_dir'] = $config['install_dir'] . '/templates'; }
590else                                  { $config['template_dir'] = rtrim($config['template_dir'], ' /'); }
591if (!isset($config['cache_dir']))     { $config['cache_dir']    = $config['temp_dir'] . '/observium_cache'; }
592else                                  { $config['cache_dir']    = rtrim($config['cache_dir'], ' /'); }
593
594// Connect to database
595$GLOBALS[OBS_DB_LINK] = dbOpen($config['db_host'], $config['db_user'], $config['db_pass'], $config['db_name']);
596
597// Base user levels
598
599$config['user_level']     = array(); // Init this array, for do not allow override over config.inc.php!
600$config['user_level'][0]  = array('permission' => 0,
601                                  'name'       => 'Disabled',
602                                  'subtext'    => 'This user disabled',
603                                  'notes'      => 'User complete can\'t login and use any services. Use it to block access for specific users, but not delete from DB.',
604                                  'row_class'  => 'disabled',
605                                  'icon'       => $config['icon']['user-delete']);
606$config['user_level'][1]  = array('permission' => OBS_PERMIT_ACCESS,
607                                  'name'       => 'Normal User',
608                                  'subtext'    => 'This user has read access to individual entities',
609                                  'notes'      => 'User can\'t see or edit anything by default. Can only see devices and entities specifically permitted.',
610                                  'row_class'  => 'default',
611                                  'icon'       => $config['icon']['users']);
612$config['user_level'][5]  = array('permission' => OBS_PERMIT_ACCESS | OBS_PERMIT_READ,
613                                  'name'       => 'Global Read',
614                                  'subtext'    => 'This user has global read access',
615                                  'notes'      => 'User can see all devices and entities with some security and configuration data masked, such as passwords.',
616                                  'row_class'  => 'suppressed',
617                                  'icon'       => $config['icon']['user-self']);
618$config['user_level'][7]  = array('permission' => OBS_PERMIT_ACCESS | OBS_PERMIT_READ | OBS_PERMIT_SECURE,
619                                  'name'       => 'Global Secure Read',
620                                  'subtext'    => 'This user has global read access with secured info',
621                                  'notes'      => 'User can see all devices and entities without any information being masked, including device configuration (supplied by e.g. RANCID).',
622                                  'row_class'  => 'warning',
623                                  'icon'       => $config['icon']['user-self']);
624$config['user_level'][8]  = array('permission' => OBS_PERMIT_ACCESS | OBS_PERMIT_READ | OBS_PERMIT_SECURE | OBS_PERMIT_EDIT,
625                                  'name'       => 'Global Secure Read / Limited Write',
626                                  'subtext'    => 'This user has secure global read access with scheduled maintenence read/write.',
627                                  'notes'      => 'User can see all devices and entities without any information being masked, including device configuration (supplied by e.g. RANCID). User can also add, edit and remove scheduled maintenance, group, contacts.',
628                                  'row_class'  => 'warning',
629                                  'icon'       => $config['icon']['user-self']);
630$config['user_level'][10] = array('permission' => OBS_PERMIT_ALL,
631                                  'name'       => 'Administrator',
632                                  'subtext'    => 'This user has full administrative access',
633                                  'notes'      => 'User can see and edit all devices and entities. This includes adding and removing devices, bills and users.',
634                                  'row_class'  => 'success',
635                                  'icon'       => $config['icon']['user-log']);
636
637$config['remote_access']['ssh']    = array('name' => "SSH",    'port' => '22',   'icon' => 'oicon-application-terminal');
638$config['remote_access']['telnet'] = array('name' => "Telnet", 'port' => '23',   'icon' => 'oicon-application-list');
639$config['remote_access']['scp']    = array('name' => "SFTP",   'port' => '22',   'icon' => 'oicon-disk-black');
640$config['remote_access']['ftp']    = array('name' => "FTP",    'port' => '21',   'icon' => 'oicon-disk');
641$config['remote_access']['http']   = array('name' => "HTTP",   'port' => '80',   'icon' => 'oicon-application-icon-large');
642$config['remote_access']['https']  = array('name' => "HTTPS",  'port' => '443',  'icon' => 'oicon-shield');
643$config['remote_access']['rdp']    = array('name' => "RDP",    'port' => '3389', 'icon' => 'oicon-connect');
644$config['remote_access']['vnc']    = array('name' => "VNC",    'port' => '5901', 'icon' => 'oicon-computer');
645
646// Set some times needed by loads of scripts (it's dynamic, so we do it here!)
647$config['time']['now']        = time();
648$config['time']['fiveminute'] = $config['time']['now'] - 300;      //time() - (5 * 60);
649$config['time']['fourhour']   = $config['time']['now'] - 14400;    //time() - (4 * 60 * 60);
650$config['time']['sixhour']    = $config['time']['now'] - 21600;    //time() - (6 * 60 * 60);
651$config['time']['twelvehour'] = $config['time']['now'] - 43200;    //time() - (12 * 60 * 60);
652$config['time']['day']        = $config['time']['now'] - 86400;    //time() - (24 * 60 * 60);
653$config['time']['twoday']     = $config['time']['now'] - 172800;   //time() - (2 * 24 * 60 * 60);
654$config['time']['week']       = $config['time']['now'] - 604800;   //time() - (7 * 24 * 60 * 60);
655$config['time']['twoweek']    = $config['time']['now'] - 1209600;  //time() - (2 * 7 * 24 * 60 * 60);
656$config['time']['month']      = $config['time']['now'] - 2678400;  //time() - (31 * 24 * 60 * 60);
657$config['time']['twomonth']   = $config['time']['now'] - 5356800;  //time() - (2 * 31 * 24 * 60 * 60);
658$config['time']['threemonth'] = $config['time']['now'] - 8035200;  //time() - (3 * 31 * 24 * 60 * 60);
659$config['time']['sixmonth']   = $config['time']['now'] - 16070400; //time() - (6 * 31 * 24 * 60 * 60);
660$config['time']['year']       = $config['time']['now'] - 31536000; //time() - (365 * 24 * 60 * 60);
661$config['time']['twoyear']    = $config['time']['now'] - 63072000; //time() - (2 * 365 * 24 * 60 * 60);
662$config['time']['threeyear']  = $config['time']['now'] - 94608000; //time() - (3 * 365 * 24 * 60 * 60);
663
664
665// Obsolete config variables
666// Note, for multiarray config options use conversion with '->'
667// example: $config['email']['default'] --> 'email->default'
668$config['obsolete_config'] = array(); // NOT CONFIGURABLE, init
669$config['obsolete_config'][] = array('old' => 'warn->ifdown',        'new' => 'frontpage->device_status->ports');
670$config['obsolete_config'][] = array('old' => 'alerts->email->enable',       'new' => 'email->enable',       'info' => 'changed since r5787');
671$config['obsolete_config'][] = array('old' => 'alerts->email->default',      'new' => 'email->default',      'info' => 'changed since r5787');
672$config['obsolete_config'][] = array('old' => 'alerts->email->default_only', 'new' => 'email->default_only', 'info' => 'changed since r5787');
673$config['obsolete_config'][] = array('old' => 'alerts->email->graphs',       'new' => 'email->graphs',       'info' => 'changed since r6976');
674$config['obsolete_config'][] = array('old' => 'email_backend',       'new' => 'email->backend',       'info' => 'changed since r5787');
675$config['obsolete_config'][] = array('old' => 'email_from',          'new' => 'email->from',          'info' => 'changed since r5787');
676$config['obsolete_config'][] = array('old' => 'email_sendmail_path', 'new' => 'email->sendmail_path', 'info' => 'changed since r5787');
677$config['obsolete_config'][] = array('old' => 'email_smtp_host',     'new' => 'email->smtp_host',     'info' => 'changed since r5787');
678$config['obsolete_config'][] = array('old' => 'email_smtp_port',     'new' => 'email->smtp_port',     'info' => 'changed since r5787');
679$config['obsolete_config'][] = array('old' => 'email_smtp_timeout',  'new' => 'email->smtp_timeout',  'info' => 'changed since r5787');
680$config['obsolete_config'][] = array('old' => 'email_smtp_secure',   'new' => 'email->smtp_secure',   'info' => 'changed since r5787');
681$config['obsolete_config'][] = array('old' => 'email_smtp_auth',     'new' => 'email->smtp_auth',     'info' => 'changed since r5787');
682$config['obsolete_config'][] = array('old' => 'email_smtp_username', 'new' => 'email->smtp_username', 'info' => 'changed since r5787');
683$config['obsolete_config'][] = array('old' => 'email_smtp_password', 'new' => 'email->smtp_password', 'info' => 'changed since r5787');
684$config['obsolete_config'][] = array('old' => 'discovery_modules->cisco-pw', 'new' => 'discovery_modules->pseudowires', 'info' => 'changed since r6205');
685$config['obsolete_config'][] = array('old' => 'discovery_modules->discovery-protocols', 'new' => 'discovery_modules->neighbours', 'info' => 'changed since r6744');
686$config['obsolete_config'][] = array('old' => 'search_modules',      'new' => 'wui->search_modules', 'info' => 'changed since r7463');
687$config['obsolete_config'][] = array('old' => 'discovery_modules->ipv4-addresses', 'new' => 'discovery_modules->ip-addresses', 'info' => 'changed since r7565');
688$config['obsolete_config'][] = array('old' => 'discovery_modules->ipv6-addresses', 'new' => 'discovery_modules->ip-addresses', 'info' => 'changed since r7565');
689$config['obsolete_config'][] = array('old' => 'location_map',        'new' => 'location->map',       'info' => 'changed since r8021');
690$config['obsolete_config'][] = array('old' => 'geocoding->api_key',  'new' => 'geo_api->google->key', 'info' => 'DEPRECATED since 19.8.10000');
691
692// Here whitelist of base definitions keys which can be overridden by config.php file
693// Note, this required only for override already exist definitions, for additions not required
694$config['definitions_whitelist'] = array('os', 'mibs', 'device_types', 'rancid', 'geo_api', 'search_modules', 'rewrites', 'nicecase', 'wui');
695
696// End of includes/definitions.inc.php
697