PRS-12 코드 포맷

This commit is contained in:
kkigomi
2023-06-30 22:02:42 +09:00
parent 4eba618a82
commit af64737b63

View File

@ -1,13 +1,13 @@
<?php
require_once("config.php");
if(!function_exists('ft_nonce_is_valid')){
if (!function_exists('ft_nonce_is_valid')) {
include_once('../editor.lib.php');
}
if( !function_exists('che_reprocessImage') ){
function che_reprocessImage($file_path, $callback){
if (!function_exists('che_reprocessImage')) {
function che_reprocessImage($file_path, $callback)
{
$MIME_TYPES_PROCESSORS = array(
"image/gif" => array("imagecreatefromgif", "imagegif"),
"image/jpg" => array("imagecreatefromjpeg", "imagejpeg"),
@ -60,13 +60,13 @@ if( !function_exists('che_reprocessImage') ){
$is_editor_upload = false;
$get_nonce = get_session('nonce_'.FT_NONCE_SESSION_KEY);
$get_nonce = get_session('nonce_' . FT_NONCE_SESSION_KEY);
if( $get_nonce && ft_nonce_is_valid( $get_nonce, 'cheditor' ) ){
if ($get_nonce && ft_nonce_is_valid($get_nonce, 'cheditor')) {
$is_editor_upload = true;
}
if( !$is_editor_upload ){
if (!$is_editor_upload) {
exit;
}
@ -78,7 +78,7 @@ run_event('cheditor_photo_upload', $data_dir, $data_url);
$tempfile = $_FILES['file']['tmp_name'];
$filename = $_FILES['file']['name'];
$filename_len = strrpos($filename, ".");
$type = substr($filename, strrpos($filename, ".")+1);
$type = substr($filename, strrpos($filename, ".") + 1);
$found = false;
switch ($type) {
case "jpg":
@ -108,29 +108,33 @@ if (!$imgsize) {
$filesize = 0;
$random_name = '-ERR';
unlink($savefile);
};
}
if ( CHE_UPLOAD_IMG_CHECK && ! che_reprocessImage($savefile, null) ){
if (CHE_UPLOAD_IMG_CHECK && !che_reprocessImage($savefile, null)) {
$filesize = 0;
$random_name = '-ERR';
unlink($savefile);
}
try {
if(defined('G5_FILE_PERMISSION')) chmod($savefile, G5_FILE_PERMISSION);
if (defined('G5_FILE_PERMISSION')) {
chmod($savefile, G5_FILE_PERMISSION);
}
} catch (Exception $e) {
}
$file_url = SAVE_URL.'/'.$filename;
$file_url = SAVE_URL . '/' . $filename;
if( function_exists('run_replace') ){
if (function_exists('run_replace')) {
$file_url = run_replace('get_editor_upload_url', $file_url, $savefile, array());
}
$rdata = sprintf('{"fileUrl": "%s", "filePath": "%s", "fileName": "%s", "fileSize": "%d" }',
$rdata = sprintf(
'{"fileUrl": "%s", "filePath": "%s", "fileName": "%s", "fileSize": "%d" }',
$file_url,
$savefile,
$filename,
$filesize );
$filesize
);
echo $rdata;