Y/m/d H:i "); /* 日時自動記入するとき設定 */
$lmt = 100; /* 投稿文字数制限 */
$kugiri = '
'; /* 記事の区切り */
/* ここまで *///////////////////////////////////////////////////////////////////////
mb_language("Japanese");
mb_internal_encoding($setchar);
if (preg_match('/utf/i', $setchar)) {
$charcode = 'utf8';
}
if (preg_match('/shift|sjis/i', $setchar)) {
$charcode = 'sjis';
}
if (preg_match('/euc/i', $setchar)) {
$charcode = 'eucjp';
}
if (preg_match('/^jis|2022/i', $setchar)) {
$charcode = 'jis';
}
mb_internal_encoding($charcode);
// Handle the stripping of magic quotes
if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) {
$process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
foreach ($process as &$val) {
foreach ($val as $k => $v) {
unset($val[$k]);
if (is_array($v)) {
$val[stripslashes($k)] = $v;
$process[] = &$val[stripslashes($k)];
} else {
$val[stripslashes($k)] = stripslashes($v);
}
}
}
}
if (file_exists("hpcomment.msg")) {
$comment = file_get_contents("hpcomment.msg");
}
$_POST['comment'] = str_replace(' ', ' ', $_POST['comment']);
if (!preg_match("/[\e\200-\377]/", $_POST['comment']) || mb_strlen($_POST['comment']) > $lmt) {
$_POST['comment'] = "";
}
if ($_POST['comment']) {
$_POST['comment'] = preg_replace("/(\x20|
)+$/i", "", $_POST['comment']);
$m1 = array('&', '"', '#', '$', '%', '\'', '`', '<', '>', '=', '?', '/');
$m2 = array('&', '"', '#', '$', '%', ''', '`', '<', '>', '=', '?', '/');
$_POST['comment'] = str_replace($m1, $m2, $_POST['comment']);
$comment = $pdate . $_POST['comment'] . "\n" . $comment;
file_put_contents("hpcomment.msg", $comment);
$btn = "parent.document.getElementById('submit').disabled=true;";
}
$comment = str_replace("\r", "", rtrim($comment));
$comment = str_replace("\n", "$kugiri", rtrim($comment));
if ($_GET['rep'] && !$_POST['comment']) {
$comment = "";
}
header("cache-control: no-store, no-cache, must-revalidate");
header("cache-control: post-check=0, pre-check=0");
header("content-type: text/html; charset=Shift_JIS");
if ($comment) {
$comment = preg_replace("/ /", " ", $comment);
$comment = preg_replace("/<br>/i", "
", $comment);
$comment = preg_replace("/<b>/i", "", $comment);
$comment = preg_replace("/</b>/i", "", $comment);
$js = "parent.document.getElementById('commentv').innerHTML='$comment';
parent.document.getElementById('commentv').style.display='block';
parent.document.getElementById('comment').value='';";
} else {
$js = "return false;";
}
print <<