@@ -1,16 +1,16 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * @package OAuth2 |
|
4 | - * @category modules |
|
5 | - * @author Nazar Mokrynskyi <[email protected]> |
|
6 | - * @copyright Copyright (c) 2011-2016, Nazar Mokrynskyi |
|
7 | - * @license MIT License, see license.txt |
|
8 | - */ |
|
3 | + * @package OAuth2 |
|
4 | + * @category modules |
|
5 | + * @author Nazar Mokrynskyi <[email protected]> |
|
6 | + * @copyright Copyright (c) 2011-2016, Nazar Mokrynskyi |
|
7 | + * @license MIT License, see license.txt |
|
8 | + */ |
|
9 | 9 | /** |
10 | - * Provides next events:<br> |
|
11 | - * OAuth2/custom_sign_in_page |
|
12 | - * OAuth2/custom_allow_access_page |
|
13 | - */ |
|
10 | + * Provides next events:<br> |
|
11 | + * OAuth2/custom_sign_in_page |
|
12 | + * OAuth2/custom_allow_access_page |
|
13 | + */ |
|
14 | 14 | namespace cs\modules\OAuth2; |
15 | 15 | use |
16 | 16 | h, |
@@ -43,8 +43,8 @@ discard block |
||
43 | 43 | $L = new Prefix('oauth2_'); |
44 | 44 | $Page = Page::instance(); |
45 | 45 | /** |
46 | - * Errors processing |
|
47 | - */ |
|
46 | + * Errors processing |
|
47 | + */ |
|
48 | 48 | if (!isset($_GET['client_id'])) { |
49 | 49 | error_redirect('invalid_request', 'client_id parameter required'); |
50 | 50 | return; |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | } |
113 | 113 | } |
114 | 114 | /** |
115 | - * guest_token should return JSON data while all other works with redirects |
|
116 | - */ |
|
115 | + * guest_token should return JSON data while all other works with redirects |
|
116 | + */ |
|
117 | 117 | if ($_GET['response_type'] != 'guest_token') { |
118 | 118 | if (!isset($_GET['redirect_uri'])) { |
119 | 119 | $e = new ExitException( |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | } |
187 | 187 | } |
188 | 188 | /** |
189 | - * Authorization processing |
|
190 | - */ |
|
189 | + * Authorization processing |
|
190 | + */ |
|
191 | 191 | if (isset($_POST['mode'])) { |
192 | 192 | switch ($_POST['mode']) { |
193 | 193 | case 'allow': |
@@ -230,85 +230,85 @@ |
||
230 | 230 | return; |
231 | 231 | } |
232 | 232 | switch ($_GET['response_type']) { |
233 | - case 'code': |
|
234 | - $Response->redirect( |
|
235 | - http_build_url( |
|
236 | - urldecode($redirect_uri), |
|
237 | - [ |
|
238 | - 'code' => $code, |
|
239 | - 'state' => isset($_GET['state']) ? $_GET['state'] : false |
|
240 | - ] |
|
241 | - ), |
|
242 | - 302 |
|
243 | - ); |
|
244 | - $Page->Content = ''; |
|
245 | - return; |
|
246 | - case 'token': |
|
247 | - $token_data = $OAuth2->get_code($code, $client['id'], $client['secret'], $redirect_uri); |
|
248 | - if ($token_data) { |
|
249 | - unset($token_data['refresh_token']); |
|
233 | + case 'code': |
|
250 | 234 | $Response->redirect( |
251 | - uri_for_token( |
|
252 | - http_build_url( |
|
253 | - urldecode($redirect_uri), |
|
254 | - array_merge( |
|
255 | - $token_data, |
|
256 | - [ |
|
257 | - 'state' => isset($_GET['state']) ? $_GET['state'] : false |
|
258 | - ] |
|
259 | - ) |
|
260 | - ) |
|
235 | + http_build_url( |
|
236 | + urldecode($redirect_uri), |
|
237 | + [ |
|
238 | + 'code' => $code, |
|
239 | + 'state' => isset($_GET['state']) ? $_GET['state'] : false |
|
240 | + ] |
|
261 | 241 | ), |
262 | 242 | 302 |
263 | 243 | ); |
264 | 244 | $Page->Content = ''; |
265 | 245 | return; |
266 | - } else { |
|
267 | - error_redirect('server_error', "Server can't get token data, try later"); |
|
268 | - return; |
|
269 | - } |
|
270 | - case 'guest_token': |
|
271 | - $Response |
|
272 | - ->header('cache-control', 'no-store') |
|
273 | - ->header('pragma', 'no-cache'); |
|
274 | - interface_off(); |
|
275 | - if ($User->user()) { |
|
276 | - $e = new ExitException( |
|
277 | - [ |
|
278 | - 'access_denied', |
|
279 | - 'Only guests, not users allowed to access this response_type' |
|
280 | - ], |
|
281 | - 403 |
|
282 | - ); |
|
283 | - $e->setJson(); |
|
284 | - throw $e; |
|
285 | - } |
|
286 | - $code = $OAuth2->add_code($client['id'], 'token', urldecode($_GET['redirect_uri'])); |
|
287 | - if (!$code) { |
|
288 | - $e = new ExitException( |
|
289 | - [ |
|
290 | - 'server_error', |
|
291 | - "Server can't generate code, try later" |
|
292 | - ], |
|
293 | - 500 |
|
294 | - ); |
|
295 | - $e->setJson(); |
|
296 | - throw $e; |
|
297 | - } |
|
298 | - $token_data = $OAuth2->get_code($code, $client['id'], $client['secret'], urldecode($_GET['redirect_uri'])); |
|
299 | - if ($token_data) { |
|
300 | - unset($token_data['refresh_token']); |
|
301 | - $Page->json($token_data); |
|
302 | - return; |
|
303 | - } else { |
|
304 | - $e = new ExitException( |
|
305 | - [ |
|
306 | - 'server_error', |
|
307 | - "Server can't get token data, try later" |
|
308 | - ], |
|
309 | - 500 |
|
310 | - ); |
|
311 | - $e->setJson(); |
|
312 | - throw $e; |
|
313 | - } |
|
246 | + case 'token': |
|
247 | + $token_data = $OAuth2->get_code($code, $client['id'], $client['secret'], $redirect_uri); |
|
248 | + if ($token_data) { |
|
249 | + unset($token_data['refresh_token']); |
|
250 | + $Response->redirect( |
|
251 | + uri_for_token( |
|
252 | + http_build_url( |
|
253 | + urldecode($redirect_uri), |
|
254 | + array_merge( |
|
255 | + $token_data, |
|
256 | + [ |
|
257 | + 'state' => isset($_GET['state']) ? $_GET['state'] : false |
|
258 | + ] |
|
259 | + ) |
|
260 | + ) |
|
261 | + ), |
|
262 | + 302 |
|
263 | + ); |
|
264 | + $Page->Content = ''; |
|
265 | + return; |
|
266 | + } else { |
|
267 | + error_redirect('server_error', "Server can't get token data, try later"); |
|
268 | + return; |
|
269 | + } |
|
270 | + case 'guest_token': |
|
271 | + $Response |
|
272 | + ->header('cache-control', 'no-store') |
|
273 | + ->header('pragma', 'no-cache'); |
|
274 | + interface_off(); |
|
275 | + if ($User->user()) { |
|
276 | + $e = new ExitException( |
|
277 | + [ |
|
278 | + 'access_denied', |
|
279 | + 'Only guests, not users allowed to access this response_type' |
|
280 | + ], |
|
281 | + 403 |
|
282 | + ); |
|
283 | + $e->setJson(); |
|
284 | + throw $e; |
|
285 | + } |
|
286 | + $code = $OAuth2->add_code($client['id'], 'token', urldecode($_GET['redirect_uri'])); |
|
287 | + if (!$code) { |
|
288 | + $e = new ExitException( |
|
289 | + [ |
|
290 | + 'server_error', |
|
291 | + "Server can't generate code, try later" |
|
292 | + ], |
|
293 | + 500 |
|
294 | + ); |
|
295 | + $e->setJson(); |
|
296 | + throw $e; |
|
297 | + } |
|
298 | + $token_data = $OAuth2->get_code($code, $client['id'], $client['secret'], urldecode($_GET['redirect_uri'])); |
|
299 | + if ($token_data) { |
|
300 | + unset($token_data['refresh_token']); |
|
301 | + $Page->json($token_data); |
|
302 | + return; |
|
303 | + } else { |
|
304 | + $e = new ExitException( |
|
305 | + [ |
|
306 | + 'server_error', |
|
307 | + "Server can't get token data, try later" |
|
308 | + ], |
|
309 | + 500 |
|
310 | + ); |
|
311 | + $e->setJson(); |
|
312 | + throw $e; |
|
313 | + } |
|
314 | 314 | } |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * @package CleverStyle CMS |
|
4 | - * @author Nazar Mokrynskyi <[email protected]> |
|
5 | - * @copyright Copyright (c) 2015-2016, Nazar Mokrynskyi |
|
6 | - * @license MIT License, see license.txt |
|
7 | - */ |
|
3 | + * @package CleverStyle CMS |
|
4 | + * @author Nazar Mokrynskyi <[email protected]> |
|
5 | + * @copyright Copyright (c) 2015-2016, Nazar Mokrynskyi |
|
6 | + * @license MIT License, see license.txt |
|
7 | + */ |
|
8 | 8 | /** |
9 | - * Base system functions, do not edit this file, or make it very carefully |
|
10 | - * otherwise system workability may be broken |
|
11 | - * |
|
12 | - * This particular file contains functions that work with global state (cookies, headers, status codes, etc.) |
|
13 | - */ |
|
9 | + * Base system functions, do not edit this file, or make it very carefully |
|
10 | + * otherwise system workability may be broken |
|
11 | + * |
|
12 | + * This particular file contains functions that work with global state (cookies, headers, status codes, etc.) |
|
13 | + */ |
|
14 | 14 | use |
15 | 15 | cs\Config, |
16 | 16 | cs\Request, |
@@ -34,11 +34,11 @@ discard block |
||
34 | 34 | /** |
35 | 35 | * @var int Avatar size in px, can be redefined |
36 | 36 | */ |
37 | - public $avatar_size = 36; |
|
37 | + public $avatar_size = 36; |
|
38 | 38 | |
39 | 39 | protected function construct () { |
40 | - $this->module = Request::instance()->current_module; |
|
41 | - $this->cache = new Cache_prefix("Comments/$this->module"); |
|
40 | + $this->module = Request::instance()->current_module; |
|
41 | + $this->cache = new Cache_prefix("Comments/$this->module"); |
|
42 | 42 | } |
43 | 43 | /** |
44 | 44 | * Set module (current module assumed by default) |
@@ -46,8 +46,8 @@ discard block |
||
46 | 46 | * @param string $module Module name |
47 | 47 | */ |
48 | 48 | function set_module ($module) { |
49 | - $this->module = $module; |
|
50 | - $this->cache = new Cache_prefix("Comments/$this->module"); |
|
49 | + $this->module = $module; |
|
50 | + $this->cache = new Cache_prefix("Comments/$this->module"); |
|
51 | 51 | } |
52 | 52 | /** |
53 | 53 | * Returns database index |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @return array|false Array of comment data on success or <b>false</b> on failure |
66 | 66 | */ |
67 | 67 | function get ($id) { |
68 | - $id = (int)$id; |
|
68 | + $id = (int)$id; |
|
69 | 69 | return $this->db()->qf([ |
70 | 70 | "SELECT |
71 | 71 | `id`, |
@@ -94,14 +94,14 @@ discard block |
||
94 | 94 | * @return array|bool Array of comment data on success or <b>false</b> on failure |
95 | 95 | */ |
96 | 96 | function add ($item, $text, $parent = 0) { |
97 | - $L = Language::instance(); |
|
97 | + $L = Language::instance(); |
|
98 | 98 | $User = User::instance(); |
99 | 99 | $text = xap($text, true); |
100 | 100 | if (!$text) { |
101 | 101 | return false; |
102 | 102 | } |
103 | - $item = (int)$item; |
|
104 | - $parent = (int)$parent; |
|
103 | + $item = (int)$item; |
|
104 | + $parent = (int)$parent; |
|
105 | 105 | if ( |
106 | 106 | $parent != 0 && |
107 | 107 | $this->db_prime()->qfs([ |
@@ -169,12 +169,12 @@ discard block |
||
169 | 169 | * @return array|false Array of comment data on success or <b>false</b> on failure |
170 | 170 | */ |
171 | 171 | function set ($id, $text) { |
172 | - $text = xap($text, true); |
|
172 | + $text = xap($text, true); |
|
173 | 173 | if (!$text) { |
174 | 174 | return false; |
175 | 175 | } |
176 | - $id = (int)$id; |
|
177 | - $comment = $this->get($id); |
|
176 | + $id = (int)$id; |
|
177 | + $comment = $this->get($id); |
|
178 | 178 | if (!$comment) { |
179 | 179 | return false; |
180 | 180 | } |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | $this->module |
191 | 191 | )) { |
192 | 192 | unset($this->cache->{$comment['item']}); |
193 | - $comment['text'] = $text; |
|
193 | + $comment['text'] = $text; |
|
194 | 194 | return $comment; |
195 | 195 | } |
196 | 196 | return false; |
@@ -203,8 +203,8 @@ discard block |
||
203 | 203 | * @return bool |
204 | 204 | */ |
205 | 205 | function del ($id) { |
206 | - $id = (int)$id; |
|
207 | - $comment = $this->db_prime()->qf([ |
|
206 | + $id = (int)$id; |
|
207 | + $comment = $this->db_prime()->qf([ |
|
208 | 208 | "SELECT `p`.`item`, COUNT(`c`.`id`) AS `count` |
209 | 209 | FROM `[prefix]comments` AS `p` |
210 | 210 | LEFT JOIN `[prefix]comments` AS `c` |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @return bool |
242 | 242 | */ |
243 | 243 | function del_all ($item) { |
244 | - $item = (int)$item; |
|
244 | + $item = (int)$item; |
|
245 | 245 | if ($this->db_prime()->q( |
246 | 246 | "DELETE FROM `[prefix]comments` |
247 | 247 | WHERE |
@@ -273,9 +273,9 @@ discard block |
||
273 | 273 | if (!is_array($data)) { |
274 | 274 | return 0; |
275 | 275 | } |
276 | - $count = 0; |
|
276 | + $count = 0; |
|
277 | 277 | foreach ($data as &$d) { |
278 | - $count += $this->count_internal($d['comments']) + 1; |
|
278 | + $count += $this->count_internal($d['comments']) + 1; |
|
279 | 279 | } |
280 | 280 | return $count; |
281 | 281 | } |
@@ -298,12 +298,12 @@ discard block |
||
298 | 298 | * @return false|array |
299 | 299 | */ |
300 | 300 | function tree_data ($item, $parent = 0) { |
301 | - $Cache = $this->cache; |
|
302 | - $L = Language::instance(); |
|
301 | + $Cache = $this->cache; |
|
302 | + $L = Language::instance(); |
|
303 | 303 | if (($comments = $Cache->{"$item/$L->clang"}) === false) { |
304 | - $item = (int)$item; |
|
305 | - $parent = (int)$parent; |
|
306 | - $comments = $this->db()->qfa([ |
|
304 | + $item = (int)$item; |
|
305 | + $parent = (int)$parent; |
|
306 | + $comments = $this->db()->qfa([ |
|
307 | 307 | "SELECT |
308 | 308 | `id`, |
309 | 309 | `parent`, |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | * Cache only root tree data |
329 | 329 | */ |
330 | 330 | if ($parent == 0) { |
331 | - $Cache->{"$item/$L->clang"} = $comments; |
|
331 | + $Cache->{"$item/$L->clang"} = $comments; |
|
332 | 332 | } |
333 | 333 | } |
334 | 334 | return $comments; |
@@ -341,15 +341,15 @@ discard block |
||
341 | 341 | * @return string |
342 | 342 | */ |
343 | 343 | function tree_html ($comments) { |
344 | - $L = Language::instance(); |
|
345 | - $User = User::instance(); |
|
344 | + $L = Language::instance(); |
|
345 | + $User = User::instance(); |
|
346 | 346 | if (!is_array($comments) || !$comments) { |
347 | 347 | return ''; |
348 | 348 | } |
349 | - $content = ''; |
|
349 | + $content = ''; |
|
350 | 350 | foreach ($comments as $comment) { |
351 | - $uniqid = uniqid('comment_', true); |
|
352 | - $content .= str_replace($uniqid, $comment['text'], h::{'article.cs-comments-comment'}( |
|
351 | + $uniqid = uniqid('comment_', true); |
|
352 | + $content .= str_replace($uniqid, $comment['text'], h::{'article.cs-comments-comment'}( |
|
353 | 353 | h::{'img.cs-comments-comment-avatar'}([ |
354 | 354 | 'src' => $User->avatar($this->avatar_size, $comment['user']), |
355 | 355 | 'alt' => $User->username($comment['user']), |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | * @return string |
406 | 406 | */ |
407 | 407 | function block ($item) { |
408 | - $L = new Language_prefix('comments_'); |
|
408 | + $L = new Language_prefix('comments_'); |
|
409 | 409 | return h::{'section#comments.cs-comments-comments'}( |
410 | 410 | $L->comments.':'. |
411 | 411 | ( |
@@ -27,8 +27,8 @@ discard block |
||
27 | 27 | protected $shortname; |
28 | 28 | |
29 | 29 | protected function construct () { |
30 | - $this->module = Request::instance()->current_module; |
|
31 | - $this->shortname = Config::instance()->module('Disqus')->shortname; |
|
30 | + $this->module = Request::instance()->current_module; |
|
31 | + $this->shortname = Config::instance()->module('Disqus')->shortname; |
|
32 | 32 | } |
33 | 33 | /** |
34 | 34 | * Set module (current module assumed by default) |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @param string $module Module name |
37 | 37 | */ |
38 | 38 | function set_module ($module) { |
39 | - $this->module = $module; |
|
39 | + $this->module = $module; |
|
40 | 40 | } |
41 | 41 | /** |
42 | 42 | * Count of comments for specified item |
@@ -73,11 +73,11 @@ discard block |
||
73 | 73 | return '<div id="disqus_thread"></div>'; |
74 | 74 | } |
75 | 75 | protected function count_js () { |
76 | - static $added = false; |
|
76 | + static $added = false; |
|
77 | 77 | if ($added) { |
78 | 78 | return; |
79 | 79 | } |
80 | - $added = true; |
|
80 | + $added = true; |
|
81 | 81 | Page::instance()->js( |
82 | 82 | "var disqus_shortname = '$this->shortname'; |
83 | 83 | if (!window.disqus_count_items) { window.disqus_count_items = []; }", |
@@ -85,11 +85,11 @@ discard block |
||
85 | 85 | ); |
86 | 86 | } |
87 | 87 | protected function block_js ($item) { |
88 | - static $added = false; |
|
88 | + static $added = false; |
|
89 | 89 | if ($added) { |
90 | 90 | return; |
91 | 91 | } |
92 | - $added = true; |
|
92 | + $added = true; |
|
93 | 93 | Page::instance()->js( |
94 | 94 | "var disqus_shortname = '$this->shortname', disqus_identifier = '".str_replace("'", "\'", "$this->module/$item")."';", |
95 | 95 | 'code' |
@@ -27,7 +27,7 @@ |
||
27 | 27 | public function onOpen (ConnectionInterface $conn, RequestInterface $request = null) { |
28 | 28 | $L = Language::instance(); |
29 | 29 | /** @noinspection PhpUndefinedFieldInspection */ |
30 | - $ip = $this->ip( |
|
30 | + $ip = $this->ip( |
|
31 | 31 | [ |
32 | 32 | $conn->remoteAddress, |
33 | 33 | $request->getHeader('X-Forwarded-For'), |
@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * @package OAuth2 |
|
4 | - * @category modules |
|
5 | - * @author Nazar Mokrynskyi <[email protected]> |
|
6 | - * @copyright Copyright (c) 2011-2016, Nazar Mokrynskyi |
|
7 | - * @license MIT License, see license.txt |
|
8 | - */ |
|
3 | + * @package OAuth2 |
|
4 | + * @category modules |
|
5 | + * @author Nazar Mokrynskyi <[email protected]> |
|
6 | + * @copyright Copyright (c) 2011-2016, Nazar Mokrynskyi |
|
7 | + * @license MIT License, see license.txt |
|
8 | + */ |
|
9 | 9 | namespace cs\modules\OAuth2; |
10 | 10 | |
11 | 11 | use |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | ->header('pragma', 'no-cache'); |
21 | 21 | interface_off(); |
22 | 22 | /** |
23 | - * Errors processing |
|
24 | - */ |
|
23 | + * Errors processing |
|
24 | + */ |
|
25 | 25 | $Config = Config::instance(); |
26 | 26 | $Page = Page::instance(); |
27 | 27 | if (!isset($_POST['grant_type'])) { |
@@ -141,8 +141,8 @@ discard block |
||
141 | 141 | throw $e; |
142 | 142 | } |
143 | 143 | /** |
144 | - * Tokens operations processing |
|
145 | - */ |
|
144 | + * Tokens operations processing |
|
145 | + */ |
|
146 | 146 | switch ($_POST['grant_type']) { |
147 | 147 | case 'authorization_code': |
148 | 148 | if (!isset($_POST['code'])) { |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * @package CleverStyle CMS |
|
4 | - * @subpackage CleverStyle theme |
|
5 | - * @author Nazar Mokrynskyi <[email protected]> |
|
6 | - * @copyright Copyright (c) 2013-2016, Nazar Mokrynskyi |
|
7 | - * @license MIT License, see license.txt |
|
8 | - */ |
|
3 | + * @package CleverStyle CMS |
|
4 | + * @subpackage CleverStyle theme |
|
5 | + * @author Nazar Mokrynskyi <[email protected]> |
|
6 | + * @copyright Copyright (c) 2013-2016, Nazar Mokrynskyi |
|
7 | + * @license MIT License, see license.txt |
|
8 | + */ |
|
9 | 9 | namespace cs; |
10 | 10 | if (preg_match('/msie|trident/i', Request::instance()->user_agent)) { |
11 | 11 | Page::instance()->Head .= '<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">'; |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * @package CleverStyle CMS |
|
4 | - * @subpackage DarkEnergy theme |
|
5 | - * @author Nazar Mokrynskyi <[email protected]> |
|
6 | - * @copyright Copyright (c) 2014-2016, Nazar Mokrynskyi |
|
7 | - * @license MIT License, see license.txt |
|
8 | - */ |
|
3 | + * @package CleverStyle CMS |
|
4 | + * @subpackage DarkEnergy theme |
|
5 | + * @author Nazar Mokrynskyi <[email protected]> |
|
6 | + * @copyright Copyright (c) 2014-2016, Nazar Mokrynskyi |
|
7 | + * @license MIT License, see license.txt |
|
8 | + */ |
|
9 | 9 | namespace cs; |
10 | 10 | $Page = Page::instance(); |
11 | 11 | if (preg_match('/msie|trident/i', Request::instance()->user_agent)) { |