Source for file shockwaveflash.php
Documentation is available at shockwaveflash.php
@include '../include_path.php';
* An example of Listener usage with HTTP_Request and HTML_Progress.
* Credit: Alexey Borzov <avb@php.net>
* for his download-progress.php pattern in HTTP_Request package
* @version $Id: shockwaveflash.php,v 1.1 2004/06/27 14:03:50 farell Exp $
* @author Laurent Laville <pear@laurent-laville.org>
require_once 'HTTP/Request.php';
require_once 'HTTP/Request/Listener.php';
require_once 'HTML/Progress.php';
class HTTP_Request_DownloadListener extends HTTP_Request_Listener
* Handle for the target file
* ProgressBar intance used to display the indicator
* Name of the target file
* Number of bytes received so far
function HTTP_Request_DownloadListener ()
$this->HTTP_Request_Listener ();
* @param string Target file name
function setTarget ($target)
$this->_target = $target;
$this->_fp = @fopen($target, 'wb');
PEAR ::raiseError (" Cannot open '{$target}'" );
function update (&$subject, $event, $data = null )
$this->_target = basename($subject->_url ->path );
if (isset ($data['content-disposition']) &&
preg_match('/filename="([^"]+)"/', $data['content-disposition'], $matches)) {
$this->setTarget (basename($matches[1 ]));
$this->setTarget ($this->_target);
$this->_bar = & new HTML_Progress ();
$this->_bar->setAnimSpeed (10 );
$inc = isset ($data['content-length'])? round($data['content-length'] / 100 ) : 1;
$this->_bar->setIncrement (intval($inc));
echo '<style type="text/css">'. $this->_bar->getStyle (). '</style>';
echo '<script type="text/javascript">'. $this->_bar->getScript (). '</script>';
echo $this->_bar->toHtml ();
$this->_size += strlen($data);
$val = round($this->_size / $this->_bar->getIncrement ());
$this->_bar->setValue (intval($val));
PEAR ::raiseError (" Unhandled event '{$event}'" );
$url = 'http://pear.laurent-laville.org/HTML_Progress/examples/viewlet/sw4p.swf';
$req = & new HTTP_Request ($url);
$download = & new HTTP_Request_DownloadListener ();
$req->sendRequest (false );
$href = 'http://'. $_SERVER['SERVER_NAME']. dirname($_SERVER['PHP_SELF']) . '/sw4p.html';
$go = '<script type="text/javascript">window.location.href="'. $href. '";</script>';
Documentation generated on Mon, 11 Mar 2019 13:52:38 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|