@@ -29,48 +29,48 @@ |
||
29 | 29 | } |
30 | 30 | |
31 | 31 | switch ($data['function']) { |
32 | - default: |
|
33 | - return; |
|
34 | - case 'get_files_list': |
|
35 | - echo _json_encode(get_files_list($data['dir'], $data['mask'], $data['mode'], $data['prefix_path'], $data['subfolders'], $data['sort'], $data['exclusion'], $data['system_files'], null, $data['limit'])); |
|
36 | - return; |
|
37 | - case 'file': |
|
38 | - echo _json_encode(file($data['filename'], $data['flags'])); |
|
39 | - return; |
|
40 | - case 'file_get_contents': |
|
41 | - echo file_get_contents($data['filename'], $data['flags'], null, $data['offset'], $data['maxlen']); |
|
42 | - return; |
|
43 | - case 'file_put_contents': |
|
44 | - echo file_put_contents($data['filename'], $data['data'], $data['flags']); |
|
45 | - return; |
|
46 | - case 'copy': |
|
47 | - echo copy($data['source'], $data['dest']); |
|
48 | - return; |
|
49 | - case 'unlink': |
|
50 | - echo unlink($data['filename']); |
|
51 | - return; |
|
52 | - case 'file_exists': |
|
53 | - echo file_exists($data['filename']); |
|
54 | - return; |
|
55 | - case 'move_uploaded_file': |
|
56 | - echo copy($data['filename'], $data['destination']); |
|
57 | - return; |
|
58 | - case 'rename': |
|
59 | - echo rename($data['oldname'], $data['newname']); |
|
60 | - return; |
|
61 | - case 'mkdir': |
|
62 | - echo mkdir($data['pathname']); |
|
63 | - return; |
|
64 | - case 'rmdir': |
|
65 | - echo rmdir($data['dirname']); |
|
66 | - return; |
|
67 | - case 'is_file': |
|
68 | - echo is_file($data['filename']); |
|
69 | - return; |
|
70 | - case 'is_dir': |
|
71 | - echo is_dir($data['filename']); |
|
72 | - return; |
|
73 | - case 'test': |
|
74 | - echo 'OK'; |
|
75 | - return; |
|
32 | + default: |
|
33 | + return; |
|
34 | + case 'get_files_list': |
|
35 | + echo _json_encode(get_files_list($data['dir'], $data['mask'], $data['mode'], $data['prefix_path'], $data['subfolders'], $data['sort'], $data['exclusion'], $data['system_files'], null, $data['limit'])); |
|
36 | + return; |
|
37 | + case 'file': |
|
38 | + echo _json_encode(file($data['filename'], $data['flags'])); |
|
39 | + return; |
|
40 | + case 'file_get_contents': |
|
41 | + echo file_get_contents($data['filename'], $data['flags'], null, $data['offset'], $data['maxlen']); |
|
42 | + return; |
|
43 | + case 'file_put_contents': |
|
44 | + echo file_put_contents($data['filename'], $data['data'], $data['flags']); |
|
45 | + return; |
|
46 | + case 'copy': |
|
47 | + echo copy($data['source'], $data['dest']); |
|
48 | + return; |
|
49 | + case 'unlink': |
|
50 | + echo unlink($data['filename']); |
|
51 | + return; |
|
52 | + case 'file_exists': |
|
53 | + echo file_exists($data['filename']); |
|
54 | + return; |
|
55 | + case 'move_uploaded_file': |
|
56 | + echo copy($data['filename'], $data['destination']); |
|
57 | + return; |
|
58 | + case 'rename': |
|
59 | + echo rename($data['oldname'], $data['newname']); |
|
60 | + return; |
|
61 | + case 'mkdir': |
|
62 | + echo mkdir($data['pathname']); |
|
63 | + return; |
|
64 | + case 'rmdir': |
|
65 | + echo rmdir($data['dirname']); |
|
66 | + return; |
|
67 | + case 'is_file': |
|
68 | + echo is_file($data['filename']); |
|
69 | + return; |
|
70 | + case 'is_dir': |
|
71 | + echo is_dir($data['filename']); |
|
72 | + return; |
|
73 | + case 'test': |
|
74 | + echo 'OK'; |
|
75 | + return; |
|
76 | 76 | } |
@@ -230,84 +230,84 @@ |
||
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 | - if ($User->user()) { |
|
275 | - $e = new ExitException( |
|
276 | - [ |
|
277 | - 'access_denied', |
|
278 | - 'Only guests, not users allowed to access this response_type' |
|
279 | - ], |
|
280 | - 403 |
|
281 | - ); |
|
282 | - $e->setJson(); |
|
283 | - throw $e; |
|
284 | - } |
|
285 | - $code = $OAuth2->add_code($client['id'], 'token', urldecode($_GET['redirect_uri'])); |
|
286 | - if (!$code) { |
|
287 | - $e = new ExitException( |
|
288 | - [ |
|
289 | - 'server_error', |
|
290 | - "Server can't generate code, try later" |
|
291 | - ], |
|
292 | - 500 |
|
293 | - ); |
|
294 | - $e->setJson(); |
|
295 | - throw $e; |
|
296 | - } |
|
297 | - $token_data = $OAuth2->get_code($code, $client['id'], $client['secret'], urldecode($_GET['redirect_uri'])); |
|
298 | - if ($token_data) { |
|
299 | - unset($token_data['refresh_token']); |
|
300 | - $Page->json($token_data); |
|
301 | - return; |
|
302 | - } else { |
|
303 | - $e = new ExitException( |
|
304 | - [ |
|
305 | - 'server_error', |
|
306 | - "Server can't get token data, try later" |
|
307 | - ], |
|
308 | - 500 |
|
309 | - ); |
|
310 | - $e->setJson(); |
|
311 | - throw $e; |
|
312 | - } |
|
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 | + if ($User->user()) { |
|
275 | + $e = new ExitException( |
|
276 | + [ |
|
277 | + 'access_denied', |
|
278 | + 'Only guests, not users allowed to access this response_type' |
|
279 | + ], |
|
280 | + 403 |
|
281 | + ); |
|
282 | + $e->setJson(); |
|
283 | + throw $e; |
|
284 | + } |
|
285 | + $code = $OAuth2->add_code($client['id'], 'token', urldecode($_GET['redirect_uri'])); |
|
286 | + if (!$code) { |
|
287 | + $e = new ExitException( |
|
288 | + [ |
|
289 | + 'server_error', |
|
290 | + "Server can't generate code, try later" |
|
291 | + ], |
|
292 | + 500 |
|
293 | + ); |
|
294 | + $e->setJson(); |
|
295 | + throw $e; |
|
296 | + } |
|
297 | + $token_data = $OAuth2->get_code($code, $client['id'], $client['secret'], urldecode($_GET['redirect_uri'])); |
|
298 | + if ($token_data) { |
|
299 | + unset($token_data['refresh_token']); |
|
300 | + $Page->json($token_data); |
|
301 | + return; |
|
302 | + } else { |
|
303 | + $e = new ExitException( |
|
304 | + [ |
|
305 | + 'server_error', |
|
306 | + "Server can't get token data, try later" |
|
307 | + ], |
|
308 | + 500 |
|
309 | + ); |
|
310 | + $e->setJson(); |
|
311 | + throw $e; |
|
312 | + } |
|
313 | 313 | } |