/**
 * 書式
 * 
 *      #blikifooter([著者名])
 *
 * 種別 
 *      ブロック型プラグイン
 *  
 * 概要
 *
 *      「投稿者 志田|パーマリンク|trackback(10)|comment(5)」を表示する
 *       blog2プラグインのblog2trackbackを元に作成させていただきました。
 *       ようかさんありがとうございます。
 * 
 * 
 * @author Yuki SHIDA <*****@*****.**>
 * @author ようか
 */
function plugin_blikifooter_convert()
{
    global $script, $vars, $trackback;
    global $_blikifooter_msg;
    $args = func_get_args();
    $retval = '';
    if (!empty($args[0])) {
        $retval .= $_blikifooter_msg['msg_author'] . '[[' . $args[0] . ']]' . $_blikifooter_msg['seplater'];
    }
    $retval .= '[[' . $_blikifooter_msg['msg_permalink'] . '>' . $vars['page'] . ']]';
    if ($trackback && isset($args[1]) && $args[1] != '0') {
        $retval .= $_blikifooter_msg['seplater'] . '[[' . $_blikifooter_msg['msg_trackback'] . '(' . tb_count($vars['page']) . '):' . $script . '?plugin=tb&__mode=view&tb_id=' . tb_get_id($vars['page']) . ']]';
    }
    $comment_count = count_comment($vars['page']);
    if (!is_null($comment_count)) {
        $retval .= $_blikifooter_msg['seplater'] . sprintf($_blikifooter_msg['msg_comment'], $comment_count);
    }
    return sprintf(BLIKIFOOTER_TEMPLATE, convert_html($retval));
}
function tb_get_rdf($page)
{
    $_script = get_script_uri();
    // Get absolute path
    $r_page = rawurlencode($page);
    $tb_id = tb_get_id($page);
    // $dcdate = substr_replace(get_date('Y-m-d\TH:i:sO', $time), ':', -2, 0);
    // dc:date="$dcdate"
    return <<<EOD
<!--
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
 <rdf:Description
   rdf:about="{$_script}?{$r_page}"
   dc:identifier="{$_script}?{$r_page}"
   dc:title="{$page}"
   trackback:ping="{$_script}?tb_id={$tb_id}" />
</rdf:RDF>
-->
EOD;
}
Example #3
0
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&amp;page={$r_page}";
    $_LINK['backup'] = "{$script}?cmd=backup&amp;page={$r_page}";
    $_LINK['copy'] = "{$script}?plugin=template&amp;refer={$r_page}";
    $_LINK['diff'] = "{$script}?cmd=diff&amp;page={$r_page}";
    $_LINK['edit'] = "{$script}?cmd=edit&amp;page={$r_page}";
    $_LINK['filelist'] = "{$script}?cmd=filelist";
    $_LINK['freeze'] = "{$script}?cmd=freeze&amp;page={$r_page}";
    $_LINK['help'] = "{$script}?" . rawurlencode($help_page);
    $_LINK['list'] = "{$script}?cmd=list";
    $_LINK['new'] = "{$script}?plugin=newpage&amp;refer={$r_page}";
    $_LINK['rdf'] = "{$script}?cmd=rss&amp;ver=1.0";
    $_LINK['recent'] = "{$script}?" . rawurlencode($whatsnew);
    $_LINK['refer'] = "{$script}?plugin=referer&amp;page={$r_page}";
    $_LINK['reload'] = "{$script}?{$r_page}";
    $_LINK['rename'] = "{$script}?plugin=rename&amp;refer={$r_page}";
    $_LINK['rss'] = "{$script}?cmd=rss";
    $_LINK['rss10'] = "{$script}?cmd=rss&amp;ver=1.0";
    // Same as 'rdf'
    $_LINK['rss20'] = "{$script}?cmd=rss&amp;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&amp;__mode=view&amp;tb_id={$tb_id}";
    }
    $_LINK['unfreeze'] = "{$script}?cmd=unfreeze&amp;page={$r_page}";
    $_LINK['upload'] = "{$script}?plugin=attach&amp;pcmd=upload&amp;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 plugin_minicalendar_viewer_convert()
{
    global $vars, $get, $post, $script, $weeklabels;
    global $_err_calendar_viewer_param, $_err_calendar_viewer_param2;
    global $_msg_calendar_viewer_right, $_msg_calendar_viewer_left;
    global $_msg_calendar_viewer_restrict;
    global $_symbol_paraedit, $trackback;
    static $viewed = array();
    if (func_num_args() < 2) {
        return PLUGIN_MINICALENDAR_VIEWER_USAGE . '<br />' . "\n";
    }
    $func_vars_array = func_get_args();
    // デフォルト値をセット
    $pagename = $func_vars_array[0];
    // 基準となるページ名
    $limit_page = 7;
    // 表示する件数制限
    $date_YM = '';
    // 一覧表示する年月
    $mode = 'past';
    // 動作モード
    $date_sep = '-';
    // 日付のセパレータ calendar2なら"-" calendarなら""
    // Check $func_args[1]
    if (preg_match("/[0-9]{4}" . $date_sep . "[0-9]{2}/", $func_vars_array[1])) {
        //指定年月の一覧表示
        $page_YM = $func_vars_array[1];
        $limit_base = 0;
        $limit_page = 31;
        //手抜き。31日分をリミットとする。
    } else {
        if (preg_match("/this/si", $func_vars_array[1])) {
            //今月の一覧表示
            $page_YM = get_date('Y' . $date_sep . 'm');
            $limit_base = 0;
            $limit_page = 31;
        } else {
            if (preg_match("/^[0-9]+\$/", $func_vars_array[1])) {
                //n日分表示
                $limit_pitch = $func_vars_array[1];
                $limit_page = $limit_pitch;
                $limit_base = 0;
                $page_YM = '';
            } else {
                if (preg_match("/([0-9]+)\\*([0-9]+)/", $func_vars_array[1], $reg_array)) {
                    $limit_pitch = $reg_array[2];
                    $limit_page = $reg_array[1] + $limit_pitch;
                    $limit_base = $reg_array[1];
                    $page_YM = '';
                } else {
                    return '#calendar_viewer(): ' . $_err_calendar_viewer_param2 . '<br />' . "\n";
                }
            }
        }
    }
    // $func_args[2]: Change default delimiter
    if (isset($func_vars_array[2]) && preg_match("/^(past|pastex|view|viewex|future|futureex)\$/si", $func_vars_array[2])) {
        $mode = $func_vars_array[2];
    }
    // $func_args[3]: Change default delimiter
    if (isset($func_vars_array[3])) {
        $date_sep = $func_vars_array[3];
    }
    // Avoid Loop etc.
    if (isset($viewed[$pagename])) {
        if ($viewed[$pagename] > PLUGIN_MINICALENDAR_MAX_VIEWS) {
            $s_page = htmlspecialchars($pagename);
            return '#calendar_viewer(): You already view: ' . $s_page . '<br />';
        }
        $viewed[$pagename]++;
        // Valid
    } else {
        $viewed[$pagename] = 1;
        // Valid
    }
    // 一覧表示するページ名とファイル名のパターン ファイル名には年月を含む
    if ($pagename == '') {
        // pagename無しのyyyy-mm-ddに対応するための処理
        $pagepattern = '';
        $pagepattern_len = 0;
        $filepattern = encode($page_YM);
        $filepattern_len = strlen($filepattern);
    } else {
        $pagepattern = strip_bracket($pagename) . '/';
        $pagepattern_len = strlen($pagepattern);
        $filepattern = encode($pagepattern . $page_YM);
        $filepattern_len = strlen($filepattern);
    }
    // ページリストの取得
    $pagelist = array();
    if ($dir = @opendir(DATA_DIR)) {
        $_date = get_date('Y' . $date_sep . 'm' . $date_sep . 'd');
        $page_date = '';
        while ($file = readdir($dir)) {
            if ($file == '..' || $file == '.') {
                continue;
            }
            if (substr($file, 0, $filepattern_len) != $filepattern) {
                continue;
            }
            $page = decode(trim(preg_replace("/\\.txt\$/", " ", $file)));
            $page_date = substr($page, $pagepattern_len);
            // $pageがカレンダー形式なのかチェック デフォルトでは yyyy-mm-dd
            if (plugin_minicalendar_viewer_isValidDate($page_date, $date_sep) == FALSE) {
                continue;
            }
            // mode毎に別条件ではじく
            // pastex modeでは今日を含む未来のページはNG
            // futureex modeでは今日を含む過去のページはNG
            // past modeでは未来のページはNG
            // future modeでは過去のページはNG
            if ($page_date >= $_date && $mode == 'pastex') {
                continue;
            }
            if ($page_date <= $_date && $mode == 'futureex') {
                continue;
            }
            if ($page_date > $_date && $mode == 'past') {
                continue;
            }
            if ($page_date < $_date && $mode == 'future') {
                continue;
            }
            $pagelist[] = $page;
        }
    }
    closedir($dir);
    // まずソート
    if ($mode == 'past' || $mode == 'pastex' || $mode == 'viewex') {
        rsort($pagelist);
    } else {
        sort($pagelist);
    }
    // ここからインクルード
    $tmppage = $vars['page'];
    $return_body = '';
    // $limit_pageの件数までインクルード
    $tmp = max($limit_base, 0);
    // Skip minus
    while ($tmp < $limit_page) {
        if (!isset($pagelist[$tmp])) {
            break;
        }
        $page = $pagelist[$tmp];
        $get['page'] = $post['page'] = $vars['page'] = $page;
        // 現状で閲覧許可がある場合だけ表示する
        if (check_readable($page, FALSE, FALSE)) {
            if (function_exists('convert_filter')) {
                $body = convert_html(convert_filter(get_source($page)));
            } else {
                $body = convert_html(get_source($page));
            }
        } else {
            $body = str_replace('$1', $page, $_msg_calendar_viewer_restrict);
        }
        $r_page = rawurlencode($page);
        $s_page = htmlspecialchars($page);
        if (PLUGIN_MINICALENDAR_VIEWER_DATE_FORMAT !== FALSE) {
            $time = strtotime(basepagename($page));
            // $date_sep must be assumed '-' or ''!
            if ($time == -1 || $time == FALSE) {
                $s_page = htmlspecialchars($page);
                // Failed. Why?
            } else {
                $week = $weeklabels[date('w', $time)];
                $s_page = htmlspecialchars(str_replace(array('$w'), array($week), date(PLUGIN_CALENDAR_VIEWER_DATE_FORMAT, $time)));
            }
        }
        $refpage = rawurlencode($tmppage);
        $page_title = basepagename($page);
        $s_page_title = htmlspecialchars($page_title);
        // if (PKWK_READONLY) {
        if (auth::check_role('readonly')) {
            $link = get_page_uri($page);
        } else {
            $link = get_cmd_uri('edit', $page, '', 'refpage=' . $refpage);
        }
        $link = '<a class="anchor_super" href="' . $link . '">' . $_symbol_paraedit . '</a>';
        $head = '<h3 class="minicalendar">' . $s_page_title . ' ' . $link . '</h3>' . "\n";
        $tail = '';
        if (PLUGIN_MINICALENDAR_VIEWER_HOLIDAYVIEW === TRUE) {
            $time = strtotime($page_title);
            if ($time != -1) {
                $yy = intval(date('Y', $time));
                $mm = intval(date('n', $time));
                $dd = intval(date('d', $time));
                $monthlabel = array(1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
                $mmstr = $monthlabel[$mm];
                $h_today = public_holiday($yy, $mm, $dd);
                if ($h_today['rc'] != 0) {
                    $classname = 'date_holiday';
                } else {
                    if ($h_today['w'] == 0) {
                        $classname = 'date_holiday';
                    } else {
                        if ($h_today['w'] == 6) {
                            $classname = 'date_weekend';
                        } else {
                            $classname = 'date_weekday';
                        }
                    }
                }
                $head = '<h3 class="' . $classname . '"><span class="day">' . sprintf('%02d', $dd) . '</span> <br />' . '<b>' . $mmstr . '</b>, <b>' . $yy . '</b>' . $link . '</h3>' . "\n";
            }
        }
        if (PLUGIN_MINICALENDAR_VIEWER_COMMENT === TRUE) {
            if (is_page(':config/plugin/addline/comment') && exist_plugin_inline('addline')) {
                $comm = convert_html(array('&addline(comment,above){comment};'));
                $comm = preg_replace(array("'<p>'si", "'</p>'si"), array("", ""), $comm);
                $tail .= str_replace('>comment', '><img src="' . IMAGE_URI . 'plus/comment.png" width="15" height="15" alt="Comment" title="Comment" />Comment', $comm);
            }
        }
        if (PLUGIN_MINICALENDAR_VIEWER_TRACKBACK === TRUE) {
            if ($trackback) {
                $tb_id = tb_get_id($page);
                $tail .= '<a href="' . $script . '?plugin=tb&amp;__mode=view&amp;tb_id=' . $tb_id . '">' . '<img src="' . IMAGE_URI . 'plus/trackback.png" width="15" height="15" alt="" title="" />Trackback(' . tb_count($page) . ')' . '</a>' . "\n";
            }
        }
        if ($tail != '') {
            $tail = '<div class="trackback">' . $tail . '</div>';
        }
        $return_body .= $head . '<div class="minicalendar_viewer">' . $body . '</div>' . $tail;
        ++$tmp;
    }
    //ここで、前後のリンクを表示
    //?plugin=minicalendar_viewer&file=ページ名&date=yyyy-mm
    $enc_pagename = rawurlencode(substr($pagepattern, 0, $pagepattern_len - 1));
    if ($page_YM != '') {
        // 年月表示時
        $date_sep_len = strlen($date_sep);
        $this_year = substr($page_YM, 0, 4);
        $this_month = substr($page_YM, 4 + $date_sep_len, 2);
        // 次月
        $next_year = $this_year;
        $next_month = $this_month + 1;
        if ($next_month > 12) {
            $next_year++;
            $next_month = 1;
        }
        $next_YM = sprintf('%04d%s%02d', $next_year, $date_sep, $next_month);
        $next_YMX = sprintf('%04d%02d', $next_year, $next_month);
        // 前月
        $prev_year = $this_year;
        $prev_month = $this_month - 1;
        if ($prev_month < 1) {
            $prev_year--;
            $prev_month = 12;
        }
        $prev_YM = sprintf('%04d%s%02d', $prev_year, $date_sep, $prev_month);
        $prev_YMX = sprintf('%04d%02d', $prev_year, $prev_month);
        //		if ($mode == "past" || $mode == "pastex") {
        //			$right_YM   = $prev_YM;
        //			$right_YMX  = $prev_YMX;
        //			$right_text = $prev_YM."&gt;&gt;";
        //			$left_YM    = $next_YM;
        //			$left_YMX   = $next_YMX;
        //			$left_text  = "&lt;&lt;".$next_YM;
        //		} else {
        $left_YM = $prev_YM;
        $left_YMX = $prev_YMX;
        $left_text = '&lt;&lt;' . $prev_YM;
        $right_YM = $next_YM;
        $right_YMX = $next_YMX;
        $right_text = $next_YM . '&gt;&gt;';
        //		}
    } else {
        // n件表示時
        if ($limit_base >= count($pagelist)) {
            $right_YM = '';
        } else {
            $right_base = $limit_base + $limit_pitch;
            $right_YM = $right_base . '*' . $limit_pitch;
            $right_text = sprintf($_msg_calendar_viewer_right, $limit_pitch);
        }
        $left_base = $limit_base - $limit_pitch;
        if ($left_base >= 0) {
            $left_YM = $left_base . '*' . $limit_pitch;
            $left_text = sprintf($_msg_calendar_viewer_left, $limit_pitch);
        } else {
            $left_YM = '';
        }
        $prev_YMX = '';
        $next_YMX = '';
    }
    // ナビゲート用のリンクを末尾に追加
    $s_date_sep = htmlspecialchars($date_sep);
    if ($left_YM != '') {
        if ($left_YMX != '') {
            $left_link = '<a href="' . $script . '?plugin=minicalendar&amp;file=' . $enc_pagename . '&amp;date=' . $left_YMX . '">' . $left_text . '</a>';
        } else {
            $left_link = '<a href="' . $script . '?plugin=minicalendar_viewer&amp;file=' . $enc_pagename . '&amp;date=' . $left_YM . '&amp;date_sep=' . $s_date_sep . '&amp;mode=' . $mode . '">' . $left_text . '</a>';
        }
    } else {
        $left_link = '';
    }
    if ($right_YM != '') {
        if ($right_YMX != '') {
            $right_link = '<a href="' . $script . '?plugin=minicalendar&amp;file=' . $enc_pagename . '&amp;date=' . $right_YMX . '">' . $right_text . '</a>';
        } else {
            $right_link = '<a href="' . $script . '?plugin=minicalendar_viewer&amp;file=' . $enc_pagename . '&amp;date=' . $right_YM . '&amp;date_sep=' . $s_date_sep . '&amp;mode=' . $mode . '">' . $right_text . '</a>';
        }
    } else {
        $right_link = '';
    }
    //past modeは<<新 旧>> 他は<<旧 新>>
    $return_body .= '<div class="prevnext">';
    $return_body .= '<div class="prevnext_r">' . $right_link . '</div>';
    $return_body .= '<div class="prevnext_l">' . $left_link . '</div>';
    $return_body .= '</div><br style="display:block;clear:both" />';
    $get['page'] = $post['page'] = $vars['page'] = $tmppage;
    return $return_body;
}
Example #5
0
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) . '&amp;nohead&amp;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_weblog_rss_action()
{
    global $rss_max, $page_title, $WikiName, $BracketName, $script, $whatsnew, $trackback, $use_static_url, $anon_writable;
    global $vars;
    global $options, $_weblog_msgs;
    //コンフィグの読み込み(指定weblog固有)
    $conf_name = $vars['config'];
    $options = weblog_get_options($conf_name, $options);
    $page = strip_bracket($options['PREFIX']);
    $with_content = $vars['content'];
    $list_count = $vars['count'];
    if ($list_count == 0) {
        $list_count = $rss_max;
    }
    $lines = get_existpages(false, $page, $list_count, " ORDER BY editedtime DESC", true);
    header("Content-type: application/xml");
    if (is_page($page)) {
        $linkpage = $page;
    } else {
        if (strrchr($page, "/")) {
            $_p = substr($page, 0, -strlen(strrchr($page, "/")));
            if (is_page($_p)) {
                $linkpage = $_p;
            }
        } else {
            $linkpage = $whatsnew;
        }
    }
    if ($use_static_url) {
        $linkpage_url = XOOPS_WIKI_URL . "/" . get_pgid_by_name($linkpage) . ".html";
    } else {
        $linkpage_url = $script . "?" . rawurlencode($linkpage);
    }
    $page_title_utf8 = $page_title;
    if (function_exists("mb_convert_encoding")) {
        $page_title_utf8 = mb_convert_encoding($page_title_utf8, "UTF-8", "auto");
        //		$page_utf8 = mb_convert_encoding($linkpage,"UTF-8","auto");
        $page_utf8 = mb_convert_encoding($options['NAME'], "UTF-8", "auto");
        $page_add_utf8 = $linkpage ? "-" . $page_utf8 : "";
    }
    $item = "";
    $rdf_li = "";
    foreach ($lines as $line) {
        $vars['page'] = $line;
        $page_name = strip_bracket($line);
        if (!preg_match("/^(.*\\/)?[0-9\\-]+\$/", $page_name)) {
            continue;
        }
        $src = @join("", get_source($page_name));
        $sources = $src;
        if (preg_match("/\\&weblog_field\\(__SUBJECT\\)\\{([^}]+)\\}\\;/m", $sources, $match)) {
            $subject = $match[1];
        }
        if (preg_match("/\\&weblog_field\\(__AUTHOR\\)\\{([^}]+)\\}\\;/m", $sources, $match)) {
            $author = $match[1];
        }
        if (preg_match("/\\&weblog_field\\(__CATEGORY,:([^\\)]+)\\)\\{([^}]+)\\}\\;((\\[ )?\\[\\[.*\\]\\]( \\])?)+/m", $sources, $match)) {
            $catpath = $match[1];
            $category = $match[2];
        }
        if (preg_match("/#weblog_field\\(__BODY\\,Start\\)\\s*\n(.*\n)#weblog_field\\(__BODY\\,End\\)\n/ms", $sources, $match)) {
            $body = $match[1];
            $body = preg_replace("/\\s*((\r\n)|(\r)|(\n))/", "\n", $body);
        }
        $title = mb_convert_encoding($subject, "UTF-8", "auto");
        $url = strip_bracket($line);
        //		if ($page) $title = preg_replace("/^".preg_quote($page_utf8,"/")."\//","",$title);
        $title = htmlspecialchars($title);
        $desc = date("D, d M Y H:i:s T", filemtime(get_filename(encode($line))));
        $dcdate = substr_replace(date("Y-m-d\\TH:i:sO", filemtime(get_filename(encode($line)))), ':', -2, 0);
        if ($use_static_url) {
            $link_url = XOOPS_WIKI_URL . "/" . get_pgid_by_name($line) . ".html";
        } else {
            $link_url = $script . "?" . rawurlencode($url);
        }
        $items .= "<item rdf:about=\"" . $link_url . "\">\n";
        $items .= " <title>{$title}</title>\n";
        $items .= " <link>" . $link_url . "</link>\n";
        $items .= " <dc:date>{$dcdate}</dc:date>\n";
        $_anon_writable = $anon_writable;
        $anon_writable = 0;
        $desc = convert_html($body, false, false);
        $desc = mb_convert_encoding(mb_substr(strip_htmltag($desc), 0, 250, "EUC-JP"), "UTF-8", "auto");
        $desc = htmlspecialchars($desc);
        $desc = mb_ereg_replace("\n", "", $desc);
        $items .= " <description>{$desc}</description>\n";
        if ($with_content == "true") {
            $src = preg_replace("/\\&weblog_field\\(__EDIT\\,[^\\)]+\\);/m", "", $src);
            $content = convert_html($src, false, false);
            $content = mb_convert_encoding($content, "UTF-8", "auto");
            $content = preg_replace("/\\<input [^\\>]+\\/>(\n)?/ms", "", $content);
            $content = preg_replace("/^(\\s*\n)+/mS", "\n", $content);
            $content = preg_replace("/\\s*\\<br \\/\\>\\s*/mS", "<br />", $content);
            $content = preg_replace("/class\\=\"p\\_right\"/", 'style="text-align:right;"', $content);
            $items .= "<content:encoded>\n<![CDATA[\n";
            $items .= "{$content}\n";
            $items .= "]]>\n</content:encoded>\n";
        }
        $anon_writable = $anon_writable = 0;
        //trackback
        if ($trackback) {
            $dc_identifier = $trackback_ping = '';
            $r_page = rawurlencode($url);
            $tb_id = tb_get_id($url);
            $dc_identifier = " <dc:identifer>{$link_url}</dc:identifer>\n";
            $trackback_ping = " <trackback:ping>{$script}?pwm_ping={$tb_id}</trackback:ping>\n";
            $items .= $dc_identifier . $trackback_ping;
        }
        if ($category != "") {
            $cats = explode(",", $category);
            foreach ($cats as $cat_item) {
                //				$subject = $catpath."/".$cat_item;
                $subject = $cat_item;
                $subject = mb_convert_encoding($subject, "UTF-8", "auto");
                $items .= "<dc:subject>{$subject}</dc:subject>\n";
            }
        }
        $items .= "</item>\n\n";
        $rdf_li .= "<rdf:li rdf:resource=\"" . $link_url . "\" />\n";
    }
    //	header('Content-type: text');
    $r_page = rawurlencode($page);
    echo <<<EOD
<?xml version="1.0" encoding="utf-8"?>

<rdf:RDF 
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns="http://purl.org/rss/1.0/"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
EOD;
    if ($with_content == "true") {
        echo "  xmlns:content=\"http://purl.org/rss/1.0/modules/content/\"\n";
    }
    if ($trackback) {
        echo "  xmlns:trackback=\"http://madskills.com/public/xml/rss/module/trackback/\"\n";
    }
    echo <<<EOD
  xml:lang="ja">
  <channel rdf:about="{$script}?plugin=weblog_rss&amp;config={$conf_name}&amp;content={$with_content}&amp;count={$list_count}">
  <title>{$page_title_utf8}.{$page_add_utf8}</title>
  <link>{$linkpage_url}</link>
  <description>PukiWiki Weblog RecentChanges</description>
  <items>
   <rdf:Seq>
      {$rdf_li}
   </rdf:Seq>
  </items>
 </channel>
 {$items}
</rdf:RDF>
EOD;
    exit;
}
Example #7
0
File: html.php Project: big2men/qhm
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&amp;page={$r_page}";
    $_LINK['backup'] = "{$script}?cmd=backup&amp;page={$r_page}";
    $_LINK['copy'] = "{$script}?plugin=template&amp;refer={$r_page}";
    $_LINK['diff'] = "{$script}?cmd=diff&amp;page={$r_page}";
    $_LINK['edit'] = "{$script}?cmd=edit&amp;page={$r_page}";
    $_LINK['filelist'] = "{$script}?cmd=filelist";
    $_LINK['freeze'] = "{$script}?cmd=freeze&amp;page={$r_page}";
    $_LINK['help'] = "{$script}?" . rawurlencode($help_page);
    $_LINK['list'] = "{$script}?cmd=list";
    $_LINK['new'] = "{$script}?plugin=newpage&amp;refer={$r_page}";
    $_LINK['rdf'] = "{$script}?cmd=rss&amp;ver=1.0";
    $_LINK['recent'] = "{$script}?" . rawurlencode($whatsnew);
    $_LINK['refer'] = "{$script}?plugin=referer&amp;page={$r_page}";
    $_LINK['reload'] = "{$script}?{$r_page}";
    $_LINK['rename'] = "{$script}?plugin=rename&amp;refer={$r_page}";
    $_LINK['delete'] = "{$script}?plugin=delete&amp;page={$r_page}";
    $_LINK['rss'] = "{$script}?cmd=rss";
    $_LINK['rss10'] = "{$script}?cmd=rss&amp;ver=1.0";
    // Same as 'rdf'
    $_LINK['rss20'] = "{$script}?cmd=rss&amp;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&amp;__mode=view&amp;tb_id={$tb_id}";
    }
    $_LINK['unfreeze'] = "{$script}?cmd=unfreeze&amp;page={$r_page}";
    $_LINK['upload'] = "{$script}?plugin=attach&amp;pcmd=upload&amp;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&amp;page=MenuBar";
    $_LINK['edit_menu2'] = "{$script}?cmd=edit&amp;page=MenuBar2";
    $_LINK['edit_navi'] = "{$script}?cmd=edit&amp;page=SiteNavigator";
    $_LINK['edit_navi2'] = "{$script}?cmd=edit&amp;page=SiteNavigator2";
    $_LINK['edit_header'] = "{$script}?cmd=edit&amp;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);
    }
}
Example #8
0
function plugin_tb_recent($page, $line)
{
    $body = '';
    $tb_id = tb_get_id($page);
    $data = tb_get(tb_get_filename($page));
    $ctr = count($data);
    if ($ctr == 0) {
        return '';
    }
    if ($ctr > 1) {
        // Sort: The first is the latest
        usort($data, create_function('$a,$b', 'return $b[0] - $a[0];'));
    }
    $body .= '<h5>' . _("RECENT TRACKBACK") . "</h5>\n";
    $body .= "<div>\n<ul class=\"recent_list\">\n";
    $i = 0;
    foreach ($data as $x) {
        if (count($x) != 5) {
            continue;
        }
        // Ignore incorrect record
        list($time, $url, $title, $excerpt, $blog_name) = $x;
        if ($title == '') {
            $title = 'no title';
        }
        $body .= '<li><a href="' . $url . '" title="' . $blog_name . ' ' . get_passage($time) . '" rel="nofollow">' . $title . '</a></li>' . "\n";
        $i++;
        if ($line == 0) {
            continue;
        }
        if ($i >= $line) {
            break;
        }
    }
    if ($i == 0) {
        return '';
    }
    $body .= "</ul>\n</div>\n";
    return $body;
}
function plugin_calendar_viewer_convert()
{
    global $vars, $get, $post, $_labels;
    //	global $_msg_calendar_viewer_right, $_msg_calendar_viewer_left;
    //	global $_msg_calendar_viewer_restrict, $_err_calendar_viewer_param2;
    global $_symbol_paraedit, $trackback;
    $_calendar_viewer_msg = array('_err_param2' => T_('Wrong second parameter.'), '_msg_right' => T_('Next %d &gt;&gt;'), '_msg_left' => T_('&lt;&lt; Prev %d'), '_msg_restrict' => T_('Due to the blocking, the calendar_viewer cannot refer to $1.'), '_title_format' => T_('%1s, %2s %3s %4s'));
    if (!isset($vars['page'])) {
        return '';
    }
    static $viewed = array();
    if (func_num_args() < 2) {
        return PLUGIN_CALENDAR_VIEWER_USAGE . '<br />' . "\n";
    }
    $func_args = func_get_args();
    // Default values
    $pagename = $func_args[0];
    // 基準となるページ名
    $page_YM = '';
    // 一覧表示する年月
    $limit_base = 0;
    // 先頭から数えて何ページ目から表示するか (先頭)
    $limit_pitch = 0;
    // 何件づつ表示するか
    $limit_page = 0;
    // サーチするページ数
    $mode = 'past';
    // 動作モード
    $date_sep = '-';
    // 日付のセパレータ calendar2なら '-', calendarなら ''
    // Check $func_args[1]
    $matches = array();
    if (preg_match('/[0-9]{4}' . $date_sep . '[0-9]{2}/', $func_args[1])) {
        // 指定年月の一覧表示
        $page_YM = $func_args[1];
        $limit_page = 31;
    } else {
        if (preg_match('/this/si', $func_args[1])) {
            // 今月の一覧表示
            $page_YM = get_date('Y' . $date_sep . 'm');
            $limit_page = 31;
        } else {
            if (preg_match('/^[0-9]+$/', $func_args[1])) {
                // n日分表示
                $limit_pitch = $func_args[1];
                $limit_page = $func_args[1];
            } else {
                if (preg_match('/(-?[0-9]+)\\*([0-9]+)/', $func_args[1], $matches)) {
                    // 先頭より数えて x ページ目から、y件づつ表示
                    $limit_base = $matches[1];
                    $limit_pitch = $matches[2];
                    $limit_page = $matches[1] + $matches[2];
                    // 読み飛ばす + 表示する
                } else {
                    return '#calendar_viewer(): ' . $_calendar_viewer_msg['_err_param2'] . '<br />' . "\n";
                }
            }
        }
    }
    // $func_args[2]: Mode setting
    if (isset($func_args[2]) && preg_match('/^(past|pastex|view|viewex|future|futureex)$/si', $func_args[2])) {
        $mode = $func_args[2];
    }
    // $func_args[3]: Change default delimiter
    if (isset($func_args[3])) {
        $date_sep = $func_args[3];
    }
    // Avoid Loop etc.
    if (isset($viewed[$pagename])) {
        if ($viewed[$pagename] > PLUGIN_CALENDAR_MAX_VIEWS) {
            $s_page = htmlsc($pagename);
            return '#calendar_viewer(): You already view: ' . $s_page . '<br />';
        }
        $viewed[$pagename]++;
        // Valid
    } else {
        $viewed[$pagename] = 1;
        // Valid
    }
    // 一覧表示するページ名とファイル名のパターン ファイル名には年月を含む
    if ($pagename == '') {
        // pagename無しのyyyy-mm-ddに対応するための処理
        $pagepattern = '';
        $pagepattern_len = 0;
        $filepattern = encode($page_YM);
        $filepattern_len = strlen($filepattern);
    } else {
        $pagepattern = strip_bracket($pagename) . '/';
        $pagepattern_len = strlen($pagepattern);
        $filepattern = encode($pagepattern . $page_YM);
        $filepattern_len = strlen($filepattern);
    }
    // ページリストの取得
    $pagelist = array();
    if ($dir = @opendir(DATA_DIR)) {
        $_date = get_date('Y' . $date_sep . 'm' . $date_sep . 'd');
        $page_date = '';
        while ($file = readdir($dir)) {
            if ($file == '..' || $file == '.') {
                continue;
            }
            if (substr($file, 0, $filepattern_len) != $filepattern) {
                continue;
            }
            $page = decode(trim(preg_replace('/\\.txt$/', ' ', $file)));
            $page_date = substr($page, $pagepattern_len);
            // Verify the $page_date pattern (Default: yyyy-mm-dd).
            // Past-mode hates the future, and
            // Future-mode hates the past.
            if (plugin_calendar_viewer_isValidDate($page_date, $date_sep) == FALSE || $page_date > $_date && $mode == 'past' || $page_date < $_date && $mode == 'future' || $page_date >= $_date && $mode == 'pastex' || $page_date <= $_date && $mode == 'futureex') {
                continue;
            }
            $pagelist[] = $page;
        }
    }
    closedir($dir);
    if ($mode == 'past' || $mode == 'pastex' || $mode == 'viewex') {
        rsort($pagelist, SORT_STRING);
        // New => Old
    } else {
        sort($pagelist, SORT_STRING);
        // Old => New
    }
    // Include start
    $tmppage = $vars['page'];
    $return_body = '';
    // $limit_page の件数までインクルード
    $tmp = max($limit_base, 0);
    // Skip minus
    while ($tmp < $limit_page) {
        if (!isset($pagelist[$tmp])) {
            break;
        }
        $page = $pagelist[$tmp];
        $get['page'] = $post['page'] = $vars['page'] = $page;
        $wiki = Factory::Wiki($page);
        // 現状で閲覧許可がある場合だけ表示する
        if ($wiki->isReadable()) {
            if (function_exists('convert_filter')) {
                $body = RendererFactory::factory(convert_filter($wiki->get()));
            } else {
                $body = $wiki->render();
            }
        } else {
            $body = str_replace('$1', $page, $_calendar_viewer_msg['_msg_restrict']);
        }
        if (PLUGIN_CALENDAR_VIEWER_DATE_FORMAT !== FALSE) {
            $time = strtotime(basename($page));
            // $date_sep must be assumed '-' or ''!
            if ($time == -1) {
                $s_page = htmlsc($page);
                // Failed. Why?
            } else {
                $week = $_labels['week'][date('w', $time)][0];
                $month = $_labels['month'][preg_replace('/^0/', '', date('m', $time))][0];
                $s_page = htmlsc(str_replace(array('$w', '$m'), array($week, $month), date(PLUGIN_CALENDAR_VIEWER_DATE_FORMAT, $time)));
            }
        } else {
            $s_page = htmlsc($page);
        }
        // if (PKWK_READONLY) {
        if (Auth::check_role('readonly')) {
            $link = get_page_uri($page);
        } else {
            $link = get_cmd_uri('edit', $page, '', array('page' => $page));
        }
        $link = '<a class="anchor_super" href="' . $link . '">' . $_symbol_paraedit . '</a>';
        $head = '<h1>' . $s_page . $link . '</h1>' . "\n";
        $page_title = basepagename($page);
        $tail = '';
        if (PLUGIN_CALENDAR_VIEWER_HOLIDAYVIEW === TRUE) {
            $time = strtotime($page_title);
            if ($time != -1) {
                $yy = intval(date('Y', $time));
                $mm = intval(date('n', $time));
                $dd = intval(date('d', $time));
                $h_today = PublicHolidayFactory::factory('JP', $yy, $mm, $dd);
                if ($h_today['rc'] != 0) {
                    $classname = 'date_holiday';
                    $weekclass = 'week_sun';
                } else {
                    switch ($h_today['w']) {
                        case 0:
                            $classname = 'date_holiday';
                            $weekclass = 'week_sun';
                            break;
                        case 6:
                            $classname = 'date_weekend';
                            $weekclass = 'week_sat';
                        default:
                            $classname = 'date_weekday';
                            $weekclass = 'week_day';
                            break;
                    }
                }
            }
        }
        if (PLUGIN_CALENDAR_VIEWER_COMMENT === TRUE) {
            if (is_page(':config/plugin/addline/comment') && exist_plugin_inline('addline')) {
                $comm = RendererFactory::factory(array('&addline(comment,above){comment};'));
                $comm = preg_replace(array("'<p>'si", "'</p>'si"), array("", ""), $comm);
                $tail .= str_replace('>comment', '><img src="' . IMAGE_URI . 'plus/comment.png" width="15" height="15" alt="Comment" title="Comment" />Comment', $comm);
            }
        }
        if (PLUGIN_CALENDAR_VIEWER_TRACKBACK === TRUE && $trackback) {
            $tb_link = get_cmd_uri('tb', '', '', array('__mode' => 'view', 'tb_id' => tb_get_id($page)));
            $tail .= '<a class="pkwk-icon_linktext cmd-trackback" href="' . $tb_link . '">' . 'Trackback(' . tb_count($page) . ')' . '</a>' . "\n";
        }
        $page_id = str_replace('/', '_', $page);
        $return_body .= '<article id="' . $page_id . '">' . "\n";
        $return_body .= $head . $body;
        $return_body .= '</article>' . "\n";
        ++$tmp;
    }
    // ここで、前後のリンクを表示
    // ?plugin=calendar_viewer&file=ページ名&date=yyyy-mm
    $page = substr($pagepattern, 0, $pagepattern_len - 1);
    $r_page = rawurlencode($page);
    if ($page_YM != '') {
        // 年月表示時
        $date_sep_len = strlen($date_sep);
        $this_year = substr($page_YM, 0, 4);
        $this_month = substr($page_YM, 4 + $date_sep_len, 2);
        // 次月
        $next_year = $this_year;
        $next_month = $this_month + 1;
        if ($next_month > 12) {
            ++$next_year;
            $next_month = 1;
        }
        $next_YM = sprintf('%04d%s%02d', $next_year, $date_sep, $next_month);
        // 前月
        $prev_year = $this_year;
        $prev_month = $this_month - 1;
        if ($prev_month < 1) {
            --$prev_year;
            $prev_month = 12;
        }
        $prev_YM = sprintf('%04d%s%02d', $prev_year, $date_sep, $prev_month);
        if ($mode == 'past') {
            $right_YM = $prev_YM;
            $right_text = $prev_YM . '&gt;&gt;';
            // >>
            $left_YM = $next_YM;
            $left_text = '&lt;&lt;' . $next_YM;
            // <<
        } else {
            $left_YM = $prev_YM;
            $left_text = '&lt;&lt;' . $prev_YM;
            // <<
            $right_YM = $next_YM;
            $right_text = $next_YM . '&gt;&gt;';
            // >>
        }
    } else {
        // n件表示時
        if ($limit_base <= 0) {
            $left_YM = '';
            // 表示しない (それより前の項目はない)
        } else {
            $left_YM = $limit_base - $limit_pitch . '*' . $limit_pitch;
            $left_text = sprintf($_calendar_viewer_msg['_msg_left'], $limit_pitch);
        }
        if ($limit_base + $limit_pitch >= count($pagelist)) {
            $right_YM = '';
            // 表示しない (それより後の項目はない)
        } else {
            $right_YM = $limit_base + $limit_pitch . '*' . $limit_pitch;
            $right_text = sprintf($_calendar_viewer_msg['_msg_right'], $limit_pitch);
        }
    }
    // ナビゲート用のリンクを末尾に追加
    if ($left_YM != '' || $right_YM != '') {
        $s_date_sep = htmlsc($date_sep);
        $left_link = $right_link = '';
        if ($left_YM != '') {
            $left_link = '<a href="' . get_cmd_uri('calendar_viewer', '', '', array('mode' => $mode, 'file' => $page, 'date_sep' => $date_sep, 'date' => $left_YM)) . '">' . $left_text . '</a>';
        }
        if ($right_YM != '') {
            $right_link = '<a href="' . get_cmd_uri('calendar_viewer', '', '', array('mode' => $mode, 'file' => $page, 'date_sep' => $date_sep, 'date' => $right_YM)) . '">' . $right_text . '</a>';
        }
        $center_link = '<a href="' . get_page_uri($page) . '">' . $page . '</a>';
        // past modeは<<新 旧>> 他は<<旧 新>>
        $nav = '<nav class="calendar_viewer_navi">' . "\n";
        $nav .= <<<EOD
<ul class="navi">
\t<li class="navi_left">{$left_link}</li>
\t<li class="navi_none">{$center_link}</li>
\t<li class="navi_right">{$right_link}</li>
</ul>
<hr />
EOD;
        $nav .= '</nav>' . "\n";
    }
    $get['page'] = $post['page'] = $vars['page'] = $tmppage;
    return $nav . $return_body;
}
function plugin_weblog_viewer_convert()
{
    global $WikiName, $BracketName, $vars, $get, $post, $hr, $script, $trackback;
    global $anon_writable, $wiki_user_dir;
    global $comment_no, $h_excerpt, $digest;
    global $options, $_weblog_msgs, $_msg_week;
    //*引数の確認
    if (func_num_args() >= 2) {
        $func_vars_array = func_get_args();
        $params = call_user_func_array("plugin_weblog_viewer_check_args", $func_vars_array);
        if (count($params) <= 1) {
            return "[weblog_viewer]:{$_weblog_msgs['err_msg_arg2']}";
        }
    } else {
        return "[weblog_viewer]:{$_weblog_msgs['err_msg_noargs']}";
    }
    foreach ($params as $param_key => $param_val) {
        ${$param_key} = $param_val;
    }
    $conf_name = $params['conf_name'];
    $options = weblog_get_options($conf_name, $options);
    if (count($options) == 0) {
        return "[weblog_viewer]:" . sprintf($_weblog_msgs['err_msg_noconf'], $conf_name);
    }
    $pagename = strip_bracket($options['PREFIX']);
    //*一覧表示するページ名とファイル名のパターン ファイル名には年月を含む
    if ($pagename == "") {
        //pagename無しのyyyy-mm-ddに対応するための処理
        $pagepattern = "";
        $pagepattern_len = 0;
        $filepattern = $page_YM;
        $filepattern_len = strlen($filepattern);
    } else {
        $pagepattern = strip_bracket($pagename) . '/';
        $pagepattern_len = strlen($pagepattern);
        $filepattern = $pagepattern . $page_YM;
        $filepattern_len = strlen($filepattern);
    }
    //*ページリストの取得
    $pagelist = array();
    $datelength = 10;
    foreach (get_existpages_db(false, $filepattern) as $page) {
        //$pageがカレンダー形式なのかチェック デフォルトでは、 yyyy-mm-dd-HHMMSS-([1-9])?
        $page = strip_bracket($page);
        if (plugin_weblog_viewer_isValidDate(substr($page, $pagepattern_len)) == false) {
            continue;
        }
        //*mode毎に別条件ではじく
        //past modeでは未来のページはNG
        if (substr($page, $pagepattern_len, $datelength) > date("Y-m-d") && $mode == "past") {
            continue;
        }
        //future modeでは過去のページはNG
        if (substr($page, $pagepattern_len, $datelength) < date("Y-m-d") && $mode == "future") {
            continue;
        }
        //view modeならall OK
        if (strlen(substr($page, $pagepattern_len)) == $datelength) {
            $pagelist[] = $page . "--";
        } else {
            $pagelist[] = $page;
        }
    }
    //ナビバー作成ここから
    $enc_pagename = rawurlencode(substr($pagepattern, 0, $pagepattern_len - 1));
    if ($page_YM != "") {
        //年月表示時
        $this_year = substr($page_YM, 0, 4);
        $this_month = substr($page_YM, 5, 2);
        //次月
        $next_year = $this_year;
        $next_month = $this_month + 1;
        if ($next_month > 12) {
            $next_year++;
            $next_month = 1;
        }
        $next_YM_T = $next_YM = sprintf("%04d-%02d", $next_year, $next_month);
        //前月
        $prev_year = $this_year;
        $prev_month = $this_month - 1;
        if ($prev_month < 1) {
            $prev_year--;
            $prev_month = 12;
        }
        $prev_YM_T = $prev_YM = sprintf("%04d-%02d", $prev_year, $prev_month);
        if ($cal2 == 1) {
            $prev_YM = sprintf("%04d%02d", $prev_year, $prev_month);
        }
        if ($mode == "past") {
            $right_YM = $prev_YM;
            $right_text = $prev_YM_T . "&gt;&gt;";
            $left_YM = $next_YM;
            $left_text = "&lt;&lt;" . $next_YM_T;
        } else {
            $left_YM = $prev_YM;
            $left_text = "&lt;&lt;" . $prev_YM_T;
            $right_YM = $next_YM;
            $right_text = $next_YM_T . "&gt;&gt;";
        }
    } else {
        //n件表示時
        if ($limit_base + $limit_pitch >= count($pagelist)) {
            $right_YM = "";
        } else {
            $right_base = $limit_base + $limit_pitch;
            $right_YM = $right_base . "*" . $limit_pitch;
            $right_text = "次の" . $limit_pitch . "件&gt;&gt;";
        }
        $left_base = $limit_base - $limit_pitch;
        if ($left_base >= 0) {
            $left_YM = $left_base . "*" . $limit_pitch;
            $left_text = "&lt;&lt;前の" . $limit_pitch . "件";
        } else {
            $left_YM = "";
        }
    }
    //リンク作成
    $_conf = rawurlencode($conf_name);
    if ($left_YM != "") {
        $left_link = "<a href=\"" . $script . "?plugin=weblog_viewer&amp;conf=" . $_conf . "&amp;date=" . $left_YM . "&amp;mode=" . $mode . "\">" . $left_text . "</a>";
    } else {
        $left_link = "";
    }
    if ($right_YM != "") {
        $right_link = "<a href=\"" . $script . "?plugin=weblog_viewer&amp;conf=" . $_conf . "&amp;date=" . $right_YM . "&amp;mode=" . $mode . "\">" . $right_text . "</a>";
    } else {
        $right_link = "";
    }
    //past modeは<<新 旧>> 他は<<旧 新>>
    $pageurl = $script . "?" . rawurlencode("[[" . strip_bracket($pagename) . "]]");
    $navi_bar .= "<table width =\"100%\" class=\"style_calendar_navi\"><tr><td align=\"left\" width=\"33%\">";
    $navi_bar .= $left_link;
    $navi_bar .= "</td><td align=\"center\" width=\"34%\">";
    $navi_bar .= make_pagelink($pagename, $options['NAME']);
    $navi_bar .= "</td><td align=\"right\" width=\"33%\">";
    $navi_bar .= $right_link;
    $navi_bar .= "</td></tr></table>";
    //ナビバー作成ここまで
    //*ここからインクルード開始
    //変数値退避
    $tmppage = $vars["page"];
    $_comment_no = $comment_no;
    $_h_excerpt = $h_excerpt;
    $_digest = $digest;
    //$tmp_related = $related;
    $return_body = "";
    //ナビバー
    $return_body .= $navi_bar;
    //まずソート
    if ($mode == "past") {
        //past modeでは新→旧
        rsort($pagelist);
    } else {
        //view mode と future mode では、旧→新
        sort($pagelist);
    }
    //$limit_pageの件数までインクルード
    $template_sources = weblog_load_template($conf_name, "list");
    if ($template_sources == FALSE) {
        return "[weblog_viewer]:" . sprintf($_weblog_msgs['err_msg_notemplate'], "{$conf_name}/list");
    }
    $tmp = $limit_base;
    $kensu = 0;
    $date_str = "";
    while ($tmp < $limit_page) {
        if (!isset($pagelist[$tmp])) {
            break;
        }
        $pagelist[$tmp] = preg_replace("/{-}-\$/", "", $pagelist[$tmp]);
        $page = "[[" . $pagelist[$tmp] . "]]";
        $vars["page"] = $post["page"] = $get["page"] = $page;
        //comment_no 初期化
        $comment_no = 0;
        $weblog_content = '';
        $content_flg = FALSE;
        $sources = get_source($page);
        $src = "";
        foreach ($sources as $source) {
            $src .= "{$source}";
        }
        $sources = $src;
        $w_author = "";
        if (preg_match("/(\\&weblog_field\\(__AUTHOR\\)\\{[^}]*\\}\\;)/mS", $sources, $match)) {
            $w_author = $match[1];
        }
        $w_timestamp = "";
        if (preg_match("/(\\&weblog_field\\(__TIMESTAMP\\)\\{[0-9]+\\}\\;)/m", $sources, $match)) {
            $w_timestamp = $match[1];
        }
        $w_subject = "";
        if (preg_match("/(\\&weblog_field\\(__SUBJECT\\)\\{[^}]+\\}\\;)/m", $sources, $match)) {
            $w_subject = $match[1];
        }
        $w_category = "";
        if (preg_match("/(\\&weblog_field\\(__CATEGORY,[^\\)]+\\)\\{[^}]+\\}\\;((\\[ )?\\[\\[.*\\]\\]( \\])?)+)/m", $sources, $match)) {
            $w_category = $match[1];
        }
        $w_edit = "";
        if (preg_match("/(\\&weblog_field\\(__EDIT\\)\\{[^}]+\\}\\;)/m", $sources, $match)) {
            $w_edit = $match[1];
        }
        $w_body = "";
        if (preg_match("/(#weblog_field\\(__BODY\\,Start\\)\\s*\n.*\n#weblog_field\\(__BODY\\,End\\)\n)/ms", $sources, $match)) {
            $w_body = $match[1];
        }
        $cmt_page = sprintf(strip_bracket($options['COMMENT_PREFIX']), strip_bracket($page));
        $count_of_page = plugin_weblog_viewer_comment_count($cmt_page);
        if (!$count_of_page) {
            $w_comment = "[ [[" . $_weblog_msgs['lbl_comment'] . "(0)>" . $page . "]] ]";
        } else {
            $w_comment = "[ [[" . $_weblog_msgs['lbl_comment'] . "({$count_of_page})>" . $cmt_page . "]] ]";
        }
        $w_trackback = "";
        if ($trackback) {
            //[[name>URL]]って使い方は正しいのかなぁ?本来は[[name:URL]]だけどこの場合は別Window表示になるし・・・
            //とりあえず、結果オーライで使ってみよう。
            $w_trackback = "[ [[TracBack(" . tb_count($page) . ")>{$script}?plugin=tb&__mode=view&tb_id=" . tb_get_id($page) . "]] ]";
        }
        $w_sources = $template_sources;
        $w_sources = preg_replace("/\\[__SUBJECT\\]/", $w_subject, $w_sources);
        $w_sources = preg_replace("/\\[__AUTHOR\\]/", $w_author, $w_sources);
        $w_sources = preg_replace("/\\[__TIMESTAMP\\]/", $w_timestamp, $w_sources);
        $w_sources = preg_replace("/\\[__BODY\\]/", $w_body, $w_sources);
        $w_sources = preg_replace("/\\[__CATEGORY\\]/", $w_category, $w_sources);
        $w_sources = preg_replace("/\\[__COMMENTCOUNT\\]/", $w_comment, $w_sources);
        $w_sources = preg_replace("/\\[__TRACKBACKCOUNT\\]/", $w_trackback, $w_sources);
        $weblog_content = convert_html($w_sources, false, false);
        if (!is_freeze($page, FALSE)) {
            $_page = preg_replace("/(.*\\/)?([0-9\\-]+)\$/", "\\2", strip_bracket($vars['page']));
            $edit_tag = "<a href=\"{$script}?plugin=weblog&mode=edit&conf={$conf_name}&page_name={$_page}\">";
            $edit_tag .= "<img src=\"image/edit.png\" alt=\"Edit\" title=\"Edit\" /></a>";
            $weblog_content = preg_replace("/\\[__EDIT\\]/", $edit_tag, $weblog_content);
        } else {
            $weblog_content = preg_replace("/\\[__EDIT\\]/", "", $weblog_content);
        }
        $body = "<div class=\"style_calendar_body\">" . $weblog_content . "</div>";
        if (ereg("([0-9]{4})-([0-9]{2})-([0-9]{2})-([0-9]{3})", $page, $match)) {
            $date0 = mktime(0, 0, 0, $match[2], $match[3], $match[1]);
            $date_str0 = date($_weblog_msgs['fmt_fullday'], $date0);
        }
        $date_str0 .= "(" . $_msg_week[date("w", $date0)] . ")";
        if ($date_str != $date_str0) {
            $date_str = $date_str0;
            if (ereg("(.*[0-9]{4}-[0-9]{2}-[0-9]{2})", strip_bracket($page), $match)) {
                $day_page = ":Weblog/Daily/" . $match[1];
            }
            $head = "<div class = \"style_calendar_date\">" . make_pagelink($day_page, $date_str) . "</div>\n";
        } else {
            $head = "";
        }
        $return_body .= $head . $body;
        $tmp++;
        $kensu++;
    }
    //表示データがあったらナビバー表示
    if ($kensu) {
        $return_body .= $navi_bar;
    }
    $vars["page"] = $post["page"] = $get["page"] = $tmppage;
    $comment_no = $_comment_no;
    $h_excerpt = $_h_excerpt;
    $digest = $_digest;
    return $return_body;
}
Example #11
0
 </div><!-- □ END id:attach -->
EOD;
}
$notes_tag = '';
if ($notes != '') {
    $notes_tag = <<<EOD
 <!-- ■BEGIN id:note -->
 <div id="note">
   {$notes}
 </div>
 <!-- □END id:note -->
EOD;
}
$trackback_tag = '';
if ($trackback) {
    $tb_id = tb_get_id($_page);
    $tb_cnt = tb_count($_page);
    $tb_label = $qm->replace("qhm_init.tb_label", $tb_cnt);
    $trackback_tag = <<<EOD
<div id="trackback"><!-- ■BEGIN id:trackback -->
<a href="{$script}?plugin=tb&amp;__mode=view&amp;tb_id={$tb_id}" onClick="OpenTrackback(this.href); return false">{$tb_label}</a> |
EOD;
}
$referer_tag = '';
if ($referer) {
    $ref_label = $qm->m['qhm_init']['ref_label'];
    $referer_tag = <<<EOD
<a href="{$script}?plugin=referer&amp;page={$r_page}">{$ref_label}</a>
</div><!-- □ END id:trackback -->
EOD;
}