summaryrefslogtreecommitdiffstats
path: root/system/libraries/Ftp.php
diff options
context:
space:
mode:
authorAndrew <browner12@gmail.com>2014-02-17 19:24:00 +0100
committerAndrew <browner12@gmail.com>2014-02-17 19:24:00 +0100
commit63cb46b94c4dda33e036643fbca3d94e0ba079f0 (patch)
treea8bc36fa23e3a7de491223c896d9aadaf4e8c408 /system/libraries/Ftp.php
parentb6d8b962e44202a74c9b9321a4a53f61a753fccf (diff)
parentffe8aded4d2210759fce3427ed04893e6c655006 (diff)
Merge branch 'develop' into patch-1
Diffstat (limited to 'system/libraries/Ftp.php')
-rw-r--r--system/libraries/Ftp.php77
1 files changed, 34 insertions, 43 deletions
diff --git a/system/libraries/Ftp.php b/system/libraries/Ftp.php
index 73a68441a..991769a6a 100644
--- a/system/libraries/Ftp.php
+++ b/system/libraries/Ftp.php
@@ -18,7 +18,7 @@
*
* @package CodeIgniter
* @author EllisLab Dev Team
- * @copyright Copyright (c) 2008 - 2013, EllisLab, Inc. (http://ellislab.com/)
+ * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* @link http://codeigniter.com
* @since Version 1.0
@@ -463,28 +463,26 @@ class CI_FTP {
$filepath = preg_replace('/(.+?)\/*$/', '\\1/', $filepath);
$list = $this->list_files($filepath);
-
- if ($list !== FALSE && count($list) > 0)
+ if ( ! empty($list))
{
- foreach ($list as $item)
+ for ($i = 0, $c = count($list); $i < $c; $i++)
{
- // If we can't delete the item it's probaly a folder so
- // we'll recursively call delete_dir()
- if ( ! @ftp_delete($this->conn_id, $item))
+ // If we can't delete the item it's probaly a directory,
+ // so we'll recursively call delete_dir()
+ if ( ! @ftp_delete($this->conn_id, $list[$i]))
{
- $this->delete_dir($item);
+ $this->delete_dir($list[$i]);
}
}
}
- $result = @ftp_rmdir($this->conn_id, $filepath);
-
- if ($result === FALSE)
+ if (@ftp_rmdir($this->conn_id, $filepath) === FALSE)
{
if ($this->debug === TRUE)
{
$this->_error('ftp_unable_to_delete');
}
+
return FALSE;
}
@@ -507,14 +505,13 @@ class CI_FTP {
return FALSE;
}
- $result = @ftp_chmod($this->conn_id, $perm, $path);
-
- if ($result === FALSE)
+ if (@ftp_chmod($this->conn_id, $perm, $path) === FALSE)
{
if ($this->debug === TRUE)
{
$this->_error('ftp_unable_to_chmod');
}
+
return FALSE;
}
@@ -531,12 +528,9 @@ class CI_FTP {
*/
public function list_files($path = '.')
{
- if ( ! $this->_is_conn())
- {
- return FALSE;
- }
-
- return ftp_nlist($this->conn_id, $path);
+ return $this->_is_conn()
+ ? ftp_nlist($this->conn_id, $path)
+ : FALSE;
}
// ------------------------------------------------------------------------
@@ -585,6 +579,7 @@ class CI_FTP {
$this->upload($locpath.$file, $rempath.$file, $mode);
}
}
+
return TRUE;
}
@@ -601,13 +596,12 @@ class CI_FTP {
*/
protected function _getext($filename)
{
- if (FALSE === strpos($filename, '.'))
+ if (($dot = strrpos($filename, '.')) === FALSE)
{
return 'txt';
}
- $x = explode('.', $filename);
- return end($x);
+ return substr($filename, $dot + 1);
}
// --------------------------------------------------------------------
@@ -621,20 +615,20 @@ class CI_FTP {
protected function _settype($ext)
{
$text_types = array(
- 'txt',
- 'text',
- 'php',
- 'phps',
- 'php4',
- 'js',
- 'css',
- 'htm',
- 'html',
- 'phtml',
- 'shtml',
- 'log',
- 'xml'
- );
+ 'txt',
+ 'text',
+ 'php',
+ 'phps',
+ 'php4',
+ 'js',
+ 'css',
+ 'htm',
+ 'html',
+ 'phtml',
+ 'shtml',
+ 'log',
+ 'xml'
+ );
return in_array($ext, $text_types) ? 'ascii' : 'binary';
}
@@ -648,12 +642,9 @@ class CI_FTP {
*/
public function close()
{
- if ( ! $this->_is_conn())
- {
- return FALSE;
- }
-
- return @ftp_close($this->conn_id);
+ return $this->_is_conn()
+ ? @ftp_close($this->conn_id)
+ : FALSE;
}
// ------------------------------------------------------------------------