- Fix bug "thread-list includes future post".
- Add "spoof post timestamp".
- Remove "autoincrement postid"
- Change fallback-post-title.
- Update default style.
このコミットが含まれているのは:
たかし 2023-08-29 14:38:30 +00:00
コミット 928a9a96c3
7個のファイルの変更27行の追加42行の削除

ファイルの表示

@ -1,4 +1,4 @@
# BIBIS, v0.9.2 # BIBIS, v0.9.3
美々蝶々の BBS です。 美々蝶々の BBS です。
## 従属ソフト ## 従属ソフト

ファイルの表示

@ -6,7 +6,6 @@ default_config('USERS_TSV', DATA_ROOT . 'users.tsv');
default_config('LIMIT_TSV', DATA_ROOT . 'repeating-limit.tsv'); default_config('LIMIT_TSV', DATA_ROOT . 'repeating-limit.tsv');
default_config('PROFILE_DIR', DATA_ROOT . 'profile/'); default_config('PROFILE_DIR', DATA_ROOT . 'profile/');
default_config('POST_DIR', DATA_ROOT . 'post/'); default_config('POST_DIR', DATA_ROOT . 'post/');
default_config('POST_LOCK_TXT', DATA_ROOT . 'post-lock.txt');
default_config('ATTACHMENT_DIR', DATA_ROOT . 'attachment/'); default_config('ATTACHMENT_DIR', DATA_ROOT . 'attachment/');
default_config('SITENAME', 'BIBIS'); default_config('SITENAME', 'BIBIS');

ファイルの表示

@ -8,7 +8,7 @@
// "{$datetime}.id{$id}.us{$userid}.to{未使用}.th{$thread_id}.txt" // "{$datetime}.id{$id}.us{$userid}.to{未使用}.th{$thread_id}.txt"
// 内訳: // 内訳:
// $datetime: 投稿日時(ISO形式、タイムゾーンは「Z」固定) // $datetime: 投稿日時(ISO形式、タイムゾーンは「Z」固定)
// $id: 投稿ID(0から始まり1づつ増える・又は・md5ハッシュ) // $id: 投稿ID(md5ハッシュ)
// $userid: 投稿者$id (ゲストの場合「-」が入る) // $userid: 投稿者$id (ゲストの場合「-」が入る)
// {未使用}: 現在は常に「-」が入る // {未使用}: 現在は常に「-」が入る
// $thread_id: 返信先スレッドの投稿ID (返信以外なら「-」が入る) // $thread_id: 返信先スレッドの投稿ID (返信以外なら「-」が入る)
@ -100,7 +100,7 @@ function get_post_metadata($file, $deleted = false) {
if ($thread_id > '') { if ($thread_id > '') {
$thread_title = load_post_title_by_id($thread_id); $thread_title = load_post_title_by_id($thread_id);
if (!$thread_title > '') { if (!$thread_title > '') {
$thread_title = '無題#' . $thread_id; $thread_title = '無題#' . mb_substr($thread_id, 0, 7);
} }
} }
@ -259,21 +259,16 @@ function add_post($userid, $title, $body, $attachment_id, $file_hash, &$post_id_
} }
$text .= '-' . PHP_EOL . $body . PHP_EOL; $text .= '-' . PHP_EOL . $body . PHP_EOL;
$fp_lock = start_post_lock(); $id = md5(bin2hex(random_bytes(256)) . $userid . $title . $body);
if ($fp_lock === false) { return ['ファイルの取得に失敗。']; }
if (ENABLE_SPOOF_TIME) {
$id = md5(mt_rand(0, 9) . count_post() . $userid . $title . $body);
} else {
$id = count_post() + 1;
}
if ($spooftime) { if ($spooftime) {
$dto = new DateTime('+' . (mt_rand(60 * 60 * 3, 60 * 60 * 27 - 1)) . 'seconds'); $dto = new DateTime('+' . (mt_rand(60 * 60 * 3, 60 * 60 * 27 - 1)) . 'seconds');
$datetime = $dto->format('Y-m-d\\TH:i:s\\Z');
$dto = null;
} else { } else {
$datetime = date('Y-m-d\\TH:i:s\\Z'); $dto = new DateTime();
} }
$datetime = $dto->format('Y-m-d\\TH:i:s\\Z');
$timestamp = $dto->getTimestamp();
$dto = null;
$file = "{$datetime}.id{$id}.us{$userid}.to-.th{$thread_id}.txt"; $file = "{$datetime}.id{$id}.us{$userid}.to-.th{$thread_id}.txt";
if ($body !== '.' || $file_hash === '') { if ($body !== '.' || $file_hash === '') {
@ -290,6 +285,7 @@ function add_post($userid, $title, $body, $attachment_id, $file_hash, &$post_id_
if ($result === false) { return ['書き込みの保存に失敗。']; } if ($result === false) { return ['書き込みの保存に失敗。']; }
@chmod(POST_DIR . $file, 0600); @chmod(POST_DIR . $file, 0600);
@touch(POST_DIR . $file, $timestamp, $timestamp);
if ($body !== '.' || $file_hash === '') { if ($body !== '.' || $file_hash === '') {
add_repeating_info(make_repeating_info($body, $datetime)); add_repeating_info(make_repeating_info($body, $datetime));
@ -298,9 +294,6 @@ function add_post($userid, $title, $body, $attachment_id, $file_hash, &$post_id_
add_repeating_info(make_repeating_info($body, $datetime, $file_hash)); add_repeating_info(make_repeating_info($body, $datetime, $file_hash));
} }
end_post_lock($fp_lock); // ここのエラーは無視
$fp_lock = null;
$post_id_ref = $id; $post_id_ref = $id;
return []; return [];
} }
@ -371,7 +364,11 @@ function load_threads() {
$threads = []; $threads = [];
foreach ($files as $filepath) { foreach ($files as $filepath) {
$thread_id = get_post_metadata(basename($filepath))['thread_id']; $metadata = get_post_metadata(basename($filepath));
$is_future = $metadata['is_future'];
$thread_id = $metadata['thread_id'];
$metadata = null;
if ($is_future) { continue; }
if ($thread_id === '') { continue; } if ($thread_id === '') { continue; }
if (isset($threads[$thread_id])) { if (isset($threads[$thread_id])) {
@ -387,7 +384,7 @@ function load_threads() {
$thread['title'] = $parent['title']; $thread['title'] = $parent['title'];
} }
else { else {
$thread['title'] = '無題#' . $thread_id; $thread['title'] = '無題#' . mb_substr($thread_id, 0, 7);
} }
$thread['detail_url'] = $parent['detail_url']; $thread['detail_url'] = $parent['detail_url'];
@ -470,20 +467,6 @@ function check_repeating_info($body, $datetime, $file_hash = '') {
// Util // Util
function start_post_lock() {
$fp = @fopen(POST_LOCK_TXT, 'w');
if ($fp === false || !flock($fp, LOCK_EX)) { return false; }
return $fp;
}
function end_post_lock($fp) {
if (!fwrite($fp, '') || !fflush($fp)) { return false; }
@flock($fp, LOCK_UN);
@fclose($fp);
return true;
}
function count_post() { function count_post() {
$pattern = '2*Z*.txt'; $pattern = '2*Z*.txt';
$files = glob(POST_DIR . '2*Z*.txt'); $files = glob(POST_DIR . '2*Z*.txt');

ファイルの表示

@ -1,5 +1,5 @@
/** theme: default **/ /** theme: default **/
/** bibis-version: 0.9.2 **/ /** bibis-version: 0.9.3 **/
/* /*
Copying and distribution of this file, with or without modification, Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright are permitted in any medium without royalty provided the copyright
@ -58,15 +58,17 @@ ul
dd ul dd ul
{ {
border-bottom: thin solid #000; background: #12110c;
border-top: thin solid #000; border-bottom: thin solid #12110c;
margin: 0.5em 0; border-top: thin solid #12110c;
color: #fff;
margin: 0.5em 0 0;
} }
dl dl
{ {
display: block; /*dillo*/ display: block; /*dillo*/
padding: 0.5em 1em; padding: 0.5em 1em 0;
} }
dt dt
@ -77,6 +79,7 @@ dt
dd dd
{ {
clear: both; /* see: .post-time */ clear: both; /* see: .post-time */
padding-bottom: 0.5em;
} }
p p

ファイルの表示

@ -1,5 +1,5 @@
/** theme: 076-like **/ /** theme: 076-like **/
/** bibis-version: 0.9.2 **/ /** bibis-version: 0.9.3 **/
/* /*
Copying and distribution of this file, with or without modification, Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright are permitted in any medium without royalty provided the copyright

ファイルの表示

@ -39,8 +39,8 @@ function sanitize_bio($s) {
function validate_post_id($s) { function validate_post_id($s) {
if ( if (
((string)(int)$s !== $s || $s < 0) ((string)(int)$s !== $s || $s < 0) // <= v0.9.2
&& !preg_match('/[0-9a-z]{32}/', $s) && !preg_match('/[0-9a-z]{32}/', $s) // >= v0.9.2
) { ) {
return ['投稿 ID が不正。']; return ['投稿 ID が不正。'];
} }

ファイルの表示

@ -11,7 +11,7 @@ $total_view = $total > 1 ? " ($total)" : '';
<?php if ($title > ''): ?> <?php if ($title > ''): ?>
<h2>件名:<?= htmlspecialchars("$title{$total_view}") ?></h2> <h2>件名:<?= htmlspecialchars("$title{$total_view}") ?></h2>
<?php elseif ($post['thread_id'] <= ''): ?> <?php elseif ($post['thread_id'] <= ''): ?>
<h2><?= htmlspecialchars("無題#{$post['id']}{$total_view}") ?></h2> <h2><?= htmlspecialchars('無題#' . mb_substr($post['id'], 0, 7) . $total_view) ?></h2>
<?php endif; ?> <?php endif; ?>
<?php <?php
view_post($post, ['res_num' => $post['thread_id'] > '' ? 0 : 1, 'is_single' => true, 'link_to_thread' => true]); view_post($post, ['res_num' => $post['thread_id'] > '' ? 0 : 1, 'is_single' => true, 'link_to_thread' => true]);