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('','
',$text); $text = str_replace('','
',$text); $text = preg_replace( '@[\s]+(border|cellpadding|cellspacing|width|height|valign|frame|rules|naturalsizeflag|background)=[^\s>]+@i', '', $text ); /* */ for ($i = 0; $i < 8; $i++) { $text = preg_replace( '@([^@Ssm', '${2}', $text ); } /* */ print $text; } function _init_boost_libs_html() { $this->_init_html_pre(); } function _content_boost_libs_html() { $text = $this->_content_html_pre(); preg_match('@]*>@i',$text,$body_begin,PREG_OFFSET_CAPTURE); preg_match('@@i',$text,$body_end,PREG_OFFSET_CAPTURE); if (!isset($body_begin[0])) { //~ Attempt to recover some content from illegal HTML that is missing the body tag. preg_match('@@i',$text,$body_begin,PREG_OFFSET_CAPTURE); } if (!isset($body_begin[0])) { //~ Attempt to recover some content from illegal HTML that is missing the body tag. preg_match('@]*>@i',$text,$body_begin,PREG_OFFSET_CAPTURE); } if (!isset($body_begin[0])) { //~ Attempt to recover some content from illegal HTML that is missing the body tag. preg_match('@<(hr|div|img|p|h1|h2|h3|h4)[^>]*>@i',$text,$body_begin,PREG_OFFSET_CAPTURE); } if (!isset($body_begin[0])) { return; } else if (!isset($body_end[0])) { $text = substr($text, $body_begin[0][1]+strlen($body_begin[0][0])); } else { $text = substr($text, $body_begin[0][1]+strlen($body_begin[0][0]), $body_end[0][1]-($body_begin[0][1]+strlen($body_begin[0][0])) ); } # nasty code, because (?!fubar) causes an ICE... preg_match('@]*>?@i',$text,$table_begin,PREG_OFFSET_CAPTURE); preg_match('@@i',$text,$table_end,PREG_OFFSET_CAPTURE); if (isset($table_begin[0]) && isset($table_end[0])) { $table_contents_start = $table_begin[0][1] + strlen($table_begin[0][0]); $table_contents = substr($text, $table_contents_start, $table_end[0][1] - $table_contents_start); if(strpos($table_contents, 'boost.png') !== FALSE) { preg_match('@]*>?([^<]*<(h[12]|p).*?)@is', $table_contents, $table_contents_header, PREG_OFFSET_CAPTURE); $text = (isset($table_contents_header[1]) ? $table_contents_header[1][0] : ''). substr($text, $table_end[0][1] + 8); } } #else #{ # $text = substr($text,$h1_begin[0][1]); #} #if (isset($title[1])) #{ # $text = "

${title[1]}

\n" . $text; #} $text = preg_replace( '@(]+>[\s]*)?]*>([\s]*)?@i', '', $text ); $text = preg_replace( '@]*>@i', '', $text ); $text = preg_replace( '@]*>@i', '', $text ); /* Remove certain attributes */ $text = preg_replace( '@[\s]+(border|cellpadding|cellspacing|width|height|valign|align|frame|rules|naturalsizeflag|background)=("[^"]*"?|\'[^\']*\'?|[^\s/>]+)@i', '', $text ); $text = preg_replace( '@]*@i', ']*>@i', '', $text ); $text = preg_replace( '@<([^\s]+)[\s]+>@i', '<${1}>', $text ); $text = _preg_replace_bounds( '@
[\s]*(
)@i','@(
)[\s]*
@i', '${1}','${1}', $text ); $text = _preg_replace_bounds( '@
[\s]*(

)@i','@(

)[\s]*
@i', '${1}','${1}', $text ); $text = _preg_replace_bounds( '@
[\s]*()@i','@(
)[\s]*
@i', '${1}','${1}', $text ); $text = _preg_replace_bounds( '@
[\s]*
  • @i','@
  • [\s]*
    @i', '
    • ','
    ', $text ); $text = _preg_replace_bounds( '@(?:
    [\s]*)+

    @i','@

    (?:[\s]*
    )+@i', '

    ','

    ', $text ); $text = preg_replace( '@(]+[\s]*>)[\s]*(${2}', $text ); $text = preg_replace( '@([\s]+[\s]+[\s]+[\s]+[\s]+[\s]+)
    .*_arr.*.*.*
    @i', '${1}
    ', $text ); $text = preg_replace( '@([\s]+[\s]+@i', '
    ${1}>', $text ); $text = preg_replace( '@
    ([\s]+[\s]+)@i', '
    ${1}', $text ); $text = preg_replace( '@src=".*theme/u_arr\.gif"@i', 'src="/gfx/space.png" class="up_image"', $text ); $text = preg_replace( '@src=".*theme/l_arr\.gif"@i', 'src="/gfx/space.png" class="prev_image"', $text ); $text = preg_replace( '@src=".*theme/r_arr\.gif"@i', 'src="/gfx/space.png" class="next_image"', $text ); $text = preg_replace( '@src=".*theme/u_arr_disabled\.gif"@i', 'src="/gfx/space.png" class="up_image_disabled"', $text ); $text = preg_replace( '@src=".*theme/l_arr_disabled\.gif"@i', 'src="/gfx/space.png" class="prev_image_disabled"', $text ); $text = preg_replace( '@src=".*theme/r_arr_disabled\.gif"@i', 'src="/gfx/space.png" class="next_image_disabled"', $text ); $text = preg_replace( '@src=".*theme/note\.gif"@i', 'src="/gfx/space.png" class="note_image"', $text ); $text = preg_replace( '@src=".*theme/alert\.gif"@i', 'src="/gfx/space.png" class="caution_image"', $text ); $text = preg_replace( '@src=".*theme/bulb\.gif"@i', 'src="/gfx/space.png" class="tip_image"', $text ); $text = preg_replace( '@@i', '', $text ); $text = preg_replace( '@(@i', '${1} class="inline">', $text ); print $text; } function _init_boost_frame1_html() { $this->_init_html_pre(); } function _content_boost_frame1_html() { $text = $this->_content_html_pre(); $text = substr($text,strpos($text,'
    ')); $text = substr($text,0,strpos($text,'')); for ($i = 0; $i < 8; $i++) { $text = preg_replace( '@(.*)@Ssm', '${2}', $text ); } $text = str_replace('
    ','',$text); $text = str_replace('
    ','
    ',$text); $text = preg_replace( '@[\s]+(border|cellpadding|cellspacing|width|height|valign|frame|rules|naturalsizeflag|background)=[^\s>]+@i', '', $text ); print $text; } function _init_simple() { } function _content_simple() { print $this->_content_html_pre(); } function _init_basic() { } function _content_basic() { $is_xhtml = preg_match('@]*xhtml@i', $text); $tag_end = $is_xhtml ? '/>' : '>'; $text = $this->_content_html_pre(); $text = preg_split('@(|]*>)@i',$text,-1,PREG_SPLIT_DELIM_CAPTURE); $state = 0; foreach($text as $section) { print($section); switch($state) { case 0: print '404 Not Found

    File "' . $this->file_ . '"not found.

    '; } } // Return a readable error message for unzip exit state. function unzip_error($exit_status) { switch($exit_status) { case 0: return 'No error.'; case 1: return 'One or more warning errors were encountered.'; case 2: return 'A generic error in the zipfile format was detected.'; case 3: return 'A severe error in the zipfile format was detected.'; case 4: return 'Unzip was unable to allocate memory for one or more buffers during program initialization.'; case 5: return 'Unzip was unable to allocate memory or unable to obtain a tty to read the decryption password(s).'; case 6: return 'Unzip was unable to allocate memory during decompression to disk.'; case 7: return 'Unzip was unable to allocate memory during in-memory decompression.'; case 9: return 'The specified zipfiles were not found.'; case 10: return 'Invalid options were specified on the command line.'; case 11: return 'No matching files were found.'; case 50: return 'The disk is (or was) full during extraction.'; case 51: return 'The end of the ZIP archive was encountered prematurely.'; case 80: return 'The user aborted unzip prematurely with control-C (or similar).'; case 81: return 'Testing or extraction of one or more files failed due to unsupported compression methods or unsupported decryption.'; case 82: return 'No files were found due to bad decryption password(s).'; default: return 'Unknown unzip error code: ' + $exit_status; } } ?>