/
configure.php
67 lines (53 loc) · 1.49 KB
/
configure.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
63
64
65
66
67
<?php
/**
* Created by JetBrains PhpStorm.
* User: Alexandr
* Date: 28.09.10
* Time: 21:54
*/
define('ROOT_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR);
define('CONNECTION_STRING_FORMAT', '!^mysql://([^:@]+)(?::([^@]+))?@([^:/]+)(?::(\d+))?/(.*)$!');
if (!defined('STDIN')) {
define('STDIN', fopen('php://stdin', 'r'));
}
if (!function_exists('gettext')) {
function _($msgid) { return $msgid; }
function gettext($msgid) { return $msgid; }
function ngettext($msgid1, $msgid2, $n) { return $n == 1 ? $msgid1 : $msgid2; }
}
if (!function_exists('filter_input')) {
// for php < 5.2
define('INPUT_POST', '$_POST');
function filter_input($type, $name) {
return eval("return {$type}['$name'];");
}
}
define('CONFIG_FILE', 'app.cfg');
define('SOFTWARE_NAME', 'loadOdie');
class Autoloader {
static public function register() {
spl_autoload_register(array(new self, 'autoload'));
}
static public function autoload($class) {
$file = ROOT_DIR . "classes/$class.php";
if (file_exists($file)) {
require_once $file;
return true;
} else
return false;
}
}
Autoloader::register();
class Config {
protected static $config;
public static function setConfig($config) {
self::$config = $config;
}
public static function getConfig($param) {
return array_key_exists($param, self::$config) ? self::$config[$param] : '';
}
public static function getAll() {
return self::$config;
}
}
file_exists(ROOT_DIR . CONFIG_FILE) and Config::setConfig(parse_ini_file(ROOT_DIR . CONFIG_FILE));