mirror of
https://github.com/Rouji/single_php_filehost.git
synced 2025-04-10 19:08:45 +00:00
handle special file extensions like .tar.gz
This commit is contained in:
parent
1f0f9d82a1
commit
fad7869109
14
index.php
14
index.php
@ -103,7 +103,7 @@ function storeFile($name, $tmpFile, $formatted = false)
|
|||||||
mkdir($STORE_PATH, 0750, true); //TODO: error handling
|
mkdir($STORE_PATH, 0750, true); //TODO: error handling
|
||||||
}
|
}
|
||||||
|
|
||||||
$ext = pathinfo($name, PATHINFO_EXTENSION);
|
$ext = getExtension($name);
|
||||||
$id = rndStr($ID_LENGTH);
|
$id = rndStr($ID_LENGTH);
|
||||||
$basename = $id . '.' . $ext;
|
$basename = $id . '.' . $ext;
|
||||||
$target_file = $STORE_PATH . $basename;
|
$target_file = $STORE_PATH . $basename;
|
||||||
@ -132,6 +132,18 @@ function storeFile($name, $tmpFile, $formatted = false)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getExtension($path)
|
||||||
|
{
|
||||||
|
$ext = pathinfo($path, PATHINFO_EXTENSION);
|
||||||
|
//special handling of .tar.* archives
|
||||||
|
$ext2 = pathinfo(substr($path,0,-(strlen($ext)+1)), PATHINFO_EXTENSION);
|
||||||
|
if ($ext2 === 'tar')
|
||||||
|
{
|
||||||
|
$ext = $ext2.'.'.$ext;
|
||||||
|
}
|
||||||
|
return $ext;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// purge all files older than their retention period allows.
|
// purge all files older than their retention period allows.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
Loading…
Reference in New Issue
Block a user