Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

+18 -11
View File
@@ -11,7 +11,7 @@
namespace IPS\File;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -47,15 +47,15 @@ class _Ftp extends \IPS\File
*/
public static function testSettings( &$values )
{
if ( !function_exists( 'ftp_connect' ) )
if ( !\function_exists( 'ftp_connect' ) )
{
throw new \BadFunctionCallException( 'ftp_err_no_ext' );
}
elseif ( $values['ftp_details']['protocol'] === 'ssl_ftp' and !function_exists( 'ftp_ssl_connect' ) )
elseif ( $values['ftp_details']['protocol'] === 'ssl_ftp' and !\function_exists( 'ftp_ssl_connect' ) )
{
throw new \BadFunctionCallException( 'ftp_err_no_ssl' );
}
elseif ( $values['ftp_details']['protocol'] === 'sftp' and !function_exists( 'ssh2_connect' ) )
elseif ( $values['ftp_details']['protocol'] === 'sftp' and !\function_exists( 'ssh2_connect' ) )
{
throw new \BadFunctionCallException( 'ftp_err_no_sftp' );
}
@@ -156,7 +156,7 @@ class _Ftp extends \IPS\File
\file_put_contents( $tmpFileName, $contents );
/* Move into the correct folder */
if( !in_array( $this->container, $this->ftp()->ls() ) )
if( !\in_array( $this->container, $this->ftp()->ls() ) )
{
/* Make dir */
$this->ftp()->mkdir( $this->container );
@@ -201,7 +201,7 @@ class _Ftp extends \IPS\File
$immediateCaller = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, 1 );
$debug = array_map( function( $row ) {
return array_filter( $row, function( $key ) {
return in_array( $key, array( 'class', 'function', 'line' ) );
return \in_array( $key, array( 'class', 'function', 'line' ) );
}, ARRAY_FILTER_USE_KEY );
}, debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS ) );
$this->log( "file_deletion", 'delete', $debug, 'log' );
@@ -242,8 +242,8 @@ class _Ftp extends \IPS\File
foreach( $pathBits as $piece )
{
$pathToCheck = count( $reconstructed ) ? implode( '/', $reconstructed ) : '.';
if( $this->ftp()->ls( $pathToCheck ) === FALSE OR !in_array( $piece, $this->ftp()->ls( $pathToCheck ) ) )
$pathToCheck = \count( $reconstructed ) ? implode( '/', $reconstructed ) : '.';
if( $this->ftp()->ls( $pathToCheck ) === FALSE OR !\in_array( $piece, $this->ftp()->ls( $pathToCheck ) ) )
{
return FALSE;
}
@@ -366,10 +366,15 @@ class _Ftp extends \IPS\File
/**
* Get filesize (in bytes)
*
* @return string
* @return string|bool
*/
public function filesize()
{
if( $this->_cachedFilesize !== null )
{
return $this->_cachedFilesize;
}
try
{
$this->ftp()->chdir( $this->configuration['ftp_details']['path'] );
@@ -383,12 +388,14 @@ class _Ftp extends \IPS\File
$this->ftp()->chdir( $this->configuration['ftp_details']['path'] );
return $size ?: parent::filesize();
$this->_cachedFilesize = $size ?: parent::filesize();
}
catch( \IPS\Ftp\Exception $e )
{
return FALSE;
$this->_cachedFilesize = FALSE;
}
return $this->_cachedFilesize;
}
/**