From c1a8d90ea641791e8f448bb60d9cbc7e5221be26 Mon Sep 17 00:00:00 2001 From: nao-pon Date: Sun, 13 Nov 2016 00:35:53 +0900 Subject: [PATCH] [VD:GoogleDrive,OneDrive,Box] CS fixes --- php/elFinderVolumeBox.class.php | 43 +++++++++++++------------ php/elFinderVolumeGoogleDrive.class.php | 2 +- php/elFinderVolumeOneDrive.class.php | 41 +++++++++++------------ 3 files changed, 44 insertions(+), 42 deletions(-) diff --git a/php/elFinderVolumeBox.class.php b/php/elFinderVolumeBox.class.php index c0449d961..f566a6ea5 100644 --- a/php/elFinderVolumeBox.class.php +++ b/php/elFinderVolumeBox.class.php @@ -235,9 +235,9 @@ class elFinderVolumeBox extends elFinderVolumeDriver protected function _bd_refreshToken($token) { if ($token->expires < time()) { - if (! isset($token->data->refresh_token) || $token->data->refresh_token === null) { - $this->session->remove('BoxTokens'); - throw new \Exception(elFinder::ERROR_REAUTH_REQUIRE); + if (!isset($token->data->refresh_token) || $token->data->refresh_token === null) { + $this->session->remove('BoxTokens'); + throw new \Exception(elFinder::ERROR_REAUTH_REQUIRE); } if (null === $this->options['client_id']) { @@ -609,19 +609,19 @@ class elFinderVolumeBox extends elFinderVolumeDriver } if ($options['user'] === 'init') { - $this->token = $this->session->get('BoxTokens'); - - if ($this->token) { - try { - $this->_bd_refreshToken($this->token); - } catch (Exception $e) { - $this->error($e->getMessage()); - $this->token = null; - $this->session->remove('BoxTokens'); - } - } - - if (empty($this->token)) { + $this->token = $this->session->get('BoxTokens'); + + if ($this->token) { + try { + $this->_bd_refreshToken($this->token); + } catch (Exception $e) { + $this->error($e->getMessage()); + $this->token = null; + $this->session->remove('BoxTokens'); + } + } + + if (empty($this->token)) { $cdata = ''; $innerKeys = array('cmd', 'host', 'options', 'pass', 'protocol', 'user'); $this->ARGS = $_SERVER['REQUEST_METHOD'] === 'POST' ? $_POST : $_GET; @@ -640,7 +640,7 @@ class elFinderVolumeBox extends elFinderVolumeDriver $this->session->set('BoxTokens', (object) array('token' => null)); $url = self::AUTH_URL.'?'.http_build_query(array('response_type' => 'code', 'client_id' => $options['client_id'], 'redirect_uri' => elFinder::getConnectorUrl().'?cmd=netmount&protocol=box&host=1')); - + $url .= '&oauth_callback='.rawurlencode($callback); } catch (Exception $e) { return array('exit' => true, 'body' => '{msg:errAccess}'); @@ -666,7 +666,7 @@ class elFinderVolumeBox extends elFinderVolumeDriver $folders = ['root' => 'My Box'] + $folders; $folders = json_encode($folders); - $expires = empty($this->token->data->refresh_token)? (int) $this->token->expires : 0; + $expires = empty($this->token->data->refresh_token) ? (int) $this->token->expires : 0; $json = '{"protocol": "box", "mode": "done", "folders": '.$folders.', "expires": '.$expires.'}'; $html = 'Box.com'; $html .= '