Skip to content

Commit

Permalink
v5.52.2 pch,spch width height
Browse files Browse the repository at this point in the history
  • Loading branch information
satopian committed Dec 27, 2022
1 parent 87ecea1 commit fa6c794
Showing 1 changed file with 62 additions and 4 deletions.
66 changes: 62 additions & 4 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 = 'v5.51.0';
const POTI_LOT = 'lot.221223';
const POTI_VER = 'v5.52.2';
const POTI_LOT = 'lot.221227';

/*
(C) 2018-2022 POTI改 POTI-board redevelopment team
Expand Down Expand Up @@ -1582,9 +1582,18 @@ function paintform(){
error(MSG045,$pchup);
}
if($pchext==="pch"){
$shi = is_neo($pchup) ? 'neo': 0;
$is_neo=is_neo($pchup);
$shi = $is_neo ? 'neo': 0;
if($is_neo){
if($get_pch_size=get_pch_size($pchup)){
list($picw,$pich)=$get_pch_size;//pchの幅と高さを取得
}
}
$dat['pchfile'] = $pchup;
} elseif($pchext==="spch"){
if($get_spch_size=get_spch_size($pchup)){
list($picw,$pich)=$get_spch_size;//pchの幅と高さを取得
}
$shi=($shi==1||$shi==2) ? $shi : 1;
$dat['pchfile'] = $pchup;
} elseif($pchext==="chi"){
Expand Down Expand Up @@ -3054,6 +3063,55 @@ function is_neo($src) {//neoのPCHかどうか調べる
fclose($fp);
return $is_neo;
}
//pchデータの幅と高さ
function get_pch_size($src) {
$fp = fopen("$src", "rb");
$pch_data=bin2hex(fread($fp,8));
fclose($fp);
$width=null;
$height=null;
$w0=hexdec(substr($pch_data,8,2));
$w1=hexdec(substr($pch_data,10,2));
$h0=hexdec(substr($pch_data,12,2));
$h1=hexdec(substr($pch_data,14,2));
if(!is_numeric($w0)||!is_numeric($w1)||!is_numeric($h0)||!is_numeric($h1)){
return;
}
$width=(int)$w0+((int)$w1*256);
$height=(int)$h0+((int)$h1*256);
return[(int)$width,(int)$height];
}
//spchデータの幅と高さ
function get_spch_size($src) {
$lines=[];
$width=null;
$height=null;
$i=0;
$fp=fopen($src,"rb");
while($line = fgets($fp)){
if(!trim($line)){
continue;
}
$lines[]=trim($line);
if($i>6){
break;
}
++$i;
}
foreach($lines as $str){
parse_str($str, $output);
if(isset($output['image_width'])){
$width=$output['image_width'];
}
if(isset($output['image_height'])){
$height=$output['image_height'];
}
}
if(!is_numeric($width)||!is_numeric($height)){
return;
}
return[(int)$width,(int)$height];
}
//表示用のログファイルを取得
function get_log($logfile) {
if(!$logfile){
Expand Down Expand Up @@ -3092,6 +3150,6 @@ function check_password_input_error_count(){
file_put_contents(__DIR__.'/templates/errorlog/error.log',$errlog,FILE_APPEND);
chmod(__DIR__.'/templates/errorlog/error.log',0600);
}else{
unlink(__DIR__.'/templates/errorlog/error.log');
safe_unlink(__DIR__.'/templates/errorlog/error.log');
}
}

0 comments on commit fa6c794

Please sign in to comment.