forked from arosenfeld/phpwatch
-
Notifications
You must be signed in to change notification settings - Fork 1
/
common.php
34 lines (32 loc) · 1.37 KB
/
common.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
require_once(dirname(__FILE__) . '/config.php');
require_once(PW2_PATH . '/src/db_schemes/' . $PW2_CONFIG['db_scheme'] . '.php');
require_once(PW2_PATH . '/src/Monitor.php');
require_once(PW2_PATH . '/src/Contact.php');
require_once(PW2_PATH . '/src/Statistics.php');
$GLOBALS['monitor_types'] = array();
$mon_handle = opendir(PW2_PATH . '/src/monitors');
while(false !== ($file = readdir($mon_handle)))
{
if(strpos($file, '.php') !== false && $file[0] != '.')
{
$GLOBALS['monitor_types'][] = substr($file, 0, strlen($file) - 4);
require_once(PW2_PATH . '/src/monitors/' . $file);
}
}
closedir($mon_handle);
$GLOBALS['channel_types'] = array();
$chan_handle = opendir(PW2_PATH . '/src/channels');
while(false !== ($file = readdir($chan_handle)))
{
if(strpos($file, '.php') !== false && $file[0] != '.')
{
$GLOBALS['channel_types'][] = substr($file, 0, strlen($file) - 4);
require_once(PW2_PATH . '/src/channels/' . $file);
}
}
closedir($chan_handle);
$GLOBALS['PW_DB'] = new $PW2_CONFIG['db_scheme']($PW2_CONFIG['db_info']['host'], $PW2_CONFIG['db_info']['db'], $PW2_CONFIG['db_info']['user'], $PW2_CONFIG['db_info']['pass']);
if($GLOBALS['PW_DB']->connect() === false)
die('Unable to connect to database.');
?>