Version 4.1.2
This commit is contained in:
1 parent
3ba79295ee
commit
28bd025b35
1131 files changed
+63658
-20579
No files matched your search
+28
-12
@@ -149,12 +149,6 @@ class _Ftp 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 );
|
||||
}
|
||||
|
||||
/* Get contents */
|
||||
$contents = $this->contents();
|
||||
|
||||
@@ -218,7 +212,7 @@ class _Ftp extends \IPS\File
|
||||
/**
|
||||
* @brief FTP Connection
|
||||
*/
|
||||
protected static $ftp = NULL;
|
||||
protected $ftp = NULL;
|
||||
|
||||
/**
|
||||
* Get FTP Connection
|
||||
@@ -228,20 +222,20 @@ class _Ftp extends \IPS\File
|
||||
*/
|
||||
protected function ftp()
|
||||
{
|
||||
if ( static::$ftp === NULL )
|
||||
if ( $this->ftp === NULL )
|
||||
{
|
||||
if ( $this->configuration['ftp_details']['protocol'] == 'sftp' )
|
||||
{
|
||||
static::$ftp = new \IPS\Ftp\Sftp( $this->configuration['ftp_details']['server'], $this->configuration['ftp_details']['un'], $this->configuration['ftp_details']['pw'], $this->configuration['ftp_details']['port'] );
|
||||
$this->ftp = new \IPS\Ftp\Sftp( $this->configuration['ftp_details']['server'], $this->configuration['ftp_details']['un'], $this->configuration['ftp_details']['pw'], $this->configuration['ftp_details']['port'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
static::$ftp = new \IPS\Ftp( $this->configuration['ftp_details']['server'], $this->configuration['ftp_details']['un'], $this->configuration['ftp_details']['pw'], $this->configuration['ftp_details']['port'], ( $this->configuration['ftp_details']['protocol'] == 'ssl_ftp' ) );
|
||||
$this->ftp = new \IPS\Ftp( $this->configuration['ftp_details']['server'], $this->configuration['ftp_details']['un'], $this->configuration['ftp_details']['pw'], $this->configuration['ftp_details']['port'], ( $this->configuration['ftp_details']['protocol'] == 'ssl_ftp' ) );
|
||||
}
|
||||
|
||||
static::$ftp->chdir( $this->configuration['ftp_details']['path'] );
|
||||
$this->ftp->chdir( $this->configuration['ftp_details']['path'] );
|
||||
}
|
||||
return static::$ftp;
|
||||
return $this->ftp;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -336,6 +330,28 @@ class _Ftp extends \IPS\File
|
||||
|
||||
$size = $this->ftp()->size( $this->filename );
|
||||
|
||||
$this->ftp()->chdir( $this->configuration['ftp_details']['path'] );
|
||||
|
||||
return $size ?: parent::filesize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Print the contents of the file
|
||||
*
|
||||
* @param int|null $start Start point to print from (for ranges)
|
||||
* @param int|null $length Length to print to (for ranges)
|
||||
* @param int|null $throttle Throttle speed
|
||||
* @return void
|
||||
*/
|
||||
public function printFile( $start=NULL, $length=NULL, $throttle=NULL )
|
||||
{
|
||||
/* Download the file locally */
|
||||
$file = $this->ftp()->download( $this->configuration['ftp_details']['path'] . ( $this->container ? '/' . $this->container : '' ) . '/' . $this->filename, NULL, TRUE );
|
||||
|
||||
/* Send the file */
|
||||
$this->sendFile( $file, $start, $length, $throttle );
|
||||
|
||||
/* Remove the temporary file */
|
||||
@unlink( $file );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user