diff options
Diffstat (limited to 'system/libraries')
-rw-r--r-- | system/libraries/Cache/Cache.php | 38 | ||||
-rw-r--r-- | system/libraries/Cache/drivers/Cache_apc.php | 30 | ||||
-rw-r--r-- | system/libraries/Cache/drivers/Cache_dummy.php | 8 | ||||
-rw-r--r-- | system/libraries/Cache/drivers/Cache_file.php | 55 | ||||
-rw-r--r-- | system/libraries/Cache/drivers/Cache_memcached.php | 10 | ||||
-rw-r--r-- | system/libraries/Calendar.php | 147 | ||||
-rw-r--r-- | system/libraries/Encrypt.php | 105 | ||||
-rw-r--r-- | system/libraries/Form_validation.php | 2 | ||||
-rw-r--r-- | system/libraries/Migration.php | 24 | ||||
-rw-r--r-- | system/libraries/Pagination.php | 30 | ||||
-rw-r--r-- | system/libraries/Profiler.php | 225 | ||||
-rw-r--r-- | system/libraries/Sha1.php | 263 | ||||
-rw-r--r-- | system/libraries/Typography.php | 101 | ||||
-rw-r--r-- | system/libraries/Upload.php | 15 | ||||
-rw-r--r-- | system/libraries/User_agent.php | 13 | ||||
-rw-r--r-- | system/libraries/Xmlrpcs.php | 144 |
16 files changed, 378 insertions, 832 deletions
diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php index 269bf9b2d..87253739c 100644 --- a/system/libraries/Cache/Cache.php +++ b/system/libraries/Cache/Cache.php @@ -1,13 +1,13 @@ -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); +<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); /** * CodeIgniter * * An open source application development framework for PHP 5.1.6 or newer * * NOTICE OF LICENSE - * + * * Licensed under the Open Software License version 3.0 - * + * * This source file is subject to the Open Software License (OSL 3.0) that is * bundled with this package in the files license.txt / license.rst. It is * also available through the world wide web at this URL: @@ -22,22 +22,22 @@ * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 2.0 - * @filesource + * @filesource */ // ------------------------------------------------------------------------ /** - * CodeIgniter Caching Class + * CodeIgniter Caching Class * * @package CodeIgniter * @subpackage Libraries * @category Core * @author EllisLab Dev Team - * @link + * @link */ class CI_Cache extends CI_Driver_Library { - + protected $valid_drivers = array( 'cache_apc', 'cache_file', 'cache_memcached', 'cache_dummy' ); @@ -45,7 +45,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; - + // ------------------------------------------------------------------------ /** @@ -64,16 +64,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); } @@ -124,7 +124,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') { @@ -132,7 +132,7 @@ class CI_Cache extends CI_Driver_Library { } // ------------------------------------------------------------------------ - + /** * Get Cache Metadata * @@ -143,7 +143,7 @@ class CI_Cache extends CI_Driver_Library { { return $this->{$this->_adapter}->get_metadata($id); } - + // ------------------------------------------------------------------------ /** @@ -151,11 +151,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' @@ -219,10 +219,10 @@ class CI_Cache extends CI_Driver_Library { return $obj; } - + // ------------------------------------------------------------------------ } // End Class /* End of file Cache.php */ -/* Location: ./system/libraries/Cache/Cache.php */
\ No newline at end of file +/* Location: ./system/libraries/Cache/Cache.php */ diff --git a/system/libraries/Cache/drivers/Cache_apc.php b/system/libraries/Cache/drivers/Cache_apc.php index f15cf8501..90b68688d 100644 --- a/system/libraries/Cache/drivers/Cache_apc.php +++ b/system/libraries/Cache/drivers/Cache_apc.php @@ -1,13 +1,13 @@ -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); +<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); /** * CodeIgniter * * An open source application development framework for PHP 5.1.6 or newer * * NOTICE OF LICENSE - * + * * Licensed under the Open Software License version 3.0 - * + * * This source file is subject to the Open Software License (OSL 3.0) that is * bundled with this package in the files license.txt / license.rst. It is * also available through the world wide web at this URL: @@ -22,30 +22,30 @@ * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @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 EllisLab 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) @@ -55,8 +55,8 @@ class CI_Cache_apc extends CI_Driver { return (is_array($data)) ? $data[0] : FALSE; } - // ------------------------------------------------------------------------ - + // ------------------------------------------------------------------------ + /** * Cache Save * @@ -70,7 +70,7 @@ class CI_Cache_apc extends CI_Driver { { return apc_store($id, array($data, time(), $ttl), $ttl); } - + // ------------------------------------------------------------------------ /** @@ -102,7 +102,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) { @@ -149,13 +149,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_dummy.php b/system/libraries/Cache/drivers/Cache_dummy.php index 965bb2bef..ff787e90b 100644 --- a/system/libraries/Cache/drivers/Cache_dummy.php +++ b/system/libraries/Cache/drivers/Cache_dummy.php @@ -1,13 +1,13 @@ -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); +<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); /** * CodeIgniter * * An open source application development framework for PHP 5.1.6 or newer * * NOTICE OF LICENSE - * + * * Licensed under the Open Software License version 3.0 - * + * * This source file is subject to the Open Software License (OSL 3.0) that is * bundled with this package in the files license.txt / license.rst. It is * also available through the world wide web at this URL: @@ -138,4 +138,4 @@ class CI_Cache_dummy extends CI_Driver { // End Class /* End of file Cache_dummy.php */ -/* Location: ./system/libraries/Cache/drivers/Cache_dummy.php */
\ No newline at end of file +/* Location: ./system/libraries/Cache/drivers/Cache_dummy.php */ diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php index be392d3d2..194279726 100644 --- a/system/libraries/Cache/drivers/Cache_file.php +++ b/system/libraries/Cache/drivers/Cache_file.php @@ -1,13 +1,13 @@ -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); +<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); /** * CodeIgniter * * An open source application development framework for PHP 5.1.6 or newer * * NOTICE OF LICENSE - * + * * Licensed under the Open Software License version 3.0 - * + * * This source file is subject to the Open Software License (OSL 3.0) that is * bundled with this package in the files license.txt / license.rst. It is * also available through the world wide web at this URL: @@ -22,19 +22,19 @@ * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @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 EllisLab Dev Team - * @link + * @link */ class CI_Cache_file extends CI_Driver { @@ -48,9 +48,7 @@ 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; } @@ -68,16 +66,15 @@ class CI_Cache_file extends CI_Driver { { return FALSE; } - - $data = read_file($this->_cache_path.$id); - $data = unserialize($data); - + + $data = unserialize(read_file($this->_cache_path.$id)); + if (time() > $data['time'] + $data['ttl']) { unlink($this->_cache_path.$id); return FALSE; } - + return $data['data']; } @@ -88,22 +85,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; @@ -119,14 +116,7 @@ class CI_Cache_file extends CI_Driver { */ public function delete($id) { - if (file_exists($this->_cache_path.$id)) - { - return unlink($this->_cache_path.$id); - } - else - { - return FALSE; - } + return (file_exists($this->_cache_path.$id)) ? unlink($this->_cache_path.$id) : FALSE; } // ------------------------------------------------------------------------ @@ -135,7 +125,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); @@ -170,10 +160,9 @@ class CI_Cache_file extends CI_Driver { { return FALSE; } - - $data = read_file($this->_cache_path.$id); - $data = unserialize($data); - + + $data = unserialize(read_file($this->_cache_path.$id)); + if (is_array($data)) { $mtime = filemtime($this->_cache_path.$id); @@ -188,7 +177,7 @@ class CI_Cache_file extends CI_Driver { 'mtime' => $mtime ); } - + return FALSE; } @@ -198,7 +187,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/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php index 78cab25d4..0037e6755 100644 --- a/system/libraries/Cache/drivers/Cache_memcached.php +++ b/system/libraries/Cache/drivers/Cache_memcached.php @@ -1,13 +1,13 @@ -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); +<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); /** * CodeIgniter * * An open source application development framework for PHP 5.1.6 or newer * * NOTICE OF LICENSE - * + * * Licensed under the Open Software License version 3.0 - * + * * This source file is subject to the Open Software License (OSL 3.0) that is * bundled with this package in the files license.txt / license.rst. It is * also available through the world wide web at this URL: @@ -84,7 +84,7 @@ class CI_Cache_memcached extends CI_Driver { { return $this->_memcached->set($id, array($data, time(), $ttl), 0, $ttl); } - + return FALSE; } @@ -256,4 +256,4 @@ class CI_Cache_memcached extends CI_Driver { // End Class /* End of file Cache_memcached.php */ -/* Location: ./system/libraries/Cache/drivers/Cache_memcached.php */
\ No newline at end of file +/* Location: ./system/libraries/Cache/drivers/Cache_memcached.php */ diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index f5ef4d576..605765bf6 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -1,13 +1,13 @@ -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); +<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); /** * CodeIgniter * * An open source application development framework for PHP 5.1.6 or newer * * NOTICE OF LICENSE - * + * * Licensed under the Open Software License version 3.0 - * + * * This source file is subject to the Open Software License (OSL 3.0) that is * bundled with this package in the files license.txt / license.rst. It is * also available through the world wide web at this URL: @@ -40,15 +40,15 @@ */ class CI_Calendar { - var $CI; - var $lang; - var $local_time; - var $template = ''; - var $start_day = 'sunday'; - var $month_type = 'long'; - var $day_type = 'abr'; - var $show_next_prev = FALSE; - var $next_prev_url = ''; + private $CI; + public $lang; + public $local_time; + public $template = ''; + public $start_day = 'sunday'; + public $month_type = 'long'; + public $day_type = 'abr'; + public $show_next_prev = FALSE; + public $next_prev_url = ''; /** * Constructor @@ -85,7 +85,7 @@ class CI_Calendar { * @param array config preferences * @return void */ - function initialize($config = array()) + public function initialize($config = array()) { foreach ($config as $key => $val) { @@ -107,23 +107,30 @@ class CI_Calendar { * @param array the data to be shown in the calendar cells * @return string */ - function generate($year = '', $month = '', $data = array()) + public function generate($year = '', $month = '', $data = array()) { // Set and validate the supplied month/year if ($year == '') - $year = date("Y", $this->local_time); - - if ($month == '') - $month = date("m", $this->local_time); - - if (strlen($year) == 1) + { + $year = date('Y', $this->local_time); + } + elseif (strlen($year) === 1) + { $year = '200'.$year; - - if (strlen($year) == 2) + } + elseif (strlen($year) === 2) + { $year = '20'.$year; + } - if (strlen($month) == 1) + if ($month == '') + { + $month = date('m', $this->local_time); + } + elseif (strlen($month) === 1) + { $month = '0'.$month; + } $adjusted_date = $this->adjust_date($month, $year); @@ -149,9 +156,9 @@ class CI_Calendar { // Set the current month/year/day // We use this to determine the "today" date - $cur_year = date("Y", $this->local_time); - $cur_month = date("m", $this->local_time); - $cur_day = date("j", $this->local_time); + $cur_year = date('Y', $this->local_time); + $cur_month = date('m', $this->local_time); + $cur_day = date('j', $this->local_time); $is_current_month = ($cur_year == $year AND $cur_month == $month) ? TRUE : FALSE; @@ -159,12 +166,7 @@ class CI_Calendar { $this->parse_template(); // Begin building the calendar output - $out = $this->temp['table_open']; - $out .= "\n"; - - $out .= "\n"; - $out .= $this->temp['heading_row_start']; - $out .= "\n"; + $out = $this->temp['table_open']."\n\n".$this->temp['heading_row_start']."\n"; // "previous" month link if ($this->show_next_prev == TRUE) @@ -173,18 +175,16 @@ class CI_Calendar { $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']); - $out .= "\n"; + $out .= str_replace('{previous_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_previous_cell'])."\n"; } // Heading containing the month/year $colspan = ($this->show_next_prev == TRUE) ? 5 : 7; - $this->temp['heading_title_cell'] = str_replace('{colspan}', $colspan, $this->temp['heading_title_cell']); - $this->temp['heading_title_cell'] = str_replace('{heading}', $this->get_month_name($month)." ".$year, $this->temp['heading_title_cell']); + $this->temp['heading_title_cell'] = str_replace('{colspan}', $colspan, + str_replace('{heading}', $this->get_month_name($month).' '.$year, $this->temp['heading_title_cell'])); - $out .= $this->temp['heading_title_cell']; - $out .= "\n"; + $out .= $this->temp['heading_title_cell']."\n"; // "next" month link if ($this->show_next_prev == TRUE) @@ -193,14 +193,9 @@ class CI_Calendar { $out .= str_replace('{next_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_next_cell']); } - $out .= "\n"; - $out .= $this->temp['heading_row_end']; - $out .= "\n"; - - // Write the cells containing the days of the week - $out .= "\n"; - $out .= $this->temp['week_row_start']; - $out .= "\n"; + $out .= "\n".$this->temp['heading_row_end']."\n\n" + // Write the cells containing the days of the week + .$this->temp['week_row_start']."\n"; $day_names = $this->get_day_names(); @@ -209,33 +204,31 @@ class CI_Calendar { $out .= str_replace('{week_day}', $day_names[($start_day + $i) %7], $this->temp['week_day_cell']); } - $out .= "\n"; - $out .= $this->temp['week_row_end']; - $out .= "\n"; + $out .= "\n".$this->temp['week_row_end']."\n"; // Build the main body of the calendar while ($day <= $total_days) { - $out .= "\n"; - $out .= $this->temp['cal_row_start']; - $out .= "\n"; + $out .= "\n".$this->temp['cal_row_start']."\n"; for ($i = 0; $i < 7; $i++) { - $out .= ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_start_today'] : $this->temp['cal_cell_start']; + $out .= ($is_current_month === TRUE AND $day == $cur_day) ? $this->temp['cal_cell_start_today'] : $this->temp['cal_cell_start']; if ($day > 0 AND $day <= $total_days) { if (isset($data[$day])) { // Cells with content - $temp = ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_content_today'] : $this->temp['cal_cell_content']; - $out .= str_replace('{day}', $day, str_replace('{content}', $data[$day], $temp)); + $temp = ($is_current_month === TRUE AND $day == $cur_day) ? + $this->temp['cal_cell_content_today'] : $this->temp['cal_cell_content']; + $out .= str_replace(array('{content}', '{day}'), array($data[$day], $day), $temp); } else { // Cells with no content - $temp = ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_no_content_today'] : $this->temp['cal_cell_no_content']; + $temp = ($is_current_month === TRUE AND $day == $cur_day) ? + $this->temp['cal_cell_no_content_today'] : $this->temp['cal_cell_no_content']; $out .= str_replace('{day}', $day, $temp); } } @@ -245,17 +238,14 @@ 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++; } - $out .= "\n"; - $out .= $this->temp['cal_row_end']; - $out .= "\n"; + $out .= "\n".$this->temp['cal_row_end']."\n"; } - $out .= "\n"; - $out .= $this->temp['table_close']; + $out .= "\n".$this->temp['table_close']; return $out; } @@ -272,7 +262,7 @@ class CI_Calendar { * @param integer the month * @return string */ - function get_month_name($month) + public function get_month_name($month) { if ($this->month_type == 'short') { @@ -287,7 +277,7 @@ class CI_Calendar { if ($this->CI->lang->line($month) === FALSE) { - return ucfirst(str_replace('cal_', '', $month)); + return ucfirst(substr($month, 4)); } return $this->CI->lang->line($month); @@ -305,10 +295,12 @@ class CI_Calendar { * @param string * @return array */ - function get_day_names($day_type = '') + public function get_day_names($day_type = '') { if ($day_type != '') + { $this->day_type = $day_type; + } if ($this->day_type == 'long') { @@ -324,9 +316,9 @@ class CI_Calendar { } $days = array(); - foreach ($day_names as $val) + for ($i = 0, $c = count($day_names); $i < $c; $i++) { - $days[] = ($this->CI->lang->line('cal_'.$val) === FALSE) ? ucfirst($val) : $this->CI->lang->line('cal_'.$val); + $days[] = ($this->CI->lang->line('cal_'.$day_names[$i]) === FALSE) ? ucfirst($day_names[$i]) : $this->CI->lang->line('cal_'.$day_names[$i]); } return $days; @@ -346,7 +338,7 @@ class CI_Calendar { * @param integer the year * @return array */ - function adjust_date($month, $year) + public function adjust_date($month, $year) { $date = array(); @@ -365,7 +357,7 @@ class CI_Calendar { $date['year']--; } - if (strlen($date['month']) == 1) + if (strlen($date['month']) === 1) { $date['month'] = '0'.$date['month']; } @@ -383,7 +375,7 @@ class CI_Calendar { * @param integer the year * @return integer */ - function get_total_days($month, $year) + public function get_total_days($month, $year) { $days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); @@ -414,7 +406,7 @@ class CI_Calendar { * @access public * @return array */ - function default_template() + public function default_template() { return array ( 'table_open' => '<table border="0" cellpadding="4" cellspacing="0">', @@ -452,7 +444,7 @@ class CI_Calendar { * @access public * @return void */ - function parse_template() + public function parse_template() { $this->temp = $this->default_template(); @@ -467,14 +459,11 @@ class CI_Calendar { { if (preg_match("/\{".$val."\}(.*?)\{\/".$val."\}/si", $this->template, $match)) { - $this->temp[$val] = $match['1']; + $this->temp[$val] = $match[1]; } - else + elseif (in_array($val, $today, TRUE)) { - if (in_array($val, $today, TRUE)) - { - $this->temp[$val] = $this->temp[str_replace('_today', '', $val)]; - } + $this->temp[$val] = $this->temp[substr($val, 0, -6)]; } } } @@ -484,4 +473,4 @@ class CI_Calendar { // END CI_Calendar class /* End of file Calendar.php */ -/* Location: ./system/libraries/Calendar.php */
\ No newline at end of file +/* Location: ./system/libraries/Calendar.php */ diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php index c2cb808dd..92b0b3c4a 100644 --- a/system/libraries/Encrypt.php +++ b/system/libraries/Encrypt.php @@ -40,22 +40,19 @@ */ class CI_Encrypt { - var $CI; - var $encryption_key = ''; - var $_hash_type = 'sha1'; - var $_mcrypt_exists = FALSE; - var $_mcrypt_cipher; - var $_mcrypt_mode; + public $encryption_key = ''; + protected $_hash_type = 'sha1'; + protected $_mcrypt_exists = FALSE; + protected $_mcrypt_cipher; + protected $_mcrypt_mode; /** * Constructor * * Simply determines whether the mcrypt library exists. - * */ public function __construct() { - $this->CI =& get_instance(); $this->_mcrypt_exists = ( ! function_exists('mcrypt_encrypt')) ? FALSE : TRUE; log_message('debug', "Encrypt Class Initialized"); } @@ -68,11 +65,10 @@ class CI_Encrypt { * Returns it as MD5 in order to have an exact-length 128 bit key. * Mcrypt is sensitive to keys that are not the correct length * - * @access public * @param string * @return string */ - function get_key($key = '') + public function get_key($key = '') { if ($key == '') { @@ -84,7 +80,7 @@ class CI_Encrypt { $CI =& get_instance(); $key = $CI->config->item('encryption_key'); - if ($key == FALSE) + if ($key === FALSE) { show_error('In order to use the encryption class requires that you set an encryption key in your config file.'); } @@ -98,13 +94,13 @@ class CI_Encrypt { /** * Set the encryption key * - * @access public * @param string * @return void */ - function set_key($key = '') + public function set_key($key = '') { $this->encryption_key = $key; + return $this; } // -------------------------------------------------------------------- @@ -120,12 +116,11 @@ class CI_Encrypt { * that is randomized with each call to this function, * even if the supplied message and key are the same. * - * @access public * @param string the string to encode * @param string the key * @return string */ - function encode($string, $key = '') + public function encode($string, $key = '') { $key = $this->get_key($key); @@ -148,12 +143,11 @@ class CI_Encrypt { * * Reverses the above process * - * @access public * @param string * @param string * @return string */ - function decode($string, $key = '') + public function decode($string, $key = '') { $key = $this->get_key($key); @@ -191,13 +185,12 @@ class CI_Encrypt { * * For more details, see http://codeigniter.com/user_guide/installation/upgrade_200.html#encryption * - * @access public * @param string * @param int (mcrypt mode constant) * @param string * @return string */ - function encode_from_legacy($string, $legacy_mode = MCRYPT_MODE_ECB, $key = '') + public function encode_from_legacy($string, $legacy_mode = MCRYPT_MODE_ECB, $key = '') { if ($this->_mcrypt_exists === FALSE) { @@ -242,12 +235,11 @@ class CI_Encrypt { * Takes a plain-text string and key as input and generates an * encoded bit-string using XOR * - * @access private * @param string * @param string * @return string */ - function _xor_encode($string, $key) + protected function _xor_encode($string, $key) { $rand = ''; while (strlen($rand) < 32) @@ -274,12 +266,11 @@ class CI_Encrypt { * Takes an encoded string and key as input and generates the * plain-text original message * - * @access private * @param string * @param string * @return string */ - function _xor_decode($string, $key) + protected function _xor_decode($string, $key) { $string = $this->_xor_merge($string, $key); @@ -299,12 +290,11 @@ class CI_Encrypt { * * Takes a string and key as input and computes the difference using XOR * - * @access private * @param string * @param string * @return string */ - function _xor_merge($string, $key) + protected function _xor_merge($string, $key) { $hash = $this->hash($key); $str = ''; @@ -321,12 +311,11 @@ class CI_Encrypt { /** * Encrypt using Mcrypt * - * @access public * @param string * @param string * @return string */ - function mcrypt_encode($data, $key) + public function mcrypt_encode($data, $key) { $init_size = mcrypt_get_iv_size($this->_get_cipher(), $this->_get_mode()); $init_vect = mcrypt_create_iv($init_size, MCRYPT_RAND); @@ -338,12 +327,11 @@ class CI_Encrypt { /** * Decrypt using Mcrypt * - * @access public * @param string * @param string * @return string */ - function mcrypt_decode($data, $key) + public function mcrypt_decode($data, $key) { $data = $this->_remove_cipher_noise($data, $key); $init_size = mcrypt_get_iv_size($this->_get_cipher(), $this->_get_mode()); @@ -365,14 +353,11 @@ class CI_Encrypt { * against Man-in-the-middle attacks on CBC mode ciphers * http://www.ciphersbyritter.com/GLOSSARY.HTM#IV * - * Function description - * - * @access private * @param string * @param string * @return string */ - function _add_cipher_noise($data, $key) + protected function _add_cipher_noise($data, $key) { $keyhash = $this->hash($key); $keylen = strlen($keyhash); @@ -399,11 +384,10 @@ class CI_Encrypt { * * Function description * - * @access public * @param type * @return type */ - function _remove_cipher_noise($data, $key) + protected function _remove_cipher_noise($data, $key) { $keyhash = $this->hash($key); $keylen = strlen($keyhash); @@ -434,13 +418,13 @@ class CI_Encrypt { /** * Set the Mcrypt Cipher * - * @access public * @param constant * @return string */ - function set_cipher($cipher) + public function set_cipher($cipher) { $this->_mcrypt_cipher = $cipher; + return $this; } // -------------------------------------------------------------------- @@ -448,13 +432,13 @@ class CI_Encrypt { /** * Set the Mcrypt Mode * - * @access public * @param constant * @return string */ function set_mode($mode) { $this->_mcrypt_mode = $mode; + return $this; } // -------------------------------------------------------------------- @@ -462,10 +446,9 @@ class CI_Encrypt { /** * Get Mcrypt cipher Value * - * @access private * @return string */ - function _get_cipher() + protected function _get_cipher() { if ($this->_mcrypt_cipher == '') { @@ -480,10 +463,9 @@ class CI_Encrypt { /** * Get Mcrypt Mode Value * - * @access private * @return string */ - function _get_mode() + protected function _get_mode() { if ($this->_mcrypt_mode == '') { @@ -498,11 +480,10 @@ class CI_Encrypt { /** * Set the Hash type * - * @access public * @param string * @return string */ - function set_hash($type = 'sha1') + public function set_hash($type = 'sha1') { $this->_hash_type = ($type != 'sha1' AND $type != 'md5') ? 'sha1' : $type; } @@ -512,45 +493,13 @@ class CI_Encrypt { /** * Hash encode a string * - * @access public * @param string * @return string */ - function hash($str) + public function hash($str) { - return ($this->_hash_type == 'sha1') ? $this->sha1($str) : md5($str); + return ($this->_hash_type == 'sha1') ? sha1($str) : md5($str); } - - // -------------------------------------------------------------------- - - /** - * Generate an SHA1 Hash - * - * @access public - * @param string - * @return string - */ - function sha1($str) - { - if ( ! function_exists('sha1')) - { - if ( ! function_exists('mhash')) - { - require_once(BASEPATH.'libraries/Sha1.php'); - $SH = new CI_SHA; - return $SH->generate($str); - } - else - { - return bin2hex(mhash(MHASH_SHA1, $str)); - } - } - else - { - return sha1($str); - } - } - } // END CI_Encrypt class diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 8173c6edf..d83afdd25 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -724,7 +724,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']); diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php index 94961b568..eb5161d76 100644 --- a/system/libraries/Migration.php +++ b/system/libraries/Migration.php @@ -1,4 +1,4 @@ -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); +<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); /** * CodeIgniter * @@ -101,12 +101,9 @@ class CI_Migration { } // Do we auto migrate to the latest migration? - if ($this->_migration_auto_latest == TRUE) + if ($this->_migration_auto_latest === TRUE AND ! $this->latest()) { - if ( ! $this->latest() ) - { - show_error($this->error_string()); - } + show_error($this->error_string()); } } @@ -134,7 +131,6 @@ class CI_Migration { ++$stop; $step = 1; } - else { // Moving Down @@ -158,11 +154,11 @@ class CI_Migration { } // Migration step not found - if (count($f) == 0) + if (count($f) === 0) { // If trying to migrate up to a version greater than the last // existing one, migrate to the last one. - if ($step == 1) + if ($step === 1) { break; } @@ -214,7 +210,7 @@ class CI_Migration { log_message('debug', 'Current migration: '.$current_version); - $version = $i + ($step == 1 ? -1 : 0); + $version = $i + ($step === 1 ? -1 : 0); // If there is nothing to do so quit if ($migrations === array()) @@ -301,13 +297,11 @@ class CI_Migration { { // 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++) + for ($i = 0, $c = count($files); $i < $c; $i++) { // Mark wrongly formatted files as false for later filtering - $name = basename($files[$i], '.php'); - if ( ! preg_match('/^\d{3}_(\w+)$/', $name)) + if ( ! preg_match('/^\d{3}_(\w+)$/', basename($files[$i], '.php'))) { $files[$i] = FALSE; } @@ -364,4 +358,4 @@ class CI_Migration { } /* End of file Migration.php */ -/* Location: ./system/libraries/Migration.php */
\ No newline at end of file +/* Location: ./system/libraries/Migration.php */ diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index eea953ae4..008c15192 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -1,4 +1,4 @@ -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); +<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); /** * CodeIgniter * @@ -131,7 +131,7 @@ class CI_Pagination { $num_pages = ceil($this->total_rows / $this->per_page); // Is there only one page? Hm... nothing more to do here then. - if ($num_pages == 1) + if ($num_pages === 1) { return ''; } @@ -146,25 +146,16 @@ class CI_Pagination { { if ($CI->input->get($this->query_string_segment) != $base_page) { - $this->cur_page = $CI->input->get($this->query_string_segment); - - // Prep the current page - no funny business! - $this->cur_page = (int) $this->cur_page; + $this->cur_page = (int) $CI->input->get($this->query_string_segment); } } - else + elseif ($CI->uri->segment($this->uri_segment) != $base_page) { - if ($CI->uri->segment($this->uri_segment) != $base_page) - { - $this->cur_page = $CI->uri->segment($this->uri_segment); - - // Prep the current page - no funny business! - $this->cur_page = (int) $this->cur_page; - } + $this->cur_page = (int) $CI->uri->segment($this->uri_segment); } - // Set current page to 1 if using page numbers instead of offset - if ($this->use_page_numbers AND $this->cur_page == 0) + // Set current page to 1 if it's not valid or if using page numbers instead of offset + if ( ! is_numeric($this->cur_page) OR ($this->use_page_numbers AND $this->cur_page == 0)) { $this->cur_page = $base_page; } @@ -176,11 +167,6 @@ class CI_Pagination { show_error('Your number of links must be a positive number.'); } - if ( ! is_numeric($this->cur_page)) - { - $this->cur_page = $base_page; - } - // Is the page number beyond the result range? // If so we show the last page if ($this->use_page_numbers) @@ -310,4 +296,4 @@ class CI_Pagination { // END Pagination Class /* End of file Pagination.php */ -/* Location: ./system/libraries/Pagination.php */
\ No newline at end of file +/* Location: ./system/libraries/Pagination.php */ diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php index 8a2568d8e..9cbd69bb2 100644 --- a/system/libraries/Profiler.php +++ b/system/libraries/Profiler.php @@ -1,13 +1,13 @@ -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); +<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); /** * CodeIgniter * * An open source application development framework for PHP 5.1.6 or newer * * NOTICE OF LICENSE - * + * * Licensed under the Open Software License version 3.0 - * + * * This source file is subject to the Open Software License (OSL 3.0) that is * bundled with this package in the files license.txt / license.rst. It is * also available through the world wide web at this URL: @@ -126,12 +126,10 @@ class CI_Profiler { { // We match the "end" marker so that the list ends // up in the order that it was defined - if (preg_match("/(.+?)_end/i", $key, $match)) + if (preg_match('/(.+?)_end/i', $key, $match) + AND isset($this->CI->benchmark->marker[$match[1].'_end'], $this->CI->benchmark->marker[$match[1].'_start'])) { - if (isset($this->CI->benchmark->marker[$match[1].'_end']) AND isset($this->CI->benchmark->marker[$match[1].'_start'])) - { - $profile[$match[1]] = $this->CI->benchmark->elapsed_time($match[1].'_start', $key); - } + $profile[$match[1]] = $this->CI->benchmark->elapsed_time($match[1].'_start', $key); } } @@ -139,12 +137,11 @@ class CI_Profiler { // Note: At some point we should turn this into a template that can // be modified. We also might want to make this data available to be logged - $output = "\n\n"; - $output .= '<fieldset id="ci_profiler_benchmarks" style="border:1px solid #900;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; - $output .= "\n"; - $output .= '<legend style="color:#900;"> '.$this->CI->lang->line('profiler_benchmarks').' </legend>'; - $output .= "\n"; - $output .= "\n\n<table style='width:100%'>\n"; + $output = "\n\n" + . '<fieldset id="ci_profiler_benchmarks" style="border:1px solid #900;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">' + . "\n" + . '<legend style="color:#900;"> '.$this->CI->lang->line('profiler_benchmarks').' </legend>' + . "\n\n\n<table style='width:100%'>\n"; foreach ($profile as $key => $val) { @@ -152,10 +149,7 @@ class CI_Profiler { $output .= "<tr><td style='padding:5px;width:50%;color:#000;font-weight:bold;background-color:#ddd;'>".$key." </td><td style='padding:5px;width:50%;color:#900;font-weight:normal;background-color:#ddd;'>".$val."</td></tr>\n"; } - $output .= "</table>\n"; - $output .= "</fieldset>"; - - return $output; + return $output."</table>\n</fieldset>"; } // -------------------------------------------------------------------- @@ -178,19 +172,16 @@ class CI_Profiler { } } - if (count($dbs) == 0) + if (count($dbs) === 0) { - $output = "\n\n"; - $output .= '<fieldset id="ci_profiler_queries" style="border:1px solid #0000FF;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; - $output .= "\n"; - $output .= '<legend style="color:#0000FF;"> '.$this->CI->lang->line('profiler_queries').' </legend>'; - $output .= "\n"; - $output .= "\n\n<table style='border:none; width:100%;'>\n"; - $output .="<tr><td style='width:100%;color:#0000FF;font-weight:normal;background-color:#eee;padding:5px'>".$this->CI->lang->line('profiler_no_db')."</td></tr>\n"; - $output .= "</table>\n"; - $output .= "</fieldset>"; - - return $output; + return "\n\n" + . '<fieldset id="ci_profiler_queries" style="border:1px solid #0000FF;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee;">' + . "\n" + . '<legend style="color:#0000FF;"> '.$this->CI->lang->line('profiler_queries').' </legend>' + . "\n\n\n<table style='border:none; width:100%;'>\n" + . '<tr><td style="width:100%;color:#0000FF;font-weight:normal;background-color:#eee;padding:5px;">' + . $this->CI->lang->line('profiler_no_db') + . "</td></tr>\n</table>\n</fieldset>"; } // Load the text helper so we can highlight the SQL @@ -205,8 +196,6 @@ class CI_Profiler { foreach ($dbs as $db) { - $count++; - $hide_queries = (count($db->queries) > $this->_query_toggle_count) ? ' display:none' : ''; $show_hide_js = '(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_queries_db_'.$count.'\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_hide').'\'?\''.$this->CI->lang->line('profiler_section_show').'\':\''.$this->CI->lang->line('profiler_section_hide').'\';">'.$this->CI->lang->line('profiler_section_hide').'</span>)'; @@ -216,13 +205,12 @@ class CI_Profiler { $show_hide_js = '(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_queries_db_'.$count.'\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_show').'\'?\''.$this->CI->lang->line('profiler_section_hide').'\':\''.$this->CI->lang->line('profiler_section_show').'\';">'.$this->CI->lang->line('profiler_section_show').'</span>)'; } - $output .= '<fieldset style="border:1px solid #0000FF;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; - $output .= "\n"; - $output .= '<legend style="color:#0000FF;"> '.$this->CI->lang->line('profiler_database').': '.$db->database.' '.$this->CI->lang->line('profiler_queries').': '.count($db->queries).' '.$show_hide_js.'</legend>'; - $output .= "\n"; - $output .= "\n\n<table style='width:100%;{$hide_queries}' id='ci_profiler_queries_db_{$count}'>\n"; + $output .= '<fieldset style="border:1px solid #0000FF;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">' + . "\n" + . '<legend style="color:#0000FF;"> '.$this->CI->lang->line('profiler_database').': '.$db->database.' '.$this->CI->lang->line('profiler_queries').': '.count($db->queries).' '.$show_hide_js.'</legend>' + . "\n\n\n<table style='width:100%;{$hide_queries}' id='ci_profiler_queries_db_{$count}'>\n"; - if (count($db->queries) == 0) + if (count($db->queries) === 0) { $output .= "<tr><td style='width:100%;color:#0000FF;font-weight:normal;background-color:#eee;padding:5px;'>".$this->CI->lang->line('profiler_no_queries')."</td></tr>\n"; } @@ -243,8 +231,7 @@ class CI_Profiler { } } - $output .= "</table>\n"; - $output .= "</fieldset>"; + $output .= "</table>\n</fieldset>"; } @@ -261,13 +248,13 @@ class CI_Profiler { */ protected function _compile_get() { - $output = "\n\n"; - $output .= '<fieldset id="ci_profiler_get" style="border:1px solid #cd6e00;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; - $output .= "\n"; - $output .= '<legend style="color:#cd6e00;"> '.$this->CI->lang->line('profiler_get_data').' </legend>'; - $output .= "\n"; + $output = "\n\n" + . '<fieldset id="ci_profiler_get" style="border:1px solid #cd6e00;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">' + . "\n" + . '<legend style="color:#cd6e00;"> '.$this->CI->lang->line('profiler_get_data').' </legend>' + . "\n"; - if (count($_GET) == 0) + if (count($_GET) === 0) { $output .= "<div style='color:#cd6e00;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->lang->line('profiler_no_get')."</div>"; } @@ -282,23 +269,15 @@ class CI_Profiler { $key = "'".$key."'"; } - $output .= "<tr><td style='width:50%;color:#000;background-color:#ddd;padding:5px'>$_GET[".$key."] </td><td style='width:50%;padding:5px;color:#cd6e00;font-weight:normal;background-color:#ddd;'>"; - if (is_array($val)) - { - $output .= "<pre>" . htmlspecialchars(stripslashes(print_r($val, true))) . "</pre>"; - } - else - { - $output .= htmlspecialchars(stripslashes($val)); - } - $output .= "</td></tr>\n"; + $output .= "<tr><td style='width:50%;color:#000;background-color:#ddd;padding:5px'>$_GET[".$key."] </td><td style='width:50%;padding:5px;color:#cd6e00;font-weight:normal;background-color:#ddd;'>" + . (is_array($val) ? "<pre>" . htmlspecialchars(stripslashes(print_r($val, true))) . "</pre>" : htmlspecialchars(stripslashes($val))) + . "</td></tr>\n"; } $output .= "</table>\n"; } - $output .= "</fieldset>"; - return $output; + return $output.'</fieldset>'; } // -------------------------------------------------------------------- @@ -310,11 +289,11 @@ class CI_Profiler { */ protected function _compile_post() { - $output = "\n\n"; - $output .= '<fieldset id="ci_profiler_post" style="border:1px solid #009900;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; - $output .= "\n"; - $output .= '<legend style="color:#009900;"> '.$this->CI->lang->line('profiler_post_data').' </legend>'; - $output .= "\n"; + $output = "\n\n" + . '<fieldset id="ci_profiler_post" style="border:1px solid #009900;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">' + . "\n" + . '<legend style="color:#009900;"> '.$this->CI->lang->line('profiler_post_data').' </legend>' + . "\n"; if (count($_POST) == 0) { @@ -345,9 +324,8 @@ class CI_Profiler { $output .= "</table>\n"; } - $output .= "</fieldset>"; - return $output; + return $output.'</fieldset>'; } // -------------------------------------------------------------------- @@ -359,24 +337,13 @@ class CI_Profiler { */ protected function _compile_uri_string() { - $output = "\n\n"; - $output .= '<fieldset id="ci_profiler_uri_string" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; - $output .= "\n"; - $output .= '<legend style="color:#000;"> '.$this->CI->lang->line('profiler_uri_string').' </legend>'; - $output .= "\n"; - - if ($this->CI->uri->uri_string == '') - { - $output .= "<div style='color:#000;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->lang->line('profiler_no_uri')."</div>"; - } - else - { - $output .= "<div style='color:#000;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->uri->uri_string."</div>"; - } - - $output .= "</fieldset>"; - - return $output; + return "\n\n" + . '<fieldset id="ci_profiler_uri_string" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">' + . "\n" + . '<legend style="color:#000;"> '.$this->CI->lang->line('profiler_uri_string').' </legend>' + . "\n<div style='color:#000;font-weight:normal;padding:4px 0 4px 0'>" + . ($this->CI->uri->uri_string == '' ? $this->CI->lang->line('profiler_no_uri') : $this->CI->uri->uri_string) + . '</div></fieldset>'; } // -------------------------------------------------------------------- @@ -388,17 +355,12 @@ class CI_Profiler { */ protected function _compile_controller_info() { - $output = "\n\n"; - $output .= '<fieldset id="ci_profiler_controller_info" style="border:1px solid #995300;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; - $output .= "\n"; - $output .= '<legend style="color:#995300;"> '.$this->CI->lang->line('profiler_controller_info').' </legend>'; - $output .= "\n"; - - $output .= "<div style='color:#995300;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->router->fetch_class()."/".$this->CI->router->fetch_method()."</div>"; - - $output .= "</fieldset>"; - - return $output; + return "\n\n" + . '<fieldset id="ci_profiler_controller_info" style="border:1px solid #995300;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">' + . "\n" + . '<legend style="color:#995300;"> '.$this->CI->lang->line('profiler_controller_info').' </legend>' + . "\n<div style='color:#995300;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->router->fetch_class().'/'.$this->CI->router->fetch_method() + . '</div></fieldset>'; } // -------------------------------------------------------------------- @@ -412,24 +374,13 @@ class CI_Profiler { */ protected function _compile_memory_usage() { - $output = "\n\n"; - $output .= '<fieldset id="ci_profiler_memory_usage" style="border:1px solid #5a0099;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; - $output .= "\n"; - $output .= '<legend style="color:#5a0099;"> '.$this->CI->lang->line('profiler_memory_usage').' </legend>'; - $output .= "\n"; - - if (function_exists('memory_get_usage') && ($usage = memory_get_usage()) != '') - { - $output .= "<div style='color:#5a0099;font-weight:normal;padding:4px 0 4px 0'>".number_format($usage).' bytes</div>'; - } - else - { - $output .= "<div style='color:#5a0099;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->lang->line('profiler_no_memory')."</div>"; - } - - $output .= "</fieldset>"; - - return $output; + return "\n\n" + . '<fieldset id="ci_profiler_memory_usage" style="border:1px solid #5a0099;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">' + . "\n" + . '<legend style="color:#5a0099;"> '.$this->CI->lang->line('profiler_memory_usage').' </legend>' + . "\n<div style='color:#5a0099;font-weight:normal;padding:4px 0 4px 0'>" + . ((function_exists('memory_get_usage') && ($usage = memory_get_usage()) != '') ? number_format($usage).' bytes' : $this->CI->lang->line('profiler_no_memory')) + . '</div></fieldset>'; } // -------------------------------------------------------------------- @@ -443,13 +394,11 @@ class CI_Profiler { */ protected function _compile_http_headers() { - $output = "\n\n"; - $output .= '<fieldset id="ci_profiler_http_headers" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; - $output .= "\n"; - $output .= '<legend style="color:#000;"> '.$this->CI->lang->line('profiler_headers').' (<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_httpheaders_table\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_show').'\'?\''.$this->CI->lang->line('profiler_section_hide').'\':\''.$this->CI->lang->line('profiler_section_show').'\';">'.$this->CI->lang->line('profiler_section_show').'</span>)</legend>'; - $output .= "\n"; - - $output .= "\n\n<table style='width:100%;display:none' id='ci_profiler_httpheaders_table'>\n"; + $output = "\n\n" + . '<fieldset id="ci_profiler_http_headers" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">' + . "\n" + . '<legend style="color:#000;"> '.$this->CI->lang->line('profiler_headers').' (<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_httpheaders_table\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_show').'\'?\''.$this->CI->lang->line('profiler_section_hide').'\':\''.$this->CI->lang->line('profiler_section_show').'\';">'.$this->CI->lang->line('profiler_section_show').'</span>)</legend>' + . "\n\n\n<table style='width:100%;display:none' id='ci_profiler_httpheaders_table'>\n"; foreach (array('HTTP_ACCEPT', 'HTTP_USER_AGENT', 'HTTP_CONNECTION', 'SERVER_PORT', 'SERVER_NAME', 'REMOTE_ADDR', 'SERVER_SOFTWARE', 'HTTP_ACCEPT_LANGUAGE', 'SCRIPT_NAME', 'REQUEST_METHOD',' HTTP_HOST', 'REMOTE_HOST', 'CONTENT_TYPE', 'SERVER_PROTOCOL', 'QUERY_STRING', 'HTTP_ACCEPT_ENCODING', 'HTTP_X_FORWARDED_FOR') as $header) { @@ -457,10 +406,7 @@ class CI_Profiler { $output .= "<tr><td style='vertical-align: top;width:50%;padding:5px;color:#900;background-color:#ddd;'>".$header." </td><td style='width:50%;padding:5px;color:#000;background-color:#ddd;'>".$val."</td></tr>\n"; } - $output .= "</table>\n"; - $output .= "</fieldset>"; - - return $output; + return $output."</table>\n</fieldset>"; } // -------------------------------------------------------------------- @@ -474,13 +420,11 @@ class CI_Profiler { */ protected function _compile_config() { - $output = "\n\n"; - $output .= '<fieldset id="ci_profiler_config" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; - $output .= "\n"; - $output .= '<legend style="color:#000;"> '.$this->CI->lang->line('profiler_config').' (<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_config_table\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_show').'\'?\''.$this->CI->lang->line('profiler_section_hide').'\':\''.$this->CI->lang->line('profiler_section_show').'\';">'.$this->CI->lang->line('profiler_section_show').'</span>)</legend>'; - $output .= "\n"; - - $output .= "\n\n<table style='width:100%; display:none' id='ci_profiler_config_table'>\n"; + $output = "\n\n" + . '<fieldset id="ci_profiler_config" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">' + . "\n" + . '<legend style="color:#000;"> '.$this->CI->lang->line('profiler_config').' (<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_config_table\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_show').'\'?\''.$this->CI->lang->line('profiler_section_hide').'\':\''.$this->CI->lang->line('profiler_section_show').'\';">'.$this->CI->lang->line('profiler_section_show').'</span>)</legend>' + . "\n\n\n<table style='width:100%; display:none' id='ci_profiler_config_table'>\n"; foreach ($this->CI->config->config as $config=>$val) { @@ -492,10 +436,7 @@ class CI_Profiler { $output .= "<tr><td style='padding:5px; vertical-align: top;color:#900;background-color:#ddd;'>".$config." </td><td style='padding:5px; color:#000;background-color:#ddd;'>".htmlspecialchars($val)."</td></tr>\n"; } - $output .= "</table>\n"; - $output .= "</fieldset>"; - - return $output; + return $output."</table>\n</fieldset>"; } // -------------------------------------------------------------------- @@ -512,9 +453,9 @@ class CI_Profiler { return; } - $output = '<fieldset id="ci_profiler_csession" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">'; - $output .= '<legend style="color:#000;"> '.$this->CI->lang->line('profiler_session_data').' (<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_session_data\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_show').'\'?\''.$this->CI->lang->line('profiler_section_hide').'\':\''.$this->CI->lang->line('profiler_section_show').'\';">'.$this->CI->lang->line('profiler_section_show').'</span>)</legend>'; - $output .= "<table style='width:100%;display:none' id='ci_profiler_session_data'>"; + $output = '<fieldset id="ci_profiler_csession" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">' + . '<legend style="color:#000;"> '.$this->CI->lang->line('profiler_session_data').' (<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_session_data\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_show').'\'?\''.$this->CI->lang->line('profiler_section_hide').'\':\''.$this->CI->lang->line('profiler_section_show').'\';">'.$this->CI->lang->line('profiler_section_show').'</span>)</legend>' + . "<table style='width:100%;display:none' id='ci_profiler_session_data'>"; foreach ($this->CI->session->all_userdata() as $key => $val) { @@ -526,9 +467,7 @@ class CI_Profiler { $output .= "<tr><td style='padding:5px; vertical-align: top;color:#900;background-color:#ddd;'>".$key." </td><td style='padding:5px; color:#000;background-color:#ddd;'>".htmlspecialchars($val)."</td></tr>\n"; } - $output .= '</table>'; - $output .= "</fieldset>"; - return $output; + return $output."</table>\n</fieldset>"; } // -------------------------------------------------------------------- @@ -553,14 +492,12 @@ class CI_Profiler { } } - if ($fields_displayed == 0) + if ($fields_displayed === 0) { $output .= '<p style="border:1px solid #5a0099;padding:10px;margin:20px 0;background-color:#eee">'.$this->CI->lang->line('profiler_no_profiles').'</p>'; } - $output .= '</div>'; - - return $output; + return $output.'</div>'; } } diff --git a/system/libraries/Sha1.php b/system/libraries/Sha1.php deleted file mode 100644 index 477b92bcb..000000000 --- a/system/libraries/Sha1.php +++ /dev/null @@ -1,263 +0,0 @@ -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); -/** - * CodeIgniter - * - * An open source application development framework for PHP 5.1.6 or newer - * - * NOTICE OF LICENSE - * - * Licensed under the Open Software License version 3.0 - * - * This source file is subject to the Open Software License (OSL 3.0) that is - * bundled with this package in the files license.txt / license.rst. It is - * also available through the world wide web at this URL: - * http://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to obtain it - * through the world wide web, please send an email to - * licensing@ellislab.com so we can send you a copy immediately. - * - * @package CodeIgniter - * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/) - * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - * @link http://codeigniter.com - * @since Version 1.0 - * @filesource - */ - -// ------------------------------------------------------------------------ - -/** - * SHA1 Encoding Class - * - * Purpose: Provides 160 bit hashing using The Secure Hash Algorithm - * developed at the National Institute of Standards and Technology. The 40 - * character SHA1 message hash is computationally infeasible to crack. - * - * This class is a fallback for servers that are not running PHP greater than - * 4.3, or do not have the MHASH library. - * - * This class is based on two scripts: - * - * Marcus Campbell's PHP implementation (GNU license) - * http://www.tecknik.net/sha-1/ - * - * ...which is based on Paul Johnston's JavaScript version - * (BSD license). http://pajhome.org.uk/ - * - * I encapsulated the functions and wrote one additional method to fix - * a hex conversion bug. - Rick Ellis - * - * @package CodeIgniter - * @subpackage Libraries - * @category Encryption - * @author EllisLab Dev Team - * @link http://codeigniter.com/user_guide/libraries/encryption.html - */ -class CI_SHA1 { - - public function __construct() - { - log_message('debug', "SHA1 Class Initialized"); - } - - /** - * Generate the Hash - * - * @access public - * @param string - * @return string - */ - function generate($str) - { - $n = ((strlen($str) + 8) >> 6) + 1; - - for ($i = 0; $i < $n * 16; $i++) - { - $x[$i] = 0; - } - - for ($i = 0; $i < strlen($str); $i++) - { - $x[$i >> 2] |= ord(substr($str, $i, 1)) << (24 - ($i % 4) * 8); - } - - $x[$i >> 2] |= 0x80 << (24 - ($i % 4) * 8); - - $x[$n * 16 - 1] = strlen($str) * 8; - - $a = 1732584193; - $b = -271733879; - $c = -1732584194; - $d = 271733878; - $e = -1009589776; - - for ($i = 0; $i < count($x); $i += 16) - { - $olda = $a; - $oldb = $b; - $oldc = $c; - $oldd = $d; - $olde = $e; - - for ($j = 0; $j < 80; $j++) - { - if ($j < 16) - { - $w[$j] = $x[$i + $j]; - } - else - { - $w[$j] = $this->_rol($w[$j - 3] ^ $w[$j - 8] ^ $w[$j - 14] ^ $w[$j - 16], 1); - } - - $t = $this->_safe_add($this->_safe_add($this->_rol($a, 5), $this->_ft($j, $b, $c, $d)), $this->_safe_add($this->_safe_add($e, $w[$j]), $this->_kt($j))); - - $e = $d; - $d = $c; - $c = $this->_rol($b, 30); - $b = $a; - $a = $t; - } - - $a = $this->_safe_add($a, $olda); - $b = $this->_safe_add($b, $oldb); - $c = $this->_safe_add($c, $oldc); - $d = $this->_safe_add($d, $oldd); - $e = $this->_safe_add($e, $olde); - } - - return $this->_hex($a).$this->_hex($b).$this->_hex($c).$this->_hex($d).$this->_hex($e); - } - - // -------------------------------------------------------------------- - - /** - * Convert a decimal to hex - * - * @access private - * @param string - * @return string - */ - function _hex($str) - { - $str = dechex($str); - - if (strlen($str) == 7) - { - $str = '0'.$str; - } - - return $str; - } - - // -------------------------------------------------------------------- - - /** - * Return result based on iteration - * - * @access private - * @return string - */ - function _ft($t, $b, $c, $d) - { - if ($t < 20) - return ($b & $c) | ((~$b) & $d); - if ($t < 40) - return $b ^ $c ^ $d; - if ($t < 60) - return ($b & $c) | ($b & $d) | ($c & $d); - - return $b ^ $c ^ $d; - } - - // -------------------------------------------------------------------- - - /** - * Determine the additive constant - * - * @access private - * @return string - */ - function _kt($t) - { - if ($t < 20) - { - return 1518500249; - } - else if ($t < 40) - { - return 1859775393; - } - else if ($t < 60) - { - return -1894007588; - } - else - { - return -899497514; - } - } - - // -------------------------------------------------------------------- - - /** - * Add integers, wrapping at 2^32 - * - * @access private - * @return string - */ - function _safe_add($x, $y) - { - $lsw = ($x & 0xFFFF) + ($y & 0xFFFF); - $msw = ($x >> 16) + ($y >> 16) + ($lsw >> 16); - - return ($msw << 16) | ($lsw & 0xFFFF); - } - - // -------------------------------------------------------------------- - - /** - * Bitwise rotate a 32-bit number - * - * @access private - * @return integer - */ - function _rol($num, $cnt) - { - return ($num << $cnt) | $this->_zero_fill($num, 32 - $cnt); - } - - // -------------------------------------------------------------------- - - /** - * Pad string with zero - * - * @access private - * @return string - */ - function _zero_fill($a, $b) - { - $bin = decbin($a); - - if (strlen($bin) < $b) - { - $bin = 0; - } - else - { - $bin = substr($bin, 0, strlen($bin) - $b); - } - - for ($i=0; $i < $b; $i++) - { - $bin = "0".$bin; - } - - return bindec($bin); - } -} -// END CI_SHA - -/* End of file Sha1.php */ -/* Location: ./system/libraries/Sha1.php */ diff --git a/system/libraries/Typography.php b/system/libraries/Typography.php index af6ca2bf2..651ba7bff 100644 --- a/system/libraries/Typography.php +++ b/system/libraries/Typography.php @@ -1,13 +1,13 @@ -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); +<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); /** * CodeIgniter * * An open source application development framework for PHP 5.1.6 or newer * * NOTICE OF LICENSE - * + * * Licensed under the Open Software License version 3.0 - * + * * This source file is subject to the Open Software License (OSL 3.0) that is * bundled with this package in the files license.txt / license.rst. It is * also available through the world wide web at this URL: @@ -31,7 +31,7 @@ * Typography Class * * - * @access private + * @access protected * @category Helpers * @author EllisLab Dev Team * @link http://codeigniter.com/user_guide/libraries/typography.html @@ -39,22 +39,22 @@ class CI_Typography { // Block level elements that should not be wrapped inside <p> tags - var $block_elements = 'address|blockquote|div|dl|fieldset|form|h\d|hr|noscript|object|ol|p|pre|script|table|ul'; + public $block_elements = 'address|blockquote|div|dl|fieldset|form|h\d|hr|noscript|object|ol|p|pre|script|table|ul'; // Elements that should not have <p> and <br /> tags within them. - var $skip_elements = 'p|pre|ol|ul|dl|object|table|h\d'; + public $skip_elements = 'p|pre|ol|ul|dl|object|table|h\d'; // Tags we want the parser to completely ignore when splitting the string. - var $inline_elements = 'a|abbr|acronym|b|bdo|big|br|button|cite|code|del|dfn|em|i|img|ins|input|label|map|kbd|q|samp|select|small|span|strong|sub|sup|textarea|tt|var'; + public $inline_elements = 'a|abbr|acronym|b|bdo|big|br|button|cite|code|del|dfn|em|i|img|ins|input|label|map|kbd|q|samp|select|small|span|strong|sub|sup|textarea|tt|var'; // array of block level elements that require inner content to be within another block level element - var $inner_block_required = array('blockquote'); + public $inner_block_required = array('blockquote'); // the last block element parsed - var $last_block_element = ''; + public $last_block_element = ''; // whether or not to protect quotes within { curly braces } - var $protect_braced_quotes = FALSE; + public $protect_braced_quotes = FALSE; /** * Auto Typography @@ -72,7 +72,7 @@ class CI_Typography { * @param bool whether to reduce more then two consecutive newlines to two * @return string */ - function auto_typography($str, $reduce_linebreaks = FALSE) + public function auto_typography($str, $reduce_linebreaks = FALSE) { if ($str == '') { @@ -127,35 +127,32 @@ class CI_Typography { // adversely affected if they are split out so we'll convert the opening bracket < temporarily to: {@TAG} $str = preg_replace("#<(/*)(".$this->inline_elements.")([ >])#i", "{@TAG}\\1\\2\\3", $str); - // Split the string at every tag. This expression creates an array with this prototype: - // - // [array] - // { - // [0] = <opening tag> - // [1] = Content... - // [2] = <closing tag> - // Etc... - // } + /* Split the string at every tag. This expression creates an array with this prototype: + * + * [array] + * { + * [0] = <opening tag> + * [1] = Content... + * [2] = <closing tag> + * Etc... + * } + */ $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 $str = ''; $process = TRUE; $paragraph = FALSE; - $current_chunk = 0; - $total_chunks = count($chunks); - foreach ($chunks as $chunk) + for ($i = 1, $c = count($chunks); $i <= $c; $i++) { - $current_chunk++; - // Are we dealing with a tag? If so, we'll skip the processing for this cycle. // Well also set the "process" flag which allows us to skip <pre> tags and a few other things. - if (preg_match("#<(/*)(".$this->block_elements.").*?>#", $chunk, $match)) + if (preg_match("#<(/*)(".$this->block_elements.").*?>#", $chunks[$i], $match)) { if (preg_match("#".$this->skip_elements."#", $match[2])) { - $process = ($match[1] == '/') ? TRUE : FALSE; + $process = ($match[1] === '/'); } if ($match[1] == '') @@ -163,24 +160,24 @@ class CI_Typography { $this->last_block_element = $match[2]; } - $str .= $chunk; + $str .= $chunks[$i]; continue; } - if ($process == FALSE) + if ($process === FALSE) { - $str .= $chunk; + $str .= $chunks[$i]; continue; } // Force a newline to make sure end tags get processed by _format_newlines() - if ($current_chunk == $total_chunks) + if ($i === $c) { - $chunk .= "\n"; + $chunks[$i] .= "\n"; } // Convert Newlines into <p> and <br /> tags - $str .= $this->_format_newlines($chunk); + $str .= $this->_format_newlines($chunks[$i]); } // No opening block level tag? Add it if needed. @@ -265,7 +262,7 @@ class CI_Typography { * @param string * @return string */ - function format_characters($str) + public function format_characters($str) { static $table; @@ -325,18 +322,13 @@ class CI_Typography { * * Converts newline characters into either <p> tags or <br /> * - * @access public + * @access protected * @param string * @return string */ - function _format_newlines($str) + protected function _format_newlines($str) { - if ($str == '') - { - return $str; - } - - if (strpos($str, "\n") === FALSE && ! in_array($this->last_block_element, $this->inner_block_required)) + if ($str == '' OR (strpos($str, "\n") === FALSE AND ! in_array($this->last_block_element, $this->inner_block_required))) { return $str; } @@ -373,11 +365,11 @@ class CI_Typography { * and we don't want double dashes converted to emdash entities, so they are marked with {@DD} * likewise double spaces are converted to {@NBS} to prevent entity conversion * - * @access public + * @access protected * @param array * @return string */ - function _protect_characters($match) + protected function _protect_characters($match) { return str_replace(array("'",'"','--',' '), array('{@SQ}', '{@DQ}', '{@DD}', '{@NBS}'), $match[0]); } @@ -391,25 +383,16 @@ class CI_Typography { * @param string * @return string */ - function nl2br_except_pre($str) + public function nl2br_except_pre($str) { - $ex = explode("pre>",$str); - $ct = count($ex); - - $newstr = ""; - for ($i = 0; $i < $ct; $i++) + $newstr = ''; + for ($ex = explode('pre>', $str), $ct = count($ex), $i = 0; $i < $ct; $i++) { - if (($i % 2) == 0) + $newstr .= (($i % 2) === 0) ? nl2br($ex[$i]) : $ex[$i]; + if ($ct - 1 !== $i) { - $newstr .= nl2br($ex[$i]); + $newstr .= 'pre>'; } - else - { - $newstr .= $ex[$i]; - } - - if ($ct - 1 != $i) - $newstr .= "pre>"; } return $newstr; diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 826bcceb8..5108afa1b 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -952,17 +952,12 @@ class CI_Upload { { global $mimes; - if (count($this->mimes) == 0) + if (count($this->mimes) === 0) { - if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php')) - { - include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'); - } - elseif (is_file(APPPATH.'config/mimes.php')) - { - include(APPPATH.'config//mimes.php'); - } - else + load_environ_config('mimes'); + + // Return FALSE if we still have no mimes after trying to load them up. + if (count($this->mimes) === 0) { return FALSE; } diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php index a007acec8..4a29d7d94 100644 --- a/system/libraries/User_agent.php +++ b/system/libraries/User_agent.php @@ -96,15 +96,10 @@ class CI_User_agent { */ private function _load_agent_file() { - if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php')) - { - include(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php'); - } - elseif (is_file(APPPATH.'config/user_agents.php')) - { - include(APPPATH.'config/user_agents.php'); - } - else + load_environ_config('user_agents'); + + // Return FALSE if we still have no mimes after trying to load them up. + if (count($this->mimes) === 0) { return FALSE; } diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php index 587b75040..893e51873 100644 --- a/system/libraries/Xmlrpcs.php +++ b/system/libraries/Xmlrpcs.php @@ -1,13 +1,13 @@ -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); +<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); /** * CodeIgniter * * An open source application development framework for PHP 5.1.6 or newer * * NOTICE OF LICENSE - * + * * Licensed under the Open Software License version 3.0 - * + * * This source file is subject to the Open Software License (OSL 3.0) that is * bundled with this package in the files license.txt / license.rst. It is * also available through the world wide web at this URL: @@ -48,12 +48,11 @@ if ( ! class_exists('CI_Xmlrpc')) */ class CI_Xmlrpcs extends CI_Xmlrpc { - var $methods = array(); //array of methods mapped to function names and signatures - var $debug_msg = ''; // Debug Message - var $system_methods = array(); // XML RPC Server methods - var $controller_obj; - - var $object = FALSE; + public $methods = array(); //array of methods mapped to function names and signatures + public $debug_msg = ''; // Debug Message + public $system_methods = array(); // XML RPC Server methods + public $controller_obj; + public $object = FALSE; /** * Constructor @@ -80,7 +79,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc * @param mixed * @return void */ - function initialize($config=array()) + public function initialize($config = array()) { if (isset($config['functions']) && is_array($config['functions'])) { @@ -111,26 +110,26 @@ class CI_Xmlrpcs extends CI_Xmlrpc * @access public * @return void */ - function set_system_methods() + public function set_system_methods() { $this->methods = array( 'system.listMethods' => array( - 'function' => 'this.listMethods', - 'signature' => array(array($this->xmlrpcArray, $this->xmlrpcString), array($this->xmlrpcArray)), - 'docstring' => 'Returns an array of available methods on this server'), - 'system.methodHelp' => array( - 'function' => 'this.methodHelp', - 'signature' => array(array($this->xmlrpcString, $this->xmlrpcString)), - 'docstring' => 'Returns a documentation string for the specified method'), + 'function' => 'this.listMethods', + 'signature' => array(array($this->xmlrpcArray, $this->xmlrpcString), array($this->xmlrpcArray)), + 'docstring' => 'Returns an array of available methods on this server'), + 'system.methodHelp' => array( + 'function' => 'this.methodHelp', + 'signature' => array(array($this->xmlrpcString, $this->xmlrpcString)), + 'docstring' => 'Returns a documentation string for the specified method'), 'system.methodSignature' => array( - 'function' => 'this.methodSignature', - 'signature' => array(array($this->xmlrpcArray, $this->xmlrpcString)), - 'docstring' => 'Returns an array describing the return type and required parameters of a method'), - 'system.multicall' => array( - 'function' => 'this.multicall', - 'signature' => array(array($this->xmlrpcArray, $this->xmlrpcArray)), - 'docstring' => 'Combine multiple RPC calls in one request. See http://www.xmlrpc.com/discuss/msgReader$1208 for details') - ); + 'function' => 'this.methodSignature', + 'signature' => array(array($this->xmlrpcArray, $this->xmlrpcString)), + 'docstring' => 'Returns an array describing the return type and required parameters of a method'), + 'system.multicall' => array( + 'function' => 'this.multicall', + 'signature' => array(array($this->xmlrpcArray, $this->xmlrpcArray)), + 'docstring' => 'Combine multiple RPC calls in one request. See http://www.xmlrpc.com/discuss/msgReader$1208 for details') + ); } // -------------------------------------------------------------------- @@ -141,12 +140,10 @@ class CI_Xmlrpcs extends CI_Xmlrpc * @access public * @return void */ - function serve() + public function serve() { $r = $this->parseRequest(); - $payload = '<?xml version="1.0" encoding="'.$this->xmlrpc_defencoding.'"?'.'>'."\n"; - $payload .= $this->debug_msg; - $payload .= $r->prepare_response(); + $payload = '<?xml version="1.0" encoding="'.$this->xmlrpc_defencoding.'"?'.'>'."\n".$this->debug_msg.$r->prepare_response(); header("Content-Type: text/xml"); header("Content-Length: ".strlen($payload)); @@ -165,7 +162,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc * @param string docstring * @return void */ - function add_to_map($methodname, $function, $sig, $doc) + public function add_to_map($methodname, $function, $sig, $doc) { $this->methods[$methodname] = array( 'function' => $function, @@ -183,7 +180,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc * @param string data * @return object xmlrpc response */ - function parseRequest($data='') + public function parseRequest($data = '') { global $HTTP_RAW_POST_DATA; @@ -203,13 +200,14 @@ class CI_Xmlrpcs extends CI_Xmlrpc $parser = xml_parser_create($this->xmlrpc_defencoding); $parser_object = new XML_RPC_Message("filler"); - $parser_object->xh[$parser] = array(); - $parser_object->xh[$parser]['isf'] = 0; - $parser_object->xh[$parser]['isf_reason'] = ''; - $parser_object->xh[$parser]['params'] = array(); - $parser_object->xh[$parser]['stack'] = array(); - $parser_object->xh[$parser]['valuestack'] = array(); - $parser_object->xh[$parser]['method'] = ''; + $parser_object->xh[$parser] = array( + 'isf' => 0, + 'isf_reason' => '', + 'params' => array(), + 'stack' => array(), + 'valuestack' => array(), + 'method' => '' + ); xml_set_object($parser, $parser_object); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true); @@ -243,7 +241,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc $m = new XML_RPC_Message($parser_object->xh[$parser]['method']); $plist=''; - for ($i=0; $i < count($parser_object->xh[$parser]['params']); $i++) + for ($i = 0, $c = count($parser_object->xh[$parser]['params']); $i < $c; $i++) { if ($this->debug === TRUE) { @@ -255,9 +253,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc if ($this->debug === TRUE) { - echo "<pre>"; - echo "---PLIST---\n" . $plist . "\n---PLIST END---\n\n"; - echo "</pre>"; + echo "<pre>---PLIST---\n".$plist."\n---PLIST END---\n\n</pre>"; } $r = $this->_execute($m); @@ -284,12 +280,12 @@ class CI_Xmlrpcs extends CI_Xmlrpc * @param object * @return mixed */ - function _execute($m) + protected function _execute($m) { $methName = $m->method_name; // Check to see if it is a system call - $system_call = (strncmp($methName, 'system', 5) == 0) ? TRUE : FALSE; + $system_call = (strncmp($methName, 'system', 5) === 0); if ($this->xss_clean == FALSE) { @@ -310,22 +306,20 @@ class CI_Xmlrpcs extends CI_Xmlrpc //------------------------------------- $method_parts = explode(".", $this->methods[$methName]['function']); - $objectCall = (isset($method_parts['1']) && $method_parts['1'] != "") ? TRUE : FALSE; + $objectCall = (isset($method_parts[1]) && $method_parts[1] != ''); if ($system_call === TRUE) { - if ( ! is_callable(array($this,$method_parts['1']))) + if ( ! is_callable(array($this,$method_parts[1]))) { return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']); } } else { - if ($objectCall && ! is_callable(array($method_parts['0'],$method_parts['1']))) - { - return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']); - } - elseif ( ! $objectCall && ! is_callable($this->methods[$methName]['function'])) + if (($objectCall AND ! is_callable(array($method_parts[0], $method_parts[1]))) + OR ( ! $objectCall AND ! is_callable($this->methods[$methName]['function'])) + ) { return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']); } @@ -338,13 +332,13 @@ class CI_Xmlrpcs extends CI_Xmlrpc if (isset($this->methods[$methName]['signature'])) { $sig = $this->methods[$methName]['signature']; - for ($i=0; $i<count($sig); $i++) + for ($i = 0, $c = count($sig); $i < $c; $i++) { $current_sig = $sig[$i]; - if (count($current_sig) == count($m->params)+1) + if (count($current_sig) === count($m->params)+1) { - for ($n=0; $n < count($m->params); $n++) + for ($n = 0, $mc = count($m->params); $n < $mc; $n++) { $p = $m->params[$n]; $pt = ($p->kindOf() == 'scalar') ? $p->scalarval() : $p->kindOf(); @@ -370,7 +364,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc if ($objectCall === TRUE) { - if ($method_parts[0] == "this" && $system_call == TRUE) + if ($method_parts[0] === 'this' && $system_call === TRUE) { return call_user_func(array($this, $method_parts[1]), $m); } @@ -379,11 +373,11 @@ class CI_Xmlrpcs extends CI_Xmlrpc if ($this->object === FALSE) { $CI =& get_instance(); - return $CI->$method_parts['1']($m); + return $CI->$method_parts[1]($m); } else { - return $this->object->$method_parts['1']($m); + return $this->object->$method_parts[1]($m); //return call_user_func(array(&$method_parts['0'],$method_parts['1']), $m); } } @@ -393,7 +387,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc return call_user_func($this->methods[$methName]['function'], $m); } } - + // -------------------------------------------------------------------- /** @@ -403,7 +397,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc * @param mixed * @return object */ - function listMethods($m) + public function listMethods($m) { $v = new XML_RPC_Values(); $output = array(); @@ -421,7 +415,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc $v->addArray($output); return new XML_RPC_Response($v); } - + // -------------------------------------------------------------------- /** @@ -431,7 +425,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc * @param mixed * @return object */ - function methodSignature($m) + public function methodSignature($m) { $parameters = $m->output_parameters(); $method_name = $parameters[0]; @@ -443,15 +437,15 @@ class CI_Xmlrpcs extends CI_Xmlrpc $sigs = array(); $signature = $this->methods[$method_name]['signature']; - for ($i=0; $i < count($signature); $i++) + for ($i = 0, $c = count($signature); $i < $c; $i++) { $cursig = array(); $inSig = $signature[$i]; - for ($j=0; $j<count($inSig); $j++) + for ($j = 0, $jc = count($inSig); $j < $jc; $j++) { $cursig[]= new XML_RPC_Values($inSig[$j], 'string'); } - $sigs[]= new XML_RPC_Values($cursig, 'array'); + $sigs[] = new XML_RPC_Values($cursig, 'array'); } $r = new XML_RPC_Response(new XML_RPC_Values($sigs, 'array')); } @@ -476,7 +470,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc * @param mixed * @return object */ - function methodHelp($m) + public function methodHelp($m) { $parameters = $m->output_parameters(); $method_name = $parameters[0]; @@ -492,7 +486,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc return new XML_RPC_Response(0, $this->xmlrpcerr['introspect_unknown'], $this->xmlrpcstr['introspect_unknown']); } } - + // -------------------------------------------------------------------- /** @@ -502,7 +496,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc * @param mixed * @return object */ - function multicall($m) + public function multicall($m) { // Disabled return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']); @@ -519,7 +513,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc $m = new XML_RPC_Message($value[0]); $plist=''; - for ($i=0; $i < count($value[1]); $i++) + for ($i = 0, $c = count($value[1]); $i < $c; $i++) { $m->addParam(new XML_RPC_Values($value[1][$i], 'string')); } @@ -546,7 +540,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc * @param mixed * @return object */ - function multicall_error($err) + public function multicall_error($err) { $str = is_string($err) ? $this->xmlrpcstr["multicall_${err}"] : $err->faultString(); $code = is_string($err) ? $this->xmlrpcerr["multicall_${err}"] : $err->faultCode(); @@ -566,7 +560,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc * @param mixed * @return object */ - function do_multicall($call) + public function do_multicall($call) { if ($call->kindOf() != 'struct') { @@ -597,11 +591,10 @@ class CI_Xmlrpcs extends CI_Xmlrpc return $this->multicall_error('notarray'); } - list($a,$b)=each($params->me); - $numParams = count($b); + list($a,$b) = each($params->me); $msg = new XML_RPC_Message($scalar_value); - for ($i = 0; $i < $numParams; $i++) + for ($i = 0, $numParams = count($b); $i < $numParams; $i++) { $msg->params[] = $params->me['array'][$i]; } @@ -619,6 +612,5 @@ class CI_Xmlrpcs extends CI_Xmlrpc } // END XML_RPC_Server class - /* End of file Xmlrpcs.php */ -/* Location: ./system/libraries/Xmlrpcs.php */
\ No newline at end of file +/* Location: ./system/libraries/Xmlrpcs.php */ |