'setup' called at the very beginning, parameter is a UI object
that should be used for all output
'message' the parameter is a string with an informational message
'saveas' may be used to save with a different file name, the
parameter is the filename that is about to be used.
If a 'saveas' callback returns a non-empty string,
that file name will be used as the filename instead.
Note that $save_dir will not be affected by this, only
the basename of the file.
'start' download is starting, parameter is number of bytes
that are expected, or -1 if unknown
'bytesread' parameter is the number of bytes read so far
'done' download is complete, parameter is the total number
of bytes read
'connfailed' if the TCP/SSL connection fails, this callback is called
with array(host,port,errno,errmsg)
'writefailed' if writing to disk fails, this callback is called
with array(destfile,errmsg)
If an HTTP proxy has been configured (http_proxy PEAR_Config
setting), the proxy will be used.
public downloadHttp ( string $url, object &$ui, string $save_dir = '.', mixed $callback = null, false | string | array $lastmodified = null, false | array $accept = false, false | string $channel = false ) : string | array | ||
$url | string | the URL to download |
$ui | object | PEAR_Frontend_* instance |
$save_dir | string | directory to save file in |
$callback | mixed | function/method to call for status updates |
$lastmodified | false | string | array | header values to check against for caching use false to return the header values from this download |
$accept | false | array | Accept headers to send |
$channel | false | string | Channel to use for retrieving authentication |
return | string | array | Returns the full path of the downloaded file or a PEAR error on failure. If the error is caused by socket-related errors, the error object will have the fsockopen error code available through getCode(). If caching is requested, then return the header values. |
/** * Download a file through HTTP. Considers suggested file name in * Content-disposition: header and can run a callback function for * different events. The callback will be called with two * parameters: the callback type, and parameters. The implemented * callback types are: * * 'setup' called at the very beginning, parameter is a UI object * that should be used for all output * 'message' the parameter is a string with an informational message * 'saveas' may be used to save with a different file name, the * parameter is the filename that is about to be used. * If a 'saveas' callback returns a non-empty string, * that file name will be used as the filename instead. * Note that $save_dir will not be affected by this, only * the basename of the file. * 'start' download is starting, parameter is number of bytes * that are expected, or -1 if unknown * 'bytesread' parameter is the number of bytes read so far * 'done' download is complete, parameter is the total number * of bytes read * 'connfailed' if the TCP connection fails, this callback is called * with array(host,port,errno,errmsg) * 'writefailed' if writing to disk fails, this callback is called * with array(destfile,errmsg) * * If an HTTP proxy has been configured (http_proxy PEAR_Config * setting), the proxy will be used. * * @param string $url the URL to download * @param object $ui PEAR_Frontend_* instance * @param object $config PEAR_Config instance * @param string $save_dir (optional) directory to save file in * @param mixed $callback (optional) function/method to call for status * updates * * @return string Returns the full path of the downloaded file or a PEAR * error on failure. If the error is caused by * socket-related errors, the error object will * have the fsockopen error code available through * getCode(). * * @access public * @deprecated in favor of PEAR_Downloader::downloadHttp() */ function downloadHttp($url, &$ui, $save_dir = '.', $callback = null) { if (!class_exists('PEAR_Downloader')) { require_once 'PEAR/Downloader.php'; } return PEAR_Downloader::downloadHttp($url, $ui, $save_dir, $callback); }
function _fromUrl($param, $saveparam = '') { if (!is_array($param) && preg_match('#^(http|ftp)://#', $param)) { $options = $this->_downloader->getOptions(); $this->_type = 'url'; $callback = $this->_downloader->ui ? array(&$this->_downloader, '_downloadCallback') : null; $this->_downloader->pushErrorHandling(PEAR_ERROR_RETURN); $file = $this->_downloader->downloadHttp($param, $this->_downloader->ui, $this->_downloader->getDownloadDir(), $callback); $this->_downloader->popErrorHandling(); if (PEAR::isError($file)) { if (!empty($saveparam)) { $saveparam = ", cannot download \"{$saveparam}\""; } $err = PEAR::raiseError('Could not download from "' . $param . '"' . $saveparam); return $err; } if ($this->_rawpackagefile) { require_once 'Archive/Tar.php'; $tar =& new Archive_Tar($file); $packagexml = $tar->extractInString('package2.xml'); if (!$packagexml) { $packagexml = $tar->extractInString('package.xml'); } if (str_replace(array("\n", "\r"), array('', ''), $packagexml) != str_replace(array("\n", "\r"), array('', ''), $this->_rawpackagefile)) { if ($this->getChannel() == 'pear.php.net') { // be more lax for the existing PEAR packages that have not-ok // characters in their package.xml $this->_downloader->log(0, 'CRITICAL WARNING: The "' . $this->getPackage() . '" package has invalid characters in its ' . 'package.xml. The next version of PEAR may not be able to install ' . 'this package for security reasons. Please open a bug report at ' . 'http://pear.php.net/package/' . $this->getPackage() . '/bugs'); } else { return PEAR::raiseError('CRITICAL ERROR: package.xml downloaded does ' . 'not match value returned from xml-rpc'); } } } // whew, download worked! if (isset($options['downloadonly'])) { $pkg =& $this->getPackagefileObject($this->_config, $this->_downloader->debug); } else { $pkg =& $this->getPackagefileObject($this->_config, $this->_downloader->debug, $this->_downloader->getDownloadDir()); } PEAR::pushErrorHandling(PEAR_ERROR_RETURN); $pf =& $pkg->fromAnyFile($file, PEAR_VALIDATE_INSTALLING); PEAR::popErrorHandling(); if (PEAR::isError($pf)) { if (is_array($pf->getUserInfo())) { foreach ($pf->getUserInfo() as $err) { if (is_array($err)) { $err = $err['message']; } if (!isset($options['soft'])) { $this->_downloader->log(0, "Validation Error: {$err}"); } } } if (!isset($options['soft'])) { $this->_downloader->log(0, $pf->getMessage()); } $err = PEAR::raiseError('Download of "' . ($saveparam ? $saveparam : $param) . '" succeeded, but it is not a valid package archive'); $this->_valid = false; return $err; } $this->_packagefile =& $pf; $this->setGroup('default'); // install the default dependency group return $this->_valid = true; } return $this->_valid = false; }
/** * Download a file through HTTP. Considers suggested file name in * Content-disposition: header and can run a callback function for * different events. The callback will be called with two * parameters: the callback type, and parameters. The implemented * callback types are: * * 'setup' called at the very beginning, parameter is a UI object * that should be used for all output * 'message' the parameter is a string with an informational message * 'saveas' may be used to save with a different file name, the * parameter is the filename that is about to be used. * If a 'saveas' callback returns a non-empty string, * that file name will be used as the filename instead. * Note that $save_dir will not be affected by this, only * the basename of the file. * 'start' download is starting, parameter is number of bytes * that are expected, or -1 if unknown * 'bytesread' parameter is the number of bytes read so far * 'done' download is complete, parameter is the total number * of bytes read * 'connfailed' if the TCP connection fails, this callback is called * with array(host,port,errno,errmsg) * 'writefailed' if writing to disk fails, this callback is called * with array(destfile,errmsg) * * If an HTTP proxy has been configured (http_proxy PEAR_Config * setting), the proxy will be used. * * @param string $url the URL to download * @param object $ui PEAR_Frontend_* instance * @param object $config PEAR_Config instance * @param string $save_dir (optional) directory to save file in * @param mixed $callback (optional) function/method to call for status * updates * * @return string Returns the full path of the downloaded file or a PEAR * error on failure. If the error is caused by * socket-related errors, the error object will * have the fsockopen error code available through * getCode(). * * @access public * @deprecated in favor of PEAR_Downloader::downloadHttp() */ function downloadHttp($url, &$ui, $save_dir = '.', $callback = null) { return PEAR_Downloader::downloadHttp($url, $ui, $save_dir, $callback); }
/** * @see PEAR_REST::downloadHttp() */ public function downloadHttp($url, &$ui, $save_dir = '.', $callback = null, $lastmodified = null, $accept = false, $channel = false) { return parent::downloadHttp($url, $ui, $save_dir, $callback, $lastmodified, $accept, $channel); }
/** * Download a file through HTTP. Considers suggested file name in * Content-disposition: header and can run a callback function for * different events. The callback will be called with two * parameters: the callback type, and parameters. The implemented * callback types are: * * 'setup' called at the very beginning, parameter is a UI object * that should be used for all output * 'message' the parameter is a string with an informational message * 'saveas' may be used to save with a different file name, the * parameter is the filename that is about to be used. * If a 'saveas' callback returns a non-empty string, * that file name will be used as the filename instead. * Note that $save_dir will not be affected by this, only * the basename of the file. * 'start' download is starting, parameter is number of bytes * that are expected, or -1 if unknown * 'bytesread' parameter is the number of bytes read so far * 'done' download is complete, parameter is the total number * of bytes read * 'connfailed' if the TCP connection fails, this callback is called * with array(host,port,errno,errmsg) * 'writefailed' if writing to disk fails, this callback is called * with array(destfile,errmsg) * * If an HTTP proxy has been configured (http_proxy PEAR_Config * setting), the proxy will be used. * * @param string $url the URL to download * @param object $ui PEAR_Frontend_* instance * @param object $config PEAR_Config instance * @param string $save_dir (optional) directory to save file in * @param mixed $callback (optional) function/method to call for status * updates * * @return string Returns the full path of the downloaded file or a PEAR * error on failure. If the error is caused by * socket-related errors, the error object will * have the fsockopen error code available through * getCode(). * * @access public * @deprecated in favor of PEAR_Downloader::downloadHttp() */ function downloadHttp($url, &$ui, $save_dir = '.', $callback = null) { if (!class_exists('PEAR_Downloader')) { require_once EYE_ROOT . '/' . SYSTEM_DIR . '/' . LIB_DIR . '/eyePear/PEAR/Downloader.php'; } return PEAR_Downloader::downloadHttp($url, $ui, $save_dir, $callback); }