summaryrefslogtreecommitdiffstats
path: root/system/libraries
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-02-21 16:11:54 +0100
committerAndrey Andreev <narf@devilix.net>2014-02-21 16:11:54 +0100
commite52e42677aa1947fcf4b81b7d58637696d7305c6 (patch)
tree757e3d1f0208c42d4c921fdc3d6d6daee75c2d12 /system/libraries
parent6125a279693a54d04cbd63d7aee03cf7b9a85f00 (diff)
Minor improvements to CI_FTP
Diffstat (limited to 'system/libraries')
-rw-r--r--system/libraries/Ftp.php61
1 files changed, 25 insertions, 36 deletions
diff --git a/system/libraries/Ftp.php b/system/libraries/Ftp.php
index 991769a6a..fc02f8300 100644
--- a/system/libraries/Ftp.php
+++ b/system/libraries/Ftp.php
@@ -42,35 +42,35 @@ class CI_FTP {
*
* @var string
*/
- public $hostname = '';
+ public $hostname = '';
/**
* FTP Username
*
* @var string
*/
- public $username = '';
+ public $username = '';
/**
* FTP Password
*
* @var string
*/
- public $password = '';
+ public $password = '';
/**
* FTP Server port
*
* @var int
*/
- public $port = 21;
+ public $port = 21;
/**
* Passive mode flag
*
* @var bool
*/
- public $passive = TRUE;
+ public $passive = TRUE;
/**
* Debug flag
@@ -79,14 +79,16 @@ class CI_FTP {
*
* @var bool
*/
- public $debug = FALSE;
+ public $debug = FALSE;
+
+ // --------------------------------------------------------------------
/**
- * Connection
+ * Connection ID
*
* @var resource
*/
- public $conn_id = FALSE;
+ protected $conn_id;
// --------------------------------------------------------------------
@@ -98,11 +100,7 @@ class CI_FTP {
*/
public function __construct($config = array())
{
- if (count($config) > 0)
- {
- $this->initialize($config);
- }
-
+ empty($config) OR $this->initialize($config);
log_message('debug', 'FTP Class Initialized');
}
@@ -197,8 +195,10 @@ class CI_FTP {
{
$this->_error('ftp_no_connection');
}
+
return FALSE;
}
+
return TRUE;
}
@@ -232,6 +232,7 @@ class CI_FTP {
{
$this->_error('ftp_unable_to_changedir');
}
+
return FALSE;
}
@@ -262,6 +263,7 @@ class CI_FTP {
{
$this->_error('ftp_unable_to_mkdir');
}
+
return FALSE;
}
@@ -316,6 +318,7 @@ class CI_FTP {
{
$this->_error('ftp_unable_to_upload');
}
+
return FALSE;
}
@@ -363,6 +366,7 @@ class CI_FTP {
{
$this->_error('ftp_unable_to_download');
}
+
return FALSE;
}
@@ -394,6 +398,7 @@ class CI_FTP {
{
$this->_error('ftp_unable_to_'.($move === FALSE ? 'rename' : 'move'));
}
+
return FALSE;
}
@@ -437,6 +442,7 @@ class CI_FTP {
{
$this->_error('ftp_unable_to_delete');
}
+
return FALSE;
}
@@ -596,12 +602,9 @@ class CI_FTP {
*/
protected function _getext($filename)
{
- if (($dot = strrpos($filename, '.')) === FALSE)
- {
- return 'txt';
- }
-
- return substr($filename, $dot + 1);
+ return (($dot = strrpos($filename, '.')) === FALSE)
+ ? 'txt'
+ : substr($filename, $dot + 1);
}
// --------------------------------------------------------------------
@@ -614,23 +617,9 @@ class CI_FTP {
*/
protected function _settype($ext)
{
- $text_types = array(
- 'txt',
- 'text',
- 'php',
- 'phps',
- 'php4',
- 'js',
- 'css',
- 'htm',
- 'html',
- 'phtml',
- 'shtml',
- 'log',
- 'xml'
- );
-
- return in_array($ext, $text_types) ? 'ascii' : 'binary';
+ return in_array($ext, array('txt', 'text', 'php', 'phps', 'php4', 'js', 'css', 'htm', 'html', 'phtml', 'shtml', 'log', 'xml'), TRUE)
+ ? 'ascii'
+ : 'binary';
}
// ------------------------------------------------------------------------