@@ -7,12 +7,12 @@ |
||
7 | 7 | */ |
8 | 8 | class LogLevel |
9 | 9 | { |
10 | - const EMERGENCY = 'emergency'; |
|
11 | - const ALERT = 'alert'; |
|
12 | - const CRITICAL = 'critical'; |
|
13 | - const ERROR = 'error'; |
|
14 | - const WARNING = 'warning'; |
|
15 | - const NOTICE = 'notice'; |
|
16 | - const INFO = 'info'; |
|
17 | - const DEBUG = 'debug'; |
|
10 | + const EMERGENCY = 'emergency'; |
|
11 | + const ALERT = 'alert'; |
|
12 | + const CRITICAL = 'critical'; |
|
13 | + const ERROR = 'error'; |
|
14 | + const WARNING = 'warning'; |
|
15 | + const NOTICE = 'notice'; |
|
16 | + const INFO = 'info'; |
|
17 | + const DEBUG = 'debug'; |
|
18 | 18 | } |
@@ -19,96 +19,96 @@ |
||
19 | 19 | */ |
20 | 20 | interface LoggerInterface |
21 | 21 | { |
22 | - /** |
|
23 | - * System is unusable. |
|
24 | - * |
|
25 | - * @param string $message |
|
26 | - * @param array $context |
|
27 | - * @return null |
|
28 | - */ |
|
29 | - public function emergency($message, array $context = array()); |
|
22 | + /** |
|
23 | + * System is unusable. |
|
24 | + * |
|
25 | + * @param string $message |
|
26 | + * @param array $context |
|
27 | + * @return null |
|
28 | + */ |
|
29 | + public function emergency($message, array $context = array()); |
|
30 | 30 | |
31 | - /** |
|
32 | - * Action must be taken immediately. |
|
33 | - * |
|
34 | - * Example: Entire website down, database unavailable, etc. This should |
|
35 | - * trigger the SMS alerts and wake you up. |
|
36 | - * |
|
37 | - * @param string $message |
|
38 | - * @param array $context |
|
39 | - * @return null |
|
40 | - */ |
|
41 | - public function alert($message, array $context = array()); |
|
31 | + /** |
|
32 | + * Action must be taken immediately. |
|
33 | + * |
|
34 | + * Example: Entire website down, database unavailable, etc. This should |
|
35 | + * trigger the SMS alerts and wake you up. |
|
36 | + * |
|
37 | + * @param string $message |
|
38 | + * @param array $context |
|
39 | + * @return null |
|
40 | + */ |
|
41 | + public function alert($message, array $context = array()); |
|
42 | 42 | |
43 | - /** |
|
44 | - * Critical conditions. |
|
45 | - * |
|
46 | - * Example: Application component unavailable, unexpected exception. |
|
47 | - * |
|
48 | - * @param string $message |
|
49 | - * @param array $context |
|
50 | - * @return null |
|
51 | - */ |
|
52 | - public function critical($message, array $context = array()); |
|
43 | + /** |
|
44 | + * Critical conditions. |
|
45 | + * |
|
46 | + * Example: Application component unavailable, unexpected exception. |
|
47 | + * |
|
48 | + * @param string $message |
|
49 | + * @param array $context |
|
50 | + * @return null |
|
51 | + */ |
|
52 | + public function critical($message, array $context = array()); |
|
53 | 53 | |
54 | - /** |
|
55 | - * Runtime errors that do not require immediate action but should typically |
|
56 | - * be logged and monitored. |
|
57 | - * |
|
58 | - * @param string $message |
|
59 | - * @param array $context |
|
60 | - * @return null |
|
61 | - */ |
|
62 | - public function error($message, array $context = array()); |
|
54 | + /** |
|
55 | + * Runtime errors that do not require immediate action but should typically |
|
56 | + * be logged and monitored. |
|
57 | + * |
|
58 | + * @param string $message |
|
59 | + * @param array $context |
|
60 | + * @return null |
|
61 | + */ |
|
62 | + public function error($message, array $context = array()); |
|
63 | 63 | |
64 | - /** |
|
65 | - * Exceptional occurrences that are not errors. |
|
66 | - * |
|
67 | - * Example: Use of deprecated APIs, poor use of an API, undesirable things |
|
68 | - * that are not necessarily wrong. |
|
69 | - * |
|
70 | - * @param string $message |
|
71 | - * @param array $context |
|
72 | - * @return null |
|
73 | - */ |
|
74 | - public function warning($message, array $context = array()); |
|
64 | + /** |
|
65 | + * Exceptional occurrences that are not errors. |
|
66 | + * |
|
67 | + * Example: Use of deprecated APIs, poor use of an API, undesirable things |
|
68 | + * that are not necessarily wrong. |
|
69 | + * |
|
70 | + * @param string $message |
|
71 | + * @param array $context |
|
72 | + * @return null |
|
73 | + */ |
|
74 | + public function warning($message, array $context = array()); |
|
75 | 75 | |
76 | - /** |
|
77 | - * Normal but significant events. |
|
78 | - * |
|
79 | - * @param string $message |
|
80 | - * @param array $context |
|
81 | - * @return null |
|
82 | - */ |
|
83 | - public function notice($message, array $context = array()); |
|
76 | + /** |
|
77 | + * Normal but significant events. |
|
78 | + * |
|
79 | + * @param string $message |
|
80 | + * @param array $context |
|
81 | + * @return null |
|
82 | + */ |
|
83 | + public function notice($message, array $context = array()); |
|
84 | 84 | |
85 | - /** |
|
86 | - * Interesting events. |
|
87 | - * |
|
88 | - * Example: User logs in, SQL logs. |
|
89 | - * |
|
90 | - * @param string $message |
|
91 | - * @param array $context |
|
92 | - * @return null |
|
93 | - */ |
|
94 | - public function info($message, array $context = array()); |
|
85 | + /** |
|
86 | + * Interesting events. |
|
87 | + * |
|
88 | + * Example: User logs in, SQL logs. |
|
89 | + * |
|
90 | + * @param string $message |
|
91 | + * @param array $context |
|
92 | + * @return null |
|
93 | + */ |
|
94 | + public function info($message, array $context = array()); |
|
95 | 95 | |
96 | - /** |
|
97 | - * Detailed debug information. |
|
98 | - * |
|
99 | - * @param string $message |
|
100 | - * @param array $context |
|
101 | - * @return null |
|
102 | - */ |
|
103 | - public function debug($message, array $context = array()); |
|
96 | + /** |
|
97 | + * Detailed debug information. |
|
98 | + * |
|
99 | + * @param string $message |
|
100 | + * @param array $context |
|
101 | + * @return null |
|
102 | + */ |
|
103 | + public function debug($message, array $context = array()); |
|
104 | 104 | |
105 | - /** |
|
106 | - * Logs with an arbitrary level. |
|
107 | - * |
|
108 | - * @param mixed $level |
|
109 | - * @param string $message |
|
110 | - * @param array $context |
|
111 | - * @return null |
|
112 | - */ |
|
113 | - public function log($level, $message, array $context = array()); |
|
105 | + /** |
|
106 | + * Logs with an arbitrary level. |
|
107 | + * |
|
108 | + * @param mixed $level |
|
109 | + * @param string $message |
|
110 | + * @param array $context |
|
111 | + * @return null |
|
112 | + */ |
|
113 | + public function log($level, $message, array $context = array()); |
|
114 | 114 | } |
@@ -32,37 +32,37 @@ |
||
32 | 32 | */ |
33 | 33 | class Demo extends Controller |
34 | 34 | { |
35 | - /** |
|
36 | - * Constructor |
|
37 | - * |
|
38 | - * @access public |
|
39 | - * @return Demo |
|
40 | - */ |
|
41 | - public function __construct() |
|
42 | - { |
|
43 | - parent::__construct(); |
|
44 | - } |
|
35 | + /** |
|
36 | + * Constructor |
|
37 | + * |
|
38 | + * @access public |
|
39 | + * @return Demo |
|
40 | + */ |
|
41 | + public function __construct() |
|
42 | + { |
|
43 | + parent::__construct(); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * bootstrap |
|
48 | - * |
|
49 | - * @access public |
|
50 | - * @return void |
|
51 | - */ |
|
52 | - public function bootstrap() |
|
53 | - { |
|
54 | - ; |
|
55 | - } |
|
46 | + /** |
|
47 | + * bootstrap |
|
48 | + * |
|
49 | + * @access public |
|
50 | + * @return void |
|
51 | + */ |
|
52 | + public function bootstrap() |
|
53 | + { |
|
54 | + ; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * install method |
|
59 | - * |
|
60 | - * @access public |
|
61 | - * @param string $sPortal |
|
62 | - * @return void |
|
63 | - */ |
|
64 | - public function install($sPortal) |
|
65 | - { |
|
66 | - $this->installDb; |
|
67 | - } |
|
57 | + /** |
|
58 | + * install method |
|
59 | + * |
|
60 | + * @access public |
|
61 | + * @param string $sPortal |
|
62 | + * @return void |
|
63 | + */ |
|
64 | + public function install($sPortal) |
|
65 | + { |
|
66 | + $this->installDb; |
|
67 | + } |
|
68 | 68 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @access public |
98 | 98 | * @param string $sName name of the session |
99 | - * @return mixed |
|
99 | + * @return boolean |
|
100 | 100 | */ |
101 | 101 | public function delete(string $sName) |
102 | 102 | { |
@@ -107,7 +107,6 @@ discard block |
||
107 | 107 | * flush the cache |
108 | 108 | * |
109 | 109 | * @access public |
110 | - * @param string $sName name of the session |
|
111 | 110 | * @return mixed |
112 | 111 | */ |
113 | 112 | public function flush() |
@@ -120,7 +119,7 @@ discard block |
||
120 | 119 | * |
121 | 120 | * @access public |
122 | 121 | * @param string $sName name of the session |
123 | - * @return mixed |
|
122 | + * @return string |
|
124 | 123 | */ |
125 | 124 | private function _getSubDirectory($sName) |
126 | 125 | { |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * @param int $iTimeout expiration of cache |
75 | 75 | * @return mixed |
76 | 76 | */ |
77 | - public function get(string $sName, int &$iFlags = null, int $iTimeout = 0) |
|
77 | + public function get(string $sName, int&$iFlags = null, int $iTimeout = 0) |
|
78 | 78 | { |
79 | 79 | if ($iTimeout > 0 && file_exists($this->_sFolder.$this->_getSubDirectory($sName).md5($sName).'.fil.cac') |
80 | 80 | && time() - filemtime($this->_sFolder.$this->_getSubDirectory($sName).md5($sName).'.fil.cac') > $iTimeout) { |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | |
85 | 85 | if (file_exists($this->_sFolder.$this->_getSubDirectory($sName).md5($sName).'.fil.cac')) { |
86 | 86 | |
87 | - return unserialize(file_get_contents($this->_sFolder . $this->_getSubDirectory($sName) . md5($sName) . '.fil.cac')); |
|
87 | + return unserialize(file_get_contents($this->_sFolder.$this->_getSubDirectory($sName).md5($sName).'.fil.cac')); |
|
88 | 88 | } else { |
89 | 89 | |
90 | 90 | return false; |
@@ -30,125 +30,125 @@ |
||
30 | 30 | */ |
31 | 31 | class File implements CacheInterface |
32 | 32 | { |
33 | - /** |
|
34 | - * var containe this folder of cache |
|
35 | - * |
|
36 | - * @access private |
|
37 | - * @var string |
|
38 | - */ |
|
39 | - private $_sFolder = ''; |
|
40 | - |
|
41 | - /** |
|
42 | - * constructor |
|
43 | - * |
|
44 | - * @access public |
|
45 | - */ |
|
46 | - public function __construct() |
|
47 | - { |
|
48 | - $this->_sFolder = str_replace('bundles'.DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.'Cache', CACHE_DIR, __DIR__).DIRECTORY_SEPARATOR; |
|
49 | - } |
|
50 | - |
|
51 | - /** |
|
52 | - * set a value |
|
53 | - * |
|
54 | - * @access public |
|
55 | - * @param string $sName name of the session |
|
56 | - * @param mixed $mValue value of this sesion var |
|
57 | - * @param int $iFlag flags |
|
58 | - * @param int $iExpire expiration of cache |
|
59 | - * @return \Venus\lib\Cache\File |
|
60 | - */ |
|
61 | - public function set(string $sName, $mValue, int $iFlag, int $iExpire) |
|
62 | - { |
|
63 | - file_put_contents($this->_sFolder.$this->_getSubDirectory($sName).md5($sName).'.fil.cac', serialize($mValue)); |
|
64 | - return $this; |
|
65 | - } |
|
66 | - |
|
67 | - /** |
|
68 | - * get a value |
|
69 | - * |
|
70 | - * @access public |
|
71 | - * @param string $sName name of the session |
|
72 | - * @param int $iFlags flags |
|
73 | - * @param int $iTimeout expiration of cache |
|
74 | - * @return mixed |
|
75 | - */ |
|
76 | - public function get(string $sName, int &$iFlags = null, int $iTimeout = 0) |
|
77 | - { |
|
78 | - if ($iTimeout > 0 && file_exists($this->_sFolder.$this->_getSubDirectory($sName).md5($sName).'.fil.cac') |
|
79 | - && time() - filemtime($this->_sFolder.$this->_getSubDirectory($sName).md5($sName).'.fil.cac') > $iTimeout) { |
|
80 | - |
|
81 | - unlink($this->_sFolder.$this->_getSubDirectory($sName).md5($sName).'.fil.cac'); |
|
82 | - } |
|
83 | - |
|
84 | - if (file_exists($this->_sFolder.$this->_getSubDirectory($sName).md5($sName).'.fil.cac')) { |
|
85 | - |
|
86 | - return unserialize(file_get_contents($this->_sFolder . $this->_getSubDirectory($sName) . md5($sName) . '.fil.cac')); |
|
87 | - } else { |
|
88 | - |
|
89 | - return false; |
|
90 | - } |
|
91 | - } |
|
92 | - |
|
93 | - /** |
|
94 | - * delete a value |
|
95 | - * |
|
96 | - * @access public |
|
97 | - * @param string $sName name of the session |
|
98 | - * @return mixed |
|
99 | - */ |
|
100 | - public function delete(string $sName) |
|
101 | - { |
|
102 | - return unlink($this->_sFolder.$this->_getSubDirectory($sName).md5($sName).'.fil.cac'); |
|
103 | - } |
|
104 | - |
|
105 | - /** |
|
106 | - * flush the cache |
|
107 | - * |
|
108 | - * @access public |
|
109 | - * @param string $sName name of the session |
|
110 | - * @return mixed |
|
111 | - */ |
|
112 | - public function flush() |
|
113 | - { |
|
114 | - $this->_removeDirectory($this->_sFolder); |
|
115 | - } |
|
116 | - |
|
117 | - /** |
|
118 | - * |
|
119 | - * |
|
120 | - * @access public |
|
121 | - * @param string $sName name of the session |
|
122 | - * @return mixed |
|
123 | - */ |
|
124 | - private function _getSubDirectory($sName) |
|
125 | - { |
|
126 | - if (!file_exists($this->_sFolder.substr(md5($sName), 0, 2).DIRECTORY_SEPARATOR.substr(md5($sName), 2, 2))) { |
|
127 | - |
|
128 | - mkdir($this->_sFolder.substr(md5($sName), 0, 2).DIRECTORY_SEPARATOR.substr(md5($sName), 2, 2), 0777, true); |
|
129 | - } |
|
130 | - |
|
131 | - return substr(md5($sName), 0, 2).DIRECTORY_SEPARATOR.substr(md5($sName), 2, 2).DIRECTORY_SEPARATOR; |
|
132 | - } |
|
133 | - |
|
134 | - /** |
|
135 | - * remove a directory recursivly |
|
136 | - * |
|
137 | - * @access private |
|
138 | - * @param string $sName nom du répertoire |
|
139 | - * @return void |
|
140 | - */ |
|
141 | - private function _removeDirectory($sName) |
|
142 | - { |
|
143 | - if ($rDirectory = opendir($sName)) { |
|
144 | - |
|
145 | - while (($sFile = readdir($rDirectory)) !== false) { |
|
146 | - |
|
147 | - if ($sFile > '0' && filetype($sName.$sFile) == "file") { unlink($sName.$sFile); } elseif ($sFile > '0' && filetype($sName.$sFile) == "dir") { remove_dir($sName.$sFile."\\"); } |
|
148 | - } |
|
149 | - |
|
150 | - closedir($rDirectory); |
|
151 | - rmdir($sName); |
|
152 | - } |
|
153 | - } |
|
33 | + /** |
|
34 | + * var containe this folder of cache |
|
35 | + * |
|
36 | + * @access private |
|
37 | + * @var string |
|
38 | + */ |
|
39 | + private $_sFolder = ''; |
|
40 | + |
|
41 | + /** |
|
42 | + * constructor |
|
43 | + * |
|
44 | + * @access public |
|
45 | + */ |
|
46 | + public function __construct() |
|
47 | + { |
|
48 | + $this->_sFolder = str_replace('bundles'.DIRECTORY_SEPARATOR.'lib'.DIRECTORY_SEPARATOR.'Cache', CACHE_DIR, __DIR__).DIRECTORY_SEPARATOR; |
|
49 | + } |
|
50 | + |
|
51 | + /** |
|
52 | + * set a value |
|
53 | + * |
|
54 | + * @access public |
|
55 | + * @param string $sName name of the session |
|
56 | + * @param mixed $mValue value of this sesion var |
|
57 | + * @param int $iFlag flags |
|
58 | + * @param int $iExpire expiration of cache |
|
59 | + * @return \Venus\lib\Cache\File |
|
60 | + */ |
|
61 | + public function set(string $sName, $mValue, int $iFlag, int $iExpire) |
|
62 | + { |
|
63 | + file_put_contents($this->_sFolder.$this->_getSubDirectory($sName).md5($sName).'.fil.cac', serialize($mValue)); |
|
64 | + return $this; |
|
65 | + } |
|
66 | + |
|
67 | + /** |
|
68 | + * get a value |
|
69 | + * |
|
70 | + * @access public |
|
71 | + * @param string $sName name of the session |
|
72 | + * @param int $iFlags flags |
|
73 | + * @param int $iTimeout expiration of cache |
|
74 | + * @return mixed |
|
75 | + */ |
|
76 | + public function get(string $sName, int &$iFlags = null, int $iTimeout = 0) |
|
77 | + { |
|
78 | + if ($iTimeout > 0 && file_exists($this->_sFolder.$this->_getSubDirectory($sName).md5($sName).'.fil.cac') |
|
79 | + && time() - filemtime($this->_sFolder.$this->_getSubDirectory($sName).md5($sName).'.fil.cac') > $iTimeout) { |
|
80 | + |
|
81 | + unlink($this->_sFolder.$this->_getSubDirectory($sName).md5($sName).'.fil.cac'); |
|
82 | + } |
|
83 | + |
|
84 | + if (file_exists($this->_sFolder.$this->_getSubDirectory($sName).md5($sName).'.fil.cac')) { |
|
85 | + |
|
86 | + return unserialize(file_get_contents($this->_sFolder . $this->_getSubDirectory($sName) . md5($sName) . '.fil.cac')); |
|
87 | + } else { |
|
88 | + |
|
89 | + return false; |
|
90 | + } |
|
91 | + } |
|
92 | + |
|
93 | + /** |
|
94 | + * delete a value |
|
95 | + * |
|
96 | + * @access public |
|
97 | + * @param string $sName name of the session |
|
98 | + * @return mixed |
|
99 | + */ |
|
100 | + public function delete(string $sName) |
|
101 | + { |
|
102 | + return unlink($this->_sFolder.$this->_getSubDirectory($sName).md5($sName).'.fil.cac'); |
|
103 | + } |
|
104 | + |
|
105 | + /** |
|
106 | + * flush the cache |
|
107 | + * |
|
108 | + * @access public |
|
109 | + * @param string $sName name of the session |
|
110 | + * @return mixed |
|
111 | + */ |
|
112 | + public function flush() |
|
113 | + { |
|
114 | + $this->_removeDirectory($this->_sFolder); |
|
115 | + } |
|
116 | + |
|
117 | + /** |
|
118 | + * |
|
119 | + * |
|
120 | + * @access public |
|
121 | + * @param string $sName name of the session |
|
122 | + * @return mixed |
|
123 | + */ |
|
124 | + private function _getSubDirectory($sName) |
|
125 | + { |
|
126 | + if (!file_exists($this->_sFolder.substr(md5($sName), 0, 2).DIRECTORY_SEPARATOR.substr(md5($sName), 2, 2))) { |
|
127 | + |
|
128 | + mkdir($this->_sFolder.substr(md5($sName), 0, 2).DIRECTORY_SEPARATOR.substr(md5($sName), 2, 2), 0777, true); |
|
129 | + } |
|
130 | + |
|
131 | + return substr(md5($sName), 0, 2).DIRECTORY_SEPARATOR.substr(md5($sName), 2, 2).DIRECTORY_SEPARATOR; |
|
132 | + } |
|
133 | + |
|
134 | + /** |
|
135 | + * remove a directory recursivly |
|
136 | + * |
|
137 | + * @access private |
|
138 | + * @param string $sName nom du répertoire |
|
139 | + * @return void |
|
140 | + */ |
|
141 | + private function _removeDirectory($sName) |
|
142 | + { |
|
143 | + if ($rDirectory = opendir($sName)) { |
|
144 | + |
|
145 | + while (($sFile = readdir($rDirectory)) !== false) { |
|
146 | + |
|
147 | + if ($sFile > '0' && filetype($sName.$sFile) == "file") { unlink($sName.$sFile); } elseif ($sFile > '0' && filetype($sName.$sFile) == "dir") { remove_dir($sName.$sFile."\\"); } |
|
148 | + } |
|
149 | + |
|
150 | + closedir($rDirectory); |
|
151 | + rmdir($sName); |
|
152 | + } |
|
153 | + } |
|
154 | 154 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * flush the cache |
94 | 94 | * |
95 | 95 | * @access public |
96 | - * @return mixed |
|
96 | + * @return boolean |
|
97 | 97 | */ |
98 | 98 | public function flush() |
99 | 99 | { |
@@ -129,9 +129,8 @@ discard block |
||
129 | 129 | * @access public |
130 | 130 | * @param string $sName name of the session |
131 | 131 | * @param mixed $mValue value of this sesion var |
132 | - * @param int $iFlag unused |
|
133 | 132 | * @param int $iExpire expiration of cache |
134 | - * @return mixed |
|
133 | + * @return Apc |
|
135 | 134 | */ |
136 | 135 | public function add(string $sName, $mValue, int $iExpire = false) |
137 | 136 | { |
@@ -32,109 +32,109 @@ |
||
32 | 32 | */ |
33 | 33 | class Redis extends RealRedis implements CacheInterface |
34 | 34 | { |
35 | - /** |
|
36 | - * constructor with the connection to Redis |
|
37 | - * |
|
38 | - * @access public |
|
39 | - * @param $oConf |
|
40 | - * @throws \Exception |
|
41 | - * @internal param string $sName name of the session |
|
42 | - * @internal param int $iFlags flags |
|
43 | - * @internal param int $iTimeout expiration of cache |
|
44 | - */ |
|
45 | - public function __construct($oConf) |
|
46 | - { |
|
47 | - if (!$this->connect($oConf->host, $oConf->port)) { |
|
35 | + /** |
|
36 | + * constructor with the connection to Redis |
|
37 | + * |
|
38 | + * @access public |
|
39 | + * @param $oConf |
|
40 | + * @throws \Exception |
|
41 | + * @internal param string $sName name of the session |
|
42 | + * @internal param int $iFlags flags |
|
43 | + * @internal param int $iTimeout expiration of cache |
|
44 | + */ |
|
45 | + public function __construct($oConf) |
|
46 | + { |
|
47 | + if (!$this->connect($oConf->host, $oConf->port)) { |
|
48 | 48 | |
49 | - throw new \Exception('Redis server unavailable'); |
|
50 | - } |
|
49 | + throw new \Exception('Redis server unavailable'); |
|
50 | + } |
|
51 | 51 | |
52 | - // Select the REDIS db index |
|
53 | - $this->select($oConf->index); |
|
54 | - } |
|
52 | + // Select the REDIS db index |
|
53 | + $this->select($oConf->index); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * get a value |
|
58 | - * |
|
59 | - * @access public |
|
60 | - * @param string $sName name of the session |
|
61 | - * @param int $iFlags flags |
|
62 | - * @param int $iTimeout expiration of cache |
|
63 | - * @return mixed |
|
64 | - */ |
|
65 | - public function get(string $sName, int &$iFlags = null, int $iTimeout = 0) |
|
66 | - { |
|
67 | - return parent::get($sName); |
|
68 | - } |
|
56 | + /** |
|
57 | + * get a value |
|
58 | + * |
|
59 | + * @access public |
|
60 | + * @param string $sName name of the session |
|
61 | + * @param int $iFlags flags |
|
62 | + * @param int $iTimeout expiration of cache |
|
63 | + * @return mixed |
|
64 | + */ |
|
65 | + public function get(string $sName, int &$iFlags = null, int $iTimeout = 0) |
|
66 | + { |
|
67 | + return parent::get($sName); |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * set a value |
|
72 | - * |
|
73 | - * @access public |
|
74 | - * @param string $sName name of the session |
|
75 | - * @param mixed $mValue value of this sesion var |
|
76 | - * @param int $iFlag unused |
|
77 | - * @param int $iExpire expiration of cache |
|
78 | - * @return \Venus\lib\Cache\Apc |
|
79 | - */ |
|
80 | - public function set(string $sName, $mValue, int $iFlag = 0, int $iExpire = false) |
|
81 | - { |
|
82 | - if ($iExpire === false) { |
|
70 | + /** |
|
71 | + * set a value |
|
72 | + * |
|
73 | + * @access public |
|
74 | + * @param string $sName name of the session |
|
75 | + * @param mixed $mValue value of this sesion var |
|
76 | + * @param int $iFlag unused |
|
77 | + * @param int $iExpire expiration of cache |
|
78 | + * @return \Venus\lib\Cache\Apc |
|
79 | + */ |
|
80 | + public function set(string $sName, $mValue, int $iFlag = 0, int $iExpire = false) |
|
81 | + { |
|
82 | + if ($iExpire === false) { |
|
83 | 83 | |
84 | - return parent::set($sName, $mValue); |
|
85 | - } |
|
86 | - else { |
|
84 | + return parent::set($sName, $mValue); |
|
85 | + } |
|
86 | + else { |
|
87 | 87 | |
88 | - return parent::setex($sName, $iExpire, $mValue); |
|
89 | - } |
|
90 | - } |
|
88 | + return parent::setex($sName, $iExpire, $mValue); |
|
89 | + } |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * flush the cache |
|
94 | - * |
|
95 | - * @access public |
|
96 | - * @return mixed |
|
97 | - */ |
|
98 | - public function flush() |
|
99 | - { |
|
100 | - return false; |
|
101 | - } |
|
92 | + /** |
|
93 | + * flush the cache |
|
94 | + * |
|
95 | + * @access public |
|
96 | + * @return mixed |
|
97 | + */ |
|
98 | + public function flush() |
|
99 | + { |
|
100 | + return false; |
|
101 | + } |
|
102 | 102 | |
103 | - /** |
|
104 | - * delete a value |
|
105 | - * |
|
106 | - * @access public |
|
107 | - * @param string $sName name of the session |
|
108 | - * @return mixed |
|
109 | - */ |
|
110 | - public function delete(string $sName) |
|
111 | - { |
|
112 | - return $this->del($sName); |
|
113 | - } |
|
103 | + /** |
|
104 | + * delete a value |
|
105 | + * |
|
106 | + * @access public |
|
107 | + * @param string $sName name of the session |
|
108 | + * @return mixed |
|
109 | + */ |
|
110 | + public function delete(string $sName) |
|
111 | + { |
|
112 | + return $this->del($sName); |
|
113 | + } |
|
114 | 114 | |
115 | - /** |
|
116 | - * close the redis connecction |
|
117 | - * |
|
118 | - * @access public |
|
119 | - * @return mixed |
|
120 | - */ |
|
121 | - public function __sleep() |
|
122 | - { |
|
123 | - $this->close(); |
|
124 | - } |
|
115 | + /** |
|
116 | + * close the redis connecction |
|
117 | + * |
|
118 | + * @access public |
|
119 | + * @return mixed |
|
120 | + */ |
|
121 | + public function __sleep() |
|
122 | + { |
|
123 | + $this->close(); |
|
124 | + } |
|
125 | 125 | |
126 | - /** |
|
127 | - * add |
|
128 | - * |
|
129 | - * @access public |
|
130 | - * @param string $sName name of the session |
|
131 | - * @param mixed $mValue value of this sesion var |
|
132 | - * @param int $iFlag unused |
|
133 | - * @param int $iExpire expiration of cache |
|
134 | - * @return mixed |
|
135 | - */ |
|
136 | - public function add(string $sName, $mValue, int $iExpire = false) |
|
137 | - { |
|
138 | - return $this->set($sName, $mValue, 0, $iExpire); |
|
139 | - } |
|
126 | + /** |
|
127 | + * add |
|
128 | + * |
|
129 | + * @access public |
|
130 | + * @param string $sName name of the session |
|
131 | + * @param mixed $mValue value of this sesion var |
|
132 | + * @param int $iFlag unused |
|
133 | + * @param int $iExpire expiration of cache |
|
134 | + * @return mixed |
|
135 | + */ |
|
136 | + public function add(string $sName, $mValue, int $iExpire = false) |
|
137 | + { |
|
138 | + return $this->set($sName, $mValue, 0, $iExpire); |
|
139 | + } |
|
140 | 140 | } |
@@ -62,7 +62,7 @@ |
||
62 | 62 | * @param int $iTimeout expiration of cache |
63 | 63 | * @return mixed |
64 | 64 | */ |
65 | - public function get(string $sName, int &$iFlags = null, int $iTimeout = 0) |
|
65 | + public function get(string $sName, int&$iFlags = null, int $iTimeout = 0) |
|
66 | 66 | { |
67 | 67 | return parent::get($sName); |
68 | 68 | } |
@@ -60,8 +60,7 @@ |
||
60 | 60 | echo "\n\n"; |
61 | 61 | echo " > Check realized on ".$options['a']; |
62 | 62 | echo "\n\n"; |
63 | - } |
|
64 | - else { |
|
63 | + } else { |
|
65 | 64 | echo "\n\n"; |
66 | 65 | echo Bash::setBackground(" ", 'red'); |
67 | 66 | echo Bash::setBackground(" [WARNING] A web server is not used ", 'red'); |
@@ -196,8 +196,7 @@ discard block |
||
196 | 196 | if ($mReturn === 403) { |
197 | 197 | |
198 | 198 | $this->_getPage403(); |
199 | - } |
|
200 | - else if ($mReturn === true) { |
|
199 | + } else if ($mReturn === true) { |
|
201 | 200 | |
202 | 201 | if (isset($oRoute->cache)) { $this->_checkCache($oRoute->cache); } |
203 | 202 | |
@@ -212,8 +211,7 @@ discard block |
||
212 | 211 | } |
213 | 212 | } else if (Request::isCliRequest()) { |
214 | 213 | |
215 | - if (isset($_SERVER['argv'])) { $aArguments = $_SERVER['argv']; } |
|
216 | - else { $aArguments = $argv; } |
|
214 | + if (isset($_SERVER['argv'])) { $aArguments = $_SERVER['argv']; } else { $aArguments = $argv; } |
|
217 | 215 | |
218 | 216 | define('PORTAL', 'Batch'); |
219 | 217 | set_include_path(get_include_path().PATH_SEPARATOR.'src'.PATH_SEPARATOR.PORTAL.PATH_SEPARATOR.'public'); |
@@ -315,8 +313,7 @@ discard block |
||
315 | 313 | } |
316 | 314 | } |
317 | 315 | } |
318 | - } |
|
319 | - else if (defined('STDIN')) { |
|
316 | + } else if (defined('STDIN')) { |
|
320 | 317 | |
321 | 318 | $oBatch = Config::get('Route')->batch->script->{$sRoute}; |
322 | 319 | echo $this->_loadController($oBatch->controller, $oBatch->action, $aParams); |
@@ -378,8 +375,7 @@ discard block |
||
378 | 375 | }, |
379 | 376 | $sRoute |
380 | 377 | ); |
381 | - } |
|
382 | - else { |
|
378 | + } else { |
|
383 | 379 | |
384 | 380 | $sFinalRoute = '.*'; |
385 | 381 | } |
@@ -429,8 +425,7 @@ discard block |
||
429 | 425 | |
430 | 426 | $oMobileDetect = new \Mobile_Detect; |
431 | 427 | |
432 | - if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
433 | - else { $sCacheExt = ''; } |
|
428 | + if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } else { $sCacheExt = ''; } |
|
434 | 429 | |
435 | 430 | $mCacheReturn = Cache::get($RequestUri.$sCacheExt, $oRoute->cache->max_age); |
436 | 431 | |
@@ -460,8 +455,7 @@ discard block |
||
460 | 455 | |
461 | 456 | header('Content-type: image/jpeg'); |
462 | 457 | } |
463 | - } |
|
464 | - else { |
|
458 | + } else { |
|
465 | 459 | |
466 | 460 | header('Content-type: text/html; charset='.$sCharset.''); |
467 | 461 | } |
@@ -504,8 +498,7 @@ discard block |
||
504 | 498 | $mReturn = $this->_loadController($oController, $sActionName, $aEntries); |
505 | 499 | |
506 | 500 | } |
507 | - } |
|
508 | - else { |
|
501 | + } else { |
|
509 | 502 | |
510 | 503 | $mReturn = $this->_loadController($oController, $sActionName, $aEntries); |
511 | 504 | } |
@@ -517,8 +510,7 @@ discard block |
||
517 | 510 | $mReturn = json_encode($mReturn, JSON_PRETTY_PRINT); |
518 | 511 | } |
519 | 512 | } |
520 | - } |
|
521 | - else if (isset($oRoute->template) && isset($oRoute->layout) && $oRoute->layout === true) { |
|
513 | + } else if (isset($oRoute->template) && isset($oRoute->layout) && $oRoute->layout === true) { |
|
522 | 514 | |
523 | 515 | define('PORTAL', preg_replace('/^\\\\Venus\\\\src\\\\([a-zA-Z0-9_]+)\\\\.+$/', '$1', $oRoute->template)); |
524 | 516 | set_include_path(get_include_path().PATH_SEPARATOR.'src'.PATH_SEPARATOR.PORTAL.PATH_SEPARATOR.'public'); |
@@ -535,8 +527,7 @@ discard block |
||
535 | 527 | |
536 | 528 | $mReturn = $oLayout->assign('model', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.PORTAL.DIRECTORY_SEPARATOR.'View'.DIRECTORY_SEPARATOR.$oRoute->template.'.tpl') |
537 | 529 | ->fetch(); |
538 | - } |
|
539 | - else if (isset($oRoute->template)) { |
|
530 | + } else if (isset($oRoute->template)) { |
|
540 | 531 | |
541 | 532 | define('PORTAL', preg_replace('/^\\\\Venus\\\\src\\\\([a-zA-Z0-9_]+)\\\\.+$/', '$1', $oRoute->template)); |
542 | 533 | set_include_path(get_include_path().PATH_SEPARATOR.'src'.PATH_SEPARATOR.PORTAL.PATH_SEPARATOR.'public'); |
@@ -560,8 +551,7 @@ discard block |
||
560 | 551 | |
561 | 552 | $oMobileDetect = new \Mobile_Detect; |
562 | 553 | |
563 | - if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
564 | - else { $sCacheExt = ''; } |
|
554 | + if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } else { $sCacheExt = ''; } |
|
565 | 555 | |
566 | 556 | if (defined('COMPRESS_HTML') && COMPRESS_HTML) { |
567 | 557 | |
@@ -615,8 +605,7 @@ discard block |
||
615 | 605 | |
616 | 606 | $oMobileDetect = new \Mobile_Detect; |
617 | 607 | |
618 | - if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
619 | - else { $sCacheExt = ''; } |
|
608 | + if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } else { $sCacheExt = ''; } |
|
620 | 609 | |
621 | 610 | $mCacheReturn = Cache::get($sActionName.$sCacheExt, $aPhpDoc['Cache']['maxage']); |
622 | 611 | |
@@ -657,8 +646,7 @@ discard block |
||
657 | 646 | |
658 | 647 | $oMobileDetect = new \Mobile_Detect; |
659 | 648 | |
660 | - if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
661 | - else { $sCacheExt = ''; } |
|
649 | + if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } else { $sCacheExt = ''; } |
|
662 | 650 | |
663 | 651 | if (defined('COMPRESS_HTML') && COMPRESS_HTML) { |
664 | 652 |
@@ -42,749 +42,749 @@ |
||
42 | 42 | */ |
43 | 43 | class Router implements LoggerAwareInterface |
44 | 44 | { |
45 | - /** |
|
46 | - * The base Uri to construct the route |
|
47 | - * |
|
48 | - * @access private |
|
49 | - * @var string |
|
50 | - */ |
|
51 | - private $_sBaseUri = ''; |
|
52 | - |
|
53 | - /** |
|
54 | - * get the security of page |
|
55 | - * |
|
56 | - * @access private |
|
57 | - * @var \Venus\core\Security |
|
58 | - */ |
|
59 | - private $_oSecurity = null; |
|
60 | - |
|
61 | - /** |
|
62 | - * The Routes of the actual host |
|
63 | - * |
|
64 | - * @access private |
|
65 | - * @var object |
|
66 | - */ |
|
67 | - private $_oRoutes = null; |
|
68 | - |
|
69 | - /** |
|
70 | - * Logger |
|
71 | - * |
|
72 | - * @access private |
|
73 | - * @var object |
|
74 | - */ |
|
75 | - private $_oLogger = null; |
|
76 | - |
|
77 | - /** |
|
78 | - * constructor |
|
79 | - * |
|
80 | - * @access public |
|
81 | - */ |
|
82 | - public function __construct() |
|
83 | - { |
|
84 | - $oLogger = Debug::getInstance(); |
|
85 | - $this->setLogger($oLogger); |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * run the routeur |
|
90 | - * |
|
91 | - * @access public |
|
92 | - * @return null|boolean |
|
93 | - */ |
|
94 | - public function run() |
|
95 | - { |
|
96 | - date_default_timezone_set(Config::get('Const')->timezone); |
|
97 | - |
|
98 | - $this->_create_constant(); |
|
99 | - |
|
100 | - if (Request::isHttpRequest()) { |
|
45 | + /** |
|
46 | + * The base Uri to construct the route |
|
47 | + * |
|
48 | + * @access private |
|
49 | + * @var string |
|
50 | + */ |
|
51 | + private $_sBaseUri = ''; |
|
52 | + |
|
53 | + /** |
|
54 | + * get the security of page |
|
55 | + * |
|
56 | + * @access private |
|
57 | + * @var \Venus\core\Security |
|
58 | + */ |
|
59 | + private $_oSecurity = null; |
|
60 | + |
|
61 | + /** |
|
62 | + * The Routes of the actual host |
|
63 | + * |
|
64 | + * @access private |
|
65 | + * @var object |
|
66 | + */ |
|
67 | + private $_oRoutes = null; |
|
68 | + |
|
69 | + /** |
|
70 | + * Logger |
|
71 | + * |
|
72 | + * @access private |
|
73 | + * @var object |
|
74 | + */ |
|
75 | + private $_oLogger = null; |
|
76 | + |
|
77 | + /** |
|
78 | + * constructor |
|
79 | + * |
|
80 | + * @access public |
|
81 | + */ |
|
82 | + public function __construct() |
|
83 | + { |
|
84 | + $oLogger = Debug::getInstance(); |
|
85 | + $this->setLogger($oLogger); |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * run the routeur |
|
90 | + * |
|
91 | + * @access public |
|
92 | + * @return null|boolean |
|
93 | + */ |
|
94 | + public function run() |
|
95 | + { |
|
96 | + date_default_timezone_set(Config::get('Const')->timezone); |
|
97 | + |
|
98 | + $this->_create_constant(); |
|
99 | + |
|
100 | + if (Request::isHttpRequest()) { |
|
101 | 101 | |
102 | - // Search if a Less file exists |
|
103 | - if (defined('LESS_ACTIVE') && LESS_ACTIVE === true) { |
|
102 | + // Search if a Less file exists |
|
103 | + if (defined('LESS_ACTIVE') && LESS_ACTIVE === true) { |
|
104 | 104 | |
105 | - if (strstr($_SERVER['REQUEST_URI'], '.css') |
|
106 | - && file_exists(preg_replace('/\.css/', '.less', $_SERVER['REQUEST_URI']))) { |
|
105 | + if (strstr($_SERVER['REQUEST_URI'], '.css') |
|
106 | + && file_exists(preg_replace('/\.css/', '.less', $_SERVER['REQUEST_URI']))) { |
|
107 | 107 | |
108 | - Less::toCss($_SERVER['REQUEST_URI']); |
|
109 | - exit; |
|
110 | - } |
|
111 | - } |
|
108 | + Less::toCss($_SERVER['REQUEST_URI']); |
|
109 | + exit; |
|
110 | + } |
|
111 | + } |
|
112 | 112 | |
113 | - // Search if a typescript file exists |
|
114 | - if (defined('TYPESCRIPT_ACTIVE') && TYPESCRIPT_ACTIVE === true) { |
|
113 | + // Search if a typescript file exists |
|
114 | + if (defined('TYPESCRIPT_ACTIVE') && TYPESCRIPT_ACTIVE === true) { |
|
115 | 115 | |
116 | - if (strstr($_SERVER['REQUEST_URI'], '.js') |
|
117 | - && file_exists(preg_replace('/\.js/', '.ts', $_SERVER['REQUEST_URI']))) { |
|
116 | + if (strstr($_SERVER['REQUEST_URI'], '.js') |
|
117 | + && file_exists(preg_replace('/\.js/', '.ts', $_SERVER['REQUEST_URI']))) { |
|
118 | 118 | |
119 | - Typescript::toJs($_SERVER['REQUEST_URI']); |
|
120 | - exit; |
|
121 | - } |
|
122 | - } |
|
119 | + Typescript::toJs($_SERVER['REQUEST_URI']); |
|
120 | + exit; |
|
121 | + } |
|
122 | + } |
|
123 | 123 | |
124 | - // Search public files in all plugins |
|
125 | - if ($_SERVER['REQUEST_URI'] !== '/') { |
|
124 | + // Search public files in all plugins |
|
125 | + if ($_SERVER['REQUEST_URI'] !== '/') { |
|
126 | 126 | |
127 | - foreach (Config::get('Plugins')->list as $iKey => $sPlugin) { |
|
127 | + foreach (Config::get('Plugins')->list as $iKey => $sPlugin) { |
|
128 | 128 | |
129 | - if (file_exists(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.$_SERVER['REQUEST_URI'])) { |
|
129 | + if (file_exists(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.$_SERVER['REQUEST_URI'])) { |
|
130 | 130 | |
131 | - echo file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.$_SERVER['REQUEST_URI']); |
|
132 | - exit; |
|
133 | - } else if (strstr($_SERVER['REQUEST_URI'], '.css') |
|
134 | - && file_exists(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.preg_replace('/\.css/', '.less', $_SERVER['REQUEST_URI']))) { |
|
131 | + echo file_get_contents(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.$_SERVER['REQUEST_URI']); |
|
132 | + exit; |
|
133 | + } else if (strstr($_SERVER['REQUEST_URI'], '.css') |
|
134 | + && file_exists(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.preg_replace('/\.css/', '.less', $_SERVER['REQUEST_URI']))) { |
|
135 | 135 | |
136 | - Less::toCss(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.preg_replace('/\.css/', '.less', $_SERVER['REQUEST_URI'])); |
|
137 | - exit; |
|
138 | - } else if (strstr($_SERVER['REQUEST_URI'], '.js') |
|
139 | - && file_exists(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.preg_replace('/\.js/', '.ts', $_SERVER['REQUEST_URI']))) { |
|
136 | + Less::toCss(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.preg_replace('/\.css/', '.less', $_SERVER['REQUEST_URI'])); |
|
137 | + exit; |
|
138 | + } else if (strstr($_SERVER['REQUEST_URI'], '.js') |
|
139 | + && file_exists(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.preg_replace('/\.js/', '.ts', $_SERVER['REQUEST_URI']))) { |
|
140 | 140 | |
141 | - Typescript::toJs(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.preg_replace('/\.js/', '.ts', $_SERVER['REQUEST_URI'])); |
|
142 | - exit; |
|
143 | - } |
|
144 | - } |
|
145 | - } |
|
141 | + Typescript::toJs(__DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'plugins'.DIRECTORY_SEPARATOR.$sPlugin.DIRECTORY_SEPARATOR.'public'.preg_replace('/\.js/', '.ts', $_SERVER['REQUEST_URI'])); |
|
142 | + exit; |
|
143 | + } |
|
144 | + } |
|
145 | + } |
|
146 | 146 | |
147 | - foreach (Config::get('Route') as $sMultiHost => $oHost) { |
|
147 | + foreach (Config::get('Route') as $sMultiHost => $oHost) { |
|
148 | 148 | |
149 | - foreach (explode(',', $sMultiHost) as $sHost) { |
|
149 | + foreach (explode(',', $sMultiHost) as $sHost) { |
|
150 | 150 | |
151 | - if ((!strstr($sHost, '/') && $sHost == $_SERVER['HTTP_HOST']) || (strstr($sHost, '/') |
|
152 | - && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost))) { |
|
151 | + if ((!strstr($sHost, '/') && $sHost == $_SERVER['HTTP_HOST']) || (strstr($sHost, '/') |
|
152 | + && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost))) { |
|
153 | 153 | |
154 | - $this->_oRoutes = $oHost; |
|
154 | + $this->_oRoutes = $oHost; |
|
155 | 155 | |
156 | - if (strstr($sHost, '/') |
|
157 | - && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost)) { |
|
156 | + if (strstr($sHost, '/') |
|
157 | + && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost)) { |
|
158 | 158 | |
159 | - $this->_sBaseUri = preg_replace('#^[^/]+#', '', $sHost); |
|
160 | - } |
|
159 | + $this->_sBaseUri = preg_replace('#^[^/]+#', '', $sHost); |
|
160 | + } |
|
161 | 161 | |
162 | - if (isset($oHost->location)) { |
|
162 | + if (isset($oHost->location)) { |
|
163 | 163 | |
164 | - header('Status: 301 Moved Permanently', false, 301); |
|
165 | - header('Location: '.$oHost->location); |
|
166 | - exit; |
|
167 | - } else if (preg_match('#getCss\?#', $_SERVER['REQUEST_URI'])) { |
|
164 | + header('Status: 301 Moved Permanently', false, 301); |
|
165 | + header('Location: '.$oHost->location); |
|
166 | + exit; |
|
167 | + } else if (preg_match('#getCss\?#', $_SERVER['REQUEST_URI'])) { |
|
168 | 168 | |
169 | - foreach ($_GET as $sKey => $sValue) { |
|
169 | + foreach ($_GET as $sKey => $sValue) { |
|
170 | 170 | |
171 | - if (file_exists(str_replace(DIRECTORY_SEPARATOR.'core', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR, __DIR__).$sKey.'.css')) { |
|
171 | + if (file_exists(str_replace(DIRECTORY_SEPARATOR.'core', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR, __DIR__).$sKey.'.css')) { |
|
172 | 172 | |
173 | - echo file_get_contents(str_replace(DIRECTORY_SEPARATOR.'core', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR, __DIR__).$sKey.'.css')."\n"; |
|
174 | - } |
|
175 | - } |
|
173 | + echo file_get_contents(str_replace(DIRECTORY_SEPARATOR.'core', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR, __DIR__).$sKey.'.css')."\n"; |
|
174 | + } |
|
175 | + } |
|
176 | 176 | |
177 | - exit; |
|
178 | - } else if (preg_match('#getJs\?#', $_SERVER['REQUEST_URI'])) { |
|
177 | + exit; |
|
178 | + } else if (preg_match('#getJs\?#', $_SERVER['REQUEST_URI'])) { |
|
179 | 179 | |
180 | - foreach ($_GET as $sKey => $sValue) { |
|
180 | + foreach ($_GET as $sKey => $sValue) { |
|
181 | 181 | |
182 | - if (file_exists(str_replace(DIRECTORY_SEPARATOR.'core', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR, __DIR__).$sKey.'.js')) { |
|
182 | + if (file_exists(str_replace(DIRECTORY_SEPARATOR.'core', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR, __DIR__).$sKey.'.js')) { |
|
183 | 183 | |
184 | - echo file_get_contents(str_replace(DIRECTORY_SEPARATOR.'core', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR, __DIR__).$sKey.'.js')."\n"; |
|
185 | - } |
|
186 | - } |
|
184 | + echo file_get_contents(str_replace(DIRECTORY_SEPARATOR.'core', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR, __DIR__).$sKey.'.js')."\n"; |
|
185 | + } |
|
186 | + } |
|
187 | 187 | |
188 | - exit; |
|
189 | - } else if (isset($oHost->routes)) { |
|
188 | + exit; |
|
189 | + } else if (isset($oHost->routes)) { |
|
190 | 190 | |
191 | - foreach ($oHost->routes as $sKey => $oRoute) { |
|
191 | + foreach ($oHost->routes as $sKey => $oRoute) { |
|
192 | 192 | |
193 | - $mReturn = $this->_route($oRoute, $_SERVER['REQUEST_URI']); |
|
193 | + $mReturn = $this->_route($oRoute, $_SERVER['REQUEST_URI']); |
|
194 | 194 | |
195 | - if ($mReturn === 403) { |
|
195 | + if ($mReturn === 403) { |
|
196 | 196 | |
197 | - $this->_getPage403(); |
|
198 | - } |
|
199 | - else if ($mReturn === true) { |
|
197 | + $this->_getPage403(); |
|
198 | + } |
|
199 | + else if ($mReturn === true) { |
|
200 | 200 | |
201 | - if (isset($oRoute->cache)) { $this->_checkCache($oRoute->cache); } |
|
201 | + if (isset($oRoute->cache)) { $this->_checkCache($oRoute->cache); } |
|
202 | 202 | |
203 | - return true; |
|
204 | - } |
|
205 | - } |
|
203 | + return true; |
|
204 | + } |
|
205 | + } |
|
206 | 206 | |
207 | - $this->_getPage404(); |
|
208 | - } |
|
209 | - } |
|
210 | - } |
|
211 | - } |
|
212 | - } else if (Request::isCliRequest()) { |
|
207 | + $this->_getPage404(); |
|
208 | + } |
|
209 | + } |
|
210 | + } |
|
211 | + } |
|
212 | + } else if (Request::isCliRequest()) { |
|
213 | 213 | |
214 | - if (isset($_SERVER['argv'])) { $aArguments = $_SERVER['argv']; } |
|
215 | - else { $aArguments = $argv; } |
|
214 | + if (isset($_SERVER['argv'])) { $aArguments = $_SERVER['argv']; } |
|
215 | + else { $aArguments = $argv; } |
|
216 | 216 | |
217 | - define('PORTAL', 'Batch'); |
|
218 | - set_include_path(get_include_path().PATH_SEPARATOR.'src'.PATH_SEPARATOR.PORTAL.PATH_SEPARATOR.'public'); |
|
217 | + define('PORTAL', 'Batch'); |
|
218 | + set_include_path(get_include_path().PATH_SEPARATOR.'src'.PATH_SEPARATOR.PORTAL.PATH_SEPARATOR.'public'); |
|
219 | 219 | |
220 | - if (!isset($aArguments[1]) && strstr($aArguments[0], '/phpunit')) { |
|
220 | + if (!isset($aArguments[1]) && strstr($aArguments[0], '/phpunit')) { |
|
221 | 221 | |
222 | - $sBatchName = "phpunit"; |
|
223 | - $aArguments[0] = "bin/console"; |
|
224 | - $aArguments[1] = "phpunit"; |
|
225 | - } else { |
|
226 | - $sBatchName = $aArguments[1]; |
|
227 | - } |
|
222 | + $sBatchName = "phpunit"; |
|
223 | + $aArguments[0] = "bin/console"; |
|
224 | + $aArguments[1] = "phpunit"; |
|
225 | + } else { |
|
226 | + $sBatchName = $aArguments[1]; |
|
227 | + } |
|
228 | 228 | |
229 | - if (isset(Config::get('Route')->batch->script->{$sBatchName})) { |
|
229 | + if (isset(Config::get('Route')->batch->script->{$sBatchName})) { |
|
230 | 230 | |
231 | - $oBatch = Config::get('Route')->batch->script->{$sBatchName}; |
|
232 | - array_shift($aArguments); |
|
233 | - array_shift($aArguments); |
|
231 | + $oBatch = Config::get('Route')->batch->script->{$sBatchName}; |
|
232 | + array_shift($aArguments); |
|
233 | + array_shift($aArguments); |
|
234 | 234 | |
235 | - $aOptions = array(); |
|
235 | + $aOptions = array(); |
|
236 | 236 | |
237 | - while (count($aArguments) > 0) { |
|
237 | + while (count($aArguments) > 0) { |
|
238 | 238 | |
239 | - if (preg_match('/^-[a-z]/', $aArguments[0])) { |
|
239 | + if (preg_match('/^-[a-z]/', $aArguments[0])) { |
|
240 | 240 | |
241 | - $sOptionName = str_replace('-', '', $aArguments[0]); |
|
241 | + $sOptionName = str_replace('-', '', $aArguments[0]); |
|
242 | 242 | |
243 | - if (isset($aArguments[1])) { |
|
244 | - $sOptionValue = $aArguments[1]; |
|
245 | - } else { |
|
246 | - $sOptionValue = ''; |
|
247 | - } |
|
243 | + if (isset($aArguments[1])) { |
|
244 | + $sOptionValue = $aArguments[1]; |
|
245 | + } else { |
|
246 | + $sOptionValue = ''; |
|
247 | + } |
|
248 | 248 | |
249 | - if (isset($oBatch->options->$sOptionName) && $oBatch->options->$sOptionName === false) { |
|
249 | + if (isset($oBatch->options->$sOptionName) && $oBatch->options->$sOptionName === false) { |
|
250 | 250 | |
251 | - $aOptions[$sOptionName] = true; |
|
252 | - array_shift($aArguments); |
|
253 | - } else if (isset($oBatch->options->$sOptionName) && ($oBatch->options->$sOptionName === 'string' |
|
254 | - || $oBatch->options->$sOptionName === 'int') |
|
255 | - ) { |
|
251 | + $aOptions[$sOptionName] = true; |
|
252 | + array_shift($aArguments); |
|
253 | + } else if (isset($oBatch->options->$sOptionName) && ($oBatch->options->$sOptionName === 'string' |
|
254 | + || $oBatch->options->$sOptionName === 'int') |
|
255 | + ) { |
|
256 | 256 | |
257 | - $aOptions[$sOptionName] = $sOptionValue; |
|
258 | - array_shift($aArguments); |
|
259 | - array_shift($aArguments); |
|
260 | - } else { |
|
257 | + $aOptions[$sOptionName] = $sOptionValue; |
|
258 | + array_shift($aArguments); |
|
259 | + array_shift($aArguments); |
|
260 | + } else { |
|
261 | 261 | |
262 | - array_shift($aArguments); |
|
263 | - } |
|
264 | - } else { |
|
262 | + array_shift($aArguments); |
|
263 | + } |
|
264 | + } else { |
|
265 | 265 | |
266 | - array_shift($aArguments); |
|
267 | - } |
|
268 | - } |
|
269 | - } |
|
266 | + array_shift($aArguments); |
|
267 | + } |
|
268 | + } |
|
269 | + } |
|
270 | 270 | |
271 | - if (isset($oBatch->controller) && isset($oBatch->action)) { |
|
271 | + if (isset($oBatch->controller) && isset($oBatch->action)) { |
|
272 | 272 | |
273 | - echo $this->_loadController($oBatch->controller, $oBatch->action, array($aOptions)); |
|
274 | - } else { |
|
273 | + echo $this->_loadController($oBatch->controller, $oBatch->action, array($aOptions)); |
|
274 | + } else { |
|
275 | 275 | |
276 | - if (Request::isCliRequest()) { |
|
276 | + if (Request::isCliRequest()) { |
|
277 | 277 | |
278 | - echo "Error : The batch not exists - please verify your Route or the name passed in your command name.\n"; |
|
279 | - } |
|
280 | - } |
|
278 | + echo "Error : The batch not exists - please verify your Route or the name passed in your command name.\n"; |
|
279 | + } |
|
280 | + } |
|
281 | 281 | |
282 | - } |
|
283 | - } |
|
282 | + } |
|
283 | + } |
|
284 | 284 | |
285 | - /** |
|
286 | - * run the routeur by the forwarsd metho (in the controller) |
|
287 | - * |
|
288 | - * @access public |
|
289 | - * @param string $sRoute route we wantload |
|
290 | - * @param array $aParams parameters to passe |
|
291 | - * @return void |
|
292 | - */ |
|
293 | - public function runByFoward(string $sRoute, array $aParams) |
|
294 | - { |
|
295 | - $this->_create_constant(); |
|
285 | + /** |
|
286 | + * run the routeur by the forwarsd metho (in the controller) |
|
287 | + * |
|
288 | + * @access public |
|
289 | + * @param string $sRoute route we wantload |
|
290 | + * @param array $aParams parameters to passe |
|
291 | + * @return void |
|
292 | + */ |
|
293 | + public function runByFoward(string $sRoute, array $aParams) |
|
294 | + { |
|
295 | + $this->_create_constant(); |
|
296 | 296 | |
297 | - if (isset($_SERVER) && isset($_SERVER['HTTP_HOST'])) { |
|
297 | + if (isset($_SERVER) && isset($_SERVER['HTTP_HOST'])) { |
|
298 | 298 | |
299 | - foreach (Config::get('Route') as $sHost => $oHost) { |
|
299 | + foreach (Config::get('Route') as $sHost => $oHost) { |
|
300 | 300 | |
301 | - if ((!strstr($sHost, '/') && $sHost == $_SERVER['HTTP_HOST']) |
|
302 | - || (strstr($sHost, '/') && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost))) { |
|
301 | + if ((!strstr($sHost, '/') && $sHost == $_SERVER['HTTP_HOST']) |
|
302 | + || (strstr($sHost, '/') && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost))) { |
|
303 | 303 | |
304 | - $this->_oRoutes = $oHost; |
|
304 | + $this->_oRoutes = $oHost; |
|
305 | 305 | |
306 | - if (strstr($sHost, '/') && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost)) { |
|
306 | + if (strstr($sHost, '/') && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost)) { |
|
307 | 307 | |
308 | - $this->_sBaseUri = preg_replace('#^[^/]+#', '', $sHost); |
|
309 | - } |
|
308 | + $this->_sBaseUri = preg_replace('#^[^/]+#', '', $sHost); |
|
309 | + } |
|
310 | 310 | |
311 | - foreach ($oHost->routes as $sKey => $oRoute) { |
|
311 | + foreach ($oHost->routes as $sKey => $oRoute) { |
|
312 | 312 | |
313 | - $this->_route($oRoute, $sRoute); |
|
314 | - } |
|
315 | - } |
|
316 | - } |
|
317 | - } |
|
318 | - else if (defined('STDIN')) { |
|
313 | + $this->_route($oRoute, $sRoute); |
|
314 | + } |
|
315 | + } |
|
316 | + } |
|
317 | + } |
|
318 | + else if (defined('STDIN')) { |
|
319 | 319 | |
320 | - $oBatch = Config::get('Route')->batch->script->{$sRoute}; |
|
321 | - echo $this->_loadController($oBatch->controller, $oBatch->action, $aParams); |
|
322 | - } |
|
323 | - } |
|
320 | + $oBatch = Config::get('Route')->batch->script->{$sRoute}; |
|
321 | + echo $this->_loadController($oBatch->controller, $oBatch->action, $aParams); |
|
322 | + } |
|
323 | + } |
|
324 | 324 | |
325 | - /** |
|
326 | - * run the error http page |
|
327 | - * |
|
328 | - * @access public |
|
329 | - * @param int iError http error |
|
330 | - * @return void |
|
331 | - */ |
|
332 | - public function runHttpErrorPage(int $iError) |
|
333 | - { |
|
334 | - $this->_create_constant(); |
|
325 | + /** |
|
326 | + * run the error http page |
|
327 | + * |
|
328 | + * @access public |
|
329 | + * @param int iError http error |
|
330 | + * @return void |
|
331 | + */ |
|
332 | + public function runHttpErrorPage(int $iError) |
|
333 | + { |
|
334 | + $this->_create_constant(); |
|
335 | 335 | |
336 | - if (isset($_SERVER) && isset($_SERVER['HTTP_HOST'])) { |
|
336 | + if (isset($_SERVER) && isset($_SERVER['HTTP_HOST'])) { |
|
337 | 337 | |
338 | - foreach (Config::get('Route') as $sHost => $oHost) { |
|
338 | + foreach (Config::get('Route') as $sHost => $oHost) { |
|
339 | 339 | |
340 | - if ((!strstr($sHost, '/') && $sHost == $_SERVER['HTTP_HOST']) |
|
341 | - || (strstr($sHost, '/') && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost))) { |
|
340 | + if ((!strstr($sHost, '/') && $sHost == $_SERVER['HTTP_HOST']) |
|
341 | + || (strstr($sHost, '/') && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost))) { |
|
342 | 342 | |
343 | - $this->_oRoutes = $oHost->routes; |
|
343 | + $this->_oRoutes = $oHost->routes; |
|
344 | 344 | |
345 | - if (strstr($sHost, '/') && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost)) { |
|
345 | + if (strstr($sHost, '/') && strstr($_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], $sHost)) { |
|
346 | 346 | |
347 | - $this->_sBaseUri = preg_replace('#^[^/]+#', '', $sHost); |
|
348 | - } |
|
347 | + $this->_sBaseUri = preg_replace('#^[^/]+#', '', $sHost); |
|
348 | + } |
|
349 | 349 | |
350 | - $sHttpErrorPageName = '_getPage'.iError; |
|
351 | - $this->$sHttpErrorPageName(); |
|
352 | - } |
|
353 | - } |
|
354 | - } |
|
355 | - } |
|
350 | + $sHttpErrorPageName = '_getPage'.iError; |
|
351 | + $this->$sHttpErrorPageName(); |
|
352 | + } |
|
353 | + } |
|
354 | + } |
|
355 | + } |
|
356 | 356 | |
357 | - /** |
|
358 | - * load a route |
|
359 | - * |
|
360 | - * @access private |
|
361 | - * @param \stdClass $oRoute one route |
|
362 | - * @param string $RequestUri URI |
|
363 | - * @return void |
|
364 | - */ |
|
365 | - private function _route(\stdClass $oRoute, string $RequestUri) |
|
366 | - { |
|
367 | - $sCharset = 'UTF-8'; |
|
357 | + /** |
|
358 | + * load a route |
|
359 | + * |
|
360 | + * @access private |
|
361 | + * @param \stdClass $oRoute one route |
|
362 | + * @param string $RequestUri URI |
|
363 | + * @return void |
|
364 | + */ |
|
365 | + private function _route(\stdClass $oRoute, string $RequestUri) |
|
366 | + { |
|
367 | + $sCharset = 'UTF-8'; |
|
368 | 368 | |
369 | - if (isset($oRoute->route)) { |
|
369 | + if (isset($oRoute->route)) { |
|
370 | 370 | |
371 | - $sRoute = str_replace("*", ".*", $oRoute->route); |
|
371 | + $sRoute = str_replace("*", ".*", $oRoute->route); |
|
372 | 372 | |
373 | - $sFinalRoute = preg_replace_callback( |
|
374 | - '|\[/{0,1}:([a-zA-Z_]+)\]|', |
|
375 | - function($aMatches) use ($oRoute) { |
|
376 | - return "/{0,1}(?P<".$aMatches[1].">".$oRoute->constraints->{$aMatches[1]}.")"; |
|
377 | - }, |
|
378 | - $sRoute |
|
379 | - ); |
|
380 | - } |
|
381 | - else { |
|
373 | + $sFinalRoute = preg_replace_callback( |
|
374 | + '|\[/{0,1}:([a-zA-Z_]+)\]|', |
|
375 | + function($aMatches) use ($oRoute) { |
|
376 | + return "/{0,1}(?P<".$aMatches[1].">".$oRoute->constraints->{$aMatches[1]}.")"; |
|
377 | + }, |
|
378 | + $sRoute |
|
379 | + ); |
|
380 | + } |
|
381 | + else { |
|
382 | 382 | |
383 | - $sFinalRoute = '.*'; |
|
384 | - } |
|
383 | + $sFinalRoute = '.*'; |
|
384 | + } |
|
385 | 385 | |
386 | - $RequestUri = preg_replace('/^([^?]+)\?.*$/', '$1', $RequestUri); |
|
387 | - $RequestUri = preg_replace('#^'.$this->_sBaseUri.'#', '', $RequestUri); |
|
386 | + $RequestUri = preg_replace('/^([^?]+)\?.*$/', '$1', $RequestUri); |
|
387 | + $RequestUri = preg_replace('#^'.$this->_sBaseUri.'#', '', $RequestUri); |
|
388 | 388 | |
389 | - if (preg_match('#^'.$sFinalRoute.'$#', $RequestUri, $aMatch)) { |
|
389 | + if (preg_match('#^'.$sFinalRoute.'$#', $RequestUri, $aMatch)) { |
|
390 | 390 | |
391 | - if (isset($oRoute->location)) { |
|
391 | + if (isset($oRoute->location)) { |
|
392 | 392 | |
393 | - $aParamEntries = array(); |
|
393 | + $aParamEntries = array(); |
|
394 | 394 | |
395 | - foreach ($oRoute->constraints as $sName => $sType) { |
|
395 | + foreach ($oRoute->constraints as $sName => $sType) { |
|
396 | 396 | |
397 | - if (isset($aMatch[$sName])) { |
|
397 | + if (isset($aMatch[$sName])) { |
|
398 | 398 | |
399 | - $aParamEntries[$sName] = $aMatch[$sName]; |
|
400 | - } |
|
401 | - } |
|
399 | + $aParamEntries[$sName] = $aMatch[$sName]; |
|
400 | + } |
|
401 | + } |
|
402 | 402 | |
403 | - $oUrlManager = new UrlManager; |
|
404 | - header('Status: 301 Moved Permanently', false, 301); |
|
405 | - header('Location: '.$oUrlManager->getUrl($oRoute->location, $aParamEntries)); |
|
406 | - exit; |
|
407 | - } |
|
403 | + $oUrlManager = new UrlManager; |
|
404 | + header('Status: 301 Moved Permanently', false, 301); |
|
405 | + header('Location: '.$oUrlManager->getUrl($oRoute->location, $aParamEntries)); |
|
406 | + exit; |
|
407 | + } |
|
408 | 408 | |
409 | - $this->_oSecurity = new Security; |
|
409 | + $this->_oSecurity = new Security; |
|
410 | 410 | |
411 | - if (!$this->_oSecurity->checkSecurity() !== null) { return 403; } |
|
411 | + if (!$this->_oSecurity->checkSecurity() !== null) { return 403; } |
|
412 | 412 | |
413 | - // create the $_GET by the URL |
|
413 | + // create the $_GET by the URL |
|
414 | 414 | |
415 | - foreach ($aMatch as $mKey => $sResults) { |
|
415 | + foreach ($aMatch as $mKey => $sResults) { |
|
416 | 416 | |
417 | - if (is_string($mKey)) { |
|
417 | + if (is_string($mKey)) { |
|
418 | 418 | |
419 | - $_GET[$mKey] = $sResults; |
|
420 | - } |
|
421 | - } |
|
419 | + $_GET[$mKey] = $sResults; |
|
420 | + } |
|
421 | + } |
|
422 | 422 | |
423 | - if (isset($oRoute->methods) && $oRoute->methods != $_SERVER['REQUEST_METHOD']) { return false; } |
|
423 | + if (isset($oRoute->methods) && $oRoute->methods != $_SERVER['REQUEST_METHOD']) { return false; } |
|
424 | 424 | |
425 | - if (isset($oRoute->schemes) && $oRoute->schemes == 'https' && !Request::isHttpsRequest()) { return false; } |
|
425 | + if (isset($oRoute->schemes) && $oRoute->schemes == 'https' && !Request::isHttpsRequest()) { return false; } |
|
426 | 426 | |
427 | - if (isset($oRoute->cache) && isset($oRoute->cache->max_age) && !isset($_GET['flush'])) { |
|
427 | + if (isset($oRoute->cache) && isset($oRoute->cache->max_age) && !isset($_GET['flush'])) { |
|
428 | 428 | |
429 | - $oMobileDetect = new \Mobile_Detect; |
|
429 | + $oMobileDetect = new \Mobile_Detect; |
|
430 | 430 | |
431 | - if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
432 | - else { $sCacheExt = ''; } |
|
431 | + if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
432 | + else { $sCacheExt = ''; } |
|
433 | 433 | |
434 | - $mCacheReturn = Cache::get($RequestUri.$sCacheExt, $oRoute->cache->max_age); |
|
434 | + $mCacheReturn = Cache::get($RequestUri.$sCacheExt, $oRoute->cache->max_age); |
|
435 | 435 | |
436 | - if ($mCacheReturn && count($_POST) < 1) { |
|
436 | + if ($mCacheReturn && count($_POST) < 1) { |
|
437 | 437 | |
438 | - echo $mCacheReturn; |
|
439 | - return true; |
|
440 | - } |
|
441 | - } |
|
438 | + echo $mCacheReturn; |
|
439 | + return true; |
|
440 | + } |
|
441 | + } |
|
442 | 442 | |
443 | - if (isset($oRoute->cache)) { $this->_checkCache($oRoute->cache); } |
|
443 | + if (isset($oRoute->cache)) { $this->_checkCache($oRoute->cache); } |
|
444 | 444 | |
445 | - if (isset($oRoute->controller)) { |
|
445 | + if (isset($oRoute->controller)) { |
|
446 | 446 | |
447 | - define('PORTAL', preg_replace('/^\\\\Venus\\\\src\\\\([a-zA-Z0-9_]+)\\\\.+$/', '$1', $oRoute->controller)); |
|
448 | - set_include_path(get_include_path().PATH_SEPARATOR.'src'.PATH_SEPARATOR.PORTAL.PATH_SEPARATOR.'public'); |
|
447 | + define('PORTAL', preg_replace('/^\\\\Venus\\\\src\\\\([a-zA-Z0-9_]+)\\\\.+$/', '$1', $oRoute->controller)); |
|
448 | + set_include_path(get_include_path().PATH_SEPARATOR.'src'.PATH_SEPARATOR.PORTAL.PATH_SEPARATOR.'public'); |
|
449 | 449 | |
450 | - if (isset($oRoute->content_type)) { |
|
450 | + if (isset($oRoute->content_type)) { |
|
451 | 451 | |
452 | - if ($oRoute->content_type == 'json') { |
|
452 | + if ($oRoute->content_type == 'json') { |
|
453 | 453 | |
454 | - header('Content-type: application/json; charset='.$sCharset.''); |
|
455 | - } else if ($oRoute->content_type == 'html') { |
|
454 | + header('Content-type: application/json; charset='.$sCharset.''); |
|
455 | + } else if ($oRoute->content_type == 'html') { |
|
456 | 456 | |
457 | - header('Content-type: text/html; charset='.$sCharset.''); |
|
458 | - } else if ($oRoute->content_type == 'jpeg') { |
|
457 | + header('Content-type: text/html; charset='.$sCharset.''); |
|
458 | + } else if ($oRoute->content_type == 'jpeg') { |
|
459 | 459 | |
460 | - header('Content-type: image/jpeg'); |
|
461 | - } |
|
462 | - } |
|
463 | - else { |
|
460 | + header('Content-type: image/jpeg'); |
|
461 | + } |
|
462 | + } |
|
463 | + else { |
|
464 | 464 | |
465 | - header('Content-type: text/html; charset='.$sCharset.''); |
|
466 | - } |
|
465 | + header('Content-type: text/html; charset='.$sCharset.''); |
|
466 | + } |
|
467 | 467 | |
468 | - $sControllerName = $oRoute->controller; |
|
469 | - $sActionName = $oRoute->action; |
|
468 | + $sControllerName = $oRoute->controller; |
|
469 | + $sActionName = $oRoute->action; |
|
470 | 470 | |
471 | - $oController = new $sControllerName; |
|
471 | + $oController = new $sControllerName; |
|
472 | 472 | |
473 | - $aEntries = array(); |
|
473 | + $aEntries = array(); |
|
474 | 474 | |
475 | - if (isset($oRoute->constraints) && is_object($oRoute->constraints)) { |
|
475 | + if (isset($oRoute->constraints) && is_object($oRoute->constraints)) { |
|
476 | 476 | |
477 | - $mReturn = null; |
|
477 | + $mReturn = null; |
|
478 | 478 | |
479 | - foreach ($oRoute->constraints as $sName => $sType) { |
|
479 | + foreach ($oRoute->constraints as $sName => $sType) { |
|
480 | 480 | |
481 | - if (isset($_GET[$sName]) && $_GET[$sName] != '') { |
|
481 | + if (isset($_GET[$sName]) && $_GET[$sName] != '') { |
|
482 | 482 | |
483 | - $aEntries[] = $_GET[$sName]; |
|
484 | - } else if (isset($oRoute->defaults_constraints) && is_object($oRoute->defaults_constraints) |
|
485 | - && isset($oRoute->defaults_constraints->{$sName})) { |
|
483 | + $aEntries[] = $_GET[$sName]; |
|
484 | + } else if (isset($oRoute->defaults_constraints) && is_object($oRoute->defaults_constraints) |
|
485 | + && isset($oRoute->defaults_constraints->{$sName})) { |
|
486 | 486 | |
487 | - $aEntries[] = $oRoute->defaults_constraints->{$sName}; |
|
488 | - } else if (isset($_GET[$sName])) { |
|
487 | + $aEntries[] = $oRoute->defaults_constraints->{$sName}; |
|
488 | + } else if (isset($_GET[$sName])) { |
|
489 | 489 | |
490 | - $aEntries[] = $_GET[$sName]; |
|
491 | - } else if (preg_match('/'.$sType.'/', '')) { |
|
490 | + $aEntries[] = $_GET[$sName]; |
|
491 | + } else if (preg_match('/'.$sType.'/', '')) { |
|
492 | 492 | |
493 | - $aEntries[] = ''; |
|
494 | - } else { |
|
493 | + $aEntries[] = ''; |
|
494 | + } else { |
|
495 | 495 | |
496 | - $this->_oLogger->warning('Error: Parameter '.$sName.' not exists!'); |
|
497 | - break; |
|
498 | - } |
|
499 | - } |
|
496 | + $this->_oLogger->warning('Error: Parameter '.$sName.' not exists!'); |
|
497 | + break; |
|
498 | + } |
|
499 | + } |
|
500 | 500 | |
501 | - if ($mReturn === null) { |
|
501 | + if ($mReturn === null) { |
|
502 | 502 | |
503 | - $mReturn = $this->_loadController($oController, $sActionName, $aEntries); |
|
503 | + $mReturn = $this->_loadController($oController, $sActionName, $aEntries); |
|
504 | 504 | |
505 | - } |
|
506 | - } |
|
507 | - else { |
|
505 | + } |
|
506 | + } |
|
507 | + else { |
|
508 | 508 | |
509 | - $mReturn = $this->_loadController($oController, $sActionName, $aEntries); |
|
510 | - } |
|
509 | + $mReturn = $this->_loadController($oController, $sActionName, $aEntries); |
|
510 | + } |
|
511 | 511 | |
512 | - if (isset($oRoute->content_type)) { |
|
512 | + if (isset($oRoute->content_type)) { |
|
513 | 513 | |
514 | - if ($oRoute->content_type === 'json') { |
|
514 | + if ($oRoute->content_type === 'json') { |
|
515 | 515 | |
516 | - $mReturn = json_encode($mReturn, JSON_PRETTY_PRINT); |
|
517 | - } |
|
518 | - } |
|
519 | - } |
|
520 | - else if (isset($oRoute->template) && isset($oRoute->layout) && $oRoute->layout === true) { |
|
516 | + $mReturn = json_encode($mReturn, JSON_PRETTY_PRINT); |
|
517 | + } |
|
518 | + } |
|
519 | + } |
|
520 | + else if (isset($oRoute->template) && isset($oRoute->layout) && $oRoute->layout === true) { |
|
521 | 521 | |
522 | - define('PORTAL', preg_replace('/^\\\\Venus\\\\src\\\\([a-zA-Z0-9_]+)\\\\.+$/', '$1', $oRoute->template)); |
|
523 | - set_include_path(get_include_path().PATH_SEPARATOR.'src'.PATH_SEPARATOR.PORTAL.PATH_SEPARATOR.'public'); |
|
522 | + define('PORTAL', preg_replace('/^\\\\Venus\\\\src\\\\([a-zA-Z0-9_]+)\\\\.+$/', '$1', $oRoute->template)); |
|
523 | + set_include_path(get_include_path().PATH_SEPARATOR.'src'.PATH_SEPARATOR.PORTAL.PATH_SEPARATOR.'public'); |
|
524 | 524 | |
525 | - $oLayout = Vendor::getVendor('Apollina\Template', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.PORTAL.DIRECTORY_SEPARATOR.'View'.DIRECTORY_SEPARATOR.'Layout.tpl'); |
|
525 | + $oLayout = Vendor::getVendor('Apollina\Template', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.PORTAL.DIRECTORY_SEPARATOR.'View'.DIRECTORY_SEPARATOR.'Layout.tpl'); |
|
526 | 526 | |
527 | - if (isset($oRoute->vars)) { |
|
527 | + if (isset($oRoute->vars)) { |
|
528 | 528 | |
529 | - foreach ($oRoute->vars as $sKey => $mValue) { |
|
529 | + foreach ($oRoute->vars as $sKey => $mValue) { |
|
530 | 530 | |
531 | - $oLayout->assign($sKey, $mValue); |
|
532 | - } |
|
533 | - } |
|
531 | + $oLayout->assign($sKey, $mValue); |
|
532 | + } |
|
533 | + } |
|
534 | 534 | |
535 | - $mReturn = $oLayout->assign('model', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.PORTAL.DIRECTORY_SEPARATOR.'View'.DIRECTORY_SEPARATOR.$oRoute->template.'.tpl') |
|
536 | - ->fetch(); |
|
537 | - } |
|
538 | - else if (isset($oRoute->template)) { |
|
535 | + $mReturn = $oLayout->assign('model', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.PORTAL.DIRECTORY_SEPARATOR.'View'.DIRECTORY_SEPARATOR.$oRoute->template.'.tpl') |
|
536 | + ->fetch(); |
|
537 | + } |
|
538 | + else if (isset($oRoute->template)) { |
|
539 | 539 | |
540 | - define('PORTAL', preg_replace('/^\\\\Venus\\\\src\\\\([a-zA-Z0-9_]+)\\\\.+$/', '$1', $oRoute->template)); |
|
541 | - set_include_path(get_include_path().PATH_SEPARATOR.'src'.PATH_SEPARATOR.PORTAL.PATH_SEPARATOR.'public'); |
|
540 | + define('PORTAL', preg_replace('/^\\\\Venus\\\\src\\\\([a-zA-Z0-9_]+)\\\\.+$/', '$1', $oRoute->template)); |
|
541 | + set_include_path(get_include_path().PATH_SEPARATOR.'src'.PATH_SEPARATOR.PORTAL.PATH_SEPARATOR.'public'); |
|
542 | 542 | |
543 | - $oTemplate = Vendor::getVendor('Apollina\Template', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.PORTAL.DIRECTORY_SEPARATOR.'View'.DIRECTORY_SEPARATOR.$oRoute->template.'.tpl'); |
|
543 | + $oTemplate = Vendor::getVendor('Apollina\Template', DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.PORTAL.DIRECTORY_SEPARATOR.'View'.DIRECTORY_SEPARATOR.$oRoute->template.'.tpl'); |
|
544 | 544 | |
545 | - if (isset($oRoute->vars)) { |
|
545 | + if (isset($oRoute->vars)) { |
|
546 | 546 | |
547 | - foreach ($oRoute->vars as $sKey => $mValue) { |
|
547 | + foreach ($oRoute->vars as $sKey => $mValue) { |
|
548 | 548 | |
549 | - $oTemplate->assign($sKey, $mValue); |
|
550 | - } |
|
551 | - } |
|
549 | + $oTemplate->assign($sKey, $mValue); |
|
550 | + } |
|
551 | + } |
|
552 | 552 | |
553 | - $mReturn = $oTemplate->fetch(); |
|
554 | - } |
|
553 | + $mReturn = $oTemplate->fetch(); |
|
554 | + } |
|
555 | 555 | |
556 | - // management of return or cache of it |
|
556 | + // management of return or cache of it |
|
557 | 557 | |
558 | - if (isset($oRoute->cache) && isset($oRoute->cache->max_age) && $mReturn) { |
|
558 | + if (isset($oRoute->cache) && isset($oRoute->cache->max_age) && $mReturn) { |
|
559 | 559 | |
560 | - $oMobileDetect = new \Mobile_Detect; |
|
560 | + $oMobileDetect = new \Mobile_Detect; |
|
561 | 561 | |
562 | - if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
563 | - else { $sCacheExt = ''; } |
|
562 | + if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
563 | + else { $sCacheExt = ''; } |
|
564 | 564 | |
565 | - if (defined('COMPRESS_HTML') && COMPRESS_HTML) { |
|
565 | + if (defined('COMPRESS_HTML') && COMPRESS_HTML) { |
|
566 | 566 | |
567 | - $mReturn = str_replace(array("\t", "\r", " "), array("", "", " "), $mReturn); |
|
568 | - } |
|
567 | + $mReturn = str_replace(array("\t", "\r", " "), array("", "", " "), $mReturn); |
|
568 | + } |
|
569 | 569 | |
570 | - Cache::set($RequestUri.$sCacheExt, $mReturn, $oRoute->cache->max_age); |
|
571 | - } |
|
570 | + Cache::set($RequestUri.$sCacheExt, $mReturn, $oRoute->cache->max_age); |
|
571 | + } |
|
572 | 572 | |
573 | - if ($mReturn) { |
|
573 | + if ($mReturn) { |
|
574 | 574 | |
575 | - echo $mReturn; |
|
576 | - return true; |
|
577 | - } |
|
578 | - } |
|
579 | - } |
|
575 | + echo $mReturn; |
|
576 | + return true; |
|
577 | + } |
|
578 | + } |
|
579 | + } |
|
580 | 580 | |
581 | - /** |
|
582 | - * create the constants |
|
583 | - * |
|
584 | - * @access private |
|
585 | - * @return void |
|
586 | - */ |
|
587 | - private function _create_constant() |
|
588 | - { |
|
589 | - foreach (Config::get('Const') as $sKey => $mValue) { |
|
581 | + /** |
|
582 | + * create the constants |
|
583 | + * |
|
584 | + * @access private |
|
585 | + * @return void |
|
586 | + */ |
|
587 | + private function _create_constant() |
|
588 | + { |
|
589 | + foreach (Config::get('Const') as $sKey => $mValue) { |
|
590 | 590 | |
591 | - if (is_string($mValue) || is_int($mValue) || is_float($mValue) || is_bool($mValue)) { |
|
591 | + if (is_string($mValue) || is_int($mValue) || is_float($mValue) || is_bool($mValue)) { |
|
592 | 592 | |
593 | - define(strtoupper($sKey), $mValue); |
|
594 | - } |
|
595 | - } |
|
596 | - } |
|
593 | + define(strtoupper($sKey), $mValue); |
|
594 | + } |
|
595 | + } |
|
596 | + } |
|
597 | 597 | |
598 | - /** |
|
599 | - * load the controller |
|
600 | - * |
|
601 | - * @access private |
|
602 | - * @param object $oControllerName controller name |
|
603 | - * @param string $sActionName method name |
|
604 | - * @param array $aParams parameters |
|
605 | - * @return mixed |
|
606 | - */ |
|
607 | - private function _loadController($oControllerName, string $sActionName, array $aParams = array()) |
|
608 | - { |
|
609 | - $aPhpDoc = PhpDoc::getPhpDocOfMethod($oControllerName, $sActionName); |
|
598 | + /** |
|
599 | + * load the controller |
|
600 | + * |
|
601 | + * @access private |
|
602 | + * @param object $oControllerName controller name |
|
603 | + * @param string $sActionName method name |
|
604 | + * @param array $aParams parameters |
|
605 | + * @return mixed |
|
606 | + */ |
|
607 | + private function _loadController($oControllerName, string $sActionName, array $aParams = array()) |
|
608 | + { |
|
609 | + $aPhpDoc = PhpDoc::getPhpDocOfMethod($oControllerName, $sActionName); |
|
610 | 610 | |
611 | - if (isset($aPhpDoc['Cache'])) { |
|
611 | + if (isset($aPhpDoc['Cache'])) { |
|
612 | 612 | |
613 | - if (!isset($aPhpDoc['Cache']['maxage'])) { $aPhpDoc['Cache']['maxage'] = 0; } |
|
613 | + if (!isset($aPhpDoc['Cache']['maxage'])) { $aPhpDoc['Cache']['maxage'] = 0; } |
|
614 | 614 | |
615 | - $oMobileDetect = new \Mobile_Detect; |
|
615 | + $oMobileDetect = new \Mobile_Detect; |
|
616 | 616 | |
617 | - if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
618 | - else { $sCacheExt = ''; } |
|
617 | + if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
618 | + else { $sCacheExt = ''; } |
|
619 | 619 | |
620 | - $mCacheReturn = Cache::get($sActionName.$sCacheExt, $aPhpDoc['Cache']['maxage']); |
|
620 | + $mCacheReturn = Cache::get($sActionName.$sCacheExt, $aPhpDoc['Cache']['maxage']); |
|
621 | 621 | |
622 | - if ($mCacheReturn !== false) { return $mCacheReturn; } |
|
623 | - } |
|
622 | + if ($mCacheReturn !== false) { return $mCacheReturn; } |
|
623 | + } |
|
624 | 624 | |
625 | - if (isset($aPhpDoc['Secure'])) { |
|
625 | + if (isset($aPhpDoc['Secure'])) { |
|
626 | 626 | |
627 | - if (isset($aPhpDoc['Secure']['roles']) && $this->_oSecurity->getUserRole() != $aPhpDoc['Secure']['roles']) { |
|
627 | + if (isset($aPhpDoc['Secure']['roles']) && $this->_oSecurity->getUserRole() != $aPhpDoc['Secure']['roles']) { |
|
628 | 628 | |
629 | - $this->_getPage403(); |
|
630 | - } |
|
631 | - } |
|
629 | + $this->_getPage403(); |
|
630 | + } |
|
631 | + } |
|
632 | 632 | |
633 | - $oController = new $oControllerName; |
|
633 | + $oController = new $oControllerName; |
|
634 | 634 | |
635 | - ob_start(); |
|
635 | + ob_start(); |
|
636 | 636 | |
637 | - if (!defined('PORTAL')) { define('PORTAL', 'Batch'); } |
|
637 | + if (!defined('PORTAL')) { define('PORTAL', 'Batch'); } |
|
638 | 638 | |
639 | - if (method_exists($oController, 'beforeExecuteRoute')) { |
|
639 | + if (method_exists($oController, 'beforeExecuteRoute')) { |
|
640 | 640 | |
641 | - call_user_func_array(array($oController, 'beforeExecuteRoute'), array()); |
|
642 | - } |
|
641 | + call_user_func_array(array($oController, 'beforeExecuteRoute'), array()); |
|
642 | + } |
|
643 | 643 | |
644 | - $mReturnController = call_user_func_array(array($oController, $sActionName), $aParams); |
|
644 | + $mReturnController = call_user_func_array(array($oController, $sActionName), $aParams); |
|
645 | 645 | |
646 | - if (method_exists($oController, 'afterExecuteRoute')) { |
|
646 | + if (method_exists($oController, 'afterExecuteRoute')) { |
|
647 | 647 | |
648 | - call_user_func_array(array($oController, 'afterExecuteRoute'), array()); |
|
649 | - } |
|
648 | + call_user_func_array(array($oController, 'afterExecuteRoute'), array()); |
|
649 | + } |
|
650 | 650 | |
651 | - $mReturn = ob_get_clean(); |
|
651 | + $mReturn = ob_get_clean(); |
|
652 | 652 | |
653 | - if ($mReturn == '') { $mReturn = $mReturnController; } |
|
653 | + if ($mReturn == '') { $mReturn = $mReturnController; } |
|
654 | 654 | |
655 | - if (isset($aPhpDoc['Cache'])) { |
|
655 | + if (isset($aPhpDoc['Cache'])) { |
|
656 | 656 | |
657 | - $oMobileDetect = new \Mobile_Detect; |
|
657 | + $oMobileDetect = new \Mobile_Detect; |
|
658 | 658 | |
659 | - if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
660 | - else { $sCacheExt = ''; } |
|
659 | + if ($oMobileDetect->isMobile()) { $sCacheExt = '.mobi'; } |
|
660 | + else { $sCacheExt = ''; } |
|
661 | 661 | |
662 | - if (defined('COMPRESS_HTML') && COMPRESS_HTML) { |
|
662 | + if (defined('COMPRESS_HTML') && COMPRESS_HTML) { |
|
663 | 663 | |
664 | - $mReturn = str_replace(array("\t", "\r", " "), array("", "", "", " "), $mReturn); |
|
665 | - } |
|
664 | + $mReturn = str_replace(array("\t", "\r", " "), array("", "", "", " "), $mReturn); |
|
665 | + } |
|
666 | 666 | |
667 | - Cache::set($sActionName.$sCacheExt, $mReturn, $aPhpDoc['Cache']['maxage']); |
|
668 | - } |
|
667 | + Cache::set($sActionName.$sCacheExt, $mReturn, $aPhpDoc['Cache']['maxage']); |
|
668 | + } |
|
669 | 669 | |
670 | - return $mReturn; |
|
671 | - } |
|
670 | + return $mReturn; |
|
671 | + } |
|
672 | 672 | |
673 | - /** |
|
674 | - * get the page 403 |
|
675 | - * |
|
676 | - * @access private |
|
677 | - * @return void |
|
678 | - */ |
|
679 | - private function _getPage403() |
|
680 | - { |
|
681 | - header("HTTP/1.0 403 Forbidden"); |
|
673 | + /** |
|
674 | + * get the page 403 |
|
675 | + * |
|
676 | + * @access private |
|
677 | + * @return void |
|
678 | + */ |
|
679 | + private function _getPage403() |
|
680 | + { |
|
681 | + header("HTTP/1.0 403 Forbidden"); |
|
682 | 682 | |
683 | - if (isset($this->_oRoutes->e403)) { |
|
683 | + if (isset($this->_oRoutes->e403)) { |
|
684 | 684 | |
685 | - $this->_oRoutes->e403->route = '/'; |
|
686 | - $_SERVER['REQUEST_URI'] = '/'; |
|
687 | - $this->_route($this->_oRoutes->e403, $_SERVER['REQUEST_URI']); |
|
688 | - } |
|
685 | + $this->_oRoutes->e403->route = '/'; |
|
686 | + $_SERVER['REQUEST_URI'] = '/'; |
|
687 | + $this->_route($this->_oRoutes->e403, $_SERVER['REQUEST_URI']); |
|
688 | + } |
|
689 | 689 | |
690 | - exit; |
|
691 | - } |
|
690 | + exit; |
|
691 | + } |
|
692 | 692 | |
693 | - /** |
|
694 | - * get the page 404 |
|
695 | - * |
|
696 | - * @access private |
|
697 | - * @return void |
|
698 | - */ |
|
699 | - private function _getPage404() |
|
700 | - { |
|
701 | - header("HTTP/1.0 404 Not Found"); |
|
693 | + /** |
|
694 | + * get the page 404 |
|
695 | + * |
|
696 | + * @access private |
|
697 | + * @return void |
|
698 | + */ |
|
699 | + private function _getPage404() |
|
700 | + { |
|
701 | + header("HTTP/1.0 404 Not Found"); |
|
702 | 702 | |
703 | - if (isset($this->_oRoutes->e404)) { |
|
703 | + if (isset($this->_oRoutes->e404)) { |
|
704 | 704 | |
705 | - $this->_oRoutes->e404->route = '/'; |
|
706 | - $_SERVER['REQUEST_URI'] = '/'; |
|
707 | - $this->_route($this->_oRoutes->e404, $_SERVER['REQUEST_URI']); |
|
708 | - } |
|
705 | + $this->_oRoutes->e404->route = '/'; |
|
706 | + $_SERVER['REQUEST_URI'] = '/'; |
|
707 | + $this->_route($this->_oRoutes->e404, $_SERVER['REQUEST_URI']); |
|
708 | + } |
|
709 | 709 | |
710 | - exit; |
|
711 | - } |
|
710 | + exit; |
|
711 | + } |
|
712 | 712 | |
713 | - /** |
|
714 | - * check the cache - just if it's not yet defined |
|
715 | - * |
|
716 | - * @access private |
|
717 | - * @param \stdClass $oCache object of cache configuration |
|
718 | - * @return void |
|
719 | - */ |
|
720 | - private function _checkCache(\stdClass $oCache) |
|
721 | - { |
|
722 | - /** |
|
723 | - * cache-control http |
|
724 | - */ |
|
713 | + /** |
|
714 | + * check the cache - just if it's not yet defined |
|
715 | + * |
|
716 | + * @access private |
|
717 | + * @param \stdClass $oCache object of cache configuration |
|
718 | + * @return void |
|
719 | + */ |
|
720 | + private function _checkCache(\stdClass $oCache) |
|
721 | + { |
|
722 | + /** |
|
723 | + * cache-control http |
|
724 | + */ |
|
725 | 725 | |
726 | - $sHearderValidity = false; |
|
727 | - $sHeader = "Cache-Control:"; |
|
726 | + $sHearderValidity = false; |
|
727 | + $sHeader = "Cache-Control:"; |
|
728 | 728 | |
729 | - if (isset($oCache->visibility) && ($oCache->visibility = 'public' || $oCache->visibility = 'private')) { |
|
729 | + if (isset($oCache->visibility) && ($oCache->visibility = 'public' || $oCache->visibility = 'private')) { |
|
730 | 730 | |
731 | - $sHearderValidity = true; |
|
732 | - $sHeader .= " ".$oCache->visibility.","; |
|
733 | - } |
|
731 | + $sHearderValidity = true; |
|
732 | + $sHeader .= " ".$oCache->visibility.","; |
|
733 | + } |
|
734 | 734 | |
735 | - if (isset($oCache->max_age)) { |
|
735 | + if (isset($oCache->max_age)) { |
|
736 | 736 | |
737 | - $sHearderValidity = true; |
|
738 | - $sHeader .= " maxage=".$oCache->max_age.","; |
|
739 | - } |
|
737 | + $sHearderValidity = true; |
|
738 | + $sHeader .= " maxage=".$oCache->max_age.","; |
|
739 | + } |
|
740 | 740 | |
741 | - if (isset($oCache->must_revalidate) && $oCache->must_revalidate === true) { |
|
741 | + if (isset($oCache->must_revalidate) && $oCache->must_revalidate === true) { |
|
742 | 742 | |
743 | - $sHearderValidity = true; |
|
744 | - $sHeader .= " must-revalidate,"; |
|
745 | - } |
|
743 | + $sHearderValidity = true; |
|
744 | + $sHeader .= " must-revalidate,"; |
|
745 | + } |
|
746 | 746 | |
747 | - if ($sHearderValidity === true) { |
|
747 | + if ($sHearderValidity === true) { |
|
748 | 748 | |
749 | - $sHeader = substr($sHeader, 0, -1); |
|
749 | + $sHeader = substr($sHeader, 0, -1); |
|
750 | 750 | |
751 | - if (!headers_sent()) { header($sHeader); } |
|
752 | - } |
|
751 | + if (!headers_sent()) { header($sHeader); } |
|
752 | + } |
|
753 | 753 | |
754 | - /** |
|
755 | - * ETag http |
|
756 | - */ |
|
754 | + /** |
|
755 | + * ETag http |
|
756 | + */ |
|
757 | 757 | |
758 | - if (isset($oCache->ETag)) { header("ETag: \"".$oCache->ETag."\""); } |
|
758 | + if (isset($oCache->ETag)) { header("ETag: \"".$oCache->ETag."\""); } |
|
759 | 759 | |
760 | - /** |
|
761 | - * expire |
|
762 | - */ |
|
760 | + /** |
|
761 | + * expire |
|
762 | + */ |
|
763 | 763 | |
764 | - if (isset($oCache->max_age)) { if (!headers_sent()) { header('Expires: '.gmdate('D, d M Y H:i:s', time() + $oCache->max_age).' GMT'); } } |
|
764 | + if (isset($oCache->max_age)) { if (!headers_sent()) { header('Expires: '.gmdate('D, d M Y H:i:s', time() + $oCache->max_age).' GMT'); } } |
|
765 | 765 | |
766 | - /** |
|
767 | - * Last-Modified http |
|
768 | - */ |
|
766 | + /** |
|
767 | + * Last-Modified http |
|
768 | + */ |
|
769 | 769 | |
770 | - if (isset($oCache->last_modified)) { if (!headers_sent()) { header('Last-Modified: '.gmdate('D, d M Y H:i:s', time() + $oCache->last_modified).' GMT'); } } |
|
770 | + if (isset($oCache->last_modified)) { if (!headers_sent()) { header('Last-Modified: '.gmdate('D, d M Y H:i:s', time() + $oCache->last_modified).' GMT'); } } |
|
771 | 771 | |
772 | - /** |
|
773 | - * vary http |
|
774 | - */ |
|
772 | + /** |
|
773 | + * vary http |
|
774 | + */ |
|
775 | 775 | |
776 | - if (isset($oCache->vary)) { header('Vary: '.$oCache->vary); } |
|
777 | - } |
|
776 | + if (isset($oCache->vary)) { header('Vary: '.$oCache->vary); } |
|
777 | + } |
|
778 | 778 | |
779 | - /** |
|
780 | - * Sets a logger instance on the object |
|
781 | - * |
|
782 | - * @access private |
|
783 | - * @param LoggerInterface $logger |
|
784 | - * @return null |
|
785 | - */ |
|
786 | - public function setLogger(LoggerInterface $logger) { |
|
779 | + /** |
|
780 | + * Sets a logger instance on the object |
|
781 | + * |
|
782 | + * @access private |
|
783 | + * @param LoggerInterface $logger |
|
784 | + * @return null |
|
785 | + */ |
|
786 | + public function setLogger(LoggerInterface $logger) { |
|
787 | 787 | |
788 | - $this->_oLogger = $logger; |
|
789 | - } |
|
788 | + $this->_oLogger = $logger; |
|
789 | + } |
|
790 | 790 | } |
@@ -49,11 +49,11 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public static function get(string $sName, string $sPortal = null, bool $bNoDoRedirect = false) |
51 | 51 | { |
52 | - if ($bNoDoRedirect === true) { $sNameCache = $sName.'_true'; } else { $sNameCache = $sName; } |
|
52 | + if ($bNoDoRedirect === true) { $sNameCache = $sName.'_true'; } else { $sNameCache = $sName; } |
|
53 | 53 | |
54 | 54 | if ($sPortal === null || !is_string($sPortal)) { |
55 | 55 | |
56 | - if (defined('PORTAL')) { |
|
56 | + if (defined('PORTAL')) { |
|
57 | 57 | |
58 | 58 | $sPortal = PORTAL; |
59 | 59 | $aDirectories = array($sPortal); |
@@ -70,93 +70,93 @@ discard block |
||
70 | 70 | |
71 | 71 | foreach ($aDirectories as $sPortal) { |
72 | 72 | |
73 | - if ($sPortal != '..' && $sPortal != '.') { |
|
73 | + if ($sPortal != '..' && $sPortal != '.') { |
|
74 | 74 | |
75 | - if (file_exists(str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-local')) { |
|
75 | + if (file_exists(str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-local')) { |
|
76 | 76 | |
77 | - $sJsonFile = str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-local'; |
|
78 | - $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
79 | - } |
|
77 | + $sJsonFile = str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-local'; |
|
78 | + $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
79 | + } |
|
80 | 80 | |
81 | - if (file_exists(str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-local')) { |
|
81 | + if (file_exists(str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-local')) { |
|
82 | 82 | |
83 | - $sJsonFile = str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-local'; |
|
84 | - $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
85 | - } |
|
83 | + $sJsonFile = str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-local'; |
|
84 | + $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
85 | + } |
|
86 | 86 | |
87 | - if (file_exists(str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev') && getenv('DEV') == 1) { |
|
87 | + if (file_exists(str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev') && getenv('DEV') == 1) { |
|
88 | 88 | |
89 | - $sJsonFile = str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev'; |
|
90 | - $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
91 | - } |
|
89 | + $sJsonFile = str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev'; |
|
90 | + $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
91 | + } |
|
92 | 92 | |
93 | - if (file_exists(str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev') && getenv('DEV') == 1) { |
|
93 | + if (file_exists(str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev') && getenv('DEV') == 1) { |
|
94 | 94 | |
95 | - $sJsonFile = str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev'; |
|
96 | - $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
97 | - } |
|
95 | + $sJsonFile = str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev'; |
|
96 | + $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
97 | + } |
|
98 | 98 | |
99 | - if (file_exists(str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev') && getenv('PROD') == 1) { |
|
99 | + if (file_exists(str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev') && getenv('PROD') == 1) { |
|
100 | 100 | |
101 | - $sJsonFile = str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-prod'; |
|
102 | - $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
103 | - } |
|
101 | + $sJsonFile = str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-prod'; |
|
102 | + $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
103 | + } |
|
104 | 104 | |
105 | - if (file_exists(str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev') && getenv('PROD') == 1) { |
|
105 | + if (file_exists(str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev') && getenv('PROD') == 1) { |
|
106 | 106 | |
107 | - $sJsonFile = str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-prod'; |
|
108 | - $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
109 | - } |
|
107 | + $sJsonFile = str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-prod'; |
|
108 | + $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
109 | + } |
|
110 | 110 | |
111 | - if (file_exists(str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev') && getenv('PREPROD') == 1) { |
|
111 | + if (file_exists(str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev') && getenv('PREPROD') == 1) { |
|
112 | 112 | |
113 | - $sJsonFile = str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-pprod'; |
|
114 | - $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
115 | - } |
|
113 | + $sJsonFile = str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-pprod'; |
|
114 | + $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
115 | + } |
|
116 | 116 | |
117 | - if (file_exists(str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev') && getenv('PREPROD') == 1) { |
|
117 | + if (file_exists(str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev') && getenv('PREPROD') == 1) { |
|
118 | 118 | |
119 | - $sJsonFile = str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-pprod'; |
|
120 | - $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
121 | - } |
|
119 | + $sJsonFile = str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-pprod'; |
|
120 | + $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
121 | + } |
|
122 | 122 | |
123 | - if (file_exists(str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev') && getenv('RECETTE') == 1) { |
|
123 | + if (file_exists(str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev') && getenv('RECETTE') == 1) { |
|
124 | 124 | |
125 | - $sJsonFile = str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-rec'; |
|
126 | - $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
127 | - } |
|
125 | + $sJsonFile = str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-rec'; |
|
126 | + $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
127 | + } |
|
128 | 128 | |
129 | - if (file_exists(str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev') && getenv('RECETTE') == 1) { |
|
129 | + if (file_exists(str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-dev') && getenv('RECETTE') == 1) { |
|
130 | 130 | |
131 | - $sJsonFile = str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-rec'; |
|
132 | - $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
133 | - } |
|
131 | + $sJsonFile = str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-rec'; |
|
132 | + $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
133 | + } |
|
134 | 134 | |
135 | - if (file_exists(str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-local')) { |
|
135 | + if (file_exists(str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-local')) { |
|
136 | 136 | |
137 | - $sJsonFile = str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-local'; |
|
138 | - $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
139 | - } |
|
137 | + $sJsonFile = str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf-local'; |
|
138 | + $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
139 | + } |
|
140 | 140 | |
141 | - if (file_exists(str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf')) { |
|
141 | + if (file_exists(str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf')) { |
|
142 | 142 | |
143 | - $sJsonFile = str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf'; |
|
144 | - $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
145 | - } |
|
143 | + $sJsonFile = str_replace('core', 'src'.DIRECTORY_SEPARATOR.$sPortal.DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf'; |
|
144 | + $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
145 | + } |
|
146 | 146 | |
147 | - $sJsonFile = str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf'; |
|
148 | - $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
149 | - } |
|
150 | - } |
|
147 | + $sJsonFile = str_replace('core', 'conf', __DIR__).DIRECTORY_SEPARATOR.$sName.'.conf'; |
|
148 | + $base = self::_mergeAndGetConf($sJsonFile, $base); |
|
149 | + } |
|
150 | + } |
|
151 | 151 | |
152 | - if ($base === '') { |
|
152 | + if ($base === '') { |
|
153 | 153 | |
154 | 154 | trigger_error("Error in your Json format in this file : ".$sJsonFile, E_USER_NOTICE); |
155 | 155 | } |
156 | 156 | |
157 | 157 | if (isset($base->redirect) && $bNoDoRedirect === false) { |
158 | 158 | |
159 | - $base = self::get($sName, $base->redirect); |
|
159 | + $base = self::get($sName, $base->redirect); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | self::$_aConfCache[$sNameCache] = $base; |
@@ -180,9 +180,9 @@ discard block |
||
180 | 180 | */ |
181 | 181 | public static function getBundleLocationName(string $sName): string |
182 | 182 | { |
183 | - $oConfig = self::get($sName, null, true); |
|
183 | + $oConfig = self::get($sName, null, true); |
|
184 | 184 | |
185 | - if (isset($oConfig->redirect)) { return $oConfig->redirect; } else { return PORTAL; } |
|
185 | + if (isset($oConfig->redirect)) { return $oConfig->redirect; } else { return PORTAL; } |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | echo "The Json ".$sFileToMerge." has an error! Please verify!\n"; |
207 | 207 | $oDebug = Debug::getInstance(); |
208 | 208 | $oDebug->error("The Json ".$sFileToMerge." has an error! Please verify!\n"); |
209 | - new \Exception("The Json ".$sFileToMerge." has an error! Please verify!\n"); |
|
209 | + new \Exception("The Json ".$sFileToMerge." has an error! Please verify!\n"); |
|
210 | 210 | } |
211 | 211 | } |
212 | 212 | |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | } else if (is_array($oConfFiles) && is_array($base) && !isset($base[$sKey])) { |
229 | 229 | |
230 | 230 | $base[$sKey] = $oConfFiles[$sKey]; |
231 | - } else if (!isset($base->$sKey) && is_array($mOne)) { |
|
231 | + } else if (!isset($base->$sKey) && is_array($mOne)) { |
|
232 | 232 | |
233 | 233 | $base->$sKey = new \StdClass; |
234 | 234 | list($oConfFiles, $base) = self::_recursiveGet($mOne, $base->$sKey); |
@@ -118,8 +118,7 @@ |
||
118 | 118 | */ |
119 | 119 | public function redirect(string $sUrl, int $iHttpCode = 301) |
120 | 120 | { |
121 | - if ($iHttpCode === 301) { header('Status: 301 Moved Permanently', false, 301); } |
|
122 | - else if ($iHttpCode === 302) { header('Status: Moved Temporarily', false, 301); } |
|
121 | + if ($iHttpCode === 301) { header('Status: 301 Moved Permanently', false, 301); } else if ($iHttpCode === 302) { header('Status: Moved Temporarily', false, 301); } |
|
123 | 122 | |
124 | 123 | header('Location: '.$sUrl); |
125 | 124 | exit; |
@@ -43,138 +43,138 @@ |
||
43 | 43 | abstract class Controller extends Mother |
44 | 44 | { |
45 | 45 | |
46 | - /** |
|
47 | - * Cache to know if a model was initialize or not because we must initialize it just one time by script |
|
48 | - * |
|
49 | - * @access private |
|
50 | - * @var array |
|
51 | - */ |
|
52 | - private static $_aInitialize = array(); |
|
46 | + /** |
|
47 | + * Cache to know if a model was initialize or not because we must initialize it just one time by script |
|
48 | + * |
|
49 | + * @access private |
|
50 | + * @var array |
|
51 | + */ |
|
52 | + private static $_aInitialize = array(); |
|
53 | 53 | |
54 | - /** |
|
55 | - * Constructor |
|
56 | - * |
|
57 | - * @access public |
|
58 | - */ |
|
59 | - public function __construct() |
|
60 | - { |
|
61 | - $aClass = explode('\\', get_called_class()); |
|
62 | - $sClassName = $aClass[count($aClass) - 1]; |
|
63 | - $sNamespaceName = preg_replace('/\\\\'.$sClassName.'$/', '', get_called_class()); |
|
64 | - |
|
65 | - if (isset($sClassName)) { |
|
66 | - |
|
67 | - $sNamespaceBaseName = str_replace('\Controller', '', $sNamespaceName); |
|
68 | - $sDefaultModel = $sNamespaceBaseName.'\Model\\'.$sClassName; |
|
69 | - $sDefaultView = str_replace('\\', DIRECTORY_SEPARATOR, str_replace('Venus\\', '\\', $sNamespaceBaseName)).DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'View'.DIRECTORY_SEPARATOR.$sClassName.'.tpl'; |
|
70 | - $sDefaultLayout = str_replace('\\', DIRECTORY_SEPARATOR, str_replace('Venus\\', '\\', $sNamespaceBaseName)).DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'View'.DIRECTORY_SEPARATOR.'Layout.tpl'; |
|
71 | - |
|
72 | - $this->model = function() use ($sDefaultModel) { return new $sDefaultModel; }; |
|
73 | - |
|
74 | - $this->view = function() use ($sDefaultView) { return Vendor::getVendor('Apollina\Template', $sDefaultView); }; |
|
75 | - |
|
76 | - $this->layout = function() use ($sDefaultLayout) { return Vendor::getVendor('Apollina\Template', $sDefaultLayout, true); }; |
|
77 | - |
|
78 | - $this->layout->assign('model', $sDefaultView); |
|
79 | - } |
|
80 | - |
|
81 | - $this->form = function() { return new Form(); }; |
|
82 | - $this->security = function() { return new Security(); }; |
|
83 | - $this->router = function() { return new Router; }; |
|
84 | - $this->mail = function() { return new Mail; }; |
|
85 | - $this->session = function() { return new Session; }; |
|
86 | - $this->translator = function() { return new I18n; }; |
|
87 | - $this->url = function() { return new UrlManager; }; |
|
88 | - $this->cookie = function() { return new Cookie; }; |
|
89 | - $this->di = function() { return new Di; }; |
|
90 | - $this->request = function() { return new Request; }; |
|
91 | - |
|
92 | - /** |
|
93 | - * Trigger on a model to initialize it. You could fill entity with it. |
|
94 | - */ |
|
95 | - if (method_exists(get_called_class(), 'initialize')) { |
|
96 | - |
|
97 | - if (!isset(self::$_aInitialize[get_called_class()])) { |
|
98 | - |
|
99 | - static::initialize(); |
|
100 | - self::$_aInitialize[get_called_class()] = true; |
|
101 | - } |
|
102 | - } |
|
103 | - |
|
104 | - /** |
|
105 | - * Trigger on a model to initialize it every time you construct it |
|
106 | - */ |
|
107 | - if (method_exists(get_called_class(), 'onConstruct')) { static::onConstruct(); } |
|
108 | - } |
|
109 | - |
|
110 | - /** |
|
111 | - * redirection HTTP |
|
112 | - * |
|
113 | - * @access public |
|
114 | - * @param string $sUrl url for the redirection |
|
115 | - * @param int $iHttpCode code of the http request |
|
116 | - * @return void |
|
117 | - */ |
|
118 | - public function redirect(string $sUrl, int $iHttpCode = 301) |
|
119 | - { |
|
120 | - if ($iHttpCode === 301) { header('Status: 301 Moved Permanently', false, 301); } |
|
121 | - else if ($iHttpCode === 302) { header('Status: Moved Temporarily', false, 301); } |
|
122 | - |
|
123 | - header('Location: '.$sUrl); |
|
124 | - exit; |
|
125 | - } |
|
126 | - |
|
127 | - /** |
|
128 | - * call an other action as you call action with URL/Cli |
|
129 | - * |
|
130 | - * @access public |
|
131 | - * @param string $sUri uri for the redirection |
|
132 | - * @param array $aParams parameters |
|
133 | - * @return void |
|
134 | - */ |
|
135 | - public function forward(string $sUri, array $aParams = array()) |
|
136 | - { |
|
137 | - $this->router->runByFoward($sUri, $aParams); |
|
138 | - } |
|
139 | - |
|
140 | - /** |
|
141 | - * call the 404 Not Found page |
|
142 | - * |
|
143 | - * @access public |
|
144 | - * @return void |
|
145 | - */ |
|
146 | - public function notFound() |
|
147 | - { |
|
148 | - $$this->router->runHttpErrorPage(404); |
|
149 | - } |
|
150 | - |
|
151 | - /** |
|
152 | - * call the 403 Forbidden page |
|
153 | - * |
|
154 | - * @access public |
|
155 | - * @return void |
|
156 | - */ |
|
157 | - public function forbidden() |
|
158 | - { |
|
159 | - $$this->router->runHttpErrorPage(403); |
|
160 | - } |
|
161 | - |
|
162 | - /** |
|
163 | - * get a property |
|
164 | - * |
|
165 | - * @access public |
|
166 | - * @param unknown_type $mKey |
|
167 | - * @return void |
|
168 | - */ |
|
169 | - public function __get($mKey) |
|
170 | - { |
|
171 | - if (isset($this->di) && property_exists($this, 'di')) { |
|
172 | - |
|
173 | - $mDi = $this->di->get($mKey); |
|
174 | - |
|
175 | - if (isset($mDi) && $mDi !== false) { return $mDi; } |
|
176 | - } |
|
177 | - |
|
178 | - return parent::__get($mKey); |
|
179 | - } |
|
54 | + /** |
|
55 | + * Constructor |
|
56 | + * |
|
57 | + * @access public |
|
58 | + */ |
|
59 | + public function __construct() |
|
60 | + { |
|
61 | + $aClass = explode('\\', get_called_class()); |
|
62 | + $sClassName = $aClass[count($aClass) - 1]; |
|
63 | + $sNamespaceName = preg_replace('/\\\\'.$sClassName.'$/', '', get_called_class()); |
|
64 | + |
|
65 | + if (isset($sClassName)) { |
|
66 | + |
|
67 | + $sNamespaceBaseName = str_replace('\Controller', '', $sNamespaceName); |
|
68 | + $sDefaultModel = $sNamespaceBaseName.'\Model\\'.$sClassName; |
|
69 | + $sDefaultView = str_replace('\\', DIRECTORY_SEPARATOR, str_replace('Venus\\', '\\', $sNamespaceBaseName)).DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'View'.DIRECTORY_SEPARATOR.$sClassName.'.tpl'; |
|
70 | + $sDefaultLayout = str_replace('\\', DIRECTORY_SEPARATOR, str_replace('Venus\\', '\\', $sNamespaceBaseName)).DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'View'.DIRECTORY_SEPARATOR.'Layout.tpl'; |
|
71 | + |
|
72 | + $this->model = function() use ($sDefaultModel) { return new $sDefaultModel; }; |
|
73 | + |
|
74 | + $this->view = function() use ($sDefaultView) { return Vendor::getVendor('Apollina\Template', $sDefaultView); }; |
|
75 | + |
|
76 | + $this->layout = function() use ($sDefaultLayout) { return Vendor::getVendor('Apollina\Template', $sDefaultLayout, true); }; |
|
77 | + |
|
78 | + $this->layout->assign('model', $sDefaultView); |
|
79 | + } |
|
80 | + |
|
81 | + $this->form = function() { return new Form(); }; |
|
82 | + $this->security = function() { return new Security(); }; |
|
83 | + $this->router = function() { return new Router; }; |
|
84 | + $this->mail = function() { return new Mail; }; |
|
85 | + $this->session = function() { return new Session; }; |
|
86 | + $this->translator = function() { return new I18n; }; |
|
87 | + $this->url = function() { return new UrlManager; }; |
|
88 | + $this->cookie = function() { return new Cookie; }; |
|
89 | + $this->di = function() { return new Di; }; |
|
90 | + $this->request = function() { return new Request; }; |
|
91 | + |
|
92 | + /** |
|
93 | + * Trigger on a model to initialize it. You could fill entity with it. |
|
94 | + */ |
|
95 | + if (method_exists(get_called_class(), 'initialize')) { |
|
96 | + |
|
97 | + if (!isset(self::$_aInitialize[get_called_class()])) { |
|
98 | + |
|
99 | + static::initialize(); |
|
100 | + self::$_aInitialize[get_called_class()] = true; |
|
101 | + } |
|
102 | + } |
|
103 | + |
|
104 | + /** |
|
105 | + * Trigger on a model to initialize it every time you construct it |
|
106 | + */ |
|
107 | + if (method_exists(get_called_class(), 'onConstruct')) { static::onConstruct(); } |
|
108 | + } |
|
109 | + |
|
110 | + /** |
|
111 | + * redirection HTTP |
|
112 | + * |
|
113 | + * @access public |
|
114 | + * @param string $sUrl url for the redirection |
|
115 | + * @param int $iHttpCode code of the http request |
|
116 | + * @return void |
|
117 | + */ |
|
118 | + public function redirect(string $sUrl, int $iHttpCode = 301) |
|
119 | + { |
|
120 | + if ($iHttpCode === 301) { header('Status: 301 Moved Permanently', false, 301); } |
|
121 | + else if ($iHttpCode === 302) { header('Status: Moved Temporarily', false, 301); } |
|
122 | + |
|
123 | + header('Location: '.$sUrl); |
|
124 | + exit; |
|
125 | + } |
|
126 | + |
|
127 | + /** |
|
128 | + * call an other action as you call action with URL/Cli |
|
129 | + * |
|
130 | + * @access public |
|
131 | + * @param string $sUri uri for the redirection |
|
132 | + * @param array $aParams parameters |
|
133 | + * @return void |
|
134 | + */ |
|
135 | + public function forward(string $sUri, array $aParams = array()) |
|
136 | + { |
|
137 | + $this->router->runByFoward($sUri, $aParams); |
|
138 | + } |
|
139 | + |
|
140 | + /** |
|
141 | + * call the 404 Not Found page |
|
142 | + * |
|
143 | + * @access public |
|
144 | + * @return void |
|
145 | + */ |
|
146 | + public function notFound() |
|
147 | + { |
|
148 | + $$this->router->runHttpErrorPage(404); |
|
149 | + } |
|
150 | + |
|
151 | + /** |
|
152 | + * call the 403 Forbidden page |
|
153 | + * |
|
154 | + * @access public |
|
155 | + * @return void |
|
156 | + */ |
|
157 | + public function forbidden() |
|
158 | + { |
|
159 | + $$this->router->runHttpErrorPage(403); |
|
160 | + } |
|
161 | + |
|
162 | + /** |
|
163 | + * get a property |
|
164 | + * |
|
165 | + * @access public |
|
166 | + * @param unknown_type $mKey |
|
167 | + * @return void |
|
168 | + */ |
|
169 | + public function __get($mKey) |
|
170 | + { |
|
171 | + if (isset($this->di) && property_exists($this, 'di')) { |
|
172 | + |
|
173 | + $mDi = $this->di->get($mKey); |
|
174 | + |
|
175 | + if (isset($mDi) && $mDi !== false) { return $mDi; } |
|
176 | + } |
|
177 | + |
|
178 | + return parent::__get($mKey); |
|
179 | + } |
|
180 | 180 | } |
@@ -103,8 +103,7 @@ discard block |
||
103 | 103 | if (!$this->_checkAccess()) { return false; } |
104 | 104 | if (!$this->_checkBlackListIps()) { return false; } |
105 | 105 | } |
106 | - } |
|
107 | - else if (isset($oSecurity->authentification) && $oSecurity->authentification === 'http_basic_validate_by_controller') { |
|
106 | + } else if (isset($oSecurity->authentification) && $oSecurity->authentification === 'http_basic_validate_by_controller') { |
|
108 | 107 | |
109 | 108 | if (!isset($_SERVER['PHP_AUTH_USER'])) { |
110 | 109 | |
@@ -217,9 +216,7 @@ discard block |
||
217 | 216 | $sLogin = self::$_sLogin; |
218 | 217 | $sPassword = Config::get('Security')->users->$sLogin->password; |
219 | 218 | |
220 | - if ($sPassword == self::$_sPassword) { return true; } |
|
221 | - else if ($sPassword == md5(self::$_sPassword)) { return true; } |
|
222 | - else { return false; } |
|
219 | + if ($sPassword == self::$_sPassword) { return true; } else if ($sPassword == md5(self::$_sPassword)) { return true; } else { return false; } |
|
223 | 220 | } |
224 | 221 | |
225 | 222 | /** |