getStaticVar() публичный статический Метод

Return elFinder static variable
public static getStaticVar ( $key ) : mixed | null
$key
Результат mixed | null
Пример #1
0
 protected function configure()
 {
     parent::configure();
     $this->tmpPath = '';
     if (!empty($this->options['tmpPath'])) {
         if ((is_dir($this->options['tmpPath']) || @mkdir($this->options['tmpPath'])) && is_writable($this->options['tmpPath'])) {
             $this->tmpPath = $this->options['tmpPath'];
         }
     }
     if (!$this->tmpPath && ($tmp = elFinder::getStaticVar('commonTempPath'))) {
         $this->tmpPath = $tmp;
     }
     $this->mimeDetect = 'internal';
 }
 /**
  * Configure after successfull mount.
  *
  * @return void
  * @author Dmitry (dio) Levashov
  **/
 protected function configure()
 {
     parent::configure();
     if (!empty($this->options['tmpPath'])) {
         if ((is_dir($this->options['tmpPath']) || @mkdir($this->options['tmpPath'], 0755, true)) && is_writable($this->options['tmpPath'])) {
             $this->tmp = $this->options['tmpPath'];
         }
     }
     if (!$this->tmp && ($tmp = elFinder::getStaticVar('commonTempPath'))) {
         $this->tmp = $tmp;
     }
     if (!$this->tmp && $this->tmbPath) {
         $this->tmp = $this->tmbPath;
     }
     if (!$this->tmp) {
         $this->disabled[] = 'mkfile';
         $this->disabled[] = 'paste';
         $this->disabled[] = 'duplicate';
         $this->disabled[] = 'upload';
         $this->disabled[] = 'edit';
         $this->disabled[] = 'archive';
         $this->disabled[] = 'extract';
     }
     // echo $this->tmp;
 }
 /**
  * Prepare FTP connection
  * Connect to remote server and check if credentials are correct, if so, store the connection id in $ftp_conn
  *
  * @return bool
  * @author Dmitry (dio) Levashov
  * @author Cem (DiscoFever)
  **/
 protected function init()
 {
     if (!class_exists('PDO', false)) {
         return $this->setError('PHP PDO class is require.');
     }
     if (!$this->options['consumerKey'] || !$this->options['consumerSecret'] || !$this->options['accessToken'] || !$this->options['accessTokenSecret']) {
         return $this->setError('Required options undefined.');
     }
     if (empty($this->options['metaCachePath']) && defined('ELFINDER_DROPBOX_META_CACHE_PATH')) {
         $this->options['metaCachePath'] = ELFINDER_DROPBOX_META_CACHE_PATH;
     }
     // make net mount key
     $this->netMountKey = md5(join('-', array('dropbox', $this->options['path'])));
     if (!$this->oauth) {
         if (defined('ELFINDER_DROPBOX_USE_CURL_PUT')) {
             $this->oauth = new Dropbox_OAuth_Curl($this->options['consumerKey'], $this->options['consumerSecret']);
         } else {
             if (class_exists('OAuth', false)) {
                 $this->oauth = new Dropbox_OAuth_PHP($this->options['consumerKey'], $this->options['consumerSecret']);
             } else {
                 if (!class_exists('HTTP_OAuth_Consumer')) {
                     // We're going to try to load in manually
                     include 'HTTP/OAuth/Consumer.php';
                 }
                 if (class_exists('HTTP_OAuth_Consumer', false)) {
                     $this->oauth = new Dropbox_OAuth_PEAR($this->options['consumerKey'], $this->options['consumerSecret']);
                 }
             }
         }
     }
     if (!$this->oauth) {
         return $this->setError('OAuth extension not loaded.');
     }
     // normalize root path
     $this->root = $this->options['path'] = $this->_normpath($this->options['path']);
     if (empty($this->options['alias'])) {
         $this->options['alias'] = $this->options['path'] === '/' ? 'Dropbox.com' : 'Dropbox' . $this->options['path'];
     }
     $this->rootName = $this->options['alias'];
     try {
         $this->oauth->setToken($this->options['accessToken'], $this->options['accessTokenSecret']);
         $this->dropbox = new Dropbox_API($this->oauth, $this->options['root']);
     } catch (Dropbox_Exception $e) {
         $this->session->remove('DropboxTokens');
         return $this->setError('Dropbox error: ' . $e->getMessage());
     }
     // user
     if (empty($this->options['dropboxUid'])) {
         try {
             $res = $this->dropbox->getAccountInfo();
             $this->options['dropboxUid'] = $res['uid'];
         } catch (Dropbox_Exception $e) {
             $this->session->remove('DropboxTokens');
             return $this->setError('Dropbox error: ' . $e->getMessage());
         }
     }
     $this->dropboxUid = $this->options['dropboxUid'];
     $this->tmbPrefix = 'dropbox' . base_convert($this->dropboxUid, 10, 32);
     if (!empty($this->options['tmpPath'])) {
         if ((is_dir($this->options['tmpPath']) || mkdir($this->options['tmpPath'])) && is_writable($this->options['tmpPath'])) {
             $this->tmp = $this->options['tmpPath'];
         }
     }
     if (!$this->tmp && is_writable($this->options['tmbPath'])) {
         $this->tmp = $this->options['tmbPath'];
     }
     if (!$this->tmp && ($tmp = elFinder::getStaticVar('commonTempPath'))) {
         $this->tmp = $tmp;
     }
     if (!empty($this->options['metaCachePath'])) {
         if ((is_dir($this->options['metaCachePath']) || mkdir($this->options['metaCachePath'])) && is_writable($this->options['metaCachePath'])) {
             $this->metaCache = $this->options['metaCachePath'];
         }
     }
     if (!$this->metaCache && $this->tmp) {
         $this->metaCache = $this->tmp;
     }
     if (!$this->metaCache) {
         return $this->setError('Cache dirctory (metaCachePath or tmp) is require.');
     }
     // setup PDO
     if (!$this->options['PDO_DSN']) {
         $this->options['PDO_DSN'] = 'sqlite:' . $this->metaCache . DIRECTORY_SEPARATOR . '.elFinder_dropbox_db_' . md5($this->dropboxUid . $this->options['consumerSecret']);
     }
     // DataBase table name
     $this->DB_TableName = $this->options['PDO_DBName'];
     // DataBase check or make table
     try {
         $this->DB = new PDO($this->options['PDO_DSN'], $this->options['PDO_User'], $this->options['PDO_Pass'], $this->options['PDO_Options']);
         if (!$this->checkDB()) {
             return $this->setError('Can not make DB table');
         }
     } catch (PDOException $e) {
         return $this->setError('PDO connection failed: ' . $e->getMessage());
     }
     $res = $this->deltaCheck($this->isMyReload());
     if ($res !== true) {
         if (is_string($res)) {
             return $this->setError($res);
         } else {
             return $this->setError('Could not check API "delta"');
         }
     }
     if (is_null($this->options['syncChkAsTs'])) {
         $this->options['syncChkAsTs'] = true;
     }
     if ($this->options['syncChkAsTs']) {
         // 'tsPlSleep' minmum 5 sec
         $this->options['tsPlSleep'] = max(5, $this->options['tsPlSleep']);
     } else {
         // 'lsPlSleep' minmum 10 sec
         $this->options['lsPlSleep'] = max(10, $this->options['lsPlSleep']);
     }
     return true;
 }
 /**
  * Set tmp path
  *
  * @return void
  * @author Dmitry (dio) Levashov
  **/
 protected function configure()
 {
     parent::configure();
     if ($tmp = $this->options['tmpPath']) {
         if (!file_exists($tmp)) {
             if (@mkdir($tmp)) {
                 @chmod($tmp, $this->options['tmbPathMode']);
             }
         }
         $this->tmpPath = is_dir($tmp) && is_writable($tmp) ? $tmp : false;
     }
     if (!$this->tmpPath && ($tmp = elFinder::getStaticVar('commonTempPath'))) {
         $this->tmpPath = $tmp;
     }
     if (!$this->tmpPath && $this->tmbPath && $this->tmbPathWritable) {
         $this->tmpPath = $this->tmbPath;
     }
     $this->mimeDetect = 'internal';
 }
 /**
  * Configure after successfull mount.
  *
  * @return void
  * @author Dmitry (dio) Levashov
  **/
 protected function configure()
 {
     $root = $this->stat($this->root);
     // chek thumbnails path
     if ($this->options['tmbPath']) {
         $this->options['tmbPath'] = strpos($this->options['tmbPath'], DIRECTORY_SEPARATOR) === false ? $this->_abspath($this->options['tmbPath']) : $this->_normpath($this->options['tmbPath']);
     }
     parent::configure();
     // set $this->tmp by options['tmpPath']
     $this->tmp = '';
     if (!empty($this->options['tmpPath'])) {
         if ((is_dir($this->options['tmpPath']) || @mkdir($this->options['tmpPath'], 0755, true)) && is_writable($this->options['tmpPath'])) {
             $this->tmp = $this->options['tmpPath'];
         }
     }
     if (!$this->tmp && ($tmp = elFinder::getStaticVar('commonTempPath'))) {
         $this->tmp = $tmp;
     }
     // if no thumbnails url - try detect it
     if ($root['read'] && !$this->tmbURL && $this->URL) {
         if (strpos($this->tmbPath, $this->root) === 0) {
             $this->tmbURL = $this->URL . str_replace(DIRECTORY_SEPARATOR, '/', substr($this->tmbPath, strlen($this->root) + 1));
             if (preg_match("|[^/?&=]\$|", $this->tmbURL)) {
                 $this->tmbURL .= '/';
             }
         }
     }
     // check quarantine dir
     $this->quarantine = '';
     if (!empty($this->options['quarantine'])) {
         if (is_dir($this->options['quarantine'])) {
             if (is_writable($this->options['quarantine'])) {
                 $this->quarantine = $this->options['quarantine'];
             }
             $this->options['quarantine'] = '';
         } else {
             $this->quarantine = $this->_abspath($this->options['quarantine']);
             if (!is_dir($this->quarantine) && !$this->_mkdir($this->root, $this->options['quarantine']) || !is_writable($this->quarantine)) {
                 $this->options['quarantine'] = $this->quarantine = '';
             }
         }
     }
     if (!$this->quarantine) {
         if (!$this->tmp) {
             $this->archivers['extract'] = array();
             $this->disabled[] = 'extract';
         } else {
             $this->quarantine = $this->tmp;
         }
     }
     if ($this->options['quarantine']) {
         $this->attributes[] = array('pattern' => '~^' . preg_quote(DIRECTORY_SEPARATOR . $this->options['quarantine']) . '$~', 'read' => false, 'write' => false, 'locked' => true, 'hidden' => true);
     }
 }
 /**
  * Prepare FTP connection
  * Connect to remote server and check if credentials are correct, if so, store the connection id in $ftp_conn.
  *
  * @return bool
  *
  * @author Dmitry (dio) Levashov
  * @author Cem (DiscoFever)
  **/
 protected function init()
 {
     if (empty($options['client_id'])) {
         if (defined('ELFINDER_GOOGLEDRIVE_CLIENTID') && ELFINDER_GOOGLEDRIVE_CLIENTID) {
             $this->options['client_id'] = ELFINDER_GOOGLEDRIVE_CLIENTID;
         } else {
             return $this->setError('Required option "client_id" is undefined.');
         }
     }
     if (empty($options['client_secret'])) {
         if (defined('ELFINDER_GOOGLEDRIVE_CLIENTSECRET') && ELFINDER_GOOGLEDRIVE_CLIENTSECRET) {
             $this->options['client_secret'] = ELFINDER_GOOGLEDRIVE_CLIENTSECRET;
         } else {
             return $this->setError('Required option "client_secret" is undefined.');
         }
     }
     if (!$this->options['access_token'] && !$this->options['refresh_token']) {
         return $this->setError('Required option "access_token" or "refresh_token" is undefined.');
     }
     try {
         $aTokenFile = '';
         if ($this->options['refresh_token']) {
             // permanent mount
             $aToken = $this->options['refresh_token'];
             $this->options['access_token'] = '';
             $tmp = elFinder::getStaticVar('commonTempPath');
             if (!$tmp) {
                 $tmp = $this->getTempPath();
             }
             if ($tmp) {
                 $aTokenFile = $tmp . DIRECTORY_SEPARATOR . md5($this->options['client_id'] . $this->options['refresh_token']) . '.gtoken';
                 if (is_file($aTokenFile)) {
                     $this->options['access_token'] = json_decode(file_get_contents($aTokenFile), true);
                 }
             }
         } else {
             // make net mount key for network mount
             if (is_array($this->options['access_token'])) {
                 $aToken = !empty($this->options['access_token']['refresh_token']) ? $this->options['access_token']['refresh_token'] : $this->options['access_token']['access_token'];
             } else {
                 return $this->setError('Required option "access_token" is not Array or empty.');
             }
         }
         $this->netMountKey = md5($aToken . '-' . $this->options['path']);
         $errors = [];
         if (!$this->service) {
             if ($this->options['googleApiClient'] && !class_exists('Google_Client')) {
                 include_once $this->options['googleApiClient'];
             }
             if (!class_exists('Google_Client')) {
                 return $this->setError('Class Google_Client not found.');
             }
             $this->client = new \Google_Client();
             $client = $this->client;
             if ($this->options['access_token']) {
                 $client->setAccessToken($this->options['access_token']);
             }
             if ($client->isAccessTokenExpired()) {
                 $client->setClientId($this->options['client_id']);
                 $client->setClientSecret($this->options['client_secret']);
                 $access_token = $client->fetchAccessTokenWithRefreshToken($this->options['refresh_token'] ?: null);
                 $client->setAccessToken($access_token);
                 if ($aTokenFile) {
                     file_put_contents($aTokenFile, json_encode($access_token));
                 } else {
                     $access_token['refresh_token'] = $this->options['access_token']['refresh_token'];
                 }
                 if (!empty($this->options['netkey'])) {
                     elFinder::$instance->updateNetVolumeOption($this->options['netkey'], 'access_token', $access_token);
                 }
                 $this->options['access_token'] = $access_token;
             }
             $this->service = new \Google_Service_Drive($client);
         }
     } catch (InvalidArgumentException $e) {
         $errors[] = $e->getMessage();
     } catch (Google_Service_Exception $e) {
         $errors[] = $e->getMessage();
     }
     if (!$this->service) {
         $this->session->remove($this->id . $this->netMountKey);
         if ($aTokenFile) {
             unlink($aTokenFile);
         }
         $errors[] = 'Google Drive Service could not be loaded.';
         return $this->setError($errors);
     }
     // normalize root path
     if ($this->options['path'] == 'root') {
         $this->options['path'] = '/';
     }
     $this->root = $this->options['path'] = $this->_normpath($this->options['path']);
     $this->options['root'] == '' ? $this->options['root'] = $this->_gd_getNameByPath('root') : $this->options['root'];
     if (empty($this->options['alias'])) {
         $this->options['alias'] = $this->options['path'] === '/' ? $this->options['root'] : sprintf($this->options['gdAlias'], $this->_gd_getNameByPath($this->options['path']));
     }
     $this->rootName = $this->options['alias'];
     if (!empty($this->options['tmpPath'])) {
         if ((is_dir($this->options['tmpPath']) || mkdir($this->options['tmpPath'])) && is_writable($this->options['tmpPath'])) {
             $this->tmp = $this->options['tmpPath'];
         }
     }
     if (!$this->tmp && is_writable($this->options['tmbPath'])) {
         $this->tmp = $this->options['tmbPath'];
     }
     if (!$this->tmp && ($tmp = elFinder::getStaticVar('commonTempPath'))) {
         $this->tmp = $tmp;
     }
     // This driver dose not support `syncChkAsTs`
     $this->options['syncChkAsTs'] = false;
     // 'lsPlSleep' minmum 10 sec
     $this->options['lsPlSleep'] = max(10, $this->options['lsPlSleep']);
     if ($this->options['useGoogleTmb']) {
         $this->options['tmbURL'] = 'https://';
     }
     return true;
 }
 /**
  * Prepare FTP connection
  * Connect to remote server and check if credentials are correct, if so, store the connection id in $ftp_conn.
  *
  * @return bool
  *
  * @author Dmitry (dio) Levashov
  * @author Cem (DiscoFever)
  **/
 protected function init()
 {
     if (!$this->options['accessToken']) {
         return $this->setError('Required option `accessToken` is undefined.');
     }
     try {
         $this->token = json_decode($this->options['accessToken']);
         $this->_bd_refreshToken();
     } catch (Exception $e) {
         $this->token = null;
         $this->session->remove('BoxTokens');
         return $this->setError($e->getMessage());
     }
     if (empty($options['netkey'])) {
         // make net mount key
         $_tokenKey = isset($this->token->data->refresh_token) ? $this->token->data->refresh_token : $this->token->data->access_token;
         $this->netMountKey = md5(implode('-', array('box', $this->options['path'], $_tokenKey)));
     } else {
         $this->netMountKey = $options['netkey'];
     }
     // normalize root path
     if ($this->options['path'] == 'root') {
         $this->options['path'] = '/';
     }
     $this->root = $this->options['path'] = $this->_normpath($this->options['path']);
     $this->options['root'] == '' ? $this->options['root'] = 'Box.com' : $this->options['root'];
     if (empty($this->options['alias'])) {
         list(, $itemId) = $this->_bd_splitPath($this->options['path']);
         $this->options['alias'] = $this->options['path'] === '/' ? $this->options['root'] : $this->_bd_query($itemId, $fetch_self = true)->name . '@Box.com';
     }
     $this->rootName = $this->options['alias'];
     $this->tmbPrefix = 'box' . base_convert($this->netMountKey, 10, 32);
     if (!empty($this->options['tmpPath'])) {
         if ((is_dir($this->options['tmpPath']) || mkdir($this->options['tmpPath'])) && is_writable($this->options['tmpPath'])) {
             $this->tmp = $this->options['tmpPath'];
         }
     }
     if (!$this->tmp && is_writable($this->options['tmbPath'])) {
         $this->tmp = $this->options['tmbPath'];
     }
     if (!$this->tmp && ($tmp = elFinder::getStaticVar('commonTempPath'))) {
         $this->tmp = $tmp;
     }
     // This driver dose not support `syncChkAsTs`
     $this->options['syncChkAsTs'] = false;
     // 'lsPlSleep' minmum 10 sec
     $this->options['lsPlSleep'] = max(10, $this->options['lsPlSleep']);
     return true;
 }
 /**
  * Prepare FTP connection
  * Connect to remote server and check if credentials are correct, if so, store the connection id in $ftp_conn.
  *
  * @return bool
  *
  * @author Dmitry (dio) Levashov
  * @author Cem (DiscoFever)
  **/
 protected function init()
 {
     if (!$this->options['accessToken']) {
         return $this->setError('Required option `accessToken` is undefined.');
     }
     try {
         $this->token = json_decode($this->options['accessToken']);
         $this->_od_refreshToken();
     } catch (Exception $e) {
         $this->token = null;
         $this->session->remove('OneDriveTokens');
         return $this->setError($e->getMessage());
     }
     if (empty($options['netkey'])) {
         // make net mount key
         $_tokenKey = isset($this->token->data->refresh_token) ? $this->token->data->refresh_token : $this->token->data->access_token;
         $this->netMountKey = md5(implode('-', array('box', $this->options['path'], $_tokenKey)));
     } else {
         $this->netMountKey = $options['netkey'];
     }
     // normalize root path
     if ($this->options['path'] == 'root') {
         $this->options['path'] = '/';
     }
     $this->root = $this->options['path'] = $this->_normpath($this->options['path']);
     $this->options['root'] == '' ? $this->options['root'] = 'OneDrive.com' : $this->options['root'];
     if (empty($this->options['alias'])) {
         $this->options['alias'] = $this->options['path'] === '/' ? $this->options['root'] : $this->_od_query(basename($this->options['path']), $fetch_self = true)->name . '@OneDrive';
     }
     $this->rootName = $this->options['alias'];
     $this->tmbPrefix = 'onedrive' . base_convert($this->netMountKey, 10, 32);
     if (!empty($this->options['tmpPath'])) {
         if ((is_dir($this->options['tmpPath']) || mkdir($this->options['tmpPath'])) && is_writable($this->options['tmpPath'])) {
             $this->tmp = $this->options['tmpPath'];
         }
     }
     if (!$this->tmp && is_writable($this->options['tmbPath'])) {
         $this->tmp = $this->options['tmbPath'];
     }
     if (!$this->tmp && ($tmp = elFinder::getStaticVar('commonTempPath'))) {
         $this->tmp = $tmp;
     }
     // This driver dose not support `syncChkAsTs`
     $this->options['syncChkAsTs'] = false;
     // 'lsPlSleep' minmum 10 sec
     $this->options['lsPlSleep'] = max(10, $this->options['lsPlSleep']);
     $this->queryOptions = array('query' => array('select' => 'id,name,lastModifiedDateTime,file,folder,size,image'));
     if ($this->options['useApiThumbnail']) {
         $this->options['tmbURL'] = 'https://';
         $this->queryOptions['query']['expand'] = 'thumbnails(select=small)';
     }
     return true;
 }