Exemplo n.º 1
0
function plugin_addline_action()
{
    global $script, $vars, $post, $now;
    global $_title_updated;
    global $_addline_messages;
    if (auth::check_role('readonly')) {
        die_message('PKWK_READONLY prohibits editing');
    }
    $refer = $vars['refer'];
    $postdata_old = get_source($refer);
    $configname = $vars['configname'];
    $above = $vars['above'];
    $block_plugin = 1;
    if (array_key_exists('addline_inno', $vars)) {
        $addline_no = $vars['addline_inno'];
        $block_plugin = 0;
    } else {
        if (array_key_exists('addline_no', $vars)) {
            $addline_no = $vars['addline_no'];
        }
    }
    $config = new Config('plugin/addline/' . $configname);
    if (!$config->read()) {
        return array('msg' => 'addline error', 'body' => "<p>config file '" . htmlspecialchars($configname) . "' is not exist.");
    }
    $config->config_name = $configname;
    $addline = join('', addline_get_source($config->page));
    $addline = rtrim($addline);
    if ($block_plugin) {
        $postdata = addline_block($addline, $postdata_old, $addline_no, $above);
    } else {
        $postdata = addline_inline($addline, $postdata_old, $addline_no, $above);
    }
    $title = $_title_updated;
    $body = '';
    if (md5(@join('', $postdata_old)) != $vars['digest']) {
        $title = $_addline_messages['title_collided'];
        $body = $_addline_messages['msg_collided'] . make_pagelink($refer);
    }
    //	$body = $postdata; // debug
    //	foreach ( $vars as $k=>$v ){$body .= "[$k:$v]&br;";}
    page_write($refer, $postdata);
    $retvars['msg'] = $title;
    $retvars['body'] = $body;
    //	$post['page'] = $get['page'] = $vars['page'] = $refer;
    $post['refer'] = $get['refer'] = $vars['refer'] = $refer;
    return $retvars;
}
Exemplo n.º 2
0
function plugin_addline_action()
{
    global $_addline_messages, $_string, $vars;
    if (Auth::check_role('readonly')) {
        die_message($_string['prohibit']);
    }
    $refer = $vars['refer'];
    $wiki = Factory::Wiki($refer);
    $postdata_old = $wiki->get();
    $configname = $vars['configname'];
    $above = $vars['above'];
    $block_plugin = 1;
    if (array_key_exists('addline_inno', $vars)) {
        $addline_no = $vars['addline_inno'];
        $block_plugin = 0;
    } else {
        if (array_key_exists('addline_no', $vars)) {
            $addline_no = $vars['addline_no'];
        }
    }
    $config = new Config('plugin/addline/' . $configname);
    if (!$config->read()) {
        return array('msg' => $_addline_messages['error'], 'body' => '<p class="alert alert-warning">' . sprintf($_addline_messages['config_notfound'], Utility::htmlsc($configname)) . '</p>');
    }
    $config->config_name = $configname;
    $template = addline_get_source($config->page);
    if (!$template) {
        return array('msg' => $_addline_messages['error'], 'body' => '<p class="alert alert-warning">' . sprintf($_addline_messages['config_notfound'], Utility::htmlsc($config->page)) . '</p>');
    }
    $addline = rtrim(join("\n", $template));
    if ($block_plugin) {
        $postdata = addline_block($addline, $postdata_old, $addline_no, $above);
    } else {
        $postdata = addline_inline($addline, $postdata_old, $addline_no, $above);
    }
    $title = $_title_updated;
    $body = '';
    if (md5(join('', $postdata_old)) !== $vars['digest']) {
        $title = $_addline_messages['title_collided'];
        $body = $_addline_messages['msg_collided'] . make_pagelink($refer);
    }
    //	$body = $postdata; // debug
    //	foreach ( $vars as $k=>$v ){$body .= "[$k:$v]&br;";}
    $wiki->set($postdata);
    $retvars['msg'] = $title;
    $retvars['body'] = $body;
    //	$post['page'] = $get['page'] = $vars['page'] = $refer;
    $post['refer'] = $get['refer'] = $vars['refer'] = $refer;
    return $retvars;
}