summaryrefslogtreecommitdiffstats
path: root/system/libraries
diff options
context:
space:
mode:
Diffstat (limited to 'system/libraries')
-rw-r--r--system/libraries/Cache/Cache.php109
-rw-r--r--system/libraries/Cache/drivers/Cache_apc.php43
-rw-r--r--system/libraries/Cache/drivers/Cache_dummy.php37
-rw-r--r--system/libraries/Cache/drivers/Cache_file.php42
-rw-r--r--system/libraries/Cache/drivers/Cache_memcached.php57
-rw-r--r--system/libraries/Cache/drivers/Cache_wincache.php7
-rw-r--r--system/libraries/Calendar.php61
-rw-r--r--system/libraries/Cart.php48
-rw-r--r--system/libraries/Driver.php52
-rw-r--r--system/libraries/Ftp.php109
-rw-r--r--system/libraries/Migration.php26
-rw-r--r--system/libraries/Pagination.php44
-rw-r--r--system/libraries/Parser.php47
-rw-r--r--system/libraries/Typography.php53
-rw-r--r--system/libraries/Upload.php328
-rw-r--r--system/libraries/Xmlrpcs.php64
-rw-r--r--system/libraries/Zip.php162
17 files changed, 528 insertions, 761 deletions
diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php
index 7642a5270..f98241617 100644
--- a/system/libraries/Cache/Cache.php
+++ b/system/libraries/Cache/Cache.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Caching Class
*
@@ -50,11 +48,37 @@ class CI_Cache extends CI_Driver_Library {
protected $_adapter = 'dummy';
protected $_backup_driver;
+ /**
+ * Constructor
+ *
+ * Initialize class properties based on the configuration array.
+ *
+ * @param array
+ * @return void
+ */
public function __construct($config = array())
{
- if ( ! empty($config))
+ $default_config = array(
+ 'adapter',
+ 'memcached'
+ );
+
+ foreach ($default_config as $key)
{
- $this->_initialize($config);
+ if (isset($config[$key]))
+ {
+ $param = '_'.$key;
+
+ $this->{$param} = $config[$key];
+ }
+ }
+
+ if (isset($config['backup']))
+ {
+ if (in_array('cache_'.$config['backup'], $this->valid_drivers))
+ {
+ $this->_backup_driver = $config['backup'];
+ }
}
}
@@ -63,11 +87,11 @@ class CI_Cache extends CI_Driver_Library {
/**
* Get
*
- * Look for a value in the cache. If it exists, return the data
+ * Look for a value in the cache. If it exists, return the data
* if not, return FALSE
*
- * @param string
- * @return mixed value that is stored/FALSE on failure
+ * @param string
+ * @return mixed value that is stored/FALSE on failure
*/
public function get($id)
{
@@ -79,11 +103,10 @@ class CI_Cache extends CI_Driver_Library {
/**
* Cache Save
*
- * @param string Unique Key
- * @param mixed Data to store
- * @param int Length of time (in seconds) to cache the data
- *
- * @return boolean true on success/false on failure
+ * @param string Unique Key
+ * @param mixed Data to store
+ * @param int Length of time (in seconds) to cache the data
+ * @return bool true on success/false on failure
*/
public function save($id, $data, $ttl = 60)
{
@@ -95,8 +118,8 @@ class CI_Cache extends CI_Driver_Library {
/**
* Delete from Cache
*
- * @param mixed unique identifier of the item in the cache
- * @return boolean true on success/false on failure
+ * @param mixed unique identifier of the item in the cache
+ * @return bool true on success/false on failure
*/
public function delete($id)
{
@@ -108,7 +131,7 @@ class CI_Cache extends CI_Driver_Library {
/**
* Clean the cache
*
- * @return boolean false on failure/true on success
+ * @return bool false on failure/true on success
*/
public function clean()
{
@@ -120,8 +143,8 @@ class CI_Cache extends CI_Driver_Library {
/**
* Cache Info
*
- * @param string user/filehits
- * @return mixed array on success, false on failure
+ * @param string user/filehits
+ * @return mixed array on success, false on failure
*/
public function cache_info($type = 'user')
{
@@ -133,8 +156,8 @@ class CI_Cache extends CI_Driver_Library {
/**
* Get Cache Metadata
*
- * @param mixed key to get cache metadata on
- * @return mixed return value from child method
+ * @param mixed key to get cache metadata on
+ * @return mixed return value from child method
*/
public function get_metadata($id)
{
@@ -144,46 +167,10 @@ class CI_Cache extends CI_Driver_Library {
// ------------------------------------------------------------------------
/**
- * Initialize
- *
- * Initialize class properties based on the configuration array.
- *
- * @param array
- * @return void
- */
- private function _initialize($config)
- {
- $default_config = array(
- 'adapter',
- 'memcached'
- );
-
- foreach ($default_config as $key)
- {
- if (isset($config[$key]))
- {
- $param = '_'.$key;
-
- $this->{$param} = $config[$key];
- }
- }
-
- if (isset($config['backup']))
- {
- if (in_array('cache_'.$config['backup'], $this->valid_drivers))
- {
- $this->_backup_driver = $config['backup'];
- }
- }
- }
-
- // ------------------------------------------------------------------------
-
- /**
* Is the requested driver supported in this environment?
*
- * @param string The driver to test.
- * @return array
+ * @param string The driver to test.
+ * @return array
*/
public function is_supported($driver)
{
@@ -202,8 +189,8 @@ class CI_Cache extends CI_Driver_Library {
/**
* __get()
*
- * @param child
- * @return object
+ * @param child
+ * @return object
*/
public function __get($child)
{
@@ -217,9 +204,7 @@ class CI_Cache extends CI_Driver_Library {
return $obj;
}
- // ------------------------------------------------------------------------
}
-// End Class
/* End of file Cache.php */
-/* Location: ./system/libraries/Cache/Cache.php */
+/* Location: ./system/libraries/Cache/Cache.php */ \ No newline at end of file
diff --git a/system/libraries/Cache/drivers/Cache_apc.php b/system/libraries/Cache/drivers/Cache_apc.php
index c387a30fc..59ab67533 100644
--- a/system/libraries/Cache/drivers/Cache_apc.php
+++ b/system/libraries/Cache/drivers/Cache_apc.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter APC Caching Class
*
@@ -36,23 +34,22 @@
* @author EllisLab Dev Team
* @link
*/
-
class CI_Cache_apc extends CI_Driver {
/**
* Get
*
- * Look for a value in the cache. If it exists, return the data
+ * Look for a value in the cache. If it exists, return the data
* if not, return FALSE
*
- * @param string
- * @return mixed value that is stored/FALSE on failure
+ * @param string
+ * @return mixed value that is stored/FALSE on failure
*/
public function get($id)
{
$data = apc_fetch($id);
- return (is_array($data)) ? $data[0] : FALSE;
+ return is_array($data) ? $data[0] : FALSE;
}
// ------------------------------------------------------------------------
@@ -60,11 +57,11 @@ class CI_Cache_apc extends CI_Driver {
/**
* Cache Save
*
- * @param string Unique Key
- * @param mixed Data to store
- * @param int Length of time (in seconds) to cache the data
+ * @param string Unique Key
+ * @param mixed Data to store
+ * @param int Length of time (in seconds) to cache the data
*
- * @return boolean true on success/false on failure
+ * @return bool true on success/false on failure
*/
public function save($id, $data, $ttl = 60)
{
@@ -77,8 +74,8 @@ class CI_Cache_apc extends CI_Driver {
/**
* Delete from Cache
*
- * @param mixed unique identifier of the item in the cache
- * @param boolean true on success/false on failure
+ * @param mixed unique identifier of the item in the cache
+ * @param bool true on success/false on failure
*/
public function delete($id)
{
@@ -90,7 +87,7 @@ class CI_Cache_apc extends CI_Driver {
/**
* Clean the cache
*
- * @return boolean false on failure/true on success
+ * @return bool false on failure/true on success
*/
public function clean()
{
@@ -102,8 +99,8 @@ class CI_Cache_apc extends CI_Driver {
/**
* Cache Info
*
- * @param string user/filehits
- * @return mixed array on success, false on failure
+ * @param string user/filehits
+ * @return mixed array on success, false on failure
*/
public function cache_info($type = NULL)
{
@@ -115,8 +112,8 @@ class CI_Cache_apc extends CI_Driver {
/**
* Get Cache Metadata
*
- * @param mixed key to get cache metadata on
- * @return mixed array on success/false on failure
+ * @param mixed key to get cache metadata on
+ * @return mixed array on success/false on failure
*/
public function get_metadata($id)
{
@@ -142,10 +139,12 @@ class CI_Cache_apc extends CI_Driver {
* is_supported()
*
* Check to see if APC is available on this system, bail if it isn't.
+ *
+ * @return bool
*/
public function is_supported()
{
- if ( ! extension_loaded('apc') OR ini_get('apc.enabled') != "1")
+ if ( ! extension_loaded('apc') OR ! (bool) @ini_get('apc.enabled'))
{
log_message('error', 'The APC PHP extension must be loaded to use APC Cache.');
return FALSE;
@@ -154,11 +153,7 @@ class CI_Cache_apc extends CI_Driver {
return TRUE;
}
- // ------------------------------------------------------------------------
-
-
}
-// End Class
/* End of file Cache_apc.php */
-/* Location: ./system/libraries/Cache/drivers/Cache_apc.php */
+/* Location: ./system/libraries/Cache/drivers/Cache_apc.php */ \ No newline at end of file
diff --git a/system/libraries/Cache/drivers/Cache_dummy.php b/system/libraries/Cache/drivers/Cache_dummy.php
index c9767e401..e8b791c5b 100644
--- a/system/libraries/Cache/drivers/Cache_dummy.php
+++ b/system/libraries/Cache/drivers/Cache_dummy.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Dummy Caching Class
*
@@ -36,7 +34,6 @@
* @author EllisLab Dev Team
* @link
*/
-
class CI_Cache_dummy extends CI_Driver {
/**
@@ -44,8 +41,8 @@ class CI_Cache_dummy extends CI_Driver {
*
* Since this is the dummy class, it's always going to return FALSE.
*
- * @param string
- * @return Boolean FALSE
+ * @param string
+ * @return bool FALSE
*/
public function get($id)
{
@@ -57,11 +54,10 @@ class CI_Cache_dummy extends CI_Driver {
/**
* Cache Save
*
- * @param string Unique Key
- * @param mixed Data to store
- * @param int Length of time (in seconds) to cache the data
- *
- * @return boolean TRUE, Simulating success
+ * @param string Unique Key
+ * @param mixed Data to store
+ * @param int Length of time (in seconds) to cache the data
+ * @return bool TRUE, Simulating success
*/
public function save($id, $data, $ttl = 60)
{
@@ -73,8 +69,8 @@ class CI_Cache_dummy extends CI_Driver {
/**
* Delete from Cache
*
- * @param mixed unique identifier of the item in the cache
- * @param boolean TRUE, simulating success
+ * @param mixed unique identifier of the item in the cache
+ * @param bool TRUE, simulating success
*/
public function delete($id)
{
@@ -86,7 +82,7 @@ class CI_Cache_dummy extends CI_Driver {
/**
* Clean the cache
*
- * @return boolean TRUE, simulating success
+ * @return bool TRUE, simulating success
*/
public function clean()
{
@@ -98,8 +94,8 @@ class CI_Cache_dummy extends CI_Driver {
/**
* Cache Info
*
- * @param string user/filehits
- * @return boolean FALSE
+ * @param string user/filehits
+ * @return bool FALSE
*/
public function cache_info($type = NULL)
{
@@ -111,8 +107,8 @@ class CI_Cache_dummy extends CI_Driver {
/**
* Get Cache Metadata
*
- * @param mixed key to get cache metadata on
- * @return boolean FALSE
+ * @param mixed key to get cache metadata on
+ * @return bool FALSE
*/
public function get_metadata($id)
{
@@ -125,17 +121,14 @@ class CI_Cache_dummy extends CI_Driver {
* Is this caching driver supported on the system?
* Of course this one is.
*
- * @return TRUE;
+ * @return bool TRUE
*/
public function is_supported()
{
return TRUE;
}
- // ------------------------------------------------------------------------
-
}
-// End Class
/* End of file Cache_dummy.php */
-/* Location: ./system/libraries/Cache/drivers/Cache_dummy.php */
+/* Location: ./system/libraries/Cache/drivers/Cache_dummy.php */ \ No newline at end of file
diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php
index c0be0def4..dd27aa90e 100644
--- a/system/libraries/Cache/drivers/Cache_file.php
+++ b/system/libraries/Cache/drivers/Cache_file.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Memcached Caching Class
*
@@ -36,14 +34,10 @@
* @author EllisLab Dev Team
* @link
*/
-
class CI_Cache_file extends CI_Driver {
protected $_cache_path;
- /**
- * Constructor
- */
public function __construct()
{
$CI =& get_instance();
@@ -57,8 +51,8 @@ class CI_Cache_file extends CI_Driver {
/**
* Fetch from cache
*
- * @param mixed unique key id
- * @return mixed data on success/false on failure
+ * @param mixed unique key id
+ * @return mixed data on success/false on failure
*/
public function get($id)
{
@@ -83,11 +77,11 @@ class CI_Cache_file extends CI_Driver {
/**
* Save into cache
*
- * @param string unique key
- * @param mixed data to store
- * @param int length of time (in seconds) the cache is valid
- * - Default is 60 seconds
- * @return boolean true on success/false on failure
+ * @param string unique key
+ * @param mixed data to store
+ * @param int length of time (in seconds) the cache is valid
+ * - Default is 60 seconds
+ * @return bool true on success/false on failure
*/
public function save($id, $data, $ttl = 60)
{
@@ -111,12 +105,12 @@ class CI_Cache_file extends CI_Driver {
/**
* Delete from Cache
*
- * @param mixed unique identifier of item in cache
- * @return boolean true on success/false on failure
+ * @param mixed unique identifier of item in cache
+ * @return bool true on success/false on failure
*/
public function delete($id)
{
- return (file_exists($this->_cache_path.$id)) ? unlink($this->_cache_path.$id) : FALSE;
+ return file_exists($this->_cache_path.$id) ? unlink($this->_cache_path.$id) : FALSE;
}
// ------------------------------------------------------------------------
@@ -124,7 +118,7 @@ class CI_Cache_file extends CI_Driver {
/**
* Clean the Cache
*
- * @return boolean false on failure/true on success
+ * @return bool false on failure/true on success
*/
public function clean()
{
@@ -138,8 +132,8 @@ class CI_Cache_file extends CI_Driver {
*
* Not supported by file-based caching
*
- * @param string user/filehits
- * @return mixed FALSE
+ * @param string user/filehits
+ * @return mixed FALSE
*/
public function cache_info($type = NULL)
{
@@ -151,8 +145,8 @@ class CI_Cache_file extends CI_Driver {
/**
* Get Cache Metadata
*
- * @param mixed key to get cache metadata on
- * @return mixed FALSE on failure, array on success.
+ * @param mixed key to get cache metadata on
+ * @return mixed FALSE on failure, array on success.
*/
public function get_metadata($id)
{
@@ -188,16 +182,14 @@ class CI_Cache_file extends CI_Driver {
*
* In the file driver, check to see that the cache directory is indeed writable
*
- * @return boolean
+ * @return bool
*/
public function is_supported()
{
return is_really_writable($this->_cache_path);
}
- // ------------------------------------------------------------------------
}
-// End Class
/* End of file Cache_file.php */
-/* Location: ./system/libraries/Cache/drivers/Cache_file.php */
+/* Location: ./system/libraries/Cache/drivers/Cache_file.php */ \ No newline at end of file
diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php
index b8f2d7e4c..1028c8fd5 100644
--- a/system/libraries/Cache/drivers/Cache_memcached.php
+++ b/system/libraries/Cache/drivers/Cache_memcached.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Memcached Caching Class
*
@@ -36,12 +34,11 @@
* @author EllisLab Dev Team
* @link
*/
-
class CI_Cache_memcached extends CI_Driver {
- private $_memcached; // Holds the memcached object
+ protected $_memcached; // Holds the memcached object
- protected $_memcache_conf = array(
+ protected $_memcache_conf = array(
'default' => array(
'default_host' => '127.0.0.1',
'default_port' => 11211,
@@ -49,19 +46,17 @@ class CI_Cache_memcached extends CI_Driver {
)
);
- // ------------------------------------------------------------------------
-
/**
* Fetch from cache
*
- * @param mixed unique key id
- * @return mixed data on success/false on failure
+ * @param mixed unique key id
+ * @return mixed data on success/false on failure
*/
public function get($id)
{
$data = $this->_memcached->get($id);
- return (is_array($data)) ? $data[0] : FALSE;
+ return is_array($data) ? $data[0] : FALSE;
}
// ------------------------------------------------------------------------
@@ -69,18 +64,18 @@ class CI_Cache_memcached extends CI_Driver {
/**
* Save
*
- * @param string unique identifier
- * @param mixed data being cached
- * @param int time to live
- * @return boolean true on success, false on failure
+ * @param string unique identifier
+ * @param mixed data being cached
+ * @param int time to live
+ * @return bool true on success, false on failure
*/
public function save($id, $data, $ttl = 60)
{
- if (get_class($this->_memcached) == 'Memcached')
+ if (get_class($this->_memcached) === 'Memcached')
{
return $this->_memcached->set($id, array($data, time(), $ttl), $ttl);
}
- else if (get_class($this->_memcached) == 'Memcache')
+ elseif (get_class($this->_memcached) === 'Memcache')
{
return $this->_memcached->set($id, array($data, time(), $ttl), 0, $ttl);
}
@@ -93,8 +88,8 @@ class CI_Cache_memcached extends CI_Driver {
/**
* Delete from Cache
*
- * @param mixed key to be deleted.
- * @return boolean true on success, false on failure
+ * @param mixed key to be deleted.
+ * @return bool true on success, false on failure
*/
public function delete($id)
{
@@ -106,7 +101,7 @@ class CI_Cache_memcached extends CI_Driver {
/**
* Clean the Cache
*
- * @return boolean false on failure/true on success
+ * @return bool false on failure/true on success
*/
public function clean()
{
@@ -118,10 +113,9 @@ class CI_Cache_memcached extends CI_Driver {
/**
* Cache Info
*
- * @param null type not supported in memcached
- * @return mixed array on success, false on failure
+ * @return mixed array on success, false on failure
*/
- public function cache_info($type = NULL)
+ public function cache_info()
{
return $this->_memcached->getStats();
}
@@ -131,8 +125,8 @@ class CI_Cache_memcached extends CI_Driver {
/**
* Get Cache Metadata
*
- * @param mixed key to get cache metadata on
- * @return mixed FALSE on failure, array on success.
+ * @param mixed key to get cache metadata on
+ * @return mixed FALSE on failure, array on success.
*/
public function get_metadata($id)
{
@@ -156,8 +150,10 @@ class CI_Cache_memcached extends CI_Driver {
/**
* Setup memcached.
+ *
+ * @return bool
*/
- private function _setup_memcached()
+ protected function _setup_memcached()
{
// Try to load memcached server info from the config file.
$CI =& get_instance();
@@ -179,14 +175,13 @@ class CI_Cache_memcached extends CI_Driver {
{
$this->_memcached = new Memcached();
}
- else if (class_exists('Memcache'))
+ elseif (class_exists('Memcache'))
{
$this->_memcached = new Memcache();
}
else
{
log_message('error', 'Failed to create object for Memcached Cache; extension not loaded?');
-
return FALSE;
}
@@ -237,23 +232,21 @@ class CI_Cache_memcached extends CI_Driver {
*
* Returns FALSE if memcached is not supported on the system.
* If it is, we setup the memcached object & return TRUE
+ *
+ * @return bool
*/
public function is_supported()
{
if ( ! extension_loaded('memcached') && ! extension_loaded('memcache'))
{
log_message('error', 'The Memcached Extension must be loaded to use Memcached Cache.');
-
return FALSE;
}
return $this->_setup_memcached();
}
- // ------------------------------------------------------------------------
-
}
-// End Class
/* End of file Cache_memcached.php */
-/* Location: ./system/libraries/Cache/drivers/Cache_memcached.php */
+/* Location: ./system/libraries/Cache/drivers/Cache_memcached.php */ \ No newline at end of file
diff --git a/system/libraries/Cache/drivers/Cache_wincache.php b/system/libraries/Cache/drivers/Cache_wincache.php
index df619d4e6..b32e66a46 100644
--- a/system/libraries/Cache/drivers/Cache_wincache.php
+++ b/system/libraries/Cache/drivers/Cache_wincache.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Wincache Caching Class
*
@@ -39,7 +37,6 @@
* @author Mike Murkovic
* @link
*/
-
class CI_Cache_wincache extends CI_Driver {
/**
@@ -68,7 +65,7 @@ class CI_Cache_wincache extends CI_Driver {
* @param string Unique Key
* @param mixed Data to store
* @param int Length of time (in seconds) to cache the data
- * @return bool true on success/false on failure
+ * @return bool true on success/false on failure
*/
public function save($id, $data, $ttl = 60)
{
@@ -162,4 +159,4 @@ class CI_Cache_wincache extends CI_Driver {
}
/* End of file Cache_wincache.php */
-/* Location: ./system/libraries/Cache/drivers/Cache_wincache.php */
+/* Location: ./system/libraries/Cache/drivers/Cache_wincache.php */ \ No newline at end of file
diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php
index 6c04de8a2..b6f145d95 100644
--- a/system/libraries/Calendar.php
+++ b/system/libraries/Calendar.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Calendar Class
*
@@ -40,7 +38,7 @@
*/
class CI_Calendar {
- private $CI;
+ protected $CI;
public $lang;
public $local_time;
public $template = '';
@@ -54,6 +52,9 @@ class CI_Calendar {
* Constructor
*
* Loads the calendar language file and sets the default time reference
+ *
+ * @param array
+ * @return void
*/
public function __construct($config = array())
{
@@ -71,7 +72,7 @@ class CI_Calendar {
$this->initialize($config);
}
- log_message('debug', "Calendar Class Initialized");
+ log_message('debug', 'Calendar Class Initialized');
}
// --------------------------------------------------------------------
@@ -81,7 +82,6 @@ class CI_Calendar {
*
* Accepts an associative array as input, containing display preferences
*
- * @access public
* @param array config preferences
* @return void
*/
@@ -101,9 +101,8 @@ class CI_Calendar {
/**
* Generate the calendar
*
- * @access public
- * @param integer the year
- * @param integer the month
+ * @param int the year
+ * @param int the month
* @param array the data to be shown in the calendar cells
* @return string
*/
@@ -147,7 +146,7 @@ class CI_Calendar {
// Set the starting day number
$local_date = mktime(12, 0, 0, $month, 1, $year);
$date = getdate($local_date);
- $day = $start_day + 1 - $date["wday"];
+ $day = $start_day + 1 - $date['wday'];
while ($day > 1)
{
@@ -160,7 +159,7 @@ class CI_Calendar {
$cur_month = date('m', $this->local_time);
$cur_day = date('j', $this->local_time);
- $is_current_month = ($cur_year == $year AND $cur_month == $month) ? TRUE : FALSE;
+ $is_current_month = ($cur_year == $year && $cur_month == $month);
// Generate the template data array
$this->parse_template();
@@ -172,7 +171,7 @@ class CI_Calendar {
if ($this->show_next_prev == TRUE)
{
// Add a trailing slash to the URL if needed
- $this->next_prev_url = preg_replace("/(.+?)\/*$/", "\\1/", $this->next_prev_url);
+ $this->next_prev_url = preg_replace('/(.+?)\/*$/', '\\1/', $this->next_prev_url);
$adjusted_date = $this->adjust_date($month - 1, $year);
$out .= str_replace('{previous_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_previous_cell'])."\n";
@@ -213,21 +212,21 @@ class CI_Calendar {
for ($i = 0; $i < 7; $i++)
{
- $out .= ($is_current_month === TRUE AND $day == $cur_day) ? $this->temp['cal_cell_start_today'] : $this->temp['cal_cell_start'];
+ $out .= ($is_current_month === TRUE && $day == $cur_day) ? $this->temp['cal_cell_start_today'] : $this->temp['cal_cell_start'];
- if ($day > 0 AND $day <= $total_days)
+ if ($day > 0 && $day <= $total_days)
{
if (isset($data[$day]))
{
// Cells with content
- $temp = ($is_current_month === TRUE AND $day == $cur_day) ?
+ $temp = ($is_current_month === TRUE && $day == $cur_day) ?
$this->temp['cal_cell_content_today'] : $this->temp['cal_cell_content'];
$out .= str_replace(array('{content}', '{day}'), array($data[$day], $day), $temp);
}
else
{
// Cells with no content
- $temp = ($is_current_month === TRUE AND $day == $cur_day) ?
+ $temp = ($is_current_month === TRUE && $day == $cur_day) ?
$this->temp['cal_cell_no_content_today'] : $this->temp['cal_cell_no_content'];
$out .= str_replace('{day}', $day, $temp);
}
@@ -238,7 +237,7 @@ class CI_Calendar {
$out .= $this->temp['cal_cell_blank'];
}
- $out .= ($is_current_month === TRUE AND $day == $cur_day) ? $this->temp['cal_cell_end_today'] : $this->temp['cal_cell_end'];
+ $out .= ($is_current_month === TRUE && $day == $cur_day) ? $this->temp['cal_cell_end_today'] : $this->temp['cal_cell_end'];
$day++;
}
@@ -258,8 +257,7 @@ class CI_Calendar {
* Generates a textual month name based on the numeric
* month provided.
*
- * @access public
- * @param integer the month
+ * @param int the month
* @return string
*/
public function get_month_name($month)
@@ -289,9 +287,8 @@ class CI_Calendar {
* Get Day Names
*
* Returns an array of day names (Sunday, Monday, etc.) based
- * on the type. Options: long, short, abrev
+ * on the type. Options: long, short, abrev
*
- * @access public
* @param string
* @return array
*/
@@ -333,9 +330,8 @@ class CI_Calendar {
* For example, if you submit 13 as the month, the year will
* increment and the month will become January.
*
- * @access public
- * @param integer the month
- * @param integer the year
+ * @param int the month
+ * @param int the year
* @return array
*/
public function adjust_date($month, $year)
@@ -370,10 +366,9 @@ class CI_Calendar {
/**
* Total days in a given month
*
- * @access public
- * @param integer the month
- * @param integer the year
- * @return integer
+ * @param int the month
+ * @param int the year
+ * @return int
*/
public function get_total_days($month, $year)
{
@@ -387,7 +382,7 @@ class CI_Calendar {
// Is the year a leap year?
if ($month == 2)
{
- if ($year % 400 == 0 OR ($year % 4 == 0 AND $year % 100 != 0))
+ if ($year % 400 == 0 OR ($year % 4 == 0 && $year % 100 != 0))
{
return 29;
}
@@ -403,8 +398,7 @@ class CI_Calendar {
*
* This is used in the event that the user has not created their own template
*
- * @access public
- * @return array
+ * @return array
*/
public function default_template()
{
@@ -441,7 +435,6 @@ class CI_Calendar {
* Harvests the data within the template {pseudo-variables}
* used to display the calendar
*
- * @access public
* @return void
*/
public function parse_template()
@@ -457,7 +450,7 @@ class CI_Calendar {
foreach (array('table_open', 'table_close', 'heading_row_start', 'heading_previous_cell', 'heading_title_cell', 'heading_next_cell', 'heading_row_end', 'week_row_start', 'week_day_cell', 'week_row_end', 'cal_row_start', 'cal_cell_start', 'cal_cell_content', 'cal_cell_no_content', 'cal_cell_blank', 'cal_cell_end', 'cal_row_end', 'cal_cell_start_today', 'cal_cell_content_today', 'cal_cell_no_content_today', 'cal_cell_end_today') as $val)
{
- if (preg_match("/\{".$val."\}(.*?)\{\/".$val."\}/si", $this->template, $match))
+ if (preg_match('/\{'.$val.'\}(.*?)\{\/'.$val.'\}/si', $this->template, $match))
{
$this->temp[$val] = $match[1];
}
@@ -470,7 +463,5 @@ class CI_Calendar {
}
-// END CI_Calendar class
-
/* End of file Calendar.php */
-/* Location: ./system/libraries/Calendar.php */
+/* Location: ./system/libraries/Calendar.php */ \ No newline at end of file
diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php
index 60a1e52fe..ca7be555e 100644
--- a/system/libraries/Cart.php
+++ b/system/libraries/Cart.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* Shopping Cart Class
*
@@ -41,12 +39,11 @@ class CI_Cart {
// These are the regular expression rules that we use to validate the product ID and product name
public $product_id_rules = '\.a-z0-9_-'; // alpha-numeric, dashes, underscores, or periods
public $product_name_rules = '\.\:\-_ a-z0-9'; // alpha-numeric, dashes, underscores, colons or periods
- public $product_name_safe = true; // only allow safe product names
-
- // Private variables. Do not change!
- private $CI;
- private $_cart_contents = array();
+ public $product_name_safe = TRUE; // only allow safe product names
+ // Protected variables. Do not change!
+ protected $CI;
+ protected $_cart_contents = array();
/**
* Shopping Class Constructor
@@ -72,7 +69,7 @@ class CI_Cart {
$this->_cart_contents = array('cart_total' => 0, 'total_items' => 0);
}
- log_message('debug', "Cart Class Initialized");
+ log_message('debug', 'Cart Class Initialized');
}
// --------------------------------------------------------------------
@@ -80,7 +77,6 @@ class CI_Cart {
/**
* Insert items into the cart and save it to the session table
*
- * @access public
* @param array
* @return bool
*/
@@ -110,7 +106,7 @@ class CI_Cart {
{
foreach ($items as $val)
{
- if (is_array($val) AND isset($val['id']))
+ if (is_array($val) && isset($val['id']))
{
if ($this->_insert($val))
{
@@ -135,11 +131,10 @@ class CI_Cart {
/**
* Insert
*
- * @access private
* @param array
* @return bool
*/
- private function _insert($items = array())
+ protected function _insert($items = array())
{
// Was any cart data passed? No? Bah...
if ( ! is_array($items) OR count($items) === 0)
@@ -213,7 +208,7 @@ class CI_Cart {
// Internally, we need to treat identical submissions, but with different options, as a unique product.
// Our solution is to convert the options array to a string and MD5 it along with the product ID.
// This becomes the unique "row ID"
- if (isset($items['options']) AND count($items['options']) > 0)
+ if (isset($items['options']) && count($items['options']) > 0)
{
$rowid = md5($items['id'].implode('', $items['options']));
}
@@ -249,7 +244,6 @@ class CI_Cart {
* changes to the quantity before checkout. That array must contain the
* product ID and quantity for each item.
*
- * @access public
* @param array
* @param string
* @return bool
@@ -308,11 +302,10 @@ class CI_Cart {
* changes to the quantity before checkout. That array must contain the
* product ID and quantity for each item.
*
- * @access private
* @param array
* @return bool
*/
- private function _update($items = array())
+ protected function _update($items = array())
{
// Without these array indexes there is nothing we can do
if ( ! isset($items['qty']) OR ! isset($items['rowid']) OR ! isset($this->_cart_contents[$items['rowid']]))
@@ -348,10 +341,9 @@ class CI_Cart {
/**
* Save the cart array to the session DB
*
- * @access private
* @return bool
*/
- private function _save_cart()
+ protected function _save_cart()
{
// Lets add up the individual prices and set the cart sub-total
$this->_cart_contents['total_items'] = $this->_cart_contents['cart_total'] = 0;
@@ -390,8 +382,7 @@ class CI_Cart {
/**
* Cart Total
*
- * @access public
- * @return integer
+ * @return int
*/
public function total()
{
@@ -405,8 +396,7 @@ class CI_Cart {
*
* Removes an item from the cart
*
- * @access public
- * @return boolean
+ * @return bool
*/
public function remove($rowid)
{
@@ -423,8 +413,7 @@ class CI_Cart {
*
* Returns the total item count
*
- * @access public
- * @return integer
+ * @return int
*/
public function total_items()
{
@@ -438,7 +427,6 @@ class CI_Cart {
*
* Returns the entire cart array
*
- * @access public
* @return array
*/
public function contents($newest_first = FALSE)
@@ -461,7 +449,6 @@ class CI_Cart {
* Returns TRUE if the rowid passed to this function correlates to an item
* that has options associated with it.
*
- * @access public
* @return bool
*/
public function has_options($rowid = '')
@@ -476,7 +463,7 @@ class CI_Cart {
*
* Returns the an array of options, for a particular product row ID
*
- * @access public
+ * @param int
* @return array
*/
public function product_options($rowid = '')
@@ -491,7 +478,7 @@ class CI_Cart {
*
* Returns the supplied number with commas and a decimal point.
*
- * @access public
+ * @param float
* @return string
*/
public function format_number($n = '')
@@ -514,7 +501,6 @@ class CI_Cart {
*
* Empties the cart and kills the session
*
- * @access public
* @return void
*/
public function destroy()
@@ -523,9 +509,7 @@ class CI_Cart {
$this->CI->session->unset_userdata('cart_contents');
}
-
}
-// END Cart Class
/* End of file Cart.php */
-/* Location: ./system/libraries/Cart.php */
+/* Location: ./system/libraries/Cart.php */ \ No newline at end of file
diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php
index 9a073b336..f409f47d4 100644
--- a/system/libraries/Driver.php
+++ b/system/libraries/Driver.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Driver Library Class
*
@@ -84,8 +82,8 @@ class CI_Driver_Library {
// it's a valid driver, but the file simply can't be found
if ( ! class_exists($child_class))
{
- log_message('error', "Unable to load the requested driver: ".$child_class);
- show_error("Unable to load the requested driver: ".$child_class);
+ log_message('error', 'Unable to load the requested driver: '.$child_class);
+ show_error('Unable to load the requested driver: '.$child_class);
}
}
@@ -96,15 +94,11 @@ class CI_Driver_Library {
}
// The requested driver isn't valid!
- log_message('error', "Invalid driver requested: ".$child_class);
- show_error("Invalid driver requested: ".$child_class);
+ log_message('error', 'Invalid driver requested: '.$child_class);
+ show_error('Invalid driver requested: '.$child_class);
}
- // --------------------------------------------------------------------
-
}
-// END CI_Driver_Library CLASS
-
/**
* CodeIgniter Driver Class
@@ -120,12 +114,12 @@ class CI_Driver_Library {
*/
class CI_Driver {
- protected $parent;
+ protected $_parent;
- private $methods = array();
- private $properties = array();
+ protected $_methods = array();
+ protected $_properties = array();
- private static $reflections = array();
+ protected static $_reflections = array();
/**
* Decorate
@@ -137,14 +131,14 @@ class CI_Driver {
*/
public function decorate($parent)
{
- $this->parent = $parent;
+ $this->_parent = $parent;
// Lock down attributes to what is defined in the class
// and speed up references in magic methods
$class_name = get_class($parent);
- if ( ! isset(self::$reflections[$class_name]))
+ if ( ! isset(self::$_reflections[$class_name]))
{
$r = new ReflectionObject($parent);
@@ -152,7 +146,7 @@ class CI_Driver {
{
if ($method->isPublic())
{
- $this->methods[] = $method->getName();
+ $this->_methods[] = $method->getName();
}
}
@@ -160,15 +154,15 @@ class CI_Driver {
{
if ($prop->isPublic())
{
- $this->properties[] = $prop->getName();
+ $this->_properties[] = $prop->getName();
}
}
- self::$reflections[$class_name] = array($this->methods, $this->properties);
+ self::$_reflections[$class_name] = array($this->_methods, $this->_properties);
}
else
{
- list($this->methods, $this->properties) = self::$reflections[$class_name];
+ list($this->_methods, $this->_properties) = self::$_reflections[$class_name];
}
}
@@ -179,16 +173,15 @@ class CI_Driver {
*
* Handles access to the parent driver library's methods
*
- * @access public
* @param string
* @param array
* @return mixed
*/
public function __call($method, $args = array())
{
- if (in_array($method, $this->methods))
+ if (in_array($method, $this->_methods))
{
- return call_user_func_array(array($this->parent, $method), $args);
+ return call_user_func_array(array($this->_parent, $method), $args);
}
$trace = debug_backtrace();
@@ -208,9 +201,9 @@ class CI_Driver {
*/
public function __get($var)
{
- if (in_array($var, $this->properties))
+ if (in_array($var, $this->_properties))
{
- return $this->parent->$var;
+ return $this->_parent->$var;
}
}
@@ -227,16 +220,13 @@ class CI_Driver {
*/
public function __set($var, $val)
{
- if (in_array($var, $this->properties))
+ if (in_array($var, $this->_properties))
{
- $this->parent->$var = $val;
+ $this->_parent->$var = $val;
}
}
- // --------------------------------------------------------------------
-
}
-// END CI_Driver CLASS
/* End of file Driver.php */
-/* Location: ./system/libraries/Driver.php */
+/* Location: ./system/libraries/Driver.php */ \ No newline at end of file
diff --git a/system/libraries/Ftp.php b/system/libraries/Ftp.php
index 4d96c00cc..8aa1650d2 100644
--- a/system/libraries/Ftp.php
+++ b/system/libraries/Ftp.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* FTP Class
*
@@ -42,16 +40,11 @@ class CI_FTP {
public $username = '';
public $password = '';
public $port = 21;
- public $passive = TRUE;
+ public $passive = TRUE;
public $debug = FALSE;
- public $conn_id = FALSE;
+ public $conn_id = FALSE;
- /**
- * Constructor - Sets Preferences
- *
- * The constructor can be passed an array of config values
- */
public function __construct($config = array())
{
if (count($config) > 0)
@@ -59,7 +52,7 @@ class CI_FTP {
$this->initialize($config);
}
- log_message('debug', "FTP Class Initialized");
+ log_message('debug', 'FTP Class Initialized');
}
// --------------------------------------------------------------------
@@ -67,7 +60,6 @@ class CI_FTP {
/**
* Initialize preferences
*
- * @access public
* @param array
* @return void
*/
@@ -90,7 +82,6 @@ class CI_FTP {
/**
* FTP Connect
*
- * @access public
* @param array the connection values
* @return bool
*/
@@ -133,10 +124,9 @@ class CI_FTP {
/**
* FTP Login
*
- * @access private
* @return bool
*/
- private function _login()
+ protected function _login()
{
return @ftp_login($this->conn_id, $this->username, $this->password);
}
@@ -146,10 +136,9 @@ class CI_FTP {
/**
* Validates the connection ID
*
- * @access private
* @return bool
*/
- private function _is_conn()
+ protected function _is_conn()
{
if ( ! is_resource($this->conn_id))
{
@@ -164,17 +153,15 @@ class CI_FTP {
// --------------------------------------------------------------------
-
/**
* Change directory
*
* The second parameter lets us momentarily turn off debugging so that
* this function can be used to test for the existence of a folder
- * without throwing an error. There's no FTP equivalent to is_dir()
+ * without throwing an error. There's no FTP equivalent to is_dir()
* so we do it by trying to change to a particular directory.
* Internally, this parameter is only used by the "mirror" function below.
*
- * @access public
* @param string
* @param bool
* @return bool
@@ -190,7 +177,7 @@ class CI_FTP {
if ($result === FALSE)
{
- if ($this->debug == TRUE AND $supress_debug == FALSE)
+ if ($this->debug == TRUE && $supress_debug == FALSE)
{
$this->_error('ftp_unable_to_changedir');
}
@@ -205,8 +192,8 @@ class CI_FTP {
/**
* Create a directory
*
- * @access public
* @param string
+ * @param int
* @return bool
*/
public function mkdir($path = '', $permissions = NULL)
@@ -230,7 +217,7 @@ class CI_FTP {
// Set file permissions if needed
if ( ! is_null($permissions))
{
- $this->chmod($path, (int)$permissions);
+ $this->chmod($path, (int) $permissions);
}
return TRUE;
@@ -241,10 +228,10 @@ class CI_FTP {
/**
* Upload a file to the server
*
- * @access public
* @param string
* @param string
* @param string
+ * @param int
* @return bool
*/
public function upload($locpath, $rempath, $mode = 'auto', $permissions = NULL)
@@ -284,7 +271,7 @@ class CI_FTP {
// Set file permissions if needed
if ( ! is_null($permissions))
{
- $this->chmod($rempath, (int)$permissions);
+ $this->chmod($rempath, (int) $permissions);
}
return TRUE;
@@ -295,7 +282,6 @@ class CI_FTP {
/**
* Download a file from a remote server to the local server
*
- * @access public
* @param string
* @param string
* @param string
@@ -337,7 +323,6 @@ class CI_FTP {
/**
* Rename (or move) a file
*
- * @access public
* @param string
* @param string
* @param bool
@@ -369,7 +354,6 @@ class CI_FTP {
/**
* Move a file
*
- * @access public
* @param string
* @param string
* @return bool
@@ -384,7 +368,6 @@ class CI_FTP {
/**
* Rename (or move) a file
*
- * @access public
* @param string
* @return bool
*/
@@ -415,7 +398,6 @@ class CI_FTP {
* Delete a folder and recursively delete everything (including sub-folders)
* containted within it.
*
- * @access public
* @param string
* @return bool
*/
@@ -427,11 +409,11 @@ class CI_FTP {
}
// Add a trailing slash to the file path if needed
- $filepath = preg_replace("/(.+?)\/*$/", "\\1/", $filepath);
+ $filepath = preg_replace('/(.+?)\/*$/', '\\1/', $filepath);
$list = $this->list_files($filepath);
- if ($list !== FALSE AND count($list) > 0)
+ if ($list !== FALSE && count($list) > 0)
{
foreach ($list as $item)
{
@@ -463,7 +445,6 @@ class CI_FTP {
/**
* Set file permissions
*
- * @access public
* @param string the file path
* @param string the permissions
* @return bool
@@ -494,7 +475,6 @@ class CI_FTP {
/**
* FTP List files in the specified directory
*
- * @access public
* @return array
*/
public function list_files($path = '.')
@@ -512,11 +492,11 @@ class CI_FTP {
/**
* Read a directory and recreate it remotely
*
- * This function recursively reads a folder and everything it contains (including
- * sub-folders) and creates a mirror via FTP based on it. Whatever the directory structure
- * of the original file path will be recreated on the server.
+ * This function recursively reads a folder and everything it contains
+ * (including sub-folders) and creates a mirror via FTP based on it.
+ * Whatever the directory structure of the original file path will be
+ * recreated on the server.
*
- * @access public
* @param string path to source with trailing slash
* @param string path to destination - include the base folder with trailing slash
* @return bool
@@ -532,7 +512,7 @@ class CI_FTP {
if ($fp = @opendir($locpath))
{
// Attempt to open the remote file path and try to create it, if it doesn't exist
- if ( ! $this->changedir($rempath, TRUE) AND ( ! $this->mkdir($rempath) OR ! $this->changedir($rempath)))
+ if ( ! $this->changedir($rempath, TRUE) && ( ! $this->mkdir($rempath) OR ! $this->changedir($rempath)))
{
return FALSE;
}
@@ -542,9 +522,9 @@ class CI_FTP {
{
if (@is_dir($locpath.$file) && $file[0] !== '.')
{
- $this->mirror($locpath.$file."/", $rempath.$file."/");
+ $this->mirror($locpath.$file.'/', $rempath.$file.'/');
}
- elseif ($file[0] !== ".")
+ elseif ($file[0] !== '.')
{
// Get the file extension so we can se the upload type
$ext = $this->_getext($file);
@@ -565,11 +545,10 @@ class CI_FTP {
/**
* Extract the file extension
*
- * @access private
* @param string
* @return string
*/
- private function _getext($filename)
+ protected function _getext($filename)
{
if (FALSE === strpos($filename, '.'))
{
@@ -580,36 +559,34 @@ class CI_FTP {
return end($x);
}
-
// --------------------------------------------------------------------
/**
* Set the upload type
*
- * @access private
* @param string
* @return string
*/
- private function _settype($ext)
+ 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';
+ 'txt',
+ 'text',
+ 'php',
+ 'phps',
+ 'php4',
+ 'js',
+ 'css',
+ 'htm',
+ 'html',
+ 'phtml',
+ 'shtml',
+ 'log',
+ 'xml'
+ );
+
+
+ return in_array($ext, $text_types) ? 'ascii' : 'binary';
}
// ------------------------------------------------------------------------
@@ -617,7 +594,6 @@ class CI_FTP {
/**
* Close the connection
*
- * @access public
* @return bool
*/
public function close()
@@ -635,20 +611,17 @@ class CI_FTP {
/**
* Display error message
*
- * @access private
* @param string
* @return void
*/
- private function _error($line)
+ protected function _error($line)
{
$CI =& get_instance();
$CI->lang->load('ftp');
show_error($CI->lang->line($line));
}
-
}
-// END FTP Class
/* End of file Ftp.php */
-/* Location: ./system/libraries/Ftp.php */
+/* Location: ./system/libraries/Ftp.php */ \ No newline at end of file
diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php
index c045ac0e2..a18fcb9f1 100644
--- a/system/libraries/Migration.php
+++ b/system/libraries/Migration.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* Migration Class
*
@@ -71,7 +69,7 @@ class CI_Migration {
}
// If not set, set it
- $this->_migration_path == '' AND $this->_migration_path = APPPATH.'migrations/';
+ $this->_migration_path != '' OR $this->_migration_path = APPPATH.'migrations/';
// Add trailing slash if not set
$this->_migration_path = rtrim($this->_migration_path, '/').'/';
@@ -101,7 +99,7 @@ class CI_Migration {
}
// Do we auto migrate to the latest migration?
- if ($this->_migration_auto_latest === TRUE AND ! $this->latest())
+ if ($this->_migration_auto_latest === TRUE && ! $this->latest())
{
show_error($this->error_string());
}
@@ -115,8 +113,7 @@ class CI_Migration {
* Calls each migration step required to get to the schema version of
* choice
*
- * @access public
- * @param $version integer Target schema version
+ * @param int Target schema version
* @return mixed TRUE if already latest, FALSE if failed, int if upgraded
*/
public function version($target_version)
@@ -241,7 +238,6 @@ class CI_Migration {
/**
* Set's the schema to the latest migration
*
- * @access public
* @return mixed true if already latest, false if failed, int if upgraded
*/
public function latest()
@@ -264,7 +260,6 @@ class CI_Migration {
/**
* Set's the schema to the migration version set in config
*
- * @access public
* @return mixed true if already current, false if failed, int if upgraded
*/
public function current()
@@ -277,7 +272,6 @@ class CI_Migration {
/**
* Error string
*
- * @access public
* @return string Error message returned as a string
*/
public function error_string()
@@ -290,7 +284,6 @@ class CI_Migration {
/**
* Set's the schema to the latest migration
*
- * @access protected
* @return mixed true if already latest, false if failed, int if upgraded
*/
protected function find_migrations()
@@ -317,8 +310,7 @@ class CI_Migration {
/**
* Retrieves current schema version
*
- * @access protected
- * @return integer Current Migration
+ * @return int Current Migration
*/
protected function _get_version()
{
@@ -331,9 +323,8 @@ class CI_Migration {
/**
* Stores the current schema version
*
- * @access protected
- * @param $migrations integer Migration reached
- * @return void Outputs a report of the migration
+ * @param int Migration reached
+ * @return void Outputs a report of the migration
*/
protected function _update_version($migrations)
{
@@ -347,8 +338,7 @@ class CI_Migration {
/**
* Enable the use of CI super-global
*
- * @access public
- * @param $var
+ * @param $var
* @return mixed
*/
public function __get($var)
@@ -358,4 +348,4 @@ class CI_Migration {
}
/* End of file Migration.php */
-/* Location: ./system/libraries/Migration.php */
+/* Location: ./system/libraries/Migration.php */ \ No newline at end of file
diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
index 86b8d79fa..0fe73d69f 100644
--- a/system/libraries/Pagination.php
+++ b/system/libraries/Pagination.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* Pagination Class
*
@@ -74,13 +72,12 @@ class CI_Pagination {
/**
* Constructor
*
- * @access public
* @param array initialization parameters
*/
public function __construct($params = array())
{
$this->initialize($params);
- log_message('debug', "Pagination Class Initialized");
+ log_message('debug', 'Pagination Class Initialized');
}
// --------------------------------------------------------------------
@@ -88,7 +85,6 @@ class CI_Pagination {
/**
* Initialize Preferences
*
- * @access public
* @param array initialization parameters
* @return void
*/
@@ -116,7 +112,6 @@ class CI_Pagination {
/**
* Generate the pagination links
*
- * @access public
* @return string
*/
public function create_links()
@@ -155,13 +150,13 @@ class CI_Pagination {
$this->cur_page = (int) $CI->input->get($this->query_string_segment);
}
}
- elseif ( ! $this->cur_page AND $CI->uri->segment($this->uri_segment) != $base_page)
+ elseif ( ! $this->cur_page && $CI->uri->segment($this->uri_segment) != $base_page)
{
$this->cur_page = (int) $CI->uri->segment($this->uri_segment);
}
// Set current page to 1 if it's not valid or if using page numbers instead of offset
- if ( ! is_numeric($this->cur_page) OR ($this->use_page_numbers AND $this->cur_page == 0))
+ if ( ! is_numeric($this->cur_page) OR ($this->use_page_numbers && $this->cur_page == 0))
{
$this->cur_page = $base_page;
}
@@ -182,12 +177,9 @@ class CI_Pagination {
$this->cur_page = $num_pages;
}
}
- else
+ elseif ($this->cur_page > $this->total_rows)
{
- if ($this->cur_page > $this->total_rows)
- {
- $this->cur_page = ($num_pages - 1) * $this->per_page;
- }
+ $this->cur_page = ($num_pages - 1) * $this->per_page;
}
$uri_page_number = $this->cur_page;
@@ -199,10 +191,10 @@ class CI_Pagination {
// Calculate the start and end numbers. These determine
// which number to start and end the digit links with
- $start = (($this->cur_page - $this->num_links) > 0) ? $this->cur_page - ($this->num_links - 1) : 1;
- $end = (($this->cur_page + $this->num_links) < $num_pages) ? $this->cur_page + $this->num_links : $num_pages;
+ $start = (($this->cur_page - $this->num_links) > 0) ? $this->cur_page - ($this->num_links - 1) : 1;
+ $end = (($this->cur_page + $this->num_links) < $num_pages) ? $this->cur_page + $this->num_links : $num_pages;
- // Is pagination being used over GET or POST? If get, add a per_page query
+ // Is pagination being used over GET or POST? If get, add a per_page query
// string. If post, add a trailing slash to the base URL if needed
if ($CI->config->item('enable_query_strings') === TRUE OR $this->page_query_string === TRUE)
{
@@ -217,18 +209,18 @@ class CI_Pagination {
$output = '';
// Render the "First" link
- if ($this->first_link !== FALSE AND $this->cur_page > ($this->num_links + 1))
+ if ($this->first_link !== FALSE && $this->cur_page > ($this->num_links + 1))
{
$first_url = ($this->first_url == '') ? $this->base_url : $this->first_url;
$output .= $this->first_tag_open.'<a '.$this->anchor_class.'href="'.$first_url.'">'.$this->first_link.'</a>'.$this->first_tag_close;
}
// Render the "previous" link
- if ($this->prev_link !== FALSE AND $this->cur_page != 1)
+ if ($this->prev_link !== FALSE && $this->cur_page != 1)
{
$i = ($this->use_page_numbers) ? $uri_page_number - 1 : $uri_page_number - $this->per_page;
- if ($i == $base_page AND $this->first_url != '')
+ if ($i == $base_page && $this->first_url != '')
{
$output .= $this->prev_tag_open.'<a '.$this->anchor_class.'href="'.$this->first_url.'">'.$this->prev_link.'</a>'.$this->prev_tag_close;
}
@@ -274,7 +266,7 @@ class CI_Pagination {
}
// Render the "next" link
- if ($this->next_link !== FALSE AND $this->cur_page < $num_pages)
+ if ($this->next_link !== FALSE && $this->cur_page < $num_pages)
{
$i = ($this->use_page_numbers) ? $this->cur_page + 1 : $this->cur_page * $this->per_page;
@@ -282,7 +274,7 @@ class CI_Pagination {
}
// Render the "Last" link
- if ($this->last_link !== FALSE AND ($this->cur_page + $this->num_links) < $num_pages)
+ if ($this->last_link !== FALSE && ($this->cur_page + $this->num_links) < $num_pages)
{
$i = ($this->use_page_numbers) ? $num_pages : ($num_pages * $this->per_page) - $this->per_page;
@@ -291,15 +283,13 @@ class CI_Pagination {
// Kill double slashes. Note: Sometimes we can end up with a double slash
// in the penultimate link so we'll kill all double slashes.
- $output = preg_replace("#([^:])//+#", "\\1/", $output);
+ $output = preg_replace('#([^:])//+#', '\\1/', $output);
// Add the wrapper HTML if exists
- $output = $this->full_tag_open.$output.$this->full_tag_close;
-
- return $output;
+ return $this->full_tag_open.$output.$this->full_tag_close;
}
+
}
-// END Pagination Class
/* End of file Pagination.php */
-/* Location: ./system/libraries/Pagination.php */
+/* Location: ./system/libraries/Pagination.php */ \ No newline at end of file
diff --git a/system/libraries/Parser.php b/system/libraries/Parser.php
index 290e17fc0..d1b5b764b 100644
--- a/system/libraries/Parser.php
+++ b/system/libraries/Parser.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* Parser Class
*
@@ -41,15 +39,14 @@ class CI_Parser {
public $l_delim = '{';
public $r_delim = '}';
public $object;
- private $CI;
+ protected $CI;
/**
- * Parse a template
+ * Parse a template
*
* Parses pseudo-variables contained in the specified template view,
* replacing them with the data in the second param
*
- * @access public
* @param string
* @param array
* @param bool
@@ -66,12 +63,11 @@ class CI_Parser {
// --------------------------------------------------------------------
/**
- * Parse a String
+ * Parse a String
*
* Parses pseudo-variables contained in the specified string,
* replacing them with the data in the second param
*
- * @access public
* @param string
* @param array
* @param bool
@@ -85,18 +81,17 @@ class CI_Parser {
// --------------------------------------------------------------------
/**
- * Parse a template
+ * Parse a template
*
* Parses pseudo-variables contained in the specified template,
* replacing them with the data in the second param
*
- * @access private
* @param string
* @param array
* @param bool
* @return string
*/
- private function _parse($template, $data, $return = FALSE)
+ protected function _parse($template, $data, $return = FALSE)
{
if ($template == '')
{
@@ -126,9 +121,8 @@ class CI_Parser {
// --------------------------------------------------------------------
/**
- * Set the left/right variable delimiters
+ * Set the left/right variable delimiters
*
- * @access public
* @param string
* @param string
* @return void
@@ -142,15 +136,14 @@ class CI_Parser {
// --------------------------------------------------------------------
/**
- * Parse a single key/value
+ * Parse a single key/value
*
- * @access private
* @param string
* @param string
* @param string
* @return string
*/
- private function _parse_single($key, $val, $string)
+ protected function _parse_single($key, $val, $string)
{
return str_replace($this->l_delim.$key.$this->r_delim, (string) $val, $string);
}
@@ -158,17 +151,16 @@ class CI_Parser {
// --------------------------------------------------------------------
/**
- * Parse a tag pair
+ * Parse a tag pair
*
- * Parses tag pairs: {some_tag} string... {/some_tag}
+ * Parses tag pairs: {some_tag} string... {/some_tag}
*
- * @access private
* @param string
* @param array
* @param string
* @return string
*/
- private function _parse_pair($variable, $data, $string)
+ protected function _parse_pair($variable, $data, $string)
{
if (FALSE === ($match = $this->_match_pair($string, $variable)))
{
@@ -200,25 +192,20 @@ class CI_Parser {
// --------------------------------------------------------------------
/**
- * Matches a variable pair
+ * Matches a variable pair
*
- * @access private
* @param string
* @param string
* @return mixed
*/
- private function _match_pair($string, $variable)
+ protected function _match_pair($string, $variable)
{
- if ( ! preg_match("|" . preg_quote($this->l_delim) . $variable . preg_quote($this->r_delim) . "(.+?)". preg_quote($this->l_delim) . '/' . $variable . preg_quote($this->r_delim) . "|s", $string, $match))
- {
- return FALSE;
- }
-
- return $match;
+ return preg_match('|'.preg_quote($this->l_delim).$variable.preg_quote($this->r_delim).'(.+?)'.preg_quote($this->l_delim).'/'.$variable.preg_quote($this->r_delim).'|s',
+ $string, $match)
+ ? $match : FALSE;
}
}
-// END Parser Class
/* End of file Parser.php */
-/* Location: ./system/libraries/Parser.php */
+/* Location: ./system/libraries/Parser.php */ \ No newline at end of file
diff --git a/system/libraries/Typography.php b/system/libraries/Typography.php
index 65e30b089..21bbad038 100644
--- a/system/libraries/Typography.php
+++ b/system/libraries/Typography.php
@@ -25,13 +25,11 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* Typography Class
*
- *
- * @access protected
+ * @package CodeIgniter
+ * @subpackage Libraries
* @category Helpers
* @author EllisLab Dev Team
* @link http://codeigniter.com/user_guide/libraries/typography.html
@@ -67,7 +65,6 @@ class CI_Typography {
* - Converts double dashes into em-dashes.
* - Converts two spaces into entities
*
- * @access public
* @param string
* @param bool whether to reduce more then two consecutive newlines to two
* @return string
@@ -94,15 +91,12 @@ class CI_Typography {
// HTML comment tags don't conform to patterns of normal tags, so pull them out separately, only if needed
$html_comments = array();
- if (strpos($str, '<!--') !== FALSE)
+ if (strpos($str, '<!--') !== FALSE && preg_match_all('#(<!\-\-.*?\-\->)#s', $str, $matches))
{
- if (preg_match_all("#(<!\-\-.*?\-\->)#s", $str, $matches))
+ for ($i = 0, $total = count($matches[0]); $i < $total; $i++)
{
- for ($i = 0, $total = count($matches[0]); $i < $total; $i++)
- {
- $html_comments[] = $matches[0][$i];
- $str = str_replace($matches[0][$i], '{@HC'.$i.'}', $str);
- }
+ $html_comments[] = $matches[0][$i];
+ $str = str_replace($matches[0][$i], '{@HC'.$i.'}', $str);
}
}
@@ -110,22 +104,22 @@ class CI_Typography {
// not contain <pre> tags, and it keeps the PCRE patterns below simpler and faster
if (strpos($str, '<pre') !== FALSE)
{
- $str = preg_replace_callback("#<pre.*?>.*?</pre>#si", array($this, '_protect_characters'), $str);
+ $str = preg_replace_callback('#<pre.*?>.*?</pre>#si', array($this, '_protect_characters'), $str);
}
// Convert quotes within tags to temporary markers.
- $str = preg_replace_callback("#<.+?>#si", array($this, '_protect_characters'), $str);
+ $str = preg_replace_callback('#<.+?>#si', array($this, '_protect_characters'), $str);
// Do the same with braces if necessary
if ($this->protect_braced_quotes === TRUE)
{
- $str = preg_replace_callback("#\{.+?\}#si", array($this, '_protect_characters'), $str);
+ $str = preg_replace_callback('#\{.+?\}#si', array($this, '_protect_characters'), $str);
}
// Convert "ignore" tags to temporary marker. The parser splits out the string at every tag
// it encounters. Certain inline tags, like image tags, links, span tags, etc. will be
// adversely affected if they are split out so we'll convert the opening bracket < temporarily to: {@TAG}
- $str = preg_replace("#<(/*)(".$this->inline_elements.")([ >])#i", "{@TAG}\\1\\2\\3", $str);
+ $str = preg_replace('#<(/*)('.$this->inline_elements.')([ >])#i', '{@TAG}\\1\\2\\3', $str);
/* Split the string at every tag. This expression creates an array with this prototype:
*
@@ -148,9 +142,9 @@ class CI_Typography {
{
// Are we dealing with a tag? If so, we'll skip the processing for this cycle.
// Well also set the "process" flag which allows us to skip <pre> tags and a few other things.
- if (preg_match("#<(/*)(".$this->block_elements.").*?>#", $chunks[$i], $match))
+ if (preg_match('#<(/*)('.$this->block_elements.').*?>#', $chunks[$i], $match))
{
- if (preg_match("#".$this->skip_elements."#", $match[2]))
+ if (preg_match('#'.$this->skip_elements.'#', $match[2]))
{
$process = ($match[1] === '/');
}
@@ -180,10 +174,10 @@ class CI_Typography {
$str .= $this->_format_newlines($chunks[$i]);
}
- // No opening block level tag? Add it if needed.
- if ( ! preg_match("/^\s*<(?:".$this->block_elements.")/i", $str))
+ // No opening block level tag? Add it if needed.
+ if ( ! preg_match('/^\s*<(?:'.$this->block_elements.')/i', $str))
{
- $str = preg_replace("/^(.*?)<(".$this->block_elements.")/i", '<p>$1</p><$2', $str);
+ $str = preg_replace('/^(.*?)<('.$this->block_elements.')/i', '<p>$1</p><$2', $str);
}
// Convert quotes, elipsis, em-dashes, non-breaking spaces, and ampersands
@@ -230,7 +224,7 @@ class CI_Typography {
// Similarly, there might be cases where a closing </block> will follow
// a closing </p> tag, so we'll correct it by adding a newline in between
- "#</p></#" => "</p>\n</"
+ '#</p></#' => "</p>\n</"
);
// Do we need to reduce empty lines?
@@ -258,7 +252,6 @@ class CI_Typography {
* to curly entities, but it also converts em-dashes,
* double spaces, and ampersands
*
- * @access public
* @param string
* @return string
*/
@@ -322,13 +315,12 @@ class CI_Typography {
*
* Converts newline characters into either <p> tags or <br />
*
- * @access protected
* @param string
* @return string
*/
protected function _format_newlines($str)
{
- if ($str == '' OR (strpos($str, "\n") === FALSE AND ! in_array($this->last_block_element, $this->inner_block_required)))
+ if ($str == '' OR (strpos($str, "\n") === FALSE && ! in_array($this->last_block_element, $this->inner_block_required)))
{
return $str;
}
@@ -337,7 +329,7 @@ class CI_Typography {
$str = str_replace("\n\n", "</p>\n\n<p>", $str);
// Convert single spaces to <br /> tags
- $str = preg_replace("/([^\n])(\n)([^\n])/", "\\1<br />\\2\\3", $str);
+ $str = preg_replace("/([^\n])(\n)([^\n])/", '\\1<br />\\2\\3', $str);
// Wrap the whole enchilada in enclosing paragraphs
if ($str != "\n")
@@ -350,9 +342,7 @@ class CI_Typography {
// Remove empty paragraphs if they are on the first line, as this
// is a potential unintended consequence of the previous code
- $str = preg_replace("/<p><\/p>(.*)/", "\\1", $str, 1);
-
- return $str;
+ return preg_replace('/<p><\/p>(.*)/', '\\1', $str, 1);
}
// ------------------------------------------------------------------------
@@ -365,7 +355,6 @@ class CI_Typography {
* and we don't want double dashes converted to emdash entities, so they are marked with {@DD}
* likewise double spaces are converted to {@NBS} to prevent entity conversion
*
- * @access protected
* @param array
* @return string
*/
@@ -379,7 +368,6 @@ class CI_Typography {
/**
* Convert newlines to HTML line breaks except within PRE tags
*
- * @access public
* @param string
* @return string
*/
@@ -399,7 +387,6 @@ class CI_Typography {
}
}
-// END Typography Class
/* End of file Typography.php */
-/* Location: ./system/libraries/Typography.php */
+/* Location: ./system/libraries/Typography.php */ \ No newline at end of file
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 42664a587..8ad67050d 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* File Uploading Class
*
@@ -38,39 +36,40 @@
*/
class CI_Upload {
- public $max_size = 0;
- public $max_width = 0;
- public $max_height = 0;
- public $max_filename = 0;
+ public $max_size = 0;
+ public $max_width = 0;
+ public $max_height = 0;
+ public $max_filename = 0;
public $max_filename_increment = 100;
- public $allowed_types = "";
- public $file_temp = "";
- public $file_name = "";
- public $orig_name = "";
- public $file_type = "";
- public $file_size = "";
- public $file_ext = "";
- public $upload_path = "";
- public $overwrite = FALSE;
- public $encrypt_name = FALSE;
- public $is_image = FALSE;
- public $image_width = '';
- public $image_height = '';
- public $image_type = '';
- public $image_size_str = '';
- public $error_msg = array();
- public $mimes = array();
- public $remove_spaces = TRUE;
- public $xss_clean = FALSE;
- public $temp_prefix = "temp_file_";
- public $client_name = '';
+ public $allowed_types = '';
+ public $file_temp = '';
+ public $file_name = '';
+ public $orig_name = '';
+ public $file_type = '';
+ public $file_size = '';
+ public $file_ext = '';
+ public $upload_path = '';
+ public $overwrite = FALSE;
+ public $encrypt_name = FALSE;
+ public $is_image = FALSE;
+ public $image_width = '';
+ public $image_height = '';
+ public $image_type = '';
+ public $image_size_str = '';
+ public $error_msg = array();
+ public $mimes = array();
+ public $remove_spaces = TRUE;
+ public $xss_clean = FALSE;
+ public $temp_prefix = 'temp_file_';
+ public $client_name = '';
protected $_file_name_override = '';
/**
* Constructor
*
- * @access public
+ * @param array
+ * @return void
*/
public function __construct($props = array())
{
@@ -79,7 +78,7 @@ class CI_Upload {
$this->initialize($props);
}
- log_message('debug', "Upload Class Initialized");
+ log_message('debug', 'Upload Class Initialized');
}
// --------------------------------------------------------------------
@@ -93,33 +92,33 @@ class CI_Upload {
public function initialize($config = array())
{
$defaults = array(
- 'max_size' => 0,
- 'max_width' => 0,
- 'max_height' => 0,
- 'max_filename' => 0,
- 'max_filename_increment' => 100,
- 'allowed_types' => "",
- 'file_temp' => "",
- 'file_name' => "",
- 'orig_name' => "",
- 'file_type' => "",
- 'file_size' => "",
- 'file_ext' => "",
- 'upload_path' => "",
- 'overwrite' => FALSE,
- 'encrypt_name' => FALSE,
- 'is_image' => FALSE,
- 'image_width' => '',
- 'image_height' => '',
- 'image_type' => '',
- 'image_size_str' => '',
- 'error_msg' => array(),
- 'mimes' => array(),
- 'remove_spaces' => TRUE,
- 'xss_clean' => FALSE,
- 'temp_prefix' => "temp_file_",
- 'client_name' => ''
- );
+ 'max_size' => 0,
+ 'max_width' => 0,
+ 'max_height' => 0,
+ 'max_filename' => 0,
+ 'max_filename_increment' => 100,
+ 'allowed_types' => '',
+ 'file_temp' => '',
+ 'file_name' => '',
+ 'orig_name' => '',
+ 'file_type' => '',
+ 'file_size' => '',
+ 'file_ext' => '',
+ 'upload_path' => '',
+ 'overwrite' => FALSE,
+ 'encrypt_name' => FALSE,
+ 'is_image' => FALSE,
+ 'image_width' => '',
+ 'image_height' => '',
+ 'image_type' => '',
+ 'image_size_str' => '',
+ 'error_msg' => array(),
+ 'mimes' => array(),
+ 'remove_spaces' => TRUE,
+ 'xss_clean' => FALSE,
+ 'temp_prefix' => 'temp_file_',
+ 'client_name' => ''
+ );
foreach ($defaults as $key => $val)
@@ -156,8 +155,7 @@ class CI_Upload {
*/
public function do_upload($field = 'userfile')
{
-
- // Is $_FILES[$field] set? If not, no reason to continue.
+ // Is $_FILES[$field] set? If not, no reason to continue.
if ( ! isset($_FILES[$field]))
{
$this->set_error('upload_no_file_selected');
@@ -176,7 +174,7 @@ class CI_Upload {
{
$error = ( ! isset($_FILES[$field]['error'])) ? 4 : $_FILES[$field]['error'];
- switch($error)
+ switch ($error)
{
case 1: // UPLOAD_ERR_INI_SIZE
$this->set_error('upload_file_exceeds_limit');
@@ -199,19 +197,19 @@ class CI_Upload {
case 8: // UPLOAD_ERR_EXTENSION
$this->set_error('upload_stopped_by_extension');
break;
- default : $this->set_error('upload_no_file_selected');
+ default:
+ $this->set_error('upload_no_file_selected');
break;
}
return FALSE;
}
-
// Set the uploaded data as class variables
$this->file_temp = $_FILES[$field]['tmp_name'];
$this->file_size = $_FILES[$field]['size'];
$this->_file_mime_type($_FILES[$field]);
- $this->file_type = preg_replace("/^(.+?);.*$/", "\\1", $this->file_type);
+ $this->file_type = preg_replace('/^(.+?);.*$/', '\\1', $this->file_type);
$this->file_type = strtolower(trim(stripslashes($this->file_type), '"'));
$this->file_name = $this->_prep_filename($_FILES[$field]['name']);
$this->file_ext = $this->get_extension($this->file_name);
@@ -234,11 +232,10 @@ class CI_Upload {
{
$this->file_name .= $this->file_ext;
}
-
- // An extension was provided, lets have it!
else
{
- $this->file_ext = $this->get_extension($this->_file_name_override);
+ // An extension was provided, lets have it!
+ $this->file_ext = $this->get_extension($this->_file_name_override);
}
if ( ! $this->is_allowed_filetype(TRUE))
@@ -281,7 +278,7 @@ class CI_Upload {
// Remove white spaces in the name
if ($this->remove_spaces == TRUE)
{
- $this->file_name = preg_replace("/\s+/", "_", $this->file_name);
+ $this->file_name = preg_replace('/\s+/', '_', $this->file_name);
}
/*
@@ -305,23 +302,20 @@ class CI_Upload {
/*
* Run the file through the XSS hacking filter
* This helps prevent malicious code from being
- * embedded within a file. Scripts can easily
+ * embedded within a file. Scripts can easily
* be disguised as images or other file types.
*/
- if ($this->xss_clean)
+ if ($this->xss_clean && $this->do_xss_clean() === FALSE)
{
- if ($this->do_xss_clean() === FALSE)
- {
- $this->set_error('upload_unable_to_write_file');
- return FALSE;
- }
+ $this->set_error('upload_unable_to_write_file');
+ return FALSE;
}
/*
* Move the file to the final destination
* To deal with different server configurations
- * we'll attempt to use copy() first. If that fails
- * we'll use move_uploaded_file(). One of the two should
+ * we'll attempt to use copy() first. If that fails
+ * we'll use move_uploaded_file(). One of the two should
* reliably work in most environments
*/
if ( ! @copy($this->file_temp, $this->upload_path.$this->file_name))
@@ -336,7 +330,7 @@ class CI_Upload {
/*
* Set the finalized image dimensions
* This sets the image width/height (assuming the
- * file was an image). We use this information
+ * file was an image). We use this information
* in the "data" function.
*/
$this->set_image_properties($this->upload_path.$this->file_name);
@@ -356,22 +350,22 @@ class CI_Upload {
*/
public function data()
{
- return array (
- 'file_name' => $this->file_name,
- 'file_type' => $this->file_type,
- 'file_path' => $this->upload_path,
- 'full_path' => $this->upload_path.$this->file_name,
- 'raw_name' => str_replace($this->file_ext, '', $this->file_name),
- 'orig_name' => $this->orig_name,
- 'client_name' => $this->client_name,
- 'file_ext' => $this->file_ext,
- 'file_size' => $this->file_size,
- 'is_image' => $this->is_image(),
- 'image_width' => $this->image_width,
- 'image_height' => $this->image_height,
- 'image_type' => $this->image_type,
- 'image_size_str' => $this->image_size_str,
- );
+ return array(
+ 'file_name' => $this->file_name,
+ 'file_type' => $this->file_type,
+ 'file_path' => $this->upload_path,
+ 'full_path' => $this->upload_path.$this->file_name,
+ 'raw_name' => str_replace($this->file_ext, '', $this->file_name),
+ 'orig_name' => $this->orig_name,
+ 'client_name' => $this->client_name,
+ 'file_ext' => $this->file_ext,
+ 'file_size' => $this->file_size,
+ 'is_image' => $this->is_image(),
+ 'image_width' => $this->image_width,
+ 'image_height' => $this->image_height,
+ 'image_type' => $this->image_type,
+ 'image_size_str' => $this->image_size_str,
+ );
}
// --------------------------------------------------------------------
@@ -442,12 +436,12 @@ class CI_Upload {
/**
* Set Maximum File Size
*
- * @param integer
+ * @param int
* @return void
*/
public function set_max_filesize($n)
{
- $this->max_size = ((int) $n < 0) ? 0: (int) $n;
+ $this->max_size = ((int) $n < 0) ? 0 : (int) $n;
}
// --------------------------------------------------------------------
@@ -455,12 +449,12 @@ class CI_Upload {
/**
* Set Maximum File Name Length
*
- * @param integer
+ * @param int
* @return void
*/
public function set_max_filename($n)
{
- $this->max_filename = ((int) $n < 0) ? 0: (int) $n;
+ $this->max_filename = ((int) $n < 0) ? 0 : (int) $n;
}
// --------------------------------------------------------------------
@@ -468,12 +462,12 @@ class CI_Upload {
/**
* Set Maximum Image Width
*
- * @param integer
+ * @param int
* @return void
*/
public function set_max_width($n)
{
- $this->max_width = ((int) $n < 0) ? 0: (int) $n;
+ $this->max_width = ((int) $n < 0) ? 0 : (int) $n;
}
// --------------------------------------------------------------------
@@ -481,12 +475,12 @@ class CI_Upload {
/**
* Set Maximum Image Height
*
- * @param integer
+ * @param int
* @return void
*/
public function set_max_height($n)
{
- $this->max_height = ((int) $n < 0) ? 0: (int) $n;
+ $this->max_height = ((int) $n < 0) ? 0 : (int) $n;
}
// --------------------------------------------------------------------
@@ -499,7 +493,7 @@ class CI_Upload {
*/
public function set_allowed_types($types)
{
- if ( ! is_array($types) && $types == '*')
+ if ( ! is_array($types) && $types === '*')
{
$this->allowed_types = '*';
return;
@@ -530,10 +524,10 @@ class CI_Upload {
{
$types = array(1 => 'gif', 2 => 'jpeg', 3 => 'png');
- $this->image_width = $D['0'];
- $this->image_height = $D['1'];
- $this->image_type = ( ! isset($types[$D['2']])) ? 'unknown' : $types[$D['2']];
- $this->image_size_str = $D['3']; // string containing height and width
+ $this->image_width = $D[0];
+ $this->image_height = $D[1];
+ $this->image_type = isset($types[$D[2]]) ? $types[$D[2]] : 'unknown';
+ $this->image_size_str = $D[3]; // string containing height and width
}
}
}
@@ -551,7 +545,7 @@ class CI_Upload {
*/
public function set_xss_clean($flag = FALSE)
{
- $this->xss_clean = ($flag == TRUE) ? TRUE : FALSE;
+ $this->xss_clean = ($flag == TRUE);
}
// --------------------------------------------------------------------
@@ -573,19 +567,14 @@ class CI_Upload {
{
$this->file_type = 'image/png';
}
-
- if (in_array($this->file_type, $jpeg_mimes))
+ elseif (in_array($this->file_type, $jpeg_mimes))
{
$this->file_type = 'image/jpeg';
}
- $img_mimes = array(
- 'image/gif',
- 'image/jpeg',
- 'image/png',
- );
+ $img_mimes = array('image/gif', 'image/jpeg', 'image/png');
- return (in_array($this->file_type, $img_mimes, TRUE)) ? TRUE : FALSE;
+ return in_array($this->file_type, $img_mimes, TRUE);
}
// --------------------------------------------------------------------
@@ -631,16 +620,13 @@ class CI_Upload {
$mime = $this->mimes_types($ext);
- if (is_array($mime))
+ if (is_array($mime) && in_array($this->file_type, $mime, TRUE))
{
- if (in_array($this->file_type, $mime, TRUE))
- {
- return TRUE;
- }
+ return TRUE;
}
elseif ($mime === $this->file_type)
{
- return TRUE;
+ return TRUE;
}
return FALSE;
@@ -655,14 +641,7 @@ class CI_Upload {
*/
public function is_allowed_filesize()
{
- if ($this->max_size != 0 AND $this->file_size > $this->max_size)
- {
- return FALSE;
- }
- else
- {
- return TRUE;
- }
+ return ($this->max_size == 0 OR $this->max_size > $this->file_size);
}
// --------------------------------------------------------------------
@@ -683,17 +662,15 @@ class CI_Upload {
{
$D = @getimagesize($this->file_temp);
- if ($this->max_width > 0 AND $D['0'] > $this->max_width)
+ if ($this->max_width > 0 && $D[0] > $this->max_width)
{
return FALSE;
}
- if ($this->max_height > 0 AND $D['1'] > $this->max_height)
+ if ($this->max_height > 0 && $D[1] > $this->max_height)
{
return FALSE;
}
-
- return TRUE;
}
return TRUE;
@@ -706,7 +683,6 @@ class CI_Upload {
*
* Verifies that it is a valid upload path with proper permissions.
*
- *
* @return bool
*/
public function validate_upload_path()
@@ -717,9 +693,9 @@ class CI_Upload {
return FALSE;
}
- if (function_exists('realpath') AND @realpath($this->upload_path) !== FALSE)
+ if (function_exists('realpath') && @realpath($this->upload_path) !== FALSE)
{
- $this->upload_path = str_replace("\\", "/", realpath($this->upload_path));
+ $this->upload_path = str_replace('\\', '/', realpath($this->upload_path));
}
if ( ! @is_dir($this->upload_path))
@@ -734,7 +710,7 @@ class CI_Upload {
return FALSE;
}
- $this->upload_path = preg_replace("/(.+?)\/*$/", "\\1/", $this->upload_path);
+ $this->upload_path = preg_replace('/(.+?)\/*$/', '\\1/', $this->upload_path);
return TRUE;
}
@@ -763,37 +739,31 @@ class CI_Upload {
public function clean_file_name($filename)
{
$bad = array(
- "<!--",
- "-->",
- "'",
- "<",
- ">",
- '"',
- '&',
- '$',
- '=',
- ';',
- '?',
- '/',
- "%20",
- "%22",
- "%3c", // <
- "%253c", // <
- "%3e", // >
- "%0e", // >
- "%28", // (
- "%29", // )
- "%2528", // (
- "%26", // &
- "%24", // $
- "%3f", // ?
- "%3b", // ;
- "%3d" // =
- );
-
- $filename = str_replace($bad, '', $filename);
-
- return stripslashes($filename);
+ '<!--', '-->',
+ "'", '"',
+ '<', '>',
+ '&', '$',
+ '=',
+ ';',
+ '?',
+ '/',
+ '%20',
+ '%22',
+ '%3c', // <
+ '%253c', // <
+ '%3e', // >
+ '%0e', // >
+ '%28', // (
+ '%29', // )
+ '%2528', // (
+ '%26', // &
+ '%24', // $
+ '%3f', // ?
+ '%3b', // ;
+ '%3d' // =
+ );
+
+ return stripslashes(str_replace($bad, '', $filename));
}
// --------------------------------------------------------------------
@@ -847,7 +817,7 @@ class CI_Upload {
$current = ini_get('memory_limit') * 1024 * 1024;
// There was a bug/behavioural change in PHP 5.2, where numbers over one million get output
- // into scientific notation. number_format() ensures this number is an integer
+ // into scientific notation. number_format() ensures this number is an integer
// http://bugs.php.net/bug.php?id=43053
$new_memory = number_format(ceil(filesize($file) + $current), 0, '.', '');
@@ -857,8 +827,8 @@ class CI_Upload {
// If the file being uploaded is an image, then we should have no problem with XSS attacks (in theory), but
// IE can be fooled into mime-type detecting a malformed image as an html file, thus executing an XSS attack on anyone
- // using IE who looks at the image. It does this by inspecting the first 255 bytes of an image. To get around this
- // CI will itself look at the first 255 bytes of an image to determine its relative safety. This can save a lot of
+ // using IE who looks at the image. It does this by inspecting the first 255 bytes of an image. To get around this
+ // CI will itself look at the first 255 bytes of an image to determine its relative safety. This can save a lot of
// processor power and time if it is actually a clean image, as it will be in nearly all instances _except_ an
// attempted XSS attack.
@@ -932,7 +902,7 @@ class CI_Upload {
*/
public function display_errors($open = '<p>', $close = '</p>')
{
- return (count($this->error_msg) > 0) ? $open . implode($close . $open, $this->error_msg) . $close : '';
+ return (count($this->error_msg) > 0) ? $open.implode($close.$open, $this->error_msg).$close : '';
}
// --------------------------------------------------------------------
@@ -940,7 +910,7 @@ class CI_Upload {
/**
* List of Mime Types
*
- * This is a list of mime types. We use it to validate
+ * This is a list of mime types. We use it to validate
* the "allowed types" set by the developer
*
* @param string
@@ -952,7 +922,7 @@ class CI_Upload {
if (count($this->mimes) == 0)
{
- if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'))
+ if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'))
{
include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php');
}
@@ -966,10 +936,9 @@ class CI_Upload {
}
$this->mimes = $mimes;
- unset($mimes);
}
- return ( ! isset($this->mimes[$mime])) ? FALSE : $this->mimes[$mime];
+ return isset($this->mimes[$mime]) ? $this->mimes[$mime] : FALSE;
}
// --------------------------------------------------------------------
@@ -1006,9 +975,7 @@ class CI_Upload {
}
}
- $filename .= '.'.$ext;
-
- return $filename;
+ return $filename.'.'.$ext;
}
// --------------------------------------------------------------------
@@ -1129,10 +1096,7 @@ class CI_Upload {
$this->file_type = $file['type'];
}
- // --------------------------------------------------------------------
-
}
-// END Upload Class
/* End of file Upload.php */
-/* Location: ./system/libraries/Upload.php */
+/* Location: ./system/libraries/Upload.php */ \ No newline at end of file
diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php
index fc41444bc..6d270c2ea 100644
--- a/system/libraries/Xmlrpcs.php
+++ b/system/libraries/Xmlrpcs.php
@@ -54,10 +54,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
public $controller_obj;
public $object = FALSE;
- /**
- * Constructor
- */
- public function __construct($config=array())
+ public function __construct($config = array())
{
parent::__construct();
$this->set_system_methods();
@@ -67,7 +64,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
$this->methods = array_merge($this->methods, $config['functions']);
}
- log_message('debug', "XML-RPC Server Class Initialized");
+ log_message('debug', 'XML-RPC Server Class Initialized');
}
// --------------------------------------------------------------------
@@ -75,7 +72,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc
/**
* Initialize Prefs and Serve
*
- * @access public
* @param mixed
* @return void
*/
@@ -107,7 +103,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc
/**
* Setting of System Methods
*
- * @access public
* @return void
*/
public function set_system_methods()
@@ -137,7 +132,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc
/**
* Main Server Function
*
- * @access public
* @return void
*/
public function serve()
@@ -145,8 +139,8 @@ class CI_Xmlrpcs extends CI_Xmlrpc
$r = $this->parseRequest();
$payload = '<?xml version="1.0" encoding="'.$this->xmlrpc_defencoding.'"?'.'>'."\n".$this->debug_msg.$r->prepare_response();
- header("Content-Type: text/xml");
- header("Content-Length: ".strlen($payload));
+ header('Content-Type: text/xml');
+ header('Content-Length: '.strlen($payload));
exit($payload);
}
@@ -155,7 +149,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc
/**
* Add Method to Class
*
- * @access public
* @param string method name
* @param string function
* @param string signature
@@ -176,7 +169,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc
/**
* Parse Server Request
*
- * @access public
* @param string data
* @return object xmlrpc response
*/
@@ -198,7 +190,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
//-------------------------------------
$parser = xml_parser_create($this->xmlrpc_defencoding);
- $parser_object = new XML_RPC_Message("filler");
+ $parser_object = new XML_RPC_Message('filler');
$parser_object->xh[$parser] = array(
'isf' => 0,
@@ -215,7 +207,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc
xml_set_character_data_handler($parser, 'character_data');
//xml_set_default_handler($parser, 'default_handler');
-
//-------------------------------------
// PARSE + PROCESS XML DATA
//-------------------------------------
@@ -245,7 +236,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
{
if ($this->debug === TRUE)
{
- $plist .= "$i - " . print_r(get_object_vars($parser_object->xh[$parser]['params'][$i]), TRUE). ";\n";
+ $plist .= $i.' - '.print_r(get_object_vars($parser_object->xh[$parser]['params'][$i]), TRUE).";\n";
}
$m->addParam($parser_object->xh[$parser]['params'][$i]);
@@ -276,7 +267,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc
/**
* Executes the Method
*
- * @access protected
* @param object
* @return mixed
*/
@@ -305,7 +295,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
// Check for Method (and Object)
//-------------------------------------
- $method_parts = explode(".", $this->methods[$methName]['function']);
+ $method_parts = explode('.', $this->methods[$methName]['function']);
$objectCall = (isset($method_parts[1]) && $method_parts[1] != '');
if ($system_call === TRUE)
@@ -315,14 +305,11 @@ class CI_Xmlrpcs extends CI_Xmlrpc
return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']);
}
}
- else
+ elseif (($objectCall && ! is_callable(array($method_parts[0], $method_parts[1])))
+ OR ( ! $objectCall && ! is_callable($this->methods[$methName]['function']))
+ )
{
- if (($objectCall AND ! is_callable(array($method_parts[0], $method_parts[1])))
- OR ( ! $objectCall AND ! is_callable($this->methods[$methName]['function']))
- )
- {
- return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']);
- }
+ return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']);
}
//-------------------------------------
@@ -351,7 +338,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
return new XML_RPC_Response(0,
$this->xmlrpcerr['incorrect_params'],
$this->xmlrpcstr['incorrect_params'] .
- ": Wanted {$wanted}, got {$pt} at param {$pno})");
+ ': Wanted '.$wanted.', got '.$pt.' at param '.$pno.')');
}
}
}
@@ -393,7 +380,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc
/**
* Server Function: List Methods
*
- * @access public
* @param mixed
* @return object
*/
@@ -409,7 +395,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
foreach ($this->system_methods as $key => $value)
{
- $output[]= new XML_RPC_Values($key, 'string');
+ $output[] = new XML_RPC_Values($key, 'string');
}
$v->addArray($output);
@@ -421,7 +407,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc
/**
* Server Function: Return Signature for Method
*
- * @access public
* @param mixed
* @return object
*/
@@ -447,18 +432,14 @@ class CI_Xmlrpcs extends CI_Xmlrpc
}
$sigs[] = new XML_RPC_Values($cursig, 'array');
}
- $r = new XML_RPC_Response(new XML_RPC_Values($sigs, 'array'));
- }
- else
- {
- $r = new XML_RPC_Response(new XML_RPC_Values('undef', 'string'));
+
+ return new XML_RPC_Response(new XML_RPC_Values($sigs, 'array'));
}
+
+ return new XML_RPC_Response(new XML_RPC_Values('undef', 'string'));
}
- else
- {
- $r = new XML_RPC_Response(0,$this->xmlrpcerr['introspect_unknown'], $this->xmlrpcstr['introspect_unknown']);
- }
- return $r;
+
+ return new XML_RPC_Response(0,$this->xmlrpcerr['introspect_unknown'], $this->xmlrpcstr['introspect_unknown']);
}
// --------------------------------------------------------------------
@@ -466,7 +447,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc
/**
* Server Function: Doc String for Method
*
- * @access public
* @param mixed
* @return object
*/
@@ -492,7 +472,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc
/**
* Server Function: Multi-call
*
- * @access public
* @param mixed
* @return object
*/
@@ -536,7 +515,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc
/**
* Multi-call Function: Error Handling
*
- * @access public
* @param mixed
* @return object
*/
@@ -556,7 +534,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc
/**
* Multi-call Function: Processes method
*
- * @access public
* @param mixed
* @return object
*/
@@ -610,7 +587,6 @@ class CI_Xmlrpcs extends CI_Xmlrpc
}
}
-// END XML_RPC_Server class
/* End of file Xmlrpcs.php */
-/* Location: ./system/libraries/Xmlrpcs.php */
+/* Location: ./system/libraries/Xmlrpcs.php */ \ No newline at end of file
diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php
index e33eb4e5a..e91e2a2ff 100644
--- a/system/libraries/Zip.php
+++ b/system/libraries/Zip.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.2.4 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* Zip Compression Class
*
@@ -44,21 +42,17 @@
*/
class CI_Zip {
- var $zipdata = '';
- var $directory = '';
- var $entries = 0;
- var $file_num = 0;
- var $offset = 0;
- var $now;
+ public $zipdata = '';
+ public $directory = '';
+ public $entries = 0;
+ public $file_num = 0;
+ public $offset = 0;
+ public $now;
- /**
- * Constructor
- */
public function __construct()
{
- log_message('debug', "Zip Compression Class Initialized");
-
$this->now = time();
+ log_message('debug', 'Zip Compression Class Initialized');
}
// --------------------------------------------------------------------
@@ -68,21 +62,19 @@ class CI_Zip {
*
* Lets you add a virtual directory into which you can place files.
*
- * @access public
* @param mixed the directory name. Can be string or array
* @return void
*/
- function add_dir($directory)
+ public function add_dir($directory)
{
- foreach ((array)$directory as $dir)
+ foreach ( (array) $directory as $dir)
{
- if ( ! preg_match("|.+/$|", $dir))
+ if ( ! preg_match('|.+/$|', $dir))
{
$dir .= '/';
}
$dir_time = $this->_get_mod_time($dir);
-
$this->_add_dir($dir, $dir_time['file_mtime'], $dir_time['file_mdate']);
}
}
@@ -90,22 +82,22 @@ class CI_Zip {
// --------------------------------------------------------------------
/**
- * Get file/directory modification time
+ * Get file/directory modification time
*
- * If this is a newly created file/dir, we will set the time to 'now'
+ * If this is a newly created file/dir, we will set the time to 'now'
*
- * @param string path to file
- * @return array filemtime/filemdate
+ * @param string path to file
+ * @return array filemtime/filemdate
*/
- function _get_mod_time($dir)
+ protected function _get_mod_time($dir)
{
// filemtime() may return false, but raises an error for non-existing files
- $date = (file_exists($dir)) ? filemtime($dir): getdate($this->now);
-
- $time['file_mtime'] = ($date['hours'] << 11) + ($date['minutes'] << 5) + $date['seconds'] / 2;
- $time['file_mdate'] = (($date['year'] - 1980) << 9) + ($date['mon'] << 5) + $date['mday'];
+ $date = file_exists($dir) ? filemtime($dir) : getdate($this->now);
- return $time;
+ return array(
+ 'file_mtime' => ($date['hours'] << 11) + ($date['minutes'] << 5) + $date['seconds'] / 2,
+ 'file_mdate' => (($date['year'] - 1980) << 9) + ($date['mon'] << 5) + $date['mday']
+ );
}
// --------------------------------------------------------------------
@@ -113,13 +105,14 @@ class CI_Zip {
/**
* Add Directory
*
- * @access private
* @param string the directory name
+ * @param int
+ * @param int
* @return void
*/
- function _add_dir($dir, $file_mtime, $file_mdate)
+ protected function _add_dir($dir, $file_mtime, $file_mdate)
{
- $dir = str_replace("\\", "/", $dir);
+ $dir = str_replace('\\', '/', $dir);
$this->zipdata .=
"\x50\x4b\x03\x04\x0a\x00\x00\x00\x00\x00"
@@ -162,29 +155,26 @@ class CI_Zip {
* Add Data to Zip
*
* Lets you add files to the archive. If the path is included
- * in the filename it will be placed within a directory. Make
+ * in the filename it will be placed within a directory. Make
* sure you use add_dir() first to create the folder.
*
- * @access public
* @param mixed
* @param string
* @return void
*/
- function add_data($filepath, $data = NULL)
+ public function add_data($filepath, $data = NULL)
{
if (is_array($filepath))
{
foreach ($filepath as $path => $data)
{
$file_data = $this->_get_mod_time($path);
-
$this->_add_data($path, $data, $file_data['file_mtime'], $file_data['file_mdate']);
}
}
else
{
$file_data = $this->_get_mod_time($filepath);
-
$this->_add_data($filepath, $data, $file_data['file_mtime'], $file_data['file_mdate']);
}
}
@@ -194,20 +184,19 @@ class CI_Zip {
/**
* Add Data to Zip
*
- * @access private
* @param string the file name/path
* @param string the data to be encoded
+ * @param int
+ * @param int
* @return void
*/
- function _add_data($filepath, $data, $file_mtime, $file_mdate)
+ protected function _add_data($filepath, $data, $file_mtime, $file_mdate)
{
- $filepath = str_replace("\\", "/", $filepath);
+ $filepath = str_replace('\\', '/', $filepath);
$uncompressed_size = strlen($data);
$crc32 = crc32($data);
-
- $gzdata = gzcompress($data);
- $gzdata = substr($gzdata, 2, -4);
+ $gzdata = substr(gzcompress($data), 2, -4);
$compressed_size = strlen($gzdata);
$this->zipdata .=
@@ -248,10 +237,11 @@ class CI_Zip {
/**
* Read the contents of a file and add it to the zip
*
- * @access public
+ * @param string
+ * @param bool
* @return bool
*/
- function read_file($path, $preserve_filepath = FALSE)
+ public function read_file($path, $preserve_filepath = FALSE)
{
if ( ! file_exists($path))
{
@@ -260,16 +250,16 @@ class CI_Zip {
if (FALSE !== ($data = file_get_contents($path)))
{
- $name = str_replace("\\", "/", $path);
-
+ $name = str_replace('\\', '/', $path);
if ($preserve_filepath === FALSE)
{
- $name = preg_replace("|.*/(.+)|", "\\1", $name);
+ $name = preg_replace('|.*/(.+)|', '\\1', $name);
}
$this->add_data($name, $data);
return TRUE;
}
+
return FALSE;
}
@@ -279,15 +269,17 @@ class CI_Zip {
* Read a directory and add it to the zip.
*
* This function recursively reads a folder and everything it contains (including
- * sub-folders) and creates a zip based on it. Whatever directory structure
+ * sub-folders) and creates a zip based on it. Whatever directory structure
* is in the original file path will be recreated in the zip file.
*
- * @access public
* @param string path to source
+ * @param bool
+ * @param bool
* @return bool
*/
- function read_dir($path, $preserve_filepath = TRUE, $root_path = NULL)
+ public function read_dir($path, $preserve_filepath = TRUE, $root_path = NULL)
{
+ $path = rtrim($path, '/\\').'/';
if ( ! $fp = @opendir($path))
{
return FALSE;
@@ -301,31 +293,27 @@ class CI_Zip {
while (FALSE !== ($file = readdir($fp)))
{
- if (substr($file, 0, 1) == '.')
+ if ($file[0] === '.')
{
continue;
}
if (@is_dir($path.$file))
{
- $this->read_dir($path.$file."/", $preserve_filepath, $root_path);
+ $this->read_dir($path.$file.'/', $preserve_filepath, $root_path);
}
- else
+ elseif (FALSE !== ($data = file_get_contents($path.$file)))
{
- if (FALSE !== ($data = file_get_contents($path.$file)))
+ $name = str_replace('\\', '/', $path);
+ if ($preserve_filepath === FALSE)
{
- $name = str_replace("\\", "/", $path);
-
- if ($preserve_filepath === FALSE)
- {
- $name = str_replace($root_path, '', $name);
- }
-
- $this->add_data($name.$file, $data);
+ $name = str_replace($root_path, '', $name);
}
+ $this->add_data($name.$file, $data);
}
}
+ closedir($fp);
return TRUE;
}
@@ -334,26 +322,23 @@ class CI_Zip {
/**
* Get the Zip file
*
- * @access public
- * @return binary string
+ * @return string (binary encoded)
*/
- function get_zip()
+ public function get_zip()
{
// Is there any data to return?
- if ($this->entries == 0)
+ if ($this->entries === 0)
{
return FALSE;
}
- $zip_data = $this->zipdata;
- $zip_data .= $this->directory."\x50\x4b\x05\x06\x00\x00\x00\x00";
- $zip_data .= pack('v', $this->entries); // total # of entries "on this disk"
- $zip_data .= pack('v', $this->entries); // total # of entries overall
- $zip_data .= pack('V', strlen($this->directory)); // size of central dir
- $zip_data .= pack('V', strlen($this->zipdata)); // offset to start of central dir
- $zip_data .= "\x00\x00"; // .zip file comment length
-
- return $zip_data;
+ return $this->zipdata
+ .$this->directory."\x50\x4b\x05\x06\x00\x00\x00\x00"
+ .pack('v', $this->entries) // total # of entries "on this disk"
+ .pack('v', $this->entries) // total # of entries overall
+ .pack('V', strlen($this->directory)) // size of central dir
+ .pack('V', strlen($this->zipdata)) // offset to start of central dir
+ ."\x00\x00"; // .zip file comment length
}
// --------------------------------------------------------------------
@@ -363,11 +348,10 @@ class CI_Zip {
*
* Lets you write a file
*
- * @access public
* @param string the file name
* @return bool
*/
- function archive($filepath)
+ public function archive($filepath)
{
if ( ! ($fp = @fopen($filepath, FOPEN_WRITE_CREATE_DESTRUCTIVE)))
{
@@ -387,23 +371,19 @@ class CI_Zip {
/**
* Download
*
- * @access public
* @param string the file name
- * @param string the data to be encoded
- * @return bool
+ * @return void
*/
- function download($filename = 'backup.zip')
+ public function download($filename = 'backup.zip')
{
- if ( ! preg_match("|.+?\.zip$|", $filename))
+ if ( ! preg_match('|.+?\.zip$|', $filename))
{
$filename .= '.zip';
}
$CI =& get_instance();
$CI->load->helper('download');
-
$get_zip = $this->get_zip();
-
$zip_content =& $get_zip;
force_download($filename, $zip_content);
@@ -414,19 +394,19 @@ class CI_Zip {
/**
* Initialize Data
*
- * Lets you clear current zip data. Useful if you need to create
+ * Lets you clear current zip data. Useful if you need to create
* multiple zips with different data.
*
- * @access public
- * @return void
+ * @return object
*/
- function clear_data()
+ public function clear_data()
{
$this->zipdata = '';
$this->directory = '';
$this->entries = 0;
$this->file_num = 0;
$this->offset = 0;
+ return $this;
}
}