Version 4.1.2
This commit is contained in:
1 parent
3ba79295ee
commit
28bd025b35
1131 files changed
+63658
-20579
No files matched your search
+52
-69
@@ -61,7 +61,11 @@ class _FileSystem extends \IPS\File
|
||||
{
|
||||
$values['custom_url'] = NULL;
|
||||
}
|
||||
|
||||
|
||||
if ( !$testDir )
|
||||
{
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'dir_not_provided', FALSE ) );
|
||||
}
|
||||
if ( !is_dir( $testDir ) )
|
||||
{
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'dir_does_not_exist', FALSE, array( 'sprintf' => array( $testDir ) ) ) );
|
||||
@@ -229,61 +233,7 @@ class _FileSystem extends \IPS\File
|
||||
{
|
||||
$file = $this->configuration['dir'] . '/' . $this->container . '/' . $this->filename;
|
||||
|
||||
/* Turn off output buffering if it is on */
|
||||
while( ob_get_level() > 0 )
|
||||
{
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
if( $throttle === NULL AND !($start AND $length) AND function_exists('readfile') )
|
||||
{
|
||||
readfile( $file );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( $fh = fopen( $file, 'rb' ) )
|
||||
{
|
||||
$read = ( $throttle !== NULL ) ? $throttle : 4096;
|
||||
|
||||
if( $start AND $length )
|
||||
{
|
||||
fseek( $fh, $start );
|
||||
|
||||
while( $length AND !feof( $fh ) )
|
||||
{
|
||||
if( $read > $length )
|
||||
{
|
||||
$read = $length;
|
||||
}
|
||||
|
||||
echo fread( $fh, $read );
|
||||
flush();
|
||||
|
||||
$length -= $read;
|
||||
|
||||
if( $throttle )
|
||||
{
|
||||
sleep( 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while( ! feof( $fh ) )
|
||||
{
|
||||
echo fread( $fh, $read );
|
||||
flush();
|
||||
|
||||
if( $throttle )
|
||||
{
|
||||
sleep( 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose( $fh );
|
||||
}
|
||||
}
|
||||
$this->sendFile( $file, $start, $length, $throttle );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -318,6 +268,7 @@ class _FileSystem extends \IPS\File
|
||||
*
|
||||
* @return array
|
||||
* @throws \DomainException
|
||||
* @throws \RuntimeException
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function getImageDimensions()
|
||||
@@ -329,6 +280,11 @@ class _FileSystem extends \IPS\File
|
||||
|
||||
$file = $this->configuration['dir'] . '/' . $this->container . '/' . $this->filename;
|
||||
|
||||
if ( ! file_exists( $file ) )
|
||||
{
|
||||
throw new \RuntimeException;
|
||||
}
|
||||
|
||||
if( ( $image = getimagesize( $file ) ) === FALSE )
|
||||
{
|
||||
return parent::getImageDimensions();
|
||||
@@ -345,12 +301,6 @@ class _FileSystem extends \IPS\File
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
/* Make sure name doesn't have anything that may break URLs */
|
||||
if ( preg_match( '#[^a-zA-Z0-9!\-_\.\*\(\)]#', $this->filename ) )
|
||||
{
|
||||
$this->filename = uniqid() . '_' . preg_replace( '#[^a-zA-Z0-9!\-_\.\*\(\)]#', '', $this->filename );
|
||||
}
|
||||
|
||||
/* Make the folder */
|
||||
$folder = $this->configuration['dir'] . '/' . $this->getFolder();
|
||||
|
||||
@@ -380,6 +330,12 @@ class _FileSystem extends \IPS\File
|
||||
|
||||
/* Set the URL */
|
||||
$this->url = new \IPS\Http\Url( $this->fullyQualifiedUrl( "{$this->container}/{$this->filename}" ) );
|
||||
|
||||
/* Clear zend opcache if enabled */
|
||||
if( function_exists('opcache_reset') )
|
||||
{
|
||||
@opcache_reset();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -391,7 +347,15 @@ class _FileSystem extends \IPS\File
|
||||
{
|
||||
if( file_exists( "{$this->configuration['dir']}/{$this->container}/{$this->filename}" ) )
|
||||
{
|
||||
return @unlink( "{$this->configuration['dir']}/{$this->container}/{$this->filename}" );
|
||||
$result = @unlink( "{$this->configuration['dir']}/{$this->container}/{$this->filename}" );
|
||||
|
||||
/* Clear zend opcache if enabled */
|
||||
if( function_exists('opcache_reset') )
|
||||
{
|
||||
@opcache_reset();
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -403,25 +367,38 @@ class _FileSystem extends \IPS\File
|
||||
* Delete Container
|
||||
*
|
||||
* @param string $container Key
|
||||
* @param bool $skipClear Skip clearing the opcache, used for recursive calls since the parent call will do it
|
||||
* @return void
|
||||
*/
|
||||
public function deleteContainer( $container )
|
||||
public function deleteContainer( $container, $skipClear = FALSE )
|
||||
{
|
||||
$dir = $this->configuration['dir'] . '/' . $container;
|
||||
|
||||
if ( is_dir( $dir ) )
|
||||
{
|
||||
foreach ( new \DirectoryIterator( $dir ) as $f )
|
||||
{
|
||||
if ( !$f->isDot() )
|
||||
{
|
||||
unlink( $f->getPathname() );
|
||||
if( $f->isDir() )
|
||||
{
|
||||
$this->deleteContainer( $container . '/' . $f->getFilename(), TRUE );
|
||||
}
|
||||
else
|
||||
{
|
||||
unlink( $f->getPathname() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$handle = opendir( $dir );
|
||||
closedir ( $handle );
|
||||
rmdir( $dir );
|
||||
}
|
||||
|
||||
/* Clear zend opcache if enabled */
|
||||
if( function_exists('opcache_reset') AND $skipClear === FALSE )
|
||||
{
|
||||
@opcache_reset();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -446,14 +423,20 @@ class _FileSystem extends \IPS\File
|
||||
}
|
||||
fclose( $file );
|
||||
@unlink( $chunk );
|
||||
|
||||
|
||||
/* Clear zend opcache if enabled */
|
||||
if( function_exists('opcache_reset') )
|
||||
{
|
||||
@opcache_reset();
|
||||
}
|
||||
|
||||
if ( $rename )
|
||||
{
|
||||
$newFileName = static::obscureFilename( $rename );
|
||||
rename( "{$this->configuration['dir']}/{$folder}/{$filename}", "{$this->configuration['dir']}/{$folder}/{$newFileName}" );
|
||||
return "{$folder}/{$newFileName}";
|
||||
}
|
||||
|
||||
|
||||
return "{$folder}/{$filename}";
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user