Edit File by line
/home/barbar84/www/wp-conte.../plugins/wp-file-.../lib/php
File: elFinderVolumeBox.class.php
<?php
[0] Fix | Delete
[1] Fix | Delete
/**
[2] Fix | Delete
* Simple elFinder driver for BoxDrive
[3] Fix | Delete
* Box.com API v2.0.
[4] Fix | Delete
*
[5] Fix | Delete
* @author Dmitry (dio) Levashov
[6] Fix | Delete
* @author Cem (discofever)
[7] Fix | Delete
**/
[8] Fix | Delete
class elFinderVolumeBox extends elFinderVolumeDriver
[9] Fix | Delete
{
[10] Fix | Delete
/**
[11] Fix | Delete
* Driver id
[12] Fix | Delete
* Must be started from letter and contains [a-z0-9]
[13] Fix | Delete
* Used as part of volume id.
[14] Fix | Delete
*
[15] Fix | Delete
* @var string
[16] Fix | Delete
**/
[17] Fix | Delete
protected $driverId = 'bd';
[18] Fix | Delete
[19] Fix | Delete
/**
[20] Fix | Delete
* @var string The base URL for API requests
[21] Fix | Delete
*/
[22] Fix | Delete
const API_URL = 'https://api.box.com/2.0';
[23] Fix | Delete
[24] Fix | Delete
/**
[25] Fix | Delete
* @var string The base URL for authorization requests
[26] Fix | Delete
*/
[27] Fix | Delete
const AUTH_URL = 'https://account.box.com/api/oauth2/authorize';
[28] Fix | Delete
[29] Fix | Delete
/**
[30] Fix | Delete
* @var string The base URL for token requests
[31] Fix | Delete
*/
[32] Fix | Delete
const TOKEN_URL = 'https://api.box.com/oauth2/token';
[33] Fix | Delete
[34] Fix | Delete
/**
[35] Fix | Delete
* @var string The base URL for upload requests
[36] Fix | Delete
*/
[37] Fix | Delete
const UPLOAD_URL = 'https://upload.box.com/api/2.0';
[38] Fix | Delete
[39] Fix | Delete
/**
[40] Fix | Delete
* Fetch fields list.
[41] Fix | Delete
*
[42] Fix | Delete
* @var string
[43] Fix | Delete
*/
[44] Fix | Delete
const FETCHFIELDS = 'type,id,name,created_at,modified_at,description,size,parent,permissions,file_version,shared_link';
[45] Fix | Delete
[46] Fix | Delete
/**
[47] Fix | Delete
* Box.com token object.
[48] Fix | Delete
*
[49] Fix | Delete
* @var object
[50] Fix | Delete
**/
[51] Fix | Delete
protected $token = null;
[52] Fix | Delete
[53] Fix | Delete
/**
[54] Fix | Delete
* Directory for tmp files
[55] Fix | Delete
* If not set driver will try to use tmbDir as tmpDir.
[56] Fix | Delete
*
[57] Fix | Delete
* @var string
[58] Fix | Delete
**/
[59] Fix | Delete
protected $tmp = '';
[60] Fix | Delete
[61] Fix | Delete
/**
[62] Fix | Delete
* Net mount key.
[63] Fix | Delete
*
[64] Fix | Delete
* @var string
[65] Fix | Delete
**/
[66] Fix | Delete
public $netMountKey = '';
[67] Fix | Delete
[68] Fix | Delete
/**
[69] Fix | Delete
* Thumbnail prefix.
[70] Fix | Delete
*
[71] Fix | Delete
* @var string
[72] Fix | Delete
**/
[73] Fix | Delete
private $tmbPrefix = '';
[74] Fix | Delete
[75] Fix | Delete
/**
[76] Fix | Delete
* Path to access token file for permanent mount
[77] Fix | Delete
*
[78] Fix | Delete
* @var string
[79] Fix | Delete
*/
[80] Fix | Delete
private $aTokenFile = '';
[81] Fix | Delete
[82] Fix | Delete
/**
[83] Fix | Delete
* hasCache by folders.
[84] Fix | Delete
*
[85] Fix | Delete
* @var array
[86] Fix | Delete
**/
[87] Fix | Delete
protected $HasdirsCache = array();
[88] Fix | Delete
[89] Fix | Delete
/**
[90] Fix | Delete
* Constructor
[91] Fix | Delete
* Extend options with required fields.
[92] Fix | Delete
*
[93] Fix | Delete
* @author Dmitry (dio) Levashov
[94] Fix | Delete
* @author Cem (DiscoFever)
[95] Fix | Delete
**/
[96] Fix | Delete
public function __construct()
[97] Fix | Delete
{
[98] Fix | Delete
$opts = array(
[99] Fix | Delete
'client_id' => '',
[100] Fix | Delete
'client_secret' => '',
[101] Fix | Delete
'accessToken' => '',
[102] Fix | Delete
'root' => 'Box.com',
[103] Fix | Delete
'path' => '/',
[104] Fix | Delete
'separator' => '/',
[105] Fix | Delete
'tmbPath' => '',
[106] Fix | Delete
'tmbURL' => '',
[107] Fix | Delete
'tmpPath' => '',
[108] Fix | Delete
'acceptedName' => '#^[^\\\/]+$#',
[109] Fix | Delete
'rootCssClass' => 'elfinder-navbar-root-box',
[110] Fix | Delete
);
[111] Fix | Delete
$this->options = array_merge($this->options, $opts);
[112] Fix | Delete
$this->options['mimeDetect'] = 'internal';
[113] Fix | Delete
}
[114] Fix | Delete
[115] Fix | Delete
/*********************************************************************/
[116] Fix | Delete
/* ORIGINAL FUNCTIONS */
[117] Fix | Delete
/*********************************************************************/
[118] Fix | Delete
[119] Fix | Delete
/**
[120] Fix | Delete
* Get Parent ID, Item ID, Parent Path as an array from path.
[121] Fix | Delete
*
[122] Fix | Delete
* @param string $path
[123] Fix | Delete
*
[124] Fix | Delete
* @return array
[125] Fix | Delete
*/
[126] Fix | Delete
protected function _bd_splitPath($path)
[127] Fix | Delete
{
[128] Fix | Delete
$path = trim($path, '/');
[129] Fix | Delete
$pid = '';
[130] Fix | Delete
if ($path === '') {
[131] Fix | Delete
$id = '0';
[132] Fix | Delete
$parent = '';
[133] Fix | Delete
} else {
[134] Fix | Delete
$paths = explode('/', trim($path, '/'));
[135] Fix | Delete
$id = array_pop($paths);
[136] Fix | Delete
if ($paths) {
[137] Fix | Delete
$parent = '/' . implode('/', $paths);
[138] Fix | Delete
$pid = array_pop($paths);
[139] Fix | Delete
} else {
[140] Fix | Delete
$pid = '0';
[141] Fix | Delete
$parent = '/';
[142] Fix | Delete
}
[143] Fix | Delete
}
[144] Fix | Delete
[145] Fix | Delete
return array($pid, $id, $parent);
[146] Fix | Delete
}
[147] Fix | Delete
[148] Fix | Delete
/**
[149] Fix | Delete
* Obtains a new access token from OAuth. This token is valid for one hour.
[150] Fix | Delete
*
[151] Fix | Delete
* @param string $clientSecret The Box client secret
[152] Fix | Delete
* @param string $code The code returned by Box after
[153] Fix | Delete
* successful log in
[154] Fix | Delete
* @param string $redirectUri Must be the same as the redirect URI passed
[155] Fix | Delete
* to LoginUrl
[156] Fix | Delete
*
[157] Fix | Delete
* @return bool|object
[158] Fix | Delete
* @throws \Exception Thrown if this Client instance's clientId is not set
[159] Fix | Delete
* @throws \Exception Thrown if the redirect URI of this Client instance's
[160] Fix | Delete
* state is not set
[161] Fix | Delete
*/
[162] Fix | Delete
protected function _bd_obtainAccessToken($client_id, $client_secret, $code)
[163] Fix | Delete
{
[164] Fix | Delete
if (null === $client_id) {
[165] Fix | Delete
return $this->setError('The client ID must be set to call obtainAccessToken()');
[166] Fix | Delete
}
[167] Fix | Delete
[168] Fix | Delete
if (null === $client_secret) {
[169] Fix | Delete
return $this->setError('The client Secret must be set to call obtainAccessToken()');
[170] Fix | Delete
}
[171] Fix | Delete
[172] Fix | Delete
if (null === $code) {
[173] Fix | Delete
return $this->setError('Authorization code must be set to call obtainAccessToken()');
[174] Fix | Delete
}
[175] Fix | Delete
[176] Fix | Delete
$url = self::TOKEN_URL;
[177] Fix | Delete
[178] Fix | Delete
$curl = curl_init();
[179] Fix | Delete
[180] Fix | Delete
$fields = http_build_query(
[181] Fix | Delete
array(
[182] Fix | Delete
'client_id' => $client_id,
[183] Fix | Delete
'client_secret' => $client_secret,
[184] Fix | Delete
'code' => $code,
[185] Fix | Delete
'grant_type' => 'authorization_code',
[186] Fix | Delete
)
[187] Fix | Delete
);
[188] Fix | Delete
[189] Fix | Delete
curl_setopt_array($curl, array(
[190] Fix | Delete
// General options.
[191] Fix | Delete
CURLOPT_RETURNTRANSFER => true,
[192] Fix | Delete
CURLOPT_POST => true,
[193] Fix | Delete
CURLOPT_POSTFIELDS => $fields,
[194] Fix | Delete
CURLOPT_URL => $url,
[195] Fix | Delete
));
[196] Fix | Delete
[197] Fix | Delete
$decoded = $this->_bd_curlExec($curl, true, array('Content-Length: ' . strlen($fields)));
[198] Fix | Delete
[199] Fix | Delete
$res = (object)array(
[200] Fix | Delete
'expires' => time() + $decoded->expires_in - 30,
[201] Fix | Delete
'initialToken' => '',
[202] Fix | Delete
'data' => $decoded
[203] Fix | Delete
);
[204] Fix | Delete
if (!empty($decoded->refresh_token)) {
[205] Fix | Delete
$res->initialToken = md5($client_id . $decoded->refresh_token);
[206] Fix | Delete
}
[207] Fix | Delete
return $res;
[208] Fix | Delete
}
[209] Fix | Delete
[210] Fix | Delete
/**
[211] Fix | Delete
* Get token and auto refresh.
[212] Fix | Delete
*
[213] Fix | Delete
* @return true|string error message
[214] Fix | Delete
* @throws Exception
[215] Fix | Delete
*/
[216] Fix | Delete
protected function _bd_refreshToken()
[217] Fix | Delete
{
[218] Fix | Delete
if (!property_exists($this->token, 'expires') || $this->token->expires < time()) {
[219] Fix | Delete
if (!$this->options['client_id']) {
[220] Fix | Delete
$this->options['client_id'] = ELFINDER_BOX_CLIENTID;
[221] Fix | Delete
}
[222] Fix | Delete
[223] Fix | Delete
if (!$this->options['client_secret']) {
[224] Fix | Delete
$this->options['client_secret'] = ELFINDER_BOX_CLIENTSECRET;
[225] Fix | Delete
}
[226] Fix | Delete
[227] Fix | Delete
if (empty($this->token->data->refresh_token)) {
[228] Fix | Delete
throw new \Exception(elFinder::ERROR_REAUTH_REQUIRE);
[229] Fix | Delete
} else {
[230] Fix | Delete
$refresh_token = $this->token->data->refresh_token;
[231] Fix | Delete
$initialToken = $this->_bd_getInitialToken();
[232] Fix | Delete
}
[233] Fix | Delete
[234] Fix | Delete
$lock = '';
[235] Fix | Delete
$aTokenFile = $this->aTokenFile? $this->aTokenFile : $this->_bd_getATokenFile();
[236] Fix | Delete
if ($aTokenFile && is_file($aTokenFile)) {
[237] Fix | Delete
$lock = $aTokenFile . '.lock';
[238] Fix | Delete
if (file_exists($lock)) {
[239] Fix | Delete
// Probably updating on other instance
[240] Fix | Delete
return true;
[241] Fix | Delete
}
[242] Fix | Delete
touch($lock);
[243] Fix | Delete
$GLOBALS['elFinderTempFiles'][$lock] = true;
[244] Fix | Delete
}
[245] Fix | Delete
[246] Fix | Delete
$postData = array(
[247] Fix | Delete
'client_id' => $this->options['client_id'],
[248] Fix | Delete
'client_secret' => $this->options['client_secret'],
[249] Fix | Delete
'grant_type' => 'refresh_token',
[250] Fix | Delete
'refresh_token' => $refresh_token
[251] Fix | Delete
);
[252] Fix | Delete
[253] Fix | Delete
$url = self::TOKEN_URL;
[254] Fix | Delete
[255] Fix | Delete
$curl = curl_init();
[256] Fix | Delete
[257] Fix | Delete
curl_setopt_array($curl, array(
[258] Fix | Delete
// General options.
[259] Fix | Delete
CURLOPT_RETURNTRANSFER => true,
[260] Fix | Delete
CURLOPT_POST => true, // i am sending post data
[261] Fix | Delete
CURLOPT_POSTFIELDS => http_build_query($postData),
[262] Fix | Delete
CURLOPT_URL => $url,
[263] Fix | Delete
));
[264] Fix | Delete
[265] Fix | Delete
$decoded = $error = '';
[266] Fix | Delete
try {
[267] Fix | Delete
$decoded = $this->_bd_curlExec($curl, true, array(), $postData);
[268] Fix | Delete
} catch (Exception $e) {
[269] Fix | Delete
$error = $e->getMessage();
[270] Fix | Delete
}
[271] Fix | Delete
if (!$decoded && !$error) {
[272] Fix | Delete
$error = 'Tried to renew the access token, but did not get a response from the Box server.';
[273] Fix | Delete
}
[274] Fix | Delete
if ($error) {
[275] Fix | Delete
$lock && unlink($lock);
[276] Fix | Delete
throw new \Exception('Box access token update failed. ('.$error.') If this message appears repeatedly, please notify the administrator.');
[277] Fix | Delete
}
[278] Fix | Delete
[279] Fix | Delete
if (empty($decoded->access_token)) {
[280] Fix | Delete
if ($aTokenFile) {
[281] Fix | Delete
if (is_file($aTokenFile)) {
[282] Fix | Delete
unlink($aTokenFile);
[283] Fix | Delete
}
[284] Fix | Delete
}
[285] Fix | Delete
$err = property_exists($decoded, 'error')? ' ' . $decoded->error : '';
[286] Fix | Delete
$err .= property_exists($decoded, 'error_description')? ' ' . $decoded->error_description : '';
[287] Fix | Delete
throw new \Exception($err? $err : elFinder::ERROR_REAUTH_REQUIRE);
[288] Fix | Delete
}
[289] Fix | Delete
[290] Fix | Delete
$token = (object)array(
[291] Fix | Delete
'expires' => time() + $decoded->expires_in - 300,
[292] Fix | Delete
'initialToken' => $initialToken,
[293] Fix | Delete
'data' => $decoded,
[294] Fix | Delete
);
[295] Fix | Delete
[296] Fix | Delete
$this->token = $token;
[297] Fix | Delete
$json = json_encode($token);
[298] Fix | Delete
[299] Fix | Delete
if (!empty($decoded->refresh_token)) {
[300] Fix | Delete
if (empty($this->options['netkey']) && $aTokenFile) {
[301] Fix | Delete
file_put_contents($aTokenFile, json_encode($token), LOCK_EX);
[302] Fix | Delete
$this->options['accessToken'] = $json;
[303] Fix | Delete
} else if (!empty($this->options['netkey'])) {
[304] Fix | Delete
// OAuth2 refresh token can be used only once,
[305] Fix | Delete
// so update it if it is the same as the token file
[306] Fix | Delete
if ($aTokenFile && is_file($aTokenFile)) {
[307] Fix | Delete
if ($_token = json_decode(file_get_contents($aTokenFile))) {
[308] Fix | Delete
if ($_token->data->refresh_token === $refresh_token) {
[309] Fix | Delete
file_put_contents($aTokenFile, $json, LOCK_EX);
[310] Fix | Delete
}
[311] Fix | Delete
}
[312] Fix | Delete
}
[313] Fix | Delete
$this->options['accessToken'] = $json;
[314] Fix | Delete
// update session value
[315] Fix | Delete
elFinder::$instance->updateNetVolumeOption($this->options['netkey'], 'accessToken', $json);
[316] Fix | Delete
$this->session->set('BoxTokens', $token);
[317] Fix | Delete
} else {
[318] Fix | Delete
throw new \Exception(ERROR_CREATING_TEMP_DIR);
[319] Fix | Delete
}
[320] Fix | Delete
}
[321] Fix | Delete
$lock && unlink($lock);
[322] Fix | Delete
}
[323] Fix | Delete
[324] Fix | Delete
return true;
[325] Fix | Delete
}
[326] Fix | Delete
[327] Fix | Delete
/**
[328] Fix | Delete
* Creates a base cURL object which is compatible with the Box.com API.
[329] Fix | Delete
*
[330] Fix | Delete
* @param array $options cURL options
[331] Fix | Delete
*
[332] Fix | Delete
* @return resource A compatible cURL object
[333] Fix | Delete
*/
[334] Fix | Delete
protected function _bd_prepareCurl($options = array())
[335] Fix | Delete
{
[336] Fix | Delete
$curl = curl_init();
[337] Fix | Delete
[338] Fix | Delete
$defaultOptions = array(
[339] Fix | Delete
// General options.
[340] Fix | Delete
CURLOPT_RETURNTRANSFER => true,
[341] Fix | Delete
);
[342] Fix | Delete
[343] Fix | Delete
curl_setopt_array($curl, $options + $defaultOptions);
[344] Fix | Delete
[345] Fix | Delete
return $curl;
[346] Fix | Delete
}
[347] Fix | Delete
[348] Fix | Delete
/**
[349] Fix | Delete
* Creates a base cURL object which is compatible with the Box.com API.
[350] Fix | Delete
*
[351] Fix | Delete
* @param $url
[352] Fix | Delete
* @param bool $contents
[353] Fix | Delete
*
[354] Fix | Delete
* @return boolean|array
[355] Fix | Delete
* @throws Exception
[356] Fix | Delete
*/
[357] Fix | Delete
protected function _bd_fetch($url, $contents = false)
[358] Fix | Delete
{
[359] Fix | Delete
$curl = curl_init($url);
[360] Fix | Delete
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
[361] Fix | Delete
[362] Fix | Delete
if ($contents) {
[363] Fix | Delete
return $this->_bd_curlExec($curl, false);
[364] Fix | Delete
} else {
[365] Fix | Delete
$result = $this->_bd_curlExec($curl);
[366] Fix | Delete
[367] Fix | Delete
if (isset($result->entries)) {
[368] Fix | Delete
$res = $result->entries;
[369] Fix | Delete
$cnt = count($res);
[370] Fix | Delete
$total = $result->total_count;
[371] Fix | Delete
$offset = $result->offset;
[372] Fix | Delete
$single = ($result->limit == 1) ? true : false;
[373] Fix | Delete
if (!$single && $total > ($offset + $cnt)) {
[374] Fix | Delete
$offset = $offset + $cnt;
[375] Fix | Delete
if (strpos($url, 'offset=') === false) {
[376] Fix | Delete
$url .= '&offset=' . $offset;
[377] Fix | Delete
} else {
[378] Fix | Delete
$url = preg_replace('/^(.+?offset=)\d+(.*)$/', '${1}' . $offset . '$2', $url);
[379] Fix | Delete
}
[380] Fix | Delete
$more = $this->_bd_fetch($url);
[381] Fix | Delete
if (is_array($more)) {
[382] Fix | Delete
$res = array_merge($res, $more);
[383] Fix | Delete
}
[384] Fix | Delete
}
[385] Fix | Delete
[386] Fix | Delete
return $res;
[387] Fix | Delete
} else {
[388] Fix | Delete
if (isset($result->type) && $result->type === 'error') {
[389] Fix | Delete
return false;
[390] Fix | Delete
} else {
[391] Fix | Delete
return $result;
[392] Fix | Delete
}
[393] Fix | Delete
}
[394] Fix | Delete
}
[395] Fix | Delete
}
[396] Fix | Delete
[397] Fix | Delete
/**
[398] Fix | Delete
* Call curl_exec().
[399] Fix | Delete
*
[400] Fix | Delete
* @param resource $curl
[401] Fix | Delete
* @param bool|string $decodeOrParent
[402] Fix | Delete
* @param array $headers
[403] Fix | Delete
*
[404] Fix | Delete
* @throws \Exception
[405] Fix | Delete
* @return mixed
[406] Fix | Delete
*/
[407] Fix | Delete
protected function _bd_curlExec($curl, $decodeOrParent = true, $headers = array(), $postData = array())
[408] Fix | Delete
{
[409] Fix | Delete
if ($this->token) {
[410] Fix | Delete
$headers = array_merge(array(
[411] Fix | Delete
'Authorization: Bearer ' . $this->token->data->access_token,
[412] Fix | Delete
), $headers);
[413] Fix | Delete
}
[414] Fix | Delete
[415] Fix | Delete
$result = elFinder::curlExec($curl, array(), $headers, $postData);
[416] Fix | Delete
[417] Fix | Delete
if (!$decodeOrParent) {
[418] Fix | Delete
return $result;
[419] Fix | Delete
}
[420] Fix | Delete
[421] Fix | Delete
$decoded = json_decode($result);
[422] Fix | Delete
[423] Fix | Delete
if ($error = !empty($decoded->error_code)) {
[424] Fix | Delete
$errmsg = $decoded->error_code;
[425] Fix | Delete
if (!empty($decoded->message)) {
[426] Fix | Delete
$errmsg .= ': ' . $decoded->message;
[427] Fix | Delete
}
[428] Fix | Delete
throw new \Exception($errmsg);
[429] Fix | Delete
} else if ($error = !empty($decoded->error)) {
[430] Fix | Delete
$errmsg = $decoded->error;
[431] Fix | Delete
if (!empty($decoded->error_description)) {
[432] Fix | Delete
$errmsg .= ': ' . $decoded->error_description;
[433] Fix | Delete
}
[434] Fix | Delete
throw new \Exception($errmsg);
[435] Fix | Delete
}
[436] Fix | Delete
[437] Fix | Delete
// make catch
[438] Fix | Delete
if ($decodeOrParent && $decodeOrParent !== true) {
[439] Fix | Delete
$raws = null;
[440] Fix | Delete
if (isset($decoded->entries)) {
[441] Fix | Delete
$raws = $decoded->entries;
[442] Fix | Delete
} elseif (isset($decoded->id)) {
[443] Fix | Delete
$raws = array($decoded);
[444] Fix | Delete
}
[445] Fix | Delete
if ($raws) {
[446] Fix | Delete
foreach ($raws as $raw) {
[447] Fix | Delete
if (isset($raw->id)) {
[448] Fix | Delete
$stat = $this->_bd_parseRaw($raw);
[449] Fix | Delete
$itemPath = $this->_joinPath($decodeOrParent, $raw->id);
[450] Fix | Delete
$this->updateCache($itemPath, $stat);
[451] Fix | Delete
}
[452] Fix | Delete
}
[453] Fix | Delete
}
[454] Fix | Delete
}
[455] Fix | Delete
[456] Fix | Delete
return $decoded;
[457] Fix | Delete
}
[458] Fix | Delete
[459] Fix | Delete
/**
[460] Fix | Delete
* Drive query and fetchAll.
[461] Fix | Delete
*
[462] Fix | Delete
* @param $itemId
[463] Fix | Delete
* @param bool $fetch_self
[464] Fix | Delete
* @param bool $recursive
[465] Fix | Delete
*
[466] Fix | Delete
* @return bool|object
[467] Fix | Delete
* @throws Exception
[468] Fix | Delete
*/
[469] Fix | Delete
protected function _bd_query($itemId, $fetch_self = false, $recursive = false)
[470] Fix | Delete
{
[471] Fix | Delete
$result = [];
[472] Fix | Delete
[473] Fix | Delete
if (null === $itemId) {
[474] Fix | Delete
$itemId = '0';
[475] Fix | Delete
}
[476] Fix | Delete
[477] Fix | Delete
if ($fetch_self) {
[478] Fix | Delete
$path = '/folders/' . $itemId . '?fields=' . self::FETCHFIELDS;
[479] Fix | Delete
} else {
[480] Fix | Delete
$path = '/folders/' . $itemId . '/items?limit=1000&fields=' . self::FETCHFIELDS;
[481] Fix | Delete
}
[482] Fix | Delete
[483] Fix | Delete
$url = self::API_URL . $path;
[484] Fix | Delete
[485] Fix | Delete
if ($recursive) {
[486] Fix | Delete
foreach ($this->_bd_fetch($url) as $file) {
[487] Fix | Delete
if ($file->type == 'folder') {
[488] Fix | Delete
$result[] = $file;
[489] Fix | Delete
$result = array_merge($result, $this->_bd_query($file->id, $fetch_self = false, $recursive = true));
[490] Fix | Delete
} elseif ($file->type == 'file') {
[491] Fix | Delete
$result[] = $file;
[492] Fix | Delete
}
[493] Fix | Delete
}
[494] Fix | Delete
} else {
[495] Fix | Delete
$result = $this->_bd_fetch($url);
[496] Fix | Delete
if ($fetch_self && !$result) {
[497] Fix | Delete
$path = '/files/' . $itemId . '?fields=' . self::FETCHFIELDS;
[498] Fix | Delete
$url = self::API_URL . $path;
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function