version_ = $path_parts[1];
$this->key_ = $path_parts[2];
if ($archive_subdir)
{
$this->file_ = $archive_file_prefix . $this->version_ . '/' . $this->key_;
}
else
{
$this->file_ = $archive_file_prefix . $this->key_;
}
$this->archive_ = str_replace('\\','/', $archive_dir . '/' . $this->version_ . '.zip');
foreach ($info_map as $i)
{
if (preg_match($i[1],$this->key_))
{
$this->extractor_ = $i[2];
$this->type_ = $i[3];
$this->preprocess_ = isset($i[4]) ? $i[4] : NULL;
break;
}
}
$unzip =
UNZIP
.' -p '.escapeshellarg($this->archive_)
.' '.escapeshellarg($this->file_);
if (! $this->extractor_)
{
# File doesn't exist, or we don't know how to handle it.
$this->extractor_ = '404';
$this->_init_404();
}
else if ($get_as_raw || $this->extractor_ == 'raw')
{
$this->_extract_raw($unzip);
//~ print "--- $unzip";
}
else
{
/* We pre-extract so we can get this like meta tag information
before we have to print it out. */
$this->content_ = $this->_extract_string($unzip);
$f = '_init_'.$this->extractor_;
$this->$f();
if($this->preprocess_) {
$this->content_ = call_user_func($this->preprocess_, $this->content_);
}
if ($this->extractor_ == 'simple')
{
$f = '_content_'.$this->extractor_;
$this->$f();
}
}
}
function content_head()
{
$charset = $this->charset_ ? $this->charset_ : 'us-ascii';
$title = $this->title_ ? 'Boost C++ Libraries - '.$this->title_ : 'Boost C++ Libraries';
print <<
${title}
HTML;
}
function is_basic()
{
return $this->extractor_ == 'basic';
}
function is_raw()
{
return $this->extractor_ == 'raw' || $this->extractor_ == 'simple';
}
function _extract_string($unzip)
{
$file_handle = popen($unzip,'r');
$text = '';
while ($file_handle && !feof($file_handle)) {
$text .= fread($file_handle,8*1024);
}
if(pclose($file_handle) == 0) {
return $text;
}
else {
$this->extractor_ = '404';
return '';
}
}
function _extract_raw($unzip)
{
header('Content-type: '.$this->type_);
## header('Content-Disposition: attachment; filename="downloaded.pdf"');
$file_handle = popen($unzip,'rb');
fpassthru($file_handle);
$exit_status = pclose($file_handle);
// Don't display errors for a corrupt zip file, as we seemd to
// be getting them for legitimate files.
if($exit_status > 3)
echo 'Error extracting file: '.unzip_error($exit_status);
}
function content()
{
if ($this->extractor_)
{
$f = '_content_'.$this->extractor_;
$this->$f();
}
}
function _init_text()
{
$this->title_ = htmlentities($this->key_);
}
function _content_text()
{
print "".htmlentities($this->key_)."
\n";
print "\n";
print htmlentities($this->content_);
print "\n";
}
function _init_cpp()
{
$this->title_ = htmlentities($this->key_);
}
function _content_cpp()
{
$text = htmlentities($this->content_);
print "".htmlentities($this->key_)."
\n";
print "\n";
$root = dirname(preg_replace('@([^/]+/)@','../',$this->key_));
$text = preg_replace(
'@(#[ ]*include[ ]+<)(boost[^&]+)@Ssm',
'${1}${2}',
$text );
$text = preg_replace(
'@(#[ ]*include[ ]+")(boost[^&]+)@Ssm',
'${1}${2}',
$text );
print $text;
print "\n";
}
function _init_html_pre()
{
preg_match('@text/html; charset=([^\s"\']+)@i',$this->content_,$charset);
if (isset($charset[1]))
{
$this->charset_ = $charset[1];
}
preg_match('@([^<]+)@i',$this->content_,$title);
if (isset($title[1]))
{
$this->title_ = $title[1];
}
}
function _content_html_pre()
{
$text = $this->content_;
$text = preg_replace(
'@href="?http://www.boost.org/?([^"\s]*)"?@i',
'href="/${1}"',
$text );
$text = preg_replace(
'@href="?http://boost.org/?([^"\s]*)"?@i',
'href="/${1}"',
$text );
$text = preg_replace(
'@href="?(?:\.\./)+people/(.*\.htm)"?@i',
'href="/users/people/${1}l"',
$text );
$text = preg_replace(
'@href="?(?:\.\./)+(LICENSE_[^"\s]*\.txt)"?@i',
'href="/${1}"',
$text );
$text = preg_replace(
'@_init_html_pre();
}
function _content_boost_book_html()
{
$text = $this->_content_html_pre();
$text = substr($text,strpos($text,''));
$text = substr($text,0,strpos($text,''));
$text = str_replace('
','',$text);
$text = str_replace('