Edit File by line
/home/barbar84/www/wp-conte.../plugins/wp-file-.../lib/php
File: elFinderVolumeDropbox2.class.php
<?php
[0] Fix | Delete
[1] Fix | Delete
use Kunnu\Dropbox\Dropbox;
[2] Fix | Delete
use Kunnu\Dropbox\DropboxApp;
[3] Fix | Delete
use Kunnu\Dropbox\DropboxFile;
[4] Fix | Delete
use Kunnu\Dropbox\Exceptions\DropboxClientException;
[5] Fix | Delete
use Kunnu\Dropbox\Models\FileMetadata;
[6] Fix | Delete
use Kunnu\Dropbox\Models\FolderMetadata;
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* Simple elFinder driver for Dropbox
[10] Fix | Delete
* kunalvarma05/dropbox-php-sdk:0.1.5 or above.
[11] Fix | Delete
*
[12] Fix | Delete
* @author Naoki Sawada
[13] Fix | Delete
**/
[14] Fix | Delete
class elFinderVolumeDropbox2 extends elFinderVolumeDriver
[15] Fix | Delete
{
[16] Fix | Delete
/**
[17] Fix | Delete
* Driver id
[18] Fix | Delete
* Must be started from letter and contains [a-z0-9]
[19] Fix | Delete
* Used as part of volume id.
[20] Fix | Delete
*
[21] Fix | Delete
* @var string
[22] Fix | Delete
**/
[23] Fix | Delete
protected $driverId = 'db';
[24] Fix | Delete
[25] Fix | Delete
/**
[26] Fix | Delete
* Dropbox service object.
[27] Fix | Delete
*
[28] Fix | Delete
* @var object
[29] Fix | Delete
**/
[30] Fix | Delete
protected $service = null;
[31] Fix | Delete
[32] Fix | Delete
/**
[33] Fix | Delete
* Fetch options.
[34] Fix | Delete
*
[35] Fix | Delete
* @var string
[36] Fix | Delete
*/
[37] Fix | Delete
private $FETCH_OPTIONS = [];
[38] Fix | Delete
[39] Fix | Delete
/**
[40] Fix | Delete
* Directory for tmp files
[41] Fix | Delete
* If not set driver will try to use tmbDir as tmpDir.
[42] Fix | Delete
*
[43] Fix | Delete
* @var string
[44] Fix | Delete
**/
[45] Fix | Delete
protected $tmp = '';
[46] Fix | Delete
[47] Fix | Delete
/**
[48] Fix | Delete
* Net mount key.
[49] Fix | Delete
*
[50] Fix | Delete
* @var string
[51] Fix | Delete
**/
[52] Fix | Delete
public $netMountKey = '';
[53] Fix | Delete
[54] Fix | Delete
/**
[55] Fix | Delete
* Constructor
[56] Fix | Delete
* Extend options with required fields.
[57] Fix | Delete
*
[58] Fix | Delete
* @author Naoki Sawada
[59] Fix | Delete
**/
[60] Fix | Delete
public function __construct()
[61] Fix | Delete
{
[62] Fix | Delete
$opts = [
[63] Fix | Delete
'app_key' => '',
[64] Fix | Delete
'app_secret' => '',
[65] Fix | Delete
'access_token' => '',
[66] Fix | Delete
'aliasFormat' => '%s@Dropbox',
[67] Fix | Delete
'path' => '/',
[68] Fix | Delete
'separator' => '/',
[69] Fix | Delete
'acceptedName' => '#^[^\\\/]+$#',
[70] Fix | Delete
'rootCssClass' => 'elfinder-navbar-root-dropbox',
[71] Fix | Delete
'publishPermission' => [
[72] Fix | Delete
'requested_visibility' => 'public',
[73] Fix | Delete
//'link_password' => '',
[74] Fix | Delete
//'expires' => '',
[75] Fix | Delete
],
[76] Fix | Delete
'getThumbSize' => 'medium', // Available sizes: 'thumb', 'small', 'medium', 'large', 'huge'
[77] Fix | Delete
];
[78] Fix | Delete
$this->options = array_merge($this->options, $opts);
[79] Fix | Delete
$this->options['mimeDetect'] = 'internal';
[80] Fix | Delete
}
[81] Fix | Delete
[82] Fix | Delete
/*********************************************************************/
[83] Fix | Delete
/* ORIGINAL FUNCTIONS */
[84] Fix | Delete
/*********************************************************************/
[85] Fix | Delete
[86] Fix | Delete
/**
[87] Fix | Delete
* Get Parent ID, Item ID, Parent Path as an array from path.
[88] Fix | Delete
*
[89] Fix | Delete
* @param string $path
[90] Fix | Delete
*
[91] Fix | Delete
* @return array
[92] Fix | Delete
*/
[93] Fix | Delete
protected function _db_splitPath($path)
[94] Fix | Delete
{
[95] Fix | Delete
$path = trim($path, '/');
[96] Fix | Delete
if ($path === '') {
[97] Fix | Delete
$dirname = '/';
[98] Fix | Delete
$basename = '';
[99] Fix | Delete
} else {
[100] Fix | Delete
$pos = strrpos($path, '/');
[101] Fix | Delete
if ($pos === false) {
[102] Fix | Delete
$dirname = '/';
[103] Fix | Delete
$basename = $path;
[104] Fix | Delete
} else {
[105] Fix | Delete
$dirname = '/' . substr($path, 0, $pos);
[106] Fix | Delete
$basename = substr($path, $pos + 1);
[107] Fix | Delete
}
[108] Fix | Delete
}
[109] Fix | Delete
[110] Fix | Delete
return [$dirname, $basename];
[111] Fix | Delete
}
[112] Fix | Delete
[113] Fix | Delete
/**
[114] Fix | Delete
* Get dat(Dropbox metadata) from Dropbox.
[115] Fix | Delete
*
[116] Fix | Delete
* @param string $path
[117] Fix | Delete
*
[118] Fix | Delete
* @return boolean|object Dropbox metadata
[119] Fix | Delete
*/
[120] Fix | Delete
private function _db_getFile($path)
[121] Fix | Delete
{
[122] Fix | Delete
if ($path === '/') {
[123] Fix | Delete
return true;
[124] Fix | Delete
}
[125] Fix | Delete
[126] Fix | Delete
$res = false;
[127] Fix | Delete
try {
[128] Fix | Delete
$file = $this->service->getMetadata($path, $this->FETCH_OPTIONS);
[129] Fix | Delete
if ($file instanceof FolderMetadata || $file instanceof FileMetadata) {
[130] Fix | Delete
$res = $file;
[131] Fix | Delete
}
[132] Fix | Delete
[133] Fix | Delete
return $res;
[134] Fix | Delete
} catch (DropboxClientException $e) {
[135] Fix | Delete
return false;
[136] Fix | Delete
}
[137] Fix | Delete
}
[138] Fix | Delete
[139] Fix | Delete
/**
[140] Fix | Delete
* Parse line from Dropbox metadata output and return file stat (array).
[141] Fix | Delete
*
[142] Fix | Delete
* @param object $raw line from ftp_rawlist() output
[143] Fix | Delete
*
[144] Fix | Delete
* @return array
[145] Fix | Delete
* @author Naoki Sawada
[146] Fix | Delete
**/
[147] Fix | Delete
protected function _db_parseRaw($raw)
[148] Fix | Delete
{
[149] Fix | Delete
$stat = [];
[150] Fix | Delete
$isFolder = false;
[151] Fix | Delete
if ($raw === true) {
[152] Fix | Delete
// root folder
[153] Fix | Delete
$isFolder = true;
[154] Fix | Delete
$stat['name'] = '';
[155] Fix | Delete
$stat['iid'] = '0';
[156] Fix | Delete
}
[157] Fix | Delete
[158] Fix | Delete
$data = [];
[159] Fix | Delete
if (is_object($raw)) {
[160] Fix | Delete
$isFolder = $raw instanceof FolderMetadata;
[161] Fix | Delete
$data = $raw->getData();
[162] Fix | Delete
} elseif (is_array($raw)) {
[163] Fix | Delete
$isFolder = $raw['.tag'] === 'folder';
[164] Fix | Delete
$data = $raw;
[165] Fix | Delete
}
[166] Fix | Delete
[167] Fix | Delete
if (isset($data['path_lower'])) {
[168] Fix | Delete
$stat['path'] = $data['path_lower'];
[169] Fix | Delete
}
[170] Fix | Delete
[171] Fix | Delete
if (isset($data['name'])) {
[172] Fix | Delete
$stat['name'] = $data['name'];
[173] Fix | Delete
}
[174] Fix | Delete
[175] Fix | Delete
if (isset($data['id'])) {
[176] Fix | Delete
$stat['iid'] = substr($data['id'], 3);
[177] Fix | Delete
}
[178] Fix | Delete
[179] Fix | Delete
if ($isFolder) {
[180] Fix | Delete
$stat['mime'] = 'directory';
[181] Fix | Delete
$stat['size'] = 0;
[182] Fix | Delete
$stat['ts'] = 0;
[183] Fix | Delete
$stat['dirs'] = -1;
[184] Fix | Delete
} else {
[185] Fix | Delete
$stat['size'] = isset($data['size']) ? (int)$data['size'] : 0;
[186] Fix | Delete
if (isset($data['server_modified'])) {
[187] Fix | Delete
$stat['ts'] = strtotime($data['server_modified']);
[188] Fix | Delete
} elseif (isset($data['client_modified'])) {
[189] Fix | Delete
$stat['ts'] = strtotime($data['client_modified']);
[190] Fix | Delete
} else {
[191] Fix | Delete
$stat['ts'] = 0;
[192] Fix | Delete
}
[193] Fix | Delete
$stat['url'] = '1';
[194] Fix | Delete
}
[195] Fix | Delete
[196] Fix | Delete
return $stat;
[197] Fix | Delete
}
[198] Fix | Delete
[199] Fix | Delete
/**
[200] Fix | Delete
* Get thumbnail from Dropbox.
[201] Fix | Delete
*
[202] Fix | Delete
* @param string $path
[203] Fix | Delete
* @param string $size
[204] Fix | Delete
*
[205] Fix | Delete
* @return string | boolean
[206] Fix | Delete
*/
[207] Fix | Delete
protected function _db_getThumbnail($path)
[208] Fix | Delete
{
[209] Fix | Delete
try {
[210] Fix | Delete
return $this->service->getThumbnail($path, $this->options['getThumbSize'])->getContents();
[211] Fix | Delete
} catch (DropboxClientException $e) {
[212] Fix | Delete
return false;
[213] Fix | Delete
}
[214] Fix | Delete
}
[215] Fix | Delete
[216] Fix | Delete
/**
[217] Fix | Delete
* Join dir name and file name(display name) and retur full path.
[218] Fix | Delete
*
[219] Fix | Delete
* @param string $dir
[220] Fix | Delete
* @param string $displayName
[221] Fix | Delete
*
[222] Fix | Delete
* @return string
[223] Fix | Delete
*/
[224] Fix | Delete
protected function _db_joinName($dir, $displayName)
[225] Fix | Delete
{
[226] Fix | Delete
return rtrim($dir, '/') . '/' . $displayName;
[227] Fix | Delete
}
[228] Fix | Delete
[229] Fix | Delete
/**
[230] Fix | Delete
* Get OAuth2 access token form OAuth1 tokens.
[231] Fix | Delete
*
[232] Fix | Delete
* @param string $app_key
[233] Fix | Delete
* @param string $app_secret
[234] Fix | Delete
* @param string $oauth1_token
[235] Fix | Delete
* @param string $oauth1_secret
[236] Fix | Delete
*
[237] Fix | Delete
* @return string|false
[238] Fix | Delete
*/
[239] Fix | Delete
public static function getTokenFromOauth1($app_key, $app_secret, $oauth1_token, $oauth1_secret)
[240] Fix | Delete
{
[241] Fix | Delete
$data = [
[242] Fix | Delete
'oauth1_token' => $oauth1_token,
[243] Fix | Delete
'oauth1_token_secret' => $oauth1_secret,
[244] Fix | Delete
];
[245] Fix | Delete
$auth = base64_encode($app_key . ':' . $app_secret);
[246] Fix | Delete
[247] Fix | Delete
$ch = curl_init('https://api.dropboxapi.com/2/auth/token/from_oauth1');
[248] Fix | Delete
curl_setopt($ch, CURLOPT_POST, true);
[249] Fix | Delete
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
[250] Fix | Delete
curl_setopt($ch, CURLOPT_HTTPHEADER, [
[251] Fix | Delete
'Content-Type: application/json',
[252] Fix | Delete
'Authorization: Basic ' . $auth,
[253] Fix | Delete
]);
[254] Fix | Delete
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
[255] Fix | Delete
$result = curl_exec($ch);
[256] Fix | Delete
curl_close($ch);
[257] Fix | Delete
[258] Fix | Delete
$res = $result ? json_decode($result, true) : [];
[259] Fix | Delete
[260] Fix | Delete
return isset($res['oauth2_token']) ? $res['oauth2_token'] : false;
[261] Fix | Delete
}
[262] Fix | Delete
[263] Fix | Delete
/*********************************************************************/
[264] Fix | Delete
/* EXTENDED FUNCTIONS */
[265] Fix | Delete
/*********************************************************************/
[266] Fix | Delete
[267] Fix | Delete
/**
[268] Fix | Delete
* Prepare
[269] Fix | Delete
* Call from elFinder::netmout() before volume->mount().
[270] Fix | Delete
*
[271] Fix | Delete
* @return array
[272] Fix | Delete
* @author Naoki Sawada
[273] Fix | Delete
**/
[274] Fix | Delete
public function netmountPrepare($options)
[275] Fix | Delete
{
[276] Fix | Delete
if (empty($options['app_key']) && defined('ELFINDER_DROPBOX_APPKEY')) {
[277] Fix | Delete
$options['app_key'] = ELFINDER_DROPBOX_APPKEY;
[278] Fix | Delete
}
[279] Fix | Delete
if (empty($options['app_secret']) && defined('ELFINDER_DROPBOX_APPSECRET')) {
[280] Fix | Delete
$options['app_secret'] = ELFINDER_DROPBOX_APPSECRET;
[281] Fix | Delete
}
[282] Fix | Delete
[283] Fix | Delete
if (!isset($options['pass'])) {
[284] Fix | Delete
$options['pass'] = '';
[285] Fix | Delete
}
[286] Fix | Delete
[287] Fix | Delete
try {
[288] Fix | Delete
$app = new DropboxApp($options['app_key'], $options['app_secret']);
[289] Fix | Delete
$dropbox = new Dropbox($app);
[290] Fix | Delete
$authHelper = $dropbox->getAuthHelper();
[291] Fix | Delete
[292] Fix | Delete
if ($options['pass'] === 'reauth') {
[293] Fix | Delete
$options['pass'] = '';
[294] Fix | Delete
$this->session->set('Dropbox2AuthParams', [])->set('Dropbox2Tokens', []);
[295] Fix | Delete
} elseif ($options['pass'] === 'dropbox2') {
[296] Fix | Delete
$options['pass'] = '';
[297] Fix | Delete
}
[298] Fix | Delete
[299] Fix | Delete
$options = array_merge($this->session->get('Dropbox2AuthParams', []), $options);
[300] Fix | Delete
[301] Fix | Delete
if (!isset($options['tokens'])) {
[302] Fix | Delete
$options['tokens'] = $this->session->get('Dropbox2Tokens', []);
[303] Fix | Delete
$this->session->remove('Dropbox2Tokens');
[304] Fix | Delete
}
[305] Fix | Delete
$aToken = $options['tokens'];
[306] Fix | Delete
if (!is_array($aToken) || !isset($aToken['access_token'])) {
[307] Fix | Delete
$aToken = [];
[308] Fix | Delete
}
[309] Fix | Delete
[310] Fix | Delete
$service = null;
[311] Fix | Delete
if ($aToken) {
[312] Fix | Delete
try {
[313] Fix | Delete
$dropbox->setAccessToken($aToken['access_token']);
[314] Fix | Delete
$this->session->set('Dropbox2AuthParams', $options);
[315] Fix | Delete
} catch (DropboxClientException $e) {
[316] Fix | Delete
$aToken = [];
[317] Fix | Delete
$options['tokens'] = [];
[318] Fix | Delete
if ($options['user'] !== 'init') {
[319] Fix | Delete
$this->session->set('Dropbox2AuthParams', $options);
[320] Fix | Delete
[321] Fix | Delete
return ['exit' => true, 'error' => elFinder::ERROR_REAUTH_REQUIRE];
[322] Fix | Delete
}
[323] Fix | Delete
}
[324] Fix | Delete
}
[325] Fix | Delete
[326] Fix | Delete
if ((isset($options['user']) && $options['user'] === 'init') || (isset($_GET['host']) && $_GET['host'] == '1')) {
[327] Fix | Delete
if (empty($options['url'])) {
[328] Fix | Delete
$options['url'] = elFinder::getConnectorUrl();
[329] Fix | Delete
}
[330] Fix | Delete
[331] Fix | Delete
if (!empty($options['id'])) {
[332] Fix | Delete
$callback = $options['url']
[333] Fix | Delete
. (strpos($options['url'], '?') !== false? '&' : '?') . 'cmd=netmount&protocol=dropbox2&host=' . ($options['id'] === 'elfinder'? '1' : $options['id']);
[334] Fix | Delete
}
[335] Fix | Delete
[336] Fix | Delete
$itpCare = isset($options['code']);
[337] Fix | Delete
$code = $itpCare? $options['code'] : (isset($_GET['code'])? $_GET['code'] : '');
[338] Fix | Delete
$state = $itpCare? $options['state'] : (isset($_GET['state'])? $_GET['state'] : '');
[339] Fix | Delete
if (!$aToken && empty($code)) {
[340] Fix | Delete
$url = $authHelper->getAuthUrl($callback);
[341] Fix | Delete
[342] Fix | Delete
$html = '<input id="elf-volumedriver-dropbox2-host-btn" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" value="{msg:btnApprove}" type="button">';
[343] Fix | Delete
$html .= '<script>
[344] Fix | Delete
jQuery("#' . $options['id'] . '").elfinder("instance").trigger("netmount", {protocol: "dropbox2", mode: "makebtn", url: "' . $url . '"});
[345] Fix | Delete
</script>';
[346] Fix | Delete
if (empty($options['pass']) && $options['host'] !== '1') {
[347] Fix | Delete
$options['pass'] = 'return';
[348] Fix | Delete
$this->session->set('Dropbox2AuthParams', $options);
[349] Fix | Delete
[350] Fix | Delete
return ['exit' => true, 'body' => $html];
[351] Fix | Delete
} else {
[352] Fix | Delete
$out = [
[353] Fix | Delete
'node' => $options['id'],
[354] Fix | Delete
'json' => '{"protocol": "dropbox2", "mode": "makebtn", "body" : "' . str_replace($html, '"', '\\"') . '", "error" : "' . elFinder::ERROR_ACCESS_DENIED . '"}',
[355] Fix | Delete
'bind' => 'netmount',
[356] Fix | Delete
];
[357] Fix | Delete
[358] Fix | Delete
return ['exit' => 'callback', 'out' => $out];
[359] Fix | Delete
}
[360] Fix | Delete
} else {
[361] Fix | Delete
if ($code && $state) {
[362] Fix | Delete
if (!empty($options['id'])) {
[363] Fix | Delete
// see https://github.com/kunalvarma05/dropbox-php-sdk/issues/115
[364] Fix | Delete
$authHelper->getPersistentDataStore()->set('state', filter_var($state, FILTER_SANITIZE_STRING));
[365] Fix | Delete
$tokenObj = $authHelper->getAccessToken($code, $state, $callback);
[366] Fix | Delete
$options['tokens'] = [
[367] Fix | Delete
'access_token' => $tokenObj->getToken(),
[368] Fix | Delete
'uid' => $tokenObj->getUid(),
[369] Fix | Delete
];
[370] Fix | Delete
unset($options['code'], $options['state']);
[371] Fix | Delete
$this->session->set('Dropbox2Tokens', $options['tokens'])->set('Dropbox2AuthParams', $options);
[372] Fix | Delete
$out = [
[373] Fix | Delete
'node' => $options['id'],
[374] Fix | Delete
'json' => '{"protocol": "dropbox2", "mode": "done", "reset": 1}',
[375] Fix | Delete
'bind' => 'netmount',
[376] Fix | Delete
];
[377] Fix | Delete
} else {
[378] Fix | Delete
$nodeid = ($_GET['host'] === '1')? 'elfinder' : $_GET['host'];
[379] Fix | Delete
$out = [
[380] Fix | Delete
'node' => $nodeid,
[381] Fix | Delete
'json' => json_encode(array(
[382] Fix | Delete
'protocol' => 'dropbox2',
[383] Fix | Delete
'host' => $nodeid,
[384] Fix | Delete
'mode' => 'redirect',
[385] Fix | Delete
'options' => array(
[386] Fix | Delete
'id' => $nodeid,
[387] Fix | Delete
'code' => $code,
[388] Fix | Delete
'state' => $state
[389] Fix | Delete
)
[390] Fix | Delete
)),
[391] Fix | Delete
'bind' => 'netmount'
[392] Fix | Delete
];
[393] Fix | Delete
}
[394] Fix | Delete
if (!$itpCare) {
[395] Fix | Delete
return array('exit' => 'callback', 'out' => $out);
[396] Fix | Delete
} else {
[397] Fix | Delete
return array('exit' => true, 'body' => $out['json']);
[398] Fix | Delete
}
[399] Fix | Delete
}
[400] Fix | Delete
$path = $options['path'];
[401] Fix | Delete
$folders = [];
[402] Fix | Delete
$listFolderContents = $dropbox->listFolder($path);
[403] Fix | Delete
$items = $listFolderContents->getItems();
[404] Fix | Delete
foreach ($items as $item) {
[405] Fix | Delete
$data = $item->getData();
[406] Fix | Delete
if ($data['.tag'] === 'folder') {
[407] Fix | Delete
$folders[$data['path_lower']] = $data['name'];
[408] Fix | Delete
}
[409] Fix | Delete
}
[410] Fix | Delete
natcasesort($folders);
[411] Fix | Delete
[412] Fix | Delete
if ($options['pass'] === 'folders') {
[413] Fix | Delete
return ['exit' => true, 'folders' => $folders];
[414] Fix | Delete
}
[415] Fix | Delete
[416] Fix | Delete
$folders = ['/' => '/'] + $folders;
[417] Fix | Delete
$folders = json_encode($folders);
[418] Fix | Delete
$json = '{"protocol": "dropbox2", "mode": "done", "folders": ' . $folders . '}';
[419] Fix | Delete
$options['pass'] = 'return';
[420] Fix | Delete
$html = 'Dropbox.com';
[421] Fix | Delete
$html .= '<script>
[422] Fix | Delete
jQuery("#' . $options['id'] . '").elfinder("instance").trigger("netmount", ' . $json . ');
[423] Fix | Delete
</script>';
[424] Fix | Delete
$this->session->set('Dropbox2AuthParams', $options);
[425] Fix | Delete
[426] Fix | Delete
return ['exit' => true, 'body' => $html];
[427] Fix | Delete
}
[428] Fix | Delete
}
[429] Fix | Delete
} catch (DropboxClientException $e) {
[430] Fix | Delete
$this->session->remove('Dropbox2AuthParams')->remove('Dropbox2Tokens');
[431] Fix | Delete
if (empty($options['pass'])) {
[432] Fix | Delete
return ['exit' => true, 'body' => '{msg:' . elFinder::ERROR_ACCESS_DENIED . '}' . ' ' . $e->getMessage()];
[433] Fix | Delete
} else {
[434] Fix | Delete
return ['exit' => true, 'error' => [elFinder::ERROR_ACCESS_DENIED, $e->getMessage()]];
[435] Fix | Delete
}
[436] Fix | Delete
}
[437] Fix | Delete
[438] Fix | Delete
if (!$aToken) {
[439] Fix | Delete
return ['exit' => true, 'error' => elFinder::ERROR_REAUTH_REQUIRE];
[440] Fix | Delete
}
[441] Fix | Delete
[442] Fix | Delete
if ($options['path'] === 'root') {
[443] Fix | Delete
$options['path'] = '/';
[444] Fix | Delete
}
[445] Fix | Delete
[446] Fix | Delete
try {
[447] Fix | Delete
if ($options['path'] !== '/') {
[448] Fix | Delete
$file = $dropbox->getMetadata($options['path']);
[449] Fix | Delete
$name = $file->getName();
[450] Fix | Delete
} else {
[451] Fix | Delete
$name = 'root';
[452] Fix | Delete
}
[453] Fix | Delete
$options['alias'] = sprintf($this->options['aliasFormat'], $name);
[454] Fix | Delete
} catch (DropboxClientException $e) {
[455] Fix | Delete
return ['exit' => true, 'error' => $e->getMessage()];
[456] Fix | Delete
}
[457] Fix | Delete
[458] Fix | Delete
foreach (['host', 'user', 'pass', 'id', 'offline'] as $key) {
[459] Fix | Delete
unset($options[$key]);
[460] Fix | Delete
}
[461] Fix | Delete
[462] Fix | Delete
return $options;
[463] Fix | Delete
}
[464] Fix | Delete
[465] Fix | Delete
/**
[466] Fix | Delete
* process of on netunmount
[467] Fix | Delete
* Drop `Dropbox` & rm thumbs.
[468] Fix | Delete
*
[469] Fix | Delete
* @param array $options
[470] Fix | Delete
*
[471] Fix | Delete
* @return bool
[472] Fix | Delete
*/
[473] Fix | Delete
public function netunmount($netVolumes, $key)
[474] Fix | Delete
{
[475] Fix | Delete
if ($tmbs = glob(rtrim($this->options['tmbPath'], '\\/') . DIRECTORY_SEPARATOR . $this->driverId . '_' . $this->options['tokens']['uid'] . '*.png')) {
[476] Fix | Delete
foreach ($tmbs as $file) {
[477] Fix | Delete
unlink($file);
[478] Fix | Delete
}
[479] Fix | Delete
}
[480] Fix | Delete
[481] Fix | Delete
return true;
[482] Fix | Delete
}
[483] Fix | Delete
[484] Fix | Delete
/*********************************************************************/
[485] Fix | Delete
/* INIT AND CONFIGURE */
[486] Fix | Delete
/*********************************************************************/
[487] Fix | Delete
[488] Fix | Delete
/**
[489] Fix | Delete
* Prepare Dropbox connection
[490] Fix | Delete
* Connect to remote server and check if credentials are correct, if so, store the connection id in $this->service.
[491] Fix | Delete
*
[492] Fix | Delete
* @return bool
[493] Fix | Delete
* @author Naoki Sawada
[494] Fix | Delete
**/
[495] Fix | Delete
protected function init()
[496] Fix | Delete
{
[497] Fix | Delete
if (empty($this->options['app_key'])) {
[498] Fix | Delete
if (defined('ELFINDER_DROPBOX_APPKEY') && ELFINDER_DROPBOX_APPKEY) {
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function