/** * Open file and return file pointer. * * @param string $path file path * @param bool $write open file for writing * * @return resource|false * * @author Dmitry (dio) Levashov **/ protected function _fopen($path, $mode = 'rb') { if ($mode === 'rb' || $mode === 'r') { if ($file = $this->_gd_getFile($path)) { if ($dlurl = $this->_gd_getDownloadUrl($file)) { $token = $this->client->getAccessToken(); $access_token = ''; if (is_array($token)) { $access_token = $token['access_token']; } else { if ($token = json_decode($client->getAccessToken())) { $access_token = $token->access_token; } } if ($access_token) { $data = array('target' => $dlurl, 'headers' => array('Authorization: Bearer ' . $access_token)); return elFinder::getStreamByUrl($data); } } } } return false; }
/** * Open file and return file pointer. * * @param string $path file path * @param bool $write open file for writing * * @return resource|false * * @author Dmitry (dio) Levashov **/ protected function _fopen($path, $mode = 'rb') { if ($mode === 'rb' || $mode === 'r') { list(, $itemId) = $this->_bd_splitPath($path); $data = array('target' => self::API_URL . '/files/' . $itemId . '/content', 'headers' => array('Authorization: Bearer ' . $this->token->data->access_token)); return elFinder::getStreamByUrl($data); } return false; }