Skip to content

Commit 491552f

Browse files
committed
投稿にJavaScriptを必須にして低レベルなbotを排除。
1 parent 0c8c614 commit 491552f

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

petitnote/functions.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
$functions_ver=20250416;
2+
$functions_ver=20250520;
33
//編集モードログアウト
44
function logout(): void {
55
session_sta();
@@ -964,6 +964,15 @@ function check_AsyncRequest($upfile=''): void {
964964
}
965965
}
966966

967+
//POSTがJavaScript経由かチェック
968+
function check_post_via_javascript(): void {
969+
global $en;
970+
//JavaScriptが無効な時はエラー
971+
if(!isset($_SERVER['HTTP_X_REQUESTED_WITH'])){//asyncリクエストでなければ
972+
error($en?'Please enable JavaScript.':'JavaScriptを有効にしてください。');
973+
}
974+
}
975+
967976
// テンポラリ内のゴミ除去
968977
function deltemp(): void {
969978
global $check_password_input_error_count;

petitnote/index.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22
//Petit Note (c)さとぴあ @satopian 2021-2025
33
//1スレッド1ログファイル形式のスレッド式画像掲示板
4-
$petit_ver='v1.86.9';
5-
$petit_lot='lot.20250518';
4+
$petit_ver='v1.87.0';
5+
$petit_lot='lot.20250520';
66

77
$lang = ($http_langs = $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? '')
88
? explode( ',', $http_langs )[0] : '';
@@ -18,7 +18,7 @@
1818
die(__DIR__.'/functions.php'.($en ? ' does not exist.':'がありません。'));
1919
}
2020
require_once(__DIR__.'/functions.php');
21-
if(!isset($functions_ver)||$functions_ver<20250416){
21+
if(!isset($functions_ver)||$functions_ver<20250520){
2222
die($en?'Please update functions.php to the latest version.':'functions.phpを最新版に更新してください。');
2323
}
2424

@@ -239,6 +239,9 @@ function post(): void {
239239
global $allow_comments_only,$res_max_w,$res_max_h,$name_input_required,$max_com,$max_px,$sage_all,$en,$only_admin_can_reply;
240240
global $usercode,$use_url_input_field,$httpsonly;
241241

242+
//Fetch API以外からのPOSTを拒否
243+
check_post_via_javascript();
244+
242245
if($use_aikotoba){
243246
check_aikotoba();
244247
}
@@ -1846,6 +1849,8 @@ function edit_form($id='',$no=''): void {
18461849
function edit(): void {
18471850
global $name_input_required,$max_com,$en,$mark_sensitive_image,$use_url_input_field,$admin_pass;
18481851

1852+
//Fetch API以外からのPOSTを拒否
1853+
check_post_via_javascript();
18491854
check_csrf_token();
18501855

18511856
//POSTされた内容を取得

0 commit comments

Comments
 (0)