/** * PHP5 Constructor * * @param array $config */ function __construct($config = array()) { parent::__construct($config); $this->_client_id = $config['client_id']; $this->_refresh_token = $config['refresh_token']; $this->_root_folder_id = $config['root_folder_id']; $this->_root_url = rtrim($config['root_url'], '/') . '/'; $this->_new_access_token_callback = $config['new_access_token_callback']; $this->_init_service($config['access_token']); }
/** * Tests mirror * * @param string $error * @return bool */ function test(&$error) { if (!parent::test($error)) { return false; } $results = array(); $files = array(array('local_path' => '', 'remote_path' => 'purge_test_' . time())); if (!$this->purge($files, $results) && isset($results[0]['error'])) { $error = $results[0]['error']; return false; } return true; }
function get_prepend_path($path) { $path = parent::get_prepend_path($path); $path = $this->_config['container'] ? trim($path, '/') . '/' . trim($this->_config['container'], '/') : $path; return $path; }
/** * Tests FTP server * * @param string $error * @return boolean */ function test(&$error) { if (!parent::test($error)) { return false; } $rand = md5(time()); $tmp_dir = 'test_dir_' . $rand; $tmp_file = 'test_file_' . $rand; $tmp_path = W3TC_CACHE_TMP_DIR . '/' . $tmp_file; if (!@file_put_contents($tmp_path, $rand)) { $error = sprintf('Unable to create file: %s.', $tmp_path); return false; } if (!$this->_connect($error)) { return false; } $this->_set_error_handler(); if (!@ftp_mkdir($this->_ftp, $tmp_dir)) { $error = sprintf('Unable to make directory: %s (%s).', $tmp_dir, $this->_get_last_error()); @unlink($tmp_path); $this->_restore_error_handler(); $this->_disconnect(); return false; } if (file_exists($this->_config['docroot'] . '/' . $tmp_dir)) { $error = sprintf('Test directory was made in your site root, not on separate FTP host or path. Change path or FTP information: %s.', $tmp_dir); @unlink($tmp_path); @ftp_rmdir($this->_ftp, $tmp_dir); $this->_restore_error_handler(); $this->_disconnect(); return false; } if (!@ftp_chdir($this->_ftp, $tmp_dir)) { $error = sprintf('Unable to change directory to: %s (%s).', $tmp_dir, $this->_get_last_error()); @unlink($tmp_path); @ftp_rmdir($this->_ftp, $tmp_dir); $this->_restore_error_handler(); $this->_disconnect(); return false; } if (!@ftp_put($this->_ftp, $tmp_file, $tmp_path, FTP_BINARY)) { $error = sprintf('Unable to upload file: %s (%s).', $tmp_path, $this->_get_last_error()); @unlink($tmp_path); @ftp_cdup($this->_ftp); @ftp_rmdir($this->_ftp, $tmp_dir); $this->_restore_error_handler(); $this->_disconnect(); return false; } @unlink($tmp_path); if (!@ftp_delete($this->_ftp, $tmp_file)) { $error = sprintf('Unable to delete file: %s (%s).', $tmp_path, $this->_get_last_error()); @ftp_cdup($this->_ftp); @ftp_rmdir($this->_ftp, $tmp_dir); $this->_restore_error_handler(); $this->_disconnect(); return false; } @ftp_cdup($this->_ftp); if (!@ftp_rmdir($this->_ftp, $tmp_dir)) { $error = sprintf('Unable to remove directory: %s (%s).', $tmp_dir, $this->_get_last_error()); $this->_restore_error_handler(); $this->_disconnect(); return false; } $this->_restore_error_handler(); $this->_disconnect(); return true; }
/** * Returns via string * * @return string */ function get_via() { return sprintf('Amazon Web Services: S3: %s', parent::get_via()); }
/** * Returns VIA string * * @return string */ function get_via() { return sprintf('Rackspace Cloud Files: %s', parent::get_via()); }
/** * Returns via string * * @return string */ function get_via() { return sprintf('S3-compatible: %s', parent::get_via()); }