gaku-ura/hide_php/board.php

149 行
5.6 KiB
PHP
Raw パーマリンク Blame 履歴

このファイルには不可視のUnicode文字が含まれています

このファイルには人間が識別できない不可視のUnicode文字が含まれており、コンピューターによって特殊な処理が行われる可能性があります。 それが意図的なものと考えられる場合は、この警告を無視して構いません。 不可視文字を表示するにはエスケープボタンを使用します。

<?php
//直接アクセスしちゃだめ
require $d_root.'/hide_php/conf/c.php';
require $d_root.'/hide_php/conf/submit.php';
require $d_root.'/hide_php/conf/bbs.php';
function fix_date($date){
$date = explode(' ', $date)[0];
return $date;
}
$bbs_dir = $d_root.'/sqlike/bbs';
//定義
//どの板
if (isset($_GET['Board'])){
$board = (int)$_GET['Board'];
} else {
$board = 1;
}
if (empty($_GET['Board'])){
$board = 1;
}
//セッションの代用
$session_num = one_time_pass(50, 100);
set_session($board, $session_num);
//掲示板のデータを読み込み
if ($board < 200){
$board_data = get($bbs_dir.'/boards.txt', $board);
} else {
$board_data = get($bbs_dir.'/user_board/'.$board.'.txt', 1);
}
if (($board_data === false) || empty($board_data)){
not_found();
}
list($board_title, $board_description, $board_content, $board_access_passwd, $board_edit_passwd) = explode("'", $board_data);
if (($board_access_passwd !== '') && (!isset($_SESSION['login:'.$board]) || ($_SESSION['login:'.$board] !== $board_access_passwd))){
header('Location:./login.php?Board='.$board);
exit;
}
//保存内容を取得
$s_name=(isset($_COOKIE['name'])?$_COOKIE['name']:'');
$s_key=(isset($_SESSION['key'])?$_SESSION['key']:'');
$_SESSION['key'] = $s_key;
$s_edit_pass=(isset($_SESSION['edit_pass'])?$_SESSION['edit_pass']:'');
$_SESSION['edit_pass'] = $s_edit_pass;
$s_color=(isset($_COOKIE['color'])?$_COOKIE['color']:'color_lz');
$s_content=(isset($_COOKIE["comment:{$board}"])?$_COOKIE["comment:{$board}"]:'');
$s_title=(isset($_COOKIE["title:{$board}"])?$_COOKIE["title:{$board}"]:'');
###########html開始
html_head($board_title.'-', $board_description, $d_root.'/sqlike/css/form/bbs.css', true);
//タイトル・一覧表示
echo '<h1>'.$board_title.'</h1>'.$board_content.'<p><br></p><p><a href="/bbs.php">掲示板ホームへ</a></p><p><br></p><main>';
echo '<table border="1"><thead><tr><th width="23%">タイトル</th><th width="23%">作成者</th><th width="23%">最終更新</th><th width="23%">作成日</th><th width="6%">件</th></tr></thead><tbody>';
$thread_count = 0;
$split_len = 20;
$board_path = $bbs_dir.'/'.$board;
$thread_list = [];
if ((int)$board >= 10){
$board_num = $board.'-';
} else {
$board_num = $board;
}
(isset($_GET['View'])?$view_list = (int)$_GET['View']:$view_list = 0);
(($view_list >= 2)?$view_list = $split_len * ($view_list -1):$view_list = 0);
$start = $view_list;
$end = $view_list + $split_len;
//スレッドを探す
$files = scandir($board_path);
if ($files !== false){
foreach ($files as $file){
if (preg_match('/^[0-9]+\.txt/', $file) === 1){
$id = str_replace('.txt', '', $file);
$thread_list[filemtime($board_path.'/'.$file).'.'.$id] = $id;
}
}
}
//並び替える
krsort($thread_list, SORT_NUMERIC);
foreach ($thread_list as $time => $thread_id){
if (($thread_count >= $start) && ($thread_count < $end)){
$thread_file = $board_path.'/'.$thread_id.'.txt';
$thread_title = get($thread_file, 1);
if ($thread_title !== false){
$thread_data = get($thread_file, 2);
if (!empty($thread_data)){
$value = explode("'", $thread_data);
list($comment_id, $name, $key, $date, $color, $content, $edit_pass) = $value;
$thread_n = substr_count(file_get_contents($thread_file), PHP_EOL) -1;
echo '<tr><td><a href="/thread.php?Area='.$board_num.$thread_id.'">'.$thread_title.'</a></td><td><span class="usr">'.user_page($name, $key).'</span></td><td>'.date('Y年m月d日', (int)$time).'</td><td>'.fix_date($date).'</td><td>'.$thread_n.'</td></tr>';
}
}
}
++$thread_count;
}
if ($thread_count === 0){
echo '<tr><td colspan="5">まだスレッドがありません。あなたが一番乗りです。</td></tr>';
}
echo '</tbody></table><p><br></p>';
//ページ分けしないといけない場合
if ($thread_count > $split_len){
echo '<p>複数ページに分けられました。</p><p><br></p>';
if ($start === 0){
echo '<span class="split" style="background:transparent;color:#000;">1</span>';
} else {
echo '<a href="/board.php?Board='.$board.'" class="split">1</a>';
}
$split = 0;
$split_count = 2;
while ($split + $split_len < $thread_count){
if ($end / $split_len === $split_count){
echo ' <span class="split" style="background:transparent;color:#000;">'.$split_count.'</span>';
} else {
echo ' <a href="/board.php?Board='.$board_num.'&View='.$split_count.'" class="split">'.$split_count.'</a>';
}
$split = $split + $split_len;
++$split_count;
}
}
//フォーム
echo '</main><p><br></p><p><br></p><form action="sqlike.php" method="POST" enctype="multipart/form-data" id="form"><h2>新しいスレッドを作成</h2>';
post_warning($s_name, $s_key);
echo '<input type="hidden" name="board" value="'.$board.'"><input type="hidden" name="session_num" value="'.$session_num.'"><p><label><b>タイトル</b><input type="text" name="title" value="'.h($s_title).'"></label></p><p><label><b>名前</b><input type="text" name="name" value="'.h($s_name).'"></label><label>#トリップ<input type="text" name="key" value="'.h($s_key).'"></label></p><p><label><b>一番目の本文</b><br><textarea rows="8" cols="25" name="comment" class="'.$s_color.'" id="text">'.h($s_content).'</textarea></label></p>';
color_options($color_list, $color_name_list, $s_color);
echo '<p><label>編集パスワード:<input type="text" name="edit_pass" value="'.h($s_edit_pass).'"></label></p><p style="float:right;"><label><b>投稿ボタンは此方→</b><button type="submit" name="submit" value="make_thread_view" class="enter">確認</button></label></p><p><label class="file">画像を選択<input type="file" name="image" accept="image/*"></label></p></form>';
html_foot($d_root.'/js/text_color.js', '');