1
0
mirror of https://github.com/misterunknown/ifm.git synced 2025-08-10 10:04:01 +02:00

Merge pull request #37 from misterunknown/issue-34

added config option for temporary directory; closes #34
This commit is contained in:
Marco Dickert
2017-06-30 12:18:39 +02:00
committed by GitHub
3 changed files with 26 additions and 8 deletions

17
ifm.php
View File

@@ -70,6 +70,13 @@ class IFMConfig {
const root_dir = "";
const defaulttimezone = "Europe/Berlin"; // set default timezone
/**
* Temp directory for zip files
*
* Default is the upload_tmp_dir which is set in the php.ini, but you may also set an different path
*/
const tmp_dir = "";
// development tools
const ajaxrequest = 1; // formular to perform an ajax request
@@ -1356,7 +1363,7 @@ ifm.init();
if( ! is_dir( realpath( IFMConfig::root_dir ) ) || ! is_readable( realpath( IFMConfig::root_dir ) ) )
die( "Cannot access root_dir.");
else
chdir( IFMConfig::root_dir );
chdir( realpath( IFMConfig::root_dir ) );
if ( ! isset($_REQUEST['api']) ) {
$this->getApplication();
} else {
@@ -1719,7 +1726,7 @@ ifm.init();
echo json_encode( array( "status" => "ERROR", "message" => "Filename not allowed" ) );
else {
unset( $zip );
$dfile = uniqid( "ifm-tmp-" ) . ".zip"; // temporary filename
$dfile = $this->pathCombine( IFMConfig::tmp_dir, uniqid( "ifm-tmp-" ) . ".zip" ); // temporary filename
try {
IFMZip::create_zip( realpath( $d['filename'] ), $dfile, ( $d['filename'] == "." ) );
if( $d['filename'] == "." ) {
@@ -1962,10 +1969,12 @@ ifm.init();
// combines two parts to a valid path
private function pathCombine( $a, $b ) {
if( $a=="" && $b=="" )
if( trim( $a ) == "" && trim( $b ) == "" )
return "";
elseif( trim( $a ) == "" )
return ltrim( $b, '/' );
else
return ltrim( rtrim( $a, '/' ) . '/' . ltrim( $b, '/' ), '/' );
return rtrim( $a, '/' ) . '/' . ltrim( $b, '/' );
}
// check if filename is allowed

View File

@@ -70,6 +70,13 @@ class IFMConfig {
const root_dir = "";
const defaulttimezone = "Europe/Berlin"; // set default timezone
/**
* Temp directory for zip files
*
* Default is the upload_tmp_dir which is set in the php.ini, but you may also set an different path
*/
const tmp_dir = "";
// development tools
const ajaxrequest = 1; // formular to perform an ajax request

View File

@@ -164,7 +164,7 @@ class IFM {
if( ! is_dir( realpath( IFMConfig::root_dir ) ) || ! is_readable( realpath( IFMConfig::root_dir ) ) )
die( "Cannot access root_dir.");
else
chdir( IFMConfig::root_dir );
chdir( realpath( IFMConfig::root_dir ) );
if ( ! isset($_REQUEST['api']) ) {
$this->getApplication();
} else {
@@ -527,7 +527,7 @@ class IFM {
echo json_encode( array( "status" => "ERROR", "message" => "Filename not allowed" ) );
else {
unset( $zip );
$dfile = uniqid( "ifm-tmp-" ) . ".zip"; // temporary filename
$dfile = $this->pathCombine( IFMConfig::tmp_dir, uniqid( "ifm-tmp-" ) . ".zip" ); // temporary filename
try {
IFMZip::create_zip( realpath( $d['filename'] ), $dfile, ( $d['filename'] == "." ) );
if( $d['filename'] == "." ) {
@@ -770,10 +770,12 @@ class IFM {
// combines two parts to a valid path
private function pathCombine( $a, $b ) {
if( $a=="" && $b=="" )
if( trim( $a ) == "" && trim( $b ) == "" )
return "";
elseif( trim( $a ) == "" )
return ltrim( $b, '/' );
else
return ltrim( rtrim( $a, '/' ) . '/' . ltrim( $b, '/' ), '/' );
return rtrim( $a, '/' ) . '/' . ltrim( $b, '/' );
}
// check if filename is allowed