Skip to content

Commit 87ddfa8

Browse files
committed
max_pchが0の時は制限なし。php.iniから設定を読み込む時に単位が正しく反映されない場合がある問題を修正。
1 parent 8d0d10c commit 87ddfa8

5 files changed

Lines changed: 36 additions & 11 deletions

File tree

petitnote/app/neo/neo.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ document.addEventListener("DOMContentLoaded", function () {
1010

1111
var Neo = function () {};
1212

13-
Neo.version = "1.6.17";
13+
Neo.version = "1.6.18";
1414
Neo.painter;
1515
Neo.fullScreen = false;
1616
Neo.uploaded = false;
@@ -1248,8 +1248,8 @@ Neo.submit = function (board, blob, thumbnail, thumbnail2) {
12481248
// 動画容量を制限するNEO独自のパラメータ
12491249
// 単位MB
12501250
if (
1251-
!Neo.config.neo_max_pch ||
12521251
isNaN(Neo.config.neo_max_pch) ||
1252+
!Number(Neo.config.neo_max_pch) ||
12531253
Number(Neo.config.neo_max_pch) * 1024 * 1024 >
12541254
headerString.length + blob.size + thumbnail_size + thumbnail2.size
12551255
) {

petitnote/functions.php

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
$functions_ver=20250605;
2+
$functions_ver=20250608;
33
//編集モードログアウト
44
function logout(): void {
55
session_sta();
@@ -1493,6 +1493,34 @@ function get_pch_size($src): ?array {
14931493
return[(int)$width,(int)$height];
14941494
}
14951495

1496+
// ini_getで取得したサイズ文字列をMBに変換
1497+
function ini_get_size_mb(string $key): int {
1498+
if (!function_exists('ini_get')) return 0;
1499+
1500+
$val = ini_get($key);
1501+
$unit = strtoupper(substr($val, -1));
1502+
$num = (float)$val;
1503+
1504+
switch ($unit) {
1505+
case 'G':
1506+
return (int)($num * 1024); // GB → MB
1507+
case 'M':
1508+
return (int)$num; // MB → MB
1509+
case 'K':
1510+
return (int)($num / 1024); // KB → MB
1511+
case 'B':
1512+
return (int)($num / 1024 / 1024); // バイト → MB
1513+
default:
1514+
return (int)((float)$val / 1024 / 1024); // 単位なし → バイトとして処理
1515+
}
1516+
}
1517+
//投稿可能な最大ファイルサイズを取得 単位MB
1518+
function get_upload_max_filesize(): int {
1519+
$upload_max = ini_get_size_mb('upload_max_filesize');
1520+
$post_max = ini_get_size_mb('post_max_size');
1521+
return min($upload_max, $post_max);
1522+
}
1523+
14961524
//使用するペイントアプリの配列化
14971525
function app_to_use(): array {
14981526
global $use_paintbbs_neo,$use_chickenpaint,$use_klecs,$use_tegaki,$use_axnos;

petitnote/index.php

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

77
$lang = ($http_langs = $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? '')
@@ -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<20250605){
21+
if(!isset($functions_ver)||$functions_ver<20250608){
2222
die($en?'Please update functions.php to the latest version.':'functions.phpを最新版に更新してください。');
2323
}
2424

@@ -946,10 +946,7 @@ function paint(): void {
946946

947947
$admin_pass= null;
948948

949-
$max_pch=0;
950-
if (function_exists('ini_get')){
951-
$max_pch = min((int)ini_get('post_max_size'),(int)ini_get('upload_max_filesize'));
952-
}
949+
$max_pch = get_upload_max_filesize();
953950

954951
switch($app){
955952
case 'chi'://ChickenPaint

petitnote/template/basic/paint_klecks.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@
139139
}
140140
Promise.all([klecks.getPNG(), klecks.getPSD()]).then(([png, psd]) => {
141141
const TotalSiz = ((png.size + psd.size) / 1024 / 1024).toFixed(3);
142-
if (TotalSiz > <?= h($max_pch) ?>) {
142+
if (<?= h($max_pch)?> && TotalSiz > <?= h($max_pch) ?>) {
143143
return alert(`<?php if ($en): ?>File size is too large.<?php else: ?>ファイルサイズが大きすぎます。<?php endif; ?>\n<?php if ($en): ?>limit size<?php else: ?>制限値<?php endif; ?>:<?= h($max_pch) ?>MB\n<?php if ($en): ?>Current size<?php else: ?>現在値<?php endif; ?>:${TotalSiz}MB`)
144144
}
145145
const formData = new FormData();

petitnote/template/basic/paint_tegaki.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155
const formData = new FormData();
156156
let DataSize = 1000;
157157
let max_pch = <?= h($max_pch) ?>;
158-
max_pch = parseInt(max_pch) * 1024 * 1024;
158+
max_pch = Number(max_pch) * 1024 * 1024;
159159
if (tgkr) {
160160
DataSize = DataSize + blob.size + tgkr.size;
161161
if (!max_pch || isNaN(max_pch) || (DataSize < max_pch)) {

0 commit comments

Comments
 (0)