summaryrefslogtreecommitdiffstats
path: root/system/libraries
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@server-speed.net>2011-04-10 10:39:31 +0200
committerFlorian Pritz <bluewind@server-speed.net>2011-04-10 10:39:31 +0200
commit1bdc9c8903eb2db33fdb8174d61e15100dfbbca8 (patch)
treeb0c645ad99e04f34817fc4e6385792111db42274 /system/libraries
parent413d0cdac49257089a0790f6ac92973a36a6b69f (diff)
update to CI 2.0.2
Signed-off-by: Florian Pritz <bluewind@server-speed.net>
Diffstat (limited to 'system/libraries')
-rwxr-xr-xsystem/libraries/Cache/Cache.php6
-rwxr-xr-xsystem/libraries/Cache/drivers/Cache_apc.php4
-rwxr-xr-xsystem/libraries/Cache/drivers/Cache_dummy.php2
-rwxr-xr-xsystem/libraries/Cache/drivers/Cache_file.php4
-rwxr-xr-xsystem/libraries/Cache/drivers/Cache_memcached.php4
-rwxr-xr-xsystem/libraries/Driver.php30
-rwxr-xr-xsystem/libraries/Email.php12
-rwxr-xr-xsystem/libraries/Form_validation.php77
-rwxr-xr-xsystem/libraries/Image_lib.php2
-rwxr-xr-xsystem/libraries/Javascript.php2
-rwxr-xr-xsystem/libraries/Profiler.php4
-rwxr-xr-xsystem/libraries/Session.php5
-rwxr-xr-xsystem/libraries/Sha1.php4
-rwxr-xr-xsystem/libraries/Table.php11
-rwxr-xr-xsystem/libraries/Trackback.php4
-rwxr-xr-xsystem/libraries/Upload.php27
-rwxr-xr-xsystem/libraries/User_agent.php16
-rwxr-xr-xsystem/libraries/Xmlrpc.php66
-rwxr-xr-xsystem/libraries/Xmlrpcs.php178
-rwxr-xr-xsystem/libraries/Zip.php2
20 files changed, 291 insertions, 169 deletions
diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php
index d3f6105ea..61e7aa761 100755
--- a/system/libraries/Cache/Cache.php
+++ b/system/libraries/Cache/Cache.php
@@ -24,11 +24,11 @@
* @author ExpressionEngine Dev Team
* @link
*/
-class Cache extends CI_Driver_Library {
+class CI_Cache extends CI_Driver_Library {
protected $valid_drivers = array(
- 'cache_apc', 'cache_file', 'cache_memcached', 'cache_dummy'
- );
+ 'cache_apc', 'cache_file', 'cache_memcached', 'cache_dummy'
+ );
protected $_cache_path = NULL; // Path of cache files (if file-based cache)
protected $_adapter = 'dummy';
diff --git a/system/libraries/Cache/drivers/Cache_apc.php b/system/libraries/Cache/drivers/Cache_apc.php
index e82e8e1f5..de75719c4 100755
--- a/system/libraries/Cache/drivers/Cache_apc.php
+++ b/system/libraries/Cache/drivers/Cache_apc.php
@@ -25,7 +25,7 @@
* @link
*/
-class Cache_apc extends CI_Driver {
+class CI_Cache_apc extends CI_Driver {
/**
* Get
@@ -114,7 +114,7 @@ class Cache_apc extends CI_Driver {
return FALSE;
}
- list($value, $time, $ttl) = $stored;
+ list($data, $time, $ttl) = $stored;
return array(
'expire' => $time + $ttl,
diff --git a/system/libraries/Cache/drivers/Cache_dummy.php b/system/libraries/Cache/drivers/Cache_dummy.php
index 74f689241..de47acb43 100755
--- a/system/libraries/Cache/drivers/Cache_dummy.php
+++ b/system/libraries/Cache/drivers/Cache_dummy.php
@@ -25,7 +25,7 @@
* @link
*/
-class Cache_dummy extends CI_Driver {
+class CI_Cache_dummy extends CI_Driver {
/**
* Get
diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php
index 3ed357f2f..13e2d1af6 100755
--- a/system/libraries/Cache/drivers/Cache_file.php
+++ b/system/libraries/Cache/drivers/Cache_file.php
@@ -25,7 +25,7 @@
* @link
*/
-class Cache_file extends CI_Driver {
+class CI_Cache_file extends CI_Driver {
protected $_cache_path;
@@ -39,7 +39,7 @@ class Cache_file extends CI_Driver {
$path = $CI->config->item('cache_path');
- $this->_cache_path = ($path == '') ? BASEPATH.'cache/' : $path;
+ $this->_cache_path = ($path == '') ? APPPATH.'cache/' : $path;
}
// ------------------------------------------------------------------------
diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php
index a7efdc5de..ec2fd216a 100755
--- a/system/libraries/Cache/drivers/Cache_memcached.php
+++ b/system/libraries/Cache/drivers/Cache_memcached.php
@@ -25,7 +25,7 @@
* @link
*/
-class Cache_memcached extends CI_Driver {
+class CI_Cache_memcached extends CI_Driver {
private $_memcached; // Holds the memcached object
@@ -122,7 +122,7 @@ class Cache_memcached extends CI_Driver {
return FALSE;
}
- list($value, $time, $ttl) = $stored;
+ list($data, $time, $ttl) = $stored;
return array(
'expire' => $time + $ttl,
diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php
index 15fc3da26..d1838f2c1 100755
--- a/system/libraries/Driver.php
+++ b/system/libraries/Driver.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
*
@@ -36,7 +36,7 @@ class CI_Driver_Library {
// subsequents calls will go straight to the proper child.
function __get($child)
{
- if (! isset($this->lib_name))
+ if ( ! isset($this->lib_name))
{
$this->lib_name = get_class($this);
}
@@ -44,7 +44,11 @@ class CI_Driver_Library {
// The class will be prefixed with the parent lib
$child_class = $this->lib_name.'_'.$child;
- if (in_array(strtolower($child_class), array_map('strtolower', $this->valid_drivers)))
+ // Remove the CI_ prefix and lowercase
+ $lib_name = strtolower(preg_replace('/^CI_/', '', $this->lib_name));
+ $driver_name = strtolower(preg_replace('/^CI_/', '', $child_class));
+
+ if (in_array($driver_name, array_map('strtolower', $this->valid_drivers)))
{
// check and see if the driver is in a separate file
if ( ! class_exists($child_class))
@@ -52,19 +56,15 @@ class CI_Driver_Library {
// check application path first
foreach (array(APPPATH, BASEPATH) as $path)
{
- // and check for case sensitivity of both the parent and child libs
- foreach (array(ucfirst($this->lib_name), strtolower($this->lib_name)) as $lib)
+ // loves me some nesting!
+ foreach (array(ucfirst($driver_name), $driver_name) as $class)
{
- // loves me some nesting!
- foreach (array(ucfirst($child_class), strtolower($child_class)) as $class)
- {
- $filepath = $path.'libraries/'.$this->lib_name.'/drivers/'.$child_class.EXT;
+ $filepath = $path.'libraries/'.$lib_name.'/drivers/'.$class.EXT;
- if (file_exists($filepath))
- {
- include_once $filepath;
- break;
- }
+ if (file_exists($filepath))
+ {
+ include_once $filepath;
+ break;
}
}
}
@@ -143,7 +143,7 @@ class CI_Driver {
}
}
- foreach($r->getProperties() as $prop)
+ foreach ($r->getProperties() as $prop)
{
if ($prop->isPublic())
{
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index e5af38f45..6c21f114d 100755
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -897,7 +897,7 @@ class CI_Email {
}
$temp = '';
- while((strlen($line)) > $charlim)
+ while ((strlen($line)) > $charlim)
{
// If the over-length word is a URL we won't wrap it
if (preg_match("!\[url.+\]|://|wwww.!", $line))
@@ -973,7 +973,7 @@ class CI_Email {
reset($this->_headers);
$this->_header_str = "";
- foreach($this->_headers as $key => $val)
+ foreach ($this->_headers as $key => $val)
{
$val = trim($val);
@@ -1607,14 +1607,14 @@ class CI_Email {
$this->_send_command('from', $this->clean_email($this->_headers['From']));
- foreach($this->_recipients as $val)
+ foreach ($this->_recipients as $val)
{
$this->_send_command('to', $val);
}
if (count($this->_cc_array) > 0)
{
- foreach($this->_cc_array as $val)
+ foreach ($this->_cc_array as $val)
{
if ($val != "")
{
@@ -1625,7 +1625,7 @@ class CI_Email {
if (count($this->_bcc_array) > 0)
{
- foreach($this->_bcc_array as $val)
+ foreach ($this->_bcc_array as $val)
{
if ($val != "")
{
@@ -1672,7 +1672,7 @@ class CI_Email {
$errstr,
$this->smtp_timeout);
- if( ! is_resource($this->_smtp_connect))
+ if ( ! is_resource($this->_smtp_connect))
{
$this->_set_error_message('email_smtp_error', $errno." ".$errstr);
return FALSE;
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index fc5b82ee3..cfc02eda9 100755
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -138,14 +138,14 @@ class CI_Form_validation {
// Build our master array
$this->_field_data[$field] = array(
- 'field' => $field,
- 'label' => $label,
- 'rules' => $rules,
- 'is_array' => $is_array,
- 'keys' => $indexes,
- 'postdata' => NULL,
- 'error' => ''
- );
+ 'field' => $field,
+ 'label' => $label,
+ 'rules' => $rules,
+ 'is_array' => $is_array,
+ 'keys' => $indexes,
+ 'postdata' => NULL,
+ 'error' => ''
+ );
return $this;
}
@@ -1040,7 +1040,7 @@ class CI_Form_validation {
return $this->valid_email(trim($str));
}
- foreach(explode(',', $str) as $email)
+ foreach (explode(',', $str) as $email)
{
if (trim($email) != '' && $this->valid_email(trim($email)) === FALSE)
{
@@ -1147,7 +1147,57 @@ class CI_Form_validation {
*/
function integer($str)
{
- return (bool)preg_match( '/^[\-+]?[0-9]+$/', $str);
+ return (bool) preg_match('/^[\-+]?[0-9]+$/', $str);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Decimal number
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function decimal($str)
+ {
+ return (bool) preg_match('/^[\-+]?[0-9]+\.[0-9]+$/', $str);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Greather than
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function greater_than($str, $min)
+ {
+ if ( ! is_numeric($str))
+ {
+ return FALSE;
+ }
+ return $str > $min;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Less than
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function less_than($str, $max)
+ {
+ if ( ! is_numeric($str))
+ {
+ return FALSE;
+ }
+ return $str < $max;
}
// --------------------------------------------------------------------
@@ -1161,7 +1211,7 @@ class CI_Form_validation {
*/
function is_natural($str)
{
- return (bool)preg_match( '/^[0-9]+$/', $str);
+ return (bool) preg_match( '/^[0-9]+$/', $str);
}
// --------------------------------------------------------------------
@@ -1286,11 +1336,6 @@ class CI_Form_validation {
*/
function xss_clean($str)
{
- if ( ! isset($this->CI->security))
- {
- $this->CI->load->library('security');
- }
-
return $this->CI->security->xss_clean($str);
}
diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index 41f9ad393..8902f524d 100755
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -749,7 +749,7 @@ class CI_Image_lib {
@chmod($this->full_dst_path, FILE_WRITE_MODE);
- return true;
+ return TRUE;
}
// --------------------------------------------------------------------
diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php
index 167859abd..34e0d7001 100755
--- a/system/libraries/Javascript.php
+++ b/system/libraries/Javascript.php
@@ -855,7 +855,7 @@ class CI_Javascript {
}
elseif (is_string($result) OR $is_key)
{
- return '"'.str_replace(array('\\', "\t", "\n", "\r", '"'), array('\\\\', '\\t', '\\n', "\\r", '\"'), $result).'"';
+ return '"'.str_replace(array('\\', "\t", "\n", "\r", '"', '/'), array('\\\\', '\\t', '\\n', "\\r", '\"', '\/'), $result).'"';
}
elseif (is_scalar($result))
{
diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php
index 6587eae0b..8a1f18ced 100755
--- a/system/libraries/Profiler.php
+++ b/system/libraries/Profiler.php
@@ -415,7 +415,7 @@ class CI_Profiler {
$output .= "\n\n<table style='width:100%'>\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)
+ 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)
{
$val = (isset($_SERVER[$header])) ? $_SERVER[$header] : '';
$output .= "<tr><td style='vertical-align: top;width:50%;padding:5px;color:#900;background-color:#ddd;'>".$header."&nbsp;&nbsp;</td><td style='width:50%;padding:5px;color:#000;background-color:#ddd;'>".$val."</td></tr>\n";
@@ -446,7 +446,7 @@ class CI_Profiler {
$output .= "\n\n<table style='width:100%'>\n";
- foreach($this->CI->config->config as $config=>$val)
+ foreach ($this->CI->config->config as $config=>$val)
{
if (is_array($val))
{
diff --git a/system/libraries/Session.php b/system/libraries/Session.php
index 53ff4f5d3..182294059 100755
--- a/system/libraries/Session.php
+++ b/system/libraries/Session.php
@@ -37,6 +37,7 @@ class CI_Session {
var $cookie_prefix = '';
var $cookie_path = '';
var $cookie_domain = '';
+ var $cookie_secure = FALSE;
var $sess_time_to_update = 300;
var $encryption_key = '';
var $flashdata_key = 'flash';
@@ -61,7 +62,7 @@ class CI_Session {
// Set all the session preferences, which can either be set
// manually via the $params array above or via the config file
- foreach (array('sess_encrypt_cookie', 'sess_use_database', 'sess_table_name', 'sess_expiration', 'sess_expire_on_close', 'sess_match_ip', 'sess_match_useragent', 'sess_cookie_name', 'cookie_path', 'cookie_domain', 'sess_time_to_update', 'time_reference', 'cookie_prefix', 'encryption_key') as $key)
+ foreach (array('sess_encrypt_cookie', 'sess_use_database', 'sess_table_name', 'sess_expiration', 'sess_expire_on_close', 'sess_match_ip', 'sess_match_useragent', 'sess_cookie_name', 'cookie_path', 'cookie_domain', 'cookie_secure', 'sess_time_to_update', 'time_reference', 'cookie_prefix', 'encryption_key') as $key)
{
$this->$key = (isset($params[$key])) ? $params[$key] : $this->CI->config->item($key);
}
@@ -666,7 +667,7 @@ class CI_Session {
$expire,
$this->cookie_path,
$this->cookie_domain,
- 0
+ $this->cookie_secure
);
}
diff --git a/system/libraries/Sha1.php b/system/libraries/Sha1.php
index ad747a001..1a657572b 100755
--- a/system/libraries/Sha1.php
+++ b/system/libraries/Sha1.php
@@ -42,7 +42,7 @@
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/general/encryption.html
*/
-class CI_SHA {
+class CI_SHA1 {
public function __construct()
{
@@ -88,7 +88,7 @@ class CI_SHA {
$oldd = $d;
$olde = $e;
- for($j = 0; $j < 80; $j++)
+ for ($j = 0; $j < 80; $j++)
{
if ($j < 16)
{
diff --git a/system/libraries/Table.php b/system/libraries/Table.php
index 485541630..def696776 100755
--- a/system/libraries/Table.php
+++ b/system/libraries/Table.php
@@ -108,7 +108,7 @@ class CI_Table {
}
$new = array();
- while(count($array) > 0)
+ while (count($array) > 0)
{
$temp = array_splice($array, 0, $col_limit);
@@ -280,7 +280,7 @@ class CI_Table {
$out .= $this->template['heading_row_start'];
$out .= $this->newline;
- foreach($this->heading as $heading)
+ foreach ($this->heading as $heading)
{
$temp = $this->template['heading_cell_start'];
@@ -310,7 +310,7 @@ class CI_Table {
$out .= $this->newline;
$i = 1;
- foreach($this->rows as $row)
+ foreach ($this->rows as $row)
{
if ( ! is_array($row))
{
@@ -323,7 +323,7 @@ class CI_Table {
$out .= $this->template['row_'.$name.'start'];
$out .= $this->newline;
- foreach($row as $cell)
+ foreach ($row as $cell)
{
$temp = $this->template['cell_'.$name.'start'];
@@ -367,6 +367,9 @@ class CI_Table {
$out .= $this->template['table_close'];
+ // Clear table class properties before generating the table
+ $this->clear();
+
return $out;
}
diff --git a/system/libraries/Trackback.php b/system/libraries/Trackback.php
index e29b35c7a..b0a767822 100755
--- a/system/libraries/Trackback.php
+++ b/system/libraries/Trackback.php
@@ -94,7 +94,7 @@ class CI_Trackback {
{
$$item = $this->convert_ascii($$item);
}
- elseif($item == 'blog_name')
+ elseif ($item == 'blog_name')
{
$$item = $this->convert_ascii($$item);
}
@@ -261,7 +261,7 @@ class CI_Trackback {
// Was it successful?
$this->response = "";
- while( ! feof($fp))
+ while ( ! feof($fp))
{
$this->response .= fgets($fp, 128);
}
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 8f84ffd7e..e80049fa4 100755
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -142,7 +142,8 @@ class CI_Upload {
*/
public function do_upload($field = 'userfile')
{
- // Is $_FILES[$field] set? If not, no reason to continue.
+
+ // Is $_FILES[$field] set? If not, no reason to continue.
if ( ! isset($_FILES[$field]))
{
$this->set_error('upload_no_file_selected');
@@ -214,7 +215,7 @@ class CI_Upload {
$this->file_name = $this->_prep_filename($this->_file_name_override);
// If no extension was provided in the file_name config item, use the uploaded one
- if(strpos($this->_file_name_override, '.') === FALSE)
+ if (strpos($this->_file_name_override, '.') === FALSE)
{
$this->file_name .= $this->file_ext;
}
@@ -874,12 +875,6 @@ class CI_Upload {
}
$CI =& get_instance();
-
- if ( ! isset($CI->security))
- {
- $CI->load->library('security');
- }
-
return $CI->security->xss_clean($data, TRUE);
}
@@ -950,11 +945,21 @@ class CI_Upload {
if (count($this->mimes) == 0)
{
- if (@require_once(APPPATH.'config/mimes'.EXT))
+ if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT))
+ {
+ include(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT);
+ }
+ elseif (is_file(APPPATH.'config/mimes'.EXT))
+ {
+ include(APPPATH.'config//mimes'.EXT);
+ }
+ else
{
- $this->mimes = $mimes;
- unset($mimes);
+ return FALSE;
}
+
+ $this->mimes = $mimes;
+ unset($mimes);
}
return ( ! isset($this->mimes[$mime])) ? FALSE : $this->mimes[$mime];
diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php
index c62174836..04cda7312 100755
--- a/system/libraries/User_agent.php
+++ b/system/libraries/User_agent.php
@@ -84,7 +84,15 @@ class CI_User_agent {
*/
private function _load_agent_file()
{
- if ( ! @include(APPPATH.'config/user_agents'.EXT))
+ if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/user_agents'.EXT))
+ {
+ include(APPPATH.'config/'.ENVIRONMENT.'/user_agents'.EXT);
+ }
+ elseif (is_file(APPPATH.'config/user_agents'.EXT))
+ {
+ include(APPPATH.'config/user_agents'.EXT);
+ }
+ else
{
return FALSE;
}
@@ -375,7 +383,11 @@ class CI_User_agent {
*/
public function is_referral()
{
- return ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '');
+ if ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '')
+ {
+ return FALSE;
+ }
+ return TRUE;
}
// --------------------------------------------------------------------
diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php
index 9cf307cc0..5da6ea6ae 100755
--- a/system/libraries/Xmlrpc.php
+++ b/system/libraries/Xmlrpc.php
@@ -207,7 +207,7 @@ class CI_Xmlrpc {
$this->data = array();
- foreach($incoming as $key => $value)
+ foreach ($incoming as $key => $value)
{
$this->data[$key] = $this->values_parsing($value);
}
@@ -232,7 +232,7 @@ class CI_Xmlrpc {
{
if (is_array($value) && array_key_exists(0, $value))
{
- if ( ! isset($value['1']) OR (! isset($this->xmlrpcTypes[$value['1']])))
+ if ( ! isset($value['1']) OR ( ! isset($this->xmlrpcTypes[$value['1']])))
{
if (is_array($value[0]))
{
@@ -243,7 +243,7 @@ class CI_Xmlrpc {
$temp = new XML_RPC_Values($value['0'], 'string');
}
}
- elseif(is_array($value['0']) && ($value['1'] == 'struct' OR $value['1'] == 'array'))
+ elseif (is_array($value['0']) && ($value['1'] == 'struct' OR $value['1'] == 'array'))
{
while (list($k) = each($value['0']))
{
@@ -281,7 +281,7 @@ class CI_Xmlrpc {
$this->error = $this->result->errstr;
return FALSE;
}
- elseif( ! is_object($this->result->val))
+ elseif ( ! is_object($this->result->val))
{
$this->error = $this->result->errstr;
return FALSE;
@@ -358,7 +358,7 @@ class XML_RPC_Client extends CI_Xmlrpc
var $errno = '';
var $errstring = '';
var $timeout = 5;
- var $no_multicall = false;
+ var $no_multicall = FALSE;
public function __construct($path, $server, $port=80)
{
@@ -392,7 +392,7 @@ class XML_RPC_Client extends CI_Xmlrpc
return $r;
}
- if(empty($msg->payload))
+ if (empty($msg->payload))
{
// $msg = XML_RPC_Messages
$msg->createPayload();
@@ -504,12 +504,7 @@ class XML_RPC_Response
function decode($array=FALSE)
{
$CI =& get_instance();
-
- if ($this->xss_clean && ! isset($CI->security))
- {
- $CI->load->library('security');
- }
-
+
if ($array !== FALSE && is_array($array))
{
while (list($key) = each($array))
@@ -553,11 +548,11 @@ class XML_RPC_Response
{
$kind = $xmlrpc_val->kindOf();
- if($kind == 'scalar')
+ if ($kind == 'scalar')
{
return $xmlrpc_val->scalarval();
}
- elseif($kind == 'array')
+ elseif ($kind == 'array')
{
reset($xmlrpc_val->me);
list($a,$b) = each($xmlrpc_val->me);
@@ -565,18 +560,18 @@ class XML_RPC_Response
$arr = array();
- for($i = 0; $i < $size; $i++)
+ for ($i = 0; $i < $size; $i++)
{
$arr[] = $this->xmlrpc_decoder($xmlrpc_val->me['array'][$i]);
}
return $arr;
}
- elseif($kind == 'struct')
+ elseif ($kind == 'struct')
{
reset($xmlrpc_val->me['struct']);
$arr = array();
- while(list($key,$value) = each($xmlrpc_val->me['struct']))
+ while (list($key,$value) = each($xmlrpc_val->me['struct']))
{
$arr[$key] = $this->xmlrpc_decoder($value);
}
@@ -595,10 +590,8 @@ class XML_RPC_Response
$t = 0;
if (preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})/', $time, $regs))
{
- if ($utc == 1)
- $t = gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
- else
- $t = mktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
+ $fnc = ($utc == 1) ? 'gmmktime' : 'mktime';
+ $t = $fnc($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
}
return $t;
}
@@ -628,7 +621,7 @@ class XML_RPC_Message extends CI_Xmlrpc
$this->method_name = $method;
if (is_array($pars) && count($pars) > 0)
{
- for($i=0; $i<count($pars); $i++)
+ for ($i=0; $i<count($pars); $i++)
{
// $pars[$i] = XML_RPC_Values
$this->params[] = $pars[$i];
@@ -646,7 +639,7 @@ class XML_RPC_Message extends CI_Xmlrpc
$this->payload .= '<methodName>' . $this->method_name . "</methodName>\r\n";
$this->payload .= "<params>\r\n";
- for($i=0; $i<count($this->params); $i++)
+ for ($i=0; $i<count($this->params); $i++)
{
// $p = XML_RPC_Values
$p = $this->params[$i];
@@ -664,7 +657,7 @@ class XML_RPC_Message extends CI_Xmlrpc
{
$data = '';
- while($datum = fread($fp, 4096))
+ while ($datum = fread($fp, 4096))
{
$data .= $datum;
}
@@ -684,7 +677,7 @@ class XML_RPC_Message extends CI_Xmlrpc
// Check for data
//-------------------------------------
- if($data == "")
+ if ($data == "")
{
error_log($this->xmlrpcstr['no_data']);
$r = new XML_RPC_Response(0, $this->xmlrpcerr['no_data'], $this->xmlrpcstr['no_data']);
@@ -896,7 +889,7 @@ class XML_RPC_Message extends CI_Xmlrpc
$this->xh[$the_parser]['isf'] = 1;
break;
case 'PARAM':
- $this->xh[$the_parser]['value'] = null;
+ $this->xh[$the_parser]['value'] = NULL;
break;
case 'VALUE':
$this->xh[$the_parser]['vt'] = 'value';
@@ -925,7 +918,7 @@ class XML_RPC_Message extends CI_Xmlrpc
$this->xh[$the_parser]['valuestack'][0]['name'] = '';
// Set NULL value to check to see if value passed for this param/member
- $this->xh[$the_parser]['value'] = null;
+ $this->xh[$the_parser]['value'] = NULL;
break;
case 'DATA':
case 'METHODCALL':
@@ -1108,7 +1101,7 @@ class XML_RPC_Message extends CI_Xmlrpc
$this->xh[$the_parser]['lv'] = 2; // Found a value
}
- if( ! @isset($this->xh[$the_parser]['ac']))
+ if ( ! @isset($this->xh[$the_parser]['ac']))
{
$this->xh[$the_parser]['ac'] = '';
}
@@ -1123,12 +1116,7 @@ class XML_RPC_Message extends CI_Xmlrpc
function output_parameters($array=FALSE)
{
$CI =& get_instance();
-
- if ($this->xss_clean && ! isset($CI->security))
- {
- $CI->load->library('security');
- }
-
+
if ($array !== FALSE && is_array($array))
{
while (list($key) = each($array))
@@ -1174,11 +1162,11 @@ class XML_RPC_Message extends CI_Xmlrpc
{
$kind = $param->kindOf();
- if($kind == 'scalar')
+ if ($kind == 'scalar')
{
return $param->scalarval();
}
- elseif($kind == 'array')
+ elseif ($kind == 'array')
{
reset($param->me);
list($a,$b) = each($param->me);
@@ -1192,13 +1180,13 @@ class XML_RPC_Message extends CI_Xmlrpc
return $arr;
}
- elseif($kind == 'struct')
+ elseif ($kind == 'struct')
{
reset($param->me['struct']);
$arr = array();
- while(list($key,$value) = each($param->me['struct']))
+ while (list($key,$value) = each($param->me['struct']))
{
$arr[$key] = $this->decode_message($value);
}
@@ -1343,7 +1331,7 @@ class XML_RPC_Values extends CI_Xmlrpc
// struct
$rs .= "<struct>\n";
reset($val);
- while(list($key2, $val2) = each($val))
+ while (list($key2, $val2) = each($val))
{
$rs .= "<member>\n<name>{$key2}</name>\n";
$rs .= $this->serializeval($val2);
diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php
index 6bedfe324..9cd332147 100755
--- a/system/libraries/Xmlrpcs.php
+++ b/system/libraries/Xmlrpcs.php
@@ -59,10 +59,15 @@ class CI_Xmlrpcs extends CI_Xmlrpc
log_message('debug', "XML-RPC Server Class Initialized");
}
- //-------------------------------------
- // Initialize Prefs and Serve
- //-------------------------------------
+ // --------------------------------------------------------------------
+ /**
+ * Initialize Prefs and Serve
+ *
+ * @access public
+ * @param mixed
+ * @return void
+ */
function initialize($config=array())
{
if (isset($config['functions']) && is_array($config['functions']))
@@ -86,11 +91,15 @@ class CI_Xmlrpcs extends CI_Xmlrpc
}
}
- //-------------------------------------
- // Setting of System Methods
- //-------------------------------------
+ // --------------------------------------------------------------------
- function set_system_methods ()
+ /**
+ * Setting of System Methods
+ *
+ * @access public
+ * @return void
+ */
+ function set_system_methods()
{
$this->methods = array(
'system.listMethods' => array(
@@ -112,11 +121,14 @@ class CI_Xmlrpcs extends CI_Xmlrpc
);
}
+ // --------------------------------------------------------------------
- //-------------------------------------
- // Main Server Function
- //-------------------------------------
-
+ /**
+ * Main Server Function
+ *
+ * @access public
+ * @return void
+ */
function serve()
{
$r = $this->parseRequest();
@@ -129,11 +141,19 @@ class CI_Xmlrpcs extends CI_Xmlrpc
exit($payload);
}
- //-------------------------------------
- // Add Method to Class
- //-------------------------------------
+ // --------------------------------------------------------------------
- function add_to_map($methodname,$function,$sig,$doc)
+ /**
+ * Add Method to Class
+ *
+ * @access public
+ * @param string method name
+ * @param string function
+ * @param string signature
+ * @param string docstring
+ * @return void
+ */
+ function add_to_map($methodname, $function, $sig, $doc)
{
$this->methods[$methodname] = array(
'function' => $function,
@@ -142,11 +162,15 @@ class CI_Xmlrpcs extends CI_Xmlrpc
);
}
+ // --------------------------------------------------------------------
- //-------------------------------------
- // Parse Server Request
- //-------------------------------------
-
+ /**
+ * Parse Server Request
+ *
+ * @access public
+ * @param string data
+ * @return object xmlrpc response
+ */
function parseRequest($data='')
{
global $HTTP_RAW_POST_DATA;
@@ -196,7 +220,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
xml_get_current_line_number($parser)));
xml_parser_free($parser);
}
- elseif($parser_object->xh[$parser]['isf'])
+ elseif ($parser_object->xh[$parser]['isf'])
{
return new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'], $this->xmlrpcstr['invalid_return']);
}
@@ -207,7 +231,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; $i < count($parser_object->xh[$parser]['params']); $i++)
{
if ($this->debug === TRUE)
{
@@ -239,10 +263,15 @@ class CI_Xmlrpcs extends CI_Xmlrpc
return $r;
}
- //-------------------------------------
- // Executes the Method
- //-------------------------------------
+ // --------------------------------------------------------------------
+ /**
+ * Executes the Method
+ *
+ * @access protected
+ * @param object
+ * @return mixed
+ */
function _execute($m)
{
$methName = $m->method_name;
@@ -297,13 +326,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; $i<count($sig); $i++)
{
$current_sig = $sig[$i];
if (count($current_sig) == count($m->params)+1)
{
- for($n=0; $n < count($m->params); $n++)
+ for ($n=0; $n < count($m->params); $n++)
{
$p = $m->params[$n];
$pt = ($p->kindOf() == 'scalar') ? $p->scalarval() : $p->kindOf();
@@ -352,23 +381,27 @@ class CI_Xmlrpcs extends CI_Xmlrpc
return call_user_func($this->methods[$methName]['function'], $m);
}
}
+
+ // --------------------------------------------------------------------
-
- //-------------------------------------
- // Server Function: List Methods
- //-------------------------------------
-
+ /**
+ * Server Function: List Methods
+ *
+ * @access public
+ * @param mixed
+ * @return object
+ */
function listMethods($m)
{
$v = new XML_RPC_Values();
$output = array();
- foreach($this->methods as $key => $value)
+ foreach ($this->methods as $key => $value)
{
$output[] = new XML_RPC_Values($key, 'string');
}
- foreach($this->system_methods as $key => $value)
+ foreach ($this->system_methods as $key => $value)
{
$output[]= new XML_RPC_Values($key, 'string');
}
@@ -376,11 +409,16 @@ class CI_Xmlrpcs extends CI_Xmlrpc
$v->addArray($output);
return new XML_RPC_Response($v);
}
+
+ // --------------------------------------------------------------------
- //-------------------------------------
- // Server Function: Return Signature for Method
- //-------------------------------------
-
+ /**
+ * Server Function: Return Signature for Method
+ *
+ * @access public
+ * @param mixed
+ * @return object
+ */
function methodSignature($m)
{
$parameters = $m->output_parameters();
@@ -393,11 +431,11 @@ class CI_Xmlrpcs extends CI_Xmlrpc
$sigs = array();
$signature = $this->methods[$method_name]['signature'];
- for($i=0; $i < count($signature); $i++)
+ for ($i=0; $i < count($signature); $i++)
{
$cursig = array();
$inSig = $signature[$i];
- for($j=0; $j<count($inSig); $j++)
+ for ($j=0; $j<count($inSig); $j++)
{
$cursig[]= new XML_RPC_Values($inSig[$j], 'string');
}
@@ -417,10 +455,15 @@ class CI_Xmlrpcs extends CI_Xmlrpc
return $r;
}
- //-------------------------------------
- // Server Function: Doc String for Method
- //-------------------------------------
+ // --------------------------------------------------------------------
+ /**
+ * Server Function: Doc String for Method
+ *
+ * @access public
+ * @param mixed
+ * @return object
+ */
function methodHelp($m)
{
$parameters = $m->output_parameters();
@@ -437,11 +480,16 @@ class CI_Xmlrpcs extends CI_Xmlrpc
return new XML_RPC_Response(0, $this->xmlrpcerr['introspect_unknown'], $this->xmlrpcstr['introspect_unknown']);
}
}
+
+ // --------------------------------------------------------------------
- //-------------------------------------
- // Server Function: Multi-call
- //-------------------------------------
-
+ /**
+ * Server Function: Multi-call
+ *
+ * @access public
+ * @param mixed
+ * @return object
+ */
function multicall($m)
{
// Disabled
@@ -459,7 +507,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; $i < count($value[1]); $i++)
{
$m->addParam(new XML_RPC_Values($value[1][$i], 'string'));
}
@@ -477,11 +525,15 @@ class CI_Xmlrpcs extends CI_Xmlrpc
return new XML_RPC_Response(new XML_RPC_Values($result, 'array'));
}
+ // --------------------------------------------------------------------
- //-------------------------------------
- // Multi-call Function: Error Handling
- //-------------------------------------
-
+ /**
+ * Multi-call Function: Error Handling
+ *
+ * @access public
+ * @param mixed
+ * @return object
+ */
function multicall_error($err)
{
$str = is_string($err) ? $this->xmlrpcstr["multicall_${err}"] : $err->faultString();
@@ -493,29 +545,45 @@ class CI_Xmlrpcs extends CI_Xmlrpc
return new XML_RPC_Values($struct, 'struct');
}
+ // --------------------------------------------------------------------
- //-------------------------------------
- // Multi-call Function: Processes method
- //-------------------------------------
-
+ /**
+ * Multi-call Function: Processes method
+ *
+ * @access public
+ * @param mixed
+ * @return object
+ */
function do_multicall($call)
{
if ($call->kindOf() != 'struct')
+ {
return $this->multicall_error('notstruct');
+ }
elseif ( ! $methName = $call->me['struct']['methodName'])
+ {
return $this->multicall_error('nomethod');
+ }
list($scalar_type,$scalar_value)=each($methName->me);
$scalar_type = $scalar_type == $this->xmlrpcI4 ? $this->xmlrpcInt : $scalar_type;
if ($methName->kindOf() != 'scalar' OR $scalar_type != 'string')
+ {
return $this->multicall_error('notstring');
+ }
elseif ($scalar_value == 'system.multicall')
+ {
return $this->multicall_error('recursion');
+ }
elseif ( ! $params = $call->me['struct']['params'])
+ {
return $this->multicall_error('noparams');
+ }
elseif ($params->kindOf() != 'array')
+ {
return $this->multicall_error('notarray');
+ }
list($a,$b)=each($params->me);
$numParams = count($b);
diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php
index 80633c708..666327d5c 100755
--- a/system/libraries/Zip.php
+++ b/system/libraries/Zip.php
@@ -289,7 +289,7 @@ class CI_Zip {
while (FALSE !== ($file = readdir($fp)))
{
- if(substr($file, 0, 1) == '.')
+ if (substr($file, 0, 1) == '.')
{
continue;
}