summaryrefslogtreecommitdiffstats
path: root/system/libraries
diff options
context:
space:
mode:
authorMichael Dennis <michaeljdennis@gmail.com>2011-08-29 19:06:59 +0200
committerMichael Dennis <michaeljdennis@gmail.com>2011-08-29 19:06:59 +0200
commit013f78dc6a878d7775aa2bbcef573934a6d88a72 (patch)
tree97ba05fd8e5efc066cb8f428744991fc628d207b /system/libraries
parentcb07a322bee5c5b0a551ab959c7475a1a702ad03 (diff)
parent70e61b5dc0b240c4a3341ca65ad9f2f5254df1b5 (diff)
Merge remote-tracking branch 'upstream/develop' into develop
Diffstat (limited to 'system/libraries')
-rw-r--r--system/libraries/Cache/drivers/Cache_memcached.php83
-rw-r--r--system/libraries/Email.php6
-rw-r--r--system/libraries/Image_lib.php2
-rw-r--r--system/libraries/Log.php21
-rw-r--r--system/libraries/Migration.php2
-rw-r--r--system/libraries/Profiler.php4
-rw-r--r--system/libraries/Upload.php54
7 files changed, 107 insertions, 65 deletions
diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php
index ec2fd216a..04aa81a5a 100644
--- a/system/libraries/Cache/drivers/Cache_memcached.php
+++ b/system/libraries/Cache/drivers/Cache_memcached.php
@@ -10,19 +10,19 @@
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 2.0
- * @filesource
+ * @filesource
*/
// ------------------------------------------------------------------------
/**
- * CodeIgniter Memcached Caching Class
+ * CodeIgniter Memcached Caching Class
*
* @package CodeIgniter
* @subpackage Libraries
* @category Core
* @author ExpressionEngine Dev Team
- * @link
+ * @link
*/
class CI_Cache_memcached extends CI_Driver {
@@ -37,18 +37,18 @@ class CI_Cache_memcached extends CI_Driver {
)
);
- // ------------------------------------------------------------------------
+ // ------------------------------------------------------------------------
/**
* Fetch from cache
*
* @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;
}
@@ -64,11 +64,11 @@ class CI_Cache_memcached extends CI_Driver {
*/
public function save($id, $data, $ttl = 60)
{
- return $this->_memcached->add($id, array($data, time(), $ttl), $ttl);
+ return $this->_memcached->set($id, array($data, time(), $ttl), $ttl);
}
// ------------------------------------------------------------------------
-
+
/**
* Delete from Cache
*
@@ -81,7 +81,7 @@ class CI_Cache_memcached extends CI_Driver {
}
// ------------------------------------------------------------------------
-
+
/**
* Clean the Cache
*
@@ -106,7 +106,7 @@ class CI_Cache_memcached extends CI_Driver {
}
// ------------------------------------------------------------------------
-
+
/**
* Get Cache Metadata
*
@@ -140,6 +140,7 @@ class CI_Cache_memcached extends CI_Driver {
{
// Try to load memcached server info from the config file.
$CI =& get_instance();
+
if ($CI->config->load('memcached', TRUE, TRUE))
{
if (is_array($CI->config->config['memcached']))
@@ -149,11 +150,24 @@ class CI_Cache_memcached extends CI_Driver {
foreach ($CI->config->config['memcached'] as $name => $conf)
{
$this->_memcache_conf[$name] = $conf;
- }
- }
+ }
+ }
+ }
+
+ if (class_exists('Memcached'))
+ {
+ $this->_memcached = new Memcached();
+ }
+ else if (class_exists('Memcache'))
+ {
+ $this->_memcached = new Memcache();
+ }
+ else
+ {
+ log_message('error', 'Failed to create object for Memcached Cache; extension not loaded?');
+
+ return FALSE;
}
-
- $this->_memcached = new Memcached();
foreach ($this->_memcache_conf as $name => $cache_server)
{
@@ -161,26 +175,42 @@ class CI_Cache_memcached extends CI_Driver {
{
$cache_server['hostname'] = $this->_default_options['default_host'];
}
-
+
if ( ! array_key_exists('port', $cache_server))
{
$cache_server['port'] = $this->_default_options['default_port'];
}
-
+
if ( ! array_key_exists('weight', $cache_server))
{
$cache_server['weight'] = $this->_default_options['default_weight'];
}
-
- $this->_memcached->addServer(
- $cache_server['hostname'], $cache_server['port'], $cache_server['weight']
- );
+
+ if (get_class($this->_memcached) == 'Memcache')
+ {
+ // Third parameter is persistance and defaults to TRUE.
+ $this->_memcached->addServer(
+ $cache_server['hostname'],
+ $cache_server['port'],
+ TRUE,
+ $cache_server['weight']
+ );
+ }
+ else
+ {
+ $this->_memcached->addServer(
+ $cache_server['hostname'],
+ $cache_server['port'],
+ $cache_server['weight']
+ );
+ }
}
+
+ return TRUE;
}
// ------------------------------------------------------------------------
-
/**
* Is supported
*
@@ -189,15 +219,14 @@ class CI_Cache_memcached extends CI_Driver {
*/
public function is_supported()
{
- if ( ! extension_loaded('memcached'))
+ if ( ! extension_loaded('memcached') && ! extension_loaded('memcache'))
{
log_message('error', 'The Memcached Extension must be loaded to use Memcached Cache.');
-
+
return FALSE;
}
-
- $this->_setup_memcached();
- return TRUE;
+
+ return $this->_setup_memcached();
}
// ------------------------------------------------------------------------
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index e28c23a04..28a3d17b4 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -452,7 +452,7 @@ class CI_Email {
*/
public function set_alt_message($str = '')
{
- $this->alt_message = $str;
+ $this->alt_message = (string) $str;
return $this;
}
@@ -477,12 +477,12 @@ class CI_Email {
* Set Wordwrap
*
* @access public
- * @param string
+ * @param bool
* @return void
*/
public function set_wordwrap($wordwrap = TRUE)
{
- $this->wordwrap = ($wordwrap === FALSE) ? FALSE : TRUE;
+ $this->wordwrap = (bool) $wordwrap;
return $this;
}
diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index 6855e4498..54cd5e2f6 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -1356,7 +1356,7 @@ class CI_Image_lib {
return FALSE;
}
- $vals = @getimagesize($path);
+ $vals = getimagesize($path);
$types = array(1 => 'gif', 2 => 'jpeg', 3 => 'png');
diff --git a/system/libraries/Log.php b/system/libraries/Log.php
index 9f1db76ba..bf10d4727 100644
--- a/system/libraries/Log.php
+++ b/system/libraries/Log.php
@@ -27,10 +27,12 @@
class CI_Log {
protected $_log_path;
- protected $_threshold = 1;
- protected $_date_fmt = 'Y-m-d H:i:s';
- protected $_enabled = TRUE;
- protected $_levels = array('ERROR' => '1', 'DEBUG' => '2', 'INFO' => '3', 'ALL' => '4');
+ protected $_threshold = 1;
+ protected $_threshold_max = 0;
+ protected $_threshold_array = array();
+ protected $_date_fmt = 'Y-m-d H:i:s';
+ protected $_enabled = TRUE;
+ protected $_levels = array('ERROR' => '1', 'DEBUG' => '2', 'INFO' => '3', 'ALL' => '4');
/**
* Constructor
@@ -50,6 +52,11 @@ class CI_Log {
{
$this->_threshold = $config['log_threshold'];
}
+ elseif (is_array($config['log_threshold']))
+ {
+ $this->_threshold = $this->_threshold_max;
+ $this->_threshold_array = array_flip($config['log_threshold']);
+ }
if ($config['log_date_format'] != '')
{
@@ -80,9 +87,13 @@ class CI_Log {
if ( ! isset($this->_levels[$level]) OR ($this->_levels[$level] > $this->_threshold))
{
- return FALSE;
+ if (empty($this->_threshold_array) OR ! isset($this->_threshold_array[$this->_levels[$level]]))
+ {
+ return FALSE;
+ }
}
+
$filepath = $this->_log_path.'log-'.date('Y-m-d').'.php';
$message = '';
diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php
index 3943ec130..3734e18f5 100644
--- a/system/libraries/Migration.php
+++ b/system/libraries/Migration.php
@@ -57,7 +57,7 @@ class CI_Migration {
}
// If not set, set it
- $this->_migration_path == '' OR $this->_migration_path = APPPATH . 'migrations/';
+ $this->_migration_path == '' AND $this->_migration_path = APPPATH . 'migrations/';
// Add trailing slash if not set
$this->_migration_path = rtrim($this->_migration_path, '/').'/';
diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php
index 082a5ee1d..330acce73 100644
--- a/system/libraries/Profiler.php
+++ b/system/libraries/Profiler.php
@@ -493,7 +493,7 @@ class CI_Profiler {
*
* @return string
*/
- private function _compile_session_data()
+ protected function _compile_session_data()
{
if ( ! isset($this->CI->session))
{
@@ -555,4 +555,4 @@ class CI_Profiler {
// END CI_Profiler class
/* End of file Profiler.php */
-/* Location: ./system/libraries/Profiler.php */ \ No newline at end of file
+/* Location: ./system/libraries/Profiler.php */
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 3177424c4..8f324de79 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -30,6 +30,7 @@ class CI_Upload {
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 = "";
@@ -80,31 +81,32 @@ class CI_Upload {
public function initialize($config = array())
{
$defaults = array(
- 'max_size' => 0,
- 'max_width' => 0,
- 'max_height' => 0,
- 'max_filename' => 0,
- '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' => ''
);
@@ -402,7 +404,7 @@ class CI_Upload {
$filename = str_replace($this->file_ext, '', $filename);
$new_filename = '';
- for ($i = 1; $i < 100; $i++)
+ for ($i = 1; $i < $this->max_filename_increment; $i++)
{
if ( ! file_exists($path.$filename.$i.$this->file_ext))
{