function plugin_tooltip_inline() { $args = func_get_args(); $glossary = array_pop($args); $term = array_shift($args); // $glossary_page = count($args) ? array_shift($args) : ''; $glossary_page = ''; if ($glossary == '') { $glossary = plugin_tooltip_get_glossary($term, $glossary_page, FALSE); // $debug .= "B=$glossary/"; if ($glossary === FALSE) { $glossary = plugin_tooltip_get_page_title($term); if ($glossary === FALSE) { $glossary = ''; } } } $s_glossary = htmlspecialchars($glossary); $page = strip_bracket($term); if (is_page($page)) { $url = get_page_uri($page); $passage = get_pg_passage($page, FALSE); return <<<EOD <a href="{$url}" class="linktip" title="{$s_glossary}{$passage}">{$term}</a> EOD; } else { return <<<EOD <span class="tooltip" title="{$s_glossary}" onmouseover="javascript:this.style.backgroundColor='#ffe4e1';" onmouseout="javascript:this.style.backgroundColor='transparent';">{$term}</span> EOD; } }
function plugin_pg_passage_inline() { $argv = func_get_args(); $argc = func_num_args(); $field = array('page', 'paren'); for ($i = 0; $i < $argc; $i++) { ${$field}[$i] = htmlspecialchars($argv[$i], ENT_QUOTES); } if (empty($page)) { return ''; } $paren = empty($paren) ? FALSE : TRUE; return get_pg_passage($page, $paren); }
function plugin_list_array($pages) { $qm = get_qm(); $symbol = ' '; $other = 'zz'; $list = array(); $cnd = 0; //並び替える foreach ($pages as $file => $page) { $pgdata = array(); $pgdata['urlencoded'] = rawurlencode($page); $pgdata['sanitized'] = htmlspecialchars($page, ENT_QUOTES); $pgdata['passage'] = get_pg_passage($page, FALSE); $pgdata['mtime'] = date('Y年m月d日 H時i分s秒', filemtime(get_filename($page))); $pgdata['title'] = get_page_title($page); $pgdata['title'] = $pgdata['title'] == $pgdata['sanitized'] ? '' : '(' . $pgdata['title'] . ')'; $pgdata['filename'] = htmlspecialchars($file); $head = preg_match('/^([A-Za-z])/', $page, $matches) ? $matches[1] : (preg_match('/^([ -~])/', $page, $matches) ? $symbol : $other); $list[$head][$page] = $pgdata; $cnt++; } ksort($list); $tmparr = isset($list[$symbol]) ? $list[$symbol] : null; unset($list[$symbol]); $list[$symbol] = $tmparr; $retlist = array(); foreach ($list as $head => $pages) { if (is_null($pages)) { continue; } ksort($pages); if ($head === $symbol) { $head = $qm->m['func']['list_symbol']; } else { if ($head === $other) { $head = $qm->m['func']['list_other']; } } $retlist[$head] = $pages; } return $retlist; }
function plugin_popular_convert() { global $vars, $whatsnew; global $_popular_plugin_frame, $_popular_plugin_today_frame; $max = PLUGIN_POPULAR_DEFAULT; $except = ''; $array = func_get_args(); $today = FALSE; switch (func_num_args()) { case 3: if ($array[2]) { $today = get_date('Y/m/d'); } case 2: $except = $array[1]; case 1: $max = $array[0]; } $counters = array(); foreach (get_existpages(COUNTER_DIR, '.count') as $file => $page) { if ($except != '' && ereg($except, $page) || $page == $whatsnew || check_non_list($page) || !is_page($page)) { continue; } $array = file(COUNTER_DIR . $file); $count = rtrim($array[0]); $date = rtrim($array[1]); $today_count = rtrim($array[2]); if ($today) { // $pageが数値に見える(たとえばencode('BBS')=424253)とき、 // array_splice()によってキー値が変更されてしまうのを防ぐ // ため、キーに '_' を連結する if ($today == $date) { $counters['_' . $page] = $today_count; } } else { $counters['_' . $page] = $count; } } asort($counters, SORT_NUMERIC); // BugTrack2/106: Only variables can be passed by reference from PHP 5.0.5 $counters = array_reverse($counters, TRUE); // with array_splice() $counters = array_splice($counters, 0, $max); $items = ''; if (!empty($counters)) { $items = '<ul class="popular_list">' . "\n"; foreach ($counters as $page => $count) { $page = substr($page, 1); $s_page = htmlsc($page); if ($page == $vars['page']) { // No need to link itself, notifies where you just read $pg_passage = get_pg_passage($page, FALSE); $items .= ' <li><span title="' . $s_page . ' ' . $pg_passage . '">' . $s_page . '<span class="counter">(' . $count . ')</span></span></li>' . "\n"; } else { $items .= ' <li>' . make_pagelink($page, $s_page . '<span class="counter">(' . $count . ')</span>') . '</li>' . "\n"; } } $items .= '</ul>' . "\n"; } return sprintf($today ? $_popular_plugin_today_frame : $_popular_plugin_frame, count($counters), $items); }
function catbody($title, $page, $body) { global $script; // MUST BE SKIN.FILE. Do not delete line. global $vars, $arg, $defaultpage, $whatsnew, $help_page, $hr; global $attach_link, $related_link, $function_freeze; global $search_word_color, $foot_explain, $note_hr, $head_tags, $foot_tags; global $trackback, $referer, $javascript; global $newtitle, $newbase, $language, $use_local_time; // Plus! skin extension global $nofollow; global $_LANG, $_LINK, $_IMAGE; global $pkwk_dtd; // XHTML 1.1, XHTML1.0, HTML 4.01 Transitional... global $page_title; // Title of this site global $do_backup; // Do backup or not global $modifier; // Site administrator's web page global $modifierlink; // Site administrator's name global $skin_file, $menubar, $sidebar; global $_string; if (!defined('SKIN_FILE') || !file_exists(SKIN_FILE) || !is_readable(SKIN_FILE)) { if (!file_exists($skin_file) || !is_readable($skin_file)) { die_message(SKIN_FILE . '(skin file) is not found.'); } else { define('SKIN_FILE', $skin_file); } } $_LINK = $_IMAGE = array(); // Add JavaScript header when ... if (!PKWK_ALLOW_JAVASCRIPT) { unset($javascript); } $_page = isset($vars['page']) ? $vars['page'] : ''; $r_page = rawurlencode($_page); // Set $_LINK for skin $_LINK['add'] = get_cmd_uri('add', $_page); $_LINK['backup'] = get_cmd_uri('backup', $_page); $_LINK['brokenlink'] = get_cmd_uri('brokenlink', $_page); $_LINK['copy'] = get_cmd_uri('template', '', '', 'refer=' . $r_page); $_LINK['diff'] = get_cmd_uri('diff', $_page); $_LINK['edit'] = get_cmd_uri('edit', $_page); $_LINK['guiedit'] = get_cmd_uri('guiedit', $_page); $_LINK['filelist'] = get_cmd_uri('filelist'); $_LINK['freeze'] = get_cmd_uri('freeze', $_page); $_LINK['help'] = get_cmd_uri('help'); $_LINK['linklist'] = get_cmd_uri('linklist', $_page); $_LINK['list'] = get_cmd_uri('list'); $_LINK['log_login'] = get_cmd_uri('logview', '', '', 'kind=login'); $_LINK['log_browse'] = get_cmd_uri('logview', $_page, '', 'kind=browse'); $_LINK['log_update'] = get_cmd_uri('logview', $_page); $_LINK['log_down'] = get_cmd_uri('logview', $_page, '', 'kind=download'); $_LINK['log_check'] = get_cmd_uri('logview', $_page, '', 'kind=check'); $_LINK['menu'] = get_page_uri($menubar); $_LINK['new'] = get_cmd_uri('newpage', '', '', 'refer=' . $r_page); $_LINK['newsub'] = get_cmd_uri('newpage_subdir', '', '', 'directory=' . $r_page); $_LINK['print'] = get_cmd_uri('print', $_page); $_LINK['full'] = get_cmd_uri('print', $_page) . '&nohead&nofoot'; $_LINK['read'] = get_page_uri($_page); $_LINK['recent'] = get_page_uri($whatsnew); $_LINK['refer'] = get_cmd_uri('referer', $_page); $_LINK['reload'] = get_page_absuri($_page); // 本当は、get_script_uri でいいけど、絶対パスでないと、スキンに影響が出る $_LINK['reload_rel'] = get_page_uri($_page); $_LINK['rename'] = get_cmd_uri('rename', '', '', 'refer=' . $r_page); $_LINK['skeylist'] = get_cmd_uri('skeylist', $_page); $_LINK['search'] = get_cmd_uri('search'); $_LINK['side'] = get_page_uri($sidebar); $_LINK['source'] = get_cmd_uri('source', $_page); $_LINK['template'] = get_cmd_uri('template', '', '', 'refer=' . $r_page); $_LINK['top'] = get_page_uri($defaultpage); if ($trackback) { $tb_id = tb_get_id($_page); $_LINK['trackback'] = get_cmd_uri('tb', '', '', '__mode=view&tb_id=' . $tb_id); } $_LINK['unfreeze'] = get_cmd_uri('unfreeze', $_page); $_LINK['upload'] = get_cmd_uri('attach', $_page, '', 'pcmd=upload'); // link rel="alternate" にも利用するため absuri にしておく $_LINK['rdf'] = get_cmd_absuri('rss', '', 'ver=1.0'); $_LINK['rss'] = get_cmd_absuri('rss'); $_LINK['rss10'] = get_cmd_absuri('rss', '', 'ver=1.0'); // Same as 'rdf' $_LINK['rss20'] = get_cmd_absuri('rss', '', 'ver=2.0'); $_LINK['mixirss'] = get_cmd_absuri('mixirss'); // Same as 'rdf' for mixi // Compat: Skins for 1.4.4 and before $link_add =& $_LINK['add']; $link_backup =& $_LINK['backup']; $link_brokenlink =& $_LINK['brokenlink']; $link_template =& $_LINK['copy']; $link_diff =& $_LINK['diff']; $link_edit =& $_LINK['edit']; $link_guiedit =& $_LINK['guiedit']; $link_filelist =& $_LINK['filelist']; $link_freeze =& $_LINK['freeze']; $link_help =& $_LINK['help']; $link_linklist =& $_LINK['linklist']; $link_list =& $_LINK['list']; $link_log_login =& $_LINK['log_login']; $link_log_browse =& $_LINK['log_browse']; $link_log_update =& $_LINK['log_update']; $link_log_down =& $_LINK['log_down']; $link_log_check =& $_LINK['log_check']; $link_menu =& $_LINK['menu']; $link_new =& $_LINK['new']; $link_newsub =& $_LINK['newsub']; $link_print =& $_LINK['print']; $link_full =& $_LINK['full']; $link_read =& $_LINK['read']; $link_whatsnew =& $_LINK['recent']; $link_refer =& $_LINK['refer']; $link_reload =& $_LINK['reload']; $link_reload_rel =& $_LINK['reload_rel']; $link_rename =& $_LINK['rename']; $link_skeylist =& $_LINK['skeylist']; $link_search =& $_LINK['search']; $link_side =& $_LINK['side']; $link_source =& $_LINK['source']; $link_top =& $_LINK['top']; if ($trackback) { $link_trackback =& $_LINK['trackback']; } $link_unfreeze =& $_LINK['unfreeze']; $link_upload =& $_LINK['upload']; // $link_rdf =& $_LINK['rdf']; $link_rss =& $_LINK['rss']; $link_rss10 =& $_LINK['rss10']; $link_rss20 =& $_LINK['rss20']; $link_mixirss =& $_LINK['mixirss']; // Init flags $is_page = is_pagename($_page) && !arg_check('backup') && !is_cantedit($_page); $is_read = arg_check('read') && is_page($_page); $is_freeze = is_freeze($_page); // Last modification date (string) of the page $lastmodified = $is_read ? get_date('D, d M Y H:i:s T', get_filetime($_page)) . ' ' . get_pg_passage($_page, FALSE) : ''; // List of attached files to the page $attaches = ''; if ($attach_link && $is_read && exist_plugin_action('attach')) { if (do_plugin_init('attach') !== FALSE) { $attaches = attach_filelist(); } } // List of related pages $related = $related_link && $is_read ? make_related($_page) : ''; // List of footnotes ksort($foot_explain, SORT_NUMERIC); $notes = !empty($foot_explain) ? $note_hr . join("\n", $foot_explain) : ''; // Tags will be inserted into <head></head> $head_tag = !empty($head_tags) ? join("\n", $head_tags) . "\n" : ''; $foot_tag = !empty($foot_tags) ? join("\n", $foot_tags) . "\n" : ''; // 1.3.x compat // Last modification date (UNIX timestamp) of the page $fmt = $is_read ? get_filetime($_page) : 0; // Search words if ($search_word_color && isset($vars['word'])) { $body = '<div class="small">' . $_string['word'] . htmlspecialchars($vars['word']) . '</div>' . $hr . "\n" . $body; // BugTrack2/106: Only variables can be passed by reference from PHP 5.0.5 $words = preg_split('/\\s+/', $vars['word'], -1, PREG_SPLIT_NO_EMPTY); $words = array_splice($words, 0, 10); // Max: 10 words $words = array_flip($words); $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 = '/' . '<textarea[^>]*>.*?<\\/textarea>' . '|' . '<[^>]*>' . '|' . '&[^;]+;' . '|' . '(' . $pattern . ')' . '/sS'; $decorate_Nth_word = create_function('$matches', 'return (isset($matches[1])) ? ' . '\'<strong class="word' . $id . '">\' . $matches[1] . \'</strong>\' : ' . '$matches[0];'); $body = preg_replace_callback($pattern, $decorate_Nth_word, $body); $notes = preg_replace_callback($pattern, $decorate_Nth_word, $notes); ++$id; } } // Compat: 'HTML convert time' without time about MenuBar and skin $taketime = elapsedtime(); require SKIN_FILE; }
function plugin_print_action() { global $defaultpage, $page_title, $newtitle; global $use_local_time, $language; global $head_tags, $foot_tags, $pkwk_dtd; global $vars; global $fixed_heading_edited, $autoglossary, $_symbol_paraedit, $_symbol_paraguiedit; global $_symbol_noexists; global $foot_explain, $note_hr; if (empty($vars['page']) || !is_page($vars['page'])) { return ''; } $page = $vars['page']; check_readable($page, false); $head = isset($vars['nohead']) ? 0 : 1; $foot = isset($vars['nofoot']) ? 0 : 1; $noa = isset($vars['noa']) ? 1 : 0; $fixed_heading_edited = $autoglossary = 0; $_symbol_paraedit = $_symbol_paraguiedit = ' '; $body = convert_html(get_source($page)); // Yetlist $noexists_pattern = '#<span class="noexists">([^<]*)<a[^>]+>' . preg_quote($_symbol_noexists, '#') . '</a></span>#'; $body = preg_replace($noexists_pattern, '$1', $body); // List of footnotes ksort($foot_explain, SORT_NUMERIC); $notes = !empty($foot_explain) ? $note_hr . join("\n", $foot_explain) : ''; if ($noa) { $body = strip_a($body); $notes = strip_a($notes); } // Tags will be inserted into <head></head> $head_tag = !empty($head_tags) ? join("\n", $head_tags) . "\n" : ''; $foot_tag = !empty($foot_tags) ? join("\n", $foot_tags) . "\n" : ''; $css_charset = 'utf-8'; switch (UI_LANG) { case 'ja_JP': $css_charset = 'Shift_JIS'; break; } // Output header pkwk_common_headers(); header('Cache-Control: no-cache'); header('Pragma: no-cache'); header('Content-Type: text/html; charset=' . CONTENT_CHARSET); header('ETag: ' . md5(MUTIME)); // Output HTML DTD, <html>, and receive content-type $meta_content_type = isset($pkwk_dtd) ? pkwk_output_dtd($pkwk_dtd) : pkwk_output_dtd(); $CONTENT_CHARSET = CONTENT_CHARSET; $SKIN_URI = SKIN_URI; $IMAGE_URI = IMAGE_URI; // Plus! not use $meta_content_type. because meta-content-type is most browser not used. umm... echo <<<EOD <head> <meta http-equiv="content-type" content="application/xhtml+xml; charset={$CONTENT_CHARSET}" /> <meta http-equiv="content-style-type" content="text/css" /> <meta http-equiv="content-script-type" content="text/javascript" /> <meta name="robots" content="NOINDEX,NOFOLLOW" /> EOD; // $newtitle - TITLE: (convert_html) if ($newtitle != '') { $h1 = $newtitle . ' - ' . $page_title; } elseif ($page == $defaultpage) { $h1 = $page_title; } else { $h1 = $page . ' - ' . $page_title; } echo ' <title>' . $h1 . '</title>' . "\n"; echo <<<EOD <link rel="stylesheet" href="{$SKIN_URI}default.css" type="text/css" media="screen" charset="{$css_charset}" /> <link rel="stylesheet" href="{$SKIN_URI}print.css" type="text/css" media="print" charset="{$css_charset}" /> <script type="text/javascript"> <!-- EOD; if (exist_plugin_convert('js_init')) { echo do_plugin_convert('js_init'); } echo <<<EOD // --> </script> <script type="text/javascript" src="{$SKIN_URI}lang/{$language}.js"></script> <script type="text/javascript" src="{$SKIN_URI}default.js"></script> EOD; if (!$use_local_time) { echo <<<EOD <script type="text/javascript" src="{$SKIN_URI}tzCalculation_LocalTimeZone.js"></script> EOD; } echo $head_tag; echo <<<EOD </head> <body> EOD; /* if ($head) { echo <<<EOD <div id="header"> <h1 class="title">$h1</h1> </div> EOD; } */ if ($head) { // Last modification date (string) of the page $lastmodified = get_date('D, d M Y H:i:s T', get_filetime($page)) . ' ' . get_pg_passage($page, FALSE); // <span style="font-size: large;line-height: 1;margin: 0px;padding: 0px;">$h1</span> $PRINT_HEAD_BGCOLOR = PRINT_HEAD_BGCOLOR; $PRINT_HEAD_BORDER = PRINT_HEAD_BORDER; echo <<<EOD <div style="background-color: {$PRINT_HEAD_BGCOLOR};border: 1px {$PRINT_HEAD_BORDER} solid;padding: 6px 8px;margin: 6px 1%;"> \t<h1 class="title">{$h1}</h1> \t<p style="font-size:10px;text-align:right;">Last-Modified: {$lastmodified}</p> </div> EOD; } echo <<<EOD <div id="contents"> <table class="contents" width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td class="ctable" valign="top"> <div id="body"> EOD; echo $body; echo <<<EOD </div> </td> </tr> </table> </div> EOD; if ($notes) { echo <<<EOD <div id="note"> {$notes} </div> EOD; } if ($foot) { echo print_foot_area(); } if (exist_plugin_convert('tz')) { echo do_plugin_convert('tz'); } echo $foot_tag; echo <<<EOD </body> </html> EOD; die; }
function page_list($pages, $cmd = 'read', $withfilename=FALSE) { global $script,$list_index,$top; global $_msg_symbol,$_msg_other; global $pagereading_enable; // ソートキーを決定する。 ' ' < '[a-zA-Z]' < 'zz'という前提。 $symbol = ' '; $other = 'zz'; $retval = ''; if($pagereading_enable) { mb_regex_encoding(SOURCE_ENCODING); $readings = get_readings($pages); } $list = array(); foreach($pages as $file=>$page) { $r_page = rawurlencode($page); $s_page = htmlspecialchars($page,ENT_QUOTES); $passage = get_pg_passage($page); $str = " <li><a href=\"$script?cmd=$cmd&page=$r_page\">$s_page</a>$passage"; if ($withfilename) { $s_file = htmlspecialchars($file); $str .= "\n <ul><li>$s_file</li></ul>\n "; } $str .= "</li>"; if($pagereading_enable) { if(mb_ereg('^([A-Za-zァ-ヶ])',$readings[$page],$matches)) { $head = $matches[1]; } elseif (mb_ereg('^[ -~]|[^ぁ-ん亜-熙]',$page)) { $head = $symbol; } else { $head = $other; } } else { $head = (preg_match('/^([A-Za-z])/',$page,$matches)) ? $matches[1] : (preg_match('/^([ -~])/',$page,$matches) ? $symbol : $other); } $list[$head][$page] = $str; } ksort($list); $cnt = 0; $arr_index = array(); $retval .= "<ul>\n"; foreach ($list as $head=>$pages) { if ($head === $symbol) { $head = $_msg_symbol; } else if ($head === $other) { $head = $_msg_other; } if ($list_index) { $cnt++; $arr_index[] = "<a id=\"top_$cnt\" href=\"#head_$cnt\"><strong>$head</strong></a>"; $retval .= " <li><a id=\"head_$cnt\" href=\"#top_$cnt\"><strong>$head</strong></a>\n <ul>\n"; } ksort($pages); $retval .= join("\n",$pages); if ($list_index) { $retval .= "\n </ul>\n </li>\n"; } } $retval .= "</ul>\n"; if ($list_index and $cnt > 0) { $top = array(); while (count($arr_index) > 0) { $top[] = join(" | \n",array_splice($arr_index,0,16))."\n"; } $retval = "<div id=\"top\" style=\"text-align:center\">\n". join("<br />",$top)."</div>\n".$retval; } return $retval; }
function page_list($pages, $cmd = 'read', $withfilename = FALSE) { global $script, $list_index; global $_msg_symbol, $_msg_other; global $pagereading_enable; // ソートキーを決定する。 ' ' < '[a-zA-Z]' < 'zz'という前提。 $symbol = ' '; $other = 'zz'; $retval = ''; if ($pagereading_enable) { mb_regex_encoding(SOURCE_ENCODING); $readings = get_readings($pages); } $list = $matches = array(); // Shrink URI for read if ($cmd == 'read') { $href = $script . '?'; } else { $href = $script . '?cmd=' . $cmd . '&page='; } foreach ($pages as $file => $page) { $r_page = rawurlencode($page); $s_page = htmlspecialchars($page, ENT_QUOTES); $passage = get_pg_passage($page); $str = ' <li><a href="' . $href . $r_page . '">' . $s_page . '</a>' . $passage; if ($withfilename) { $s_file = htmlspecialchars($file); $str .= "\n" . ' <ul><li>' . $s_file . '</li></ul>' . "\n" . ' '; } $str .= '</li>'; // WARNING: Japanese code hard-wired if ($pagereading_enable) { if (mb_ereg('^([A-Za-z])', mb_convert_kana($page, 'a'), $matches)) { $head = $matches[1]; } elseif (isset($readings[$page]) && mb_ereg('^([ァ-ヶ])', $readings[$page], $matches)) { // here $head = $matches[1]; } elseif (mb_ereg('^[ -~]|[^ぁ-ん亜-熙]', $page)) { // and here $head = $symbol; } else { $head = $other; } } else { $head = preg_match('/^([A-Za-z])/', $page, $matches) ? $matches[1] : (preg_match('/^([ -~])/', $page, $matches) ? $symbol : $other); } $list[$head][$page] = $str; } ksort($list); $cnt = 0; $arr_index = array(); $retval .= '<ul>' . "\n"; foreach ($list as $head => $pages) { if ($head === $symbol) { $head = $_msg_symbol; } else { if ($head === $other) { $head = $_msg_other; } } if ($list_index) { ++$cnt; $arr_index[] = '<a id="top_' . $cnt . '" href="#head_' . $cnt . '"><strong>' . $head . '</strong></a>'; $retval .= ' <li><a id="head_' . $cnt . '" href="#top_' . $cnt . '"><strong>' . $head . '</strong></a>' . "\n" . ' <ul>' . "\n"; } ksort($pages); $retval .= join("\n", $pages); if ($list_index) { $retval .= "\n </ul>\n </li>\n"; } } $retval .= '</ul>' . "\n"; if ($list_index && $cnt > 0) { $top = array(); while (!empty($arr_index)) { $top[] = join(' | ' . "\n", array_splice($arr_index, 0, 16)) . "\n"; } $retval = '<div id="top" style="text-align:center">' . "\n" . join('<br />', $top) . '</div>' . "\n" . $retval; } return $retval; }
function plugin_ls2_get_headings($page, &$params, $level, $include = FALSE) { global $script; static $_ls2_anchor = 0; // ページが未表示のとき $is_done = isset($params["page_{$page}"]) && $params["page_{$page}"] > 0; if (!$is_done) { $params["page_{$page}"] = ++$_ls2_anchor; } $r_page = rawurlencode($page); $s_page = htmlsc($page); $title = $s_page . ' ' . get_pg_passage($page, FALSE); $href = $script . '?cmd=read&page=' . $r_page; plugin_ls2_list_push($params, $level); $ret = $include ? '<li>include ' : '<li>'; if ($params['title'] && $is_done) { $ret .= '<a href="' . $href . '" title="' . $title . '">' . $s_page . '</a> '; $ret .= '<a href="#list_' . $params["page_{$page}"] . '"><sup>↑</sup></a>'; array_push($params['result'], $ret); return; } $ret .= '<a id="list_' . $params["page_{$page}"] . '" href="' . $href . '" title="' . $title . '">' . $s_page . '</a>'; array_push($params['result'], $ret); $anchor = PLUGIN_LS2_ANCHOR_ORIGIN; $matches = array(); foreach (get_source($page) as $line) { if ($params['title'] && preg_match('/^(\\*{1,3})/', $line, $matches)) { $id = make_heading($line); $level = strlen($matches[1]); $id = PLUGIN_LS2_ANCHOR_PREFIX . $anchor++; plugin_ls2_list_push($params, $level + strlen($level)); array_push($params['result'], '<li><a href="' . $href . $id . '">' . $line . '</a>'); } else { if ($params['include'] && preg_match('/^#include\\((.+)\\)/', $line, $matches) && is_page($matches[1])) { plugin_ls2_get_headings($matches[1], $params, $level + 1, TRUE); } } } }
function catbody($title, $page, $body) { global $script, $script_ssl, $vars, $arg, $defaultpage, $whatsnew, $help_page, $hr; global $attach_link, $related_link, $cantedit, $function_freeze; global $search_word_color, $_msg_word, $foot_explain, $note_hr, $head_tags; global $trackback, $trackback_javascript, $referer, $javascript; global $nofollow, $non_list; global $_LANG, $_LINK, $_IMAGE; global $pkwk_dtd; // XHTML 1.1, XHTML1.0, HTML 4.01 Transitional... global $page_title; // Title of this site global $do_backup; // Do backup or not global $modifier; // Site administrator's web page global $modifierlink; // Site administrator's name global $owneraddr; // Site owner address global $ownertel; // Site owner tel global $headcopy; // Site headcopy global $menuadmin; // Menu Administrate Page global $style_type, $style_name, $logo_image, $logo_header; global $keywords, $description, $accesstag, $ga_tracking_id, $killer_fg, $killer_bg, $noindex, $accesstag_moved; //for skin by hokuken global $qhm_adminmenu; // Site administration menu 20 JUN 2007 global $custom_meta; // Insert meta tag for specific meta tag global $adcode; // AD code (exp. Google Adwords, Analytics ... ) 25 JLY 2007 by hokuken.com global $nowindow; // Disable including external_link.js global $killer_page2; // for Killer page Design 2 global $no_qhm_licence; // qhm licence global $include_skin_file_path; //orignal skin setting global $qhm_access_key; global $reg_exp_host; global $unload_confirm, $check_login; global $enable_wp_theme, $enable_wp_theme_name, $wp_add_css; //WordPress用のテーマ global $mobile_redirect, $googlemaps_apikey; global $other_plugins, $other_plugin_categories; global $default_script, $init_scripts; global $enable_smart_style, $smart_name; // smart phone global $is_update; global $enable_fitvids; // body部分以外は、元々の$script を使う(通常のリンク設定)を使う // 結果、$body内は、script_sslを使ったリンクになるが、ナビ、メニューなどは、元の$scriptを必ず使う $script = $init_scripts['normal']; $script_ssl = $init_scripts['ssl']; if (!file_exists(SKIN_FILE) || !is_readable(SKIN_FILE)) { die_message('SKIN_FILE is not found'); } $_LINK = $_IMAGE = array(); // Add JavaScript header when ... if ($trackback && $trackback_javascript) { $javascript = 1; } // Set something If you want if (!PKWK_ALLOW_JAVASCRIPT) { unset($javascript); } $_page = isset($vars['page']) ? $vars['page'] : ''; $r_page = rawurlencode($_page); //QHM Template $qt = get_qt(); if (!$qt->set_page) { $qt->set_page($_page); } //QHM Messages $qm = get_qm(); // Set $_LINK for skin $_LINK['add'] = "{$script}?cmd=add&page={$r_page}"; $_LINK['backup'] = "{$script}?cmd=backup&page={$r_page}"; $_LINK['copy'] = "{$script}?plugin=template&refer={$r_page}"; $_LINK['diff'] = "{$script}?cmd=diff&page={$r_page}"; $_LINK['edit'] = "{$script}?cmd=edit&page={$r_page}"; $_LINK['filelist'] = "{$script}?cmd=filelist"; $_LINK['freeze'] = "{$script}?cmd=freeze&page={$r_page}"; $_LINK['help'] = "{$script}?" . rawurlencode($help_page); $_LINK['list'] = "{$script}?cmd=list"; $_LINK['new'] = "{$script}?plugin=newpage&refer={$r_page}"; $_LINK['rdf'] = "{$script}?cmd=rss&ver=1.0"; $_LINK['recent'] = "{$script}?" . rawurlencode($whatsnew); $_LINK['refer'] = "{$script}?plugin=referer&page={$r_page}"; $_LINK['reload'] = "{$script}?{$r_page}"; $_LINK['rename'] = "{$script}?plugin=rename&refer={$r_page}"; $_LINK['delete'] = "{$script}?plugin=delete&page={$r_page}"; $_LINK['rss'] = "{$script}?cmd=rss"; $_LINK['rss10'] = "{$script}?cmd=rss&ver=1.0"; // Same as 'rdf' $_LINK['rss20'] = "{$script}?cmd=rss&ver=2.0"; $_LINK['search'] = "{$script}?cmd=search"; $_LINK['top'] = dirname($script . 'dummy.php') . '/'; if ($trackback) { $tb_id = tb_get_id($_page); $_LINK['trackback'] = "{$script}?plugin=tb&__mode=view&tb_id={$tb_id}"; } $_LINK['unfreeze'] = "{$script}?cmd=unfreeze&page={$r_page}"; $_LINK['upload'] = "{$script}?plugin=attach&pcmd=upload&page={$r_page}"; $_LINK['menuadmin'] = "{$script}?" . rawurlencode($menuadmin); //Hokuken.com original $_LINK['qhm_adminmenu'] = qhm_get_script_path() . "?cmd=qhmauth"; $_LINK['qhm_logout'] = "{$script}?cmd=qhmlogout"; $_LINK['qhm_setting'] = "{$script}?cmd=qhmsetting"; $_LINK['edit_menu'] = "{$script}?cmd=edit&page=MenuBar"; $_LINK['edit_menu2'] = "{$script}?cmd=edit&page=MenuBar2"; $_LINK['edit_navi'] = "{$script}?cmd=edit&page=SiteNavigator"; $_LINK['edit_navi2'] = "{$script}?cmd=edit&page=SiteNavigator2"; $_LINK['edit_header'] = "{$script}?cmd=edit&page=SiteHeader"; $_LINK['yetlist'] = "{$script}?cmd=yetlist"; // Compat: Skins for 1.4.4 and before $link_add =& $_LINK['add']; $link_new =& $_LINK['new']; // New! $link_edit =& $_LINK['edit']; $link_diff =& $_LINK['diff']; $link_top =& $_LINK['top']; $link_list =& $_LINK['list']; $link_filelist =& $_LINK['filelist']; $link_search =& $_LINK['search']; $link_whatsnew =& $_LINK['recent']; $link_backup =& $_LINK['backup']; $link_help =& $_LINK['help']; $link_trackback =& $_LINK['trackback']; // New! $link_rdf =& $_LINK['rdf']; // New! $link_rss =& $_LINK['rss']; $link_rss10 =& $_LINK['rss10']; // New! $link_rss20 =& $_LINK['rss20']; // New! $link_freeze =& $_LINK['freeze']; $link_unfreeze =& $_LINK['unfreeze']; $link_upload =& $_LINK['upload']; $link_template =& $_LINK['copy']; $link_refer =& $_LINK['refer']; // New! $link_rename =& $_LINK['rename']; $link_delete =& $_LINK['delete']; $link_menuadmin =& $_LINK['menuadmin']; //Hokuken.com original $link_copy =& $_LINK['copy']; $link_qhm_adminmenu =& $_LINK['qhm_adminmenu']; //Hokuken.com original $link_qhm_logout =& $_LINK['qhm_logout']; //Hokuken.com original $link_qhm_setting =& $_LINK['qhm_setting']; //Hokuken.com original $link_edit_menu =& $_LINK['edit_menu']; //Hokuken.com original $link_edit_menu2 =& $_LINK['edit_menu2']; $link_edit_navi =& $_LINK['edit_navi']; //Hokuken.com original $link_edit_navi2 =& $_LINK['edit_navi2']; //Hokuken.com original $link_edit_header =& $_LINK['edit_header']; //Hokuken.com original $link_yetlist =& $_LINK['yetlist']; //Hokuken.com original // Init flags $is_page = is_pagename($_page) && $_page != $whatsnew; $is_read = arg_check('read') && is_page($_page); $is_freeze = is_freeze($_page); // Last modification date (string) of the page $lastmodified = $is_read ? format_date(get_filetime($_page)) . ' ' . get_pg_passage($_page, FALSE) : ''; // List of attached files to the page $attaches = $attach_link && $is_read && exist_plugin_action('attach') ? attach_filelist() : ''; // List of related pages $related = $related_link && $is_read ? make_related($_page) : ''; // List of footnotes ksort($foot_explain, SORT_NUMERIC); $notes = !empty($foot_explain) ? $note_hr . join("\n", $foot_explain) : ''; // Tags will be inserted into <head></head> $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 = '<div class="small">' . $_msg_word . htmlspecialchars($vars['word']) . '</div>' . $hr . "\n" . $body; // BugTrack2/106: Only variables can be passed by reference from PHP 5.0.5 // with array_splice(), array_flip() $words = preg_split('/\\s+/', $vars['word'], -1, PREG_SPLIT_NO_EMPTY); $words = array_splice($words, 0, 10); // Max: 10 words $words = array_flip($words); $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 = '/' . '<textarea[^>]*>.*?<\\/textarea>' . '|' . '<[^>]*>' . '|' . '&[^;]+;' . '|' . '(' . $pattern . ')' . '/sS'; $decorate_Nth_word = create_function('$matches', 'return (isset($matches[1])) ? ' . '\'<strong class="word' . $id . '">\' . $matches[1] . \'</strong>\' : ' . '$matches[0];'); $body = preg_replace_callback($pattern, $decorate_Nth_word, $body); $notes = preg_replace_callback($pattern, $decorate_Nth_word, $notes); ++$id; } } //----------------------------------------------------------------------- // // customized by hokuken for QHM (2009/1/28) // //----------------------------------------------------------------------- //----------------- 携帯の場合の処理 -------------------------------------- if (preg_match('/keitai.skin.php$/', SKIN_FILE)) { require LIB_DIR . 'qhm_init.php'; require LIB_DIR . 'qhm_init_main.php'; require SKIN_FILE; return; } //------------------- IF UA is mobile, end here ----------------------- //---------- KILLERPAGE: でもKILLERPAGE2:に統合 いつか消したい -------------- if ($killer_fg != '') { //load common setting and output header require LIB_DIR . 'qhm_init.php'; $killer_page2['fg'] = $killer_fg; $killer_page2['bg'] = $killer_bg; $killer_page2['width'] = 700; $killer_page2['padding'] = 60; $killer_page2['bg_body'] = '#fff'; $killer_page2['fg_body'] = '#000'; require LIB_DIR . 'qhm_init_killer.php'; $longtaketime = getmicrotime() - MUTIME; $taketime = sprintf('%01.03f', $longtaketime); $qt->setv('taketime', $taketime); } //--------------------------- いつか消したい end here ---------------- /////////////////////////////////////////////////////////////////// // // Main // //common setting require LIB_DIR . 'qhm_init.php'; $qt->enable_cache = $qt->getv('editable') ? false : $qt->enable_cache; $qt->set_encode($shiftjis || $eucjp ? true : false); if ($shiftjis) { $output_encode = 'Shift_JIS'; } else { if ($eucjp) { $output_encode = 'EUC-JP'; } else { $output_encode = CONTENT_CHARSET; } } define('WORDPRESS_CHARSET', $output_encode); //output common header (available change encode) $qt->setv('meta_content_type', qhm_output_dtd($pkwk_dtd, CONTENT_CHARSET, $output_encode)); //------- KILLERPAGE2: セールスレター型デザイン ------------------- if (isset($killer_page2['fg']) != '') { require LIB_DIR . 'qhm_init_killer.php'; //JQuery Include $jquery_script = ''; $jquery_cookie_script = ''; if ($qt->getv('jquery_include')) { $jquery_script = '<script type="text/javascript" src="js/jquery.js"></script>'; $jquery_cookie_script = '<script type="text/javascript" src="js/jquery.cookie.js"></script>'; } $bootstrap_style = $bootstrap_script = ''; if ($qt->getv('bootstrap_script')) { $bootstrap_style = $qt->getv('bootstrap_style'); $bootstrap_script = $qt->getv('bootstrap_script'); } $qt->setv('jquery_script', $bootstrap_style . $jquery_script . $bootstrap_script); $qt->setv('jquery_cookie_script', $jquery_cookie_script); $longtaketime = getmicrotime() - MUTIME; $taketime = sprintf('%01.03f', $longtaketime); $qt->setv('taketime', $taketime); $qt->read('skin/killerpage2/pukiwiki.skin.php'); return; } //------------------------------------------------------------- // ---- include main design skin file ---- if (isset($_SESSION['temp_skin']) && strlen($_SESSION['temp_skin']) > 0) { $style_type = $_SESSION['temp_style_type']; } //pluginでデザインが指定されている場合 if ($include_skin_file_path != '') { $style_name = $include_skin_file_path; } require LIB_DIR . 'qhm_init_main.php'; // meta:GENERATOR $generator_tag = '<meta name="GENERATOR" content="Quick Homepage Maker; version=' . QHM_VERSION . '; haik=' . (is_bootstrap_skin() ? 'true' : 'false') . '" />' . "\n"; $qt->prependv_once('generator_tag', 'beforescript', $generator_tag); //------------------------------------------------- // ogp タグを挿入 //------------------------------------------------- if (exist_plugin('ogp')) { plugin_ogp_set_template($body); } //独自のテンプレートファイルをチェック $skin_file = SKIN_DIR . "{$style_name}/pukiwiki.skin.php"; if ($qt->getv('layout_name')) { $layout_file = $qt->getv('layout_name') . '.skin.php'; $layout_path = SKIN_DIR . "{$style_name}/{$layout_file}"; if (file_exists($layout_path)) { $skin_file = $layout_path; } } else { $layout_prefix = 'content'; if ($_page === $defaultpage) { $layout_prefix = 'default'; } else { if (is_qblog()) { $layout_prefix = 'article'; } } $layout_name = isset($style_config["{$layout_prefix}_layout"]) ? $style_config["{$layout_prefix}_layout"] : ""; $layout_path = SKIN_DIR . "{$style_name}/{$layout_name}.skin.php"; if (file_exists($layout_path)) { $skin_file = $layout_path; } } if (!file_exists($skin_file)) { $skin_file = SKIN_FILE; //デフォルトの位置 } // Read design config for customize $style_config = read_skin_config($style_name); $skin_custom_vars = get_skin_custom_vars($style_name); $custom_css = make_custom_css($style_name); $qt->prependv('beforescript', $custom_css); if (isset($style_config['bootstrap']) && $style_config['bootstrap'] !== false) { $qt->setv('jquery_include', true); } // Default Eyecatch if (isset($skin_custom_vars['default_eyecatch']) && $skin_custom_vars['default_eyecatch'] && $qt->getv('main_visual') === '' && exist_plugin('eyecatch')) { $bg_image = $color = ''; if (isset($skin_custom_vars['eyecatch_bgimage'])) { $bg_image = $skin_custom_vars['eyecatch_bgimage']; $bg_image = is_url($bg_image, TRUE, TRUE) || file_exists(get_file_path($bg_image)) ? $bg_image : ''; } if (isset($skin_custom_vars['enable_eyecatch_bgimage']) && !$skin_custom_vars['enable_eyecatch_bgimage']) { $bg_image = ''; } if (isset($skin_custom_vars['eyecatch_color'])) { $color = 'color=' . $skin_custom_vars['eyecatch_color']; } if (is_qblog()) { $title_copy = $qblog_title; } else { if (isset($skin_custom_vars['eyecatch_title_type']) && trim($skin_custom_vars['eyecatch_title_type']) == 'site') { $title_copy = $page_title; } else { if ($_page === $defaultpage) { $title_copy = $page_title; } else { $title_copy = get_page_title($_page); } } } $content = <<<EOD ! {$title_copy} EOD; plugin_eyecatch_convert($bg_image, $color, '__default', $content); } if ($qt->getv('no_eyecatch')) { $qt->setv('main_visual', "<!-- no eyecatch -->"); } // Determine emptiness of eyecatch $qt->setv('eyecatch_is_empty', $qt->getv('no_eyecatch') || $qt->getv('main_visual') === ''); if (isset($skin_custom_vars['palette_color']) && trim($skin_custom_vars['palette_color'])) { $qt->setv('palette_color', trim($skin_custom_vars['palette_color'])); $qt->setv('palette_color_class', 'haik-palette-' . trim($skin_custom_vars['palette_color'])); } //JQuery Include $jquery_script = ''; $jquery_cookie_script = ''; if ($qt->getv('jquery_include')) { $jquery_script = '<script type="text/javascript" src="js/jquery.js"></script>'; $jquery_cookie_script = '<script type="text/javascript" src="js/jquery.cookie.js"></script>'; } if ($qt->getv('bootstrap_script')) { $bootstrap_script = $qt->getv('bootstrap_script'); } $qt->setv('jquery_script', $jquery_script . $bootstrap_script); $qt->setv('jquery_cookie_script', $jquery_cookie_script); $longtaketime = getmicrotime() - MUTIME; $taketime = sprintf('%01.03f', $longtaketime); $qt->setv('taketime', $taketime); //UniversalAnalytics Tracking Code if ($code = $qt->getv('ga_universal_analytics')) { $qt->appendv('beforescript', $code); } //------------------------------------------------------------------ // WordPressデザイン if ($enable_wp_theme && ($vars['cmd'] != 'qhmsetting' && $vars['plugin'] != 'qhmsetting')) { define('TEMPLATEPATH', 'skin/wordpress/' . $enable_wp_theme_name); include LIB_DIR . 'wp_adapter.php'; wp_load_functions(); $skin_file = get_wp_skin_file(); } //------------------------------------------------------------------- //------------------------------------------------------------------- // プレビュー用のskinファイルを表示 $tmpfilename = ''; if (isset($_SESSION['temp_skin']) && strlen($_SESSION['temp_skin']) > 0) { $tmpfilename = $skin_file = tempnam(realpath(CACHEQHM_DIR), 'qhmdesign'); file_put_contents($skin_file, $_SESSION['temp_skin']); $qt->setv('default_css', $bootstrap_css . $_SESSION['temp_css']); $qt->setv('style_path', $_SESSION['temp_style_path']); } //------------------------------------------------------------------- //skinファイルを読み込んで、表示 $qt->read($skin_file, $_page); // 一時ファイルの削除 if (file_exists($tmpfilename) && strpos(basename($tmpfilename), 'qhmdesign') === 0) { unlink($tmpfilename); } }
function plugin_mixirecent_convert() { global $vars, $date_format; // $_mixirecent_plugin_frame; static $done; $_mixirecent_plugin_frame_s = _('recent(%d)'); $_mixirecent_plugin_frame = sprintf('<h5>%s</h5><div>%%s</div>', $_mixirecent_plugin_frame_s); $mixirecent_lines = PLUGIN_MIXIRECENT_DEFAULT_LINES; if (func_num_args()) { $args = func_get_args(); if (!is_numeric($args[0]) || isset($args[1])) { return PLUGIN_MIXIRECENT_USAGE . '<br />'; } else { $mixirecent_lines = $args[0]; } } // Show only the first one if (isset($done)) { return '<!-- #mixirecent(): You already view changes -->'; } // Get latest N changes if (file_exists(PLUGIN_MIXIRECENT_CACHE)) { $source = file(PLUGIN_MIXIRECENT_CACHE); $lines = array_splice($source, 0, $mixirecent_lines); } else { return '#mixirecent(): Cache file of RecentChanges not found' . '<br />'; } $date = $items = ''; foreach ($lines as $line) { list($time, $page) = explode("\t", rtrim($line)); $_date = get_date($date_format, $time); if ($date != $_date) { // End of the day if ($date != '') { $items .= '</ul>' . "\n"; } // New day $date = $_date; $items .= '<strong>' . $date . '</strong>' . "\n" . '<ul class="mixirecent_list">' . "\n"; } $s_page = htmlspecialchars($page); $pg_passage = get_pg_passage($page, FALSE); if (plugin_mixirecent_isValidDate(substr($page, -10)) && check_readable($page, false, false)) { // for Calendar/MiniCalendar $savepage = $vars['page']; $title = $page; $source = get_source($page); $itemhx = ''; $itemlx = ''; while (!empty($source)) { $line = array_shift($source); if (preg_match('/^(\\*{1,3})(.*)\\[#([A-Za-z][\\w-]+)\\](.*)$/m', $line, $matches)) { $anchortitle = strip_htmltag(convert_html($matches[2])); $anchortitle = preg_replace("/[\r\n]/", ' ', $anchortitle); $anchortitle = PLUGIN_MIXIRECENT_NOTITLE ? $anchortitle : $anchortitle . '(' . $title . ')'; $sharp = '#'; $itemhx .= "<li><a href=\"" . get_page_uri($page) . "{$sharp}{$matches[3]}\" title=\"{$s_page} {$pg_passage}\">{$anchortitle}</a></li>\n"; } } if ($itemhx != '') { $items .= $itemhx; } else { if ($page == $vars['page']) { // No need to link to the page now you read, notifies where you just read $items .= ' <li>' . $s_page . '</li>' . "\n"; } else { $items .= ' <li><a href="' . get_page_uri($page) . '" title="' . $s_page . ' ' . $pg_passage . '">' . $s_page . '</a></li>' . "\n"; } } $vars['page'] = $savepage; } else { if ($page == $vars['page']) { // No need to link to the page now you read, notifies where you just read $items .= ' <li>' . $s_page . '</li>' . "\n"; } else { $items .= ' <li><a href="' . get_page_uri($page) . '" title="' . $s_page . ' ' . $pg_passage . '">' . $s_page . '</a></li>' . "\n"; } } } // End of the day if ($date != '') { $items .= '</ul>' . "\n"; } $done = TRUE; return sprintf($_mixirecent_plugin_frame, count($lines), $items); }
function catbody($title,$page,$body) { global $script,$vars,$arg,$defaultpage,$whatsnew,$help_page,$hr; global $related_link,$cantedit,$function_freeze,$search_word_color,$_msg_word; global $foot_explain,$note_hr,$head_tags; global $html_transitional; // FALSE:XHTML1.1 TRUE:XHTML1.0 Transitional global $page_title; // ホームページのタイトル global $do_backup; // バックアップを行うかどうか global $modifier; // 編集者のホームページ global $modifierlink; // 編集者の名前 $_page = $vars['page']; $r_page = rawurlencode($_page); $link_add = "$script?cmd=add&page=$r_page"; $link_edit = "$script?cmd=edit&page=$r_page"; $link_diff = "$script?cmd=diff&page=$r_page"; $link_top = "$script?".rawurlencode($defaultpage); $link_list = "$script?cmd=list"; $link_filelist = "$script?cmd=filelist"; $link_search = "$script?cmd=search"; $link_whatsnew = "$script?".rawurlencode($whatsnew); $link_backup = "$script?cmd=backup&page=$r_page"; $link_help = "$script?".rawurlencode($help_page); $link_rss = "$script?cmd=rss10"; $link_freeze = "$script?cmd=freeze&page=$r_page"; $link_unfreeze = "$script?cmd=unfreeze&page=$r_page"; $link_upload = "$script?plugin=attach&pcmd=upload&page=$r_page"; $link_template = "$script?plugin=template&refer=$r_page"; $link_rename = "$script?plugin=rename&refer=$r_page"; // ページの表示時TRUE(バックアップの表示、RecentChangesの表示を除く) $is_page = (is_pagename($_page) and !arg_check('backup') and $_page != $whatsnew); // ページの読み出し時TRUE $is_read = (arg_check('read') and is_page($_page)); // ページが凍結されているときTRUE $is_freeze = is_freeze($_page); // ページの最終更新時刻(文字列) $lastmodified = $is_read ? get_date('D, d M Y H:i:s T',get_filetime($_page)).' '.get_pg_passage($_page,FALSE) : ''; // 関連するページのリスト $related = ($is_read and $related_link) ? make_related($_page) : ''; // 添付ファイルのリスト $attaches = ($is_read and exist_plugin_action('attach')) ? attach_filelist() : ''; // 注釈のリスト ksort($foot_explain,SORT_NUMERIC); $notes = count($foot_explain) ? $note_hr.join("\n",$foot_explain) : ''; // <head>内に追加するタグ $head_tag = count($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 and array_key_exists('word',$vars)) { $body = '<div class="small">'.$_msg_word.htmlspecialchars($vars['word'])."</div>$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 $arr[1] ? $arr[1] : "<strong class=\"word'.$id++.'\">{$arr[2]}</strong>";' ); $body = preg_replace_callback($pattern,$callback,$body); $notes = preg_replace_callback($pattern,$callback,$notes); } } $longtaketime = getmicrotime() - MUTIME; $taketime = sprintf('%01.03f',$longtaketime); if (!file_exists(SKIN_FILE)||!is_readable(SKIN_FILE)) { die_message(SKIN_FILE.'(skin file) is not found.'); } require(SKIN_FILE); }
function weblog_viewer_show_headings($page, &$params, $prefix = "", $child_count = "") { global $script, $auto_template_name; global $_weblog_list_anchor, $_weblog_msgs; static $_auto_template_name = ""; if (!$_auto_template_name) { $_auto_template_name = preg_quote($auto_template_name, '/'); } // テンプレートページは表示しない場合 if (preg_match("/\\/" . $_auto_template_name . "(_m)?\$/", $page)) { return; } $ret = ''; $rules = '/\\(\\(((?:(?!\\)\\)).)*)\\)\\)/'; $is_done = (isset($params[$page]) and $params[$page] > 0); //ページが表示済みのときTrue if (!$is_done) { $params[$page] = ++$_weblog_list_anchor; } $name = strip_bracket($page); $title = $name . ' ' . get_pg_passage($page, FALSE); if ($params['weblog']) { if (!ereg("(.*/)?([0-9]{4})-([0-9]{2})-([0-9]{2})-([0-9]{6}).*\$", $name, $m)) { return; } if (!checkdate($m[3], $m[4], $m[2])) { return; } } if ($use_static_url = 1) { $pgid = get_pgid_by_name($page); $href = XOOPS_WIKI_URL . "/{$pgid}.html"; } else { $href = $script . '?' . rawurlencode($name); } //ページ名が「数字と-」だけの場合は、*(**)行を取得してみる $_name = ""; if (preg_match("/^(.*\\/)?[0-9\\-]+\$/", $name)) { $_name = get_heading($page); } //基準ページ名は省く nao-pon if ($name != $prefix) { $name = str_replace($prefix, "", $name); $_is_base = false; } else { $_is_base = true; } //階層でマージン設定 $name = str_replace("/", "\t", $name); //マルチバイトを考慮してTABに変換 $c_count = count_chars($name); if ($_is_base) { $c_margin = 0; //基準ページ } else { $c_margin = $c_count[9] * 15; //TABのコード=9 } //[/(\tに変換済)]以前をカット $name = preg_replace("/.*\t/", "", $name); $ret .= '<li style="margin-left:' . $c_margin . 'px;">'; if ($params['weblog']) { $_page = preg_replace("/(.*\\/)?([0-9\\-]+)\$/", "\\2", $page); $t_year = substr($_page, 0, 4); $t_month = substr($_page, 5, 2); $t_day = substr($_page, 8, 2); $t_hour = substr($_page, 11, 2); $t_min = substr($_page, 13, 2); $t_sec = substr($_page, 15, 2); $timestamp = mktime($t_hour, $t_min, $t_sec, $t_month, $t_day, $t_year); // $info = get_pg_info_db($page); // $timestamp = $info['buildtime']; $make_date[1] = date("Y", $timestamp); $make_date[2] = date("m", $timestamp); $make_date[3] = date("d", $timestamp); $make_date[4] = date("H:i", $timestamp); if ($params['weblog'] === "time") { $page_attr = $make_date[4]; } else { $page_attr = $make_date[2] . "/" . $make_date[3] . " " . $make_date[4]; } $ret .= $page_attr . " - "; } if ($_name) { $name = $_name; } if ($params['relatedcount']) { $name .= " (" . links_get_related_count($page) . ")"; } if ($child_count != "") { $name .= " ({$child_count})"; } //Newマーク付加 if (!$params['nonew'] && exist_plugin_inline("new")) { $new_mark = do_plugin_inline("new", "{$page}/,nolink", ""); } $ret .= '<a id="list_' . $params[$page] . '" href="' . $href . '" title="' . $title . '">' . $name . '</a>' . $new_mark; $anchor = WEBLOG_LIST_ANCHOR_ORIGIN; $_ret = ''; if ($_ret != '') { $ret .= "<ul>{$_ret}</ul>\n"; } $ret .= '</li>' . "\n"; return $ret; }
function plugin_popular_convert() { global $vars, $whatsnew; $qm = get_qm(); $qt = get_qt(); $max = PLUGIN_POPULAR_DEFAULT; $except = ''; $array = func_get_args(); //---- キャッシュのための処理を登録 ----- if ($qt->create_cache) { $args = func_get_args(); return $qt->get_dynamic_plugin_mark(__FUNCTION__, $args); } //------------------------------------ $today = FALSE; switch (func_num_args()) { case 3: if ($array[2]) { $today = get_date('Y/m/d'); } case 2: $except = $array[1]; case 1: $max = $array[0]; } $counters = array(); foreach (get_existpages(COUNTER_DIR, '.count') as $file => $page) { if ($except != '' && ereg($except, $page) || $page == $whatsnew || check_non_list($page) || !is_page($page)) { continue; } $array = array_pad(file(COUNTER_DIR . $file), 3, 0); $count = rtrim($array[0]); $date = rtrim($array[1]); $today_count = rtrim($array[2]); if ($today) { // $pageが数値に見える(たとえばencode('BBS')=424253)とき、 // array_splice()によってキー値が変更されてしまうのを防ぐ // ため、キーに '_' を連結する if ($today == $date) { $counters['_' . $page] = $today_count; } } else { $counters['_' . $page] = $count; } } asort($counters, SORT_NUMERIC); // BugTrack2/106: Only variables can be passed by reference from PHP 5.0.5 $counters = array_reverse($counters, TRUE); // with array_splice() $counters = array_splice($counters, 0, $max); $items = ''; if (!empty($counters)) { $items = '<ul class="popular_list">' . "\n"; foreach ($counters as $page => $count) { $page = substr($page, 1); $s_page = htmlspecialchars($page); //customized by hokuken.com $s_page = get_page_title($page); if ($page == $vars['page']) { // No need to link itself, notifies where you just read $pg_passage = get_pg_passage($page, FALSE); $items .= ' <li><span title="' . $s_page . ' ' . $pg_passage . '">' . $s_page . '<span class="counter">(' . $count . ')</span></span></li>' . "\n"; } else { $items .= ' <li>' . make_pagelink($page, $s_page . '<span class="counter">(' . $count . ')</span>') . '</li>' . "\n"; } } $items .= '</ul>' . "\n"; } $html = sprintf($today ? $qm->m['plg_popular']['today_frame'] : $qm->m['plg_popular']['frame'], count($counters), $items); return '<div class="qhm-plugin-popular">' . $html . '</div>'; }
function plugin_ls2_1_get_headings($page, &$params, $level = 1, $include = false, $prefix, $top_level = 1, &$pages) { global $script; static $_ls2_anchor = 0; // すでにこのページの見出しを表示したかどうかのフラグ $is_done = isset($params["page_{$page}"]) && $params["page_{$page}"] > 0; if (!$is_done) { $params["page_{$page}"] = ++$_ls2_anchor; } $s_page = htmlspecialchars($page); $title = $s_page . ' ' . get_pg_passage($page, false); $r_page = rawurlencode($page); $href = $script . '?' . $r_page; // relative オプション。リンク名制御。 if ($params['relative']) { // パターンの最後の / 以下を取り除く。例) sample/test/d -> sample/test // $prefix_dir = preg_replace('/[^\/]+$/','',$prefix); if (($pos = strrpos($prefix, '/')) !== false) { $prefix_dir = substr($prefix, 0, $pos + 1); } // ページ名からそのパターンをとり除く。 // $s_page = ereg_replace("^$prefix_dir",'',$s_page); $s_page = substr($s_page, strlen($prefix_dir)); // relative オプションと hierarchy オプションが同時に指定された場合は // パターンを取り除くだけでなく、上位の存在しているページ名も取り除く。 if ($params['display'] == 'hierarchy') { $tmp = $s_page; // depth オプションが指定されていた場合 $top_level が変わります。 while (substr_count($tmp, "/") > $top_level - 1) { // 一階層ずつとりのぞく if (($pos = strrpos($tmp, '/')) !== false) { $tmp = substr($tmp, 0, $pos); } // 上位のページが存在していれば、その文字列を取り除き、相対名にする。 if (in_array($prefix_dir . $tmp, $pages)) { // $s_page = ereg_replace("^$tmp/",'',$s_page); $s_page = substr($s_page, strlen("{$tmp}/")); break; } } } } // date オプション。更新日時の追加。 $date = ''; if ($params['date']) { $date = format_date(get_filetime($page)); } // new オプション。New! 表示の追加。 $new = ''; if ($params['new']) { global $_plugin_new_elapses; $timestamp = get_filetime($page) - LOCALZONE; $erapse = UTIME - $timestamp; foreach ($_plugin_new_elapses as $limit => $tag) { if ($erapse <= $limit) { $new .= sprintf($tag, get_passage($timestamp)); break; } } } plugin_ls2_1_list_push($params, $level); // LI TAG. display オプションに依る。plugin_ls2_1_list_push にも。 if ($params['display'] == 'inline') { $litag = ''; } else { $litag = '<li>'; } array_push($params['result'], $litag); // include されたページの場合 if ($include) { $ret = 'include '; } else { $ret = ''; } // すでに表示済みなら必ずファイル内探索処理はせずに抜ける if ($is_done) { $ret .= '<a href="' . $href . '" title="' . $title . '">' . $s_page . '</a> '; $ret .= '<a href="#list_' . $params["page_{$page}"] . '"><sup>↑</sup></a>'; array_push($params['result'], $ret); return; } $ret .= '<a id="list_' . $params["page_{$page}"] . '" href="' . $href . '" title="' . $title . '">' . $s_page . '</a>'; if ($date != '') { $ret .= " {$date}"; } if ($new != '') { $ret .= " {$new}"; } array_push($params['result'], $ret); // title オプション、include オプション時はファイル内探索もする if ($params['title'] || $params['include']) { $anchor = PLUGIN_LS2_1_ANCHOR_ORIGIN; $matches = array(); // 全体で title_number 個ではなく各ファイル単位で title_number 個 $title_counter = 0; foreach (get_source($page) as $line) { if ($params['title'] && preg_match('/^(\\*{1,3})/', $line, $matches)) { if ($params['title_number']) { // ただの件数制限なので途中で抜けても $anchor には不整合はでないはず if ($title_counter >= $params['title_number']) { if (!$params['include']) { break; } else { continue; } } $title_counter++; } // $line は 'remove footnotes and HTML tags' される。見出し行のアンカーが返されるが正直いらない。 $id = make_heading($line); $hlevel = strlen($matches[1]); $id = PLUGIN_LS2_1_ANCHOR_PREFIX . $anchor++; plugin_ls2_1_list_push($params, $level + $hlevel); array_push($params['result'], $litag); array_push($params['result'], '<a href="' . $href . $id . '">' . $line . '</a>'); } else { if ($params['include'] && preg_match('/^#include\\((.+)\\)/', $line, $matches) && is_page($matches[1])) { plugin_ls2_1_get_headings($matches[1], $params, $level + $hlevel + 1, true, $prefix, $top_level, $pages); } } } } }
function catbody($title, $page, $body) { global $script, $vars, $arg, $defaultpage, $whatsnew, $help_page, $hr; global $attach_link, $related_link, $cantedit, $function_freeze; global $search_word_color, $_msg_word, $foot_explain, $note_hr, $head_tags; global $trackback, $trackback_javascript, $referer, $javascript; global $nofollow; global $_LANG, $_LINK, $_IMAGE; global $pkwk_dtd; // XHTML 1.1, XHTML1.0, HTML 4.01 Transitional... global $page_title; // Title of this site global $do_backup; // Do backup or not global $modifier; // Site administrator's web page global $modifierlink; // Site administrator's name if (!file_exists(SKIN_FILE) || !is_readable(SKIN_FILE)) { die_message('SKIN_FILE is not found'); } $_LINK = $_IMAGE = array(); // Add JavaScript header when ... if ($trackback && $trackback_javascript) { $javascript = 1; } // Set something If you want if (!PKWK_ALLOW_JAVASCRIPT) { unset($javascript); } $_page = isset($vars['page']) ? $vars['page'] : ''; $r_page = rawurlencode($_page); // Set $_LINK for skin $_LINK['add'] = "{$script}?cmd=add&page={$r_page}"; $_LINK['backup'] = "{$script}?cmd=backup&page={$r_page}"; $_LINK['copy'] = "{$script}?plugin=template&refer={$r_page}"; $_LINK['diff'] = "{$script}?cmd=diff&page={$r_page}"; $_LINK['edit'] = "{$script}?cmd=edit&page={$r_page}"; $_LINK['filelist'] = "{$script}?cmd=filelist"; $_LINK['freeze'] = "{$script}?cmd=freeze&page={$r_page}"; $_LINK['help'] = "{$script}?" . rawurlencode($help_page); $_LINK['list'] = "{$script}?cmd=list"; $_LINK['new'] = "{$script}?plugin=newpage&refer={$r_page}"; $_LINK['rdf'] = "{$script}?cmd=rss&ver=1.0"; $_LINK['recent'] = "{$script}?" . rawurlencode($whatsnew); $_LINK['refer'] = "{$script}?plugin=referer&page={$r_page}"; $_LINK['reload'] = "{$script}?{$r_page}"; $_LINK['rename'] = "{$script}?plugin=rename&refer={$r_page}"; $_LINK['rss'] = "{$script}?cmd=rss"; $_LINK['rss10'] = "{$script}?cmd=rss&ver=1.0"; // Same as 'rdf' $_LINK['rss20'] = "{$script}?cmd=rss&ver=2.0"; $_LINK['search'] = "{$script}?cmd=search"; $_LINK['top'] = "{$script}?" . rawurlencode($defaultpage); if ($trackback) { $tb_id = tb_get_id($_page); $_LINK['trackback'] = "{$script}?plugin=tb&__mode=view&tb_id={$tb_id}"; } $_LINK['unfreeze'] = "{$script}?cmd=unfreeze&page={$r_page}"; $_LINK['upload'] = "{$script}?plugin=attach&pcmd=upload&page={$r_page}"; // Compat: Skins for 1.4.4 and before $link_add =& $_LINK['add']; $link_new =& $_LINK['new']; // New! $link_edit =& $_LINK['edit']; $link_diff =& $_LINK['diff']; $link_top =& $_LINK['top']; $link_list =& $_LINK['list']; $link_filelist =& $_LINK['filelist']; $link_search =& $_LINK['search']; $link_whatsnew =& $_LINK['recent']; $link_backup =& $_LINK['backup']; $link_help =& $_LINK['help']; $link_trackback =& $_LINK['trackback']; // New! $link_rdf =& $_LINK['rdf']; // New! $link_rss =& $_LINK['rss']; $link_rss10 =& $_LINK['rss10']; // New! $link_rss20 =& $_LINK['rss20']; // New! $link_freeze =& $_LINK['freeze']; $link_unfreeze =& $_LINK['unfreeze']; $link_upload =& $_LINK['upload']; $link_template =& $_LINK['copy']; $link_refer =& $_LINK['refer']; // New! $link_rename =& $_LINK['rename']; // Init flags $is_page = is_pagename($_page) && !arg_check('backup') && $_page != $whatsnew; $is_read = arg_check('read') && is_page($_page); $is_freeze = is_freeze($_page); // Last modification date (string) of the page $lastmodified = $is_read ? format_date(get_filetime($_page)) . ' ' . get_pg_passage($_page, FALSE) : ''; // List of attached files to the page $attaches = $attach_link && $is_read && exist_plugin_action('attach') ? attach_filelist() : ''; // List of related pages $related = $related_link && $is_read ? make_related($_page) : ''; // List of footnotes ksort($foot_explain, SORT_NUMERIC); $notes = !empty($foot_explain) ? $note_hr . join("\n", $foot_explain) : ''; // Tags will be inserted into <head></head> $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 = '<div class="small">' . $_msg_word . htmlsc($vars['word']) . '</div>' . $hr . "\n" . $body; // BugTrack2/106: Only variables can be passed by reference from PHP 5.0.5 // with array_splice(), array_flip() $words = preg_split('/\\s+/', $vars['word'], -1, PREG_SPLIT_NO_EMPTY); $words = array_splice($words, 0, 10); // Max: 10 words $words = array_flip($words); $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 = htmlsc($key); $pattern = '/' . '<textarea[^>]*>.*?<\\/textarea>' . '|' . '<[^>]*>' . '|' . '&[^;]+;' . '|' . '(' . $pattern . ')' . '/sS'; $decorate_Nth_word = create_function('$matches', 'return (isset($matches[1])) ? ' . '\'<strong class="word' . $id . '">\' . $matches[1] . \'</strong>\' : ' . '$matches[0];'); $body = preg_replace_callback($pattern, $decorate_Nth_word, $body); $notes = preg_replace_callback($pattern, $decorate_Nth_word, $notes); ++$id; } } $longtaketime = getmicrotime() - MUTIME; $taketime = sprintf('%01.03f', $longtaketime); require SKIN_FILE; }
function get_popular_links($pages, $linkstrs, $counts, $currentpage = '') { $links = array(); foreach ($pages as $i => $page) { $linkstr = htmlspecialchars($linkstrs[$i]); $count = $counts[$i]; if ($count === 0) { continue; } $linkstr .= '<span class="counter">(' . $count . ')</span>'; if ($page == $currentpage) { // Do not link to itself $title = htmlspecialchars($page) . ' ' . get_pg_passage($page, false); $links[$i] = '<span title="' . $title . '">' . $linkstr . '</span>'; } else { $links[$i] = make_pagelink($page, $linkstr); } } return $links; }
function plugin_contents2_1_get_headings($page, &$params) { static $_contents2_1_anchor = 0; // すでにこのページの見出しを表示したかどうかのフラグ $is_done = isset($params["page_{$page}"]) && $params["page_{$page}"] > 0; if (!$is_done) { $params["page_{$page}"] = ++$_contents2_1_anchor; } // include ページの場合 if ($params['page_anchor_counter'] > 1) { // 表示済み if ($is_done) { $params['page_anchor_counter']--; return; } // 標準 #include プラグインにはアンカーはつかないのでこのアンカーリンクは機能しない。 // 自作プラグイン/include2.inc.php はこれに対応しています。 $id = '#' . plugin_contents2_1_pageanchor($page); // include ページ名のレベルは0 $level = 0; $link_string = htmlspecialchars($page); $title = $link_string . ' ' . get_pg_passage($page, false); plugin_contents2_1_push2result($page, &$params, $level, $page, $id, $title, $link_string); } $anchor_counter = PLUGIN_CONTENTS2_1_ANCHOR_ORIGIN; $matches = array(); foreach (get_source($page) as $line) { // include ページにある #contents2_1 は呼び出しの #contents2_1 とは明らかに違うやつなので // include ページに対しては fromhere 検索すらしない(無論見出しも)。 // ただ $params['page_anchor_counter'] のために #include を辿って #include の数は数えないといけない。 // fixed_anchor=false だとしても fixed_anchor がまだ作られていないページである可能性があるのでやはり数えないといけない。 if ($params['fromhere'] && !$params['fromhere_detected'] && $params['page_anchor_counter'] > 1) { if ($params['include'] && preg_match('/^#include.*\\((.+)\\)/', $line, $matches) && is_page($matches[1])) { $params['page_anchor_counter']++; plugin_contents2_1_get_headings($matches[1], $params); } continue; } // fromhere 判定。まだ見つかっていない場合は何もしない if ($params['fromhere'] && !$params['fromhere_detected'] && ($params['fromhere_detected'] = preg_match('/^#contents2\\_1/', $line, $matches))) { // do nothing } elseif (preg_match('/^(\\*{1,3})/', $line, $matches)) { // アンカー文字列をつくる。$anchor_counter++ が重要。 $id = PLUGIN_CONTENTS2_1_ANCHOR_PREFIX . $params['page_anchor_counter'] . '_' . $anchor_counter++; // fromhere がまだ見つかっていなければ $anchor_counter++ だけして continue。 if ($params['fromhere'] && !$params['fromhere_detected']) { continue; } // 見出しレベルは1以降 $level = strlen($matches[1]); // $line は 'remove footnotes and HTML tags' される。見出し行の固定アンカーが返される。 $fixed_id = make_heading($line); if ($params['fixed_anchor'] && $fixed_id !== '') { $id = '#' . $fixed_id; } // 自動アンカーがつく設定の場合の [#438239] の前に勝手に挿入される空白が make_heading ではまだ残るようなので。 $title = $link_string = trim($line); plugin_contents2_1_push2result($line, &$params, $level, $page, $id, $title, $link_string); // number 判定。制限を越えていれば抜けて終了。 if ($params['number'] != '' && $params['number_counter'] >= $params['number']) { break; } } elseif ($params['include'] && preg_match('/^#include.*\\((.+)\\)/', $line, $matches) && is_page($matches[1])) { $params['page_anchor_counter']++; plugin_contents2_1_get_headings($matches[1], $params); } } }
function make_pagelink($page, $alias = '', $anchor = '', $refer = '', $isautolink = FALSE) { global $vars, $link_compact, $related, $_symbol_noexists; $s_page = htmlspecialchars(strip_bracket($page)); if (!is_page($page)) { $realpages = get_autoaliases(strip_bracket($page)); foreach ($realpages as $realpage) { if (is_page($realpage)) { $page = $realpage; break; } } } $s_alias = $alias == '' ? $s_page : $alias; if ($page == '') { return '<a href="' . $anchor . '">' . $s_alias . '</a>'; } // if ($page == '') return open_uri_in_new_window('<a href="' . $anchor . '">' . $s_alias . '</a>', 'make_pagelink'); $r_refer = $refer == '' ? '' : '&refer=' . rawurlencode($refer); if (!isset($related[$page]) && $page != $vars['page'] && is_page($page)) { $related[$page] = get_filetime($page); } if ($isautolink || is_page($page)) { // Hyperlink to the page if ($link_compact) { $title = ''; } else { $title = ' title="' . $s_page . get_pg_passage($page, FALSE) . '"'; } // AutoLink marker if ($isautolink) { $al_left = '<!--autolink--><span class="autolink">'; $al_right = '</span><!--/autolink-->'; } else { $al_left = $al_right = ''; } return $al_left . '<a ' . 'href="' . get_page_uri($page) . $anchor . '"' . $title . '>' . $s_alias . '</a>' . $al_right; // return open_uri_in_new_window($al_left . // '<a href="' . get_page_uri($page) . $anchor . '"' . $title . '>' . // $s_alias . '</a>' . $al_right, 'make_pagelink'); } else { // Dangling link // if (PKWK_READONLY) return $s_alias; // No dacorations if (auth::check_role('readonly')) { return $s_alias; } // No dacorations $retval = $s_alias . '<a href="' . get_cmd_uri('edit', $page) . $r_refer . '">' . $_symbol_noexists . '</a>'; if ($link_compact) { return $retval; // return open_uri_in_new_window($retval, 'make_pagelink_e'); } else { return '<span class="noexists">' . $retval . '</span>'; } } }
function make_pagelink($page, $alias = '', $anchor = '', $refer = '', $isautolink = FALSE) { global $script, $vars, $link_compact, $related, $_symbol_noexists; $s_page = htmlspecialchars(strip_bracket($page)); $s_alias = $alias == '' ? $s_page : $alias; if ($page == '') { return '<a href="' . $anchor . '">' . $s_alias . '</a>'; } $r_page = rawurlencode($page); $r_refer = $refer == '' ? '' : '&refer=' . rawurlencode($refer); if (!isset($related[$page]) && $page != $vars['page'] && is_page($page)) { $related[$page] = get_filetime($page); } if ($isautolink || is_page($page)) { // Hyperlink to the page if ($link_compact) { $title = ''; } else { $title = ' title="' . $s_page . get_pg_passage($page, FALSE) . '"'; } // AutoLink marker if ($isautolink) { $al_left = '<!--autolink-->'; $al_right = '<!--/autolink-->'; } else { $al_left = $al_right = ''; } return $al_left . '<a ' . 'href="' . $script . '?' . $r_page . $anchor . '"' . $title . '>' . $s_alias . '</a>' . $al_right; } else { // Dangling link if (PKWK_READONLY) { return $s_alias; } // No dacorations $retval = $s_alias . '<a href="' . $script . '?cmd=edit&page=' . $r_page . $r_refer . '">' . $_symbol_noexists . '</a>'; if ($link_compact) { return $retval; } else { return '<span class="noexists">' . $retval . '</span>'; } } }
function plugin_popular_convert() { global $vars; // global $_popular_plugin_frame, $_popular_plugin_today_frame; static $localtime; $_popular_plugin_frame_s = _('popular(%d)'); $_popular_plugin_today_frame_s = _('today\'s(%d)'); $_popular_plugin_yesterday_frame_s = _('yesterday\'s(%d)'); $_popular_plugin_recent_frame_s = _('recent\'s(%d)'); $_popular_plugin_frame = sprintf('<h5>%s</h5><div>%%s</div>', $_popular_plugin_frame_s); $_popular_plugin_today_frame = sprintf('<h5>%s</h5><div>%%s</div>', $_popular_plugin_today_frame_s); $_popular_plugin_yesterday_frame = sprintf('<h5>%s</h5><div>%%s</div>', $_popular_plugin_yesterday_frame_s); $_popular_plugin_recent_frame = sprintf('<h5>%s</h5><div>%%s</div>', $_popular_plugin_recent_frame_s); $view = 'total'; $max = PLUGIN_POPULAR_DEFAULT; $except = ''; if (!isset($localtime)) { list($zone, $zonetime) = set_timezone(DEFAULT_LANG); $localtime = UTIME + $zonetime; } $today = gmdate('Y/m/d', $localtime); // $yesterday = gmdate('Y/m/d', strtotime('yesterday', $localtime)); $yesterday = gmdate('Y/m/d', gmmktime(0, 0, 0, gmdate('m', $localtime), gmdate('d', $localtime) - 1, gmdate('Y', $localtime))); $array = func_get_args(); switch (func_num_args()) { case 3: switch ($array[2]) { case 'today': case 'true': $view = 'today'; break; case 'yesterday': $view = 'yesterday'; break; case 'recent': $view = 'recent'; break; case 'total': case 'false': default: $view = 'total'; break; } case 2: $except = $array[1]; case 1: $max = $array[0]; } $counters = array(); foreach (auth::get_existpages(COUNTER_DIR, '.count') as $file => $page) { if ($except != '' && ereg($except, $page) || is_cantedit($page) || check_non_list($page) || !is_page($page)) { continue; } $array = file(COUNTER_DIR . $file); $count = rtrim($array[0]); $date = rtrim($array[1]); $today_count = rtrim($array[2]); $yesterday_count = rtrim($array[3]); $counters['_' . $page] = 0; if ($view == 'today' or $view == 'recent') { // $pageが数値に見える(たとえばencode('BBS')=424253)とき、 // array_splice()によってキー値が変更されてしまうのを防ぐ // ため、キーに '_' を連結する if ($today == $date) { $counters['_' . $page] = $today_count; } } if ($view == 'yesterday' or $view == 'recent') { if ($today == $date) { $counters['_' . $page] += $yesterday_count; } elseif ($yesterday == $date) { $counters['_' . $page] += $today_count; } } if ($view == 'total') { $counters['_' . $page] = $count; } if ($counters['_' . $page] == 0) { unset($counters['_' . $page]); } } asort($counters, SORT_NUMERIC); // BugTrack2/106: Only variables can be passed by reference from PHP 5.0.5 $counters = array_reverse($counters, TRUE); // with array_splice() $counters = array_splice($counters, 0, $max); $items = ''; if (!empty($counters)) { $items = '<ul class="popular_list">' . "\n"; foreach ($counters as $page => $count) { $page = substr($page, 1); $s_page = htmlspecialchars($page); if ($page == $vars['page']) { // No need to link itself, notifies where you just read $pg_passage = get_pg_passage($page, FALSE); $items .= ' <li><span title="' . $s_page . ' ' . $pg_passage . '">' . $s_page . '<span class="counter">(' . $count . ')</span></span></li>' . "\n"; } else { $items .= ' <li>' . make_pagelink($page, $s_page . '<span class="counter">(' . $count . ')</span>') . '</li>' . "\n"; } } $items .= '</ul>' . "\n"; } switch ($view) { case 'today': $frame = $_popular_plugin_today_frame; break; case 'yesterday': $frame = $_popular_plugin_yesterday_frame; break; case 'recent': $frame = $_popular_plugin_recent_frame; break; case 'total': default: $frame = $_popular_plugin_frame; break; } return sprintf($frame, count($counters), $items); }