Skip to content

Commit 7bda253

Browse files
committed
禁止ホストの時は、SESSIONに保存してホスト名の再計算をしない。
1 parent bc35db2 commit 7bda253

2 files changed

Lines changed: 17 additions & 13 deletions

File tree

petitnote/functions.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
$functions_ver=20250601;
2+
$functions_ver=20250602;
33
//編集モードログアウト
44
function logout(): void {
55
session_sta();
@@ -1150,23 +1150,31 @@ function is_ngword ($ngwords, $strs): bool {
11501150
/* 禁止ホストチェック */
11511151
function is_badhost(): bool {
11521152
global $badhost,$reject_if_no_reverse_dns;
1153+
session_sta();
1154+
$session_badhost = $_SESSION['is_badhost'] ?? false; //SESSIONに保存された値を取得
1155+
if($session_badhost){//セッションに保存されている場合はチェックしない
1156+
return true;
1157+
}
11531158
//ホスト取得
11541159
$userip = get_uip();
11551160
$host = $userip ? gethostbyaddr($userip) :'';
11561161

11571162
if($host === $userip){//ホスト名がipアドレスになる場合は
11581163
if($reject_if_no_reverse_dns){
1164+
$_SESSION['is_badhost'] = true;
11591165
return true; //リバースDNSがない場合は拒絶
11601166
}
11611167
foreach($badhost as $value){
1162-
if (preg_match("/\A$value/i",$host)) {//前方一致
1168+
if (preg_match("/\A$value/i",$host)) {//前方一致
1169+
$_SESSION['is_badhost'] = true;
11631170
return true;
11641171
}
11651172
}
11661173
return false;
11671174
}else{
11681175
foreach($badhost as $value){
11691176
if (preg_match("/$value\z/i",$host)) {
1177+
$_SESSION['is_badhost'] = true;
11701178
return true;
11711179
}
11721180
}

petitnote/index.php

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

@@ -249,7 +249,8 @@ function post(): void {
249249

250250
//投稿間隔をチェック
251251
check_submission_interval();
252-
252+
//NGワードがあれば拒絶
253+
Reject_if_NGword_exists_in_the_post();
253254
//POSTされた内容を取得
254255
$userip =t(get_uip());
255256
//ホスト取得
@@ -268,9 +269,6 @@ function post(): void {
268269
$url = t(filter_input_data('POST','url',FILTER_VALIDATE_URL));
269270
$url= (adminpost_valid() || $use_url_input_field) ? $url : '';
270271

271-
//NGワードがあれば拒絶
272-
Reject_if_NGword_exists_in_the_post();
273-
274272
$pwd=$pwd ? $pwd : t(filter_input_data('COOKIE','pwdc'));//未入力ならCookieのパスワード
275273
if(!$pwd){//それでも$pwdが空なら
276274
$pwd = substr(hash('sha256', random_bytes(16)), 0, 15);
@@ -1874,7 +1872,8 @@ function edit(): void {
18741872

18751873
//投稿間隔をチェック
18761874
check_submission_interval();
1877-
1875+
//NGワードがあれば拒絶
1876+
Reject_if_NGword_exists_in_the_post();
18781877
//POSTされた内容を取得
18791878
$userip =t(get_uip());
18801879
//ホスト取得
@@ -1902,9 +1901,6 @@ function edit(): void {
19021901
error($en?"This operation has failed.\nPlease reload.":"失敗しました。\nリロードしてください。");
19031902
}
19041903

1905-
//NGワードがあれば拒絶
1906-
Reject_if_NGword_exists_in_the_post();
1907-
19081904
//ログ読み込み
19091905
if(!is_file(LOG_DIR."{$no}.log")){
19101906
error($en? 'The article does not exist.':'記事がありません。');

0 commit comments

Comments
 (0)