@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * @package CleverStyle CMS |
|
4 | - * @subpackage System module |
|
5 | - * @category modules |
|
6 | - * @author Nazar Mokrynskyi <[email protected]> |
|
7 | - * @copyright Copyright (c) 2013-2016, Nazar Mokrynskyi |
|
8 | - * @license MIT License, see license.txt |
|
9 | - */ |
|
3 | + * @package CleverStyle CMS |
|
4 | + * @subpackage System module |
|
5 | + * @category modules |
|
6 | + * @author Nazar Mokrynskyi <[email protected]> |
|
7 | + * @copyright Copyright (c) 2013-2016, Nazar Mokrynskyi |
|
8 | + * @license MIT License, see license.txt |
|
9 | + */ |
|
10 | 10 | namespace cs; |
11 | 11 | use |
12 | 12 | h; |
@@ -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; |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | } |
132 | 132 | $Response = Response::instance(); |
133 | 133 | /** |
134 | - * Authorization processing |
|
135 | - */ |
|
134 | + * Authorization processing |
|
135 | + */ |
|
136 | 136 | if (isset($_POST['mode'])) { |
137 | 137 | if ($_POST['mode'] == 'allow') { |
138 | 138 | $OAuth2->add_access($client['id']); |
@@ -172,43 +172,43 @@ |
||
172 | 172 | return; |
173 | 173 | } |
174 | 174 | switch ($_GET['response_type']) { |
175 | - case 'code': |
|
176 | - $Response->redirect( |
|
177 | - http_build_url( |
|
178 | - urldecode($redirect_uri), |
|
179 | - [ |
|
180 | - 'code' => $code, |
|
181 | - 'state' => isset($_GET['state']) ? $_GET['state'] : false |
|
182 | - ] |
|
183 | - ), |
|
184 | - 302 |
|
185 | - ); |
|
186 | - $Page->Content = ''; |
|
187 | - return; |
|
188 | - case 'token': |
|
189 | - $token_data = $OAuth2->get_code($code, $client['id'], $client['secret'], $redirect_uri); |
|
190 | - if ($token_data) { |
|
191 | - unset($token_data['refresh_token']); |
|
175 | + case 'code': |
|
192 | 176 | $Response->redirect( |
193 | - uri_for_token( |
|
194 | - http_build_url( |
|
195 | - urldecode($redirect_uri), |
|
196 | - array_merge( |
|
197 | - $token_data, |
|
198 | - [ |
|
199 | - 'state' => isset($_GET['state']) ? $_GET['state'] : false |
|
200 | - ] |
|
201 | - ) |
|
202 | - ) |
|
177 | + http_build_url( |
|
178 | + urldecode($redirect_uri), |
|
179 | + [ |
|
180 | + 'code' => $code, |
|
181 | + 'state' => isset($_GET['state']) ? $_GET['state'] : false |
|
182 | + ] |
|
203 | 183 | ), |
204 | 184 | 302 |
205 | 185 | ); |
206 | 186 | $Page->Content = ''; |
207 | 187 | return; |
208 | - } else { |
|
209 | - error_redirect('server_error', "Server can't get token data, try later"); |
|
210 | - return; |
|
211 | - } |
|
212 | - default: |
|
213 | - error_redirect('unsupported_response_type', 'Specified response_type is not supported, only "token" or "code" types available'); |
|
188 | + case 'token': |
|
189 | + $token_data = $OAuth2->get_code($code, $client['id'], $client['secret'], $redirect_uri); |
|
190 | + if ($token_data) { |
|
191 | + unset($token_data['refresh_token']); |
|
192 | + $Response->redirect( |
|
193 | + uri_for_token( |
|
194 | + http_build_url( |
|
195 | + urldecode($redirect_uri), |
|
196 | + array_merge( |
|
197 | + $token_data, |
|
198 | + [ |
|
199 | + 'state' => isset($_GET['state']) ? $_GET['state'] : false |
|
200 | + ] |
|
201 | + ) |
|
202 | + ) |
|
203 | + ), |
|
204 | + 302 |
|
205 | + ); |
|
206 | + $Page->Content = ''; |
|
207 | + return; |
|
208 | + } else { |
|
209 | + error_redirect('server_error', "Server can't get token data, try later"); |
|
210 | + return; |
|
211 | + } |
|
212 | + default: |
|
213 | + error_redirect('unsupported_response_type', 'Specified response_type is not supported, only "token" or "code" types available'); |
|
214 | 214 | } |
@@ -1,15 +1,15 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * @package CleverStyle CMS |
|
4 | - * @author Nazar Mokrynskyi <[email protected]> |
|
5 | - * @copyright Copyright (c) 2011-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) 2011-2016, Nazar Mokrynskyi |
|
6 | + * @license MIT License, see license.txt |
|
7 | + */ |
|
8 | 8 | namespace cs; |
9 | 9 | require __DIR__.'/loader_base.php'; |
10 | 10 | /** |
11 | - * Including of custom files |
|
12 | - */ |
|
11 | + * Including of custom files |
|
12 | + */ |
|
13 | 13 | foreach (glob(CUSTOM.'/*.php') ?: [] as $custom) { |
14 | 14 | include $custom; |
15 | 15 | } |
@@ -1,14 +1,14 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * @package CleverStyle CMS |
|
4 | - * @author Nazar Mokrynskyi <[email protected]> |
|
5 | - * @copyright Copyright (c) 2011-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) 2011-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 | - */ |
|
9 | + * Base system functions, do not edit this file, or make it very carefully |
|
10 | + * otherwise system workability may be broken |
|
11 | + */ |
|
12 | 12 | use |
13 | 13 | cs\App, |
14 | 14 | cs\Cache, |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | cs\Response, |
20 | 20 | cs\Text; |
21 | 21 | /** |
22 | - * Auto Loading of classes |
|
23 | - */ |
|
22 | + * Auto Loading of classes |
|
23 | + */ |
|
24 | 24 | spl_autoload_register(function ($class) { |
25 | 25 | static $cache; |
26 | 26 | if (!isset($cache)) { |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | return false; |
57 | 57 | }, true, true); |
58 | 58 | /** |
59 | - * Clean cache of classes autoload and customization |
|
60 | - */ |
|
59 | + * Clean cache of classes autoload and customization |
|
60 | + */ |
|
61 | 61 | function clean_classes_cache () { |
62 | 62 | if (file_exists(CACHE.'/classes/autoload')) { |
63 | 63 | unlink(CACHE.'/classes/autoload'); |
@@ -128,12 +128,12 @@ discard block |
||
128 | 128 | return false; |
129 | 129 | } |
130 | 130 | /** |
131 | - * Get file destination in file system by it's url |
|
132 | - * |
|
133 | - * @param string $url |
|
134 | - * |
|
135 | - * @return false|string |
|
136 | - */ |
|
131 | + * Get file destination in file system by it's url |
|
132 | + * |
|
133 | + * @param string $url |
|
134 | + * |
|
135 | + * @return false|string |
|
136 | + */ |
|
137 | 137 | function source_by_url ($url) { |
138 | 138 | $Config = Config::instance(true); |
139 | 139 | if (!$Config) { |
@@ -145,10 +145,10 @@ discard block |
||
145 | 145 | return false; |
146 | 146 | } |
147 | 147 | /** |
148 | - * Public cache cleaning |
|
149 | - * |
|
150 | - * @return bool |
|
151 | - */ |
|
148 | + * Public cache cleaning |
|
149 | + * |
|
150 | + * @return bool |
|
151 | + */ |
|
152 | 152 | function clean_pcache () { |
153 | 153 | $ok = true; |
154 | 154 | $list = get_files_list(PUBLIC_CACHE, false, 'fd', true, true, 'name|desc'); |
@@ -163,12 +163,12 @@ discard block |
||
163 | 163 | return $ok; |
164 | 164 | } |
165 | 165 | /** |
166 | - * Formatting of time in seconds to human-readable form |
|
167 | - * |
|
168 | - * @param int $time Time in seconds |
|
169 | - * |
|
170 | - * @return string |
|
171 | - */ |
|
166 | + * Formatting of time in seconds to human-readable form |
|
167 | + * |
|
168 | + * @param int $time Time in seconds |
|
169 | + * |
|
170 | + * @return string |
|
171 | + */ |
|
172 | 172 | function format_time ($time) { |
173 | 173 | if (!is_numeric($time)) { |
174 | 174 | return $time; |
@@ -206,13 +206,13 @@ discard block |
||
206 | 206 | return implode(' ', $res); |
207 | 207 | } |
208 | 208 | /** |
209 | - * Formatting of data size in bytes to human-readable form |
|
210 | - * |
|
211 | - * @param int $size |
|
212 | - * @param bool|int $round |
|
213 | - * |
|
214 | - * @return float|string |
|
215 | - */ |
|
209 | + * Formatting of data size in bytes to human-readable form |
|
210 | + * |
|
211 | + * @param int $size |
|
212 | + * @param bool|int $round |
|
213 | + * |
|
214 | + * @return float|string |
|
215 | + */ |
|
216 | 216 | function format_filesize ($size, $round = false) { |
217 | 217 | if (!is_numeric($size)) { |
218 | 218 | return $size; |
@@ -237,10 +237,10 @@ discard block |
||
237 | 237 | return $round ? round($size, $round).$unit : $size.$unit; |
238 | 238 | } |
239 | 239 | /** |
240 | - * Get list of timezones |
|
241 | - * |
|
242 | - * @return array |
|
243 | - */ |
|
240 | + * Get list of timezones |
|
241 | + * |
|
242 | + * @return array |
|
243 | + */ |
|
244 | 244 | function get_timezones_list () { |
245 | 245 | if ( |
246 | 246 | !class_exists('\\cs\\Cache', false) || |
@@ -276,12 +276,12 @@ discard block |
||
276 | 276 | return $timezones; |
277 | 277 | } |
278 | 278 | /** |
279 | - * Get multilingual value from $Config->core array |
|
280 | - * |
|
281 | - * @param string $item |
|
282 | - * |
|
283 | - * @return false|string |
|
284 | - */ |
|
279 | + * Get multilingual value from $Config->core array |
|
280 | + * |
|
281 | + * @param string $item |
|
282 | + * |
|
283 | + * @return false|string |
|
284 | + */ |
|
285 | 285 | function get_core_ml_text ($item) { |
286 | 286 | $Config = Config::instance(true); |
287 | 287 | if (!$Config) { |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | * Try to load classes from different places. If not found in one place - try in another. |
41 | 41 | */ |
42 | 42 | if ( |
43 | - _require_once($file = DIR."/core/classes/$namespace/$class_name.php", false) || //Core classes |
|
43 | + _require_once($file = DIR."/core/classes/$namespace/$class_name.php", false) || //Core classes |
|
44 | 44 | _require_once($file = DIR."/core/thirdparty/$namespace/$class_name.php", false) || //Third party classes |
45 | - _require_once($file = DIR."/core/traits/$namespace/$class_name.php", false) || //Core traits |
|
46 | - _require_once($file = ENGINES."/$namespace/$class_name.php", false) || //Core engines |
|
47 | - _require_once($file = MODULES."/../$namespace/$class_name.php", false) || //Classes in modules |
|
45 | + _require_once($file = DIR."/core/traits/$namespace/$class_name.php", false) || //Core traits |
|
46 | + _require_once($file = ENGINES."/$namespace/$class_name.php", false) || //Core engines |
|
47 | + _require_once($file = MODULES."/../$namespace/$class_name.php", false) || //Classes in modules |
|
48 | 48 | _require_once($file = PLUGINS."/../$namespace/$class_name.php", false) //Classes in plugins |
49 | 49 | ) { |
50 | 50 | $cache[$class] = realpath($file); |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @return false|string |
118 | 118 | */ |
119 | 119 | function url_by_source ($source) { |
120 | - $Config = Config::instance(true); |
|
120 | + $Config = Config::instance(true); |
|
121 | 121 | if (!$Config) { |
122 | 122 | return false; |
123 | 123 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * @return false|string |
136 | 136 | */ |
137 | 137 | function source_by_url ($url) { |
138 | - $Config = Config::instance(true); |
|
138 | + $Config = Config::instance(true); |
|
139 | 139 | if (!$Config) { |
140 | 140 | return false; |
141 | 141 | } |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | if (!is_numeric($time)) { |
174 | 174 | return $time; |
175 | 175 | } |
176 | - $L = Language::instance(); |
|
177 | - $res = []; |
|
176 | + $L = Language::instance(); |
|
177 | + $res = []; |
|
178 | 178 | if ($time >= 31536000) { |
179 | 179 | $time_x = round($time / 31536000); |
180 | 180 | $time -= $time_x * 31536000; |
@@ -185,12 +185,12 @@ discard block |
||
185 | 185 | $time -= $time_x * 2592000; |
186 | 186 | $res[] = $L->time($time_x, 'M'); |
187 | 187 | } |
188 | - if($time >= 86400) { |
|
188 | + if ($time >= 86400) { |
|
189 | 189 | $time_x = round($time / 86400); |
190 | 190 | $time -= $time_x * 86400; |
191 | 191 | $res[] = $L->time($time_x, 'd'); |
192 | 192 | } |
193 | - if($time >= 3600) { |
|
193 | + if ($time >= 3600) { |
|
194 | 194 | $time_x = round($time / 3600); |
195 | 195 | $time -= $time_x * 3600; |
196 | 196 | $res[] = $L->time($time_x, 'h'); |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | $timezones_ = $timezones = []; |
252 | 252 | foreach ($tzs as $tz) { |
253 | 253 | $offset = (new DateTimeZone($tz))->getOffset(new DateTime); |
254 | - $offset_ = ($offset < 0 ? '-' : '+'). |
|
254 | + $offset_ = ($offset < 0 ? '-' : '+'). |
|
255 | 255 | str_pad(floor(abs($offset / 3600)), 2, 0, STR_PAD_LEFT).':'. |
256 | 256 | str_pad(abs(($offset % 3600) / 60), 2, 0, STR_PAD_LEFT); |
257 | 257 | $timezones_[(39600 + $offset).$tz] = [ |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | * @return false|string |
284 | 284 | */ |
285 | 285 | function get_core_ml_text ($item) { |
286 | - $Config = Config::instance(true); |
|
286 | + $Config = Config::instance(true); |
|
287 | 287 | if (!$Config) { |
288 | 288 | return false; |
289 | 289 | } |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | ] |
425 | 425 | ); |
426 | 426 | }; |
427 | - $render_page_item = function ($i) use ($page, $url, $head_links, $render_head_links) { |
|
427 | + $render_page_item = function ($i) use ($page, $url, $head_links, $render_head_links) { |
|
428 | 428 | if ($head_links) { |
429 | 429 | $render_head_links($i); |
430 | 430 | } |
@@ -517,14 +517,14 @@ discard block |
||
517 | 517 | } |
518 | 518 | $output = []; |
519 | 519 | if (!is_callable($url)) { |
520 | - $original_url = $url; |
|
520 | + $original_url = $url; |
|
521 | 521 | $url = function ($page) use ($original_url) { |
522 | 522 | return sprintf($original_url, $page); |
523 | 523 | }; |
524 | 524 | } |
525 | 525 | if ($total <= 11) { |
526 | 526 | for ($i = 1; $i <= $total; ++$i) { |
527 | - $output[] = [ |
|
527 | + $output[] = [ |
|
528 | 528 | $i, |
529 | 529 | [ |
530 | 530 | 'is' => 'cs-button', |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | } else { |
539 | 539 | if ($page <= 6) { |
540 | 540 | for ($i = 1; $i <= 7; ++$i) { |
541 | - $output[] = [ |
|
541 | + $output[] = [ |
|
542 | 542 | $i, |
543 | 543 | [ |
544 | 544 | 'is' => 'cs-button', |
@@ -549,7 +549,7 @@ discard block |
||
549 | 549 | ] |
550 | 550 | ]; |
551 | 551 | } |
552 | - $output[] = [ |
|
552 | + $output[] = [ |
|
553 | 553 | '...', |
554 | 554 | [ |
555 | 555 | 'is' => 'cs-button', |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | ] |
559 | 559 | ]; |
560 | 560 | for ($i = $total - 2; $i <= $total; ++$i) { |
561 | - $output[] = [ |
|
561 | + $output[] = [ |
|
562 | 562 | $i, |
563 | 563 | [ |
564 | 564 | 'is' => 'cs-button', |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | } |
571 | 571 | } elseif ($page >= $total - 5) { |
572 | 572 | for ($i = 1; $i <= 3; ++$i) { |
573 | - $output[] = [ |
|
573 | + $output[] = [ |
|
574 | 574 | $i, |
575 | 575 | [ |
576 | 576 | 'is' => 'cs-button', |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | ] |
581 | 581 | ]; |
582 | 582 | } |
583 | - $output[] = [ |
|
583 | + $output[] = [ |
|
584 | 584 | '...', |
585 | 585 | [ |
586 | 586 | 'is' => 'cs-button', |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | ] |
590 | 590 | ]; |
591 | 591 | for ($i = $total - 6; $i <= $total; ++$i) { |
592 | - $output[] = [ |
|
592 | + $output[] = [ |
|
593 | 593 | $i, |
594 | 594 | [ |
595 | 595 | 'is' => 'cs-button', |
@@ -602,7 +602,7 @@ discard block |
||
602 | 602 | } |
603 | 603 | } else { |
604 | 604 | for ($i = 1; $i <= 2; ++$i) { |
605 | - $output[] = [ |
|
605 | + $output[] = [ |
|
606 | 606 | $i, |
607 | 607 | [ |
608 | 608 | 'is' => 'cs-button', |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | ] |
613 | 613 | ]; |
614 | 614 | } |
615 | - $output[] = [ |
|
615 | + $output[] = [ |
|
616 | 616 | '...', |
617 | 617 | [ |
618 | 618 | 'is' => 'cs-button', |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | ] |
622 | 622 | ]; |
623 | 623 | for ($i = $page - 2; $i <= $page + 2; ++$i) { |
624 | - $output[] = [ |
|
624 | + $output[] = [ |
|
625 | 625 | $i, |
626 | 626 | [ |
627 | 627 | 'is' => 'cs-button', |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | ] |
633 | 633 | ]; |
634 | 634 | } |
635 | - $output[] = [ |
|
635 | + $output[] = [ |
|
636 | 636 | '...', |
637 | 637 | [ |
638 | 638 | 'is' => 'cs-button', |
@@ -641,7 +641,7 @@ discard block |
||
641 | 641 | ] |
642 | 642 | ]; |
643 | 643 | for ($i = $total - 1; $i <= $total; ++$i) { |
644 | - $output[] = [ |
|
644 | + $output[] = [ |
|
645 | 645 | $i, |
646 | 646 | [ |
647 | 647 | 'is' => 'cs-button', |