Skip to content

Commit 795936e

Browse files
committed
ホスト名逆引きができないipアドレスからの投稿を拒絶する設定項目を追加。
1 parent 2d88307 commit 795936e

3 files changed

Lines changed: 16 additions & 5 deletions

File tree

petitnote/config.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,14 @@
130130
// 禁止ホスト
131131
$badhost =["example.com","example.org"];
132132

133+
//ホスト名が逆引きできないIPアドレスからの投稿を拒絶する
134+
// する: true しない: false
135+
136+
// $reject_if_no_reverse_dns = true;
137+
$reject_if_no_reverse_dns = false;
138+
139+
// ※逆引きできないIPアドレスの利用者も多いため、true にすると一部の正当なユーザーが投稿できなくなる可能性があります。
140+
133141
/*使用目的別設定*/
134142

135143
// ホームページへ戻るリンクを上段のメニューに表示する

petitnote/functions.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1147,12 +1147,15 @@ function is_ngword ($ngwords, $strs): bool {
11471147

11481148
/* 禁止ホストチェック */
11491149
function is_badhost(): bool {
1150-
global $badhost;
1150+
global $badhost,$reject_if_no_reverse_dns;
11511151
//ホスト取得
11521152
$userip = get_uip();
11531153
$host = $userip ? gethostbyaddr($userip) :'';
11541154

11551155
if($host === $userip){//ホスト名がipアドレスになる場合は
1156+
if($reject_if_no_reverse_dns){
1157+
return true; //リバースDNSがない場合は拒絶
1158+
}
11561159
foreach($badhost as $value){
11571160
if (preg_match("/\A$value/i",$host)) {//前方一致
11581161
return true;

petitnote/index.php

Lines changed: 4 additions & 4 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.88.9';
5-
$petit_lot='lot.20250529';
4+
$petit_ver='v1.88.10';
5+
$petit_lot='lot.20250530';
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<20250529){
21+
if(!isset($functions_ver)||$functions_ver<20250530){
2222
die($en?'Please update functions.php to the latest version.':'functions.phpを最新版に更新してください。');
2323
}
2424

@@ -116,12 +116,12 @@
116116
$darkmode_by_default = $darkmode_by_default ?? false;
117117
$sitename = $sitename ?? '';
118118
$fetch_articles_to_skip = $fetch_articles_to_skip ?? true;
119+
$reject_if_no_reverse_dns = $reject_if_no_reverse_dns ?? false;
119120
$mode = (string)filter_input_data('POST','mode');
120121
$mode = $mode ? $mode :(string)filter_input_data('GET','mode');
121122
$resno=(int)filter_input_data('GET','resno',FILTER_VALIDATE_INT);
122123
$userip = get_uip();
123124
$httpsonly = (bool)($_SERVER['HTTPS'] ?? '');
124-
125125
//user-codeの発行
126126
$usercode = t(filter_input_data('COOKIE', 'usercode'));//user-codeを取得
127127

0 commit comments

Comments
 (0)