Skip to content

Commit

Permalink
v6.53.0 GDのバージョンチェックを省略。GDが使えるかどうかのチェックを thumbnail_gd.inc.phpのクラス内へ。
Browse files Browse the repository at this point in the history
  • Loading branch information
satopian committed Nov 24, 2024
1 parent a42e089 commit 47915d6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 43 deletions.
50 changes: 10 additions & 40 deletions potiboard5/potiboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

// POTI-board EVO
// バージョン :
const POTI_VER = 'v6.52.2';
const POTI_LOT = 'lot.20241123';
const POTI_VER = 'v6.53.0';
const POTI_LOT = 'lot.20241124';

/*
(C) 2018-2024 POTI改 POTI-board redevelopment team
Expand Down Expand Up @@ -99,7 +99,7 @@
die($err);
}
require(__DIR__.'/thumbnail_gd.inc.php');
if($thumbnail_gd_ver < 20241102){
if($thumbnail_gd_ver < 20241124){
die($en ? "Please update thumbnail_gd.inc.php" : "thumbnail_gd.inc.phpを更新してください。");
}
//SNS共有Class
Expand Down Expand Up @@ -375,37 +375,8 @@
return redirect(h(PHP_SELF2));
}

exit;
exit();

//GD版が使えるかチェック
function gd_check(){
$check = array("ImageCreate","ImageCopyResized","ImageCreateFromJPEG","ImageJPEG","ImageDestroy");

//最低限のGD関数が使えるかチェック
if(!(get_gd_ver() && (ImageTypes() & IMG_JPG))){
return false;
}
foreach ( $check as $cmd ) {
if(!function_exists($cmd)){
return false;
}
}
return true;
}

//gdのバージョンを調べる
function get_gd_ver(){
if(function_exists("gd_info")){
$gdver=gd_info();
$phpinfo=(string)$gdver["GD Version"];
$end=strpos($phpinfo,".");
$phpinfo=substr($phpinfo,0,$end);
$length = strlen($phpinfo)-1;
$phpinfo=substr($phpinfo,$length);
return $phpinfo;
}
return false;
}

//ユーザーip
function get_uip(){
Expand Down Expand Up @@ -901,7 +872,7 @@ function error($mes,$dest=''){

$dat['mes'] = nl2br(h($mes));
htmloutput(OTHERFILE,$dat);
exit;
exit();
}

// 文字列の類似性
Expand Down Expand Up @@ -2570,12 +2541,12 @@ function replace($no="",$pwd="",$repcode="",$java=""){
if(!trim($value)){
continue;
}
list($eno,$edate,$name,$email,$sub,$com,$url,$ehost,$epwd,$ext,$_w,$_h,$etim,,$ptime,$fcolor,$epchext,$ethumbnail,$etool,$logver,) = explode(",", rtrim($value).',,,,,,,');
list($eno,$edate,$name,$email,$sub,$com,$url,$ehost,$epwd,$ext,$_w,$_h,$etim,,$ptime,$fcolor,$epchext,$ethumbnail,$etool,$logver,) = explode(",", rtrim($value).',,,,,,,');
//画像差し換えに管理パスは使っていない
if($eno === $no && check_password($pwd, $epwd)){
$flag = true;
break;
}
if($eno === $no && check_password($pwd, $epwd)){
$flag = true;
break;
}
}
if(!$flag){
closeFile($fp);
Expand Down Expand Up @@ -3647,7 +3618,6 @@ function create_line_from_treenumber ($fp,$trees){
return $line;
}
function make_thumbnail($imgfile,$time,$max_w,$max_h){
global $use_thumb;
$thumbnail='';
if(USE_THUMB){//スレッドの画像のサムネイルを使う時
if(thumbnail_gd::thumb(IMG_DIR,$imgfile,$time,$max_w,$max_h)){
Expand Down
26 changes: 23 additions & 3 deletions potiboard5/thumbnail_gd.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// https://paintbbs.sakura.ne.jp/
// originalscript (C)SakaQ 2005 http://www.punyu.net/php/

$thumbnail_gd_ver=20241117;
$thumbnail_gd_ver=20241124;
defined('PERMISSION_FOR_DEST') or define('PERMISSION_FOR_DEST', 0606); //config.phpで未定義なら0606
class thumbnail_gd {

Expand All @@ -15,7 +15,7 @@ public static function thumb($path,$fname,$time,$max_w,$max_h,$options=[]){
if(!is_file($fname)){
return;
}
if(!gd_check()||!function_exists("ImageCreate")||!function_exists("ImageCreateFromJPEG")){
if(!self::gd_check()||!function_exists("ImageCreate")||!function_exists("ImageCreateFromJPEG")){
return;
}
if((isset($options['webp'])||isset($options['thumbnail_webp'])) && !function_exists("ImageWEBP")){
Expand Down Expand Up @@ -46,7 +46,7 @@ public static function thumb($path,$fname,$time,$max_w,$max_h,$options=[]){
};
// 出力画像(サムネイル)のイメージを作成
$exists_ImageCopyResampled = false;
if(function_exists("ImageCreateTrueColor") && get_gd_ver()=="2"){
if(function_exists("ImageCreateTrueColor")){
$im_out = ImageCreateTrueColor($out_w, $out_h);

if(self::isTransparencyEnabled($options, $mime_type)){//透明度を扱う時
Expand Down Expand Up @@ -94,6 +94,26 @@ public static function thumb($path,$fname,$time,$max_w,$max_h,$options=[]){
return false;

}
//GD版が使えるかチェック
private static function gd_check() {
// GDモジュールが有効化されているか
if (!extension_loaded('gd')) {
return false;
}
// GDモジュールが動作可能か
if (!function_exists('gd_info')) {
return false;
}
// JPEGのサポートを確認
if (!(ImageTypes() & IMG_JPG)) {
return false;
}
// JPEG出力関数の存在を確認
if (!function_exists('ImageJPEG')) {
return false;
}
return true;
}
// 透明度の処理を行う必要があるかを判断
private static function isTransparencyEnabled($options, $mime_type) {
// 透明度を扱うオプションが設定されているか確認
Expand Down

0 comments on commit 47915d6

Please sign in to comment.