芝麻web文件管理V1.00
编辑当前文件:/home/mgatv524/public_html/avenida/views/HTTP_Request.tar
docs/download-progress.php 0000644 00000006604 14716407566 0011704 0 ustar 00 HTTP_Request_Listener(); } /** * Opens the target file * @param string Target file name * @throws PEAR_Error */ function setTarget($target) { $this->_target = $target; $this->_fp = @fopen($target, 'wb'); if (!$this->_fp) { PEAR::raiseError("Cannot open '{$target}'"); } } function update(&$subject, $event, $data = null) { switch ($event) { case 'sentRequest': $this->_target = basename($subject->_url->path); break; case 'gotHeaders': if (isset($data['content-disposition']) && preg_match('/filename="([^"]+)"/', $data['content-disposition'], $matches)) { $this->setTarget(basename($matches[1])); } else { $this->setTarget($this->_target); } $this->_bar =& new Console_ProgressBar( '* ' . $this->_target . ' %fraction% KB [%bar%] %percent%', '=>', '-', 79, (isset($data['content-length'])? round($data['content-length'] / 1024): 100) ); $this->_size = 0; break; case 'tick': $this->_size += strlen($data); $this->_bar->update(round($this->_size / 1024)); fwrite($this->_fp, $data); break; case 'gotBody': fclose($this->_fp); break; case 'connect': case 'disconnect': break; default: PEAR::raiseError("Unhandled event '{$event}'"); } // switch } } // Try using any other package if you like, but choose the bigger ones // to be able to see the progress bar $url = 'http://pear.php.net/get/HTML_QuickForm-stable'; $req =& new HTTP_Request($url); $download =& new HTTP_Request_DownloadListener(); $req->attach($download); $req->sendRequest(false); ?> docs/example.php 0000644 00000006161 14716407566 0007664 0 ustar 00 | // +-----------------------------------------------------------------------+ /** * This will grab a webpage and display it * * @category HTTP * @package HTTP_Request * @version CVS: $Id: example.php,v 1.7 2007/05/18 19:20:12 avb Exp $ * @ignore */ /** * Class for performing HTTP requests */ include('HTTP/Request.php'); $req = &new HTTP_Request('http://www.php.net'); $req->setMethod(HTTP_REQUEST_METHOD_POST); $req->addPostData('Foo', 'bar'); $req->sendRequest(); $response1 = $req->getResponseBody(); $req->setMethod(HTTP_REQUEST_METHOD_GET); $req->setURL('http://pear.php.net'); $req->clearPostData(); $req->sendRequest(); $response2 = $req->getResponseBody(); echo $response1; echo $response2; ?>