$version, 'key' => $key, 'file' => $file, 'archive' => $archive ); } function display_from_archive( $archive_location_details, $content_map = array(), $override_extractor = null) { $info_map = array_merge($content_map, array( array('@.*@','@[.](txt|py|rst|jam|v2|bat|sh|xml|qbk)$@i','text','text/plain'), array('@.*@','@[.](c|h|cpp|hpp)$@i','cpp','text/plain'), array('@.*@','@[.]png$@i','raw','image/png'), array('@.*@','@[.]gif$@i','raw','image/gif'), array('@.*@','@[.](jpg|jpeg|jpe)$@i','raw','image/jpeg'), array('@.*@','@[.]css$@i','raw','text/css'), array('@.*@','@[.]js$@i','raw','application/x-javascript'), array('@.*@','@[.]pdf$@i','raw','application/pdf'), array('@.*@','@[.](html|htm)$@i','raw','text/html'), array('@.*@','@[^.](Jamroot|Jamfile|ChangeLog)$@i','text','text/plain'), array('@.*@','@[.]dtd$@i','raw','application/xml-dtd'), )); $preprocess = null; $extractor = null; $type = null; foreach ($info_map as $i) { if (preg_match($i[1],$archive_location_details['key'])) { $extractor = $i[2]; $type = $i[3]; $preprocess = isset($i[4]) ? $i[4] : NULL; break; } } if ($override_extractor) $extractor = $override_extractor; if (!$extractor) { file_not_found($archive_location_details['file']); return; } $unzip = UNZIP .' -p '.escapeshellarg($archive_location_details['archive']) .' '.escapeshellarg($archive_location_details['file']); if($extractor == 'raw') { display_raw_file($unzip, $type); return; } $archive = new boost_archive(); $archive->key_ = $archive_location_details['key']; // Note: this sets $archive->content_ with either the content or an error // message: if(!extract_file($unzip, $archive->content_)) { file_not_found($archive_location_details['file'], $archive->content_); return; } if($type == 'text/html') { if(html_headers($archive->content_)) { echo $archive->content_; exit(0); } } if ($preprocess) { $archive->content_ = call_user_func($preprocess, $archive->content_); } $extractor_name = $extractor.'_filter'; call_user_func($extractor_name, $archive); } class boost_archive { var $key_ = NULL; var $title_ = NULL; var $charset_ = NULL; var $content_ = NULL; } class boost_archive_render_callbacks { var $content_callback, $archive; function boost_archive_render_callbacks($content, $archive) { $this->content_callback = $content; $this->archive = $archive; } function content_head() { $charset = $this->archive->charset_ ? $this->archive->charset_ : 'us-ascii'; $title = $this->archive->title_ ? 'Boost C++ Libraries - '.$this->archive->title_ : 'Boost C++ Libraries'; print <<
\n";
print htmlentities($archive->content_);
print "\n";
}
function cpp_filter($archive) {
$archive->title_ = htmlentities($archive->key_);
display_template(new boost_archive_render_callbacks('cpp_filter_content', $archive));
}
function cpp_filter_content($archive)
{
$text = htmlentities($archive->content_);
print "\n";
$root = dirname(preg_replace('@([^/]+/)@','../',$archive->key_));
$text = preg_replace(
'@(#[ ]*include[ ]+<)(boost[^&]+)@Ssm',
'${1}${2}',
$text );
$text = preg_replace(
'@(#[ ]*include[ ]+")(boost[^&]+)@Ssm',
'${1}${2}',
$text );
print $text;
print "\n";
}
function boost_book_html_filter($archive) {
html_init($archive);
display_template(new boost_archive_render_callbacks('boost_book_html_filter_content', $archive));
}
function boost_book_html_filter_content($archive)
{
$text = prepare_html($archive->content_);
$text = substr($text,strpos($text,'