"hide_php" にファイルをアップロード

このコミットが含まれているのは:
may 2024-03-25 15:52:02 +09:00
コミット 77af6cb960
5個のファイルの変更200行の追加133行の削除

ファイルの表示

@ -1,10 +1,12 @@
<?php
//直接アクセスしちゃだめ
#エスケープ規定保存時はエスケープ、クッキーは表示時にエスケープ
#エスケープ規定: 保存時はエスケープ、クッキーは表示時にエスケープ
#順番待ち規定: スレッド、スレッド作成、板編集の順番で優先する
require $d_root.'/hide_php/conf/c.php';
require $d_root.'/hide_php/conf/submit.php';
require $d_root.'/hide_php/conf/form.php';
require $d_root.'/hide_php/conf/bbs.php';
header("Content-Security-Policy:connect-src 'self';object-src 'none';base-uri 'self';script-src 'none';");
@ -39,7 +41,8 @@ function vi_image_type($image_file_type, $white_type_list){
}
$date = date('Y年m月d日 H時i分');
$w = ':';
$w = '-';
$bbs_dir = $d_root.'/sqlike/bbs';
$reason_session = '<h1>認証に失敗</h1><p>フォームの認証に失敗しました。大変申し訳ございませんが、このエラーの場合は<b>入力内容が保存されない</b>場合がございます。</p><p>この画面が何度も表示される場合は、投稿フォームをリロードして下さい。</p>';
$reason_input = '<h1>入力ミス</h1>未入力の項目があります。(タイトル)と名前とコメントは必須です。<br>';
@ -59,7 +62,7 @@ if (isset($_POST['submit'])){
if (isset($_POST['board'])){
$meta = h($_POST['board']);
if (is_dir($d_root.'/sqlike/bbs/'.$meta) === false){
if (is_dir($bbs_dir.'/'.$meta) === false){
form_die();
}
@ -72,7 +75,7 @@ if (isset($_POST['submit'])){
$area = explode($w, $meta);
$board = (int)$area[0];
$thread = (int)$area[1];
$meta = (string)$board.':'.(string)$thread;
$meta = (string)$board.$w.(string)$thread;
} else {
$board = (int)substr($meta, 0, 1);
$thread = (int)substr($meta, 1);
@ -85,7 +88,7 @@ if (isset($_POST['submit'])){
if (empty($thread)){
form_die();
}
$thread_file = $d_root.'/sqlike/bbs/'.$board.'/'.$thread.'.txt';
$thread_file = $bbs_dir.'/'.$board.'/'.$thread.'.txt';
if (file_exists($thread_file) === false){
form_die();
}
@ -206,10 +209,10 @@ $output = '<p>貴方は新しくスレッドを<b class="color_bl">作成</b>し
form_die();
}
$image_name = mt_rand().'.'.$image_file_type;
$path = $d_root.'/sqlike/bbs/file/'.$image_name;
$path = $bbs_dir.'/file/'.$image_name;
while (file_exists($path)){
$image_name = mt_rand().'.'.$image_file_type;
$path = $d_root.'/sqlike/bbs/file/'.$image_name;
$path = $bbs_dir.'/file/'.$image_name;
}
$upload_image = file_put_contents($path, base64_decode($image_text), LOCK_EX);
$content = $content.'{{'.$image_name.'}}';
@ -218,7 +221,7 @@ $output = '<p>貴方は新しくスレッドを<b class="color_bl">作成</b>し
//板をロック
file_lock('make_thread:'.$board);
//板が消された場合
if (!file_exists($d_root.'/sqlike/bbs/'.$board)){
if (!file_exists($bbs_dir.'/'.$board)){
if (isset($upload_image)){
if ($upload_image !== false){
unlink($path);
@ -230,7 +233,7 @@ $output = '<p>貴方は新しくスレッドを<b class="color_bl">作成</b>し
//スレッドの最大番号
$max_thread_id = 0;
$thread_files = scandir($d_root.'/sqlike/bbs/'.$board);
$thread_files = scandir($bbs_dir.'/'.$board);
foreach ($thread_files as $thread_file){
if (substr($thread_file, 0, 1) === '.'){
continue;
@ -245,7 +248,7 @@ $output = '<p>貴方は新しくスレッドを<b class="color_bl">作成</b>し
//新規ファイル
$thread_id = $max_thread_id + 1;
$thread_file = $d_root.'/sqlike/bbs/'.$board.'/'.$thread_id.'.txt';
$thread_file = $bbs_dir.'/'.$board.'/'.$thread_id.'.txt';
//パスワードはハシッシュ化
$string = $title.PHP_EOL.L1(implode("'", ['1', $name, t_key($name, $key), $date, $color, $content, pass($edit_pass)])).PHP_EOL;
@ -374,10 +377,10 @@ $output = '<p>貴方はスレッド「<b class="color_bl">'.get($thread_file, 1)
form_die();
}
$image_name = mt_rand().'.'.$image_file_type;
$path = $d_root.'/sqlike/bbs/file/'.$image_name;
$path = $bbs_dir.'/file/'.$image_name;
while (file_exists($path)){
$image_name = mt_rand().'.'.$image_file_type;
$path = $d_root.'/sqlike/bbs/file/'.$image_name;
$path = $bbs_dir.'/file/'.$image_name;
}
$upload_image = file_put_contents($path, base64_decode($image_text), LOCK_EX);
$content = $content.'{{'.$image_name.'}}';

ファイルの表示

@ -3,6 +3,7 @@
require $d_root.'/hide_php/conf/c.php';
require $d_root.'/hide_php/conf/submit.php';
require $d_root.'/hide_php/conf/form.php';
require $d_root.'/hide_php/conf/bbs.php';
$nonce = one_time_pass(20, 30);
header("Content-Security-Policy:connect-src 'self';object-src 'none';base-uri 'self';script-src 'nonce-{$nonce}';");
@ -70,9 +71,9 @@ function get_owner_passwd($board){
global $d_root;
if ($board >= 200){
$board_file = $d_root.'/sqlike/bbs/user_board/'.$board.'.txt';
(file_exists($board_file)?$board_data = explode('<<', get($board_file, 1)):exit);
list($board_title, $board_description, $board_content, $board_own, $board_passwd) = $board_data;
return strval($board_passwd);
(file_exists($board_file)?$board_data = explode("'", get($board_file, 1)):exit);
list($board_title, $board_description, $board_content, $board_access_passwd, $board_edit_passwd) = $board_data;
return (string)$board_edit_passwd;
} else {
$keyfile = $d_root.'/sqlike/own/master_key.txt';
return pass((file_exists($keyfile)?get($keyfile, 1):exit));
@ -95,7 +96,9 @@ function remove_images_from_thread($thread_file){
}
}
$w = ':';
$w = '-';
$bbs_dir = $d_root.'/sqlike/bbs';
$reason_session = '<h1>認証に失敗</h1>フォームの認証に失敗しました。<br><p>この画面が何度も表示される場合は、投稿フォームをリロードして下さい。</p>';
$reason_passwd = '<h1>照合エラー</h1>編集パスワードが間違っています。<br>';
//前提条件ここまで
@ -129,7 +132,7 @@ $submit = $_POST['submit'];
$area = explode($w, $meta);
$board = (int)$area[0];
$thread = (int)$area[1];
$areas = (string)$board.':'.(string)$thread;
$areas = (string)$board.$w.(string)$thread;
} else {
$board = (int)substr($meta, 0, 1);
$thread = (int)substr($meta, 1);
@ -142,7 +145,7 @@ $submit = $_POST['submit'];
if (empty($thread)){
form_die();
}
$thread_file = $d_root.'/sqlike/bbs/'.$board.'/'.$thread.'.txt';
$thread_file = $bbs_dir.'/'.$board.'/'.$thread.'.txt';
if (file_exists($thread_file) === false){
form_die();
}
@ -208,7 +211,7 @@ $output = '<h1>パスワードを入力</h1>
}
if ($hashed === $master_key){
$notice = '<p><b class="color_bl">管理人</b>モードで編集しています。(コメントがエスケープされません。「&lt」は「'.h('&lt').'」にする等の対策が必要です)</p>';
$notice = '<p><b class="color_bl">管理人</b>モードで編集しています。(本文がエスケープされません。「&lt」は「'.h('&lt').'」にする等の対策が必要です)</p>';
$comment_text = h(preg_replace('/{{[0-9].*}}/', '', str_replace('<br>', PHP_EOL, $content_p)));
} else {
$notice = '<p><b class="color_bl">通常</b>モードで編集しています。(特に気をつけるポイントはありません)</p>';
@ -219,7 +222,7 @@ $output = '<h1>パスワードを入力</h1>
$s_key=(isset($_COOKIE['key'])?s_pass_d($_COOKIE['key']):'');
//文字色リスト
$color_option = '<span>文字色<br>';
$color_option = '<div><p>文字色<br>';
$count = 0;
foreach ($color_list as $c){
$color_option = $color_option.'<label class="'.$c.'"><input type="radio" name="color" value="'.$c.'" id="'.$c.'"';
@ -229,7 +232,7 @@ $output = '<h1>パスワードを入力</h1>
$color_option = $color_option.'>'.$color_name_list[$count].'</label> ';
++$count;
}
$color_option = $color_option.'</span>';
$color_option = $color_option.'</p></div>';
$comment_array = [$thread_id_p, $name_p, $key_p, $date_p, $color_p, $content_p];
@ -338,7 +341,7 @@ $output = '<h1>内容を修正</h1>'.$notice.'<p>以下、もとの内容です
if (isset($_POST['check'])){
if ($_POST['check'] === 'del'){
$past_image = $d_root.'/sqlike/bbs/file/'.$image_name;
$past_image = $bbs_dir.'/file/'.$image_name;
if (file_exists($past_image)){
if (!empty($image_name)){
unlink($past_image);
@ -353,10 +356,10 @@ $output = '<h1>内容を修正</h1>'.$notice.'<p>以下、もとの内容です
form_die();
}
$image_name = mt_rand().'.'.$image_file_type;
$path = $d_root.'/sqlike/bbs/file/' .$image_name;
$path = $bbs_dir.'/file/' .$image_name;
while (file_exists($path)){
$image_name = mt_rand().'.'.$image_file_type;
$path = $d_root.'/sqlike/bbs/file/'.$image_name;
$path = $bbs_dir.'/file/'.$image_name;
}
file_put_contents($path, base64_decode($image_text), LOCK_EX);
}

49
hide_php/login.php ノーマルファイル
ファイルの表示

@ -0,0 +1,49 @@
<?php
//直接アクセスしちゃだめ
require $d_root.'/hide_php/conf/c.php';
require $d_root.'/hide_php/conf/submit.php';
require $d_root.'/hide_php/conf/form.php';
header("Content-Security-Policy:connect-src 'self';object-src 'none';base-uri 'self';script-src 'none';");
//定義
if (isset($_GET['Board'])){
$board = (int)$_GET['Board'];
} else {
not_found();
}
if ($board === 0){
not_found();
}
if (isset($_POST['session_num'], $_POST['access_passwd'])){
$url = (isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:'unset');
if (check_session('login', $_POST['session_num'], $url, true)){
setcookie('login:'.$board, s_pass_e(h($_POST['access_passwd'])), ['expires' => time() + 9999, 'path' => '/', 'samesite' => 'Strict']);
header('Location:./board.php?Board='.$board);
exit;
}
}
$session_num = one_time_pass(50, 100);
set_session('login', $session_num);
######html開始
html_head('ログイン-', '', '', false);
echo '<h1>ログイン</h1>';
echo '<form action="" method="POST">
<input type="hidden" name="session_num" value="'.$session_num.'">
<p><label><b>アクセスパスワード</b><input type="text" name="access_passwd" style="background:#fff;color:#111;width:40%;font-size:1em;height:1.4em;"></label><button type="submit" style="background:#eef;padding:.3em;">ログイン</button></p>
</form>';
html_foot('', '');

ファイルの表示

@ -6,7 +6,7 @@ header("Content-Security-Policy:connect-src 'self';object-src 'none';base-uri 's
if (isset($_GET['Page'])){
$page = $_GET['Page'];
if (preg_match('/^([0-9]|[a-z]|[A-Z])+$/', $page) !== 1){
if (preg_match('/^([0-9]|[a-z]|[A-Z]|-|_)+$/', $page) !== 1){
$page = (int)$page;
}
} else {
@ -16,15 +16,21 @@ if (isset($_GET['Page'])){
$file = $d_root.'/sqlike/html/menu/'.$page.'.html';
if (file_exists($file)){
$page_title = get($file, 1);
$page_head = explode("'", get($file, 1));
$page_title = $page_head[0];
$content = implode(get_rows($file, 2));
} else {
not_found();
}
if ($page_head[1] === 'noindex'){
$robots = false;
} else {
$robots = true;
}
#############html開始
html_head($page_title.'-', 'メニューページです。ブログのようなものです。', '', true);
html_head($page_title.'-', 'メニューページです。ブログのようなものです。', '', $robots);
echo '<h1>'.$page_title.'</h1>';
echo $content;
html_foot('', '');

ファイルの表示

@ -50,81 +50,87 @@ function remove_images_from_thread($thread_file){
}
}
$reason_session = '<h1>認証に失敗</h1>フォームの認証に失敗しました。大変申し訳ございませんが、このエラーの場合は<b>入力内容が保存されない</b>場合がございます。<br>';
$reason_input = '<h1>入力ミス</h1>未入力の項目があります。(タイトル)と名前とコメントは必須です。<br>特にスレッドを作成するときにタイトルが入力されないと大変なことになります。<br>';
//関数
$date = date('Y年m月d日 H時i分');
$bbs_dir = $d_root.'/sqlike/bbs';
//投稿した
if (isset($_POST['submit'])){
$reason_session = '<h1>認証に失敗</h1>フォームの認証に失敗しました。大変申し訳ございませんが、このエラーの場合は<b>入力内容が保存されない</b>場合がございます。<br>';
$reason_input = '<h1>入力ミス</h1><p>未入力の項目があります。</p><p>タイトルと管理パスワードは必須です。</p>';
//定義
//共通の認証 板やスレッドの同定も
if (isset($_POST['session_num'])){
$session_num = h($_POST['session_num']);
$url = (isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:'unset');
if (check_session('mkboard', $session_num, $url, true)){
if (isset($_POST['submit'], $_POST['session_num'])){
$url = (isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:'unset');
if (check_session('mkboard', $_POST['session_num'], $url, true)){
//switch長いよ
switch ($_POST['submit']){
case 'mkboard':
(isset($_POST['user'])?$user=$_POST['user']:form_die());
(empty($user)?form_die():$user=h($user));
(isset($_POST['title'])?$title=h($_POST['title']):form_die());
(isset($_POST['description'])?$description=h($_POST['description']):form_die());
(isset($_POST['content'])?$content=$_POST['content']:form_die());
(isset($_POST['html'])?$html=h($_POST['html']):form_die());
(isset($_POST['edit_pass'])?$edit_pass=h($_POST['edit_pass']):form_die());
if (not_empty($title) && not_empty($edit_pass)){
(($html==='no')?$v_content=p($content):$v_content=L1($content));
$post_list = [];
$form_key = ['title', 'description', 'content', 'html', 'access_pass', 'edit_pass', 'full_name'];
foreach ($form_key as $post){
if (!isset($_POST[$post])){
form_die();
} else {
$post_list[] = $_POST[$post];
}
}
list($title, $description, $content, $html, $access_pass, $edit_pass, $full_name) = $post_list;
if (not_empty($title) && not_empty($html) && not_empty($edit_pass)){
if ($html !== 'yes'){
$content = h($content);
}
//セッションの代用
$session_num = one_time_pass(50, 100);
set_session('mkboard', $session_num);
$output = '<h1>プレビュー</h1><p>以下の内容で板を作成します。</p><p><br></p>
<p>タイトル:'.$title.'</p>
<p>説明:'.$description.'</p>
<p>中身:'.$v_content.'</p>
<p>管理パスワード:'.$edit_pass.'</p>
$output = '<h1>プレビュー</h1><p>以下の内容で板を作成します。</p>
<p>タイトル:'.h($title).'</p>
<p>説明:'.h($description).'</p>
<p>内容:'.$content.'</p>
<p>アクセスパスワード:'.h($access_pass).'</p>
<p>管理パスワード:'.h($edit_pass).'</p>
<form action="" method="POST">
<input type="hidden" name="session_num" value="'.$session_num.'">
<input type="hidden" name="user" value="'.$user.'">
<input type="hidden" name="title" value="'.$title.'">
<input type="hidden" name="description" value="'.$description.'">
<input type="hidden" name="title" value="'.h($title).'">
<input type="hidden" name="description" value="'.h($description).'">
<input type="hidden" name="content" value="'.h($content).'">
<input type="hidden" name="html" value="'.$html.'">
<input type="hidden" name="edit_pass" value="'.$edit_pass.'">
<p class="c"><button type="submit" name="submit" value="post" class="enter">決定</button></p>
<input type="hidden" name="html" value="'.h($html).'">
<input type="hidden" name="access_pass" value="'.h($access_pass).'">
<input type="hidden" name="edit_pass" value="'.h($edit_pass).'">
<input type="hidden" name="full_name" value="'.h($full_name).'">
<input type="hidden" name="session_num" value="'.$session_num.'">
<p class="c"><button type="submit" name="submit" value="post" class="enter">作成</button></p>
</form>';
} else {
$output = $reason_input;
}
break;
case 'post':
(isset($_POST['user'])?$user=h($_POST['user']):form_die());
(isset($_POST['title'])?$title=h($_POST['title']):form_die());
(isset($_POST['description'])?$description=h($_POST['description']):form_die());
(isset($_POST['content'])?$content=$_POST['content']:form_die());
(isset($_POST['html'])?$html=h($_POST['html']):form_die());
(isset($_POST['edit_pass'])?$edit_pass=h($_POST['edit_pass']):form_die());
if (!not_empty($title) || !not_empty($edit_pass)){
form_die();
$post_list = [];
$form_key = ['title', 'description', 'content', 'html', 'access_pass', 'edit_pass', 'full_name'];
foreach ($form_key as $post){
if (!isset($_POST[$post])){
form_die();
} else {
$post_list[] = $_POST[$post];
}
}
(($html==='no')?$content=p($content):$content=str_replace('<<', '', L1($content)));
list($title, $description, $content, $html, $access_pass, $edit_pass, $full_name) = $post_list;
if (not_empty($title) && not_empty($html) && not_empty($edit_pass)){
if ($html !== 'yes'){
$content = p($content);
} else {
$content = str_replace("'", '', $content);
}
//ロック
file_lock('make_board');
//利用者作成板の最大番号
$user_boards = scandir($d_root.'/sqlike/bbs/user_board');
$user_boards = scandir($bbs_dir.'/user_board');
$max_board_id = 199;
foreach ($user_boards as $user_board){
if (substr($user_board, 0, 1) === '.'){
@ -140,49 +146,51 @@ $output = '<h1>プレビュー</h1><p>以下の内容で板を作成します。
//新規ファイル
$board_id = $max_board_id + 1; //最低でも200
$board_file = $d_root.'/sqlike/bbs/user_board/'.$board_id.'.txt';
$string = L1(implode('<<', [$title, $description, $content, $user, pass($edit_pass)])).PHP_EOL;
$board_file = $bbs_dir.'/user_board/'.$board_id.'.txt';
$string = L1(implode("'", [h($title), h($description), $content, pass(h($access_pass)), pass(h($edit_pass))])).PHP_EOL.$full_name.PHP_EOL;
file_put_contents($board_file, $string, LOCK_EX);
$board_dir = $d_root.'/sqlike/bbs/'.$board_id;
$board_dir = $bbs_dir.'/'.$board_id;
mkdir($board_dir, 0777);
//解除
file_unlock('make_board');
$output = '<h1>作成成功</h1><p>板の作成に成功したと思います。</p><p><a href="/board.php?Board='.$board_id.'">板のURL</a></p><p>管理パスワードは「マスターキー」として使えます。あるいは、設定変更に必要となります。</p>';
break;
} else {
form_die();
}
break;
case 'edit':
(isset($_POST['board'])?$board=(int)$_POST['board']:form_die());
$s_edit_pass=(isset($_COOKIE['edit_pass'])?s_pass_d($_COOKIE['edit_pass']):'');
//セッションの代用
$session_num = one_time_pass(50, 100);
set_session('mkboard', $session_num);
$output = '<h1>パスワードを入力</h1>
<p>管理パスワードを入力して下さい。</p>
$output = '<h1>パスワードを入力</h1><p>管理パスワードを入力して下さい。</p>
<form action="" method="POST">
<input type="hidden" name="session_num" value="'.$session_num.'">
<input type="hidden" name="board" value="'.$board.'">
<label>パスワード<input type="text" name="edit_passwd" style="background:#fff;color:#a04;border:solid 0.1em #111;"></label>
<label>パスワード<input type="text" name="edit_passwd" value="'.h($s_edit_pass).'" style="background:#fff;color:#a04;border:solid 0.1em #111;"></label>
<button type="submit" name="submit" value="editing" class="enter">編集</button>
</form>';
break;
case 'editing':
(isset($_POST['board'])?$board=(int)$_POST['board']:form_die());
(isset($_POST['edit_passwd'])?$edit_passwd=$_POST['edit_passwd']:form_die());
$board_file = $d_root.'/sqlike/bbs/user_board/'.$board.'.txt';
(file_exists($board_file)?$board_data=get($board_file, 1):form_die());
$value = explode('<<', $board_data);
$board_title = $value[0];
$board_description = $value[1];
$board_content = $value[2];
$board_own = $value[3];
$board_passwd = $value[4];
(isset($_POST['edit_passwd'])?$edit_passwd=h($_POST['edit_passwd']):form_die());
$board_file = $bbs_dir.'/user_board/'.$board.'.txt';
$board_head = get($board_file, 1);
if ($board_head === false){
form_die();
}
list($board_title, $board_description, $board_content, $board_access_passwd, $board_edit_passwd) = explode("'", $board_head);
if ($board_passwd === pass($edit_passwd)){
if ($board_edit_passwd === pass($edit_passwd)){
//セッションの代用
$session_num = one_time_pass(50, 100);
@ -194,14 +202,15 @@ $output = '<h1>'.$board_title.'を編集</h1>
<h2>板を編集</h2>
<input type="hidden" name="session_num" value="'.$session_num.'">
<input type="hidden" name="board" value="'.$board.'">
<input type="hidden" name="user" value="'.$board_own.'">
<input type="hidden" name="full_name" value="'.get($board_file, 2).'">
<input type="hidden" name="edit_pass_p" value="'.$edit_passwd.'">
<P><label>タイトル<input type="text" name="title" value="'.$board_title.'"></label></p>
<p><label>説明<input type="text" name="description" value="'.$board_description.'" style="width:75%;"></label></p>
<p><label>コンテンツ<br><textarea rows="15" name="content">'.h($board_content).'</textarea></label></p>
<p><label>コンテンツ<br><textarea rows="8" name="content">'.h($board_content).'</textarea></label></p>
<p>コンテンツをHTMLとしますか? (HTMLが分からない方は「いいえ」にチェックして下さい)<br>
<label><input type="radio" name="html" value="yes" checked>はい</label> <label><input type="radio" name="html" value="no">いいえ</label></p>
<p><label>管理パスワード<input type="text" name="edit_pass" value="'.$edit_passwd.'"></label></p>
<p><br></p>
<p>パスワード:<br><label>入室<input type="text" name="access_pass"></label><label><b>管理</b><input type="text" name="edit_pass" value="'.$edit_passwd.'"></label></p>
<p style="float:right;"><button type="submit" name="submit" value="edited" class="enter">編集完了</button></p>
<p><br></p>
<h3>危険な操作</h2>
@ -214,33 +223,37 @@ $output = '<h1>'.$board_title.'を編集</h1>
}
break;
case 'edited':
(isset($_POST['board'])?$board=(int)$_POST['board']:form_die());
(isset($_POST['user'])?$user=h($_POST['user']):form_die());
(isset($_POST['title'])?$title=h($_POST['title']):form_die());
(isset($_POST['description'])?$description=h($_POST['description']):form_die());
(isset($_POST['content'])?$content=$_POST['content']:form_die());
(isset($_POST['html'])?$html=h($_POST['html']):form_die());
(isset($_POST['edit_pass_p'])?$edit_pass_p=h($_POST['edit_pass_p']):form_die());
(isset($_POST['edit_pass'])?$edit_pass=h($_POST['edit_pass']):form_die());
(isset($_POST['kill_board'])?$kill_board=$_POST['kill_board']:form_die());
$post_list = [];
$form_key = ['title', 'description', 'content', 'html', 'access_pass', 'edit_pass', 'edit_pass_p', 'full_name', 'kill_board'];
foreach ($form_key as $post){
if (!isset($_POST[$post])){
form_die();
} else {
$post_list[] = $_POST[$post];
}
}
list($title, $description, $content, $html, $access_pass, $edit_pass, $edit_pass_p, $full_name, $kill_board) = $post_list;
if (not_empty($title) && not_empty($edit_pass)){
(($html==='no')?$content=p($content):$content=str_replace('<<', '', L1($content)));
if ($html !== 'yes'){
$content = p($content);
} else {
$content = str_replace("'", '', $content);
}
$board_file = $d_root.'/sqlike/bbs/user_board/'.$board.'.txt';
$board_dir = $d_root.'/sqlike/bbs/'.$board;
(file_exists($board_file)?$board_data=get($board_file, 1):form_die());
$value = explode('<<', $board_data);
$board_title = $value[0];
$board_description = $value[1];
$board_content = $value[2];
$board_own = $value[3];
$board_passwd = $value[4];
$board_file = $bbs_dir.'/user_board/'.$board.'.txt';
$board_dir = $bbs_dir.'/'.$board;
$board_head = get($board_file, 1);
$board_maker = get($board_file, 2);
if ($board_maker === false){
not_found();
}
list($board_title, $board_description, $board_content, $board_access_passwd, $board_edit_passwd) = explode("'", $board_head);
if ($board_passwd === pass($edit_pass_p)){
if (($board_edit_passwd === pass($edit_pass_p)) && ($full_name === $board_maker)){
##危険##
if ($kill_board === '削除します'){
@ -262,46 +275,39 @@ $output = '<h1>'.$board_title.'を編集</h1>
}
unlink($board_file);
} else {
$string = L1(implode('<<', [$title, $description, $content, $user, pass($edit_pass)])).PHP_EOL;
$string = L1(implode("'", [h($title), h($description), $content, pass($access_pass), pass($edit_pass)])).PHP_EOL.$full_name.PHP_EOL;
file_put_contents($board_file, $string, LOCK_EX);
}
$output = '<h1>編集成功?</h1><p>板の編集に成功したと思います。</p><p><a href="../board.php?Board='.$board.'">板のURL</a></p>';
$output = '<h1>編集成功?</h1><p>板の編集に成功したと思います。</p><p><a href="/board.php?Board='.$board.'">板のURL</a></p>';
} else {
$output = '<h1>認証エラー</h1><p>パスワードが違います。</p>';
form_die();
}
} else {
$output = $reason_input;
}
break;
default:
not_found();
form_die();
break;
}
//switchi終わり
} else {
$output = $reason_session;
}
//認証結果
} else {
$output = $reason_session;
}
//トークン送信
} else {
form_die();
}
//投稿
#############html開始
html_head('板の作成と編集-', '', $d_root.'/sqlike/css/form/bbs.css', false);
###########html開始
html_head('板の作成・編集', '', $d_root.'/sqlike/css/form/bbs.css', false);
if (isset($output)){
echo $output;
echo $output;
}
echo '<p><br></p><p><a href="./">戻る</a></p><p><br></p><p><br></p>';
echo '<p><br></p><p><a href="./">戻る</a></p>';
html_foot('', '');