summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
Diffstat (limited to 'system')
-rw-r--r--system/core/Utf8.php25
-rw-r--r--system/libraries/Cache/Cache.php36
-rw-r--r--system/libraries/Cache/drivers/Cache_apc.php30
-rw-r--r--system/libraries/Cache/drivers/Cache_dummy.php8
-rw-r--r--system/libraries/Cache/drivers/Cache_file.php55
-rw-r--r--system/libraries/Cache/drivers/Cache_memcached.php10
-rw-r--r--system/libraries/Encrypt.php105
-rw-r--r--system/libraries/Sha1.php263
-rw-r--r--system/libraries/Xmlrpcs.php144
9 files changed, 169 insertions, 507 deletions
diff --git a/system/core/Utf8.php b/system/core/Utf8.php
index 7abe4e43b..1bcf526a5 100644
--- a/system/core/Utf8.php
+++ b/system/core/Utf8.php
@@ -44,19 +44,18 @@ class CI_Utf8 {
* Constructor
*
* Determines if UTF-8 support is to be enabled
- *
*/
- function __construct()
+ public function __construct()
{
log_message('debug', "Utf8 Class Initialized");
global $CFG;
if (
- preg_match('/./u', 'é') === 1 // PCRE must support UTF-8
- AND function_exists('iconv') // iconv must be installed
- AND ini_get('mbstring.func_overload') != 1 // Multibyte string function overloading cannot be enabled
- AND $CFG->item('charset') == 'UTF-8' // Application charset must be UTF-8
+ @preg_match('/./u', 'é') === 1 // PCRE must support UTF-8
+ && function_exists('iconv') // iconv must be installed
+ && ini_get('mbstring.func_overload') !== 1 // Multibyte string function overloading cannot be enabled
+ && $CFG->item('charset') == 'UTF-8' // Application charset must be UTF-8
)
{
log_message('debug', "UTF-8 Support Enabled");
@@ -90,11 +89,10 @@ class CI_Utf8 {
*
* Ensures strings are UTF-8
*
- * @access public
* @param string
* @return string
*/
- function clean_string($str)
+ public function clean_string($str)
{
if ($this->_is_ascii($str) === FALSE)
{
@@ -113,11 +111,10 @@ class CI_Utf8 {
* line feeds, and carriage returns, as all others can cause
* problems in XML
*
- * @access public
* @param string
* @return string
*/
- function safe_ascii_for_xml($str)
+ public function safe_ascii_for_xml($str)
{
return remove_invisible_characters($str, FALSE);
}
@@ -129,12 +126,11 @@ class CI_Utf8 {
*
* Attempts to convert a string to UTF-8
*
- * @access public
* @param string
* @param string - input encoding
* @return string
*/
- function convert_to_utf8($str, $encoding)
+ public function convert_to_utf8($str, $encoding)
{
if (function_exists('iconv'))
{
@@ -159,13 +155,12 @@ class CI_Utf8 {
*
* Tests if a string is standard 7-bit ASCII or not
*
- * @access public
* @param string
* @return bool
*/
- function _is_ascii($str)
+ protected function _is_ascii($str)
{
- return (preg_match('/[^\x00-\x7F]/S', $str) == 0);
+ return (preg_match('/[^\x00-\x7F]/S', $str) === 0);
}
// --------------------------------------------------------------------
diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php
index c296fa770..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,7 +151,7 @@ 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)
@@ -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/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/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/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 */