$head_tag = ! empty($head_tags) ? join("\n", $head_tags) ."\n" : ''; // 1.3.x compat // Last modification date (UNIX timestamp) of the page $fmt = $is_read ? get_filetime($_page) + LOCALZONE : 0; // Search words if ($search_word_color && isset($vars['word'])) { $body = '
' . $_msg_word . htmlspecialchars($vars['word']) . '
' . $hr . "\n" . $body; $words = array_flip(array_splice( preg_split('/\s+/', $vars['word'], -1, PREG_SPLIT_NO_EMPTY), 0, 10)); $keys = array(); foreach ($words as $word=>$id) $keys[$word] = strlen($word); arsort($keys, SORT_NUMERIC); $keys = get_search_words(array_keys($keys), TRUE); $id = 0; foreach ($keys as $key=>$pattern) { $s_key = htmlspecialchars($key); $pattern = '/<[^>]*>|(' . $pattern . ')|&[^;]+;/'; $callback = create_function( '$arr', 'return (count($arr) > 1) ? \'\' . $arr[1] . \'\' : $arr[0];' ); $body = preg_replace_callback($pattern, $callback, $body); $notes = preg_replace_callback($pattern, $callback, $notes); } } $longtaketime = getmicrotime() - MUTIME; $taketime = sprintf('%01.03f', $longtaketime); require(SKIN_FILE); } // Show 'edit' form function edit_form($page, $postdata, $digest = 0, $b_template = TRUE) { global $script, $vars, $rows, $cols, $hr, $function_freeze; global $_btn_addtop, $_btn_preview, $_btn_repreview, $_btn_update, $_btn_cancel, $_msg_help, $_btn_notchangetimestamp; global $whatsnew, $_btn_template, $_btn_load, $non_list, $load_template_func; $refer = $template = $addtag = $add_top = ''; if ($digest == 0) $digest = md5(join('', get_source($page))); $checked_top = isset($vars['add_top']) ? ' checked="checked"' : ''; $checked_time = isset($vars['notimestamp']) ? ' checked="checked"' : ''; if(isset($vars['add'])) { $addtag = ''; $add_top = '' . $_btn_addtop . ''; } if($load_template_func && $b_template) { $pages = array(); $non_list_pattern = '/' . $non_list . '/'; foreach(get_existpages() as $_page) { if ($_page == $whatsnew || preg_match($non_list_pattern, $_page)) continue; $s_page = htmlspecialchars($_page); $pages[$_page] = ' '; } ksort($pages); $s_pages = join("\n", $pages); $template = << $s_pages
EOD; if (isset($vars['refer']) && $vars['refer'] != '') $refer = '[[' . strip_bracket($vars['refer']) . ']]' . "\n\n"; } $r_page = rawurlencode($page); $s_page = htmlspecialchars($page); $s_digest = htmlspecialchars($digest); $s_postdata = htmlspecialchars($refer . $postdata); $s_original = isset($vars['original']) ? htmlspecialchars($vars['original']) : $s_postdata; $b_preview = isset($vars['preview']); // TRUE when preview $btn_preview = $b_preview ? $_btn_repreview : $_btn_preview; $body = <<
$template $addtag
$add_top $_btn_notchangetimestamp  
EOD; if (isset($vars['help'])) { $body .= $hr . catrule(); } else { $body .= ''; } return $body; } // Related pages function make_related($page, $tag = '') { global $script, $vars, $rule_related_str, $related_str, $non_list; global $_ul_left_margin, $_ul_margin, $_list_pad_str; $links = links_get_related($page); if ($tag) { ksort($links); } else { arsort($links); } $_links = array(); $non_list_pattern = '/' . $non_list . '/'; foreach ($links as $page=>$lastmod) { if (preg_match($non_list_pattern, $page)) continue; $r_page = rawurlencode($page); $s_page = htmlspecialchars($page); $passage = get_passage($lastmod); $_links[] = $tag ? '' . $s_page . '' : '' . $s_page . '' . $passage; } if (empty($_links)) return ''; // Nothing if ($tag == 'p') { // From the line-head $margin = $_ul_left_margin + $_ul_margin; $style = sprintf($_list_pad_str, 1, $margin, $margin); $retval = "\n" . '' . "\n" . '
  • ' . join($rule_related_str, $_links) . '
  • ' . "\n" . '' . "\n"; } else if ($tag) { $retval = join($rule_related_str, $_links); } else { $retval = join($related_str, $_links); } return $retval; } // User-defined rules (convert without replacing source) function make_line_rules($str) { global $line_rules; static $pattern, $replace; if (! isset($pattern)) { $pattern = array_map(create_function('$a', 'return \'/\' . $a . \'/\';'), array_keys($line_rules)); $replace = array_values($line_rules); unset($line_rules); } return preg_replace($pattern, $replace, $str); } function strip_htmltag($str) { global $_symbol_noexists; $noexists_pattern = '#([^<]*)]+>' . preg_quote($_symbol_noexists, '#') . '#'; $str = preg_replace($noexists_pattern, '$1', $str); //$str = preg_replace('/]+>\?<\/a>/', '', $str); return preg_replace('/<[^>]+>/', '', $str); } // Make a backlink. searching-link of the page name, by the page name, for the page name function make_search($page) { global $script; $s_page = htmlspecialchars($page); $r_page = rawurlencode($page); return '' . $s_page . ' '; } // Make heading (remove footnotes and HTML tags) function make_heading(& $str, $strip = TRUE) { global $NotePattern; // Cut fixed-anchors $id = ''; $matches = array(); if (preg_match('/^(\*{0,3})(.*?)\[#([A-Za-z][\w-]+)\](.*?)$/m', $str, $matches)) { $str = $matches[2] . $matches[4]; $id = $matches[3]; } else { $str = preg_replace('/^\*{0,3}/', '', $str); } // Cut footnotes and tags if ($strip === TRUE) $str = strip_htmltag(make_link(preg_replace($NotePattern, '', $str))); return $id; } // Separate a page-name(or URL or null string) and an anchor // (last one standing) without sharp function anchor_explode($page, $strict_editable = FALSE) { $pos = strrpos($page, '#'); if ($pos === FALSE) return array($page, '', FALSE); // Ignore the last sharp letter if ($pos + 1 == strlen($page)) { $pos = strpos(substr($page, $pos + 1), '#'); if ($pos === FALSE) return array($page, '', FALSE); } $s_page = substr($page, 0, $pos); $anchor = substr($page, $pos + 1); if($strict_editable === TRUE && preg_match('/^[a-z][a-f0-9]{7}$/', $anchor)) { return array ($s_page, $anchor, TRUE); // Seems fixed-anchor } else { return array ($s_page, $anchor, FALSE); } } // Check HTTP header()s were sent already, or // there're blank lines or something out of php blocks function pkwk_headers_sent() { if (PKWK_OPTIMISE) return; $file = $line = ''; if (version_compare(PHP_VERSION, '4.3.0', '>=')) { if (headers_sent($file, $line)) die('Headers already sent at ' . htmlspecialchars($file) . ' line ' . $line . '.'); } else { if (headers_sent()) die('Headers already sent.'); } } // Output common HTTP headers function pkwk_common_headers() { if (! PKWK_OPTIMISE) pkwk_headers_sent(); if(defined('PKWK_ZLIB_LOADABLE_MODULE')) { $matches = array(); if(ini_get('zlib.output_compression') && preg_match('/\b(gzip|deflate)\b/i', $_SERVER['HTTP_ACCEPT_ENCODING'], $matches)) { // Bug #29350 output_compression compresses everything _without header_ as loadable module // http://bugs.php.net/bug.php?id=29350 header('Content-Encoding: ' . $matches[1]); header('Vary: Accept-Encoding'); } } } // DTD definitions define('PKWK_DTD_XHTML_1_1', 17); // Strict only define('PKWK_DTD_XHTML_1_0', 16); // Strict define('PKWK_DTD_XHTML_1_0_STRICT', 16); define('PKWK_DTD_XHTML_1_0_TRANSITIONAL', 15); define('PKWK_DTD_XHTML_1_0_FRAMESET', 14); define('PKWK_DTD_HTML_4_01', 3); // Strict define('PKWK_DTD_HTML_4_01_STRICT', 3); define('PKWK_DTD_HTML_4_01_TRANSITIONAL', 2); define('PKWK_DTD_HTML_4_01_FRAMESET', 1); // Output HTML DTD, start tag. Return content-type. function pkwk_output_dtd($pkwk_dtd = PKWK_DTD_XHTML_1_1) { static $called; if (isset($called)) die('pkwk_output_dtd() already called. Why?'); $called = TRUE; $type = 'XHTML'; $option = ''; switch($pkwk_dtd){ case PKWK_DTD_XHTML_1_1 : $version = '1.1' ; $dtd = 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'; break; case PKWK_DTD_XHTML_1_0_STRICT : $version = '1.0' ; $option = 'Strict'; $dtd = 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'; break; case PKWK_DTD_XHTML_1_0_TRANSITIONAL: $version = '1.0' ; $option = 'Transitional'; $dtd = 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'; break; case PKWK_DTD_HTML_4_01_STRICT : $type = 'HTML'; $version = '4.01'; $dtd = 'http://www.w3.org/TR/html4/strict.dtd'; break; case PKWK_DTD_HTML_4_01_TRANSITIONAL: $type = 'HTML'; $version = '4.01'; $option = 'Transitional'; $dtd = 'http://www.w3.org/TR/html4/loose.dtd'; break; default: die('DTD not specified or invalid DTD'); break; } // Output XML or not if ($type == 'XHTML') echo '' . "\n"; // Output doctype echo '' . "\n"; // Output start tag echo '' . "\n"; // // Return content-type (with MIME type) if ($type == 'XHTML') { // NOTE: XHTML 1.1 browser will ignore http-equiv return '' . "\n"; } else { return '' . "\n"; } } ?>