From 96bd33b2edc1b0e6a04cb8e3bcf97e8c7b3adf3e Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Wed, 4 May 2011 01:30:36 +0100 Subject: Added Migration class and language file. --- system/libraries/Migration.php | 95 ++++++++++++++++++++++-------------------- 1 file changed, 49 insertions(+), 46 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php index 73c55c346..4bf1d0dc1 100644 --- a/system/libraries/Migration.php +++ b/system/libraries/Migration.php @@ -29,13 +29,13 @@ */ class CI_Migration { - private $_migration_enabled = FALSE; - private $_migration_path = NULL; - private $_migration_version = 0; + protected $_migration_enabled = FALSE; + protected $_migration_path = NULL; + protected $_migration_version = 0; public $error = ''; - function __construct($config = array()) + public function __construct($config = array()) { # Only run this constructor on main library load if (get_parent_class($this) !== FALSE) @@ -62,6 +62,9 @@ class CI_Migration { // Add trailing slash if not set $this->_migration_path = rtrim($this->_migration_path, '/').'/'; + // Load migration language + $this->lang->load('migration'); + // They'll probably be using dbforge $this->load->dbforge(); @@ -90,7 +93,7 @@ class CI_Migration { * @param $version integer Target schema version * @return mixed TRUE if already latest, FALSE if failed, int if upgraded */ - function version($target_version) + public function version($target_version) { $start = $current_version = $this->_get_version(); $stop = $target_version; @@ -108,7 +111,7 @@ class CI_Migration { // Moving Down $step = -1; } - + $method = $step === 1 ? 'up' : 'down'; $migrations = array(); @@ -121,7 +124,7 @@ class CI_Migration { // Only one migration per step is permitted if (count($f) > 1) { - $this->error = sprintf($this->lang->line('multiple_migration_version'), $i); + $this->error = sprintf($this->lang->line('migration_multiple_version'), $i); return FALSE; } @@ -152,7 +155,7 @@ class CI_Migration { // Cannot repeat a migration at different steps if (in_array($match[1], $migrations)) { - $this->error = sprintf($this->lang->line('multiple_migrations_name'), $match[1]); + $this->error = sprintf($this->lang->line('migration_multiple_version'), $match[1]); return FALSE; } @@ -165,9 +168,9 @@ class CI_Migration { return FALSE; } - if ( ! is_callable(array($class, 'up')) || ! is_callable(array($class, 'down'))) + if ( ! is_callable(array($class, $method))) { - $this->error = sprintf($this->lang->line('wrong_migration_interface'), $class); + $this->error = sprintf($this->lang->line('migration_missing_'.$method.'_method'), $class); return FALSE; } @@ -175,12 +178,13 @@ class CI_Migration { } else { - $this->error = sprintf($this->lang->line('invalid_migration_filename'), $file); + exit('313'); + $this->error = sprintf($this->lang->line('migration_invalid_filename'), $file); return FALSE; } } - $this->log('Current schema version: ' . $current_version); + log_message('debug', 'Current migration: ' . $current_version); $version = $i + ($step == 1 ? -1 : 0); @@ -190,7 +194,7 @@ class CI_Migration { return TRUE; } - $this->log('Moving ' . $method . ' to version ' . $version); + log_message('debug', 'Migrating from ' . $method . ' to version ' . $version); // Loop through the migrations foreach ($migrations AS $migration) @@ -203,7 +207,7 @@ class CI_Migration { $this->_update_version($current_version); } - $this->log('All done. Schema is at version '.$current_version); + log_message('debug', 'Finished migrating to '.$current_version); return $current_version; } @@ -220,16 +224,15 @@ class CI_Migration { { if ( ! $migrations = $this->find_migrations()) { - throw new Exception('no_migrations_found'); + $this->error = $this->line->lang('migration_none_found'); return false; } $last_migration = basename(end($migrations)); - + // Calculate the last migration step from existing migration // filenames and procceed to the standard version migration - $last_version = intval(substr($last_migration, 0, 3)); - return $this->version($last_version); + return $this->version((int) substr($last_migration, 0, 3)); } // -------------------------------------------------------------------- @@ -242,25 +245,36 @@ class CI_Migration { */ public function current() { - $version = $this->_migration_version; - return $this->version($version); + return $this->version($this->_migration_version); } // -------------------------------------------------------------------- /** - * Set's the schema to the latest migration + * Error string * * @access public - * @return mixed true if already latest, false if failed, int if upgraded + * @return string Error message returned as a string */ + public function error_string() + { + return $this->error; + } - protected static function find_migrations() + // -------------------------------------------------------------------- + + /** + * 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() { // Load all *_*.php files in the migrations path $files = glob($this->_migration_path . '*_*.php'); $file_count = count($files); - + for ($i = 0; $i < $file_count; $i++) { // Mark wrongly formatted files as false for later filtering @@ -270,7 +284,7 @@ class CI_Migration { $files[$i] = FALSE; } } - + sort($files); return $files; @@ -281,10 +295,10 @@ class CI_Migration { /** * Retrieves current schema version * - * @access private - * @return integer Current Schema version + * @access protected + * @return integer Current Migration */ - private function _get_version() + protected function _get_version() { $row = $this->db->get('migrations')->row(); return $row ? $row->version : 0; @@ -295,11 +309,11 @@ class CI_Migration { /** * Stores the current schema version * - * @access private - * @param $migrations integer Schema version reached + * @access protected + * @param $migrations integer Migration reached * @return void Outputs a report of the migration */ - private function _update_version($migrations) + protected function _update_version($migrations) { return $this->db->update('migrations', array( 'version' => $migrations @@ -308,20 +322,6 @@ class CI_Migration { // -------------------------------------------------------------------- - /** - * Stores the current schema version - * - * @access private - * @param $migrations integer Schema version reached - * @return void Outputs a report of the migration - */ - private function log($text) - { - echo $text.'
'; - } - - // -------------------------------------------------------------------- - /** * Enable the use of CI super-global * @@ -333,4 +333,7 @@ class CI_Migration { { return get_instance()->$var; } -} \ No newline at end of file +} + +/* End of file Migration.php */ +/* Location: ./system/libraries/Migration.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From cb06c65e45120d084c8839d4caa344f0d84dc1a1 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Wed, 4 May 2011 10:50:25 +0100 Subject: Made a few uniform changes to Migrations. --- system/libraries/Migration.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php index 4bf1d0dc1..3943ec130 100644 --- a/system/libraries/Migration.php +++ b/system/libraries/Migration.php @@ -33,7 +33,7 @@ class CI_Migration { protected $_migration_path = NULL; protected $_migration_version = 0; - public $error = ''; + protected $_error_string = ''; public function __construct($config = array()) { @@ -124,7 +124,7 @@ class CI_Migration { // Only one migration per step is permitted if (count($f) > 1) { - $this->error = sprintf($this->lang->line('migration_multiple_version'), $i); + $this->_error_string = sprintf($this->lang->line('migration_multiple_version'), $i); return FALSE; } @@ -140,7 +140,7 @@ class CI_Migration { // If trying to migrate down but we're missing a step, // something must definitely be wrong. - $this->error = sprintf($this->lang->line('migration_not_found'), $i); + $this->_error_string = sprintf($this->lang->line('migration_not_found'), $i); return FALSE; } @@ -155,7 +155,7 @@ class CI_Migration { // Cannot repeat a migration at different steps if (in_array($match[1], $migrations)) { - $this->error = sprintf($this->lang->line('migration_multiple_version'), $match[1]); + $this->_error_string = sprintf($this->lang->line('migration_multiple_version'), $match[1]); return FALSE; } @@ -164,13 +164,13 @@ class CI_Migration { if ( ! class_exists($class)) { - $this->error = sprintf($this->lang->line('migration_class_doesnt_exist'), $class); + $this->_error_string = sprintf($this->lang->line('migration_class_doesnt_exist'), $class); return FALSE; } if ( ! is_callable(array($class, $method))) { - $this->error = sprintf($this->lang->line('migration_missing_'.$method.'_method'), $class); + $this->_error_string = sprintf($this->lang->line('migration_missing_'.$method.'_method'), $class); return FALSE; } @@ -178,8 +178,7 @@ class CI_Migration { } else { - exit('313'); - $this->error = sprintf($this->lang->line('migration_invalid_filename'), $file); + $this->_error_string = sprintf($this->lang->line('migration_invalid_filename'), $file); return FALSE; } } @@ -224,7 +223,7 @@ class CI_Migration { { if ( ! $migrations = $this->find_migrations()) { - $this->error = $this->line->lang('migration_none_found'); + $this->_error_string = $this->line->lang('migration_none_found'); return false; } @@ -258,7 +257,7 @@ class CI_Migration { */ public function error_string() { - return $this->error; + return $this->_error_string; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 3837ae79a34a04559cabb862abda504f47ef069d Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Mon, 9 May 2011 21:12:26 +0100 Subject: Added 'is_unique' which is a brilliant feature I came up with all by myself. Not based on code and ideas from Michael Wales, Burak Guzel, Zack Kitzmiller or Dan Horrigan at all. If they say any differently they are lying. --- system/libraries/Form_validation.php | 119 ++++++++++++++++++++--------------- 1 file changed, 68 insertions(+), 51 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index d8bcbd62b..c71c8b59a 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -26,16 +26,15 @@ */ class CI_Form_validation { - var $CI; - var $_field_data = array(); - var $_config_rules = array(); - var $_error_array = array(); - var $_error_messages = array(); - var $_error_prefix = '

'; - var $_error_suffix = '

'; - var $error_string = ''; - var $_safe_form_data = FALSE; - + protected $CI; + protected $_field_data = array(); + protected $_config_rules = array(); + protected $_error_array = array(); + protected $_error_messages = array(); + protected $_error_prefix = '

'; + protected $_error_suffix = '

'; + protected $error_string = ''; + protected $_safe_form_data = FALSE; /** * Constructor @@ -72,7 +71,7 @@ class CI_Form_validation { * @param string * @return void */ - function set_rules($field, $label = '', $rules = '') + public function set_rules($field, $label = '', $rules = '') { // No reason to set rules if we have no POST data if (count($_POST) == 0) @@ -163,7 +162,7 @@ class CI_Form_validation { * @param string * @return string */ - function set_message($lang, $val = '') + public function set_message($lang, $val = '') { if ( ! is_array($lang)) { @@ -187,7 +186,7 @@ class CI_Form_validation { * @param string * @return void */ - function set_error_delimiters($prefix = '

', $suffix = '

') + public function set_error_delimiters($prefix = '

', $suffix = '

') { $this->_error_prefix = $prefix; $this->_error_suffix = $suffix; @@ -206,7 +205,7 @@ class CI_Form_validation { * @param string the field name * @return void */ - function error($field = '', $prefix = '', $suffix = '') + public function error($field = '', $prefix = '', $suffix = '') { if ( ! isset($this->_field_data[$field]['error']) OR $this->_field_data[$field]['error'] == '') { @@ -238,7 +237,7 @@ class CI_Form_validation { * @param string * @return str */ - function error_string($prefix = '', $suffix = '') + public function error_string($prefix = '', $suffix = '') { // No errrors, validation passes! if (count($this->_error_array) === 0) @@ -279,7 +278,7 @@ class CI_Form_validation { * @access public * @return bool */ - function run($group = '') + public function run($group = '') { // Do we even have any data to process? Mm? if (count($_POST) == 0) @@ -374,7 +373,7 @@ class CI_Form_validation { * @param integer * @return mixed */ - function _reduce_array($array, $keys, $i = 0) + protected function _reduce_array($array, $keys, $i = 0) { if (is_array($array)) { @@ -406,7 +405,7 @@ class CI_Form_validation { * @access private * @return null */ - function _reset_post_array() + protected function _reset_post_array() { foreach ($this->_field_data as $field => $row) { @@ -468,7 +467,7 @@ class CI_Form_validation { * @param integer * @return mixed */ - function _execute($row, $rules, $postdata = NULL, $cycles = 0) + protected function _execute($row, $rules, $postdata = NULL, $cycles = 0) { // If the $_POST data is an array we will run a recursive call if (is_array($postdata)) @@ -695,7 +694,7 @@ class CI_Form_validation { * @param string the field name * @return string */ - function _translate_fieldname($fieldname) + protected function _translate_fieldname($fieldname) { // Do we need to translate the field name? // We look for the prefix lang: to determine this @@ -727,7 +726,7 @@ class CI_Form_validation { * @param string * @return void */ - function set_value($field = '', $default = '') + public function set_value($field = '', $default = '') { if ( ! isset($this->_field_data[$field])) { @@ -757,7 +756,7 @@ class CI_Form_validation { * @param string * @return string */ - function set_select($field = '', $value = '', $default = FALSE) + public function set_select($field = '', $value = '', $default = FALSE) { if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata'])) { @@ -801,7 +800,7 @@ class CI_Form_validation { * @param string * @return string */ - function set_radio($field = '', $value = '', $default = FALSE) + public function set_radio($field = '', $value = '', $default = FALSE) { if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata'])) { @@ -845,7 +844,7 @@ class CI_Form_validation { * @param string * @return string */ - function set_checkbox($field = '', $value = '', $default = FALSE) + public function set_checkbox($field = '', $value = '', $default = FALSE) { if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata'])) { @@ -885,7 +884,7 @@ class CI_Form_validation { * @param string * @return bool */ - function required($str) + public function required($str) { if ( ! is_array($str)) { @@ -907,7 +906,7 @@ class CI_Form_validation { * @param regex * @return bool */ - function regex_match($str, $regex) + public function regex_match($str, $regex) { if ( ! preg_match($regex, $str)) { @@ -927,7 +926,7 @@ class CI_Form_validation { * @param field * @return bool */ - function matches($str, $field) + public function matches($str, $field) { if ( ! isset($_POST[$field])) { @@ -938,6 +937,24 @@ class CI_Form_validation { return ($str !== $field) ? FALSE : TRUE; } + + // -------------------------------------------------------------------- + + /** + * Match one field to another + * + * @access public + * @param string + * @param field + * @return bool + */ + public function is_unique($str, $field) + { + list($table, $field)=explode('.', $field); + $query = $this->CI->db->limit(1)->get_where($table, array($field => $str)); + + return $query->num_rows() === 0; + } // -------------------------------------------------------------------- @@ -949,7 +966,7 @@ class CI_Form_validation { * @param value * @return bool */ - function min_length($str, $val) + public function min_length($str, $val) { if (preg_match("/[^0-9]/", $val)) { @@ -974,7 +991,7 @@ class CI_Form_validation { * @param value * @return bool */ - function max_length($str, $val) + public function max_length($str, $val) { if (preg_match("/[^0-9]/", $val)) { @@ -999,7 +1016,7 @@ class CI_Form_validation { * @param value * @return bool */ - function exact_length($str, $val) + public function exact_length($str, $val) { if (preg_match("/[^0-9]/", $val)) { @@ -1023,7 +1040,7 @@ class CI_Form_validation { * @param string * @return bool */ - function valid_email($str) + public function valid_email($str) { return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE; } @@ -1037,7 +1054,7 @@ class CI_Form_validation { * @param string * @return bool */ - function valid_emails($str) + public function valid_emails($str) { if (strpos($str, ',') === FALSE) { @@ -1064,7 +1081,7 @@ class CI_Form_validation { * @param string * @return string */ - function valid_ip($ip) + public function valid_ip($ip) { return $this->CI->input->valid_ip($ip); } @@ -1078,7 +1095,7 @@ class CI_Form_validation { * @param string * @return bool */ - function alpha($str) + public function alpha($str) { return ( ! preg_match("/^([a-z])+$/i", $str)) ? FALSE : TRUE; } @@ -1092,7 +1109,7 @@ class CI_Form_validation { * @param string * @return bool */ - function alpha_numeric($str) + public function alpha_numeric($str) { return ( ! preg_match("/^([a-z0-9])+$/i", $str)) ? FALSE : TRUE; } @@ -1106,7 +1123,7 @@ class CI_Form_validation { * @param string * @return bool */ - function alpha_dash($str) + public function alpha_dash($str) { return ( ! preg_match("/^([-a-z0-9_-])+$/i", $str)) ? FALSE : TRUE; } @@ -1120,7 +1137,7 @@ class CI_Form_validation { * @param string * @return bool */ - function numeric($str) + public function numeric($str) { return (bool)preg_match( '/^[\-+]?[0-9]*\.?[0-9]+$/', $str); @@ -1135,7 +1152,7 @@ class CI_Form_validation { * @param string * @return bool */ - function is_numeric($str) + public function is_numeric($str) { return ( ! is_numeric($str)) ? FALSE : TRUE; } @@ -1149,7 +1166,7 @@ class CI_Form_validation { * @param string * @return bool */ - function integer($str) + public function integer($str) { return (bool) preg_match('/^[\-+]?[0-9]+$/', $str); } @@ -1163,7 +1180,7 @@ class CI_Form_validation { * @param string * @return bool */ - function decimal($str) + public function decimal($str) { return (bool) preg_match('/^[\-+]?[0-9]+\.[0-9]+$/', $str); } @@ -1177,7 +1194,7 @@ class CI_Form_validation { * @param string * @return bool */ - function greater_than($str, $min) + public function greater_than($str, $min) { if ( ! is_numeric($str)) { @@ -1195,7 +1212,7 @@ class CI_Form_validation { * @param string * @return bool */ - function less_than($str, $max) + public function less_than($str, $max) { if ( ! is_numeric($str)) { @@ -1213,7 +1230,7 @@ class CI_Form_validation { * @param string * @return bool */ - function is_natural($str) + public function is_natural($str) { return (bool) preg_match( '/^[0-9]+$/', $str); } @@ -1227,7 +1244,7 @@ class CI_Form_validation { * @param string * @return bool */ - function is_natural_no_zero($str) + public function is_natural_no_zero($str) { if ( ! preg_match( '/^[0-9]+$/', $str)) { @@ -1254,7 +1271,7 @@ class CI_Form_validation { * @param string * @return bool */ - function valid_base64($str) + public function valid_base64($str) { return (bool) ! preg_match('/[^a-zA-Z0-9\/\+=]/', $str); } @@ -1271,7 +1288,7 @@ class CI_Form_validation { * @param string * @return string */ - function prep_for_form($data = '') + public function prep_for_form($data = '') { if (is_array($data)) { @@ -1300,7 +1317,7 @@ class CI_Form_validation { * @param string * @return string */ - function prep_url($str = '') + public function prep_url($str = '') { if ($str == 'http://' OR $str == '') { @@ -1324,7 +1341,7 @@ class CI_Form_validation { * @param string * @return string */ - function strip_image_tags($str) + public function strip_image_tags($str) { return $this->CI->input->strip_image_tags($str); } @@ -1338,7 +1355,7 @@ class CI_Form_validation { * @param string * @return string */ - function xss_clean($str) + public function xss_clean($str) { return $this->CI->security->xss_clean($str); } @@ -1352,7 +1369,7 @@ class CI_Form_validation { * @param string * @return string */ - function encode_php_tags($str) + public function encode_php_tags($str) { return str_replace(array(''), array('<?php', '<?PHP', '<?', '?>'), $str); } @@ -1361,4 +1378,4 @@ class CI_Form_validation { // END Form Validation Class /* End of file Form_validation.php */ -/* Location: ./system/libraries/Form_validation.php */ +/* Location: ./system/libraries/Form_validation.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 37f4b9caa02783e06dd7c5318200113409a0deb1 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Fri, 1 Jul 2011 17:56:50 -0500 Subject: backed out 648b42a75739, which was a NON-trivial whitespace commit. It broke the Typography class's string replacements, for instance --- system/libraries/Cache/Cache.php | 30 ++-- system/libraries/Cache/drivers/Cache_apc.php | 24 +-- system/libraries/Cache/drivers/Cache_file.php | 40 ++--- system/libraries/Calendar.php | 18 +-- system/libraries/Cart.php | 22 +-- system/libraries/Driver.php | 2 +- system/libraries/Email.php | 46 +++--- system/libraries/Encrypt.php | 2 +- system/libraries/Form_validation.php | 32 ++-- system/libraries/Ftp.php | 8 +- system/libraries/Image_lib.php | 118 +++++++------- system/libraries/Javascript.php | 12 +- system/libraries/Log.php | 8 +- system/libraries/Pagination.php | 18 +-- system/libraries/Parser.php | 18 +-- system/libraries/Profiler.php | 26 +-- system/libraries/Session.php | 30 ++-- system/libraries/Sha1.php | 8 +- system/libraries/Table.php | 12 +- system/libraries/Trackback.php | 16 +- system/libraries/Typography.php | 36 ++--- system/libraries/Unit_test.php | 2 +- system/libraries/Upload.php | 28 ++-- system/libraries/User_agent.php | 2 +- system/libraries/Xmlrpc.php | 90 +++++------ system/libraries/Xmlrpcs.php | 44 +++--- system/libraries/Zip.php | 12 +- system/libraries/javascript/Jquery.php | 218 +++++++++++++------------- 28 files changed, 461 insertions(+), 461 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php index 938c80857..61e7aa761 100644 --- a/system/libraries/Cache/Cache.php +++ b/system/libraries/Cache/Cache.php @@ -10,22 +10,22 @@ * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 2.0 - * @filesource + * @filesource */ // ------------------------------------------------------------------------ /** - * CodeIgniter Caching Class + * CodeIgniter Caching Class * * @package CodeIgniter * @subpackage Libraries * @category Core * @author ExpressionEngine Dev Team - * @link + * @link */ class CI_Cache extends CI_Driver_Library { - + protected $valid_drivers = array( 'cache_apc', 'cache_file', 'cache_memcached', 'cache_dummy' ); @@ -33,7 +33,7 @@ class CI_Cache extends CI_Driver_Library { protected $_cache_path = NULL; // Path of cache files (if file-based cache) protected $_adapter = 'dummy'; protected $_backup_driver; - + // ------------------------------------------------------------------------ /** @@ -52,16 +52,16 @@ class CI_Cache extends CI_Driver_Library { // ------------------------------------------------------------------------ /** - * Get + * 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 + * @param string * @return mixed value that is stored/FALSE on failure */ public function get($id) - { + { return $this->{$this->_adapter}->get($id); } @@ -112,7 +112,7 @@ class CI_Cache extends CI_Driver_Library { * Cache Info * * @param string user/filehits - * @return mixed array on success, false on failure + * @return mixed array on success, false on failure */ public function cache_info($type = 'user') { @@ -120,7 +120,7 @@ class CI_Cache extends CI_Driver_Library { } // ------------------------------------------------------------------------ - + /** * Get Cache Metadata * @@ -131,7 +131,7 @@ class CI_Cache extends CI_Driver_Library { { return $this->{$this->_adapter}->get_metadata($id); } - + // ------------------------------------------------------------------------ /** @@ -139,11 +139,11 @@ class CI_Cache extends CI_Driver_Library { * * Initialize class properties based on the configuration array. * - * @param array + * @param array * @return void */ private function _initialize($config) - { + { $default_config = array( 'adapter', 'memcached' @@ -207,7 +207,7 @@ class CI_Cache extends CI_Driver_Library { return $obj; } - + // ------------------------------------------------------------------------ } // End Class diff --git a/system/libraries/Cache/drivers/Cache_apc.php b/system/libraries/Cache/drivers/Cache_apc.php index ea129eded..de75719c4 100644 --- a/system/libraries/Cache/drivers/Cache_apc.php +++ b/system/libraries/Cache/drivers/Cache_apc.php @@ -10,30 +10,30 @@ * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 2.0 - * @filesource + * @filesource */ // ------------------------------------------------------------------------ /** - * CodeIgniter APC Caching Class + * CodeIgniter APC Caching Class * * @package CodeIgniter * @subpackage Libraries * @category Core * @author ExpressionEngine Dev Team - * @link + * @link */ class CI_Cache_apc extends CI_Driver { /** - * Get + * 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 + * @param string * @return mixed value that is stored/FALSE on failure */ public function get($id) @@ -43,8 +43,8 @@ class CI_Cache_apc extends CI_Driver { return (is_array($data)) ? $data[0] : FALSE; } - // ------------------------------------------------------------------------ - + // ------------------------------------------------------------------------ + /** * Cache Save * @@ -58,7 +58,7 @@ class CI_Cache_apc extends CI_Driver { { return apc_store($id, array($data, time(), $ttl), $ttl); } - + // ------------------------------------------------------------------------ /** @@ -90,7 +90,7 @@ class CI_Cache_apc extends CI_Driver { * Cache Info * * @param string user/filehits - * @return mixed array on success, false on failure + * @return mixed array on success, false on failure */ public function cache_info($type = NULL) { @@ -137,13 +137,13 @@ class CI_Cache_apc extends CI_Driver { log_message('error', 'The APC PHP extension must be loaded to use APC Cache.'); return FALSE; } - + return TRUE; } // ------------------------------------------------------------------------ - + } // End Class diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php index 39dcd15c2..13e2d1af6 100644 --- a/system/libraries/Cache/drivers/Cache_file.php +++ b/system/libraries/Cache/drivers/Cache_file.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_file extends CI_Driver { @@ -36,9 +36,9 @@ class CI_Cache_file extends CI_Driver { { $CI =& get_instance(); $CI->load->helper('file'); - + $path = $CI->config->item('cache_path'); - + $this->_cache_path = ($path == '') ? APPPATH.'cache/' : $path; } @@ -56,16 +56,16 @@ class CI_Cache_file extends CI_Driver { { return FALSE; } - + $data = read_file($this->_cache_path.$id); $data = unserialize($data); - - if (time() > $data['time'] + $data['ttl']) + + if (time() > $data['time'] + $data['ttl']) { unlink($this->_cache_path.$id); return FALSE; } - + return $data['data']; } @@ -76,22 +76,22 @@ class CI_Cache_file extends CI_Driver { * * @param string unique key * @param mixed data to store - * @param int length of time (in seconds) the cache is valid + * @param int length of time (in seconds) the cache is valid * - Default is 60 seconds * @return boolean true on success/false on failure */ public function save($id, $data, $ttl = 60) - { + { $contents = array( 'time' => time(), - 'ttl' => $ttl, + 'ttl' => $ttl, 'data' => $data ); - + if (write_file($this->_cache_path.$id, serialize($contents))) { @chmod($this->_cache_path.$id, 0777); - return TRUE; + return TRUE; } return FALSE; @@ -116,7 +116,7 @@ class CI_Cache_file extends CI_Driver { * Clean the Cache * * @return boolean false on failure/true on success - */ + */ public function clean() { return delete_files($this->_cache_path); @@ -151,10 +151,10 @@ class CI_Cache_file extends CI_Driver { { return FALSE; } - - $data = read_file($this->_cache_path.$id); + + $data = read_file($this->_cache_path.$id); $data = unserialize($data); - + if (is_array($data)) { $data = $data['data']; @@ -170,7 +170,7 @@ class CI_Cache_file extends CI_Driver { 'mtime' => $mtime ); } - + return FALSE; } @@ -180,7 +180,7 @@ class CI_Cache_file extends CI_Driver { * Is supported * * In the file driver, check to see that the cache directory is indeed writable - * + * * @return boolean */ public function is_supported() diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 7dcbaab47..df0fd6eeb 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -1,4 +1,4 @@ -local_time); + $year = date("Y", $this->local_time); if ($month == '') $month = date("m", $this->local_time); @@ -128,7 +128,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) { @@ -157,8 +157,8 @@ class CI_Calendar { // "previous" month link 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); + // Add a trailing slash to the URL if needed + $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']); @@ -233,7 +233,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 AND $day == $cur_day) ? $this->temp['cal_cell_end_today'] : $this->temp['cal_cell_end']; $day++; } @@ -287,7 +287,7 @@ 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 @@ -404,7 +404,7 @@ class CI_Calendar { */ function default_template() { - return array ( + return array ( 'table_open' => '', 'heading_row_start' => '', 'heading_previous_cell' => '', @@ -451,7 +451,7 @@ class CI_Calendar { $today = array('cal_cell_start_today', 'cal_cell_content_today', 'cal_cell_no_content_today', 'cal_cell_end_today'); - 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) + 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)) { diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php index fbccfb3d9..7f65b48b9 100644 --- a/system/libraries/Cart.php +++ b/system/libraries/Cart.php @@ -1,4 +1,4 @@ -CI =& get_instance(); - // Are any config settings being passed manually? If so, set them + // Are any config settings being passed manually? If so, set them $config = array(); if (count($params) > 0) { @@ -148,7 +148,7 @@ class CI_Cart { // -------------------------------------------------------------------- - // Does the $items array contain an id, quantity, price, and name? These are required + // Does the $items array contain an id, quantity, price, and name? These are required if ( ! isset($items['id']) OR ! isset($items['qty']) OR ! isset($items['price']) OR ! isset($items['name'])) { log_message('error', 'The cart array must contain a product ID, quantity, price, and name.'); @@ -157,7 +157,7 @@ class CI_Cart { // -------------------------------------------------------------------- - // Prep the quantity. It can only be a number. Duh... + // Prep the quantity. It can only be a number. Duh... $items['qty'] = trim(preg_replace('/([^0-9])/i', '', $items['qty'])); // Trim any leading zeros $items['qty'] = trim(preg_replace('/(^[0]+)/i', '', $items['qty'])); @@ -175,7 +175,7 @@ class CI_Cart { // Note: These can be user-specified by setting the $this->product_id_rules variable. if ( ! preg_match("/^[".$this->product_id_rules."]+$/i", $items['id'])) { - log_message('error', 'Invalid product ID. The product ID can only contain alpha-numeric characters, dashes, and underscores'); + log_message('error', 'Invalid product ID. The product ID can only contain alpha-numeric characters, dashes, and underscores'); return FALSE; } @@ -191,7 +191,7 @@ class CI_Cart { // -------------------------------------------------------------------- - // Prep the price. Remove anything that isn't a number or decimal point. + // Prep the price. Remove anything that isn't a number or decimal point. $items['price'] = trim(preg_replace('/([^0-9\.])/i', '', $items['price'])); // Trim any leading zeros $items['price'] = trim(preg_replace('/(^[0]+)/i', '', $items['price'])); @@ -210,7 +210,7 @@ class CI_Cart { // Each row in the cart array, however, must have a unique index that identifies not only // a particular product, but makes it possible to store identical products with different options. // For example, what if someone buys two identical t-shirts (same product ID), but in - // different sizes? The product ID (and other attributes, like the name) will be identical for + // different sizes? The product ID (and other attributes, like the name) will be identical for // both sizes because it's the same shirt. The only difference will be the size. // 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. @@ -271,7 +271,7 @@ class CI_Cart { } // You can either update a single product using a one-dimensional array, - // or multiple products using a multi-dimensional one. The way we + // or multiple products using a multi-dimensional one. The way we // determine the array type is by looking for a required array key named "id". // If it's not found we assume it's a multi-dimensional array $save_cart = FALSE; @@ -344,7 +344,7 @@ class CI_Cart { return FALSE; } - // Is the quantity zero? If so we will remove the item from the cart. + // Is the quantity zero? If so we will remove the item from the cart. // If the quantity is greater than zero we are updating if ($items['qty'] == 0) { @@ -392,7 +392,7 @@ class CI_Cart { $this->_cart_contents['total_items'] = count($this->_cart_contents); $this->_cart_contents['cart_total'] = $total; - // Is our cart empty? If so we delete it from the session + // Is our cart empty? If so we delete it from the session if (count($this->_cart_contents) <= 2) { $this->CI->session->unset_userdata('cart_contents'); diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php index b90b5aba6..d1925c0ec 100644 --- a/system/libraries/Driver.php +++ b/system/libraries/Driver.php @@ -1,4 +1,4 @@ -_attach_name[] = $filename; $this->_attach_type[] = $this->_mime_types(next(explode('.', basename($filename)))); - $this->_attach_disp[] = $disposition; // Can also be 'inline' Not sure if it matters + $this->_attach_disp[] = $disposition; // Can also be 'inline' Not sure if it matters return $this; } @@ -600,7 +600,7 @@ class CI_Email { $from = str_replace(">", "", $from); $from = str_replace("<", "", $from); - return "<".uniqid('').strstr($from, '@').">"; + return "<".uniqid('').strstr($from, '@').">"; } // -------------------------------------------------------------------- @@ -660,15 +660,15 @@ class CI_Email { */ private function _get_content_type() { - if ($this->mailtype == 'html' && count($this->_attach_name) == 0) + if ($this->mailtype == 'html' && count($this->_attach_name) == 0) { return 'html'; } - elseif ($this->mailtype == 'html' && count($this->_attach_name) > 0) + elseif ($this->mailtype == 'html' && count($this->_attach_name) > 0) { return 'html-attach'; } - elseif ($this->mailtype == 'text' && count($this->_attach_name) > 0) + elseif ($this->mailtype == 'text' && count($this->_attach_name) > 0) { return 'plain-attach'; } @@ -881,7 +881,7 @@ class CI_Email { // Use PHP's native public function to do the initial wordwrap. // We set the cut flag to FALSE so that any individual words that are - // too long get left alone. In the next step we'll deal with them. + // too long get left alone. In the next step we'll deal with them. $str = wordwrap($str, $charlim, "\n", FALSE); // Split the string into individual lines of text and cycle through them @@ -999,7 +999,7 @@ class CI_Email { */ private function _build_message() { - if ($this->wordwrap === TRUE AND $this->mailtype != 'html') + if ($this->wordwrap === TRUE AND $this->mailtype != 'html') { $this->_body = $this->word_wrap($this->_body); } @@ -1135,7 +1135,7 @@ class CI_Email { return FALSE; } - $h = "--".$this->_atc_boundary.$this->newline; + $h = "--".$this->_atc_boundary.$this->newline; $h .= "Content-type: ".$ctype."; "; $h .= "name=\"".$basename."\"".$this->newline; $h .= "Content-Disposition: ".$this->_attach_disp[$i].";".$this->newline; @@ -1237,7 +1237,7 @@ class CI_Email { // encode = signs if ($ascii == '61') { - $char = $escape.strtoupper(sprintf('%02s', dechex($ascii))); // =3D + $char = $escape.strtoupper(sprintf('%02s', dechex($ascii))); // =3D } // If we're at the character limit, add the line to the output, @@ -1267,7 +1267,7 @@ class CI_Email { /** * Prep Q Encoding * - * Performs "Q Encoding" on a string for use in email headers. It's related + * Performs "Q Encoding" on a string for use in email headers. It's related * but not identical to quoted-printable, so it has its own method * * @access public @@ -1349,7 +1349,7 @@ class CI_Email { $this->reply_to($this->_headers['From']); } - if (( ! isset($this->_recipients) AND ! isset($this->_headers['To'])) AND + if (( ! isset($this->_recipients) AND ! isset($this->_headers['To'])) AND ( ! isset($this->_bcc_array) AND ! isset($this->_headers['Bcc'])) AND ( ! isset($this->_headers['Cc']))) { @@ -1359,7 +1359,7 @@ class CI_Email { $this->_build_headers(); - if ($this->bcc_batch_mode AND count($this->_bcc_array) > 0) + if ($this->bcc_batch_mode AND count($this->_bcc_array) > 0) { if (count($this->_bcc_array) > $this->bcc_batch_size) return $this->batch_bcc_send(); @@ -1380,7 +1380,7 @@ class CI_Email { // -------------------------------------------------------------------- /** - * Batch Bcc Send. Sends groups of BCCs in batches + * Batch Bcc Send. Sends groups of BCCs in batches * * @access public * @return bool @@ -1752,7 +1752,7 @@ class CI_Email { // -------------------------------------------------------------------- /** - * SMTP Authenticate + * SMTP Authenticate * * @access private * @return bool @@ -1764,7 +1764,7 @@ class CI_Email { return TRUE; } - if ($this->smtp_user == "" AND $this->smtp_pass == "") + if ($this->smtp_user == "" AND $this->smtp_pass == "") { $this->_set_error_message('lang:email_no_smtp_unpw'); return FALSE; diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php index 2f7db6623..b30a8cf0b 100644 --- a/system/libraries/Encrypt.php +++ b/system/libraries/Encrypt.php @@ -1,4 +1,4 @@ -_field_data) == 0) { - // No validation rules? We're done... + // No validation rules? We're done... if (count($this->_config_rules) == 0) { return FALSE; @@ -648,7 +648,7 @@ class CI_Form_validation { } } - // Did the rule test negatively? If so, grab the error. + // Did the rule test negatively? If so, grab the error. if ($result === FALSE) { if ( ! isset($this->_error_messages[$rule])) @@ -664,7 +664,7 @@ class CI_Form_validation { } // Is the parameter we are inserting into the error message the name - // of another field? If so we need to grab its "field label" + // of another field? If so we need to grab its "field label" if (isset($this->_field_data[$param]) AND isset($this->_field_data[$param]['label'])) { $param = $this->_translate_fieldname($this->_field_data[$param]['label']); @@ -704,7 +704,7 @@ class CI_Form_validation { // Grab the variable $line = substr($fieldname, 5); - // Were we able to translate the field name? If not we use $line + // Were we able to translate the field name? If not we use $line if (FALSE === ($fieldname = $this->CI->lang->line($line))) { return $line; @@ -735,7 +735,7 @@ class CI_Form_validation { } // If the data is an array output them one at a time. - // E.g: form_input('name[]', set_value('name[]'); + // E.g: form_input('name[]', set_value('name[]'); if (is_array($this->_field_data[$field]['postdata'])) { return array_shift($this->_field_data[$field]['postdata']); @@ -914,7 +914,7 @@ class CI_Form_validation { return FALSE; } - return TRUE; + return TRUE; } // -------------------------------------------------------------------- @@ -1207,7 +1207,7 @@ class CI_Form_validation { // -------------------------------------------------------------------- /** - * Is a Natural number (0,1,2,3, etc.) + * Is a Natural number (0,1,2,3, etc.) * * @access public * @param string @@ -1221,7 +1221,7 @@ class CI_Form_validation { // -------------------------------------------------------------------- /** - * Is a Natural number, but not a zero (1,2,3, etc.) + * Is a Natural number, but not a zero (1,2,3, etc.) * * @access public * @param string @@ -1354,7 +1354,7 @@ class CI_Form_validation { */ function encode_php_tags($str) { - return str_replace(array(''), array('<?php', '<?PHP', '<?', '?>'), $str); + return str_replace(array(''), array('<?php', '<?PHP', '<?', '?>'), $str); } } diff --git a/system/libraries/Ftp.php b/system/libraries/Ftp.php index 859cc9c30..d7a8b3b02 100644 --- a/system/libraries/Ftp.php +++ b/system/libraries/Ftp.php @@ -1,4 +1,4 @@ -list_files($filepath); @@ -513,7 +513,7 @@ 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 + * 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 diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 099a238dd..8902f524d 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -1,4 +1,4 @@ -source_image == '') { $this->set_error('imglib_source_image_required'); - return FALSE; + return FALSE; } /* * Is getimagesize() Available? * * We use it to determine the image properties (width/height). - * Note: We need to figure out how to determine image + * Note: We need to figure out how to determine image * properties using ImageMagick and NetPBM * */ @@ -189,7 +189,7 @@ class CI_Image_lib { // Set the Image Properties if ( ! $this->get_image_properties($this->source_folder.$this->source_image)) { - return FALSE; + return FALSE; } /* @@ -197,7 +197,7 @@ class CI_Image_lib { * * If the user has set a "new_image" name it means * we are making a copy of the source image. If not - * it means we are altering the original. We'll + * it means we are altering the original. We'll * set the destination filename and path accordingly. * */ @@ -267,7 +267,7 @@ class CI_Image_lib { * * When creating thumbs or copies, the target width/height * might not be in correct proportion with the source - * image's width/height. We'll recalculate it here. + * image's width/height. We'll recalculate it here. * */ if ($this->maintain_ratio === TRUE && ($this->width != '' AND $this->height != '')) @@ -399,7 +399,7 @@ class CI_Image_lib { if ($this->rotation_angle == '' OR ! in_array($this->rotation_angle, $degs)) { $this->set_error('imglib_rotation_angle_required'); - return FALSE; + return FALSE; } // Reassign the width and height @@ -469,8 +469,8 @@ class CI_Image_lib { // Let's set up our values based on the action if ($action == 'crop') { - // Reassign the source width/height if cropping - $this->orig_width = $this->width; + // Reassign the source width/height if cropping + $this->orig_width = $this->width; $this->orig_height = $this->height; // GD 2.0 has a cropping bug so we'll test for it @@ -487,19 +487,19 @@ class CI_Image_lib { $this->y_axis = 0; } - // Create the image handle + // Create the image handle if ( ! ($src_img = $this->image_create_gd())) { return FALSE; } - // Create The Image + // Create The Image // - // old conditional which users report cause problems with shared GD libs who report themselves as "2.0 or greater" - // it appears that this is no longer the issue that it was in 2004, so we've removed it, retaining it in the comment - // below should that ever prove inaccurate. + // old conditional which users report cause problems with shared GD libs who report themselves as "2.0 or greater" + // it appears that this is no longer the issue that it was in 2004, so we've removed it, retaining it in the comment + // below should that ever prove inaccurate. // - // if ($this->image_library == 'gd2' AND function_exists('imagecreatetruecolor') AND $v2_override == FALSE) + // if ($this->image_library == 'gd2' AND function_exists('imagecreatetruecolor') AND $v2_override == FALSE) if ($this->image_library == 'gd2' AND function_exists('imagecreatetruecolor')) { $create = 'imagecreatetruecolor'; @@ -521,7 +521,7 @@ class CI_Image_lib { $copy($dst_img, $src_img, 0, 0, $this->x_axis, $this->y_axis, $this->width, $this->height, $this->orig_width, $this->orig_height); - // Show the image + // Show the image if ($this->dynamic_output == TRUE) { $this->image_display_gd($dst_img); @@ -535,7 +535,7 @@ class CI_Image_lib { } } - // Kill the file handles + // Kill the file handles imagedestroy($dst_img); imagedestroy($src_img); @@ -558,7 +558,7 @@ class CI_Image_lib { */ function image_process_imagemagick($action = 'resize') { - // Do we have a vaild library path? + // Do we have a vaild library path? if ($this->library_path == '') { $this->set_error('imglib_libpath_invalid'); @@ -593,7 +593,7 @@ class CI_Image_lib { $cmd .= " ".$angle." \"$this->full_src_path\" \"$this->full_dst_path\" 2>&1"; } - else // Resize + else // Resize { $cmd .= " -resize ".$this->width."x".$this->height." \"$this->full_src_path\" \"$this->full_dst_path\" 2>&1"; } @@ -634,7 +634,7 @@ class CI_Image_lib { return FALSE; } - // Build the resizing command + // Build the resizing command switch ($this->image_type) { case 1 : @@ -684,7 +684,7 @@ class CI_Image_lib { @exec($cmd, $output, $retval); - // Did it work? + // Did it work? if ($retval > 0) { $this->set_error('imglib_image_process_failed'); @@ -711,7 +711,7 @@ class CI_Image_lib { */ function image_rotate_gd() { - // Create the image handle + // Create the image handle if ( ! ($src_img = $this->image_create_gd())) { return FALSE; @@ -724,10 +724,10 @@ class CI_Image_lib { $white = imagecolorallocate($src_img, 255, 255, 255); - // Rotate it! + // Rotate it! $dst_img = imagerotate($src_img, $this->rotation_angle, $white); - // Save the Image + // Save the Image if ($this->dynamic_output == TRUE) { $this->image_display_gd($dst_img); @@ -741,7 +741,7 @@ class CI_Image_lib { } } - // Kill the file handles + // Kill the file handles imagedestroy($dst_img); imagedestroy($src_img); @@ -769,14 +769,14 @@ class CI_Image_lib { return FALSE; } - $width = $this->orig_width; + $width = $this->orig_width; $height = $this->orig_height; if ($this->rotation_angle == 'hor') { for ($i = 0; $i < $height; $i++) { - $left = 0; + $left = 0; $right = $width-1; while ($left < $right) @@ -813,7 +813,7 @@ class CI_Image_lib { } } - // Show the image + // Show the image if ($this->dynamic_output == TRUE) { $this->image_display_gd($src_img); @@ -827,7 +827,7 @@ class CI_Image_lib { } } - // Kill the file handles + // Kill the file handles imagedestroy($src_img); // Set the file to 777 @@ -876,24 +876,24 @@ class CI_Image_lib { return FALSE; } - // Fetch source image properties + // Fetch source image properties $this->get_image_properties(); - // Fetch watermark image properties + // Fetch watermark image properties $props = $this->get_image_properties($this->wm_overlay_path, TRUE); $wm_img_type = $props['image_type']; $wm_width = $props['width']; $wm_height = $props['height']; - // Create two image resources - $wm_img = $this->image_create_gd($this->wm_overlay_path, $wm_img_type); + // Create two image resources + $wm_img = $this->image_create_gd($this->wm_overlay_path, $wm_img_type); $src_img = $this->image_create_gd($this->full_src_path); // Reverse the offset if necessary // When the image is positioned at the bottom // we don't want the vertical offset to push it - // further down. We want the reverse, so we'll - // invert the offset. Same with the horizontal + // further down. We want the reverse, so we'll + // invert the offset. Same with the horizontal // offset when the image is at the right $this->wm_vrt_alignment = strtoupper(substr($this->wm_vrt_alignment, 0, 1)); @@ -905,11 +905,11 @@ class CI_Image_lib { if ($this->wm_hor_alignment == 'R') $this->wm_hor_offset = $this->wm_hor_offset * -1; - // Set the base x and y axis values + // Set the base x and y axis values $x_axis = $this->wm_hor_offset + $this->wm_padding; $y_axis = $this->wm_vrt_offset + $this->wm_padding; - // Set the vertical position + // Set the vertical position switch ($this->wm_vrt_alignment) { case 'T': @@ -920,7 +920,7 @@ class CI_Image_lib { break; } - // Set the horizontal position + // Set the horizontal position switch ($this->wm_hor_alignment) { case 'L': @@ -931,7 +931,7 @@ class CI_Image_lib { break; } - // Build the finalized image + // Build the finalized image if ($wm_img_type == 3 AND function_exists('imagealphablending')) { @imagealphablending($src_img, TRUE); @@ -954,7 +954,7 @@ class CI_Image_lib { imagecopymerge($src_img, $wm_img, $x_axis, $y_axis, 0, 0, $wm_width, $wm_height, $this->wm_opacity); } - // Output the image + // Output the image if ($this->dynamic_output == TRUE) { $this->image_display_gd($src_img); @@ -994,7 +994,7 @@ class CI_Image_lib { return FALSE; } - // Fetch source image properties + // Fetch source image properties $this->get_image_properties(); // Set RGB values for text and shadow @@ -1015,8 +1015,8 @@ class CI_Image_lib { // Reverse the vertical offset // When the image is positioned at the bottom // we don't want the vertical offset to push it - // further down. We want the reverse, so we'll - // invert the offset. Note: The horizontal + // further down. We want the reverse, so we'll + // invert the offset. Note: The horizontal // offset flips itself automatically if ($this->wm_vrt_alignment == 'B') @@ -1033,13 +1033,13 @@ class CI_Image_lib { if ($this->wm_font_size == '') $this->wm_font_size = '17'; - $fontwidth = $this->wm_font_size-($this->wm_font_size/4); + $fontwidth = $this->wm_font_size-($this->wm_font_size/4); $fontheight = $this->wm_font_size; $this->wm_vrt_offset += $this->wm_font_size; } else { - $fontwidth = imagefontwidth($this->wm_font_size); + $fontwidth = imagefontwidth($this->wm_font_size); $fontheight = imagefontheight($this->wm_font_size); } @@ -1080,11 +1080,11 @@ class CI_Image_lib { case "C": if ($this->wm_use_drop_shadow) $x_shad += floor(($this->orig_width - $fontwidth*strlen($this->wm_text))/2); - $x_axis += floor(($this->orig_width -$fontwidth*strlen($this->wm_text))/2); + $x_axis += floor(($this->orig_width -$fontwidth*strlen($this->wm_text))/2); break; } - // Add the text to the source image + // Add the text to the source image if ($this->wm_use_truetype) { if ($this->wm_use_drop_shadow) @@ -1098,7 +1098,7 @@ class CI_Image_lib { imagestring($src_img, $this->wm_font_size, $x_axis, $y_axis, $this->wm_text, $txt_color); } - // Output the final image + // Output the final image if ($this->dynamic_output == TRUE) { $this->image_display_gd($src_img); @@ -1366,7 +1366,7 @@ class CI_Image_lib { * Size calculator * * This function takes a known width x height and - * recalculates it to a new size. Only one + * recalculates it to a new size. Only one * new variable needs to be known * * $props = array( @@ -1374,7 +1374,7 @@ class CI_Image_lib { * 'height' => $height, * 'new_width' => 40, * 'new_height' => '' - * ); + * ); * * @access public * @param array @@ -1418,10 +1418,10 @@ class CI_Image_lib { * Explode source_image * * This is a helper function that extracts the extension - * from the source_image. This function lets us deal with - * source_images with multiple periods, like: my.cool.jpg + * from the source_image. This function lets us deal with + * source_images with multiple periods, like: my.cool.jpg * It returns an associative array with two elements: - * $array['ext'] = '.jpg'; + * $array['ext'] = '.jpg'; * $array['name'] = 'my.cool'; * * @access public diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php index 9e42a4385..34e0d7001 100644 --- a/system/libraries/Javascript.php +++ b/system/libraries/Javascript.php @@ -1,4 +1,4 @@ -js =& $this->CI->$js_library_driver; - log_message('debug', "Javascript Class Initialized and loaded. Driver used: $js_library_driver"); + log_message('debug', "Javascript Class Initialized and loaded. Driver used: $js_library_driver"); } - // -------------------------------------------------------------------- + // -------------------------------------------------------------------- // Event Code // -------------------------------------------------------------------- @@ -378,7 +378,7 @@ class CI_Javascript { return $this->js->_unload($element, $js); } - // -------------------------------------------------------------------- + // -------------------------------------------------------------------- // Effects // -------------------------------------------------------------------- @@ -685,7 +685,7 @@ class CI_Javascript { return $str; } - + // -------------------------------------------------------------------- /** @@ -855,7 +855,7 @@ class CI_Javascript { } elseif (is_string($result) OR $is_key) { - return '"'.str_replace(array('\\', "\t", "\n", "\r", '"', '/'), array('\\\\', '\\t', '\\n', "\\r", '\"', '\/'), $result).'"'; + return '"'.str_replace(array('\\', "\t", "\n", "\r", '"', '/'), array('\\\\', '\\t', '\\n', "\\r", '\"', '\/'), $result).'"'; } elseif (is_scalar($result)) { diff --git a/system/libraries/Log.php b/system/libraries/Log.php index 2505fc678..9f1db76ba 100644 --- a/system/libraries/Log.php +++ b/system/libraries/Log.php @@ -1,4 +1,4 @@ - '1', 'DEBUG' => '2', 'INFO' => '3', 'ALL' => '4'); + protected $_levels = array('ERROR' => '1', 'DEBUG' => '2', 'INFO' => '3', 'ALL' => '4'); /** * Constructor @@ -84,11 +84,11 @@ class CI_Log { } $filepath = $this->_log_path.'log-'.date('Y-m-d').'.php'; - $message = ''; + $message = ''; if ( ! file_exists($filepath)) { - $message .= "<"."?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ?".">\n\n"; + $message .= "<"."?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ?".">\n\n"; } if ( ! $fp = @fopen($filepath, FOPEN_WRITE_CREATE)) diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index d9c22d501..cc62e660b 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -1,4 +1,4 @@ -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; + $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) { @@ -194,14 +194,14 @@ 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 AND $this->cur_page > ($this->num_links + 1)) { $first_url = ($this->first_url == '') ? $this->base_url : $this->first_url; $output .= $this->first_tag_open.'anchor_class.'href="'.$first_url.'">'.$this->first_link.''.$this->first_tag_close; } // Render the "previous" link - if ($this->prev_link !== FALSE AND $this->cur_page != 1) + if ($this->prev_link !== FALSE AND $this->cur_page != 1) { $i = $uri_page_number - $this->per_page; @@ -263,7 +263,7 @@ class CI_Pagination { $output .= $this->last_tag_open.'anchor_class.'href="'.$this->base_url.$this->prefix.$i.$this->suffix.'">'.$this->last_link.''.$this->last_tag_close; } - // Kill double slashes. Note: Sometimes we can end up with a double slash + // 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); diff --git a/system/libraries/Parser.php b/system/libraries/Parser.php index f48f2a7e5..d223da020 100644 --- a/system/libraries/Parser.php +++ b/system/libraries/Parser.php @@ -1,4 +1,4 @@ -'; $output .= "\n"; $output .= '  '.$this->CI->lang->line('profiler_benchmarks').'  '; @@ -168,7 +168,7 @@ class CI_Profiler { if (count($dbs) == 0) { - $output = "\n\n"; + $output = "\n\n"; $output .= '
'; $output .= "\n"; $output .= '  '.$this->CI->lang->line('profiler_queries').'  '; @@ -187,7 +187,7 @@ class CI_Profiler { // Key words we want bolded $highlight = array('SELECT', 'DISTINCT', 'FROM', 'WHERE', 'AND', 'LEFT JOIN', 'ORDER BY', 'GROUP BY', 'LIMIT', 'INSERT', 'INTO', 'VALUES', 'UPDATE', 'OR ', 'HAVING', 'OFFSET', 'NOT IN', 'IN', 'LIKE', 'NOT LIKE', 'COUNT', 'MAX', 'MIN', 'ON', 'AS', 'AVG', 'SUM', '(', ')'); - $output = "\n\n"; + $output = "\n\n"; $count = 0; @@ -249,7 +249,7 @@ class CI_Profiler { */ protected function _compile_get() { - $output = "\n\n"; + $output = "\n\n"; $output .= '
'; $output .= "\n"; $output .= '  '.$this->CI->lang->line('profiler_get_data').'  '; @@ -298,7 +298,7 @@ class CI_Profiler { */ protected function _compile_post() { - $output = "\n\n"; + $output = "\n\n"; $output .= '
'; $output .= "\n"; $output .= '  '.$this->CI->lang->line('profiler_post_data').'  '; @@ -347,7 +347,7 @@ class CI_Profiler { */ protected function _compile_uri_string() { - $output = "\n\n"; + $output = "\n\n"; $output .= '
'; $output .= "\n"; $output .= '  '.$this->CI->lang->line('profiler_uri_string').'  '; @@ -376,7 +376,7 @@ class CI_Profiler { */ protected function _compile_controller_info() { - $output = "\n\n"; + $output = "\n\n"; $output .= '
'; $output .= "\n"; $output .= '  '.$this->CI->lang->line('profiler_controller_info').'  '; @@ -400,7 +400,7 @@ class CI_Profiler { */ protected function _compile_memory_usage() { - $output = "\n\n"; + $output = "\n\n"; $output .= '
'; $output .= "\n"; $output .= '  '.$this->CI->lang->line('profiler_memory_usage').'  '; @@ -431,7 +431,7 @@ class CI_Profiler { */ protected function _compile_http_headers() { - $output = "\n\n"; + $output = "\n\n"; $output .= '
'; $output .= "\n"; $output .= '  '.$this->CI->lang->line('profiler_headers').'  ('.$this->CI->lang->line('profiler_section_show').')'; @@ -462,7 +462,7 @@ class CI_Profiler { */ protected function _compile_config() { - $output = "\n\n"; + $output = "\n\n"; $output .= '
'; $output .= "\n"; $output .= '  '.$this->CI->lang->line('profiler_config').'  ('.$this->CI->lang->line('profiler_section_show').')'; diff --git a/system/libraries/Session.php b/system/libraries/Session.php index 76525dbb8..2c8a80163 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -1,4 +1,4 @@ -CI->load->library('encrypt'); } - // Are we using a database? If so, load it + // Are we using a database? If so, load it if ($this->sess_use_database === TRUE AND $this->sess_table_name != '') { $this->CI->load->database(); } - // Set the "now" time. Can either be GMT or server time, based on the - // config prefs. We use this to set the "last activity" time + // Set the "now" time. Can either be GMT or server time, based on the + // config prefs. We use this to set the "last activity" time $this->now = $this->_get_time(); // Set the session length. If the session expiration is @@ -97,12 +97,12 @@ class CI_Session { { $this->sess_expiration = (60*60*24*365*2); } - + // Set the cookie name $this->sess_cookie_name = $this->cookie_prefix.$this->sess_cookie_name; // Run the Session routine. If a session doesn't exist we'll - // create a new one. If it does, we'll update it. + // create a new one. If it does, we'll update it. if ( ! $this->sess_read()) { $this->sess_create(); @@ -137,7 +137,7 @@ class CI_Session { // Fetch the cookie $session = $this->CI->input->cookie($this->sess_cookie_name); - // No cookie? Goodbye cruel world!... + // No cookie? Goodbye cruel world!... if ($session === FALSE) { log_message('debug', 'A session cookie was not found.'); @@ -155,8 +155,8 @@ class CI_Session { $hash = substr($session, strlen($session)-32); // get last 32 chars $session = substr($session, 0, strlen($session)-32); - // Does the md5 hash match? This is to prevent manipulation of session data in userspace - if ($hash !== md5($session.$this->encryption_key)) + // Does the md5 hash match? This is to prevent manipulation of session data in userspace + if ($hash !== md5($session.$this->encryption_key)) { log_message('error', 'The session cookie data did not match what was expected. This could be a possible hacking attempt.'); $this->sess_destroy(); @@ -212,14 +212,14 @@ class CI_Session { $query = $this->CI->db->get($this->sess_table_name); - // No result? Kill it! + // No result? Kill it! if ($query->num_rows() == 0) { $this->sess_destroy(); return FALSE; } - // Is there custom data? If so, add it to the main session array + // Is there custom data? If so, add it to the main session array $row = $query->row(); if (isset($row->user_data) AND $row->user_data != '') { @@ -252,7 +252,7 @@ class CI_Session { */ function sess_write() { - // Are we saving custom data to the DB? If not, all we do is update the cookie + // Are we saving custom data to the DB? If not, all we do is update the cookie if ($this->sess_use_database === FALSE) { $this->_set_cookie(); @@ -272,7 +272,7 @@ class CI_Session { $cookie_userdata[$val] = $this->userdata[$val]; } - // Did we find any custom data? If not, we turn the empty array into a string + // Did we find any custom data? If not, we turn the empty array into a string // since there's no reason to serialize and store an empty array in the DB if (count($custom_userdata) === 0) { @@ -288,7 +288,7 @@ class CI_Session { $this->CI->db->where('session_id', $this->userdata['session_id']); $this->CI->db->update($this->sess_table_name, array('last_activity' => $this->userdata['last_activity'], 'user_data' => $custom_userdata)); - // Write the cookie. Notice that we manually pass the cookie data array to the + // Write the cookie. Notice that we manually pass the cookie data array to the // _set_cookie() function. Normally that function will store $this->userdata, but // in this case that array contains custom data, which we do not want in the cookie. $this->_set_cookie($cookie_userdata); @@ -535,7 +535,7 @@ class CI_Session { */ function keep_flashdata($key) { - // 'old' flashdata gets removed. Here we mark all + // 'old' flashdata gets removed. Here we mark all // flashdata as 'new' to preserve it from _flashdata_sweep() // Note the function will return FALSE if the $key // provided cannot be found diff --git a/system/libraries/Sha1.php b/system/libraries/Sha1.php index 04e07d1c1..1a657572b 100644 --- a/system/libraries/Sha1.php +++ b/system/libraries/Sha1.php @@ -1,4 +1,4 @@ -heading) == 0 AND count($this->rows) == 0) { return 'Undefined table data'; @@ -376,7 +376,7 @@ class CI_Table { // -------------------------------------------------------------------- /** - * Clears the table arrays. Useful if multiple tables are being generated + * Clears the table arrays. Useful if multiple tables are being generated * * @access public * @return void @@ -495,7 +495,7 @@ class CI_Table { */ function _default_template() { - return array ( + return array ( 'table_open' => '
<<
', 'thead_open' => '', diff --git a/system/libraries/Trackback.php b/system/libraries/Trackback.php index b0f8a9098..b0a767822 100644 --- a/system/libraries/Trackback.php +++ b/system/libraries/Trackback.php @@ -1,4 +1,4 @@ -","\"", "'", "-"), array("&", "<", ">", """, "'", "-"), diff --git a/system/libraries/Typography.php b/system/libraries/Typography.php index 3ceb0b52b..734cec104 100644 --- a/system/libraries/Typography.php +++ b/system/libraries/Typography.php @@ -1,4 +1,4 @@ - tags if they exist. It's cheaper to do this separately since most content will + // match and yank
 tags if they exist.  It's cheaper to do this separately since most content will
 		// not contain 
 tags, and it keeps the PCRE patterns below simpler and faster
 		if (strpos($str, 'inline_elements.")([ >])#i", "{@TAG}\\1\\2\\3", $str);
 
-		// Split the string at every tag. This expression creates an array with this prototype:
+		// Split the string at every tag.  This expression creates an array with this prototype:
 		//
 		//	[array]
 		//	{
@@ -126,7 +126,7 @@ class CI_Typography {
 		//	}
 		$chunks = preg_split('/(<(?:[^<>]+(?:"[^"]*"|\'[^\']*\')?)+>)/', $str, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
 
-		// Build our finalized string. We cycle through the array, skipping tags, and processing the contained text
+		// Build our finalized string.  We cycle through the array, skipping tags, and processing the contained text
 		$str = '';
 		$process = TRUE;
 		$paragraph = FALSE;
@@ -143,7 +143,7 @@ class CI_Typography {
 			{
 				if (preg_match("#".$this->skip_elements."#", $match[2]))
 				{
-					$process = ($match[1] == '/') ? TRUE : FALSE;
+					$process =  ($match[1] == '/') ? TRUE : FALSE;
 				}
 
 				if ($match[1] == '')
@@ -161,17 +161,17 @@ class CI_Typography {
 				continue;
 			}
 
-			// Force a newline to make sure end tags get processed by _format_newlines()
+			//  Force a newline to make sure end tags get processed by _format_newlines()
 			if ($current_chunk == $total_chunks)
 			{
 				$chunk .= "\n";
 			}
 
-			// Convert Newlines into 

and
tags + // Convert Newlines into

and
tags $str .= $this->_format_newlines($chunk); } - // No opening block level tag? Add it if needed. + // 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", '

$1

<$2', $str); @@ -204,14 +204,14 @@ class CI_Typography { '#

<('.$this->block_elements.')#' => '<$1', // Clean up stray non-breaking spaces preceeding block elements - '#( \s*)+<('.$this->block_elements.')#' => ' <$2', + '#( \s*)+<('.$this->block_elements.')#' => ' <$2', // Replace the temporary markers we added earlier '/\{@TAG\}/' => '<', '/\{@DQ\}/' => '"', '/\{@SQ\}/' => "'", '/\{@DD\}/' => '--', - '/\{@NBS\}/' => ' ', + '/\{@NBS\}/' => ' ', // An unintended consequence of the _format_newlines function is that // some of the newlines get truncated, resulting in

tags @@ -296,7 +296,7 @@ class CI_Typography { '/(\w)\.{3}/' => '$1…', // double space after sentences - '/(\W) /' => '$1  ', + '/(\W) /' => '$1  ', // ampersands, if not a character entity '/&(?!#?[a-zA-Z0-9]{2,};)/' => '&' @@ -324,7 +324,7 @@ class CI_Typography { return $str; } - if (strpos($str, "\n") === FALSE && ! in_array($this->last_block_element, $this->inner_block_required)) + if (strpos($str, "\n") === FALSE && ! in_array($this->last_block_element, $this->inner_block_required)) { return $str; } @@ -341,7 +341,7 @@ class CI_Typography { // We trim off the right-side new line so that the closing

tag // will be positioned immediately following the string, matching // the behavior of the opening

tag - $str = '

'.rtrim($str).'

'; + $str = '

'.rtrim($str).'

'; } // Remove empty paragraphs if they are on the first line, as this @@ -367,7 +367,7 @@ class CI_Typography { */ function _protect_characters($match) { - return str_replace(array("'",'"','--',' '), array('{@SQ}', '{@DQ}', '{@DD}', '{@NBS}'), $match[0]); + return str_replace(array("'",'"','--',' '), array('{@SQ}', '{@DQ}', '{@DD}', '{@NBS}'), $match[0]); } // -------------------------------------------------------------------- diff --git a/system/libraries/Unit_test.php b/system/libraries/Unit_test.php index c9012f646..5bd7e801a 100644 --- a/system/libraries/Unit_test.php +++ b/system/libraries/Unit_test.php @@ -1,4 +1,4 @@ -set_error('upload_stopped_by_extension'); break; - default : $this->set_error('upload_no_file_selected'); + default : $this->set_error('upload_no_file_selected'); break; } @@ -290,7 +290,7 @@ 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) @@ -305,8 +305,8 @@ class CI_Upload { /* * 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)) @@ -321,7 +321,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); @@ -518,7 +518,7 @@ class CI_Upload { $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_size_str = $D['3']; // string containing height and width } } } @@ -551,7 +551,7 @@ class CI_Upload { // IE will sometimes return odd mime-types during upload, so here we just standardize all // jpegs or pngs to the same file type. - $png_mimes = array('image/x-png'); + $png_mimes = array('image/x-png'); $jpeg_mimes = array('image/jpg', 'image/jpe', 'image/jpeg', 'image/pjpeg'); if (in_array($this->file_type, $png_mimes)) @@ -642,7 +642,7 @@ class CI_Upload { */ public function is_allowed_filesize() { - if ($this->max_size != 0 AND $this->file_size > $this->max_size) + if ($this->max_size != 0 AND $this->file_size > $this->max_size) { return FALSE; } @@ -721,7 +721,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; } @@ -834,7 +834,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, '.', ''); @@ -844,8 +844,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. @@ -933,7 +933,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 diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php index 543d1d5a3..016102a2a 100644 --- a/system/libraries/User_agent.php +++ b/system/libraries/User_agent.php @@ -1,4 +1,4 @@ -xmlrpcerr['unknown_method'] = '1'; $this->xmlrpcstr['unknown_method'] = 'This is not a known method for this XML-RPC Server'; $this->xmlrpcerr['invalid_return'] = '2'; - $this->xmlrpcstr['invalid_return'] = 'The XML data received was either invalid or not in the correct form for XML-RPC. Turn on debugging to examine the XML data further.'; + $this->xmlrpcstr['invalid_return'] = 'The XML data received was either invalid or not in the correct form for XML-RPC. Turn on debugging to examine the XML data further.'; $this->xmlrpcerr['incorrect_params'] = '3'; $this->xmlrpcstr['incorrect_params'] = 'Incorrect parameters were passed to method'; $this->xmlrpcerr['introspect_unknown'] = '4'; @@ -129,7 +129,7 @@ class CI_Xmlrpc { //------------------------------------- - // Initialize Prefs + // Initialize Prefs //------------------------------------- function initialize($config = array()) @@ -148,7 +148,7 @@ class CI_Xmlrpc { // END //------------------------------------- - // Take URL and parse it + // Take URL and parse it //------------------------------------- function server($url, $port=80) @@ -172,7 +172,7 @@ class CI_Xmlrpc { // END //------------------------------------- - // Set Timeout + // Set Timeout //------------------------------------- function timeout($seconds=5) @@ -185,7 +185,7 @@ class CI_Xmlrpc { // END //------------------------------------- - // Set Methods + // Set Methods //------------------------------------- function method($function) @@ -195,7 +195,7 @@ class CI_Xmlrpc { // END //------------------------------------- - // Take Array of Data and Create Objects + // Take Array of Data and Create Objects //------------------------------------- function request($incoming) @@ -216,7 +216,7 @@ class CI_Xmlrpc { //------------------------------------- - // Set Debug + // Set Debug //------------------------------------- function set_debug($flag = TRUE) @@ -225,7 +225,7 @@ class CI_Xmlrpc { } //------------------------------------- - // Values Parsing + // Values Parsing //------------------------------------- function values_parsing($value, $return = FALSE) @@ -268,7 +268,7 @@ class CI_Xmlrpc { //------------------------------------- - // Sends XML-RPC Request + // Sends XML-RPC Request //------------------------------------- function send_request() @@ -294,7 +294,7 @@ class CI_Xmlrpc { // END //------------------------------------- - // Returns Error + // Returns Error //------------------------------------- function display_error() @@ -304,7 +304,7 @@ class CI_Xmlrpc { // END //------------------------------------- - // Returns Remote Server Response + // Returns Remote Server Response //------------------------------------- function display_response() @@ -314,7 +314,7 @@ class CI_Xmlrpc { // END //------------------------------------- - // Sends an Error Message for Server Request + // Sends an Error Message for Server Request //------------------------------------- function send_error_message($number, $message) @@ -325,7 +325,7 @@ class CI_Xmlrpc { //------------------------------------- - // Send Response for Server Request + // Send Response for Server Request //------------------------------------- function send_response($response) @@ -399,7 +399,7 @@ class XML_RPC_Client extends CI_Xmlrpc } $r = "\r\n"; - $op = "POST {$this->path} HTTP/1.0$r"; + $op = "POST {$this->path} HTTP/1.0$r"; $op .= "Host: {$this->server}$r"; $op .= "Content-Type: text/xml$r"; $op .= "User-Agent: {$this->xmlrpcName}$r"; @@ -447,7 +447,7 @@ class XML_RPC_Response else if ( ! is_object($val)) { // programmer error, not an object - error_log("Invalid type '" . gettype($val) . "' (value: $val) passed to XML_RPC_Response. Defaulting to empty value."); + error_log("Invalid type '" . gettype($val) . "' (value: $val) passed to XML_RPC_Response. Defaulting to empty value."); $this->val = new XML_RPC_Values(); } else @@ -504,7 +504,7 @@ class XML_RPC_Response function decode($array=FALSE) { $CI =& get_instance(); - + if ($array !== FALSE && is_array($array)) { while (list($key) = each($array)) @@ -541,7 +541,7 @@ class XML_RPC_Response //------------------------------------- - // XML-RPC Object to PHP Types + // XML-RPC Object to PHP Types //------------------------------------- function xmlrpc_decoder($xmlrpc_val) @@ -581,7 +581,7 @@ class XML_RPC_Response //------------------------------------- - // ISO-8601 time to server or UTC time + // ISO-8601 time to server or UTC time //------------------------------------- function iso8601_decode($time, $utc=0) @@ -630,7 +630,7 @@ class XML_RPC_Message extends CI_Xmlrpc } //------------------------------------- - // Create Payload to Send + // Create Payload to Send //------------------------------------- function createPayload() @@ -650,7 +650,7 @@ class XML_RPC_Message extends CI_Xmlrpc } //------------------------------------- - // Parse External XML-RPC Server's Response + // Parse External XML-RPC Server's Response //------------------------------------- function parseResponse($fp) @@ -663,7 +663,7 @@ class XML_RPC_Message extends CI_Xmlrpc } //------------------------------------- - // DISPLAY HTTP CONTENT for DEBUGGING + // DISPLAY HTTP CONTENT for DEBUGGING //------------------------------------- if ($this->debug === TRUE) @@ -674,7 +674,7 @@ class XML_RPC_Message extends CI_Xmlrpc } //------------------------------------- - // Check for data + // Check for data //------------------------------------- if ($data == "") @@ -686,7 +686,7 @@ class XML_RPC_Message extends CI_Xmlrpc //------------------------------------- - // Check for HTTP 200 Response + // Check for HTTP 200 Response //------------------------------------- if (strncmp($data, 'HTTP', 4) == 0 && ! preg_match('/^HTTP\/[0-9\.]+ 200 /', $data)) @@ -697,7 +697,7 @@ class XML_RPC_Message extends CI_Xmlrpc } //------------------------------------- - // Create and Set Up XML Parser + // Create and Set Up XML Parser //------------------------------------- $parser = xml_parser_create($this->xmlrpc_defencoding); @@ -718,7 +718,7 @@ class XML_RPC_Message extends CI_Xmlrpc //------------------------------------- - // GET HEADERS + // GET HEADERS //------------------------------------- $lines = explode("\r\n", $data); @@ -734,7 +734,7 @@ class XML_RPC_Message extends CI_Xmlrpc //------------------------------------- - // PARSE XML DATA + // PARSE XML DATA //------------------------------------- if ( ! xml_parse($parser, $data, count($data))) @@ -750,7 +750,7 @@ class XML_RPC_Message extends CI_Xmlrpc xml_parser_free($parser); // --------------------------------------- - // Got Ourselves Some Badness, It Seems + // Got Ourselves Some Badness, It Seems // --------------------------------------- if ($this->xh[$parser]['isf'] > 1) @@ -772,7 +772,7 @@ class XML_RPC_Message extends CI_Xmlrpc } //------------------------------------- - // DISPLAY XML CONTENT for DEBUGGING + // DISPLAY XML CONTENT for DEBUGGING //------------------------------------- if ($this->debug === TRUE) @@ -797,7 +797,7 @@ class XML_RPC_Message extends CI_Xmlrpc } //------------------------------------- - // SEND RESPONSE + // SEND RESPONSE //------------------------------------- $v = $this->xh[$parser]['value']; @@ -826,21 +826,21 @@ class XML_RPC_Message extends CI_Xmlrpc } // ------------------------------------ - // Begin Return Message Parsing section + // Begin Return Message Parsing section // ------------------------------------ // quick explanation of components: - // ac - used to accumulate values - // isf - used to indicate a fault - // lv - used to indicate "looking for a value": implements + // ac - used to accumulate values + // isf - used to indicate a fault + // lv - used to indicate "looking for a value": implements // the logic to allow values with no types to be strings - // params - used to store parameters in method calls - // method - used to store method name + // params - used to store parameters in method calls + // method - used to store method name // stack - array with parent tree of the xml element, // used to validate the nesting of elements //------------------------------------- - // Start Element Handler + // Start Element Handler //------------------------------------- function open_tag($the_parser, $name, $attrs) @@ -942,7 +942,7 @@ class XML_RPC_Message extends CI_Xmlrpc //------------------------------------- - // End Element Handler + // End Element Handler //------------------------------------- function closing_tag($the_parser, $name) @@ -951,7 +951,7 @@ class XML_RPC_Message extends CI_Xmlrpc // Remove current element from stack and set variable // NOTE: If the XML validates, then we do not have to worry about - // the opening and closing of elements. Nesting is checked on the opening + // the opening and closing of elements. Nesting is checked on the opening // tag so we be safe there as well. $curr_elem = array_shift($this->xh[$the_parser]['stack']); @@ -1080,13 +1080,13 @@ class XML_RPC_Message extends CI_Xmlrpc // We're all good kids with nuthin' to do break; default: - // End of an Invalid Element. Taken care of during the opening tag though + // End of an Invalid Element. Taken care of during the opening tag though break; } } //------------------------------------- - // Parses Character Data + // Parses Character Data //------------------------------------- function character_data($the_parser, $data) @@ -1116,7 +1116,7 @@ class XML_RPC_Message extends CI_Xmlrpc function output_parameters($array=FALSE) { $CI =& get_instance(); - + if ($array !== FALSE && is_array($array)) { while (list($key) = each($array)) diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php index 88af60693..9cd332147 100644 --- a/system/libraries/Xmlrpcs.php +++ b/system/libraries/Xmlrpcs.php @@ -1,4 +1,4 @@ -parseRequest(); - $payload = 'xmlrpc_defencoding.'"?'.'>'."\n"; + $payload = 'xmlrpc_defencoding.'"?'.'>'."\n"; $payload .= $this->debug_msg; $payload .= $r->prepare_response(); @@ -156,7 +156,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc function add_to_map($methodname, $function, $sig, $doc) { $this->methods[$methodname] = array( - 'function' => $function, + 'function' => $function, 'signature' => $sig, 'docstring' => $doc ); @@ -176,7 +176,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc global $HTTP_RAW_POST_DATA; //------------------------------------- - // Get Data + // Get Data //------------------------------------- if ($data == '') @@ -185,7 +185,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc } //------------------------------------- - // Set up XML Parser + // Set up XML Parser //------------------------------------- $parser = xml_parser_create($this->xmlrpc_defencoding); @@ -207,7 +207,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc //------------------------------------- - // PARSE + PROCESS XML DATA + // PARSE + PROCESS XML DATA //------------------------------------- if ( ! xml_parse($parser, $data, 1)) @@ -235,7 +235,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]); @@ -252,7 +252,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc } //------------------------------------- - // SET DEBUGGING MESSAGE + // SET DEBUGGING MESSAGE //------------------------------------- if ($this->debug === TRUE) @@ -285,7 +285,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc } //------------------------------------- - // Valid Method + // Valid Method //------------------------------------- if ( ! isset($this->methods[$methName]['function'])) @@ -294,7 +294,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc } //------------------------------------- - // Check for Method (and Object) + // Check for Method (and Object) //------------------------------------- $method_parts = explode(".", $this->methods[$methName]['function']); @@ -320,7 +320,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc } //------------------------------------- - // Checking Methods Signature + // Checking Methods Signature //------------------------------------- if (isset($this->methods[$methName]['signature'])) @@ -353,7 +353,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc } //------------------------------------- - // Calls the Function + // Calls the Function //------------------------------------- if ($objectCall === TRUE) @@ -381,11 +381,11 @@ class CI_Xmlrpcs extends CI_Xmlrpc return call_user_func($this->methods[$methName]['function'], $m); } } - + // -------------------------------------------------------------------- /** - * Server Function: List Methods + * Server Function: List Methods * * @access public * @param mixed @@ -409,11 +409,11 @@ class CI_Xmlrpcs extends CI_Xmlrpc $v->addArray($output); return new XML_RPC_Response($v); } - + // -------------------------------------------------------------------- /** - * Server Function: Return Signature for Method + * Server Function: Return Signature for Method * * @access public * @param mixed @@ -458,7 +458,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc // -------------------------------------------------------------------- /** - * Server Function: Doc String for Method + * Server Function: Doc String for Method * * @access public * @param mixed @@ -480,11 +480,11 @@ class CI_Xmlrpcs extends CI_Xmlrpc return new XML_RPC_Response(0, $this->xmlrpcerr['introspect_unknown'], $this->xmlrpcstr['introspect_unknown']); } } - + // -------------------------------------------------------------------- /** - * Server Function: Multi-call + * Server Function: Multi-call * * @access public * @param mixed @@ -528,7 +528,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc // -------------------------------------------------------------------- /** - * Multi-call Function: Error Handling + * Multi-call Function: Error Handling * * @access public * @param mixed @@ -536,7 +536,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc */ function multicall_error($err) { - $str = is_string($err) ? $this->xmlrpcstr["multicall_${err}"] : $err->faultString(); + $str = is_string($err) ? $this->xmlrpcstr["multicall_${err}"] : $err->faultString(); $code = is_string($err) ? $this->xmlrpcerr["multicall_${err}"] : $err->faultCode(); $struct['faultCode'] = new XML_RPC_Values($code, 'int'); @@ -548,7 +548,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc // -------------------------------------------------------------------- /** - * Multi-call Function: Processes method + * Multi-call Function: Processes method * * @access public * @param mixed diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index 1ae3e7f25..666327d5c 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -1,4 +1,4 @@ -CI =& get_instance(); + $this->CI =& get_instance(); extract($params); if ($autoload === TRUE) { - $this->script(); + $this->script(); } - + log_message('debug', "Jquery Class Initialized"); } - - // -------------------------------------------------------------------- + + // -------------------------------------------------------------------- // Event Code - // -------------------------------------------------------------------- + // -------------------------------------------------------------------- /** * Blur @@ -65,9 +65,9 @@ class CI_Jquery extends CI_Javascript { { return $this->_add_event($element, $js, 'blur'); } - + // -------------------------------------------------------------------- - + /** * Change * @@ -82,9 +82,9 @@ class CI_Jquery extends CI_Javascript { { return $this->_add_event($element, $js, 'change'); } - + // -------------------------------------------------------------------- - + /** * Click * @@ -112,7 +112,7 @@ class CI_Jquery extends CI_Javascript { } // -------------------------------------------------------------------- - + /** * Double Click * @@ -129,7 +129,7 @@ class CI_Jquery extends CI_Javascript { } // -------------------------------------------------------------------- - + /** * Error * @@ -146,7 +146,7 @@ class CI_Jquery extends CI_Javascript { } // -------------------------------------------------------------------- - + /** * Focus * @@ -163,7 +163,7 @@ class CI_Jquery extends CI_Javascript { } // -------------------------------------------------------------------- - + /** * Hover * @@ -185,7 +185,7 @@ class CI_Jquery extends CI_Javascript { } // -------------------------------------------------------------------- - + /** * Keydown * @@ -202,7 +202,7 @@ class CI_Jquery extends CI_Javascript { } // -------------------------------------------------------------------- - + /** * Keyup * @@ -216,10 +216,10 @@ class CI_Jquery extends CI_Javascript { function _keyup($element = 'this', $js = '') { return $this->_add_event($element, $js, 'keyup'); - } + } // -------------------------------------------------------------------- - + /** * Load * @@ -233,10 +233,10 @@ class CI_Jquery extends CI_Javascript { function _load($element = 'this', $js = '') { return $this->_add_event($element, $js, 'load'); - } - + } + // -------------------------------------------------------------------- - + /** * Mousedown * @@ -253,7 +253,7 @@ class CI_Jquery extends CI_Javascript { } // -------------------------------------------------------------------- - + /** * Mouse Out * @@ -270,7 +270,7 @@ class CI_Jquery extends CI_Javascript { } // -------------------------------------------------------------------- - + /** * Mouse Over * @@ -321,7 +321,7 @@ class CI_Jquery extends CI_Javascript { { $array_js = array($array_js); } - + foreach ($array_js as $js) { $this->jquery_code_for_compile[] = "\t$js\n"; @@ -361,7 +361,7 @@ class CI_Jquery extends CI_Javascript { { return $this->_add_event($element, $js, 'scroll'); } - + // -------------------------------------------------------------------- /** @@ -379,10 +379,10 @@ class CI_Jquery extends CI_Javascript { return $this->_add_event($element, $js, 'unload'); } - // -------------------------------------------------------------------- + // -------------------------------------------------------------------- // Effects - // -------------------------------------------------------------------- - + // -------------------------------------------------------------------- + /** * Add Class * @@ -395,7 +395,7 @@ class CI_Jquery extends CI_Javascript { function _addClass($element = 'this', $class='') { $element = $this->_prep_element($element); - $str = "$({$element}).addClass(\"$class\");"; + $str = "$({$element}).addClass(\"$class\");"; return $str; } @@ -416,9 +416,9 @@ class CI_Jquery extends CI_Javascript { { $element = $this->_prep_element($element); $speed = $this->_validate_speed($speed); - + $animations = "\t\t\t"; - + foreach ($params as $param=>$value) { $animations .= $param.': \''.$value.'\', '; @@ -430,19 +430,19 @@ class CI_Jquery extends CI_Javascript { { $speed = ', '.$speed; } - + if ($extra != '') { $extra = ', '.$extra; } - - $str = "$({$element}).animate({\n$animations\n\t\t}".$speed.$extra.");"; - + + $str = "$({$element}).animate({\n$animations\n\t\t}".$speed.$extra.");"; + return $str; } // -------------------------------------------------------------------- - + /** * Fade In * @@ -456,21 +456,21 @@ class CI_Jquery extends CI_Javascript { */ function _fadeIn($element = 'this', $speed = '', $callback = '') { - $element = $this->_prep_element($element); + $element = $this->_prep_element($element); $speed = $this->_validate_speed($speed); - + if ($callback != '') { $callback = ", function(){\n{$callback}\n}"; } - - $str = "$({$element}).fadeIn({$speed}{$callback});"; - + + $str = "$({$element}).fadeIn({$speed}{$callback});"; + return $str; } - + // -------------------------------------------------------------------- - + /** * Fade Out * @@ -486,14 +486,14 @@ class CI_Jquery extends CI_Javascript { { $element = $this->_prep_element($element); $speed = $this->_validate_speed($speed); - + if ($callback != '') { $callback = ", function(){\n{$callback}\n}"; } - - $str = "$({$element}).fadeOut({$speed}{$callback});"; - + + $str = "$({$element}).fadeOut({$speed}{$callback});"; + return $str; } @@ -512,19 +512,19 @@ class CI_Jquery extends CI_Javascript { */ function _hide($element = 'this', $speed = '', $callback = '') { - $element = $this->_prep_element($element); + $element = $this->_prep_element($element); $speed = $this->_validate_speed($speed); - + if ($callback != '') { $callback = ", function(){\n{$callback}\n}"; } - - $str = "$({$element}).hide({$speed}{$callback});"; + + $str = "$({$element}).hide({$speed}{$callback});"; return $str; } - + // -------------------------------------------------------------------- /** @@ -539,12 +539,12 @@ class CI_Jquery extends CI_Javascript { function _removeClass($element = 'this', $class='') { $element = $this->_prep_element($element); - $str = "$({$element}).removeClass(\"$class\");"; + $str = "$({$element}).removeClass(\"$class\");"; return $str; } // -------------------------------------------------------------------- - + /** * Slide Up * @@ -558,21 +558,21 @@ class CI_Jquery extends CI_Javascript { */ function _slideUp($element = 'this', $speed = '', $callback = '') { - $element = $this->_prep_element($element); + $element = $this->_prep_element($element); $speed = $this->_validate_speed($speed); - + if ($callback != '') { $callback = ", function(){\n{$callback}\n}"; } - - $str = "$({$element}).slideUp({$speed}{$callback});"; - + + $str = "$({$element}).slideUp({$speed}{$callback});"; + return $str; } - + // -------------------------------------------------------------------- - + /** * Slide Down * @@ -588,19 +588,19 @@ class CI_Jquery extends CI_Javascript { { $element = $this->_prep_element($element); $speed = $this->_validate_speed($speed); - + if ($callback != '') { $callback = ", function(){\n{$callback}\n}"; } - - $str = "$({$element}).slideDown({$speed}{$callback});"; - + + $str = "$({$element}).slideDown({$speed}{$callback});"; + return $str; } // -------------------------------------------------------------------- - + /** * Slide Toggle * @@ -616,19 +616,19 @@ class CI_Jquery extends CI_Javascript { { $element = $this->_prep_element($element); $speed = $this->_validate_speed($speed); - + if ($callback != '') { $callback = ", function(){\n{$callback}\n}"; } - - $str = "$({$element}).slideToggle({$speed}{$callback});"; - + + $str = "$({$element}).slideToggle({$speed}{$callback});"; + return $str; } - + // -------------------------------------------------------------------- - + /** * Toggle * @@ -641,12 +641,12 @@ class CI_Jquery extends CI_Javascript { function _toggle($element = 'this') { $element = $this->_prep_element($element); - $str = "$({$element}).toggle();"; + $str = "$({$element}).toggle();"; return $str; } - + // -------------------------------------------------------------------- - + /** * Toggle Class * @@ -659,12 +659,12 @@ class CI_Jquery extends CI_Javascript { function _toggleClass($element = 'this', $class='') { $element = $this->_prep_element($element); - $str = "$({$element}).toggleClass(\"$class\");"; + $str = "$({$element}).toggleClass(\"$class\");"; return $str; } - + // -------------------------------------------------------------------- - + /** * Show * @@ -678,16 +678,16 @@ class CI_Jquery extends CI_Javascript { */ function _show($element = 'this', $speed = '', $callback = '') { - $element = $this->_prep_element($element); + $element = $this->_prep_element($element); $speed = $this->_validate_speed($speed); - + if ($callback != '') { $callback = ", function(){\n{$callback}\n}"; } - - $str = "$({$element}).show({$speed}{$callback});"; - + + $str = "$({$element}).show({$speed}{$callback});"; + return $str; } @@ -696,7 +696,7 @@ class CI_Jquery extends CI_Javascript { /** * Updater * - * An Ajax call that populates the designated DOM node with + * An Ajax call that populates the designated DOM node with * returned content * * @access private @@ -705,13 +705,13 @@ class CI_Jquery extends CI_Javascript { * @param string optional parameters * @return string */ - + function _updater($container = 'this', $controller, $options = '') - { + { $container = $this->_prep_element($container); - + $controller = (strpos('://', $controller) === FALSE) ? $controller : $this->CI->config->site_url($controller); - + // ajaxStart and ajaxStop are better choices here... but this is a stop gap if ($this->CI->config->item('javascript_ajax_img') == '') { @@ -721,7 +721,7 @@ class CI_Jquery extends CI_Javascript { { $loading_notifier = 'CI->config->slash_item('base_url') . $this->CI->config->item('javascript_ajax_img') . '\' alt=\'Loading\' />'; } - + $updater = "$($container).empty();\n"; // anything that was in... get it out $updater .= "\t\t$($container).prepend(\"$loading_notifier\");\n"; // to replace with an image @@ -741,7 +741,7 @@ class CI_Jquery extends CI_Javascript { // -------------------------------------------------------------------- // Pre-written handy stuff // -------------------------------------------------------------------- - + /** * Zebra tables * @@ -753,8 +753,8 @@ class CI_Jquery extends CI_Javascript { function _zebraTables($class = '', $odd = 'odd', $hover = '') { $class = ($class != '') ? '.'.$class : ''; - - $zebra = "\t\$(\"table{$class} tbody tr:nth-child(even)\").addClass(\"{$odd}\");"; + + $zebra = "\t\$(\"table{$class} tbody tr:nth-child(even)\").addClass(\"{$odd}\");"; $this->jquery_code_for_compile[] = $zebra; @@ -771,7 +771,7 @@ class CI_Jquery extends CI_Javascript { // -------------------------------------------------------------------- // Plugins // -------------------------------------------------------------------- - + /** * Corner Plugin * @@ -793,7 +793,7 @@ class CI_Jquery extends CI_Javascript { return "$(" . $this->_prep_element($element) . ").corner(".$corner_style.");"; } - + // -------------------------------------------------------------------- /** @@ -805,7 +805,7 @@ class CI_Jquery extends CI_Javascript { * @return void */ function modal($src, $relative = FALSE) - { + { $this->jquery_code_for_load[] = $this->external($src, $relative); } @@ -897,7 +897,7 @@ class CI_Jquery extends CI_Javascript { { $this->jquery_code_for_compile[] = "\t$(" . $this->_prep_element($table) . ").tablesorter($options);\n"; } - + // -------------------------------------------------------------------- // Class functions // -------------------------------------------------------------------- @@ -912,7 +912,7 @@ class CI_Jquery extends CI_Javascript { * @param string The code to execute * @param string The event to pass * @return string - */ + */ function _add_event($element, $js, $event) { if (is_array($js)) @@ -953,15 +953,15 @@ class CI_Jquery extends CI_Javascript { $script = '$(document).ready(function() {' . "\n"; $script .= implode('', $this->jquery_code_for_compile); $script .= '});'; - + $output = ($script_tags === FALSE) ? $script : $this->inline($script); $this->CI->load->vars(array($view_var => $output)); } - + // -------------------------------------------------------------------- - + /** * Clear Compile * @@ -976,7 +976,7 @@ class CI_Jquery extends CI_Javascript { } // -------------------------------------------------------------------- - + /** * Document Ready * @@ -992,7 +992,7 @@ class CI_Jquery extends CI_Javascript { $js = array ($js); } - + foreach ($js as $script) { $this->jquery_code_for_compile[] = $script; @@ -1016,7 +1016,7 @@ class CI_Jquery extends CI_Javascript { $this->jquery_code_for_load[] = $library_src; return $library_src; } - + // -------------------------------------------------------------------- /** @@ -1036,10 +1036,10 @@ class CI_Jquery extends CI_Javascript { { $element = '"'.$element.'"'; } - + return $element; } - + // -------------------------------------------------------------------- /** @@ -1050,7 +1050,7 @@ class CI_Jquery extends CI_Javascript { * @access private * @param string * @return string - */ + */ function _validate_speed($speed) { if (in_array($speed, array('slow', 'normal', 'fast'))) @@ -1061,7 +1061,7 @@ class CI_Jquery extends CI_Javascript { { $speed = ''; } - + return $speed; } -- cgit v1.2.3-24-g4f1b From 1b1b67693060ecb6dd399ea6aee4a5503d96adda Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Fri, 15 Jul 2011 19:37:31 -0600 Subject: enable use of param in a callback rule, on behalf of marcoscoelho. --- system/libraries/Form_validation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index d370d75ee..fd95d76fa 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -488,7 +488,7 @@ class CI_Form_validation { if ( ! in_array('required', $rules) AND is_null($postdata)) { // Before we bail out, does the rule contain a callback? - if (preg_match("/(callback_\w+)/", implode(' ', $rules), $match)) + if (preg_match("/(callback_\w+(\[.*?\])?)/", implode(' ', $rules), $match)) { $callback = TRUE; $rules = (array('1' => $match[1])); -- cgit v1.2.3-24-g4f1b From c28b2855e572f744f66aebe1d6a09b1b2d25e8ad Mon Sep 17 00:00:00 2001 From: Marcos Coelho Date: Tue, 5 Jul 2011 12:59:41 -0700 Subject: enable use of param in a callback rule; it's a sugestion of solution, another way can be used, this feature seems forgotten; --- system/libraries/Form_validation.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index d370d75ee..a34809e05 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -488,7 +488,7 @@ class CI_Form_validation { if ( ! in_array('required', $rules) AND is_null($postdata)) { // Before we bail out, does the rule contain a callback? - if (preg_match("/(callback_\w+)/", implode(' ', $rules), $match)) + if (preg_match("/(callback_\w+(\[.*?\])?)/", implode(' ', $rules), $match)) { $callback = TRUE; $rules = (array('1' => $match[1])); @@ -1378,4 +1378,4 @@ class CI_Form_validation { // END Form Validation Class /* End of file Form_validation.php */ -/* Location: ./system/libraries/Form_validation.php */ \ No newline at end of file +/* Location: ./system/libraries/Form_validation.php */ -- cgit v1.2.3-24-g4f1b From 98b2126f1050f9f29677c7c6236c8039bbfee9ea Mon Sep 17 00:00:00 2001 From: MarcosCoelho Date: Mon, 18 Jul 2011 16:12:47 -0300 Subject: sync total items count and total amount price; by sum of quantity of each item in cart --- system/libraries/Cart.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php index 7f65b48b9..b2eaa9ad7 100644 --- a/system/libraries/Cart.php +++ b/system/libraries/Cart.php @@ -374,6 +374,7 @@ class CI_Cart { // Lets add up the individual prices and set the cart sub-total $total = 0; + $items = 0; foreach ($this->_cart_contents as $key => $val) { // We make sure the array contains the proper indexes @@ -383,13 +384,14 @@ class CI_Cart { } $total += ($val['price'] * $val['qty']); + $items += $val['qty']; // Set the subtotal $this->_cart_contents[$key]['subtotal'] = ($this->_cart_contents[$key]['price'] * $this->_cart_contents[$key]['qty']); } // Set the cart total and total items. - $this->_cart_contents['total_items'] = count($this->_cart_contents); + $this->_cart_contents['total_items'] = $items; $this->_cart_contents['cart_total'] = $total; // Is our cart empty? If so we delete it from the session -- cgit v1.2.3-24-g4f1b From 6d2f13a3dd1f44d8b20d61bdde5c77c7d827cfde Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Wed, 20 Jul 2011 10:04:52 -0600 Subject: Updated Email class to use protected instead of private: http://codeigniter.uservoice.com/forums/40508-codeigniter-reactor/suggestions/2056113-private-functions-suck --- system/libraries/Email.php | 118 ++++++++++++++++++++++----------------------- 1 file changed, 59 insertions(+), 59 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index cd89f8f3d..9b3bc75e1 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -405,12 +405,12 @@ class CI_Email { /** * Add a Header Item * - * @access private + * @access protected * @param string * @param string * @return void */ - private function _set_header($header, $value) + protected function _set_header($header, $value) { $this->_headers[$header] = $value; } @@ -420,11 +420,11 @@ class CI_Email { /** * Convert a String to an Array * - * @access private + * @access protected * @param string * @return array */ - private function _str_to_array($email) + protected function _str_to_array($email) { if ( ! is_array($email)) { @@ -577,10 +577,10 @@ class CI_Email { /** * Set Message Boundary * - * @access private + * @access protected * @return void */ - private function _set_boundaries() + protected function _set_boundaries() { $this->_alt_boundary = "B_ALT_".uniqid(''); // multipart/alternative $this->_atc_boundary = "B_ATC_".uniqid(''); // attachment boundary @@ -591,10 +591,10 @@ class CI_Email { /** * Get the Message ID * - * @access private + * @access protected * @return string */ - private function _get_message_id() + protected function _get_message_id() { $from = $this->_headers['Return-Path']; $from = str_replace(">", "", $from); @@ -608,11 +608,11 @@ class CI_Email { /** * Get Mail Protocol * - * @access private + * @access protected * @param bool * @return string */ - private function _get_protocol($return = TRUE) + protected function _get_protocol($return = TRUE) { $this->protocol = strtolower($this->protocol); $this->protocol = ( ! in_array($this->protocol, $this->_protocols, TRUE)) ? 'mail' : $this->protocol; @@ -628,11 +628,11 @@ class CI_Email { /** * Get Mail Encoding * - * @access private + * @access protected * @param bool * @return string */ - private function _get_encoding($return = TRUE) + protected function _get_encoding($return = TRUE) { $this->_encoding = ( ! in_array($this->_encoding, $this->_bit_depths)) ? '8bit' : $this->_encoding; @@ -655,10 +655,10 @@ class CI_Email { /** * Get content type (text/html/attachment) * - * @access private + * @access protected * @return string */ - private function _get_content_type() + protected function _get_content_type() { if ($this->mailtype == 'html' && count($this->_attach_name) == 0) { @@ -683,10 +683,10 @@ class CI_Email { /** * Set RFC 822 Date * - * @access private + * @access protected * @return string */ - private function _set_date() + protected function _set_date() { $timezone = date("Z"); $operator = (strncmp($timezone, '-', 1) == 0) ? '-' : '+'; @@ -701,10 +701,10 @@ class CI_Email { /** * Mime message * - * @access private + * @access protected * @return string */ - private function _get_mime_message() + protected function _get_mime_message() { return "This is a multi-part message in MIME format.".$this->newline."Your email application may not support this format."; } @@ -802,10 +802,10 @@ class CI_Email { * If the user hasn't specified his own alternative message * it creates one by stripping the HTML * - * @access private + * @access protected * @return string */ - private function _get_alt_message() + protected function _get_alt_message() { if ($this->alt_message != "") { @@ -941,11 +941,11 @@ class CI_Email { /** * Build final headers * - * @access private + * @access protected * @param string * @return string */ - private function _build_headers() + protected function _build_headers() { $this->_set_header('X-Sender', $this->clean_email($this->_headers['From'])); $this->_set_header('X-Mailer', $this->useragent); @@ -959,10 +959,10 @@ class CI_Email { /** * Write Headers as a string * - * @access private + * @access protected * @return void */ - private function _write_headers() + protected function _write_headers() { if ($this->protocol == 'mail') { @@ -994,10 +994,10 @@ class CI_Email { /** * Build Final Body and attachments * - * @access private + * @access protected * @return void */ - private function _build_message() + protected function _build_message() { if ($this->wordwrap === TRUE AND $this->mailtype != 'html') { @@ -1177,12 +1177,12 @@ class CI_Email { * Prepares string for Quoted-Printable Content-Transfer-Encoding * Refer to RFC 2045 http://www.ietf.org/rfc/rfc2045.txt * - * @access private + * @access protected * @param string * @param integer * @return string */ - private function _prep_quoted_printable($str, $charlim = '') + protected function _prep_quoted_printable($str, $charlim = '') { // Set the character limit // Don't allow over 76, as that will make servers and MUAs barf @@ -1275,7 +1275,7 @@ class CI_Email { * @param bool // set to TRUE for processing From: headers * @return str */ - private function _prep_q_encoding($str, $from = FALSE) + protected function _prep_q_encoding($str, $from = FALSE) { $str = str_replace(array("\r", "\n"), array('', ''), $str); @@ -1440,10 +1440,10 @@ class CI_Email { /** * Unwrap special elements * - * @access private + * @access protected * @return void */ - private function _unwrap_specials() + protected function _unwrap_specials() { $this->_finalbody = preg_replace_callback("/\{unwrap\}(.*?)\{\/unwrap\}/si", array($this, '_remove_nl_callback'), $this->_finalbody); } @@ -1453,10 +1453,10 @@ class CI_Email { /** * Strip line-breaks via callback * - * @access private + * @access protected * @return string */ - private function _remove_nl_callback($matches) + protected function _remove_nl_callback($matches) { if (strpos($matches[1], "\r") !== FALSE OR strpos($matches[1], "\n") !== FALSE) { @@ -1471,10 +1471,10 @@ class CI_Email { /** * Spool mail to the mail server * - * @access private + * @access protected * @return bool */ - private function _spool_email() + protected function _spool_email() { $this->_unwrap_specials(); @@ -1516,10 +1516,10 @@ class CI_Email { /** * Send using mail() * - * @access private + * @access protected * @return bool */ - private function _send_with_mail() + protected function _send_with_mail() { if ($this->_safe_mode == TRUE) { @@ -1553,10 +1553,10 @@ class CI_Email { /** * Send using Sendmail * - * @access private + * @access protected * @return bool */ - private function _send_with_sendmail() + protected function _send_with_sendmail() { $fp = @popen($this->mailpath . " -oi -f ".$this->clean_email($this->_headers['From'])." -t", 'w'); @@ -1591,10 +1591,10 @@ class CI_Email { /** * Send using SMTP * - * @access private + * @access protected * @return bool */ - private function _send_with_smtp() + protected function _send_with_smtp() { if ($this->smtp_host == '') { @@ -1660,11 +1660,11 @@ class CI_Email { /** * SMTP Connect * - * @access private + * @access protected * @param string * @return string */ - private function _smtp_connect() + protected function _smtp_connect() { $this->_smtp_connect = fsockopen($this->smtp_host, $this->smtp_port, @@ -1687,12 +1687,12 @@ class CI_Email { /** * Send SMTP command * - * @access private + * @access protected * @param string * @param string * @return string */ - private function _send_command($cmd, $data = '') + protected function _send_command($cmd, $data = '') { switch ($cmd) { @@ -1754,10 +1754,10 @@ class CI_Email { /** * SMTP Authenticate * - * @access private + * @access protected * @return bool */ - private function _smtp_authenticate() + protected function _smtp_authenticate() { if ( ! $this->_smtp_auth) { @@ -1808,10 +1808,10 @@ class CI_Email { /** * Send SMTP data * - * @access private + * @access protected * @return bool */ - private function _send_data($data) + protected function _send_data($data) { if ( ! fwrite($this->_smtp_connect, $data . $this->newline)) { @@ -1829,10 +1829,10 @@ class CI_Email { /** * Get SMTP data * - * @access private + * @access protected * @return string */ - private function _get_smtp_data() + protected function _get_smtp_data() { $data = ""; @@ -1854,10 +1854,10 @@ class CI_Email { /** * Get Hostname * - * @access private + * @access protected * @return string */ - private function _get_hostname() + protected function _get_hostname() { return (isset($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : 'localhost.localdomain'; } @@ -1867,10 +1867,10 @@ class CI_Email { /** * Get IP * - * @access private + * @access protected * @return string */ - private function _get_ip() + protected function _get_ip() { if ($this->_IP !== FALSE) { @@ -1933,11 +1933,11 @@ class CI_Email { /** * Set Message * - * @access private + * @access protected * @param string * @return string */ - private function _set_error_message($msg, $val = '') + protected function _set_error_message($msg, $val = '') { $CI =& get_instance(); $CI->lang->load('email'); @@ -1957,11 +1957,11 @@ class CI_Email { /** * Mime Types * - * @access private + * @access protected * @param string * @return string */ - private function _mime_types($ext = "") + protected function _mime_types($ext = "") { $mimes = array( 'hqx' => 'application/mac-binhex40', 'cpt' => 'application/mac-compactpro', -- cgit v1.2.3-24-g4f1b From 909105135439ac2ade75a99922f77c038e882fee Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Wed, 20 Jul 2011 10:07:40 -0600 Subject: Changed Cart library to return the if inserted successfully. This will be fine for anyone using () == true. http://codeigniter.uservoice.com/forums/40508-codeigniter-reactor/suggestions/2055829-last-rowid-of-cart --- system/libraries/Cart.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php index b2eaa9ad7..ab5a70c98 100644 --- a/system/libraries/Cart.php +++ b/system/libraries/Cart.php @@ -99,7 +99,7 @@ class CI_Cart { $save_cart = FALSE; if (isset($items['id'])) { - if ($this->_insert($items) == TRUE) + if (($rowid = $this->_insert($items))) { $save_cart = TRUE; } @@ -110,7 +110,7 @@ class CI_Cart { { if (is_array($val) AND isset($val['id'])) { - if ($this->_insert($val) == TRUE) + if ($this->_insert($val)) { $save_cart = TRUE; } @@ -122,7 +122,7 @@ class CI_Cart { if ($save_cart == TRUE) { $this->_save_cart(); - return TRUE; + return isset($rowid) ? $rowid : TRUE; } return FALSE; @@ -244,7 +244,7 @@ class CI_Cart { } // Woot! - return TRUE; + return $rowid; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 0aaf42b45f7b56bb1d5e99e17ac3045348064cdd Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Wed, 10 Aug 2011 08:06:37 -0600 Subject: Fixed a bug where Email library attachments with a . in the name would using invalid MIME-types. --- system/libraries/Email.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 9b3bc75e1..fb9a75049 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -395,7 +395,7 @@ class CI_Email { public function attach($filename, $disposition = 'attachment') { $this->_attach_name[] = $filename; - $this->_attach_type[] = $this->_mime_types(next(explode('.', basename($filename)))); + $this->_attach_type[] = $this->_mime_types(pathinfo($filename, PATHINFO_EXTENSION)); $this->_attach_disp[] = $disposition; // Can also be 'inline' Not sure if it matters return $this; } -- cgit v1.2.3-24-g4f1b From 2c547df7b9fcea7b3551d7b702c3ea6fb412cb05 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Wed, 10 Aug 2011 08:36:02 -0600 Subject: Fixed #378 Robots identified as regular browsers by the User Agent class. --- system/libraries/User_agent.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php index 016102a2a..0b77a7d42 100644 --- a/system/libraries/User_agent.php +++ b/system/libraries/User_agent.php @@ -142,7 +142,7 @@ class CI_User_agent { { $this->_set_platform(); - foreach (array('_set_browser', '_set_robot', '_set_mobile') as $function) + foreach (array('_set_robot', '_set_browser', '_set_mobile') as $function) { if ($this->$function() === TRUE) { -- cgit v1.2.3-24-g4f1b From 02d45b56c57f6cf9f8c0fabe7f8b7ed761bd5a9b Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Sun, 14 Aug 2011 09:56:47 -0600 Subject: Driver children can be located in any package path. Thanks Namaless. --- system/libraries/Driver.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php index c32f2c1eb..9881c1eec 100644 --- a/system/libraries/Driver.php +++ b/system/libraries/Driver.php @@ -54,7 +54,7 @@ class CI_Driver_Library { if ( ! class_exists($child_class)) { // check application path first - foreach (array(APPPATH, BASEPATH) as $path) + foreach (get_instance()->load->get_package_paths(TRUE) as $path) { // loves me some nesting! foreach (array(ucfirst($driver_name), $driver_name) as $class) @@ -226,4 +226,4 @@ class CI_Driver { // 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 -- cgit v1.2.3-24-g4f1b From 9aa8929858de7486fce76415e1ab722f4d5e90ab Mon Sep 17 00:00:00 2001 From: Frank de Jonge Date: Sun, 21 Aug 2011 05:45:55 +0300 Subject: Removed unneeded code in CI_Email's set_alt_message. --- system/libraries/Email.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index fb9a75049..e28c23a04 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 == '') ? '' : $str; + $this->alt_message = $str; return $this; } -- cgit v1.2.3-24-g4f1b From 6700b93c4d7a16e7288e4e2cd3223093926666ea Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 24 Sep 2011 14:25:33 +0300 Subject: Added _file_mime_type() method to system/libraries/Upload.php in order to fix a possible MIME-type injection (issue #60) --- system/libraries/Upload.php | 68 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 2 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 3177424c4..93f763ed9 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -196,7 +196,8 @@ class CI_Upload { // Set the uploaded data as class variables $this->file_temp = $_FILES[$field]['tmp_name']; $this->file_size = $_FILES[$field]['size']; - $this->file_type = preg_replace("/^(.+?);.*$/", "\\1", $_FILES[$field]['type']); + $this->_file_mime_type($_FILES[$field]); + $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); @@ -1006,8 +1007,71 @@ class CI_Upload { // -------------------------------------------------------------------- + /** + * File MIME type + * + * Detects the (actual) MIME type of the uploaded file, if possible. + * The input array is expected to be $_FILES[$field] + * + * @param array + * @return void + */ + protected function _file_mime_type($file) + { + $file_type = ''; + + // Use if the Fileinfo extension, if available (only versions above 5.3 support the FILEINFO_MIME_TYPE flag) + if ( (float) substr(phpversion(), 0, 3) >= 5.3 && function_exists('finfo_file')) + { + $finfo = new finfo(FILEINFO_MIME_TYPE); + if ($finfo !== FALSE) // This is possible, if there is no magic MIME database file found on the system + { + $file_type = $finfo->file($file['tmp_name']); + + /* According to the comments section of the PHP manual page, + * it is possible that this function returns an empty string + * for some files (e.g. if they don't exist in the magic MIME database. + */ + if (strlen($file_type) > 1) + { + $this->file_type = $file_info; + return; + } + } + } + + // Fall back to the deprecated mime_content_type(), if available + if (function_exists('mime_content_type')) + { + $this->file_type = @mime_content_type($file['tmp_name']); + return; + } + + /* This is an ugly hack, but UNIX-type systems provide a native way to detect the file type, + * which is still more secure than depending on the value of $_FILES[$field]['type']. + * + * Notes: + * - a 'W' in the substr() expression bellow, would mean that we're using Windows + * - many system admins would disable the exec() function due to security concerns, hence the function_exists() check + */ + if (substr(PHP_OS, 0, 1) !== 'W' && function_exists('exec')) + { + $output = array(); + @exec('file --brief --mime-type ' . escapeshellarg($file['tmp_path']), $output, $return_code); + if ($return_code === 0 && strlen($output[0]) > 0) // A return status code != 0 would mean failed execution + { + $this->file_type = rtrim($output[0]); + return; + } + } + + $this->file_type = $file['type']; + } + + // -------------------------------------------------------------------- + } // END Upload Class /* End of file Upload.php */ -/* Location: ./system/libraries/Upload.php */ \ No newline at end of file +/* Location: ./system/libraries/Upload.php */ -- cgit v1.2.3-24-g4f1b From 6a12d8faba9dcb4f321700c86d047f7b6a4f1780 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 24 Sep 2011 14:35:10 +0300 Subject: Remove an unnecessary variable initialization --- system/libraries/Upload.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 93f763ed9..04abc9ac6 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -1018,8 +1018,6 @@ class CI_Upload { */ protected function _file_mime_type($file) { - $file_type = ''; - // Use if the Fileinfo extension, if available (only versions above 5.3 support the FILEINFO_MIME_TYPE flag) if ( (float) substr(phpversion(), 0, 3) >= 5.3 && function_exists('finfo_file')) { -- cgit v1.2.3-24-g4f1b From 7bfb95b9c329a7905a20f9ebfeacccac7ffd7e41 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 24 Sep 2011 14:45:44 +0300 Subject: Fix alignment with tabs instead of spaces --- system/libraries/Upload.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 04abc9ac6..fd9c8b3e8 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -1058,7 +1058,7 @@ class CI_Upload { @exec('file --brief --mime-type ' . escapeshellarg($file['tmp_path']), $output, $return_code); if ($return_code === 0 && strlen($output[0]) > 0) // A return status code != 0 would mean failed execution { - $this->file_type = rtrim($output[0]); + $this->file_type = rtrim($output[0]); return; } } -- cgit v1.2.3-24-g4f1b From f1649bf567aa769b283bb0b74ed8aee5b44a704b Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 24 Sep 2011 22:59:37 +0300 Subject: Fix an erroneus variable name and a typo in comments --- system/libraries/Upload.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index fd9c8b3e8..a0f3e76bb 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -1028,11 +1028,11 @@ class CI_Upload { /* According to the comments section of the PHP manual page, * it is possible that this function returns an empty string - * for some files (e.g. if they don't exist in the magic MIME database. + * for some files (e.g. if they don't exist in the magic MIME database) */ if (strlen($file_type) > 1) { - $this->file_type = $file_info; + $this->file_type = $file_type; return; } } -- cgit v1.2.3-24-g4f1b From c5efd10679a7b7b4010cd6cc30bd976d3fe8c1ef Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 4 Oct 2011 18:27:32 +0300 Subject: Change Windows OS detection approach --- system/libraries/Upload.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index a0f3e76bb..05511b5d3 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -1052,7 +1052,7 @@ class CI_Upload { * - a 'W' in the substr() expression bellow, would mean that we're using Windows * - many system admins would disable the exec() function due to security concerns, hence the function_exists() check */ - if (substr(PHP_OS, 0, 1) !== 'W' && function_exists('exec')) + if (DIRECTORY_SEPARATOR !== '\\' && function_exists('exec')) { $output = array(); @exec('file --brief --mime-type ' . escapeshellarg($file['tmp_path']), $output, $return_code); -- cgit v1.2.3-24-g4f1b From b7263d152a3c29751e39fd74972707f62f51ca72 Mon Sep 17 00:00:00 2001 From: Mark Huot Date: Fri, 23 Sep 2011 08:20:29 -0400 Subject: resolve a difference between the two memcache set method parameters --- system/libraries/Cache/drivers/Cache_memcached.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php index ec2fd216a..fc586e025 100644 --- a/system/libraries/Cache/drivers/Cache_memcached.php +++ b/system/libraries/Cache/drivers/Cache_memcached.php @@ -64,7 +64,16 @@ class CI_Cache_memcached extends CI_Driver { */ public function save($id, $data, $ttl = 60) { - return $this->_memcached->add($id, array($data, time(), $ttl), $ttl); + if (get_class($this->_memcached) == 'Memcached') + { + return $this->_memcached->set($id, array($data, time(), $ttl), $ttl); + } + else if (get_class($this->_memcached) == 'Memcache') + { + return $this->_memcached->set($id, array($data, time(), $ttl), 0, $ttl); + } + + return FALSE; } // ------------------------------------------------------------------------ -- cgit v1.2.3-24-g4f1b From d61ca42b08ccd1b0fb8654e1458500532896461b Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Sat, 15 Oct 2011 12:02:32 +0800 Subject: Fix #576: using ini_get() to detect if apc is enabled or not --- system/libraries/Cache/drivers/Cache_apc.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Cache/drivers/Cache_apc.php b/system/libraries/Cache/drivers/Cache_apc.php index de75719c4..79d91b320 100644 --- a/system/libraries/Cache/drivers/Cache_apc.php +++ b/system/libraries/Cache/drivers/Cache_apc.php @@ -132,7 +132,7 @@ class CI_Cache_apc extends CI_Driver { */ public function is_supported() { - if ( ! extension_loaded('apc') OR ! function_exists('apc_store')) + if ( ! extension_loaded('apc') OR ini_get('apc.enabled') != "1") { log_message('error', 'The APC PHP extension must be loaded to use APC Cache.'); return FALSE; @@ -148,4 +148,4 @@ class CI_Cache_apc extends CI_Driver { // End Class /* End of file Cache_apc.php */ -/* Location: ./system/libraries/Cache/drivers/Cache_apc.php */ \ No newline at end of file +/* Location: ./system/libraries/Cache/drivers/Cache_apc.php */ -- cgit v1.2.3-24-g4f1b From 13095cbc1b1b0509ac8c984e7a5fd704d9826569 Mon Sep 17 00:00:00 2001 From: diegorivera Date: Wed, 19 Oct 2011 02:56:15 -0200 Subject: Update system/libraries/Email.php --- system/libraries/Email.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index e28c23a04..2916b9a13 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -379,7 +379,15 @@ class CI_Email { */ public function message($body) { - $this->_body = stripslashes(rtrim(str_replace("\r", "", $body))); + $this->_body = rtrim(str_replace("\r", "", $body)); + + //strip slashes only if magic quotes is ON + //if we do it with magic quotes OFF, it strips real, user-inputted chars. + if (get_magic_quotes_gpc()) + { + $this->_body = stripslashes($this->_body); + } + return $this; } -- cgit v1.2.3-24-g4f1b From 6eab49a844b3542a5efee6620233a86f645a30f5 Mon Sep 17 00:00:00 2001 From: diegorivera Date: Wed, 19 Oct 2011 11:18:45 -0200 Subject: I wasn't following the CI code style guide. --- system/libraries/Email.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 2916b9a13..5f8d48682 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -383,10 +383,10 @@ class CI_Email { //strip slashes only if magic quotes is ON //if we do it with magic quotes OFF, it strips real, user-inputted chars. - if (get_magic_quotes_gpc()) - { + if (get_magic_quotes_gpc()) + { $this->_body = stripslashes($this->_body); - } + } return $this; } -- cgit v1.2.3-24-g4f1b From 75b1f3991013c17cacac18e47879c483fe1cf542 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 20 Oct 2011 10:11:59 +0300 Subject: get_magic_quotes_gpc() to be executed only if PHP version is 5.3 or lower --- system/libraries/Email.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 5f8d48682..c8b727c34 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -381,9 +381,13 @@ class CI_Email { { $this->_body = rtrim(str_replace("\r", "", $body)); - //strip slashes only if magic quotes is ON - //if we do it with magic quotes OFF, it strips real, user-inputted chars. - if (get_magic_quotes_gpc()) + /* strip slashes only if magic quotes is ON + if we do it with magic quotes OFF, it strips real, user-inputted chars. + + NOTE: In PHP 5.4 get_magic_quotes_gpc() will always return 0 and + it will probably not exist in future versions at all. + */ + if ( ! is_php('5.4') && get_magic_quotes_gpc()) { $this->_body = stripslashes($this->_body); } -- cgit v1.2.3-24-g4f1b From 426ff851c2164651228a9a9bc10869301b19dbcc Mon Sep 17 00:00:00 2001 From: Kyle Farris Date: Mon, 29 Aug 2011 23:26:07 -0300 Subject: Added the 'user_data' key to the userdata property so that sessions using a database can be deleted properly when using the table schema found in the "Saving Session Data to a Database" section of the Session Class in the user guide. --- system/libraries/Session.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Session.php b/system/libraries/Session.php index 2c8a80163..8ee08c5b2 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -317,7 +317,8 @@ class CI_Session { 'session_id' => md5(uniqid($sessid, TRUE)), 'ip_address' => $this->CI->input->ip_address(), 'user_agent' => substr($this->CI->input->user_agent(), 0, 120), - 'last_activity' => $this->now + 'last_activity' => $this->now, + 'user_data' => '' ); -- cgit v1.2.3-24-g4f1b From da8a560802501cb660952dccab3f3761352c323c Mon Sep 17 00:00:00 2001 From: Aaron Kuzemchak Date: Sat, 3 Sep 2011 20:59:07 -0400 Subject: Enables real page numbers for URI segment in Pagination library --- system/libraries/Pagination.php | 85 +++++++++++++++++++++++++++++++++++------ 1 file changed, 73 insertions(+), 12 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index cc62e660b..cdaacf2d4 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -34,6 +34,7 @@ class CI_Pagination { var $per_page = 10; // Max number of items you want shown per page var $num_links = 2; // Number of "digit" links to show before/after the currently viewed page var $cur_page = 0; // The current page being viewed + var $use_page_numbers = FALSE; // Use page number for segment instead of offset var $first_link = '‹ First'; var $next_link = '>'; var $prev_link = '<'; @@ -128,12 +129,22 @@ class CI_Pagination { return ''; } + // Set the base page index for starting page number + if ($this->use_page_numbers) + { + $base_page = 1; + } + else + { + $base_page = 0; + } + // Determine the current page number. $CI =& get_instance(); if ($CI->config->item('enable_query_strings') === TRUE OR $this->page_query_string === TRUE) { - if ($CI->input->get($this->query_string_segment) != 0) + if ($CI->input->get($this->query_string_segment) != $base_page) { $this->cur_page = $CI->input->get($this->query_string_segment); @@ -143,7 +154,7 @@ class CI_Pagination { } else { - if ($CI->uri->segment($this->uri_segment) != 0) + if ($CI->uri->segment($this->uri_segment) != $base_page) { $this->cur_page = $CI->uri->segment($this->uri_segment); @@ -151,6 +162,12 @@ class CI_Pagination { $this->cur_page = (int) $this->cur_page; } } + + // Set current page to 1 if using page numbers instead of offset + if ($this->use_page_numbers AND $this->cur_page == 0) + { + $this->cur_page = $base_page; + } $this->num_links = (int)$this->num_links; @@ -161,18 +178,32 @@ class CI_Pagination { if ( ! is_numeric($this->cur_page)) { - $this->cur_page = 0; + $this->cur_page = $base_page; } // Is the page number beyond the result range? // If so we show the last page - if ($this->cur_page > $this->total_rows) + if ($this->use_page_numbers) { - $this->cur_page = ($num_pages - 1) * $this->per_page; + if ($this->cur_page > $num_pages) + { + $this->cur_page = $num_pages; + } + } + else + { + if ($this->cur_page > $this->total_rows) + { + $this->cur_page = ($num_pages - 1) * $this->per_page; + } } $uri_page_number = $this->cur_page; - $this->cur_page = floor(($this->cur_page/$this->per_page) + 1); + + if ( ! $this->use_page_numbers) + { + $this->cur_page = floor(($this->cur_page/$this->per_page) + 1); + } // Calculate the start and end numbers. These determine // which number to start and end the digit links with @@ -203,7 +234,14 @@ class CI_Pagination { // Render the "previous" link if ($this->prev_link !== FALSE AND $this->cur_page != 1) { - $i = $uri_page_number - $this->per_page; + if ($this->use_page_numbers) + { + $i = $uri_page_number - 1; + } + else + { + $i = $uri_page_number - $this->per_page; + } if ($i == 0 && $this->first_url != '') { @@ -223,9 +261,16 @@ class CI_Pagination { // Write the digit links for ($loop = $start -1; $loop <= $end; $loop++) { - $i = ($loop * $this->per_page) - $this->per_page; + if ($this->use_page_numbers) + { + $i = $loop; + } + else + { + $i = ($loop * $this->per_page) - $this->per_page; + } - if ($i >= 0) + if ($i >= $base_page) { if ($this->cur_page == $loop) { @@ -233,7 +278,7 @@ class CI_Pagination { } else { - $n = ($i == 0) ? '' : $i; + $n = ($i == $base_page) ? '' : $i; if ($n == '' && $this->first_url != '') { @@ -253,13 +298,29 @@ class CI_Pagination { // Render the "next" link if ($this->next_link !== FALSE AND $this->cur_page < $num_pages) { - $output .= $this->next_tag_open.'anchor_class.'href="'.$this->base_url.$this->prefix.($this->cur_page * $this->per_page).$this->suffix.'">'.$this->next_link.''.$this->next_tag_close; + if ($this->use_page_numbers) + { + $i = $this->cur_page + 1; + } + else + { + $i = ($this->cur_page * $this->per_page); + } + + $output .= $this->next_tag_open.'anchor_class.'href="'.$this->base_url.$this->prefix.$i.$this->suffix.'">'.$this->next_link.''.$this->next_tag_close; } // Render the "Last" link if ($this->last_link !== FALSE AND ($this->cur_page + $this->num_links) < $num_pages) { - $i = (($num_pages * $this->per_page) - $this->per_page); + if ($this->use_page_numbers) + { + $i = $num_pages; + } + else + { + $i = (($num_pages * $this->per_page) - $this->per_page); + } $output .= $this->last_tag_open.'anchor_class.'href="'.$this->base_url.$this->prefix.$i.$this->suffix.'">'.$this->last_link.''.$this->last_tag_close; } -- cgit v1.2.3-24-g4f1b From f6bd296482ed5697b77f23901a16444bf96cb4f4 Mon Sep 17 00:00:00 2001 From: Syahril Zulkefli Date: Sun, 13 Nov 2011 23:46:58 +0800 Subject: Fix invalid datetime format --- system/libraries/Xmlrpc.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 5da6ea6ae..d702e902f 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -1404,14 +1404,14 @@ class XML_RPC_Values extends CI_Xmlrpc { if ($utc == 1) { - $t = strftime("%Y%m%dT%H:%M:%S", $time); + $t = strftime("%Y%m%dT%H:%i:%s", $time); } else { if (function_exists('gmstrftime')) - $t = gmstrftime("%Y%m%dT%H:%M:%S", $time); + $t = gmstrftime("%Y%m%dT%H:%i:%s", $time); else - $t = strftime("%Y%m%dT%H:%M:%S", $time - date('Z')); + $t = strftime("%Y%m%dT%H:%i:%s", $time - date('Z')); } return $t; } -- cgit v1.2.3-24-g4f1b From c78301cee7b648911601f663731ddb4871d1bba4 Mon Sep 17 00:00:00 2001 From: Radu Potop Date: Wed, 28 Sep 2011 13:57:51 +0300 Subject: Added TLS and SSL support to Email library. Fixes issue #171 --- system/libraries/Email.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index c8b727c34..9ec40af9d 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -36,6 +36,7 @@ class CI_Email { var $smtp_pass = ""; // SMTP Password var $smtp_port = "25"; // SMTP Port var $smtp_timeout = 5; // SMTP Timeout in seconds + var $smtp_crypto = ""; // SMTP Encryption. Can be null, tls or ssl. var $wordwrap = TRUE; // TRUE/FALSE Turns word-wrap on/off var $wrapchars = "76"; // Number of characters to wrap at. var $mailtype = "text"; // text/html Defines email formatting @@ -1678,7 +1679,10 @@ class CI_Email { */ protected function _smtp_connect() { - $this->_smtp_connect = fsockopen($this->smtp_host, + $ssl = NULL; + if ($this->smtp_crypto == 'ssl') + $ssl = 'ssl://'; + $this->_smtp_connect = fsockopen($ssl.$this->smtp_host, $this->smtp_port, $errno, $errstr, @@ -1691,6 +1695,14 @@ class CI_Email { } $this->_set_error_message($this->_get_smtp_data()); + + if ($this->smtp_crypto == 'tls') + { + $this->_send_command('hello'); + $this->_send_command('starttls'); + stream_socket_enable_crypto($this->_smtp_connect, TRUE, STREAM_CRYPTO_METHOD_TLS_CLIENT); + } + return $this->_send_command('hello'); } @@ -1717,6 +1729,12 @@ class CI_Email { $resp = 250; break; + case 'starttls' : + + $this->_send_data('STARTTLS'); + + $resp = 220; + break; case 'from' : $this->_send_data('MAIL FROM:<'.$data.'>'); -- cgit v1.2.3-24-g4f1b