Example #1
0
function plugin_edit_action()
{
    global $vars, $_title_edit, $load_template_func;
    if (PKWK_READONLY) {
        die_message('PKWK_READONLY prohibits editing');
    }
    $page = isset($vars['page']) ? $vars['page'] : '';
    check_editable($page, true, true);
    if (isset($vars['preview']) || $load_template_func && isset($vars['template'])) {
        return plugin_edit_preview();
    } else {
        if (isset($vars['write'])) {
            return plugin_edit_write();
        } else {
            if (isset($vars['cancel'])) {
                return plugin_edit_cancel();
            }
        }
    }
    $postdata = @join('', get_source($page));
    if ($postdata == '') {
        $postdata = auto_template($page);
    }
    return array('msg' => $_title_edit, 'body' => edit_form($page, $postdata));
}
Example #2
0
function plugin_newpage_action()
{
    global $vars;
    $qm = get_qm();
    if (PKWK_READONLY) {
        die_message($qm->m['fmt_err_pkwk_readonly']);
    }
    if ($vars['page'] == '') {
        $retvars['msg'] = $qm->m['plg_newpage']['label'];
        $retvars['body'] = plugin_newpage_convert();
        if (preg_match('/id="([^"]+)"/', $retvars['body'], $ms)) {
            $domid = $ms[1];
            //jquery ライブラリの読み込み
            $qt = get_qt();
            $qt->setv('jquery_include', true);
            $addscript = <<<EOS
<script type="text/javascript">
jQuery(function(){
\tjQuery("#{$domid}").focus().select();
});
</script>
EOS;
            $qt->appendv_once('plugin_select_fsize', 'beforescript', $addscript);
        }
        return $retvars;
    } else {
        $page = strip_bracket($vars['page']);
        $r_page = rawurlencode(isset($vars['refer']) ? get_fullname($page, $vars['refer']) : $page);
        $r_refer = rawurlencode($vars['refer']);
        pkwk_headers_sent();
        header('Location: ' . get_script_uri() . '?cmd=read&page=' . $r_page . '&refer=' . $r_refer);
        exit;
    }
}
function plugin_doc_ini_action()
{
    global $script, $vars, $_doc_ini_msg;
    if (auth::check_role('role_adm_contents')) {
        die_message('NOT AUTHORIZED.');
    }
    if (empty($vars['page'])) {
        return;
    }
    if (!is_pagename($vars['page'])) {
        return '';
    }
    // Invalid page name;
    $action = empty($vars['action']) ? '' : $vars['action'];
    $retval = array();
    $msg_title = sprintf($_doc_ini_msg['msg_confirmation'], $vars['page']);
    if ($action === 'exec') {
        return plugin_doc_ini_exec($vars['page']);
    }
    $retval['body'] = <<<EOD
<form action="{$script}" method="post">
        <div>
\t{$msg_title}
                <input type="hidden" name="plugin" value="doc_ini" />
                <input type="hidden" name="action" value="exec" />
                <input type="hidden" name="page" value="{$vars['page']}" />
                <input type="submit" value="{$_doc_ini_msg['btn_exec']}" />
        </div>
</form>

EOD;
    $retval['msg'] = $_doc_ini_msg['title_confirmation'];
    return $retval;
}
/**
 * GreyBox (gb_pageset) プラグイン
 *
 * @copyright   Copyright &copy; 2009, Katsumi Saito <*****@*****.**>
 * @version     $Id: gb_pageset.inc.php,v 0.1 2009/03/31 00:37:00 upk Exp $
 * @link	http://orangoo.com/labs/GreyBox/
 */
function plugin_gb_pageset_convert()
{
    global $script, $vars;
    static $get_greybox = true;
    if ($get_greybox) {
        $get_greybox = false;
        if (exist_plugin('greybox')) {
            greybox_set_head_tags();
        } else {
            die_message('greybox plugin not found.');
        }
    }
    $argv = func_get_args();
    $argc = func_num_args();
    $field = array('page_set_name', 'caption', 'url');
    for ($i = 0; $i < $argc; $i++) {
        ${$field}[$i] = htmlspecialchars($argv[$i], ENT_QUOTES);
    }
    if (empty($page_set_name) || empty($url)) {
        return 'usage: #gb_pageset(page_set_name, caption, url)';
    }
    if (empty($caption)) {
        $caption = 'no title';
    }
    $caption = str_replace('&amp;#039;', '\'', $caption);
    // ' の対応
    return '<a href="' . $url . '" title="' . $caption . '" rel="gb_pageset[' . $page_set_name . ']">' . $caption . "</a>\n";
}
function plugin_newpage_action()
{
    global $vars;
    $_btn_edit = _('Edit');
    $_msg_newpage = _('New page');
    // if (PKWK_READONLY) die_message('PKWK_READONLY prohibits editing');
    if (auth::check_role('readonly')) {
        die_message(_('PKWK_READONLY prohibits editing'));
    }
    if (auth::is_check_role(PKWK_CREATE_PAGE)) {
        die_message(_('PKWK_CREATE_PAGE prohibits editing'));
    }
    if ($vars['page'] == '') {
        $retvars['msg'] = $_msg_newpage;
        $retvars['body'] = plugin_newpage_convert();
        return $retvars;
    } else {
        $page = strip_bracket($vars['page']);
        if (isset($vars['refer'])) {
            $r_page = get_fullname($page, $vars['refer']);
            $r_refer = 'refer=' . $vars['refer'];
        } else {
            $r_page = $page;
            $r_refer = '';
        }
        pkwk_headers_sent();
        header('Location: ' . get_page_location_uri($r_page, $r_refer));
        exit;
    }
}
function plugin_html2pdf_get_request_uri($init_uri = '')
{
    if ($init_uri == '') {
        // Set automatically
        $msg = 'get_request_uri() failed: Please set $script at INI_FILE manually';
        if (isset($_SERVER['REQUEST_URI']) && $_SERVER['REQUEST_URI'][0] == '/') {
            $url = SERVER_PORT == 443 ? 'https://' : 'http://';
            // scheme
            $url .= SERVER_NAME;
            // host
            $url .= SERVER_PORT == 80 ? '' : ':' . SERVER_PORT;
            // port
            $url .= $_SERVER['REQUEST_URI'];
        } else {
            global $vars;
            $url = get_script_uri() . '?';
            $queries = array();
            $queries[] = $vars['cmd'] != '' ? 'cmd=' . rawurlencode($vars['cmd']) : '';
            $queries[] = $vars['page'] != '' ? 'page=' . rawurlencode($vars['page']) : '';
            $url .= implode('&', $queries);
        }
        if (!is_url($url, TRUE)) {
            die_message($msg);
        }
    } else {
        // Set manually
        if (!is_url($init_uri, TRUE)) {
            die_message('$url: Invalid URI');
        }
        $url = $init_uri;
    }
    return $url;
}
Example #7
0
function plugin_search_action()
{
    global $post, $vars, $_title_result, $_title_search, $_msg_searching;
    if (PLUGIN_SEARCH_DISABLE_GET_ACCESS) {
        $s_word = isset($post['word']) ? htmlsc($post['word']) : '';
    } else {
        $s_word = isset($vars['word']) ? htmlsc($vars['word']) : '';
    }
    if (strlen($s_word) > PLUGIN_SEARCH_MAX_LENGTH) {
        unset($vars['word']);
        // Stop using $_msg_word at lib/html.php
        die_message('Search words too long');
    }
    $type = isset($vars['type']) ? $vars['type'] : '';
    $base = isset($vars['base']) ? $vars['base'] : '';
    if ($s_word != '') {
        // Search
        $msg = str_replace('$1', $s_word, $_title_result);
        $body = do_search($vars['word'], $type, false, $base);
    } else {
        // Init
        unset($vars['word']);
        // Stop using $_msg_word at lib/html.php
        $msg = $_title_search;
        $body = '<br />' . "\n" . $_msg_searching . "\n";
    }
    // Show search form
    $bases = $base == '' ? array() : array($base);
    $body .= plugin_search_search_form($s_word, $type, $bases);
    return array('msg' => $msg, 'body' => $body);
}
Example #8
0
function plugin_mypage_convert()
{
    global $_mypage_msg;
    @(list($is_page) = func_get_args());
    $is_page = empty($is_page) ? false : true;
    $auth_key = Auth::get_user_info();
    // 認証確認
    if (empty($auth_key['key'])) {
        return '';
    }
    // マイページ利用の確認
    if (empty($auth_key['mypage'])) {
        return '';
    }
    // マイページの作成により制御
    // マイページ未作成の場合
    // is_page : true  -> プラグイン利用ページに遷移 -> #mypage(1)
    //         : false -> 新規作成画面に遷移         -> #mypage
    // The page cannot be prepared. -> ページの準備ができていません。
    if ($is_page && !is_page($auth_key['mypage'])) {
        return $_mypage_msg['msg_no_page'];
    }
    // 画面に誘導
    header('Location: ' . get_page_location_uri($auth_key['mypage']));
    // 誘導失敗時の対処(ブラウザによる)
    die_message($_mypage_msg['err_jump']);
}
Example #9
0
function plugin_links_action()
{
    global $script, $post, $vars, $foot_explain;
    global $_links_messages;
    if (PKWK_READONLY) {
        die_message('PKWK_READONLY prohibits this');
    }
    $msg = $body = '';
    if (empty($vars['action']) || empty($post['adminpass']) || !pkwk_login($post['adminpass'])) {
        $msg =& $_links_messages['title_update'];
        $body = convert_html($_links_messages['msg_usage']);
        $body .= <<<EOD
<form method="POST" action="{$script}">
 <div>
  <input type="hidden" name="plugin" value="links" />
  <input type="hidden" name="action" value="update" />
  <label for="_p_links_adminpass">{$_links_messages['msg_adminpass']}</label>
  <input type="password" name="adminpass" id="_p_links_adminpass" size="20" value="" />
  <input type="submit" value="{$_links_messages['btn_submit']}" />
 </div>
</form>
EOD;
    } elseif ($vars['action'] == 'update') {
        links_init();
        $foot_explain = array();
        // Exhaust footnotes
        $msg =& $_links_messages['title_update'];
        $body =& $_links_messages['msg_done'];
    } else {
        $msg =& $_links_messages['title_update'];
        $body =& $_links_messages['err_invalid'];
    }
    return array('msg' => $msg, 'body' => $body);
}
Example #10
0
function plugin_search2_action()
{
    global $post, $vars;
    $qm = get_qm();
    $s_word = isset($vars['word']) ? h($vars['word']) : '';
    if (strlen($s_word) > PLUGIN_SEARCH2_MAX_LENGTH) {
        unset($vars['word']);
        die_message($qm->m['plg_search']['err_toolong']);
    }
    $type = isset($vars['type']) ? $vars['type'] : '';
    $base = isset($vars['base']) ? $vars['base'] : '';
    if ($s_word != '') {
        // Search
        $msg = str_replace('$1', $s_word, $qm->m['plg_search']['title_result']);
        $body = plugin_search2_do_search($vars['word'], $type, FALSE, $base);
    } else {
        // Init
        unset($vars['word']);
        $msg = $qm->m['plg_search']['title_search'];
        $body = '<br />' . "\n" . $qm->m['plg_search']['note'] . "\n";
    }
    // Show search form
    $bases = $base == '' ? array() : array($base);
    $body .= plugin_search2_form($s_word, $type, $bases);
    return array('msg' => $msg, 'body' => $body);
}
function plugin_commentx_action()
{
    global $vars, $post;
    // Petit SPAM Check (Client(Browser)-Server Ticket Check)
    $spam = FALSE;
    if (isset($post['encode_hint']) && $post['encode_hint'] != '') {
        if (PKWK_ENCODING_HINT != $post['encode_hint']) {
            $spam = TRUE;
        }
    } else {
        if (PKWK_ENCODING_HINT != '') {
            $spam = TRUE;
        }
    }
    if (method_exists('auth', 'check_role')) {
        // Plus!
        if (auth::check_role('readonly')) {
            die_message('PKWK_READONLY prohibits editing');
        }
        if (!is_page($vars['refer']) && auth::is_check_role(PKWK_CREATE_PAGE)) {
            die_message(_('PKWK_CREATE_PAGE prohibits editing'));
        }
    } else {
        if (PKWK_READONLY) {
            die_message('PKWK_READONLY prohibits editing');
        }
    }
    // If SPAM, goto jail.
    if ($spam) {
        return plugin_commentx_honeypot();
    }
    return plugin_commentx_write();
}
Example #12
0
function plugin_search_action()
{
    global $post, $vars;
    $_title_search = _('Search for word(s)');
    $_title_result = _('Search result of  $1');
    $_msg_searching = _('Key words are case-insenstive, and are searched for in all pages.');
    if (PLUGIN_SEARCH_DISABLE_GET_ACCESS) {
        $s_word = isset($post['word']) ? htmlspecialchars($post['word']) : '';
    } else {
        $s_word = isset($vars['word']) ? htmlspecialchars($vars['word']) : '';
    }
    if (strlen($s_word) > PLUGIN_SEARCH_MAX_LENGTH) {
        unset($vars['word']);
        // Stop using $_msg_word at lib/html.php
        die_message('Search words too long');
    }
    $type = isset($vars['type']) ? $vars['type'] : '';
    $base = isset($vars['base']) ? $vars['base'] : '';
    if ($s_word != '') {
        // Search
        $msg = str_replace('$1', $s_word, $_title_result);
        $body = do_search($vars['word'], $type, FALSE, $base);
    } else {
        // Init
        unset($vars['word']);
        // Stop using $_msg_word at lib/html.php
        $msg = $_title_search;
        $body = '<br />' . "\n" . $_msg_searching . "\n";
    }
    // Show search form
    $bases = $base == '' ? array() : array($base);
    $body .= plugin_search_search_form($s_word, $type, $bases);
    return array('msg' => $msg, 'body' => $body);
}
Example #13
0
function plugin_memo_action()
{
    global $vars, $cols, $rows, $_string;
    //	global $_title_collided, $_msg_collided, $_title_updated;
    $_title_collided = $_string['title_collided'];
    $_title_updated = $_string['updated'];
    $_msg_collided = $_string['msg_collided'];
    // if (PKWK_READONLY) die_message('PKWK_READONLY prohibits editing');
    if (Auth::check_role('readonly')) {
        die_message('PKWK_READONLY prohibits editing');
    }
    if (!isset($vars['msg']) || $vars['msg'] == '') {
        return;
    }
    $memo_body = preg_replace('/' . "\r" . '/', '', $vars['msg']);
    $memo_body = str_replace("\n", '\\n', $memo_body);
    $memo_body = str_replace('"', '&#x22;', $memo_body);
    // Escape double quotes
    $memo_body = str_replace(',', '&#x2c;', $memo_body);
    // Escape commas
    $wiki = Factory::Wiki($vars['refer']);
    $postdata = array();
    $memo_no = 0;
    foreach ($wiki->get() as $line) {
        if (preg_match('/^#memo\\(?.*\\)?$/i', $line)) {
            if ($memo_no == $vars['memo_no']) {
                $postdata[] = '#memo(' . $memo_body . ')' . "\n";
                $line = '';
            }
            ++$memo_no;
        }
        $postdata[] = $line;
    }
    $postdata_input = $memo_body . "\n";
    $body = '';
    if ($wiki->digest() !== $vars['digest']) {
        $title = $_title_collided;
        $body = $_msg_collided . "\n";
        $s_refer = Utility::htmlsc($vars['refer']);
        $s_digest = Utility::htmlsc($vars['digest']);
        $s_postdata_input = Utility::htmlsc($postdata_input);
        $script = get_script_uri();
        $body .= <<<EOD
<form action="{$script}" method="post" class="plugin-memo-form">
\t<input type="hidden" name="cmd" value="preview" />
\t<input type="hidden" name="refer"  value="{$s_refer}" />
\t<input type="hidden" name="digest" value="{$s_digest}" />
\t<textarea name="msg" rows="{$rows}" cols="{$cols}" class="form-control">{$s_postdata_input}</textarea>
</form>
EOD;
    } else {
        $wiki->set($postdata);
        $title = $_title_updated;
    }
    $retvars['msg'] =& $title;
    $retvars['body'] =& $body;
    $vars['page'] = $vars['refer'];
    return $retvars;
}
Example #14
0
function plugin_versionlist_action()
{
    global $_title_versionlist;
    if (PKWK_SAFE_MODE) {
        die_message('PKWK_SAFE_MODE prohibits this');
    }
    return array('msg' => $_title_versionlist, 'body' => plugin_versionlist_convert());
}
Example #15
0
function plugin_versionlist_action()
{
    // if (PKWK_SAFE_MODE) die_message('PKWK_SAFE_MODE prohibits this');
    if (Auth::check_role('safemode')) {
        die_message('PKWK_SAFE_MODE prohibits this');
    }
    return array('msg' => _('version list'), 'body' => plugin_versionlist_convert());
}
Example #16
0
function plugin_versionlist_action()
{
    $qm = get_qm();
    if (PKWK_SAFE_MODE) {
        die_message('PKWK_SAFE_MODE prohibits this');
    }
    return array('msg' => $qm->m['plg_versionlist']['title_versionlist'], 'body' => plugin_versionlist_convert());
}
Example #17
0
function plugin_vote_action()
{
    global $vars, $script, $cols, $rows;
    global $_title_collided, $_msg_collided, $_title_updated;
    global $_vote_plugin_votes;
    if (PKWK_READONLY) {
        die_message('PKWK_READONLY prohibits editing');
    }
    $postdata_old = get_source($vars['refer']);
    $vote_no = 0;
    $title = $body = $postdata = $postdata_input = $vote_str = '';
    $matches = array();
    foreach ($postdata_old as $line) {
        if (!preg_match('/^#vote(?:\\((.*)\\)(.*))?$/i', $line, $matches) || $vote_no++ != $vars['vote_no']) {
            $postdata .= $line;
            continue;
        }
        $args = explode(',', $matches[1]);
        $lefts = isset($matches[2]) ? $matches[2] : '';
        foreach ($args as $arg) {
            $cnt = 0;
            if (preg_match('/^(.+)\\[(\\d+)\\]$/', $arg, $matches)) {
                $arg = $matches[1];
                $cnt = $matches[2];
            }
            $e_arg = encode($arg);
            if (!empty($vars['vote_' . $e_arg]) && $vars['vote_' . $e_arg] == $_vote_plugin_votes) {
                ++$cnt;
            }
            $votes[] = $arg . '[' . $cnt . ']';
        }
        $vote_str = '#vote(' . @join(',', $votes) . ')' . $lefts . "\n";
        $postdata_input = $vote_str;
        $postdata .= $vote_str;
    }
    if (md5(@join('', get_source($vars['refer']))) != $vars['digest']) {
        $title = $_title_collided;
        $s_refer = htmlsc($vars['refer']);
        $s_digest = htmlsc($vars['digest']);
        $s_postdata_input = htmlsc($postdata_input);
        $body = <<<EOD
{$_msg_collided}
<form action="{$script}?cmd=preview" method="post">
 <div>
  <input type="hidden" name="refer"  value="{$s_refer}" />
  <input type="hidden" name="digest" value="{$s_digest}" />
  <textarea name="msg" rows="{$rows}" cols="{$cols}" id="textarea">{$s_postdata_input}</textarea><br />
 </div>
</form>

EOD;
    } else {
        page_write($vars['refer'], $postdata);
        $title = $_title_updated;
    }
    $vars['page'] = $vars['refer'];
    return array('msg' => $title, 'body' => $body);
}
Example #18
0
function plugin_memo_action()
{
    global $script, $vars, $cols, $rows;
    global $_title_collided, $_msg_collided, $_title_updated;
    if (PKWK_READONLY) {
        die_message('PKWK_READONLY prohibits editing');
    }
    if (!isset($vars['msg']) || $vars['msg'] == '') {
        return;
    }
    $memo_body = preg_replace('/' . "\r" . '/', '', $vars['msg']);
    $memo_body = str_replace("\n", '\\n', $memo_body);
    $memo_body = str_replace('"', '&#x22;', $memo_body);
    // Escape double quotes
    $memo_body = str_replace(',', '&#x2c;', $memo_body);
    // Escape commas
    $postdata_old = get_source($vars['refer']);
    $postdata = '';
    $memo_no = 0;
    foreach ($postdata_old as $line) {
        if (preg_match("/^#memo\\(?.*\\)?\$/i", $line)) {
            if ($memo_no == $vars['memo_no']) {
                $postdata .= '#memo(' . $memo_body . ')' . "\n";
                $line = '';
            }
            ++$memo_no;
        }
        $postdata .= $line;
    }
    $postdata_input = $memo_body . "\n";
    $body = '';
    if (md5(@join('', get_source($vars['refer']))) != $vars['digest']) {
        $title = $_title_collided;
        $body = $_msg_collided . "\n";
        $s_refer = htmlspecialchars($vars['refer']);
        $s_digest = htmlspecialchars($vars['digest']);
        $s_postdata_input = htmlspecialchars($postdata_input);
        $body .= <<<EOD
<form action="{$script}?cmd=preview" method="post">
 <div>
 <p>
  <input type="hidden" name="refer"  value="{$s_refer}" />
  <input type="hidden" name="digest" value="{$s_digest}" />
  <textarea name="msg" rows="{$rows}" cols="{$cols}" id="textarea">{$s_postdata_input}</textarea>
 </p>
 </div>
</form>
EOD;
    } else {
        page_write($vars['refer'], $postdata);
        $title = $_title_updated;
    }
    $retvars['msg'] =& $title;
    $retvars['body'] =& $body;
    $vars['page'] = $vars['refer'];
    return $retvars;
}
Example #19
0
function plugin_stationary_action()
{
    // See above
    if (PKWK_SAFE_MODE || PKWK_READONLY) {
        die_message('PKWK_SAFE_MODE or PKWK_READONLY prohibits this');
    }
    $msg = 'Message';
    $body = 'Message body';
    return array('msg' => htmlsc($msg), 'body' => htmlsc($body));
}
Example #20
0
function check_role_die($msg)
{
    global $defaultpage, $vars;
    if (!empty($vars['page']) && $defaultpage == $vars['page']) {
        die_message($msg);
    }
    header('Location: ' . get_location_uri());
    // 飛ばないときしかメッセージは表示されない
    die($msg);
}
Example #21
0
function plugin_insert_action()
{
    global $script, $vars, $cols, $rows;
    global $_title_collided, $_msg_collided, $_title_updated;
    if (PKWK_READONLY) {
        die_message('PKWK_READONLY prohibits editing');
    }
    if (!isset($vars['msg']) || $vars['msg'] == '') {
        return;
    }
    $vars['msg'] = preg_replace('/' . "\r" . '/', '', $vars['msg']);
    $insert = $vars['msg'] != '' ? "\n" . $vars['msg'] . "\n" : '';
    $postdata = '';
    $postdata_old = get_source($vars['refer']);
    $insert_no = 0;
    foreach ($postdata_old as $line) {
        if (!INSERT_INS) {
            $postdata .= $line;
        }
        if (preg_match('/^#insert$/i', $line)) {
            if ($insert_no == $vars['insert_no']) {
                $postdata .= $insert;
            }
            $insert_no++;
        }
        if (INSERT_INS) {
            $postdata .= $line;
        }
    }
    $postdata_input = $insert . "\n";
    $body = '';
    if (md5(@join('', get_source($vars['refer']))) != $vars['digest']) {
        $title = $_title_collided;
        $body = $_msg_collided . "\n";
        $s_refer = htmlsc($vars['refer']);
        $s_digest = htmlsc($vars['digest']);
        $s_postdata_input = htmlsc($postdata_input);
        $body .= <<<EOD
<form action="{$script}?cmd=preview" method="post">
 <div>
  <input type="hidden" name="refer"  value="{$s_refer}" />
  <input type="hidden" name="digest" value="{$s_digest}" />
  <textarea name="msg" rows="{$rows}" cols="{$cols}" id="textarea">{$s_postdata_input}</textarea><br />
 </div>
</form>
EOD;
    } else {
        page_write($vars['refer'], $postdata);
        $title = $_title_updated;
    }
    $retvars['msg'] = $title;
    $retvars['body'] = $body;
    $vars['page'] = $vars['refer'];
    return $retvars;
}
Example #22
0
function plugin_stationary_action()
{
    // See above
    // if (PKWK_SAFE_MODE || PKWK_READONLY)
    if (Auth::check_role('safemode') || Auth::check_role('readonly')) {
        die_message('PKWK_SAFE_MODE or PKWK_READONLY prohibits this');
    }
    $msg = 'Message';
    $body = 'Message body';
    return array('msg' => htmlsc($msg), 'body' => htmlsc($body));
}
Example #23
0
function plugin_add_action()
{
    global $get, $post, $vars, $_title_add, $_msg_add;
    if (PKWK_READONLY) {
        die_message('PKWK_READONLY prohibits editing');
    }
    $page = isset($vars['page']) ? $vars['page'] : '';
    check_editable($page);
    $get['add'] = $post['add'] = $vars['add'] = TRUE;
    return array('msg' => $_title_add, 'body' => '<ul>' . "\n" . ' <li>' . $_msg_add . '</li>' . "\n" . '</ul>' . "\n" . edit_form($page, ''));
}
Example #24
0
function plugin_add_action()
{
    global $get, $post, $vars;
    $qm = get_qm();
    if (PKWK_READONLY) {
        die_message('PKWK_READONLY prohibits editing');
    }
    $page = isset($vars['page']) ? $vars['page'] : '';
    check_editable($page);
    $get['add'] = $post['add'] = $vars['add'] = TRUE;
    return array('msg' => $qm->m['plg_add']['title'], 'body' => '<ul>' . "\n" . ' <li>' . $qm->m['plg_add']['note'] . '</li>' . "\n" . '</ul>' . "\n" . edit_form($page, ''));
}
Example #25
0
function plugin_showrss_action()
{
    if (PKWK_SAFE_MODE) {
        die_message('PKWK_SAFE_MODE prohibit this');
    }
    $body = '';
    foreach (array('xml', 'mbstring') as $extension) {
        ${$extension} = extension_loaded($extension) ? '&color(green){Found};' : '&color(red){Not found};';
        $body .= '| ' . $extension . ' extension | ' . ${$extension} . ' |' . "\n";
    }
    return array('msg' => 'showrss_info', 'body' => convert_html($body));
}
Example #26
0
function plugin_comment_action()
{
    global $vars, $post, $_comment_messages;
    // if (PKWK_READONLY) die_message('PKWK_READONLY prohibits editing');
    if (Auth::check_role('readonly')) {
        die_message(sprintf($_comment_messages['err_prohibit'], 'PKWK_READONLY'));
    }
    if (!is_page($vars['refer']) && Auth::is_check_role(PKWK_CREATE_PAGE)) {
        Utility::dieMessage(sprintf($_comment_messages['err_prohibit'], 'PKWK_CREATE_PAGE'));
    }
    return plugin_comment_write();
}
Example #27
0
function plugin_rename_action()
{
    global $whatsnew;
    // if (PKWK_READONLY) die_message('PKWK_READONLY prohibits this');
    if (auth::check_role('readonly')) {
        die_message('PKWK_READONLY prohibits this');
    }
    $method = plugin_rename_getvar('method');
    if ($method == 'regex') {
        $src = plugin_rename_getvar('src');
        if ($src == '') {
            return plugin_rename_phase1();
        }
        $src_pattern = '/' . preg_quote($src, '/') . '/';
        $arr0 = preg_grep($src_pattern, auth::get_existpages());
        if (!is_array($arr0) || empty($arr0)) {
            return plugin_rename_phase1('nomatch');
        }
        $dst = plugin_rename_getvar('dst');
        $arr1 = preg_replace($src_pattern, $dst, $arr0);
        foreach ($arr1 as $page) {
            if (!is_pagename($page)) {
                return plugin_rename_phase1('notvalid');
            }
        }
        return plugin_rename_regex($arr0, $arr1);
    } else {
        // $method == 'page'
        $page = plugin_rename_getvar('page');
        $refer = plugin_rename_getvar('refer');
        if ($refer === '') {
            return plugin_rename_phase1();
        } else {
            if (!is_page($refer)) {
                return plugin_rename_phase1('notpage', $refer);
            } else {
                if ($refer === $whatsnew) {
                    return plugin_rename_phase1('norename', $refer);
                } else {
                    if ($page === '' || $page === $refer) {
                        return plugin_rename_phase2();
                    } else {
                        if (!is_pagename($page)) {
                            return plugin_rename_phase2('notvalid');
                        } else {
                            return plugin_rename_refer();
                        }
                    }
                }
            }
        }
    }
}
Example #28
0
function plugin_add_action()
{
    global $get, $post, $vars;
    // if (PKWK_READONLY) die_message('PKWK_READONLY prohibits editing');
    if (auth::check_role('readonly')) {
        die_message('PKWK_READONLY prohibits editing');
    }
    $page = isset($vars['page']) ? $vars['page'] : '';
    check_editable($page);
    $get['add'] = $post['add'] = $vars['add'] = TRUE;
    return array('msg' => _("Add to \$1"), 'body' => '<ul>' . "\n" . ' <li>' . _('Two and the contents of an input are added for a new-line to the contents of a page of present addition.') . '</li>' . "\n" . '</ul>' . "\n" . edit_form($page, ''));
}
Example #29
0
function plugin_search_action()
{
    global $post, $vars;
    global $_search_msg, $_LANG;
    /*
    	if (isset($vars['update_index'])){
    		PukiWiki\SearchLucene::updateIndex();
    		return array('msg'=>'done.');
    	}
    */
    if (PLUGIN_SEARCH_DISABLE_GET_ACCESS) {
        $s_word = isset($post['word']) ? htmlsc($post['word']) : '';
    } else {
        $s_word = isset($vars['word']) ? htmlsc($vars['word']) : '';
    }
    if (strlen($s_word) > PLUGIN_SEARCH_MAX_LENGTH) {
        unset($vars['word']);
        // Stop using $_msg_word at lib/html.php
        die_message('Search words too long');
    }
    $type = isset($vars['type']) ? $vars['type'] : '';
    $base = isset($vars['base']) ? $vars['base'] : '';
    $format = isset($vars['format']) ? $vars['format'] : 'html';
    switch ($format) {
        case 'xml':
            // OpenSearch
            // http://www.opensearch.org/
            global $site_name, $notify_from, $shortcut_icon;
            $ret = array('<?xml version="1.0" encoding="UTF-8"?>', '<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">', '<ShortName>' . $_search_msg['title_search'] . ' - ' . $site_name . '</ShortName>', '<Description>' . $_search_msg['title_search'] . ' - ' . $site_name . '</Description>', '<Contact>' . $notify_from . '</Contact>', '<Image height="16" width="16" type="image/x-icon">data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA%2F%2F%2F%2FBP%2F8%2BjT%2F7%2BdK%2F%2F38M%2F%2F%2F%2Fw0AAAAAAAAAAAAAAAAAAAAA%2F%2F%2F%2FC%2F%2F%2B%2FTH%2F7%2BdK%2F%2Fv4N%2F%2F%2F%2FwUAAAAA%2F%2F%2F%2FBf%2Ft5IH%2F5djE%2F%2FLsn%2F7u5pT63tKe%2BNzLkOjFmnnq27p%2B%2BOfXk%2Fnl06z%2B7eOV%2F%2FLsn%2F%2Fm2cD%2F6%2BGM%2F%2F%2F%2FBv%2F072P%2F5til%2F%2F%2F%2FGfz4%2BB%2FrqJOE9qBr7vukUv3%2FzoL%2F%2F%2Bao%2F%2Fznsv7337j4662LwPXWyyX%2F%2F%2F8Y%2F%2Bfbmv%2Fz7XD%2F7uaJ%2F%2FDohf%2F%2F%2FwH729Ib9loZzv97Jv7%2Fo0v%2F%2F%2BOt%2F%2F%2Fmrf%2F%2F0oD%2F%2F9KC%2F%2Fm3bu3vsZopAAAAAP%2Fw6H7%2F7uaQ%2FvHpgP%2Fy7JL%2F9vQW%2F1kvvf9UEef%2Fhj7v%2F%2FPP9%2F%2F95Pv%2F9df7%2F7FQ%2Bf%2BxUPT%2F0IPq%2F8V3xf%2F69RT%2F8uyR%2FvHphv%2F28Vr%2F9vGB%2F6qWsf9jK%2Bb%2FhEjm%2F7iF5v%2F16Ob%2F59Ln%2F9iw5%2F%2BZL%2Bf%2Fnzvm%2F%2Bq15v%2B1Zeb%2Bxp6x%2F%2Fbygf%2F07mf%2F%2F%2F8R%2FvHqkP68p9f%2FoW7o%2F4BL5v%2BCROb%2FfCrm%2F4Al5v%2BRPOb%2FvIXm%2F9Sp5v%2Fuxeb%2FsnHn%2F8Ci3f7x6o7%2F%2F%2F8XAAAAAP%2F38lz9o4Tu%2F9K28%2F%2FUs%2Bb%2FYxrm%2F3os5v%2BWSeb%2F1LPm%2F%2F%2F%2F5v%2F%2F%2Feb%2F9Nfm%2F9Wy8v%2BceO7%2F9fBoAAAAAAAAAAD%2F%2BfZD%2Brig8%2F%2FRtvH%2F8OLv%2F5dg5v%2BOSub%2FnFjm%2F8KW5v%2F%2F%2F%2Bb%2F%2F%2F7m%2F%2FPg7v%2FMqfH%2FsZnz%2F%2FfzTQAAAAD%2F%2F%2F8J%2F%2FDpku2EZcL8up71%2F%2BfW8v%2FUu%2B7%2Fp3Dm%2F6hw5v%2FKo%2Bb%2F4s7m%2F8ip7f%2FkzvP%2FzbD1%2FXxazP%2Fw6ZH%2F%2F%2F8O%2F%2Fn1SP%2F18ILtooy19Zt16v%2FUvfL%2Fz7Xy%2F9G07%2F%2FDmub%2F1bnm%2F%2FDn7v%2Fw4%2FL%2F38jy%2FYhb6%2FeTfbn%2F9fCB%2F%2FfyVf%2Fy63v%2F9O6N%2FPX1Hed%2BW7z%2BuZjq%2F%2Bja9P%2Fo2PH%2F4c3y%2F9i%2F8v%2Ft3%2FL%2F4s%2F0%2FKV%2B6%2BlUL8f77%2B0c%2F%2FTujf%2Fy64H%2F7OKA%2F%2FTvhv%2F%2F%2FwL35OAa9rmgwP%2F58On%2B7eL2%2F%2Bre%2BP7j1Pj%2B4M72%2BrCN6uNeOcb22dQi%2F%2F%2F%2FAf%2F074H%2F7OKG%2F%2FLsbf%2Fs4qj%2F%2F%2F8J%2F%2F%2F%2FDv3y8EX84tbL%2Fenh2v7m2vn93s%2F6%2BMq42%2FS6p8z77OhM%2F%2F%2F%2FD%2F%2F%2F%2Fwj%2F7eSc%2F%2FHqev%2F%2F%2Fwn%2F6NyN%2F%2BjcvP%2Fw6KH%2F8ema%2F%2B%2Fmk%2F%2Fv54%2F%2F%2B%2Fk2%2F%2Fv6MP%2Fv54z%2F7%2BaU%2F%2FDpmf%2Fw6KH%2F6d65%2FubZmP%2F%2F%2FwwAAAAA%2F%2F%2F%2FBf%2F59UP%2B7eNl%2FvPtVv%2F%2F%2Fx7%2F%2F%2F8CAAAAAAAAAAD%2F%2F%2F8C%2F%2F%2F%2FG%2F%2F07lP%2B7eNl%2F%2Fj0R%2F%2F%2F%2FwcAAAAAg8GsQQAArEEAAKxBAASsQQAArEEAAKxBAACsQYABrEGAAaxBAACsQQAArEEAAKxBAACsQQAArEEAAKxBgYGsQQ%3D%3D</Image>', '<Language>' . DEFAULT_LANG . '</Language>', '<InputEncoding>UTF-8</InputEncoding>', '<OutputEncoding>UTF-8</OutputEncoding>', '<Url type="text/html" method="' . (!PLUGIN_SEARCH_DISABLE_GET_ACCESS ? 'get' : 'post') . '" template="' . Router::get_script_uri() . '">', '<Param name="cmd" value="search" />', '<Param name="encode_hint" value="' . PKWK_ENCODING_HINT . '" />', '<Param name="type" value="AND" />', '<Param name="word" value="{searchTerms}" />', '</Url>', '<Url type="application/x-suggestions+json" template="' . Router::get_cmd_uri('list', null, null, array('type' => 'json')) . '&amp;word={searchTerms}" />', '<moz:SearchForm>' . Router::get_cmd_uri('search') . '</moz:SearchForm>', '</OpenSearchDescription>');
            header('Content-Type:application/opensearchdescription+xml');
            echo join("\n", $ret);
            exit;
            break;
        default:
            if ($s_word !== '') {
                // Search
                $msg = str_replace('$1', $s_word, $_search_msg['title_result']);
                $body = Search::do_search($vars['word'], $type, FALSE, $base);
            } else {
                // Init
                unset($vars['word']);
                // Stop using $_msg_word at lib/html.php
                $msg = $_search_msg['title_search'];
                $body = '<p>' . $_search_msg['msg_searching'] . '</p>' . "\n";
            }
            // Show search form
            $bases = $base == '' ? array() : array($base);
            $body .= plugin_search_search_form($s_word, $type, $bases);
            break;
    }
    return array('msg' => $msg, 'body' => $body);
}
Example #30
0
function plugin_source_action()
{
    global $vars, $_source_messages;
    if (PKWK_SAFE_MODE) {
        die_message('PKWK_SAFE_MODE prohibits this');
    }
    $page = isset($vars['page']) ? $vars['page'] : '';
    $vars['refer'] = $page;
    if (!is_page($page) || !check_readable($page, false, false)) {
        return array('msg' => $_source_messages['msg_notfound'], 'body' => $_source_messages['err_notfound']);
    }
    return array('msg' => $_source_messages['msg_title'], 'body' => '<pre id="source">' . htmlsc(join('', get_source($page))) . '</pre>');
}