function plugin_referer_action()
{
    global $vars, $referer;
    global $_referer_msg;
    // Setting: Off
    if (!$referer) {
        return array('msg' => '', 'body' => '');
    }
    if (isset($vars['page']) && $vars['page'] != '' && is_page($vars['page'])) {
        $sort = empty($vars['sort']) ? '0d' : $vars['sort'];
        return array('msg' => $_referer_msg['msg_H0_Refer'], 'body' => plugin_referer_body($vars['page'], $sort));
    }
    $pages = auth::get_existpages(TRACKBACK_DIR, '.ref');
    if (empty($pages)) {
        return array('msg' => '', 'body' => '');
    } else {
        $body = '';
        $sort = empty($vars['sort']) ? '0d' : $vars['sort'];
        foreach ($pages as $page) {
            $body .= '<h2>' . make_pagelink($page) . '</h2>';
            $body .= plugin_referer_body($page, $sort);
        }
        return array('msg' => 'referer list', 'body' => $body);
    }
}
function plugin_basename_body()
{
    global $vars;
    global $defaultpage;
    $options['page'] = isset($vars['page']) ? $vars['page'] : $defaultpage;
    foreach (func_get_args() as $arg) {
        list($key, $val) = array_pad(explode('=', $arg, 2), 2, TRUE);
        $options[$key] = $val;
    }
    if ($options['page'] == '') {
        return '';
    }
    $basename = htmlspecialchars(basename($options['page']));
    if ($options['nolink'] || !is_page($options['page'])) {
        $body = $basename;
    } else {
        global $link_compact;
        $tmp = $link_compact;
        $link_compact = 1;
        $link = make_pagelink($options['page'], $basename);
        $link_compact = $tmp;
        return $link;
    }
    return $body;
}
示例#3
0
 /**
  * Make a hyperlink to the page without passage
  *
  * @param string $page pagename
  * @param string $alias string to be displayed on the link
  * @param string $anchor anchor
  * @param string $refer reference pagename. query '&amp;refer=' is added. 
  * @param bool $isautolink flag if this link is created via autolink or not
  * @return string link html
  * @uses lib/make_link.php#make_pagelink
  */
 function make_pagelink_nopg($page, $alias = '', $anchor = '', $refer = '', $isautolink = FALSE)
 {
     // no passage
     global $show_passage;
     $tmp = $show_passage;
     $show_passage = 0;
     $link = make_pagelink($page, $alias, $anchor, $refer, $isautolink);
     $show_passage = $tmp;
     return $link;
 }
示例#4
0
function plugin_read_action()
{
    global $vars, $_title_invalidwn, $_msg_invalidiwn;
    $page = isset($vars['page']) ? $vars['page'] : '';
    if (is_page($page)) {
        // ページを表示
        check_readable($page, true, true);
        header_lastmod($page);
        return array('msg' => '', 'body' => '');
        // } else if (! PKWK_SAFE_MODE && is_interwiki($page)) {
    } else {
        if (!auth::check_role('safemode') && is_interwiki($page)) {
            return do_plugin_action('interwiki');
            // InterWikiNameを処理
        } else {
            if (is_pagename($page)) {
                $realpages = get_autoaliases($page);
                if (count($realpages) == 1) {
                    $realpage = $realpages[0];
                    if (is_page($realpage)) {
                        header('HTTP/1.0 301 Moved Permanently');
                        header('Location: ' . get_script_uri() . '?' . rawurlencode($realpage));
                        return;
                    } else {
                        // 存在しない場合、直接編集フォームに飛ばす // To avoid infinite loop
                        header('Location: ' . get_script_uri() . '?cmd=edit&page=' . rawurlencode($realpage));
                        return;
                    }
                } elseif (count($realpages) >= 2) {
                    $body = '<p>';
                    $body .= _('This pagename is an alias to') . '<br />';
                    foreach ($realpages as $realpage) {
                        $body .= make_pagelink($realpage) . '<br />';
                    }
                    $body .= '</p>';
                    return array('msg' => _('Redirect'), 'body' => $body);
                }
                $vars['cmd'] = 'edit';
                return do_plugin_action('edit');
                // 存在しないので、編集フォームを表示
            } else {
                // 無効なページ名
                return array('msg' => $_title_invalidwn, 'body' => str_replace('$1', htmlspecialchars($page), str_replace('$2', 'WikiName', $_msg_invalidiwn)));
            }
        }
    }
}
示例#5
0
function plugin_topicpath_inline()
{
    global $vars, $defaultpage, $topicpath;
    if (isset($topicpath) && $topicpath == false) {
        return '';
    }
    $page = isset($vars['page']) ? $vars['page'] : '';
    if ($page == '' || $page == $defaultpage) {
        return '';
    }
    $parts = explode('/', $page);
    $b_link = TRUE;
    if (PLUGIN_TOPICPATH_THIS_PAGE_DISPLAY) {
        $b_link = PLUGIN_TOPICPATH_THIS_PAGE_LINK;
    } else {
        array_pop($parts);
        // Remove the page itself
    }
    $topic_path = array();
    while (!empty($parts)) {
        $_landing = join('/', $parts);
        $element = htmlsc(array_pop($parts));
        if (!$b_link) {
            // This page ($_landing == $page)
            $b_link = TRUE;
            $topic_path[] = $element;
            // } else if (PKWK_READONLY && ! is_page($_landing)) {
        } else {
            if (Auth::check_role('readonly') && !is_page($_landing)) {
                // Page not exists
                $topic_path[] = $element;
            } else {
                // Page exists or not exists
                $topic_path[] = '<a href="' . get_page_uri($_landing) . '">' . $element . '</a>';
            }
        }
    }
    if (PLUGIN_TOPICPATH_TOP_DISPLAY) {
        $topic_path[] = make_pagelink($defaultpage, PLUGIN_TOPICPATH_TOP_LABEL);
    }
    return '<ul><li>' . join('</li><li>', array_reverse($topic_path)) . '</li></ul>';
}
function plugin_grepall_grep()
{
    global $vars, $defaultpage;
    $page = isset($vars['page']) ? $vars['page'] : $defultpage;
    $filter = isset($vars['filter']) ? $vars['filter'] : '';
    $grep = isset($vars['grep']) ? $vars['grep'] : '';
    // page lists
    if ($page !== '') {
        if (!is_page($page)) {
            $body = '<p>' . htmlspecialchars($page) . ' does not exist.</p>';
            return $body;
        }
        $pages = (array) $page;
    } else {
        $pages = get_existpages();
        if ($filter !== '') {
            $pages = preg_grep('/' . preg_quote($filter, '/') . '/', $pages);
        }
    }
    // grep
    $body = '';
    foreach ($pages as $page) {
        if (!check_readable($page)) {
            $body = '<p>' . htmlspecialchars($page) . ' is not readable.</p>';
            return $body;
        }
        $lines = get_source($page);
        $lines = preg_grep('/' . preg_quote($grep, '/') . '/', $lines);
        if (empty($lines)) {
            continue;
        }
        $contents = '';
        foreach ($lines as $i => $line) {
            $contents .= sprintf('%04d:', $i) . htmlspecialchars($line);
        }
        $body .= make_pagelink($page) . '<br />' . "\n";
        $body .= '<pre>' . htmlspecialchars($contents) . '</pre>';
    }
    return $body;
}
示例#7
0
function plugin_topicpath_inline()
{
    global $script, $vars, $defaultpage;
    $page = isset($vars['page']) ? $vars['page'] : '';
    if ($page == '' || $page == $defaultpage) {
        return '';
    }
    $parts = explode('/', $page);
    $b_link = TRUE;
    if (PLUGIN_TOPICPATH_THIS_PAGE_DISPLAY) {
        $b_link = PLUGIN_TOPICPATH_THIS_PAGE_LINK;
    } else {
        array_pop($parts);
        // Remove the page itself
    }
    $topic_path = array();
    while (!empty($parts)) {
        $_landing = join('/', $parts);
        $landing = rawurlencode($_landing);
        $element = htmlsc(array_pop($parts));
        if (!$b_link) {
            // This page ($_landing == $page)
            $b_link = TRUE;
            $topic_path[] = $element;
        } else {
            if (PKWK_READONLY && !is_page($_landing)) {
                // Page not exists
                $topic_path[] = $element;
            } else {
                // Page exists or not exists
                $topic_path[] = '<a href="' . $script . '?' . $landing . '">' . $element . '</a>';
            }
        }
    }
    if (PLUGIN_TOPICPATH_TOP_DISPLAY) {
        $topic_path[] = make_pagelink($defaultpage, PLUGIN_TOPICPATH_TOP_LABEL);
    }
    return join(PLUGIN_TOPICPATH_TOP_SEPARATOR, array_reverse($topic_path));
}
示例#8
0
function plugin_diff_delete($page)
{
    global $script, $vars;
    global $_title_diff_delete, $_msg_diff_deleted;
    global $_msg_diff_adminpass, $_btn_delete, $_msg_invalidpass;
    $filename = DIFF_DIR . encode($page) . '.txt';
    $body = '';
    if (!is_pagename($page)) {
        $body = 'Invalid page name';
    }
    if (!file_exists($filename)) {
        $body = make_pagelink($page) . '\'s diff seems not found';
    }
    if ($body) {
        return array('msg' => $_title_diff_delete, 'body' => $body);
    }
    if (isset($vars['pass'])) {
        if (pkwk_login($vars['pass'])) {
            unlink($filename);
            return array('msg' => $_title_diff_delete, 'body' => str_replace('$1', make_pagelink($page), $_msg_diff_deleted));
        } else {
            $body .= '<p><strong>' . $_msg_invalidpass . '</strong></p>' . "\n";
        }
    }
    $s_page = htmlsc($page);
    $body .= <<<EOD
<p>{$_msg_diff_adminpass}</p>
<form action="{$script}" method="post">
 <div>
  <input type="hidden"   name="cmd"    value="diff" />
  <input type="hidden"   name="page"   value="{$s_page}" />
  <input type="hidden"   name="action" value="delete" />
  <input type="password" name="pass"   size="12" />
  <input type="submit"   name="ok"     value="{$_btn_delete}" />
 </div>
</form>
EOD;
    return array('msg' => $_title_diff_delete, 'body' => $body);
}
 /**
  * Clean Table of Contents Cache Files
  */
 function clean_cache()
 {
     set_time_limit(0);
     global $vars;
     $page = isset($vars['page']) ? $vars['page'] : '';
     if ($page != '') {
         $toc = new PluginSonotsToc();
         $file = $toc->syntax['cachefile']($page);
         @unlink($file);
         if (exec_page($page, '/^#contentsx/')) {
             $body = 'Recreated a cache of ';
         } else {
             $body = 'No #contentsx in ';
         }
         $body .= make_pagelink($page);
     } else {
         $toc = new PluginSonotsToc();
         $file = $toc->syntax['cachefile']('hoge');
         $suffix = substr($file, strrpos($file, '.'));
         // remove all files
         $files = sonots::get_existfiles(CACHE_DIR, $suffix);
         foreach ($files as $file) {
             unlink($file);
         }
         // execute all pages
         $exec_pages = sonots::exec_existpages('', '/^#contentsx/');
         $links = array_map('make_pagelink', $exec_pages);
         $body = '<p>Following pages were executed to assure:</p>' . '<p>' . implode("<br />\n", $links) . '</p>';
     }
     return $body;
 }
示例#10
0
function plugin_tracker_getlist($page, $refer, $config_name, $list, $order = '', $limit = NULL)
{
    $config = new Config('plugin/tracker/' . $config_name);
    if (!$config->read()) {
        return "<p>config file '" . htmlsc($config_name) . "' is not exist.";
    }
    $config->config_name = $config_name;
    if (!is_page($config->page . '/' . $list)) {
        return "<p>config file '" . make_pagelink($config->page . '/' . $list) . "' not found.</p>";
    }
    $list =& new Tracker_list($page, $refer, $config, $list);
    $list->sort($order);
    return $list->toString($limit);
}
示例#11
0
function plugin_table_edit2_action()
{
    global $vars, $post, $auth_users, $_string;
    $table_num = $vars['table_num'];
    $page = isset($vars['refer']) ? $vars['refer'] : null;
    if (empty($page)) {
        Utility::dieMessage('Page name is null.');
    }
    $wiki = Factory::Wiki($page);
    if (is_freeze($page)) {
        check_editable($page, true, true);
    }
    if ($wiki->isFreezed()) {
        $wiki->checkEditable(true);
    }
    //	Cancel
    $anchr_jump = PLUGIN_TABLE_EDIT2_ANCHR_JUMP ? '#TableEdit2TableNumber' . $table_num : '';
    if (isset($vars['cancel'])) {
        Utility::redirect($wiki->uri() . $anchr_jump);
        exit;
    }
    $line_count = 1;
    $table_sub_num = 1;
    //td
    $table_sub_num_chk = 1;
    //td
    $setting = 0;
    $import = $export = $csv_cancel = 0;
    $edit_mod = isset($vars['edit_mod']) ? $vars['edit_mod'] : '';
    $td_edit = $edit_mod == 't_edit_td' || $edit_mod == 'td' ? 1 : 0;
    $tr_edit = $edit_mod == 't_edit' || $edit_mod == 'tr' ? 1 : 0;
    $t_edit = $edit_mod == 't_edit_td' || $edit_mod == 't_edit' ? 1 : 0;
    $edit_show = $edit_mod == 'tdshow' || $edit_mod == 'show' ? 1 : 0;
    // Petit SPAM Check (Client(Browser)-Server Ticket Check)
    $spam = FALSE;
    if (!function_exists('honeypot_write') && $t_edit) {
        $spam = plugin_table_edit2_spam($post['encode_hint']);
    }
    if ($spam) {
        return plugin_table_edit2_honeypot();
    }
    if (Auth::check_role('readonly')) {
        die_message('PKWK_READONLY prohibits editing');
    }
    if (PLUGIN_TABLE_EDIT2_HTTP_REFERER) {
        if (!function_exists('path_check')) {
            if (!preg_match('/^(' . $script_uri . ')/', $_SERVER['HTTP_REFERER'])) {
                return;
            }
        } else {
            if (!path_check($script_uri, $_SERVER['HTTP_REFERER'])) {
                return;
            }
        }
    }
    if ($edit_mod === 'setting') {
        $set = new TableEdit2SettingWrite($vars);
        if (!$set->sc) {
            return $set->error;
        }
        $setting = 1;
        unset($vars['table_mod']);
    }
    $notimestamp = FALSE;
    if (isset($vars['csv_mod']) || isset($vars['ex_cancel']) || isset($vars['im_cancel']) || isset($vars['set_csv']) || isset($vars['csv_back'])) {
        $csv = new TableEdit2CsvAction();
        if (isset($vars['csv_mod']) && $vars['csv_mod'] === 'import') {
            $csv->csv_import($vars);
            $import = 1;
        } else {
            if (isset($vars['csv_mod']) && $vars['csv_mod'] === 'export') {
                $export = 1;
                $csv_export_data = array();
            } else {
                if (isset($vars['ex_cancel']) || isset($vars['im_cancel'])) {
                    $csv_cancel = 1;
                    $notimestamp = TRUE;
                } else {
                    if (isset($vars['set_csv'])) {
                        $set_csv = 1;
                        $notimestamp = TRUE;
                    } else {
                        if (isset($vars['csv_back'])) {
                            if (PLUGIN_TABLE_EDIT2_CSV_UNLINK) {
                                $con = new TableEdit2CsvConversion($page, array('name' => $vars['file_name']));
                                unlink($con->filename);
                                unlink($con->logname);
                            }
                            Utility::redirect($wiki->uri());
                            exit;
                        } else {
                            return array('msg' => 'csv error', 'body' => 'csv option error');
                            // . join("\n", $csv_data)
                        }
                    }
                }
            }
        }
    }
    if (isset($vars['table_mod'])) {
        $chg = new TableEdit2TableMod($vars['table_mod']);
    }
    if ($td_edit || $tr_edit) {
        $edit = new TableEdit2Edit($vars);
    }
    if ($edit_show) {
        $show = new TableEdit2Show($vars, $page);
    }
    $args = get_source($page);
    static $count = 0;
    $source_s = '';
    $body = '';
    $row_title = 0;
    $td_title_count = 0;
    if ($td_edit || $tr_edit || $setting || $import) {
        $notimestamp = isset($vars['notimestamp']) ? TRUE : FALSE;
    }
    foreach ($wiki->get() as $args_key => $args_line) {
        if (preg_match('/^#([^\\(\\{]+)(?:\\(([^\\r]*)\\))?(\\{*)/', $args_line, $matches) !== FALSE) {
            if (isset($matches[1]) && ($matches[1] == 'table_edit2' || $matches[1] == "table_edit2\n")) {
                $table_find = 1;
                $count++;
                if ($line_count === 1 && $count == $table_num) {
                    if (preg_match('/auth_check[=_](on|off)/i', $matches[2], $auth_check)) {
                        if ($auth_check[1] == 'on') {
                            if (!auth::auth_pw($auth_users)) {
                                $user = TableEdit2Auth::basic_auth();
                                if (empty($user)) {
                                    return;
                                }
                            }
                        }
                    } else {
                        check_editable($page, true, true);
                    }
                    if ($setting) {
                        $args_line = $set->plugin_set_opt($matches[3]);
                    }
                    if ($import) {
                        $args_line = $csv->import_data_set($matches[2], $matches[3]);
                    }
                    if (isset($vars['ex_cancel'])) {
                        $args_line = $csv->cancel($matches[2], $matches[3], 'export');
                    }
                    if (isset($vars['im_cancel'])) {
                        $args_line = $csv->cancel($matches[2], $matches[3], 'import');
                    }
                    if (isset($set_csv)) {
                        $args_line = $csv->set_csv_opt($matches[2], $matches[3], $vars['set_csv']);
                    }
                    if ($edit_mod == 'tdshow') {
                        //tdshow - td_title - 06.11.11
                        if (preg_match('/title_c=(\\d+)/i', $matches[2], $match_title)) {
                            $td_title_count = $match_title[1] - 1;
                        }
                    }
                    if ($edit_mod == 'show') {
                        //show				header
                        if (preg_match('/title_r=(\\d+)/i', $matches[2], $m_row_title)) {
                            $row_title = $m_row_title[1];
                        }
                    }
                    if ($edit_show) {
                        $show->text_type($matches[2]);
                    }
                    if (isset($vars['table_mod'])) {
                        //table_mod
                        $notimestamp = TRUE;
                        $args_line = $chg->table_mod_chg($matches, $args_line);
                    }
                }
                $end_line = strlen($matches[3]);
            }
        }
        if (isset($end_line) && preg_match('/^\\}{' . $end_line . '}/', $args_line) || !isset($end_line)) {
            $table_find = 0;
        }
        if ($table_find && $table_num == $count && !isset($vars['table_mod']) && !$setting && !$import) {
            $table_sub_num_count_chk = 0;
            $table_f_chose = preg_match('/^\\|(.+)\\|([hHfFcC]?)$/', $args_line, $match_line) ? 1 : 0;
            if ($args_line[0] == ',' && $args_line != ',') {
                $table_f_chose = 2;
            }
            if ($td_edit || $tr_edit) {
                $edit->chose = $table_f_chose;
            }
            if ($table_f_chose) {
                if ($table_f_chose === 1) {
                    $match_t = explode("|", $match_line[1]);
                } elseif ($table_f_chose === 2) {
                    $match_t = csv_explode(',', substr(str_replace("\n", '', $args_line), 1));
                    $match_line = array(1 => join(',', $match_t), 2 => '');
                }
                if ($export) {
                    $csv_export_data[] = $match_line[1];
                }
                if (isset($vars['table_sub_num']) && $table_sub_num === $vars['table_sub_num'] && $table_sub_num_chk) {
                    //td 06.09.18
                    $show->chk_table_sub_first_line = $line_count;
                    $table_sub_num_chk = 0;
                }
                if (isset($vars['line_count']) && $vars['line_count'] === $line_count || strtolower($match_line[2]) === 'h' || $edit_mod == 'tdshow' || $td_edit || $row_title) {
                    //					$match_t = explode("|", $match_line[1]);
                    if ($edit_mod == 'tdshow') {
                        //tdshow - td_title - 06.11.11
                        $show->td_title[$line_count] = $match_t[$td_title_count];
                    }
                }
                if ($edit_mod == 'show') {
                    //show				header
                    if ($match_line[2] == 'h' && !$row_title) {
                        $show->table_header($match_t);
                    }
                    if ($line_count == $row_title) {
                        $show->table_header($match_t);
                    }
                }
                if ($vars['line_count'] == $line_count || $table_sub_num == $vars['table_sub_num']) {
                    // textarea 06.11.12
                    if ($edit_show) {
                        if ($show->t_type == 'textarea') {
                            $show->text_type_textarea(count($match_t));
                        }
                    }
                }
                if ($td_edit && $table_sub_num_chk == 0 && $table_sub_num == $vars['table_sub_num']) {
                    $source_s .= $edit->td_edit($match_t) . $match_line[2] . "\n";
                    $table_sub_num_count_chk = 1;
                } else {
                    if (isset($vars['line_count']) && $vars['line_count'] == $line_count && !$td_edit) {
                        if ($tr_edit) {
                            //t_edit tr_add
                            if (isset($vars['add_show']) && $vars['add_show'] === 1) {
                                $source_s .= $args_line;
                                if ($edit->chose !== 2) {
                                    $edit->chk_csv_source($args, $args_key);
                                }
                            }
                            $source_s .= $edit->tr_edit($args_line, $match_t, $match_line[2]);
                        } else {
                            if ($edit_show) {
                                //show or tdshow
                                $show->line_count = $line_count;
                                $body = $show->show_mod($match_t);
                            }
                        }
                    } else {
                        if ($edit_mod == 'tdshow') {
                            //tdshow and edit_td
                            $show->cells[$line_count] = $match_t;
                        }
                        $table_sub_num_count_chk = 1;
                        //td06.09.18
                        $source_s .= $args_line;
                    }
                }
                $line_count++;
            } else {
                if ($table_sub_num_count_chk == 1 && substr($args_line, 0, 2) != '//') {
                    //td
                    $table_sub_num++;
                    $table_sub_num_count_chk = 0;
                }
                $source_s .= $args_line;
            }
        } else {
            $source_s .= $args_line . "\n";
        }
    }
    if ($export) {
        return $csv->csv_export($vars, $csv_export_data);
    }
    $collision = 0;
    if ($tr_edit || $td_edit) {
        if (Factory::Wiki($vars['refer'])->digest() !== $vars['digest']) {
            global $_string, $_title;
            $title = $_title['collided'];
            $body = $_string['msg_collided_auto'] . make_pagelink($vars['refer']);
            $collision = 1;
        }
    }
    if ($tr_edit || $td_edit || isset($vars['table_mod']) || $setting || $import || $csv_cancel || isset($set_csv)) {
        $source = explode("\n", $source_s);
        array_pop($source);
        // 末尾に余計な改行が入るので削除
        //		var_dump($source);
        //		die;
        $wiki->set(explode("\n", $source_s), $notimestamp);
    }
    $get['page'] = $post['page'] = $vars['page'] = $page;
    if ($collision) {
        return array('msg' => $title, 'body' => $body);
    }
    if ($edit_show) {
        return array('msg' => $show->title, 'body' => $body);
    }
    //header('Location: ' . $script_uri . '?' . rawurlencode($page) . $anchr_jump);
    Utility::redirect($wiki->uri() . $anchr_jump);
    exit;
}
function plugin_commentx_write()
{
    global $script, $vars, $now;
    global $_no_name;
    //	global $_msg_comment_collided, $_title_comment_collided, $_title_updated;
    $_title_updated = _("\$1 was updated");
    $_title_comment_collided = _("On updating  \$1, a collision has occurred.");
    $_msg_comment_collided = _("It seems that someone has already updated the page you were editing.<br />") . _("The comment was added, alhough it may be inserted in the wrong position.<br />");
    if (!isset($vars['msg'])) {
        return array('msg' => '', 'body' => '');
    }
    // Do nothing
    if (preg_match(PLUGIN_COMMENTX_NGWORD, $vars['msg'])) {
        return array('msg' => '', 'body' => '');
    }
    // Validate
    if (is_spampost(array('msg'))) {
        return plugin_commentx_honeypot();
    }
    $vars['msg'] = preg_replace('/\\s+$/', "", $vars['msg']);
    // Cut last LF
    if (PLUGIN_COMMENTX_LINE_BREAK) {
        // Convert linebreaks into pukiwiki's linebreaks &br;
        $vars['msg'] = str_replace("\n", "&br;\n", $vars['msg']);
    } else {
        // Replace empty lines into #br
        $vars['msg'] = preg_replace('/^\\s*\\n/m', "#br\n", $vars['msg']);
    }
    $head = '';
    $match = array();
    if (preg_match('/^(-{1,2})-*\\s*(.*)/', $vars['msg'], $match)) {
        $head =& $match[1];
        $vars['msg'] =& $match[2];
    }
    if ($vars['msg'] == '') {
        return array('msg' => '', 'body' => '');
    }
    // Do nothing
    $comment = str_replace('$msg', $vars['msg'], PLUGIN_COMMENTX_FORMAT_MSG);
    list($nick, $vars['name'], $disabled) = plugin_commentx_get_nick();
    if (isset($vars['name']) || $vars['nodate'] != '1') {
        $_name = !isset($vars['name']) || $vars['name'] == '' ? $_no_name : $vars['name'];
        $_name = $_name == '' ? '' : str_replace('$name', $_name, PLUGIN_COMMENTX_FORMAT_NAME);
        $_now = $vars['nodate'] == '1' ? '' : str_replace('$now', $now, PLUGIN_COMMENTX_FORMAT_NOW);
        $comment = str_replace("MSG", $comment, PLUGIN_COMMENTX_FORMAT_STRING);
        $comment = str_replace("NAME", $_name, $comment);
        $comment = str_replace("NOW", $_now, $comment);
    }
    $comment = '-' . $head . ' ' . $comment;
    $postdata = '';
    $comment_no = 0;
    $above = isset($vars['above']) && $vars['above'] == '1';
    foreach (get_source($vars['refer']) as $line) {
        if (!$above) {
            $postdata .= $line;
        }
        if (preg_match('/^#commentx/i', $line) && $comment_no++ == $vars['comment_no']) {
            if ($above) {
                $postdata = rtrim($postdata) . "\n" . $comment . "\n" . "\n";
                // Insert one blank line above #commment, to avoid indentation
            } else {
                $postdata = rtrim($postdata) . "\n" . $comment . "\n";
                // Insert one blank line below #commment
            }
        }
        if ($above) {
            $postdata .= $line;
        }
    }
    $title = $_title_updated;
    $body = '';
    if (md5(@join('', get_source($vars['refer']))) != $vars['digest']) {
        $title = $_title_comment_collided;
        $body = $_msg_comment_collided . make_pagelink($vars['refer']);
    }
    page_write($vars['refer'], $postdata);
    $retvars['msg'] = $title;
    $retvars['body'] = $body;
    if ($vars['refpage']) {
        header("Location: {$script}?" . rawurlencode($vars['refpage']));
        exit;
    }
    $vars['page'] = $vars['refer'];
    return $retvars;
}
示例#13
0
 function toString($flat)
 {
     global $_title_cannotread;
     if (!$this->func->check_readable($this->page, FALSE, FALSE)) {
         return str_replace('$1', make_pagelink($this->page), $_title_cannotread);
     } else {
         if ($flat) {
             return $this->to_flat();
         }
     }
     $ret = '';
     $files = array_keys($this->files);
     sort($files);
     foreach ($files as $file) {
         $_files = array();
         foreach (array_keys($this->files[$file]) as $age) {
             $_files[$age] = $this->files[$file][$age]->toString(FALSE, TRUE);
         }
         if (!isset($_files[0])) {
             $_files[0] = htmlspecialchars($file);
         }
         ksort($_files);
         $_file = $_files[0];
         unset($_files[0]);
         $ret .= " <li>{$_file}\n";
         if (count($_files)) {
             $ret .= "<ul>\n<li>" . join("</li>\n<li>", $_files) . "</li>\n</ul>\n";
         }
         $ret .= " </li>\n";
     }
     return $this->func->make_pagelink($this->page) . "\n<ul>\n{$ret}</ul>\n";
 }
示例#14
0
function plugin_calendar2_convert()
{
    global $script, $vars, $post, $get, $weeklabels, $WikiName, $BracketName;
    global $_calendar2_plugin_edit, $_calendar2_plugin_empty;
    $date_str = get_date('Ym');
    $base = strip_bracket($vars['page']);
    $today_view = TRUE;
    if (func_num_args()) {
        $args = func_get_args();
        foreach ($args as $arg) {
            if (is_numeric($arg) && strlen($arg) == 6) {
                $date_str = $arg;
            } else {
                if ($arg == 'off') {
                    $today_view = FALSE;
                } else {
                    $base = strip_bracket($arg);
                }
            }
        }
    }
    if ($base == '*') {
        $base = '';
        $prefix = '';
    } else {
        $prefix = $base . '/';
    }
    $r_base = rawurlencode($base);
    $s_base = htmlsc($base);
    $r_prefix = rawurlencode($prefix);
    $s_prefix = htmlsc($prefix);
    $yr = substr($date_str, 0, 4);
    $mon = substr($date_str, 4, 2);
    if ($yr != get_date('Y') || $mon != get_date('m')) {
        $now_day = 1;
        $other_month = 1;
    } else {
        $now_day = get_date('d');
        $other_month = 0;
    }
    $today = getdate(mktime(0, 0, 0, $mon, $now_day, $yr) - LOCALZONE + ZONETIME);
    $m_num = $today['mon'];
    $d_num = $today['mday'];
    $year = $today['year'];
    $f_today = getdate(mktime(0, 0, 0, $m_num, 1, $year) - LOCALZONE + ZONETIME);
    $wday = $f_today['wday'];
    $day = 1;
    $m_name = $year . '.' . $m_num;
    $y = substr($date_str, 0, 4) + 0;
    $m = substr($date_str, 4, 2) + 0;
    $prev_date_str = $m == 1 ? sprintf('%04d%02d', $y - 1, 12) : sprintf('%04d%02d', $y, $m - 1);
    $next_date_str = $m == 12 ? sprintf('%04d%02d', $y + 1, 1) : sprintf('%04d%02d', $y, $m + 1);
    $ret = '';
    if ($today_view) {
        $ret = '<table border="0" summary="calendar frame">' . "\n" . ' <tr>' . "\n" . '  <td valign="top">' . "\n";
    }
    $ret .= <<<EOD
   <table class="style_calendar" cellspacing="1" width="150" border="0" summary="calendar body">
    <tr>
     <td class="style_td_caltop" colspan="7">
      <a href="{$script}?plugin=calendar2&amp;file={$r_base}&amp;date={$prev_date_str}">&lt;&lt;</a>
      <strong>{$m_name}</strong>
      <a href="{$script}?plugin=calendar2&amp;file={$r_base}&amp;date={$next_date_str}">&gt;&gt;</a>
EOD;
    if ($prefix) {
        $ret .= "\n" . '      <br />[<a href="' . $script . '?' . $r_base . '">' . $s_base . '</a>]';
    }
    $ret .= "\n" . '     </td>' . "\n" . '    </tr>' . "\n" . '    <tr>' . "\n";
    foreach ($weeklabels as $label) {
        $ret .= '     <td class="style_td_week">' . $label . '</td>' . "\n";
    }
    $ret .= '    </tr>' . "\n" . '    <tr>' . "\n";
    // Blank
    for ($i = 0; $i < $wday; $i++) {
        $ret .= '     <td class="style_td_blank">&nbsp;</td>' . "\n";
    }
    while (checkdate($m_num, $day, $year)) {
        $dt = sprintf('%4d-%02d-%02d', $year, $m_num, $day);
        $page = $prefix . $dt;
        $r_page = rawurlencode($page);
        $s_page = htmlsc($page);
        if ($wday == 0 && $day > 1) {
            $ret .= '    </tr>' . "\n" . '    <tr>' . "\n";
        }
        $style = 'style_td_day';
        // Weekday
        if (!$other_month && $day == $today['mday'] && $m_num == $today['mon'] && $year == $today['year']) {
            // Today
            $style = 'style_td_today';
        } else {
            if ($wday == 0) {
                // Sunday
                $style = 'style_td_sun';
            } else {
                if ($wday == 6) {
                    //  Saturday
                    $style = 'style_td_sat';
                }
            }
        }
        if (is_page($page)) {
            $link = '<a href="' . $script . '?' . $r_page . '" title="' . $s_page . '"><strong>' . $day . '</strong></a>';
        } else {
            if (PKWK_READONLY) {
                $link = '<span class="small">' . $day . '</small>';
            } else {
                $link = $script . '?cmd=edit&amp;page=' . $r_page . '&amp;refer=' . $r_base;
                $link = '<a class="small" href="' . $link . '" title="' . $s_page . '">' . $day . '</a>';
            }
        }
        $ret .= '     <td class="' . $style . '">' . "\n" . '      ' . $link . "\n" . '     </td>' . "\n";
        ++$day;
        $wday = ++$wday % 7;
    }
    if ($wday > 0) {
        while ($wday++ < 7) {
            // Blank
            $ret .= '     <td class="style_td_blank">&nbsp;</td>' . "\n";
        }
    }
    $ret .= '    </tr>' . "\n" . '   </table>' . "\n";
    if ($today_view) {
        $tpage = $prefix . sprintf('%4d-%02d-%02d', $today['year'], $today['mon'], $today['mday']);
        $r_tpage = rawurlencode($tpage);
        if (is_page($tpage)) {
            $_page = $vars['page'];
            $get['page'] = $post['page'] = $vars['page'] = $tpage;
            $str = convert_html(get_source($tpage));
            $str .= '<hr /><a class="small" href="' . $script . '?cmd=edit&amp;page=' . $r_tpage . '">' . $_calendar2_plugin_edit . '</a>';
            $get['page'] = $post['page'] = $vars['page'] = $_page;
        } else {
            $str = sprintf($_calendar2_plugin_empty, make_pagelink(sprintf('%s%4d-%02d-%02d', $prefix, $today['year'], $today['mon'], $today['mday'])));
        }
        $ret .= '  </td>' . "\n" . '  <td valign="top">' . $str . '</td>' . "\n" . ' </tr>' . "\n" . '</table>' . "\n";
    }
    return $ret;
}
 function get_title($inclpage, $titlestr, $option = true)
 {
     global $fixed_heading_edited;
     $anchorlink = ' ' . PluginIncludex::get_page_anchorlink($inclpage);
     $editlink = $fixed_heading_edited ? ' ' . PluginIncludex::get_page_editlink($inclpage) : '';
     if ($titlestr == '') {
         //return $ret = '<div class="' .$this->plugin . '">' . $anchorlink . '</div>';
         return '';
     }
     switch ($option) {
         case false:
             $ret = '<h1 class="includex">' . $titlestr . $editlink . $anchorlink . '</h1>';
             break;
         case true:
         default:
             $link = make_pagelink($inclpage, $titlestr);
             $ret = '<h1 class="includex">' . $link . $editlink . $anchorlink . '</h1>';
             break;
     }
     return $ret;
 }
示例#16
0
function plugin_calendar2_convert()
{
    $qt = get_qt();
    //---- キャッシュのための処理を登録 -----
    if ($qt->create_cache) {
        $args = func_get_args();
        return $qt->get_dynamic_plugin_mark(__FUNCTION__, $args);
    }
    //------------------------------------
    global $script, $vars, $post, $get, $weeklabels, $WikiName, $BracketName;
    $qm = get_qm();
    $date_str = get_date('Ym');
    $base = strip_bracket($vars['page']);
    $today_view = TRUE;
    if (func_num_args()) {
        $args = func_get_args();
        foreach ($args as $arg) {
            if (is_numeric($arg) && strlen($arg) == 6) {
                $date_str = $arg;
            } else {
                if ($arg == 'off') {
                    $today_view = FALSE;
                } else {
                    $base = strip_bracket($arg);
                }
            }
        }
    }
    if ($base == '*') {
        $base = '';
        $prefix = '';
    } else {
        $prefix = $base . '/';
    }
    $r_base = rawurlencode($base);
    $s_base = htmlspecialchars($base);
    $r_prefix = rawurlencode($prefix);
    $s_prefix = htmlspecialchars($prefix);
    $yr = substr($date_str, 0, 4);
    $mon = substr($date_str, 4, 2);
    if ($yr != get_date('Y') || $mon != get_date('m')) {
        $now_day = 1;
        $other_month = 1;
    } else {
        $now_day = get_date('d');
        $other_month = 0;
    }
    $today = getdate(mktime(0, 0, 0, $mon, $now_day, $yr) - LOCALZONE + ZONETIME);
    $m_num = $today['mon'];
    $d_num = $today['mday'];
    $year = $today['year'];
    $f_today = getdate(mktime(0, 0, 0, $m_num, 1, $year) - LOCALZONE + ZONETIME);
    $wday = $f_today['wday'];
    $day = 1;
    $m_name = $year . '.' . $m_num;
    $y = substr($date_str, 0, 4) + 0;
    $m = substr($date_str, 4, 2) + 0;
    $prev_date_str = $m == 1 ? sprintf('%04d%02d', $y - 1, 12) : sprintf('%04d%02d', $y, $m - 1);
    $next_date_str = $m == 12 ? sprintf('%04d%02d', $y + 1, 1) : sprintf('%04d%02d', $y, $m + 1);
    $ret = '';
    $today_view_str = '';
    if ($today_view) {
        $ret = '<table border="0" summary="calendar frame">' . "\n" . ' <tr>' . "\n" . '  <td valign="top">' . "\n";
    } else {
        $today_view_str = "&amp;view=off";
    }
    $ret .= <<<EOD
   <table class="style_calendar" cellspacing="1" border="0" summary="calendar body">
    <tr>
     <td class="style_td_caltop text-center" colspan="7">
      <a href="{$script}?plugin=calendar2&amp;file={$r_base}&amp;date={$prev_date_str}{$today_view_str}">&lt;&lt;</a>
      <strong>{$m_name}</strong>
      <a href="{$script}?plugin=calendar2&amp;file={$r_base}&amp;date={$next_date_str}{$today_view_str}">&gt;&gt;</a>
EOD;
    if ($prefix) {
        $ret .= "\n" . '      <br />[<a href="' . $script . '?' . $r_base . '">' . $s_base . '</a>]';
    }
    $ret .= "\n" . '     </td>' . "\n" . '    </tr>' . "\n" . '    <tr>' . "\n";
    foreach ($weeklabels as $label) {
        $ret .= '     <td class="style_td_week text-center" width="30" height="30">' . $label . '</td>' . "\n";
    }
    $ret .= '    </tr>' . "\n" . '    <tr>' . "\n";
    // Blank
    for ($i = 0; $i < $wday; $i++) {
        $ret .= '     <td class="style_td_blank">&nbsp;</td>' . "\n";
    }
    while (checkdate($m_num, $day, $year)) {
        $dt = sprintf('%4d-%02d-%02d', $year, $m_num, $day);
        $page = $prefix . $dt;
        $r_page = rawurlencode($page);
        $s_page = htmlspecialchars($page);
        if ($wday == 0 && $day > 1) {
            $ret .= '    </tr>' . "\n" . '    <tr>' . "\n";
        }
        $style = 'style_td_day text-right';
        // Weekday
        if (!$other_month && $day == $today['mday'] && $m_num == $today['mon'] && $year == $today['year']) {
            // Today
            $style = 'style_td_today text-right alert-success';
        } else {
            if ($wday == 0) {
                // Sunday
                $style = 'style_td_sun text-right alert-danger';
            } else {
                if ($wday == 6) {
                    //  Saturday
                    $style = 'style_td_sat text-right alert-info';
                }
            }
        }
        if (is_page($page)) {
            $link = '<a href="' . $script . '?' . $r_page . '" title="' . $s_page . '"><strong style="">' . $day . '</strong></a>';
            $style .= ' btn-warning';
        } else {
            if (PKWK_READONLY) {
                $link = '<span class="small">' . $day . '</span>';
            } else {
                $editable = check_editable($page, FALSE, FALSE);
                // 管理ログイン後
                if ($editable === TRUE) {
                    $link = $script . '?cmd=edit&amp;page=' . $r_page . '&amp;refer=' . $r_base;
                    $link = '<a class="small" href="' . $link . '" title="' . $s_page . '">' . $day . '</a>';
                } else {
                    $link = '<span class="small">' . $day . '</span>';
                }
            }
        }
        $ret .= '     <td class="' . $style . '">' . "\n" . '      ' . $link . "\n" . '     </td>' . "\n";
        ++$day;
        $wday = ++$wday % 7;
    }
    if ($wday > 0) {
        while ($wday++ < 7) {
            // Blank
            $ret .= '     <td class="style_td_blank">&nbsp;</td>' . "\n";
        }
    }
    $ret .= '    </tr>' . "\n" . '   </table>' . "\n";
    if ($today_view) {
        $tpage = $prefix . sprintf('%4d-%02d-%02d', $today['year'], $today['mon'], $today['mday']);
        $r_tpage = rawurlencode($tpage);
        if (is_page($tpage)) {
            $_page = $vars['page'];
            $get['page'] = $post['page'] = $vars['page'] = $tpage;
            $str = convert_html(get_source($tpage));
            $str .= '<hr /><a class="small" href="' . $script . '?cmd=edit&amp;page=' . $r_tpage . '">' . $qm->m['plg_calendar2']['edit'] . '</a>';
            $get['page'] = $post['page'] = $vars['page'] = $_page;
        } else {
            $str = $qm->replace('plg_calendar2.empty', make_pagelink(sprintf('%s%4d-%02d-%02d', $prefix, $today['year'], $today['mon'], $today['mday'])));
        }
        $ret .= '  </td>' . "\n" . '  <td valign="top">' . $str . '</td>' . "\n" . ' </tr>' . "\n" . '</table>' . "\n";
    }
    return '<div class="qhm-plugin-calendar2">' . $ret . '</div>';
}
示例#17
0
function plugin_new_inline()
{
    global $vars, $_plugin_new_elapses;
    $retval = '';
    $args = func_get_args();
    $date = strip_autolink(array_pop($args));
    // {date} always exists
    if ($date !== '') {
        // Show 'New!' message by the time of the $date string
        if (func_num_args() > 2) {
            return '&new([nodate]){date};';
        }
        $timestamp = strtotime($date);
        if ($timestamp === -1) {
            return '&new([nodate]){date}: Invalid date string;';
        }
        $timestamp -= ZONETIME;
        $retval = in_array('nodate', $args) ? '' : htmlsc($date);
    } else {
        // Show 'New!' message by the timestamp of the page
        if (func_num_args() > 3) {
            return '&new(pagename[,nolink]);';
        }
        $name = strip_bracket(!empty($args) ? array_shift($args) : $vars['page']);
        $page = get_fullname($name, $vars['page']);
        $nolink = in_array('nolink', $args);
        if (substr($page, -1) == '/') {
            // Check multiple pages started with "$page"
            $timestamp = 0;
            $regex = '/^' . preg_quote($page, '/') . '/';
            foreach (preg_grep($regex, get_existpages()) as $page) {
                // Get the latest pagename and its timestamp
                $_timestamp = get_filetime($page);
                if ($timestamp < $_timestamp) {
                    $timestamp = $_timestamp;
                    $retval = $nolink ? '' : make_pagelink($page);
                }
            }
            if ($timestamp == 0) {
                return '&new(pagename/[,nolink]): No such pages;';
            }
        } else {
            // Check a page
            if (is_page($page)) {
                $timestamp = get_filetime($page);
                $retval = $nolink ? '' : make_pagelink($page, $name);
            } else {
                return '&new(pagename[,nolink]): No such page;';
            }
        }
    }
    // Add 'New!' string by the elapsed time
    $erapse = UTIME - $timestamp;
    foreach ($_plugin_new_elapses as $limit => $tag) {
        if ($erapse <= $limit) {
            $retval .= sprintf($tag, get_passage($timestamp));
            break;
        }
    }
    if ($date !== '') {
        // Show a date string
        return sprintf(PLUGIN_NEW_DATE_FORMAT, $retval);
    } else {
        // Show a page name
        return $retval;
    }
}
示例#18
0
function plugin_rename_phase3($pages)
{
    global $_rename_messages, $vars;
    $msg = $input = '';
    $files = plugin_rename_get_files($pages);
    $exists = array();
    foreach ($files as $_page => $arr) {
        foreach ($arr as $old => $new) {
            if (file_exists($new)) {
                $exists[$_page][$old] = $new;
            }
        }
    }
    if (isset($vars['menu']) && !Auth::check_role('role_contents_admin')) {
        return plugin_rename_phase4($pages, $files, $exists);
    }
    $pass = plugin_rename_getvar('pass');
    if ($pass != '' && pkwk_login($pass)) {
        return plugin_rename_phase4($pages, $files, $exists);
    } else {
        if ($pass != '') {
            $msg = plugin_rename_err('adminpass');
        }
    }
    $method = plugin_rename_getvar('method');
    if ($method == 'regex') {
        $s_src = htmlsc(plugin_rename_getvar('src'));
        $s_dst = htmlsc(plugin_rename_getvar('dst'));
        $msg .= $_rename_messages['msg_regex'] . '<br />';
        $input .= '<input type="hidden" name="method" value="regex" />';
        $input .= '<input type="hidden" name="src"    value="' . $s_src . '" />';
        $input .= '<input type="hidden" name="dst"    value="' . $s_dst . '" />';
    } else {
        $s_refer = htmlsc(plugin_rename_getvar('refer'));
        $s_page = htmlsc(plugin_rename_getvar('page'));
        $s_related = htmlsc(plugin_rename_getvar('related'));
        $msg .= $_rename_messages['msg_page'] . '<br />';
        $input .= '<input type="hidden" name="method"  value="page" />';
        $input .= '<input type="hidden" name="refer"   value="' . $s_refer . '" />';
        $input .= '<input type="hidden" name="page"    value="' . $s_page . '" />';
        $input .= '<input type="hidden" name="related" value="' . $s_related . '" />';
    }
    if (!empty($exists)) {
        $msg .= $_rename_messages['err_already_below'] . '<ul>';
        foreach ($exists as $page => $arr) {
            $msg .= '<li>' . make_pagelink(decode($page));
            $msg .= $_rename_messages['msg_arrow'];
            $msg .= htmlsc(decode($pages[$page]));
            if (!empty($arr)) {
                $msg .= '<ul>' . "\n";
                foreach ($arr as $ofile => $nfile) {
                    $msg .= '<li>' . $ofile . $_rename_messages['msg_arrow'] . $nfile . '</li>' . "\n";
                }
                $msg .= '</ul>';
            }
            $msg .= '</li>' . "\n";
        }
        $msg .= '</ul><hr />' . "\n";
        $input .= '<input type="radio" name="exist" value="0" checked="checked" />' . $_rename_messages['msg_exist_none'] . '<br />' . "\n";
        $input .= '<input type="radio" name="exist" value="1" />' . $_rename_messages['msg_exist_overwrite'] . '<br />' . "\n";
    }
    $ret = array();
    $auth = '';
    if (Auth::check_role('role_contents_admin')) {
        $auth = <<<EOD
<div class="form-group">
  <label for="_p_rename_adminpass">{$_rename_messages['msg_adminpass']}</label>
  <input type="password" name="pass" id="_p_rename_adminpass" value="" class="form-control" />
</div>
EOD;
    }
    $ret['msg'] = $_rename_messages['msg_title'];
    $script = get_script_uri();
    $ret['body'] = <<<EOD
{$msg}
\t<form action="{$script}" method="post" class="plugin-rename-form">
\t\t<input type="hidden" name="cmd" value="rename" />
\t\t<input type="hidden" name="menu"   value="1" />
\t\t{$input}
\t\t{$auth}
\t\t<input type="submit" class="btn btn-warning" value="{$_rename_messages['btn_submit']}" />
\t</form>
\t<p>{$_rename_messages['msg_confirm']}</p>
EOD;
    ksort($pages, SORT_STRING);
    $ret['body'] .= '<ul>' . "\n";
    foreach ($pages as $old => $new) {
        $ret['body'] .= '<li>' . make_pagelink(decode($old)) . $_rename_messages['msg_arrow'] . Utility::htmlsc(Utility::decode($new)) . '</li>' . "\n";
    }
    $ret['body'] .= '</ul>' . "\n";
    return $ret;
}
示例#19
0
function plugin_backup_get_list($page)
{
    global $script;
    //	global $_msg_backuplist, $_msg_diff, $_msg_nowdiff, $_msg_source, $_msg_nobackup;
    //	global $_title_backup_delete;
    $_msg_backuplist = _('List of Backups');
    $_msg_nobackup = _('There are no backup(s) of $1.');
    $_msg_diff = _('diff');
    $_msg_nowdiff = _('diff current');
    $_msg_source = _('source');
    $_title_backup_delete = _('Deleting backup of $1');
    $r_page = rawurlencode($page);
    $s_page = htmlspecialchars($page);
    $retval = array();
    $retval[0] = <<<EOD
<ul>
 <li><a href="{$script}?cmd=backup">{$_msg_backuplist}</a>
  <ul>
EOD;
    $retval[1] = "\n";
    $retval[2] = <<<EOD
  </ul>
 </li>
</ul>
EOD;
    $backups = _backup_file_exists($page) ? get_backup($page) : array();
    if (empty($backups)) {
        $msg = str_replace('$1', make_pagelink($page), $_msg_nobackup);
        $retval[1] .= '   <li>' . $msg . '</li>' . "\n";
        return join('', $retval);
    }
    // if (! PKWK_READONLY) {
    if (!auth::check_role('readonly')) {
        $retval[1] .= '   <li><a href="' . $script . '?cmd=backup&amp;action=delete&amp;page=' . $r_page . '">';
        $retval[1] .= str_replace('$1', $s_page, $_title_backup_delete);
        $retval[1] .= '</a></li>' . "\n";
    }
    $href = $script . '?cmd=backup&amp;page=' . $r_page . '&amp;age=';
    $_anchor_from = $_anchor_to = '';
    $safemode = auth::check_role('safemode');
    foreach ($backups as $age => $data) {
        if (!PLUGIN_BACKUP_DISABLE_BACKUP_RENDERING) {
            $_anchor_from = '<a href="' . $href . $age . '">';
            $_anchor_to = '</a>';
        }
        $time = isset($data['real']) ? $data['real'] : $data['time'];
        $date = format_date($time, TRUE);
        $retval[1] .= <<<EOD
   <li>{$_anchor_from}{$age} {$date}{$_anchor_to}
EOD;
        if (!$safemode) {
            $retval[1] .= <<<EOD
     [ <a href="{$href}{$age}&amp;action=diff">{$_msg_diff}</a>
     | <a href="{$href}{$age}&amp;action=nowdiff">{$_msg_nowdiff}</a>
     | <a href="{$href}{$age}&amp;action=source">{$_msg_source}</a>
     ]
EOD;
        }
        $retval[1] .= <<<EOD
   </li>
EOD;
    }
    return join('', $retval);
}
示例#20
0
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);
}
示例#21
0
function plugin_bugtrack_list_convert()
{
    global $script, $vars, $_plugin_bugtrack;
    $page = $vars['page'];
    if (func_num_args()) {
        list($_page) = func_get_args();
        $_page = get_fullname(strip_bracket($_page), $page);
        if (is_pagename($_page)) {
            $page = $_page;
        }
    }
    $data = array();
    $pattern = $page . '/';
    $pattern_len = strlen($pattern);
    foreach (get_existpages() as $page) {
        if (strpos($page, $pattern) === 0 && is_numeric(substr($page, $pattern_len))) {
            array_push($data, plugin_bugtrack_list_pageinfo($page));
        }
    }
    $count_list = count($_plugin_bugtrack['state_list']);
    $table = array();
    for ($i = 0; $i <= $count_list + 1; ++$i) {
        $table[$i] = array();
    }
    foreach ($data as $line) {
        list($page, $no, $summary, $name, $priority, $state, $category) = $line;
        foreach (array('summary', 'name', 'priority', 'state', 'category') as $item) {
            ${$item} = htmlsc(${$item});
        }
        $page_link = make_pagelink($page);
        $state_no = array_search($state, $_plugin_bugtrack['state_sort']);
        if ($state_no === NULL || $state_no === FALSE) {
            $state_no = $count_list;
        }
        $bgcolor = htmlsc($_plugin_bugtrack['state_bgcolor'][$state_no]);
        $row = <<<EOD
 <tr>
  <td style="background-color:{$bgcolor}">{$page_link}</td>
  <td style="background-color:{$bgcolor}">{$state}</td>
  <td style="background-color:{$bgcolor}">{$priority}</td>
  <td style="background-color:{$bgcolor}">{$category}</td>
  <td style="background-color:{$bgcolor}">{$name}</td>
  <td style="background-color:{$bgcolor}">{$summary}</td>
 </tr>
EOD;
        $table[$state_no][$no] = $row;
    }
    $table_html = ' <tr>' . "\n";
    $bgcolor = htmlsc($_plugin_bugtrack['header_bgcolor']);
    foreach (array('pagename', 'state', 'priority', 'category', 'name', 'summary') as $item) {
        $table_html .= '  <th style="background-color:' . $bgcolor . '">' . htmlsc($_plugin_bugtrack[$item]) . '</th>' . "\n";
    }
    $table_html .= ' </tr>' . "\n";
    for ($i = 0; $i <= $count_list; ++$i) {
        ksort($table[$i], SORT_NUMERIC);
        $table_html .= join("\n", $table[$i]);
    }
    return '<table border="1" width="100%">' . "\n" . $table_html . "\n" . '</table>';
}
示例#22
0
 function MapNode($page, $reverse = FALSE)
 {
     global $script, $non_list;
     static $id = 0;
     $this->page = $page;
     $this->is_page = is_page($page);
     $this->cache = CACHE_DIR . encode($page);
     $this->done = !$this->is_page;
     $this->link = make_pagelink($page);
     $this->id = ++$id;
     $this->hide_pattern = '/' . $non_list . '/';
     $this->rels = $reverse ? $this->ref() : $this->rel();
     $mark = $reverse ? '' : '<sup>+</sup>';
     $this->mark = '<a id="rel_' . $this->id . '" href="' . $script . '?plugin=map&amp;refer=' . rawurlencode($this->page) . '">' . $mark . '</a>';
 }
示例#23
0
function plugin_navi_convert()
{
    global $vars, $script, $head_tags;
    global $_navi_prev, $_navi_next, $_navi_up, $_navi_home;
    static $navi = array();
    $current = $vars['page'];
    $reverse = FALSE;
    if (func_num_args()) {
        list($home, $reverse) = array_pad(func_get_args(), 2, '');
        // strip_bracket() is not necessary but compatible
        $home = get_fullname(strip_bracket($home), $current);
        $is_home = $home == $current;
        if (!is_page($home)) {
            return '#navi(contents-page-name): No such page: ' . htmlspecialchars($home) . '<br />';
        } else {
            if (!$is_home && !preg_match('/^' . preg_quote($home, '/') . '/', $current)) {
                return '#navi(' . htmlspecialchars($home) . '): Not a child page like: ' . htmlspecialchars($home . '/' . basename($current)) . '<br />';
            }
        }
        $reverse = strtolower($reverse) == 'reverse';
    } else {
        $home = $vars['page'];
        $is_home = TRUE;
        // $home == $current
    }
    $pages = array();
    $footer = isset($navi[$home]);
    // The first time: FALSE, the second: TRUE
    if (!$footer) {
        $navi[$home] = array('up' => '', 'prev' => '', 'prev1' => '', 'next' => '', 'next1' => '', 'home' => '', 'home1' => '');
        $pages = preg_grep('/^' . preg_quote($home, '/') . '($|\\/)/', get_existpages());
        if (PLUGIN_NAVI_EXCLUSIVE_REGEX != '') {
            // If old PHP could use preg_grep(,,PREG_GREP_INVERT)...
            $pages = array_diff($pages, preg_grep(PLUGIN_NAVI_EXCLUSIVE_REGEX, $pages));
        }
        $pages[] = $current;
        // Sentinel :)
        $pages = array_unique($pages);
        natcasesort($pages);
        if ($reverse) {
            $pages = array_reverse($pages);
        }
        $prev = $home;
        foreach ($pages as $page) {
            if ($page == $current) {
                break;
            }
            $prev = $page;
        }
        $next = current($pages);
        $pos = strrpos($current, '/');
        $up = '';
        if ($pos > 0) {
            $up = substr($current, 0, $pos);
            $navi[$home]['up'] = make_pagelink($up, $_navi_up);
        }
        if (!$is_home) {
            $navi[$home]['prev'] = make_pagelink($prev);
            $navi[$home]['prev1'] = make_pagelink($prev, $_navi_prev);
        }
        if ($next != '') {
            $navi[$home]['next'] = make_pagelink($next);
            $navi[$home]['next1'] = make_pagelink($next, $_navi_next);
        }
        $navi[$home]['home'] = make_pagelink($home);
        $navi[$home]['home1'] = make_pagelink($home, $_navi_home);
        // Generate <link> tag: start next prev(previous) parent(up)
        // Not implemented: contents(toc) search first(begin) last(end)
        if (PLUGIN_NAVI_LINK_TAGS) {
            foreach (array('start' => $home, 'next' => $next, 'prev' => $prev, 'up' => $up) as $rel => $_page) {
                if ($_page != '') {
                    $s_page = htmlspecialchars($_page);
                    $r_page = rawurlencode($_page);
                    $head_tags[] = ' <link rel="' . $rel . '" href="' . $script . '?' . $r_page . '" title="' . $s_page . '" />';
                }
            }
        }
    }
    $ret = '';
    if ($is_home) {
        // Show contents
        $count = count($pages);
        if ($count == 0) {
            return '#navi(contents-page-name): You already view the result<br />';
        } else {
            if ($count == 1) {
                // Sentinel only: Show usage and warning
                $home = htmlspecialchars($home);
                $ret .= '#navi(' . $home . '): No child page like: ' . $home . '/Foo';
            } else {
                $ret .= '<ul>';
                foreach ($pages as $page) {
                    if ($page != $home) {
                        $ret .= ' <li>' . make_pagelink($page) . '</li>';
                    }
                }
                $ret .= '</ul>';
            }
        }
    } else {
        if (!$footer) {
            // Header
            $ret = <<<EOD
<ul class="navi">
 <li class="navi_left">{$navi[$home]['prev1']}</li>
 <li class="navi_right">{$navi[$home]['next1']}</li>
 <li class="navi_none">{$navi[$home]['home']}</li>
</ul>
<hr class="full_hr" />
EOD;
        } else {
            // Footer
            $ret = <<<EOD
<hr class="full_hr" />
<ul class="navi">
 <li class="navi_left">{$navi[$home]['prev1']}<br />{$navi[$home]['prev']}</li>
 <li class="navi_right">{$navi[$home]['next1']}<br />{$navi[$home]['next']}</li>
 <li class="navi_none">{$navi[$home]['home1']}<br />{$navi[$home]['up']}</li>
</ul>
EOD;
        }
    }
    return $ret;
}
function plugin_minicalendar_convert()
{
    global $script, $vars, $post, $get, $weeklabels, $WikiName, $BracketName;
    //	global $_minicalendar_plugin_edit, $_minicalendar_plugin_empty;
    $_minicalendar_plugin_edit = _('[edit]');
    $_minicalendar_plugin_empty = _('%s is empty.');
    $today_view = TRUE;
    $today_args = 'viewex';
    $date_str = get_date('Ym');
    $base = strip_bracket($vars['page']);
    if (func_num_args() > 0) {
        $args = func_get_args();
        foreach ($args as $arg) {
            if (is_numeric($arg) && strlen($arg) == 6) {
                $date_str = $arg;
            } else {
                if ($arg == 'off') {
                    $today_view = FALSE;
                } else {
                    if ($arg == 'past' || $arg == 'pastex' || $arg == 'future' || $arg == 'futureex' || $arg == 'view' || $arg == 'viewex') {
                        $today_args = $arg;
                    } else {
                        $base = strip_bracket($arg);
                    }
                }
            }
        }
    }
    if ($base == '*') {
        $base = '';
        $prefix = '';
    } else {
        $prefix = $base . '/';
    }
    $r_base = rawurlencode($base);
    $s_base = htmlspecialchars($base);
    $r_prefix = rawurlencode($prefix);
    $s_prefix = htmlspecialchars($prefix);
    $yr = substr($date_str, 0, 4);
    $mon = substr($date_str, 4, 2);
    if ($yr != get_date('Y') || $mon != get_date('m')) {
        $now_day = 1;
        $other_month = 1;
    } else {
        $now_day = get_date('d');
        $other_month = 0;
    }
    $today = getdate(mktime(0, 0, 0, $mon, $now_day, $yr));
    $m_num = $today['mon'];
    $d_num = $today['mday'];
    $year = $today['year'];
    $f_today = getdate(mktime(0, 0, 0, $m_num, 1, $year));
    $wday = $f_today['wday'];
    $day = 1;
    $m_name = $year . '.' . $m_num;
    $y = substr($date_str, 0, 4) + 0;
    $m = substr($date_str, 4, 2) + 0;
    $prev_date_str = $m == 1 ? sprintf('%04d%02d', $y - 1, 12) : sprintf('%04d%02d', $y, $m - 1);
    $next_date_str = $m == 12 ? sprintf('%04d%02d', $y + 1, 1) : sprintf('%04d%02d', $y, $m + 1);
    $this_date_str = sprintf('%04d%02d', $y, $m);
    $page_YM = sprintf('%04d-%02d', $y, $m);
    $ret = '';
    if (!defined('UA_MOBILE') || UA_MOBILE == 0) {
        if ($today_view) {
            if (exist_plugin('topicpath')) {
                $ret = "<div id=\"topicpath\"><a href=\"" . $script . "\">" . PLUGIN_TOPICPATH_TOP_LABEL . "</a>" . PLUGIN_TOPICPATH_TOP_SEPARATOR . "calendar - " . $s_base . "</div>\n";
            }
            $ret .= "<h2>" . sprintf(_('%04d/%02d %s'), $y, $m, $s_base) . "</h2>\n";
            $ret .= "<table style=\"width:92%\" border=\"0\" cellspacing=\"0\" cellpadding=\"8\" summary=\"calendar frame\">\n <tr>\n  <td valign=\"top\" width=\"160\">\n";
        }
        $ret .= <<<EOD
   <table class="ministyle_calendar" cellspacing="1" width="150" border="0" summary="calendar body">
    <tr>
     <td class="ministyle_td_caltop" colspan="7">
      <a href="{$script}?plugin=minicalendar&amp;file={$r_base}&amp;date={$prev_date_str}&amp;mode={$today_args}">&lt;&lt;</a>
      <strong>{$m_name}</strong>
      <a href="{$script}?plugin=minicalendar&amp;file={$r_base}&amp;date={$next_date_str}&amp;mode={$today_args}">&gt;&gt;</a>
EOD;
        if ($prefix) {
            //		$ret .= "\n      <br />[<a href=\"" . get_page_uri($base) . "\">$s_base</a>]";
            $ret .= "\n      <br />[<a href=\"{$script}?plugin=minicalendar&amp;file={$r_base}&amp;date={$this_date_str}&amp;mode={$today_args}\">{$s_base}</a>]";
        }
        $ret .= "\n     </td>\n    </tr>\n    <tr>\n";
        foreach ($weeklabels as $label) {
            $ret .= "     <td class=\"ministyle_td_week\">{$label}</td>\n";
        }
        $ret .= "    </tr>\n    <tr>\n";
        // Blank
        for ($i = 0; $i < $wday; $i++) {
            $ret .= "     <td class=\"ministyle_td_blank\">&nbsp;</td>\n";
        }
        while (checkdate($m_num, $day, $year)) {
            $dt = sprintf('%4d-%02d-%02d', $year, $m_num, $day);
            $page = $prefix . $dt;
            $r_page = rawurlencode($page);
            $s_page = htmlspecialchars($page);
            $h_today = public_holiday($year, $m_num, $day);
            $hday = $h_today['rc'];
            if ($wday == 0 and $day > 1) {
                $ret .= "    </tr>\n    <tr>\n";
            }
            $style = 'ministyle_td_day';
            // Weekday
            if (!$other_month && $day == $today['mday'] && $m_num == $today['mon'] && $year == $today['year']) {
                // Today
                $style = 'ministyle_td_today';
            } else {
                if ($hday != 0) {
                    // Holiday
                    $style = 'ministyle_td_sun';
                } else {
                    if ($wday == 0) {
                        // Sunday
                        $style = 'ministyle_td_sun';
                    } else {
                        if ($wday == 6) {
                            //  Saturday
                            $style = 'ministyle_td_sat';
                        }
                    }
                }
            }
            if (is_page($page)) {
                $link = "<a class=\"small\" href=\"" . get_page_uri($page) . "\" title=\"{$s_page}\"><strong>{$day}</strong></a>";
            } else {
                $link = "<a class=\"small\" href=\"{$script}?cmd=edit&amp;page={$r_page}&amp;refer={$r_base}\" title=\"{$s_page}\">{$day}</a>";
            }
            //		$ret .= "     <td class=\"$style\">\n      $link\n     </td>\n";
            $ret .= "     <td class=\"{$style}\">{$link}</td>\n";
            $day++;
            $wday = ++$wday % 7;
        }
        if ($wday > 0) {
            while ($wday++ < 7) {
                // Blank
                //			$ret .= "     <td class=\"ministyle_td_blank\">&nbsp;</td>\n";
                $ret .= "     <td class=\"ministyle_td_blank\"> </td>\n";
            }
        }
        $ret .= "    </tr>\n   </table>\n";
        if ($today_view) {
            if ($today_args == '') {
                $tpage = $prefix . sprintf("%4d-%02d-%02d", $today['year'], $today['mon'], $today['mday']);
                $r_tpage = rawurlencode($tpage);
                if (is_page($tpage)) {
                    $_page = $vars['page'];
                    $get['page'] = $post['page'] = $vars['page'] = $tpage;
                    $str = convert_html(get_source($tpage));
                    $str .= "<hr /><a class=\"small\" href=\"{$script}?cmd=edit&amp;page={$r_tpage}\">{$_minicalendar_plugin_edit}</a>";
                    $get['page'] = $post['page'] = $vars['page'] = $_page;
                } else {
                    $str = sprintf($_minicalendar_plugin_empty, make_pagelink(sprintf('%s%4d-%02d-%02d', $prefix, $today['year'], $today['mon'], $today['mday'])));
                }
            } else {
                $aryargs = array(rawurldecode($r_base), $page_YM, $today_args);
                if (exist_plugin('minicalendar_viewer')) {
                    bindtextdomain('minicalendar_viewer', LANG_DIR);
                    bind_textdomain_codeset('minicalendar_viewer', SOURCE_ENCODING);
                    textdomain('minicalendar_viewer');
                    $str = call_user_func_array('plugin_minicalendar_viewer_convert', $aryargs);
                    textdomain('minicalendar');
                }
            }
            $ret .= "  </td>\n  <td valign=\"top\">{$str}</td>\n </tr>\n</table>\n";
        }
    } else {
        //
        // for non-default profile
        //
        $ret .= <<<EOD
      <a href="{$script}?plugin=minicalendar&amp;file={$r_base}&amp;date={$prev_date_str}&amp;mode={$today_args}">&lt;&lt;</a>
      <strong>{$m_name}</strong>
      <a href="{$script}?plugin=minicalendar&amp;file={$r_base}&amp;date={$next_date_str}&amp;mode={$today_args}">&gt;&gt;</a>
EOD;
        if ($prefix) {
            //		$ret .= "\n      <br />[<a href=\"" . get_page_uri($base) . "\">$s_base</a>]";
            $ret .= "\n      <br />[<a href=\"{$script}?plugin=minicalendar&amp;file={$r_base}&amp;date={$this_date_str}&amp;mode={$today_args}\">{$s_base}</a>]";
        }
        $ret .= "<br />\n";
        foreach ($weeklabels as $label) {
            $ret .= "     {$label}\n";
        }
        $ret .= "<br />\n";
        // Blank
        for ($i = 0; $i < $wday; $i++) {
            $ret .= " &nbsp;&nbsp;\n";
        }
        while (checkdate($m_num, $day, $year)) {
            $dt = sprintf('%4d-%02d-%02d', $year, $m_num, $day);
            $page = $prefix . $dt;
            $r_page = rawurlencode($page);
            $s_page = htmlspecialchars($page);
            $h_today = public_holiday($year, $m_num, $day);
            $hday = $h_today['rc'];
            if ($wday == 0 and $day > 1) {
                $ret .= "    <br />\n";
            }
            $style = 'ministyle_td_day';
            // Weekday
            if (!$other_month && $day == $today['mday'] && $m_num == $today['mon'] && $year == $today['year']) {
                // Today
                $style = 'ministyle_td_today';
            } else {
                if ($hday != 0) {
                    // Holiday
                    $style = 'ministyle_td_sun';
                } else {
                    if ($wday == 0) {
                        // Sunday
                        $style = 'ministyle_td_sun';
                    } else {
                        if ($wday == 6) {
                            //  Saturday
                            $style = 'ministyle_td_sat';
                        }
                    }
                }
            }
            if (is_page($page)) {
                if ($day < 10) {
                    $spc = '&nbsp;';
                } else {
                    $spc = '';
                }
                $link = "{$spc}<a class=\"small\" href=\"" . get_page_uri($page) . "\" title=\"{$s_page}\"><font color=\"red\">{$day}</font></a>";
            } else {
                if ($day < 10) {
                    $spc = '&nbsp;';
                } else {
                    $spc = '';
                }
                $link = "{$spc}<a class=\"small\" href=\"{$script}?cmd=edit&amp;page={$r_page}&amp;refer={$r_base}\" title=\"{$s_page}\">{$day}</a>";
            }
            $ret .= $link . "\n";
            $day++;
            $wday = ++$wday % 7;
        }
        if ($wday > 0) {
            while ($wday++ < 7) {
                // Blank
                $ret .= " &nbsp;\n";
            }
        }
        $ret .= "<br /><br />\n";
        if ($today_view) {
            if ($today_args == '') {
                $tpage = $prefix . sprintf("%4d-%02d-%02d", $today['year'], $today['mon'], $today['mday']);
                $r_tpage = rawurlencode($tpage);
                if (is_page($tpage)) {
                    $_page = $vars['page'];
                    $get['page'] = $post['page'] = $vars['page'] = $tpage;
                    $str = convert_html(get_source($tpage));
                    $str .= "<hr /><a class=\"small\" href=\"{$script}?cmd=edit&amp;page={$r_tpage}\">{$_minicalendar_plugin_edit}</a>";
                    $get['page'] = $post['page'] = $vars['page'] = $_page;
                } else {
                    $str = sprintf($_minicalendar_plugin_empty, make_pagelink(sprintf('%s%4d-%02d-%02d', $prefix, $today['year'], $today['mon'], $today['mday'])));
                }
            } else {
                $aryargs = array(rawurldecode($r_base), $page_YM, $today_args);
                if (exist_plugin('minicalendar_viewer')) {
                    bindtextdomain('minicalendar_viewer', LANG_DIR);
                    bind_textdomain_codeset('minicalendar_viewer', SOURCE_ENCODING);
                    textdomain('minicalendar_viewer');
                    $str = call_user_func_array('plugin_minicalendar_viewer_convert', $aryargs);
                    textdomain('minicalendar');
                }
            }
            $ret .= $str . "\n";
        }
    }
    return $ret;
}
 function fixed_anchor()
 {
     $pages = $this->get_pages();
     $done = array();
     foreach ($pages as $page) {
         $do = false;
         $lines = get_source($page);
         foreach ($lines as $i => $line) {
             // multiline plugin. refer lib/convert_html
             if (defined('PKWKEXP_DISABLE_MULTILINE_PLUGIN_HACK') && PKWKEXP_DISABLE_MULTILINE_PLUGIN_HACK === 0) {
                 $matches = array();
                 if ($multiline < 2) {
                     if (preg_match('/^#([^\\(\\{]+)(?:\\(([^\\r]*)\\))?(\\{*)/', $line, $matches)) {
                         $multiline = strlen($matches[3]);
                     }
                 } else {
                     if (preg_match('/^\\}{' . $multiline . '}$/', $line, $matches)) {
                         $multiline = 0;
                     }
                     continue;
                 }
             }
             if (preg_match($this->def_headline, $line, $matches)) {
                 $anchor = make_heading($line, FALSE);
                 if ($anchor === '') {
                     $do = true;
                     break;
                 }
             }
         }
         if ($do) {
             $source = join('', $lines);
             page_write($page, $source, true);
             // ->make_str_rules -> generate_fixed_heading_ancher_id
             // chown also
             $done[] = $page;
         }
     }
     $body = '<p>';
     $body .= '<b>Created fixed_heading anchors for followings:</b><br />';
     foreach ($done as $page) {
         $link = make_pagelink($page);
         $body .= $link . "<br />\n";
     }
     $body .= '</p>';
     return $body;
 }
 function make_pagelink($page, $alias, $anchor)
 {
     global $vars;
     if ($this->options['link'][1] == 'off' || $anchor == '') {
         return htmlspecialchars($alias);
     }
     if ($this->options['link'][1] == 'on' && $page == $vars['page'] || $this->options['link'][1] == 'anchor') {
         $page = '';
     }
     global $show_passage;
     $tmp = $show_passage;
     $show_passage = 0;
     $link = make_pagelink($page, $alias, $anchor);
     $show_passage = $tmp;
     return $link;
 }
function plugin_tracker_list_action()
{
    global $get;
    $base = isset($get['base']) ? $get['base'] : '';
    $refer = isset($get['refer']) ? $get['refer'] : '';
    $rel = '';
    $config = isset($get['config']) ? $get['config'] : '';
    $order = isset($get['order']) ? $get['order'] : '';
    $list = isset($get['list']) ? $get['list'] : '';
    $limit = isset($get['limit']) ? $get['limit'] : NULL;
    $s_refer = make_pagelink($refer);
    return array('msg' => plugin_tracker_message('msg_list'), 'body' => str_replace('$1', $s_refer, plugin_tracker_message('msg_back')) . plugin_tracker_list_render($base, $refer, $rel, $config, $order, $list, $limit));
}
示例#28
0
function plugin_backup_get_list($page)
{
    global $layout_pages;
    //レイアウト部品の場合、スタイルを変更する
    $is_layout = FALSE;
    if (isset($layout_pages) && isset($layout_pages[$page])) {
        $is_layout = TRUE;
    }
    $qm = get_qm();
    $script = get_script_uri();
    $r_page = rawurlencode($page);
    $s_page = htmlspecialchars($page);
    //バックアップ一覧へのリンクは、
    //レイアウト部品の場合、編集リンクを表示する
    $backuplist_link = $is_layout ? '<a href="' . h($script) . '?cmd=edit&amp;page=' . $r_page . '">' . h($layout_pages[$page]) . 'を編集する</a>' : '<a href="' . h($script) . '?cmd=backup">' . $qm->m['plg_backup']['backuplist'] . '</a>';
    $retval = array();
    $retval[0] = '
<ul>
  <li>
    ' . $backuplist_link . '
    <ul>
';
    $retval[1] = "\n";
    $retval[2] = <<<EOD
    </ul>
  </li>
</ul>
EOD;
    $backups = _backup_file_exists($page) ? get_backup($page) : array();
    if (empty($backups)) {
        $pagelink = $is_layout ? h($layout_pages[$page]) : make_pagelink($page);
        $msg = str_replace('$1', $pagelink, $qm->m['plg_backup']['nobackup']);
        $retval[1] .= '   <li>' . $msg . '</li>' . "\n";
        return join('', $retval);
    }
    if (!PKWK_READONLY) {
        $retval[1] .= '   <li><a href="' . $script . '?cmd=backup&amp;action=delete&amp;page=' . $r_page . '">';
        $retval[1] .= str_replace('$1', $is_layout ? h($layout_pages[$page]) : $s_page, $qm->m['plg_backup']['title_backup_delete']);
        $retval[1] .= '</a></li>' . "\n";
    }
    $href = $script . '?cmd=backup&amp;page=' . $r_page . '&amp;age=';
    $_anchor_from = $_anchor_to = '';
    foreach ($backups as $age => $data) {
        if (!PLUGIN_BACKUP_DISABLE_BACKUP_RENDERING) {
            $_anchor_from = '<a href="' . $href . $age . '">';
            $_anchor_to = '</a>';
        }
        $date = format_date($data['time'], TRUE);
        $retval[1] .= <<<EOD
   <li>{$_anchor_from}{$age} {$date}{$_anchor_to}
     [ <a href="{$href}{$age}&amp;action=diff">{$qm->m['plg_backup']['diff']}</a>
     | <a href="{$href}{$age}&amp;action=nowdiff">{$qm->m['plg_backup']['nowdiff']}</a>
     | <a href="{$href}{$age}&amp;action=source">{$qm->m['plg_backup']['source']}</a>
     ]
   </li>
EOD;
    }
    return join('', $retval);
}
示例#29
0
 function toString()
 {
     return make_pagelink($this->name, $this->alias, '', $this->page, TRUE);
 }
}
// Title
if ($is_read) {
    if ($newtitle) {
        $display_title = $newtitle . ' - ' . $page_title;
        $heading_title = make_pagelink($vars['page'], $newtitle);
    } elseif (substr($vars['page'], 0, strlen($wikinote_ini['prefix'])) === $wikinote_ini['prefix']) {
        $wikinote_title = $wikinote_notepage_prefix_title . ':' . substr(strstr($vars['page'], '/'), 1);
        $display_title = $wikinote_title . ' - ' . $page_title;
        $heading_title = make_pagelink($vars['page'], $wikinote_title);
    } elseif ($vars['page'] == $defaultpage) {
        $display_title = $page_title;
        $heading_title = make_pagelink($vars['page'], $page_title);
    } else {
        $display_title = $vars['page'] . ' - ' . $page_title;
        $heading_title = make_pagelink($vars['page'], get_short_pagename($vars['page']));
    }
} else {
    $display_title = $title . ' - ' . $page_title;
    $heading_title = $title;
}
// Navigation tab (Wikinote)
$wikinote_navi = '';
if (exist_plugin('wikinote')) {
    $wikinote = new PluginWikinote($wikinote_ini);
    if ($wikinote->is_effect()) {
        if ($wikinote->is_notepage()) {
            $wikinote_navi = $wikinote->show_tabs($wikinote_notepage_tabs);
        } else {
            $wikinote_navi = $wikinote->show_tabs($wikinote_mainpage_tabs);
        }