-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconfig.php
62 lines (51 loc) · 1.43 KB
/
config.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
ini_set("display_errors", true);
error_reporting(0); // E_ALL
$root = pathinfo($_SERVER['SCRIPT_FILENAME']);
define('PROTOCOL', 'http://');
define('DIRNAME', basename($root['dirname'])); // 'basename', 'extension' and 'filename'
define('SERVER_ROOT', realpath(dirname(__FILE__)));
define('PUB_URL', PROTOCOL . $_SERVER['HTTP_HOST'] . '/' . DIRNAME);
/*
* include classes
* PDO class (medoo.class.php)
* Mikrotik Class (RouterosAPI.class.php)
*
* O nome da classe precisa ser igual ao nome do arquivo para o
* `spl_autoload_register()` funcionar de forma adequada.
*/
spl_autoload_register(function($class) {
include 'class/' . $class . '.class.php';
});
/*
* start session
*/
if (php_sapi_name() !== 'cli')
{
// checa versao do php para poder comparar status da sessao
if (version_compare(phpversion(), '5.4.0', '>='))
{
// PHP_SESSION_DISABLED = 0
// PHP_SESSION_NONE = 1
// PHP_SESSION_ACTIVE = 2
$ss = session_status() === PHP_SESSION_ACTIVE ? TRUE : FALSE;
if ($ss === FALSE ) session_start();
}
else
{
$ss = session_id() === '' ? FALSE : TRUE;
if ($ss === FALSE ) session_start();
}
}
/*
* PDO Instantiation via medoo
* See file >> DOC
*/
$database = new medoo(array(
'database_type' => 'mysql',
'database_name' => 'synet',
'server' => 'localhost',
'username' => 'synet',
'password' => 'nZQ4xw1EhruaEVTZ',
'charset' => 'utf8'
));