/** * Tests mirror * * @param string $error * @return bool */ function test(&$error) { if (!parent::test($error)) { return false; } $results = array(); $files = array('' => '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; }
/** * Returns VIA string * * @return string */ function get_via() { return sprintf('Rackspace Cloud Files: %s', parent::get_via()); }
/** * Returns array of headers * * @param string $file * @return array */ function _get_headers($file) { $allowed_headers = array('Content-Length', 'Content-Type', 'Content-Encoding', 'Content-Language', 'Content-MD5', 'Cache-Control'); $headers = parent::_get_headers($file); foreach ($headers as $header => $value) { if (!in_array($header, $allowed_headers)) { unset($headers[$header]); } } return $headers; }
/** * 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; }
/** * 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_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 (!@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; }
/** * PHP5 Constructor * * @param array $config */ function __construct($config = array()) { $config = array_merge(array('domain' => array()), $config); parent::__construct($config); }
/** * Returns via string * * @return string */ function get_via() { return sprintf('Amazon Web Services: S3: %s', parent::get_via()); }