フォーク元 tak4/bibis
v0.9.3
- Fix bug "thread-list includes future post". - Add "spoof post timestamp". - Remove "autoincrement postid" - Change fallback-post-title. - Update default style.
このコミットが含まれているのは:
コミット
928a9a96c3
|
@ -6,7 +6,6 @@ default_config('USERS_TSV', DATA_ROOT . 'users.tsv');
|
|||
default_config('LIMIT_TSV', DATA_ROOT . 'repeating-limit.tsv');
|
||||
default_config('PROFILE_DIR', DATA_ROOT . 'profile/');
|
||||
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('SITENAME', 'BIBIS');
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// "{$datetime}.id{$id}.us{$userid}.to{未使用}.th{$thread_id}.txt"
|
||||
// 内訳:
|
||||
// $datetime: 投稿日時(ISO形式、タイムゾーンは「Z」固定)
|
||||
// $id: 投稿ID(0から始まり1づつ増える・又は・md5ハッシュ)
|
||||
// $id: 投稿ID(md5ハッシュ)
|
||||
// $userid: 投稿者$id (ゲストの場合「-」が入る)
|
||||
// {未使用}: 現在は常に「-」が入る
|
||||
// $thread_id: 返信先スレッドの投稿ID (返信以外なら「-」が入る)
|
||||
|
@ -100,7 +100,7 @@ function get_post_metadata($file, $deleted = false) {
|
|||
if ($thread_id > '') {
|
||||
$thread_title = load_post_title_by_id($thread_id);
|
||||
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;
|
||||
|
||||
$fp_lock = start_post_lock();
|
||||
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;
|
||||
}
|
||||
$id = md5(bin2hex(random_bytes(256)) . $userid . $title . $body);
|
||||
|
||||
if ($spooftime) {
|
||||
$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 {
|
||||
$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";
|
||||
|
||||
if ($body !== '.' || $file_hash === '') {
|
||||
|
@ -290,6 +285,7 @@ function add_post($userid, $title, $body, $attachment_id, $file_hash, &$post_id_
|
|||
if ($result === false) { return ['書き込みの保存に失敗。']; }
|
||||
|
||||
@chmod(POST_DIR . $file, 0600);
|
||||
@touch(POST_DIR . $file, $timestamp, $timestamp);
|
||||
|
||||
if ($body !== '.' || $file_hash === '') {
|
||||
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));
|
||||
}
|
||||
|
||||
end_post_lock($fp_lock); // ここのエラーは無視
|
||||
$fp_lock = null;
|
||||
|
||||
$post_id_ref = $id;
|
||||
return [];
|
||||
}
|
||||
|
@ -371,7 +364,11 @@ function load_threads() {
|
|||
$threads = [];
|
||||
|
||||
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 (isset($threads[$thread_id])) {
|
||||
|
@ -387,7 +384,7 @@ function load_threads() {
|
|||
$thread['title'] = $parent['title'];
|
||||
}
|
||||
else {
|
||||
$thread['title'] = '無題#' . $thread_id;
|
||||
$thread['title'] = '無題#' . mb_substr($thread_id, 0, 7);
|
||||
}
|
||||
$thread['detail_url'] = $parent['detail_url'];
|
||||
|
||||
|
@ -470,20 +467,6 @@ function check_repeating_info($body, $datetime, $file_hash = '') {
|
|||
|
||||
// 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() {
|
||||
$pattern = '2*Z*.txt';
|
||||
$files = glob(POST_DIR . '2*Z*.txt');
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/** theme: default **/
|
||||
/** bibis-version: 0.9.2 **/
|
||||
/** bibis-version: 0.9.3 **/
|
||||
/*
|
||||
Copying and distribution of this file, with or without modification,
|
||||
are permitted in any medium without royalty provided the copyright
|
||||
|
@ -58,15 +58,17 @@ ul
|
|||
|
||||
dd ul
|
||||
{
|
||||
border-bottom: thin solid #000;
|
||||
border-top: thin solid #000;
|
||||
margin: 0.5em 0;
|
||||
background: #12110c;
|
||||
border-bottom: thin solid #12110c;
|
||||
border-top: thin solid #12110c;
|
||||
color: #fff;
|
||||
margin: 0.5em 0 0;
|
||||
}
|
||||
|
||||
dl
|
||||
{
|
||||
display: block; /*dillo*/
|
||||
padding: 0.5em 1em;
|
||||
padding: 0.5em 1em 0;
|
||||
}
|
||||
|
||||
dt
|
||||
|
@ -77,6 +79,7 @@ dt
|
|||
dd
|
||||
{
|
||||
clear: both; /* see: .post-time */
|
||||
padding-bottom: 0.5em;
|
||||
}
|
||||
|
||||
p
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/** theme: 076-like **/
|
||||
/** bibis-version: 0.9.2 **/
|
||||
/** bibis-version: 0.9.3 **/
|
||||
/*
|
||||
Copying and distribution of this file, with or without modification,
|
||||
are permitted in any medium without royalty provided the copyright
|
||||
|
|
|
@ -39,8 +39,8 @@ function sanitize_bio($s) {
|
|||
|
||||
function validate_post_id($s) {
|
||||
if (
|
||||
((string)(int)$s !== $s || $s < 0)
|
||||
&& !preg_match('/[0-9a-z]{32}/', $s)
|
||||
((string)(int)$s !== $s || $s < 0) // <= v0.9.2
|
||||
&& !preg_match('/[0-9a-z]{32}/', $s) // >= v0.9.2
|
||||
) {
|
||||
return ['投稿 ID が不正。'];
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ $total_view = $total > 1 ? " ($total)" : '';
|
|||
<?php if ($title > ''): ?>
|
||||
<h2>件名:<?= htmlspecialchars("$title{$total_view}") ?></h2>
|
||||
<?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
|
||||
view_post($post, ['res_num' => $post['thread_id'] > '' ? 0 : 1, 'is_single' => true, 'link_to_thread' => true]);
|
||||
|
|
読み込み中…
新しいイシューから参照