-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.php
More file actions
66 lines (53 loc) · 1.57 KB
/
init.php
File metadata and controls
66 lines (53 loc) · 1.57 KB
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
<?php
namespace Parser\Classes;
//init
require_once($_SERVER['DOCUMENT_ROOT'] . '/' . 'config/config.php');
//external libs
require_once(LIB_DIR . "/phpQuery.php");
require_once(LIB_DIR . "/class.FastTemplate.php");
//class autoloader
spl_autoload_register(function ($class) {
// project-specific namespace prefix
$prefix = 'Parser\\Classes\\';
// base directory for the namespace prefix
$base_dir = __DIR__ . '/classes/';
// does the class use the namespace prefix?
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) !== 0) {
// no, move to the next registered autoloader
return;
}
// get the relative class name
$relative_class = substr($class, $len);
// replace the namespace prefix with the base directory, replace namespace
// separators with directory separators in the relative class name, append
// with .php
$file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
// if the file exists, require it
if (file_exists($file)) {
require $file;
}
});
//TEMPLATE ENGINE INIT
define("TROOT", $_SERVER['DOCUMENT_ROOT'] . '/tpl/');
$obj = new \FastTemplate(TROOT);
$obj->define(array(
"index" => "index.tpl",
"news" => "news.tpl",
"news_in" => "news_in.tpl",
"news_read" => "news_read.tpl",
"login" => "login.tpl",
"admin" => "admin.tpl",
"src_in" => "src_in.tpl",
"img" => "img.tpl",
"news_del" => "news_del.tpl",
"admin_menu" => "admin_menu.tpl",
"alert" => "alert.tpl",
"alert_success" => "alert_success.tpl",
));
//DB init
DB::getInstance();
$admin = new Admin();
if ($admin->auth_check()) {
$obj->parse("ADMIN_MENU", ".admin_menu");
}