-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslentry.php
86 lines (72 loc) · 2.31 KB
/
slentry.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
<?php
require_once 'safeLogger.php';
Class slentry
{
public function entry()
{
$get = $_GET;
$params = array();
$urlParamCount = 0;
$urlRange = array("controller", "page", "module");
foreach ($get as $key => $value) {
$key = urlencode(trim($key));
$params[$key] = htmlspecialchars(trim($value));
if (in_array($key, $urlRange)) {
$urlParamCount++;
};
}
if ($urlParamCount > 1) {
throw new Exception("Bad Url!");
}else if ($urlParamCount==0 || empty($get)){
$this->easyConfig('login');
}
if (isset($params['page'])) {
$urlParam = $params['page'];
$this->easyConfig($urlParam);
}
if (isset($params['controller'])) {
$urlParam = $params['controller'];
if(isset($params['controller'])){
$func = $params['controller'];
}else{
$func = 'controller';
}
include_once ROOT_PATH.'/function/'.$urlParam.'.php';
$module = new $params['controller'];
$module->$func();
//you can render html in your function
}
if (isset($params['module'])) {
$urlParam = $params['module'];
if(isset($params['func'])){
$func = $params['func'];
}else{
$func = 'index';
}
include_once ROOT_PATH."/function/"."$urlParam".".php";
$module = new $params['module'];
$module->$func();
$this->easyConfig($urlParam);
}
}
public function easyConfig($param){
$config = array(
'search' => array('header','search'), //include "include header.html" ;include "seracher.html";
'account' => array('header','account'),
);
foreach ( $config as $key => $value){
if($param == $key){
$row = $value;
foreach ($row as $key2 => $value2){
include_once ROOT_PATH.'/page/'.$value2.'.html';
}
return false;
}
}
include_once ROOT_PATH.'/page/'.$param.'.html';
return false;
}
}
$log = new slentry();
$log->entry();
?>