<?php
-// $Id: insert.inc.php,v 1.11 2004/10/09 08:01:58 henoheno Exp $
-
-/////////////////////////////////////////////////
-// ¥Æ¥¥¹¥È¥¨¥ê¥¢¤Î¥«¥é¥à¿ô
-define('INSERT_COLS',70);
-/////////////////////////////////////////////////
-// ¥Æ¥¥¹¥È¥¨¥ê¥¢¤Î¹Ô¿ô
-define('INSERT_ROWS',5);
-/////////////////////////////////////////////////
-// ÁÞÆþ¤¹¤ë°ÌÃÖ 1:Íó¤ÎÁ° 0:Íó¤Î¸å
-define('INSERT_INS',1);
+// $Id: insert.inc.php,v 1.16 2011/01/25 15:01:01 henoheno Exp $
+//
+// Text inserting box plugin
+
+define('INSERT_COLS', 70); // Columns of textarea
+define('INSERT_ROWS', 5); // Rows of textarea
+define('INSERT_INS', 1); // Order of insertion (1:before the textarea, 0:after)
function plugin_insert_action()
{
global $script, $vars, $cols, $rows;
global $_title_collided, $_msg_collided, $_title_updated;
- if (! isset($vars['msg']) || $vars['msg'] == '') {
- return;
- }
+ 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" : '';
+ $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']) {
+ 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;
- }
+ if (INSERT_INS) $postdata .= $line;
}
- $postdata_input = "$insert\n";
+ $postdata_input = $insert . "\n";
+ $body = '';
if (md5(@join('', get_source($vars['refer']))) != $vars['digest']) {
$title = $_title_collided;
- $body = "$_msg_collided\n";
+ $body = $_msg_collided . "\n";
- $s_refer = htmlspecialchars($vars['refer']);
- $s_digest = htmlspecialchars($vars['digest']);
- $s_postdata_input = htmlspecialchars($postdata_input);
+ $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="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 {
+ } else {
page_write($vars['refer'], $postdata);
$title = $_title_updated;
}
- $retvars['msg'] = $title;
+ $retvars['msg'] = $title;
$retvars['body'] = $body;
$vars['page'] = $vars['refer'];
return $retvars;
}
+
function plugin_insert_convert()
{
global $script, $vars, $digest;
global $_btn_insert;
static $numbers = array();
- if (! isset($numbers[$vars['page']]))
- {
- $numbers[$vars['page']] = 0;
- }
+ if (PKWK_READONLY) return ''; // Show nothing
+
+ if (! isset($numbers[$vars['page']])) $numbers[$vars['page']] = 0;
+
$insert_no = $numbers[$vars['page']]++;
- $s_page = htmlspecialchars($vars['page']);
- $s_digest = htmlspecialchars($digest);
- $s_cols = INSERT_COLS;
- $s_rows = INSERT_ROWS;
- $string = <<<EOD
+ $s_page = htmlsc($vars['page']);
+ $s_digest = htmlsc($digest);
+ $s_cols = INSERT_COLS;
+ $s_rows = INSERT_ROWS;
+ $string = <<<EOD
<form action="$script" method="post">
<div>
<input type="hidden" name="insert_no" value="$insert_no" />