-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
95 lines (75 loc) · 2.28 KB
/
index.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
function parseURI()
{
$uri=ltrim($_SERVER['REQUEST_URI'],'/');
$tmp=explode('/',$uri);
$result['type']=$tmp[0];
if(array_key_exists(1,$tmp))
$result['uri']=preg_replace('/[^a-z]/', '',$tmp[1]);
else
$result['uri']='';
if(array_key_exists(2,$tmp))
$result['id']=$tmp[2];
else
$result['id']='';
return $result;
}
$CONFIG_FILE ='configuration.ini';
define('CONFIG_FILE', $CONFIG_FILE);
$CONFIG = (array) parse_ini_file(CONFIG_FILE, true);
require_once "./lib/Hook.class.php";
require_once "./lib/LCsvGenieacsApiInterface.php";
require_once "./lib/LCsvGenieacsInterface.php";
require_once "./lib/LCPEInterface.php";
require_once "./lib/LCsvStorageInterface.php";
require_once "./lib/LCsvStorageFile.class.php";
require_once "./lib/LCsvGenieacs.class.php";
require_once "./lib/LCsvCache.class.php";
require_once "./lib/LCsvGenieacsApi.class.php";
require_once "./lib/LCPE.class.php";
require_once "./lib/BaseCPE.class.php";
require_once "./lib/loadServers.php";
require_once "./lib/loadCPE.php";
$hooks=new Hooks();
$route=parseURI();
if($hooks->existsServer($route['type']))
{
$data['method']=$_SERVER['REQUEST_METHOD'];
$data['uri']=$route['uri'];
$data['id']=$route['id'];
$data['token']=$_SERVER['HTTP_AUTHORIZATION'];
print $hooks->execute($route['type'],$data);
}
else
{
if($CONFIG['cache']['enable'])
$cache=new LCsvCache();
if(array_key_exists('storageclass',$CONFIG['general']))
$storagename=$CONFIG['general']['storageclass'];
else
$storagename= 'LCsvStorageFile';
$STORAGE= new $storagename();
$LAPI=new LCsvGenieacsApi($CONFIG['general']['ip'],$cache);
if(file_exists('smarty/libs/Smarty.class.php'))
{
require 'smarty/libs/Smarty.class.php';
$smarty = new Smarty;
if(!array_key_exists('m', $_GET))
$module='welcome';
else
$module=$_GET['m'];
$smarty->assign('cache_enable', $CONFIG['cache']['enable']);
$smarty->assign('title', 'Light CSV');
$file='modules/'. $module . '.php';
if (file_exists($file)) {
include $file;
}
else {
echo "No souch page.";
exit;
}
}
else
include 'actions.inc.php';
}
?>