Update storage.php
This commit is contained in:
parent
d49894dd4f
commit
941e6569c5
|
@ -152,7 +152,7 @@ if(!check_function_exists("read_storage_file")) {
|
||||||
$result = false;
|
$result = false;
|
||||||
|
|
||||||
$storage_type = get_value_in_array("storage_type", $options, "data");
|
$storage_type = get_value_in_array("storage_type", $options, "data");
|
||||||
$max_age = get_value_in_array("max_age", $options, 0); // max_age (seconds), the value 0 is forever
|
$max_age = intval(get_value_in_array("max_age", $options, 0)); // max_age (seconds), the value 0 is forever
|
||||||
$upload_base_path = get_storage_path($storage_type);
|
$upload_base_path = get_storage_path($storage_type);
|
||||||
$upload_base_url = get_storage_url($storage_type);
|
$upload_base_url = get_storage_url($storage_type);
|
||||||
$upload_filename = sprintf("%s/%s", $upload_base_path, get_safe_path($filename));
|
$upload_filename = sprintf("%s/%s", $upload_base_path, get_safe_path($filename));
|
||||||
|
@ -160,12 +160,11 @@ if(!check_function_exists("read_storage_file")) {
|
||||||
if(file_exists($upload_filename)) {
|
if(file_exists($upload_filename)) {
|
||||||
$is_valid = false;
|
$is_valid = false;
|
||||||
$upload_filesize = filesize($upload_filename);
|
$upload_filesize = filesize($upload_filename);
|
||||||
$upload_ctime = filectime($upload_filename);
|
$upload_mtime = filemtime($upload_filename);
|
||||||
|
$upload_age = get_current_timestamp() - $upload_mtime;
|
||||||
|
|
||||||
if($upload_filesize > 0) {
|
if($upload_filesize > 0) {
|
||||||
$is_valid = true;
|
$is_valid = ($max_age > 0) ? ($upload_age <= $max_age) : true;
|
||||||
} elseif($max_age > 0 && (get_current_timestamp() - $upload_ctime) <= $max_age) {
|
|
||||||
$is_valid = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($is_valid) {
|
if($is_valid) {
|
||||||
|
@ -249,7 +248,7 @@ if(!check_function_exists("remove_storage_file")) {
|
||||||
@chown($upload_filename, $options['chown']);
|
@chown($upload_filename, $options['chown']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!array_key_empty("shell", $options)) {
|
if(!array_key_equals("shell", $options, true)) {
|
||||||
if(loadHelper("exectool")) {
|
if(loadHelper("exectool")) {
|
||||||
$exec_cmd = ($options['shell'] == "windows") ? "del '%s'" : "rm -f '%s'";
|
$exec_cmd = ($options['shell'] == "windows") ? "del '%s'" : "rm -f '%s'";
|
||||||
exec_command(sprintf($exec_cmd, make_safe_argument($upload_filename)));
|
exec_command(sprintf($exec_cmd, make_safe_argument($upload_filename)));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user