Update storage.php

This commit is contained in:
Namhyeon Go 2019-05-13 18:08:36 +09:00 committed by GitHub
parent e7accfa96a
commit 0561ce9f33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -47,9 +47,15 @@ if(!check_function_exists("get_storage_dir")) {
}
}
if(!check_function_exists("get_safe_path")) {
function get_safe_path($path) {
return str_replace("../", "", $path);
}
}
if(!check_function_exists("get_storage_path")) {
function get_storage_path($type="data") {
$dir_path = sprintf("./%s/%s", get_storage_dir(), make_safe_path($type));
$dir_path = sprintf("./%s/%s", get_storage_dir(), get_safe_path($type));
if(!is_dir($dir_path)) {
if(!@mkdir($dir_path, 0777)) {
@ -63,7 +69,7 @@ if(!check_function_exists("get_storage_path")) {
if(!check_function_exists("get_storage_url")) {
function get_storage_url($type="data") {
return sprintf("%s%s/%s", base_url(), get_storage_dir(), make_safe_path($type));
return sprintf("%s%s/%s", base_url(), get_storage_dir(), get_safe_path($type));
}
}
@ -138,7 +144,7 @@ if(!check_function_exists("read_storage_file")) {
$storage_type = get_value_in_array("storage_type", $options, "data");
$upload_base_path = get_storage_path($storage_type);
$upload_base_url = get_storage_url($storage_type);
$upload_filename = sprintf("%s/%s", $upload_base_path, make_safe_path($filename));
$upload_filename = sprintf("%s/%s", $upload_base_path, get_safe_path($filename));
if(file_exists($upload_filename)) {
$upload_filesize = filesize($upload_filename);
@ -207,7 +213,7 @@ if(!check_function_exists("remove_storage_file")) {
$storage_type = get_value_in_array("storage_type", $options, "data");
$upload_base_path = get_storage_path($storage_type);
$upload_base_url = get_storage_url($storage_type);
$upload_filename = sprintf("%s/%s", $upload_base_path, make_safe_path($filename));
$upload_filename = sprintf("%s/%s", $upload_base_path, get_safe_path($filename));
// add option: encryption
$encryption = get_value_in_array("encryption", $options, "");
@ -251,9 +257,11 @@ if(!check_function_exists("write_storage_file")) {
$mode = get_value_in_array("mode", $options, "w");
$upload_base_path = get_storage_path($storage_type);
$upload_base_url = get_storage_url($storage_type);
$upload_filename = sprintf("%s/%s", $upload_base_path, make_safe_path($filename));
$upload_filename = sprintf("%s/%s", $upload_base_path, get_safe_path($filename));
// add option: encryption
// add option: encryption Update config.php 4 minutes ago
database.php Update database.php 9 days ago
logger.php
$encryption = get_value_in_array("encryption", $options, "");
if(!empty($encryption)) {
if(!loadHelper("encryptiontool")) {
@ -304,7 +312,7 @@ if(!check_function_exists("append_storage_file")) {
if(!check_function_exists("get_real_path")) {
function get_real_path($filename) {
$filename = make_safe_path($filename);
$filename = get_safe_path($filename);
return file_exists($filename) ? realpath($filename) : false;
}
}