$version, 'key' => $key, 'file' => $file, 'archive' => $archive, 'zipfile' => $zipfile ); } function display_from_archive( $params, $content_map = array(), $override_extractor = null) { $params['template'] = dirname(__FILE__)."/template.php"; $params['title'] = NULL; $params['charset'] = NULL; $params['content'] = 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],$params['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($params); return; } // Check zipfile. $check_file = $params['zipfile'] ? $params['archive'] : $params['file']; if (!is_file($check_file)) { file_not_found($params, $params['zipfile'] ? 'Unable to find zipfile.' : 'Unable to find file.'); return; } $last_modified = max( strtotime("Sun, 11 Jul 2010 18:55:24 +0100"), filemtime($check_file)); if (!conditional_get($last_modified)) return; // Extract the file from the zipfile if ($params['zipfile']) { $unzip = UNZIP .' -p '.escapeshellarg($params['archive']) .' '.escapeshellarg($params['file']); if($extractor == 'raw') { display_raw_file($unzip, $type); return; } // Note: this sets $params['content'] with either the content or an error // message: if(!extract_file($unzip, $params['content'])) { file_not_found($params, $params['content']); return; } } else { if($extractor == 'raw') { display_unzipped_file($params['file'], $type); return; } // Note: this sets $params['content'] with either the content or an error // message: if(!extract_unzipped_file($params['file'], $params['content'])) { file_not_found($params, $params['content']); return; } } if($type == 'text/html') { if(html_headers($params['content'])) { if($_SERVER['REQUEST_METHOD'] != 'HEAD') echo $params['content']; return; } } if($_SERVER['REQUEST_METHOD'] == 'HEAD') return; if ($preprocess) { $params['content'] = call_user_func($preprocess, $params['content']); } echo_filtered($extractor, $params); } function conditional_get($last_modified) { if(!$last_modified) return true; $last_modified_text = date(DATE_RFC2822, $last_modified); $etag = '"'.md5($last_modified).'"'; header("Last-Modified: $last_modified_text"); header("ETag: $etag"); $checked = false; if(isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { $checked = true; $if_modified_since = strtotime(stripslashes($_SERVER['HTTP_IF_MODIFIED_SINCE'])); if(!$if_modified_since || $if_modified_since < $last_modified) return true; } if(isset($_SERVER['HTTP_IF_NONE_MATCH'])) { $checked = true; if(stripslashes($_SERVER['HTTP_IF_NONE_MATCH'] != $etag)) return true; } if(!$checked) return true; header($_SERVER["SERVER_PROTOCOL"].' 304 Not Modified'); return false; } class boost_archive_render_callbacks { var $content_callback, $params; function boost_archive_render_callbacks($content, $params) { $this->content_callback = $content; $this->archive = $params; } 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_encoded_text($params, 'text');
print "\n";
}
function cpp_filter($params) {
$params['title'] = htmlentities($params['key']);
display_template($params['template'],
new boost_archive_render_callbacks('cpp_filter_content', $params));
}
function cpp_filter_content($params)
{
print "\n";
print_encoded_text($params, 'cpp');
print "\n";
}
function boost_book_html_filter($params) {
html_init($params);
display_template($params['template'],
new boost_archive_render_callbacks('boost_book_html_filter_content', $params));
}
function boost_book_html_filter_content($params)
{
$text = prepare_html($params['content']);
$text = substr($text,strpos($text,'