Version 4.1.19

This commit is contained in:
Neo committed 2025-12-19 05:38:56 -08:00
1 parent 28bd025b35
commit 2bd5025018
2674 files changed
+233518 -77766

No files matched your search

+58 -25
View File
@@ -2,9 +2,9 @@
/**
* @brief File Handler: File System
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @since 06 May 2013
* @version SVN_VERSION_NUMBER
*/
@@ -53,9 +53,9 @@ class _FileSystem extends \IPS\File
*/
public static function testSettings( &$values )
{
$values['dir'] = rtrim( $values['dir'], '/' );
$values['dir'] = rtrim( $values['dir'], '\\/' );
$testDir = str_replace( '{root}', \IPS\ROOT_PATH, $values['dir'] );
$values['url'] = trim( str_replace( \IPS\ROOT_PATH, '', $testDir ), '/' );
$values['url'] = trim( str_replace( \IPS\ROOT_PATH, '', $testDir ), '\\/' );
if ( empty( $values['toggle'] ) )
{
@@ -105,7 +105,7 @@ class _FileSystem extends \IPS\File
*/
public static function moveCheck( $configuration, $oldConfiguration )
{
if ( str_replace( '{root}', \IPS\ROOT_PATH, $configuration['dir'] ) !== str_replace( '{root}', \IPS\ROOT_PATH, $oldConfiguration['dir'] ) )
if ( str_replace( '{root}', \IPS\ROOT_PATH, preg_replace( '#/{1,}/#', '/', rtrim( $configuration['dir'], '/' ) ) ) !== str_replace( '{root}', \IPS\ROOT_PATH, preg_replace( '#/{1,}/#', '/', rtrim( $oldConfiguration['dir'], '/' ) ) ) )
{
return TRUE;
}
@@ -173,7 +173,7 @@ class _FileSystem extends \IPS\File
{
$url = str_replace( 'http://', 'https://', $url );
}
return $url;
return rtrim( $url, '/' );
}
/**
@@ -249,7 +249,9 @@ class _FileSystem extends \IPS\File
{
if( file_exists( $this->configuration['dir'] . '/' . $this->container . '/' . $this->filename ) )
{
if ( ! ( $this->contents = @file_get_contents( $this->configuration['dir'] . '/' . $this->container . '/' . $this->filename ) ) )
$this->contents = @file_get_contents( $this->configuration['dir'] . '/' . $this->container . '/' . $this->filename );
if ( $this->contents === FALSE )
{
throw new \RuntimeException( 'COULD_NOT_OPEN_FILE' );
}
@@ -307,19 +309,25 @@ class _FileSystem extends \IPS\File
/* Save the file */
if( $this->temporaryFilePath )
{
if( !@\rename( $this->temporaryFilePath, "{$folder}/{$this->filename}" ) OR @chmod( "{$folder}/{$this->filename}", \IPS\IPS_FILE_PERMISSION ) === FALSE )
if( !@\rename( $this->temporaryFilePath, "{$folder}/{$this->filename}" ) )
{
\IPS\Log::log( "Could not move file {$folder}/{$this->filename}" , 'FileSystem' );
throw new \RuntimeException( 'COULD_NOT_MOVE_FILE' );
}
@chmod( "{$folder}/{$this->filename}", \IPS\IPS_FILE_PERMISSION );
}
else
{
if ( $contents = $this->contents() )
{
if ( !@\file_put_contents( "{$folder}/{$this->filename}", $contents ) OR @chmod( "{$folder}/{$this->filename}", \IPS\IPS_FILE_PERMISSION ) === FALSE )
if ( !@\file_put_contents( "{$folder}/{$this->filename}", $contents ) )
{
\IPS\Log::log( "Could not write file {$folder}/{$this->filename}" , 'FileSystem' );
throw new \RuntimeException( 'COULD_NOT_WRITE_FILE' );
}
@chmod( "{$folder}/{$this->filename}", \IPS\IPS_FILE_PERMISSION );
}
else
{
@@ -328,14 +336,14 @@ 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') )
if ( function_exists( 'opcache_invalidate' ) )
{
@opcache_reset();
@opcache_invalidate( "{$folder}/{$this->filename}" );
}
/* Set the URL */
$this->url = \IPS\Http\Url::createFromString( $this->fullyQualifiedUrl( "{$this->container}/{$this->filename}" ), FALSE );
}
/**
@@ -345,14 +353,17 @@ class _FileSystem extends \IPS\File
*/
public function delete()
{
/* Log deletion request */
$this->log( "file_deletion", 'delete', NULL, 'log' );
if( file_exists( "{$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') )
if ( function_exists( 'opcache_invalidate' ) )
{
@opcache_reset();
@opcache_invalidate( "{$this->configuration['dir']}/{$this->container}/{$this->filename}" );
}
return $result;
@@ -376,29 +387,51 @@ class _FileSystem extends \IPS\File
if ( is_dir( $dir ) )
{
$files = array();
$dirs = array();
foreach ( new \DirectoryIterator( $dir ) as $f )
{
if ( !$f->isDot() )
{
if( $f->isDir() )
{
$this->deleteContainer( $container . '/' . $f->getFilename(), TRUE );
$dirs[] = $container . '/' . $f->getFilename();
}
else
{
unlink( $f->getPathname() );
$files[] = $f->getPathname();
}
}
}
/* If we have any directories to delete - delete them */
foreach( $dirs as $directory )
{
$this->deleteContainer( $directory, true );
}
/* And now delete the files */
foreach( $files as $file )
{
unlink( $file );
/* Clear zend opcache if enabled */
if( $skipClear === FALSE and function_exists( 'opcache_invalidate' ) )
{
@opcache_invalidate( $file );
}
}
/* And finally, remove the directory we're currently working with */
rmdir( $dir );
}
/* Clear zend opcache if enabled */
if( function_exists('opcache_reset') AND $skipClear === FALSE )
{
@opcache_reset();
}
/* Log deletion request */
$realContainer = $this->container;
$this->container = $container;
$this->log( "container_deletion", 'delete', $_REQUEST, 'log' );
$this->container = $realContainer;
}
/**
@@ -425,9 +458,9 @@ class _FileSystem extends \IPS\File
@unlink( $chunk );
/* Clear zend opcache if enabled */
if( function_exists('opcache_reset') )
if ( function_exists( 'opcache_invalidate' ) )
{
@opcache_reset();
@opcache_invalidate( "{$this->configuration['dir']}/{$folder}/{$filename}" );
}
if ( $rename )