内に追加するタグ
$head_tag = ! empty($head_tags) ? join("\n", $head_tags) ."\n" : '';
// 1.3.x compat
// ページの最終更新時刻(UNIX timestamp)
$fmt = $is_read ? get_filetime($_page) + LOCALZONE : 0;
//単語検索
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);
}
// インライン要素のパース (obsolete)
function inline($line, $remove = FALSE)
{
global $NotePattern;
$line = htmlspecialchars($line);
if ($remove)
$line = preg_replace($NotePattern, '', $line);
return $line;
}
// インライン要素のパース (リンク、見出し一覧) (obsolete)
function inline2($str)
{
return make_link($str);
}
// 編集フォームの表示
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,
$_btn_freeze, $_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 = get_existpages();
$pages = array();
foreach($_pages as $_page) {
if ($_page == $whatsnew || preg_match("/$non_list/", $_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
$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;
}
// 関連するページ
function make_related($page, $tag = '')
{
global $script, $vars, $related, $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();
foreach ($links as $page=>$lastmod) {
if (preg_match("/$non_list/", $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 '';
if ($tag == 'p') { // 行頭から
$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;
}
// ユーザ定義ルール(ソースは置換せずコンバート)
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);
}
// HTMLタグを取り除く
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);
}
// ページ名からページ名を検索するリンクを作成
function make_search($page)
{
global $script, $WikiName;
$s_page = htmlspecialchars($page);
$r_page = rawurlencode($page);
//WikiWikiWeb like...
//if(preg_match("/^$WikiName$/", $page))
// $name = preg_replace("/([A-Z][a-z]+)/", "$1 ", $name);
return "$s_page ";
}
// 見出しを生成 (脚注やHTMLタグを除去)
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 header()s were sent already, or
// there're blank lines or something out of php blocks
function pkwk_headers_sent()
{
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.');
}
}
function pkwk_common_headers()
{
if (! PKWK_OPTIMISE) pkwk_headers_sent();
$matches = array();
if(ini_get('zlib.output_compression') &&
preg_match('/\b(gzip|deflate)\b/i', $_SERVER['HTTP_ACCEPT_ENCODING'], $matches)) {
header('Content-Encoding: ' . $matches[1]);
header('Vary: Accept-Encoding');
}
}
?>