Skip to content

Commit

Permalink
Update storage.php
Browse files Browse the repository at this point in the history
  • Loading branch information
gnh1201 authored Nov 14, 2019
1 parent d49894d commit 941e656
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions system/storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,20 +152,19 @@ function read_storage_file($filename, $options=array()) {
$result = false;

$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_url = get_storage_url($storage_type);
$upload_filename = sprintf("%s/%s", $upload_base_path, get_safe_path($filename));

if(file_exists($upload_filename)) {
$is_valid = false;
$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) {
$is_valid = true;
} elseif($max_age > 0 && (get_current_timestamp() - $upload_ctime) <= $max_age) {
$is_valid = true;
$is_valid = ($max_age > 0) ? ($upload_age <= $max_age) : true;
}

if($is_valid) {
Expand Down Expand Up @@ -249,7 +248,7 @@ function remove_storage_file($filename, $options=array()) {
@chown($upload_filename, $options['chown']);
}

if(!array_key_empty("shell", $options)) {
if(!array_key_equals("shell", $options, true)) {
if(loadHelper("exectool")) {
$exec_cmd = ($options['shell'] == "windows") ? "del '%s'" : "rm -f '%s'";
exec_command(sprintf($exec_cmd, make_safe_argument($upload_filename)));
Expand Down

0 comments on commit 941e656

Please sign in to comment.