summaryrefslogtreecommitdiffstats
path: root/system/libraries
diff options
context:
space:
mode:
authorPascal Kriete <pascal.kriete@ellislab.com>2010-11-04 22:59:52 +0100
committerPascal Kriete <pascal.kriete@ellislab.com>2010-11-04 22:59:52 +0100
commite917f9be8b05c81357c1c2c9730d5060685d644d (patch)
treeb6a7d5ce8ba57b69ba61454f77829b04f2ce5974 /system/libraries
parent5b2d2da5ae2e97043c6bef53e565d30e50196e2b (diff)
parente1f6e9ddff788f6a154f5f35dc117d14aeb0c484 (diff)
Automated merge with http://hg.ellislab.com/CodeIgniter2
Diffstat (limited to 'system/libraries')
-rw-r--r--system/libraries/Calendar.php156
-rw-r--r--system/libraries/Cart.php140
-rw-r--r--system/libraries/Driver.php44
-rw-r--r--system/libraries/Email.php124
-rw-r--r--system/libraries/Encrypt.php30
-rw-r--r--system/libraries/Form_validation.php436
-rw-r--r--system/libraries/Ftp.php14
-rw-r--r--system/libraries/Image_lib.php42
-rw-r--r--system/libraries/Javascript.php174
-rw-r--r--system/libraries/Log.php34
-rw-r--r--system/libraries/Pagination.php20
-rw-r--r--system/libraries/Parser.php26
-rw-r--r--system/libraries/Profiler.php184
-rw-r--r--system/libraries/Security.php152
-rw-r--r--system/libraries/Session.php26
-rw-r--r--system/libraries/Sha1.php22
-rw-r--r--system/libraries/Table.php156
-rw-r--r--system/libraries/Trackback.php246
-rw-r--r--system/libraries/Typography.php154
-rw-r--r--system/libraries/Unit_test.php110
-rw-r--r--system/libraries/Upload.php298
-rw-r--r--system/libraries/User_agent.php166
-rw-r--r--system/libraries/Xmlrpc.php326
-rw-r--r--system/libraries/Xmlrpcs.php152
-rw-r--r--system/libraries/Zip.php56
-rw-r--r--system/libraries/javascript/Jquery.php28
26 files changed, 1666 insertions, 1650 deletions
diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php
index 275bf2451..924333faa 100644
--- a/system/libraries/Calendar.php
+++ b/system/libraries/Calendar.php
@@ -33,7 +33,7 @@ class CI_Calendar {
var $local_time;
var $template = '';
var $start_day = 'sunday';
- var $month_type = 'long';
+ var $month_type = 'long';
var $day_type = 'abr';
var $show_next_prev = FALSE;
var $next_prev_url = '';
@@ -46,26 +46,26 @@ class CI_Calendar {
* @access public
*/
function CI_Calendar($config = array())
- {
+ {
$this->CI =& get_instance();
-
+
if ( ! in_array('calendar_lang'.EXT, $this->CI->lang->is_loaded, TRUE))
{
$this->CI->lang->load('calendar');
}
$this->local_time = time();
-
+
if (count($config) > 0)
{
$this->initialize($config);
}
-
+
log_message('debug', "Calendar Class Initialized");
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Initialize the user preferences
*
@@ -74,7 +74,7 @@ class CI_Calendar {
* @access public
* @param array config preferences
* @return void
- */
+ */
function initialize($config = array())
{
foreach ($config as $key => $val)
@@ -85,7 +85,7 @@ class CI_Calendar {
}
}
}
-
+
// --------------------------------------------------------------------
/**
@@ -102,66 +102,66 @@ class CI_Calendar {
// 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)
+
+ if (strlen($year) == 1)
$year = '200'.$year;
-
- if (strlen($year) == 2)
+
+ if (strlen($year) == 2)
$year = '20'.$year;
- if (strlen($month) == 1)
+ if (strlen($month) == 1)
$month = '0'.$month;
-
+
$adjusted_date = $this->adjust_date($month, $year);
-
+
$month = $adjusted_date['month'];
$year = $adjusted_date['year'];
-
+
// Determine the total days in the month
$total_days = $this->get_total_days($month, $year);
-
+
// Set the starting day of the week
$start_days = array('sunday' => 0, 'monday' => 1, 'tuesday' => 2, 'wednesday' => 3, 'thursday' => 4, 'friday' => 5, 'saturday' => 6);
$start_day = ( ! isset($start_days[$this->start_day])) ? 0 : $start_days[$this->start_day];
-
+
// Set the starting day number
$local_date = mktime(12, 0, 0, $month, 1, $year);
$date = getdate($local_date);
$day = $start_day + 1 - $date["wday"];
-
+
while ($day > 1)
{
$day -= 7;
}
-
+
// 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);
-
+
$is_current_month = ($cur_year == $year AND $cur_month == $month) ? TRUE : FALSE;
-
+
// Generate the template data array
$this->parse_template();
-
- // Begin building the calendar output
+
+ // Begin building the calendar output
$out = $this->temp['table_open'];
- $out .= "\n";
+ $out .= "\n";
- $out .= "\n";
+ $out .= "\n";
$out .= $this->temp['heading_row_start'];
$out .= "\n";
-
+
// "previous" month link
if ($this->show_next_prev == TRUE)
{
// Add a trailing slash to the URL if needed
$this->next_prev_url = preg_replace("/(.+?)\/*$/", "\\1/", $this->next_prev_url);
-
+
$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";
@@ -169,26 +169,26 @@ class CI_Calendar {
// 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)."&nbsp;".$year, $this->temp['heading_title_cell']);
-
+
$out .= $this->temp['heading_title_cell'];
$out .= "\n";
// "next" month link
if ($this->show_next_prev == TRUE)
- {
+ {
$adjusted_date = $this->adjust_date($month + 1, $year);
$out .= str_replace('{next_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_next_cell']);
}
- $out .= "\n";
+ $out .= "\n";
$out .= $this->temp['heading_row_end'];
$out .= "\n";
// Write the cells containing the days of the week
- $out .= "\n";
+ $out .= "\n";
$out .= $this->temp['week_row_start'];
$out .= "\n";
@@ -213,11 +213,11 @@ class CI_Calendar {
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'];
-
+
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));
@@ -234,22 +234,22 @@ class CI_Calendar {
// Blank cells
$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 .= "\n";
$out .= $this->temp['cal_row_end'];
- $out .= "\n";
+ $out .= "\n";
}
- $out .= "\n";
+ $out .= "\n";
$out .= $this->temp['table_close'];
return $out;
}
-
+
// --------------------------------------------------------------------
/**
@@ -272,9 +272,9 @@ class CI_Calendar {
{
$month_names = array('01' => 'cal_january', '02' => 'cal_february', '03' => 'cal_march', '04' => 'cal_april', '05' => 'cal_mayl', '06' => 'cal_june', '07' => 'cal_july', '08' => 'cal_august', '09' => 'cal_september', '10' => 'cal_october', '11' => 'cal_november', '12' => 'cal_december');
}
-
+
$month = $month_names[$month];
-
+
if ($this->CI->lang->line($month) === FALSE)
{
return ucfirst(str_replace('cal_', '', $month));
@@ -282,7 +282,7 @@ class CI_Calendar {
return $this->CI->lang->line($month);
}
-
+
// --------------------------------------------------------------------
/**
@@ -299,7 +299,7 @@ class CI_Calendar {
{
if ($day_type != '')
$this->day_type = $day_type;
-
+
if ($this->day_type == 'long')
{
$day_names = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday');
@@ -312,16 +312,16 @@ class CI_Calendar {
{
$day_names = array('su', 'mo', 'tu', 'we', 'th', 'fr', 'sa');
}
-
+
$days = array();
foreach ($day_names as $val)
- {
+ {
$days[] = ($this->CI->lang->line('cal_'.$val) === FALSE) ? ucfirst($val) : $this->CI->lang->line('cal_'.$val);
}
-
+
return $days;
}
-
+
// --------------------------------------------------------------------
/**
@@ -362,7 +362,7 @@ class CI_Calendar {
return $date;
}
-
+
// --------------------------------------------------------------------
/**
@@ -393,7 +393,7 @@ class CI_Calendar {
return $days_in_month[$month - 1];
}
-
+
// --------------------------------------------------------------------
/**
@@ -407,17 +407,17 @@ class CI_Calendar {
function default_template()
{
return array (
- 'table_open' => '<table border="0" cellpadding="4" cellspacing="0">',
- 'heading_row_start' => '<tr>',
+ 'table_open' => '<table border="0" cellpadding="4" cellspacing="0">',
+ 'heading_row_start' => '<tr>',
'heading_previous_cell' => '<th><a href="{previous_url}">&lt;&lt;</a></th>',
- 'heading_title_cell' => '<th colspan="{colspan}">{heading}</th>',
- 'heading_next_cell' => '<th><a href="{next_url}">&gt;&gt;</a></th>',
- 'heading_row_end' => '</tr>',
- 'week_row_start' => '<tr>',
- 'week_day_cell' => '<td>{week_day}</td>',
- 'week_row_end' => '</tr>',
- 'cal_row_start' => '<tr>',
- 'cal_cell_start' => '<td>',
+ 'heading_title_cell' => '<th colspan="{colspan}">{heading}</th>',
+ 'heading_next_cell' => '<th><a href="{next_url}">&gt;&gt;</a></th>',
+ 'heading_row_end' => '</tr>',
+ 'week_row_start' => '<tr>',
+ 'week_day_cell' => '<td>{week_day}</td>',
+ 'week_row_end' => '</tr>',
+ 'cal_row_start' => '<tr>',
+ 'cal_cell_start' => '<td>',
'cal_cell_start_today' => '<td>',
'cal_cell_content' => '<a href="{content}">{day}</a>',
'cal_cell_content_today' => '<a href="{content}"><strong>{day}</strong></a>',
@@ -428,9 +428,9 @@ class CI_Calendar {
'cal_cell_end_today' => '</td>',
'cal_row_end' => '</tr>',
'table_close' => '</table>'
- );
+ );
}
-
+
// --------------------------------------------------------------------
/**
@@ -442,17 +442,17 @@ class CI_Calendar {
* @access public
* @return void
*/
- function parse_template()
- {
+ function parse_template()
+ {
$this->temp = $this->default_template();
-
- if ($this->template == '')
- {
- return;
- }
-
+
+ if ($this->template == '')
+ {
+ return;
+ }
+
$today = array('cal_cell_start_today', 'cal_cell_content_today', 'cal_cell_no_content_today', 'cal_cell_end_today');
-
+
foreach (array('table_open', 'table_close', 'heading_row_start', 'heading_previous_cell', 'heading_title_cell', 'heading_next_cell', 'heading_row_end', 'week_row_start', 'week_day_cell', 'week_row_end', 'cal_row_start', 'cal_cell_start', 'cal_cell_content', 'cal_cell_no_content', 'cal_cell_blank', 'cal_cell_end', 'cal_row_end', 'cal_cell_start_today', 'cal_cell_content_today', 'cal_cell_no_content_today', 'cal_cell_end_today') as $val)
{
if (preg_match("/\{".$val."\}(.*?)\{\/".$val."\}/si", $this->template, $match))
@@ -466,8 +466,8 @@ class CI_Calendar {
$this->temp[$val] = $this->temp[str_replace('_today', '', $val)];
}
}
- }
- }
+ }
+ }
}
diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php
index 643d2eca4..f3969ef2c 100644
--- a/system/libraries/Cart.php
+++ b/system/libraries/Cart.php
@@ -29,7 +29,7 @@ class CI_Cart {
// These are the regular expression rules that we use to validate the product ID and product name
var $product_id_rules = '\.a-z0-9_-'; // alpha-numeric, dashes, underscores, or periods
var $product_name_rules = '\.\:\-_ a-z0-9'; // alpha-numeric, dashes, underscores, colons or periods
-
+
// Private variables. Do not change!
var $CI;
var $_cart_contents = array();
@@ -39,12 +39,12 @@ class CI_Cart {
* Shopping Class Constructor
*
* The constructor loads the Session class, used to store the shopping cart contents.
- */
+ */
function CI_Cart($params = array())
- {
+ {
// Set the super object to a local variable for use later
$this->CI =& get_instance();
-
+
// Are any config settings being passed manually? If so, set them
$config = array();
if (count($params) > 0)
@@ -54,10 +54,10 @@ class CI_Cart {
$config[$key] = $val;
}
}
-
+
// Load the Sessions class
$this->CI->load->library('session', $config);
-
+
// Grab the shopping cart array from the session table, if it exists
if ($this->CI->session->userdata('cart_contents') !== FALSE)
{
@@ -66,15 +66,15 @@ class CI_Cart {
else
{
// No cart exists so we'll set some base values
- $this->_cart_contents['cart_total'] = 0;
- $this->_cart_contents['total_items'] = 0;
+ $this->_cart_contents['cart_total'] = 0;
+ $this->_cart_contents['total_items'] = 0;
}
-
+
log_message('debug', "Cart Class Initialized");
}
// --------------------------------------------------------------------
-
+
/**
* Insert items into the cart and save it to the session table
*
@@ -90,15 +90,15 @@ class CI_Cart {
log_message('error', 'The insert method must be passed an array containing data.');
return FALSE;
}
-
- // You can either insert a single product using a one-dimensional array,
+
+ // You can either insert a single product using a one-dimensional array,
// or multiple products using a multi-dimensional one. The way we
// determine the array type is by looking for a required array key named "id"
// at the top level. If it's not found, we will assume it's a multi-dimensional array.
-
- $save_cart = FALSE;
+
+ $save_cart = FALSE;
if (isset($items['id']))
- {
+ {
if ($this->_insert($items) == TRUE)
{
$save_cart = TRUE;
@@ -114,7 +114,7 @@ class CI_Cart {
{
$save_cart = TRUE;
}
- }
+ }
}
}
@@ -129,7 +129,7 @@ class CI_Cart {
}
// --------------------------------------------------------------------
-
+
/**
* Insert
*
@@ -145,9 +145,9 @@ class CI_Cart {
log_message('error', 'The insert method must be passed an array containing data.');
return FALSE;
}
-
+
// --------------------------------------------------------------------
-
+
// Does the $items array contain an id, quantity, price, and name? These are required
if ( ! isset($items['id']) OR ! isset($items['qty']) OR ! isset($items['price']) OR ! isset($items['name']))
{
@@ -156,7 +156,7 @@ class CI_Cart {
}
// --------------------------------------------------------------------
-
+
// Prep the quantity. It can only be a number. Duh...
$items['qty'] = trim(preg_replace('/([^0-9])/i', '', $items['qty']));
// Trim any leading zeros
@@ -167,9 +167,9 @@ class CI_Cart {
{
return FALSE;
}
-
+
// --------------------------------------------------------------------
-
+
// Validate the product ID. It can only be alpha-numeric, dashes, underscores or periods
// Not totally sure we should impose this rule, but it seems prudent to standardize IDs.
// Note: These can be user-specified by setting the $this->product_id_rules variable.
@@ -180,7 +180,7 @@ class CI_Cart {
}
// --------------------------------------------------------------------
-
+
// Validate the product name. It can only be alpha-numeric, dashes, underscores, colons or periods.
// Note: These can be user-specified by setting the $this->product_name_rules variable.
if ( ! preg_match("/^[".$this->product_name_rules."]+$/i", $items['name']))
@@ -195,7 +195,7 @@ class CI_Cart {
$items['price'] = trim(preg_replace('/([^0-9\.])/i', '', $items['price']));
// Trim any leading zeros
$items['price'] = trim(preg_replace('/(^[0]+)/i', '', $items['price']));
-
+
// Is the price a valid number?
if ( ! is_numeric($items['price']))
{
@@ -204,13 +204,13 @@ class CI_Cart {
}
// --------------------------------------------------------------------
-
+
// We now need to create a unique identifier for the item being inserted into the cart.
- // Every time something is added to the cart it is stored in the master cart array.
- // Each row in the cart array, however, must have a unique index that identifies not only
- // a particular product, but makes it possible to store identical products with different options.
- // For example, what if someone buys two identical t-shirts (same product ID), but in
- // different sizes? The product ID (and other attributes, like the name) will be identical for
+ // Every time something is added to the cart it is stored in the master cart array.
+ // Each row in the cart array, however, must have a unique index that identifies not only
+ // a particular product, but makes it possible to store identical products with different options.
+ // For example, what if someone buys two identical t-shirts (same product ID), but in
+ // different sizes? The product ID (and other attributes, like the name) will be identical for
// both sizes because it's the same shirt. The only difference will be the size.
// Internally, we need to treat identical submissions, but with different options, as a unique product.
// Our solution is to convert the options array to a string and MD5 it along with the product ID.
@@ -225,19 +225,19 @@ class CI_Cart {
// Technically, we don't need to MD5 the ID in this case, but it makes
// sense to standardize the format of array indexes for both conditions
$rowid = md5($items['id']);
- }
+ }
// --------------------------------------------------------------------
// Now that we have our unique "row ID", we'll add our cart items to the master array
-
+
// let's unset this first, just to make sure our index contains only the data from this submission
- unset($this->_cart_contents[$rowid]);
-
+ unset($this->_cart_contents[$rowid]);
+
// Create a new index with our new row ID
$this->_cart_contents[$rowid]['rowid'] = $rowid;
-
- // And add the new items to the cart array
+
+ // And add the new items to the cart array
foreach ($items as $key => $val)
{
$this->_cart_contents[$rowid][$key] = $val;
@@ -248,11 +248,11 @@ class CI_Cart {
}
// --------------------------------------------------------------------
-
+
/**
* Update the cart
*
- * This function permits the quantity of a given item to be changed.
+ * This function permits the quantity of a given item to be changed.
* Typically it is called from the "view cart" page if a user makes
* changes to the quantity before checkout. That array must contain the
* product ID and quantity for each item.
@@ -269,8 +269,8 @@ class CI_Cart {
{
return FALSE;
}
-
- // You can either update a single product using a one-dimensional array,
+
+ // You can either update a single product using a one-dimensional array,
// or multiple products using a multi-dimensional one. The way we
// determine the array type is by looking for a required array key named "id".
// If it's not found we assume it's a multi-dimensional array
@@ -292,7 +292,7 @@ class CI_Cart {
{
$save_cart = TRUE;
}
- }
+ }
}
}
@@ -307,11 +307,11 @@ class CI_Cart {
}
// --------------------------------------------------------------------
-
+
/**
* Update the cart
*
- * This function permits the quantity of a given item to be changed.
+ * This function permits the quantity of a given item to be changed.
* Typically it is called from the "view cart" page if a user makes
* changes to the quantity before checkout. That array must contain the
* product ID and quantity for each item.
@@ -319,7 +319,7 @@ class CI_Cart {
* @access private
* @param array
* @return bool
- */
+ */
function _update($items = array())
{
// Without these array indexes there is nothing we can do
@@ -327,7 +327,7 @@ class CI_Cart {
{
return FALSE;
}
-
+
// Prep the quantity
$items['qty'] = preg_replace('/([^0-9])/i', '', $items['qty']);
@@ -336,7 +336,7 @@ class CI_Cart {
{
return FALSE;
}
-
+
// Is the new quantity different than what is already saved in the cart?
// If it's the same there's nothing to do
if ($this->_cart_contents[$items['rowid']]['qty'] == $items['qty'])
@@ -348,18 +348,18 @@ class CI_Cart {
// If the quantity is greater than zero we are updating
if ($items['qty'] == 0)
{
- unset($this->_cart_contents[$items['rowid']]);
+ unset($this->_cart_contents[$items['rowid']]);
}
else
{
$this->_cart_contents[$items['rowid']]['qty'] = $items['qty'];
}
-
+
return TRUE;
}
// --------------------------------------------------------------------
-
+
/**
* Save the cart array to the session DB
*
@@ -383,20 +383,20 @@ class CI_Cart {
}
$total += ($val['price'] * $val['qty']);
-
+
// Set the subtotal
$this->_cart_contents[$key]['subtotal'] = ($this->_cart_contents[$key]['price'] * $this->_cart_contents[$key]['qty']);
}
// Set the cart total and total items.
- $this->_cart_contents['total_items'] = count($this->_cart_contents);
+ $this->_cart_contents['total_items'] = count($this->_cart_contents);
$this->_cart_contents['cart_total'] = $total;
-
+
// Is our cart empty? If so we delete it from the session
if (count($this->_cart_contents) <= 2)
{
$this->CI->session->unset_userdata('cart_contents');
-
+
// Nothing more to do... coffee time!
return FALSE;
}
@@ -406,11 +406,11 @@ class CI_Cart {
$this->CI->session->set_userdata(array('cart_contents' => $this->_cart_contents));
// Woot!
- return TRUE;
+ return TRUE;
}
// --------------------------------------------------------------------
-
+
/**
* Cart Total
*
@@ -423,7 +423,7 @@ class CI_Cart {
}
// --------------------------------------------------------------------
-
+
/**
* Total Items
*
@@ -438,7 +438,7 @@ class CI_Cart {
}
// --------------------------------------------------------------------
-
+
/**
* Cart Contents
*
@@ -450,16 +450,16 @@ class CI_Cart {
function contents()
{
$cart = $this->_cart_contents;
-
+
// Remove these so they don't create a problem when showing the cart table
unset($cart['total_items']);
unset($cart['cart_total']);
-
+
return $cart;
}
// --------------------------------------------------------------------
-
+
/**
* Has options
*
@@ -475,12 +475,12 @@ class CI_Cart {
{
return FALSE;
}
-
+
return TRUE;
}
// --------------------------------------------------------------------
-
+
/**
* Product options
*
@@ -500,7 +500,7 @@ class CI_Cart {
}
// --------------------------------------------------------------------
-
+
/**
* Format Number
*
@@ -515,15 +515,15 @@ class CI_Cart {
{
return '';
}
-
+
// Remove anything that isn't a number or decimal point.
$n = trim(preg_replace('/([^0-9\.])/i', '', $n));
-
+
return number_format($n, 2, '.', ',');
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Destroy the cart
*
@@ -535,9 +535,9 @@ class CI_Cart {
function destroy()
{
unset($this->_cart_contents);
-
- $this->_cart_contents['cart_total'] = 0;
- $this->_cart_contents['total_items'] = 0;
+
+ $this->_cart_contents['cart_total'] = 0;
+ $this->_cart_contents['total_items'] = 0;
$this->CI->session->unset_userdata('cart_contents');
}
diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php
index 07ef2e724..1261b4c72 100644
--- a/system/libraries/Driver.php
+++ b/system/libraries/Driver.php
@@ -25,25 +25,25 @@
* @subpackage Libraries
* @category Libraries
* @author EllisLab Dev Team
- * @link
+ * @link
*/
class CI_Driver_Library {
protected $valid_drivers = array();
protected static $lib_name;
-
+
// The first time a child is used it won't exist, so we instantiate it
// subsequents calls will go straight to the proper child.
function __get($child)
{
if (! isset($this->lib_name))
{
- $this->lib_name = get_class($this);
+ $this->lib_name = get_class($this);
}
// 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)))
{
// check and see if the driver is in a separate file
@@ -64,11 +64,11 @@ class CI_Driver_Library {
{
include_once $filepath;
break;
- }
+ }
}
}
}
-
+
// it's a valid driver, but the file simply can't be found
if ( ! class_exists($child_class))
{
@@ -82,14 +82,14 @@ class CI_Driver_Library {
$this->$child = $obj;
return $this->$child;
}
-
+
// The requested driver isn't valid!
log_message('error', "Invalid driver requested: ".$child_class);
show_error("Invalid driver requested: ".$child_class);
}
-
+
// --------------------------------------------------------------------
-
+
}
// END CI_Driver_Library CLASS
@@ -104,11 +104,11 @@ class CI_Driver_Library {
* @subpackage Libraries
* @category Libraries
* @author EllisLab Dev Team
- * @link
+ * @link
*/
class CI_Driver {
protected $parent;
-
+
private $methods = array();
private $properties = array();
@@ -126,16 +126,16 @@ class CI_Driver {
function decorate($parent)
{
$this->parent = $parent;
-
+
// Lock down attributes to what is defined in the class
// and speed up references in magic methods
-
+
$class_name = get_class($parent);
-
+
if ( ! isset(self::$reflections[$class_name]))
{
$r = new ReflectionObject($parent);
-
+
foreach ($r->getMethods() as $method)
{
if ($method->isPublic())
@@ -151,7 +151,7 @@ class CI_Driver {
$this->properties[] = $prop->getName();
}
}
-
+
self::$reflections[$class_name] = array($this->methods, $this->properties);
}
else
@@ -159,9 +159,9 @@ class CI_Driver {
list($this->methods, $this->properties) = self::$reflections[$class_name];
}
}
-
+
// --------------------------------------------------------------------
-
+
/**
* __call magic method
*
@@ -185,7 +185,7 @@ class CI_Driver {
}
// --------------------------------------------------------------------
-
+
/**
* __get magic method
*
@@ -204,7 +204,7 @@ class CI_Driver {
}
// --------------------------------------------------------------------
-
+
/**
* __set magic method
*
@@ -222,9 +222,9 @@ class CI_Driver {
$this->parent->$var = $val;
}
}
-
+
// --------------------------------------------------------------------
-
+
}
// END CI_Driver CLASS
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index af48757bb..6c0309b0d 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -129,7 +129,7 @@ class CI_Email {
$this->_smtp_auth = ($this->smtp_user == '' AND $this->smtp_pass == '') ? FALSE : TRUE;
$this->_safe_mode = ((boolean)@ini_get("safe_mode") === FALSE) ? FALSE : TRUE;
}
-
+
// --------------------------------------------------------------------
/**
@@ -161,7 +161,7 @@ class CI_Email {
$this->_attach_disp = array();
}
}
-
+
// --------------------------------------------------------------------
/**
@@ -202,7 +202,7 @@ class CI_Email {
$this->_set_header('From', $name.' <'.$from.'>');
$this->_set_header('Return-Path', '<'.$from.'>');
}
-
+
// --------------------------------------------------------------------
/**
@@ -238,7 +238,7 @@ class CI_Email {
$this->_set_header('Reply-To', $name.' <'.$replyto.'>');
$this->_replyto_flag = TRUE;
}
-
+
// --------------------------------------------------------------------
/**
@@ -273,7 +273,7 @@ class CI_Email {
break;
}
}
-
+
// --------------------------------------------------------------------
/**
@@ -300,7 +300,7 @@ class CI_Email {
$this->_cc_array = $cc;
}
}
-
+
// --------------------------------------------------------------------
/**
@@ -336,7 +336,7 @@ class CI_Email {
$this->_set_header('Bcc', implode(", ", $bcc));
}
}
-
+
// --------------------------------------------------------------------
/**
@@ -351,7 +351,7 @@ class CI_Email {
$subject = $this->_prep_q_encoding($subject);
$this->_set_header('Subject', $subject);
}
-
+
// --------------------------------------------------------------------
/**
@@ -365,7 +365,7 @@ class CI_Email {
{
$this->_body = stripslashes(rtrim(str_replace("\r", "", $body)));
}
-
+
// --------------------------------------------------------------------
/**
@@ -396,7 +396,7 @@ class CI_Email {
{
$this->_headers[$header] = $value;
}
-
+
// --------------------------------------------------------------------
/**
@@ -422,7 +422,7 @@ class CI_Email {
}
return $email;
}
-
+
// --------------------------------------------------------------------
/**
@@ -436,7 +436,7 @@ class CI_Email {
{
$this->alt_message = ($str == '') ? '' : $str;
}
-
+
// --------------------------------------------------------------------
/**
@@ -450,7 +450,7 @@ class CI_Email {
{
$this->mailtype = ($type == 'html') ? 'html' : 'text';
}
-
+
// --------------------------------------------------------------------
/**
@@ -464,7 +464,7 @@ class CI_Email {
{
$this->wordwrap = ($wordwrap === FALSE) ? FALSE : TRUE;
}
-
+
// --------------------------------------------------------------------
/**
@@ -478,7 +478,7 @@ class CI_Email {
{
$this->protocol = ( ! in_array($protocol, $this->_protocols, TRUE)) ? 'mail' : strtolower($protocol);
}
-
+
// --------------------------------------------------------------------
/**
@@ -504,7 +504,7 @@ class CI_Email {
$this->priority = $n;
}
-
+
// --------------------------------------------------------------------
/**
@@ -524,7 +524,7 @@ class CI_Email {
$this->newline = $newline;
}
-
+
// --------------------------------------------------------------------
/**
@@ -544,7 +544,7 @@ class CI_Email {
$this->crlf = $crlf;
}
-
+
// --------------------------------------------------------------------
/**
@@ -558,7 +558,7 @@ class CI_Email {
$this->_alt_boundary = "B_ALT_".uniqid(''); // multipart/alternative
$this->_atc_boundary = "B_ATC_".uniqid(''); // attachment boundary
}
-
+
// --------------------------------------------------------------------
/**
@@ -575,7 +575,7 @@ class CI_Email {
return "<".uniqid('').strstr($from, '@').">";
}
-
+
// --------------------------------------------------------------------
/**
@@ -595,7 +595,7 @@ class CI_Email {
return $this->protocol;
}
}
-
+
// --------------------------------------------------------------------
/**
@@ -650,7 +650,7 @@ class CI_Email {
return 'plain';
}
}
-
+
// --------------------------------------------------------------------
/**
@@ -668,7 +668,7 @@ class CI_Email {
return sprintf("%s %s%04d", date("D, j M Y H:i:s"), $operator, $timezone);
}
-
+
// --------------------------------------------------------------------
/**
@@ -681,7 +681,7 @@ class CI_Email {
{
return "This is a multi-part message in MIME format.".$this->newline."Your email application may not support this format.";
}
-
+
// --------------------------------------------------------------------
/**
@@ -710,7 +710,7 @@ class CI_Email {
return TRUE;
}
-
+
// --------------------------------------------------------------------
/**
@@ -724,7 +724,7 @@ class CI_Email {
{
return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $address)) ? FALSE : TRUE;
}
-
+
// --------------------------------------------------------------------
/**
@@ -740,11 +740,11 @@ class CI_Email {
{
if (preg_match('/\<(.*)\>/', $email, $match))
{
- return $match['1'];
+ return $match['1'];
}
- else
+ else
{
- return $email;
+ return $email;
}
}
@@ -754,17 +754,17 @@ class CI_Email {
{
if (preg_match( '/\<(.*)\>/', $addy, $match))
{
- $clean_email[] = $match['1'];
+ $clean_email[] = $match['1'];
}
- else
+ else
{
- $clean_email[] = $addy;
+ $clean_email[] = $addy;
}
}
return $clean_email;
}
-
+
// --------------------------------------------------------------------
/**
@@ -804,7 +804,7 @@ class CI_Email {
for ($x = 1; $x <= $i; $x ++)
{
- $n .= "\n";
+ $n .= "\n";
}
$body = str_replace($n, "\n\n", $body);
@@ -812,7 +812,7 @@ class CI_Email {
return $this->word_wrap($body, '76');
}
-
+
// --------------------------------------------------------------------
/**
@@ -908,7 +908,7 @@ class CI_Email {
return $output;
}
-
+
// --------------------------------------------------------------------
/**
@@ -926,7 +926,7 @@ class CI_Email {
$this->_set_header('Message-ID', $this->_get_message_id());
$this->_set_header('Mime-Version', '1.0');
}
-
+
// --------------------------------------------------------------------
/**
@@ -961,7 +961,7 @@ class CI_Email {
$this->_header_str = rtrim($this->_header_str);
}
}
-
+
// --------------------------------------------------------------------
/**
@@ -1150,7 +1150,7 @@ class CI_Email {
return;
}
-
+
// --------------------------------------------------------------------
/**
@@ -1245,7 +1245,7 @@ class CI_Email {
}
// --------------------------------------------------------------------
-
+
/**
* Prep Q Encoding
*
@@ -1317,7 +1317,7 @@ class CI_Email {
}
// --------------------------------------------------------------------
-
+
/**
* Send Email
*
@@ -1358,7 +1358,7 @@ class CI_Email {
return TRUE;
}
}
-
+
// --------------------------------------------------------------------
/**
@@ -1416,7 +1416,7 @@ class CI_Email {
$this->_spool_email();
}
}
-
+
// --------------------------------------------------------------------
/**
@@ -1429,7 +1429,7 @@ class CI_Email {
{
$this->_finalbody = preg_replace_callback("/\{unwrap\}(.*?)\{\/unwrap\}/si", array($this, '_remove_nl_callback'), $this->_finalbody);
}
-
+
// --------------------------------------------------------------------
/**
@@ -1447,7 +1447,7 @@ class CI_Email {
return $matches[1];
}
-
+
// --------------------------------------------------------------------
/**
@@ -1492,7 +1492,7 @@ class CI_Email {
$this->_set_error_message('email_sent', $this->_get_protocol());
return TRUE;
}
-
+
// --------------------------------------------------------------------
/**
@@ -1528,7 +1528,7 @@ class CI_Email {
}
}
}
-
+
// --------------------------------------------------------------------
/**
@@ -1550,12 +1550,12 @@ class CI_Email {
fputs($fp, $this->_header_str);
fputs($fp, $this->_finalbody);
- $status = pclose($fp);
-
+ $status = pclose($fp);
+
if (version_compare(PHP_VERSION, '4.2.3') == -1)
{
$status = $status >> 8 & 0xFF;
- }
+ }
if ($status != 0)
{
@@ -1566,7 +1566,7 @@ class CI_Email {
return TRUE;
}
-
+
// --------------------------------------------------------------------
/**
@@ -1635,7 +1635,7 @@ class CI_Email {
$this->_send_command('quit');
return TRUE;
}
-
+
// --------------------------------------------------------------------
/**
@@ -1662,7 +1662,7 @@ class CI_Email {
$this->_set_error_message($this->_get_smtp_data());
return $this->_send_command('hello');
}
-
+
// --------------------------------------------------------------------
/**
@@ -1729,7 +1729,7 @@ class CI_Email {
return TRUE;
}
-
+
// --------------------------------------------------------------------
/**
@@ -1783,7 +1783,7 @@ class CI_Email {
return TRUE;
}
-
+
// --------------------------------------------------------------------
/**
@@ -1804,7 +1804,7 @@ class CI_Email {
return TRUE;
}
}
-
+
// --------------------------------------------------------------------
/**
@@ -1829,7 +1829,7 @@ class CI_Email {
return $data;
}
-
+
// --------------------------------------------------------------------
/**
@@ -1842,7 +1842,7 @@ class CI_Email {
{
return (isset($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : 'localhost.localdomain';
}
-
+
// --------------------------------------------------------------------
/**
@@ -1862,7 +1862,7 @@ class CI_Email {
$rip = (isset($_SERVER['REMOTE_ADDR']) AND $_SERVER['REMOTE_ADDR'] != "") ? $_SERVER['REMOTE_ADDR'] : FALSE;
$fip = (isset($_SERVER['HTTP_X_FORWARDED_FOR']) AND $_SERVER['HTTP_X_FORWARDED_FOR'] != "") ? $_SERVER['HTTP_X_FORWARDED_FOR'] : FALSE;
- if ($cip && $rip) $this->_IP = $cip;
+ if ($cip && $rip) $this->_IP = $cip;
elseif ($rip) $this->_IP = $rip;
elseif ($cip) $this->_IP = $cip;
elseif ($fip) $this->_IP = $fip;
@@ -1884,7 +1884,7 @@ class CI_Email {
return $this->_IP;
}
-
+
// --------------------------------------------------------------------
/**
@@ -1908,7 +1908,7 @@ class CI_Email {
$msg .= "<pre>".$this->_header_str."\n".htmlspecialchars($this->_subject)."\n".htmlspecialchars($this->_finalbody).'</pre>';
return $msg;
}
-
+
// --------------------------------------------------------------------
/**
@@ -1932,7 +1932,7 @@ class CI_Email {
$this->_debug_msg[] = str_replace('%s', $val, $line)."<br />";
}
}
-
+
// --------------------------------------------------------------------
/**
diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php
index b27847a55..b95dd999c 100644
--- a/system/libraries/Encrypt.php
+++ b/system/libraries/Encrypt.php
@@ -144,7 +144,7 @@ class CI_Encrypt {
function decode($string, $key = '')
{
$key = $this->get_key($key);
-
+
if (preg_match('/[^a-zA-Z0-9\/\+=]/', $string))
{
return FALSE;
@@ -163,12 +163,12 @@ class CI_Encrypt {
{
$dec = $this->_xor_decode($dec, $key);
}
-
+
return $dec;
}
// --------------------------------------------------------------------
-
+
/**
* Encode from Legacy
*
@@ -176,7 +176,7 @@ class CI_Encrypt {
* returns a newly encoded string using the improved method added in 2.0.0
* This allows for backwards compatibility and a method to transition to the
* new encryption algorithms.
- *
+ *
* For more details, see http://codeigniter.com/user_guide/installation/upgrade_200.html#encryption
*
* @access public
@@ -192,22 +192,22 @@ class CI_Encrypt {
log_message('error', 'Encoding from legacy is available only when Mcrypt is in use.');
return FALSE;
}
-
+
// decode it first
// set mode temporarily to what it was when string was encoded with the legacy
- // algorithm - typically MCRYPT_MODE_ECB
+ // algorithm - typically MCRYPT_MODE_ECB
$current_mode = $this->_get_mode();
$this->set_mode($legacy_mode);
-
+
$key = $this->get_key($key);
-
+
if (preg_match('/[^a-zA-Z0-9\/\+=]/', $string))
{
return FALSE;
}
$dec = base64_decode($string);
-
+
if (($dec = $this->mcrypt_decode($dec, $key)) === FALSE)
{
return FALSE;
@@ -223,7 +223,7 @@ class CI_Encrypt {
}
// --------------------------------------------------------------------
-
+
/**
* XOR Encode
*
@@ -247,7 +247,7 @@ class CI_Encrypt {
$enc = '';
for ($i = 0; $i < strlen($string); $i++)
- {
+ {
$enc .= substr($rand, ($i % strlen($rand)), 1).(substr($rand, ($i % strlen($rand)), 1) ^ substr($string, $i, 1));
}
@@ -410,7 +410,7 @@ class CI_Encrypt {
{
$temp = $temp + 256;
}
-
+
$str .= chr($temp);
}
@@ -418,7 +418,7 @@ class CI_Encrypt {
}
// --------------------------------------------------------------------
-
+
/**
* Set the Mcrypt Cipher
*
@@ -477,7 +477,7 @@ class CI_Encrypt {
{
$this->_mcrypt_mode = MCRYPT_MODE_CBC;
}
-
+
return $this->_mcrypt_mode;
}
@@ -503,7 +503,7 @@ class CI_Encrypt {
* @access public
* @param string
* @return string
- */
+ */
function hash($str)
{
return ($this->_hash_type == 'sha1') ? $this->sha1($str) : md5($str);
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index 64baaef25..566655b12 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -25,29 +25,29 @@
* @link http://codeigniter.com/user_guide/libraries/form_validation.html
*/
class CI_Form_validation {
-
+
var $CI;
- var $_field_data = array();
+ var $_field_data = array();
var $_config_rules = array();
var $_error_array = array();
- var $_error_messages = array();
+ var $_error_messages = array();
var $_error_prefix = '<p>';
var $_error_suffix = '</p>';
var $error_string = '';
- var $_safe_form_data = FALSE;
+ var $_safe_form_data = FALSE;
/**
* Constructor
*
- */
+ */
function CI_Form_validation($rules = array())
- {
+ {
$this->CI =& get_instance();
-
+
// Validation rules can be stored in a config file.
$this->_config_rules = $rules;
-
+
// Automatically load the form helper
$this->CI->load->helper('form');
@@ -56,12 +56,12 @@ class CI_Form_validation {
{
mb_internal_encoding($this->CI->config->item('charset'));
}
-
+
log_message('debug', "Form Validation Class Initialized");
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Set Rules
*
@@ -80,7 +80,7 @@ class CI_Form_validation {
{
return;
}
-
+
// If an array was passed via the first parameter instead of indidual string
// values we cycle through it and recursively call this function.
if (is_array($field))
@@ -101,7 +101,7 @@ class CI_Form_validation {
}
return;
}
-
+
// No fields? Nothing to do...
if ( ! is_string($field) OR ! is_string($rules) OR $field == '')
{
@@ -113,9 +113,9 @@ class CI_Form_validation {
// Is the field name an array? We test for the existence of a bracket "[" in
// the field name to determine this. If it is an array, we break it apart
- // into its components so that we can fetch the corresponding POST data later
+ // into its components so that we can fetch the corresponding POST data later
if (strpos($field, '[') !== FALSE AND preg_match_all('/\[(.*?)\]/', $field, $matches))
- {
+ {
// Note: Due to a bug in current() that affects some versions
// of PHP we can not pass function call directly into it
$x = explode('[', $field);
@@ -128,19 +128,19 @@ class CI_Form_validation {
$indexes[] = $matches['1'][$i];
}
}
-
+
$is_array = TRUE;
}
else
{
- $indexes = array();
- $is_array = FALSE;
+ $indexes = array();
+ $is_array = FALSE;
}
-
- // Build our master array
+
+ // Build our master array
$this->_field_data[$field] = array(
- 'field' => $field,
- 'label' => $label,
+ 'field' => $field,
+ 'label' => $label,
'rules' => $rules,
'is_array' => $is_array,
'keys' => $indexes,
@@ -150,7 +150,7 @@ class CI_Form_validation {
}
// --------------------------------------------------------------------
-
+
/**
* Set Error Message
*
@@ -168,12 +168,12 @@ class CI_Form_validation {
{
$lang = array($lang => $val);
}
-
+
$this->_error_messages = array_merge($this->_error_messages, $lang);
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Set The Error Delimiter
*
@@ -183,7 +183,7 @@ class CI_Form_validation {
* @param string
* @param string
* @return void
- */
+ */
function set_error_delimiters($prefix = '<p>', $suffix = '</p>')
{
$this->_error_prefix = $prefix;
@@ -191,7 +191,7 @@ class CI_Form_validation {
}
// --------------------------------------------------------------------
-
+
/**
* Get Error Message
*
@@ -200,14 +200,14 @@ class CI_Form_validation {
* @access public
* @param string the field name
* @return void
- */
+ */
function error($field = '', $prefix = '', $suffix = '')
- {
+ {
if ( ! isset($this->_field_data[$field]['error']) OR $this->_field_data[$field]['error'] == '')
{
return '';
}
-
+
if ($prefix == '')
{
$prefix = $this->_error_prefix;
@@ -222,7 +222,7 @@ class CI_Form_validation {
}
// --------------------------------------------------------------------
-
+
/**
* Error String
*
@@ -232,7 +232,7 @@ class CI_Form_validation {
* @param string
* @param string
* @return str
- */
+ */
function error_string($prefix = '', $suffix = '')
{
// No errrors, validation passes!
@@ -240,7 +240,7 @@ class CI_Form_validation {
{
return '';
}
-
+
if ($prefix == '')
{
$prefix = $this->_error_prefix;
@@ -250,7 +250,7 @@ class CI_Form_validation {
{
$suffix = $this->_error_suffix;
}
-
+
// Generate the error string
$str = '';
foreach ($this->_error_array as $val)
@@ -260,12 +260,12 @@ class CI_Form_validation {
$str .= $prefix.$val.$suffix."\n";
}
}
-
+
return $str;
}
// --------------------------------------------------------------------
-
+
/**
* Run the Validator
*
@@ -273,7 +273,7 @@ class CI_Form_validation {
*
* @access public
* @return bool
- */
+ */
function run($group = '')
{
// Do we even have any data to process? Mm?
@@ -281,7 +281,7 @@ class CI_Form_validation {
{
return FALSE;
}
-
+
// Does the _field_data array containing the validation rules exist?
// If not, we look to see if they were assigned via a config file
if (count($this->_field_data) == 0)
@@ -291,10 +291,10 @@ class CI_Form_validation {
{
return FALSE;
}
-
+
// Is there a validation rule for the particular URI being accessed?
$uri = ($group == '') ? trim($this->CI->uri->ruri_string(), '/') : $group;
-
+
if ($uri != '' AND isset($this->_config_rules[$uri]))
{
$this->set_rules($this->_config_rules[$uri]);
@@ -303,7 +303,7 @@ class CI_Form_validation {
{
$this->set_rules($this->_config_rules);
}
-
+
// We're we able to set the rules correctly?
if (count($this->_field_data) == 0)
{
@@ -311,17 +311,17 @@ class CI_Form_validation {
return FALSE;
}
}
-
+
// Load the language file containing error messages
$this->CI->lang->load('form_validation');
-
- // Cycle through the rules for each field, match the
+
+ // Cycle through the rules for each field, match the
// corresponding $_POST item and test for errors
foreach ($this->_field_data as $field => $row)
- {
+ {
// Fetch the data from the corresponding $_POST array and cache it in the _field_data array.
// Depending on whether the field name is an array or a string will determine where we get it from.
-
+
if ($row['is_array'] == TRUE)
{
$this->_field_data[$field]['postdata'] = $this->_reduce_array($_POST, $row['keys']);
@@ -333,8 +333,8 @@ class CI_Form_validation {
$this->_field_data[$field]['postdata'] = $_POST[$field];
}
}
-
- $this->_execute($row, explode('|', $row['rules']), $this->_field_data[$field]['postdata']);
+
+ $this->_execute($row, explode('|', $row['rules']), $this->_field_data[$field]['postdata']);
}
// Did we end up with any errors?
@@ -347,7 +347,7 @@ class CI_Form_validation {
// Now we need to re-set the POST data with the new, processed data
$this->_reset_post_array();
-
+
// No errors, validation passes!
if ($total_errors == 0)
{
@@ -359,7 +359,7 @@ class CI_Form_validation {
}
// --------------------------------------------------------------------
-
+
/**
* Traverse a multidimensional $_POST array index until the data is found
*
@@ -368,7 +368,7 @@ class CI_Form_validation {
* @param array
* @param integer
* @return mixed
- */
+ */
function _reduce_array($array, $keys, $i = 0)
{
if (is_array($array))
@@ -389,18 +389,18 @@ class CI_Form_validation {
return $array;
}
}
-
+
return $array;
}
// --------------------------------------------------------------------
-
+
/**
* Re-populate the _POST array with our finalized and processed data
*
* @access private
* @return null
- */
+ */
function _reset_post_array()
{
foreach ($this->_field_data as $field => $row)
@@ -418,7 +418,7 @@ class CI_Form_validation {
{
// start with a reference
$post_ref =& $_POST;
-
+
// before we assign values, make a reference to the right POST key
if (count($row['keys']) == 1)
{
@@ -452,7 +452,7 @@ class CI_Form_validation {
}
// --------------------------------------------------------------------
-
+
/**
* Executes the Validation routines
*
@@ -462,21 +462,21 @@ class CI_Form_validation {
* @param mixed
* @param integer
* @return mixed
- */
+ */
function _execute($row, $rules, $postdata = NULL, $cycles = 0)
{
// If the $_POST data is an array we will run a recursive call
if (is_array($postdata))
- {
+ {
foreach ($postdata as $key => $val)
{
$this->_execute($row, $rules, $val, $cycles);
$cycles++;
}
-
+
return;
}
-
+
// --------------------------------------------------------------------
// If the field is blank, but NOT required, no further tests are necessary
@@ -496,7 +496,7 @@ class CI_Form_validation {
}
// --------------------------------------------------------------------
-
+
// Isset Test. Typically this rule will only apply to checkboxes.
if (is_null($postdata) AND $callback == FALSE)
{
@@ -504,31 +504,31 @@ class CI_Form_validation {
{
// Set the message type
$type = (in_array('required', $rules)) ? 'required' : 'isset';
-
+
if ( ! isset($this->_error_messages[$type]))
{
if (FALSE === ($line = $this->CI->lang->line($type)))
{
$line = 'The field was not set';
- }
+ }
}
else
{
$line = $this->_error_messages[$type];
}
-
+
// Build the error message
$message = sprintf($line, $this->_translate_fieldname($row['label']));
// Save the error message
$this->_field_data[$row['field']]['error'] = $message;
-
+
if ( ! isset($this->_error_array[$row['field']]))
{
$this->_error_array[$row['field']] = $message;
}
}
-
+
return;
}
@@ -538,7 +538,7 @@ class CI_Form_validation {
foreach ($rules As $rule)
{
$_in_array = FALSE;
-
+
// We set the $postdata variable with the current data in our master array so that
// each cycle of the loop is dealing with the processed data from the last cycle
if ($row['is_array'] == TRUE AND is_array($this->_field_data[$row['field']]['postdata']))
@@ -549,7 +549,7 @@ class CI_Form_validation {
{
continue;
}
-
+
$postdata = $this->_field_data[$row['field']]['postdata'][$cycles];
$_in_array = TRUE;
}
@@ -559,15 +559,15 @@ class CI_Form_validation {
}
// --------------------------------------------------------------------
-
- // Is the rule a callback?
+
+ // Is the rule a callback?
$callback = FALSE;
if (substr($rule, 0, 9) == 'callback_')
{
$rule = substr($rule, 9);
$callback = TRUE;
}
-
+
// Strip the parameter (if exists) from the rule
// Rules can contain a parameter: max_length[5]
$param = FALSE;
@@ -576,15 +576,15 @@ class CI_Form_validation {
$rule = $match[1];
$param = $match[2];
}
-
+
// Call the function that corresponds to the rule
if ($callback === TRUE)
{
if ( ! method_exists($this->CI, $rule))
- {
+ {
continue;
}
-
+
// Run the function and grab the result
$result = $this->CI->$rule($postdata, $param);
@@ -597,7 +597,7 @@ class CI_Form_validation {
{
$this->_field_data[$row['field']]['postdata'] = (is_bool($result)) ? $postdata : $result;
}
-
+
// If the field isn't required and we just processed a callback we'll move on...
if ( ! in_array('required', $rules, TRUE) AND $result !== FALSE)
{
@@ -605,15 +605,15 @@ class CI_Form_validation {
}
}
else
- {
+ {
if ( ! method_exists($this, $rule))
{
- // If our own wrapper function doesn't exist we see if a native PHP function does.
+ // If our own wrapper function doesn't exist we see if a native PHP function does.
// Users can use any native PHP function call that has one param.
if (function_exists($rule))
{
$result = $rule($postdata);
-
+
if ($_in_array == TRUE)
{
$this->_field_data[$row['field']]['postdata'][$cycles] = (is_bool($result)) ? $postdata : $result;
@@ -623,7 +623,7 @@ class CI_Form_validation {
$this->_field_data[$row['field']]['postdata'] = (is_bool($result)) ? $postdata : $result;
}
}
-
+
continue;
}
@@ -638,54 +638,54 @@ class CI_Form_validation {
$this->_field_data[$row['field']]['postdata'] = (is_bool($result)) ? $postdata : $result;
}
}
-
+
// Did the rule test negatively? If so, grab the error.
if ($result === FALSE)
- {
+ {
if ( ! isset($this->_error_messages[$rule]))
{
if (FALSE === ($line = $this->CI->lang->line($rule)))
{
$line = 'Unable to access an error message corresponding to your field name.';
- }
+ }
}
else
{
$line = $this->_error_messages[$rule];
}
-
+
// Is the parameter we are inserting into the error message the name
// of another field? If so we need to grab its "field label"
if (isset($this->_field_data[$param]) AND isset($this->_field_data[$param]['label']))
{
$param = $this->_translate_fieldname($this->_field_data[$param]['label']);
}
-
+
// Build the error message
$message = sprintf($line, $this->_translate_fieldname($row['label']), $param);
// Save the error message
$this->_field_data[$row['field']]['error'] = $message;
-
+
if ( ! isset($this->_error_array[$row['field']]))
{
$this->_error_array[$row['field']] = $message;
}
-
+
return;
}
}
}
// --------------------------------------------------------------------
-
+
/**
* Translate a field name
*
* @access private
* @param string the field name
* @return string
- */
+ */
function _translate_fieldname($fieldname)
{
// Do we need to translate the field name?
@@ -693,8 +693,8 @@ class CI_Form_validation {
if (substr($fieldname, 0, 5) == 'lang:')
{
// Grab the variable
- $line = substr($fieldname, 5);
-
+ $line = substr($fieldname, 5);
+
// Were we able to translate the field name? If not we use $line
if (FALSE === ($fieldname = $this->CI->lang->line($line)))
{
@@ -706,7 +706,7 @@ class CI_Form_validation {
}
// --------------------------------------------------------------------
-
+
/**
* Get the value from a form
*
@@ -717,19 +717,19 @@ class CI_Form_validation {
* @param string the field name
* @param string
* @return void
- */
+ */
function set_value($field = '', $default = '')
{
if ( ! isset($this->_field_data[$field]))
{
return $default;
}
-
+
return $this->_field_data[$field]['postdata'];
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Set Select
*
@@ -740,9 +740,9 @@ class CI_Form_validation {
* @param string
* @param string
* @return string
- */
+ */
function set_select($field = '', $value = '', $default = FALSE)
- {
+ {
if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata']))
{
if ($default === TRUE AND count($this->_field_data) === 0)
@@ -751,9 +751,9 @@ class CI_Form_validation {
}
return '';
}
-
+
$field = $this->_field_data[$field]['postdata'];
-
+
if (is_array($field))
{
if ( ! in_array($value, $field))
@@ -768,12 +768,12 @@ class CI_Form_validation {
return '';
}
}
-
+
return ' selected="selected"';
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Set Radio
*
@@ -784,7 +784,7 @@ class CI_Form_validation {
* @param string
* @param string
* @return string
- */
+ */
function set_radio($field = '', $value = '', $default = FALSE)
{
if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata']))
@@ -795,9 +795,9 @@ class CI_Form_validation {
}
return '';
}
-
+
$field = $this->_field_data[$field]['postdata'];
-
+
if (is_array($field))
{
if ( ! in_array($value, $field))
@@ -812,12 +812,12 @@ class CI_Form_validation {
return '';
}
}
-
+
return ' checked="checked"';
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Set Checkbox
*
@@ -828,7 +828,7 @@ class CI_Form_validation {
* @param string
* @param string
* @return string
- */
+ */
function set_checkbox($field = '', $value = '', $default = FALSE)
{
if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata']))
@@ -839,9 +839,9 @@ class CI_Form_validation {
}
return '';
}
-
+
$field = $this->_field_data[$field]['postdata'];
-
+
if (is_array($field))
{
if ( ! in_array($value, $field))
@@ -856,12 +856,12 @@ class CI_Form_validation {
return '';
}
}
-
+
return ' checked="checked"';
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Required
*
@@ -880,9 +880,9 @@ class CI_Form_validation {
return ( ! empty($str));
}
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Match one field to another
*
@@ -895,16 +895,16 @@ class CI_Form_validation {
{
if ( ! isset($_POST[$field]))
{
- return FALSE;
+ return FALSE;
}
-
+
$field = $_POST[$field];
return ($str !== $field) ? FALSE : TRUE;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Minimum Length
*
@@ -912,7 +912,7 @@ class CI_Form_validation {
* @param string
* @param value
* @return bool
- */
+ */
function min_length($str, $val)
{
if (preg_match("/[^0-9]/", $val))
@@ -922,14 +922,14 @@ class CI_Form_validation {
if (function_exists('mb_strlen'))
{
- return (mb_strlen($str) < $val) ? FALSE : TRUE;
+ return (mb_strlen($str) < $val) ? FALSE : TRUE;
}
-
+
return (strlen($str) < $val) ? FALSE : TRUE;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Max Length
*
@@ -937,7 +937,7 @@ class CI_Form_validation {
* @param string
* @param value
* @return bool
- */
+ */
function max_length($str, $val)
{
if (preg_match("/[^0-9]/", $val))
@@ -947,14 +947,14 @@ class CI_Form_validation {
if (function_exists('mb_strlen'))
{
- return (mb_strlen($str) > $val) ? FALSE : TRUE;
+ return (mb_strlen($str) > $val) ? FALSE : TRUE;
}
-
+
return (strlen($str) > $val) ? FALSE : TRUE;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Exact Length
*
@@ -962,7 +962,7 @@ class CI_Form_validation {
* @param string
* @param value
* @return bool
- */
+ */
function exact_length($str, $val)
{
if (preg_match("/[^0-9]/", $val))
@@ -972,42 +972,42 @@ class CI_Form_validation {
if (function_exists('mb_strlen'))
{
- return (mb_strlen($str) != $val) ? FALSE : TRUE;
+ return (mb_strlen($str) != $val) ? FALSE : TRUE;
}
-
+
return (strlen($str) != $val) ? FALSE : TRUE;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Valid Email
*
* @access public
* @param string
* @return bool
- */
+ */
function valid_email($str)
{
return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE;
}
// --------------------------------------------------------------------
-
+
/**
* Valid Emails
*
* @access public
* @param string
* @return bool
- */
+ */
function valid_emails($str)
{
if (strpos($str, ',') === FALSE)
{
return $this->valid_email(trim($str));
}
-
+
foreach(explode(',', $str) as $email)
{
if (trim($email) != '' && $this->valid_email(trim($email)) === FALSE)
@@ -1015,12 +1015,12 @@ class CI_Form_validation {
return FALSE;
}
}
-
+
return TRUE;
}
// --------------------------------------------------------------------
-
+
/**
* Validate IP Address
*
@@ -1034,56 +1034,56 @@ class CI_Form_validation {
}
// --------------------------------------------------------------------
-
+
/**
* Alpha
*
* @access public
* @param string
* @return bool
- */
+ */
function alpha($str)
{
return ( ! preg_match("/^([a-z])+$/i", $str)) ? FALSE : TRUE;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Alpha-numeric
*
* @access public
* @param string
* @return bool
- */
+ */
function alpha_numeric($str)
{
return ( ! preg_match("/^([a-z0-9])+$/i", $str)) ? FALSE : TRUE;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Alpha-numeric with underscores and dashes
*
* @access public
* @param string
* @return bool
- */
+ */
function alpha_dash($str)
{
return ( ! preg_match("/^([-a-z0-9_-])+$/i", $str)) ? FALSE : TRUE;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Numeric
*
* @access public
* @param string
* @return bool
- */
+ */
function numeric($str)
{
return (bool)preg_match( '/^[\-+]?[0-9]*\.?[0-9]+$/', $str);
@@ -1092,72 +1092,72 @@ class CI_Form_validation {
// --------------------------------------------------------------------
- /**
- * Is Numeric
- *
- * @access public
- * @param string
- * @return bool
- */
- function is_numeric($str)
- {
- return ( ! is_numeric($str)) ? FALSE : TRUE;
- }
+ /**
+ * Is Numeric
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function is_numeric($str)
+ {
+ return ( ! is_numeric($str)) ? FALSE : TRUE;
+ }
// --------------------------------------------------------------------
-
+
/**
* Integer
*
* @access public
* @param string
* @return bool
- */
+ */
function integer($str)
{
return (bool)preg_match( '/^[\-+]?[0-9]+$/', $str);
}
-
+
// --------------------------------------------------------------------
- /**
- * Is a Natural number (0,1,2,3, etc.)
- *
- * @access public
- * @param string
- * @return bool
- */
- function is_natural($str)
- {
- return (bool)preg_match( '/^[0-9]+$/', $str);
- }
+ /**
+ * Is a Natural number (0,1,2,3, etc.)
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function is_natural($str)
+ {
+ return (bool)preg_match( '/^[0-9]+$/', $str);
+ }
// --------------------------------------------------------------------
- /**
- * Is a Natural number, but not a zero (1,2,3, etc.)
- *
- * @access public
- * @param string
- * @return bool
- */
+ /**
+ * Is a Natural number, but not a zero (1,2,3, etc.)
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
function is_natural_no_zero($str)
- {
- if ( ! preg_match( '/^[0-9]+$/', $str))
- {
- return FALSE;
- }
-
- if ($str == 0)
- {
- return FALSE;
- }
-
- return TRUE;
- }
-
+ {
+ if ( ! preg_match( '/^[0-9]+$/', $str))
+ {
+ return FALSE;
+ }
+
+ if ($str == 0)
+ {
+ return FALSE;
+ }
+
+ return TRUE;
+ }
+
// --------------------------------------------------------------------
-
+
/**
* Valid Base64
*
@@ -1172,9 +1172,9 @@ class CI_Form_validation {
{
return (bool) ! preg_match('/[^a-zA-Z0-9\/\+=]/', $str);
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Prep data for form
*
@@ -1193,10 +1193,10 @@ class CI_Form_validation {
{
$data[$key] = $this->prep_for_form($val);
}
-
+
return $data;
}
-
+
if ($this->_safe_form_data == FALSE OR $data === '')
{
return $data;
@@ -1204,54 +1204,54 @@ class CI_Form_validation {
return str_replace(array("'", '"', '<', '>'), array("&#39;", "&quot;", '&lt;', '&gt;'), stripslashes($data));
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Prep URL
*
* @access public
* @param string
* @return string
- */
+ */
function prep_url($str = '')
{
if ($str == 'http://' OR $str == '')
{
return '';
}
-
+
if (substr($str, 0, 7) != 'http://' && substr($str, 0, 8) != 'https://')
{
$str = 'http://'.$str;
}
-
+
return $str;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Strip Image Tags
*
* @access public
* @param string
* @return string
- */
+ */
function strip_image_tags($str)
{
return $this->CI->input->strip_image_tags($str);
}
-
+
// --------------------------------------------------------------------
-
+
/**
* XSS Clean
*
* @access public
* @param string
* @return string
- */
+ */
function xss_clean($str)
{
if ( ! isset($this->CI->security))
@@ -1261,16 +1261,16 @@ class CI_Form_validation {
return $this->CI->security->xss_clean($str);
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Convert PHP tags to entities
*
* @access public
* @param string
* @return string
- */
+ */
function encode_php_tags($str)
{
return str_replace(array('<?php', '<?PHP', '<?', '?>'), array('&lt;?php', '&lt;?PHP', '&lt;?', '?&gt;'), $str);
diff --git a/system/libraries/Ftp.php b/system/libraries/Ftp.php
index 07f4b1ff3..fa2d3770b 100644
--- a/system/libraries/Ftp.php
+++ b/system/libraries/Ftp.php
@@ -295,7 +295,7 @@ class CI_FTP {
{
return FALSE;
}
-
+
// Set the mode if not specified
if ($mode == 'auto')
{
@@ -303,9 +303,9 @@ class CI_FTP {
$ext = $this->_getext($rempath);
$mode = $this->_settype($ext);
}
-
+
$mode = ($mode == 'ascii') ? FTP_ASCII : FTP_BINARY;
-
+
$result = @ftp_get($this->conn_id, $locpath, $rempath, $mode);
if ($result === FALSE)
@@ -314,11 +314,11 @@ class CI_FTP {
{
$this->_error('ftp_unable_to_download');
}
- return FALSE;
+ return FALSE;
}
-
+
return TRUE;
- }
+ }
// --------------------------------------------------------------------
@@ -454,7 +454,7 @@ class CI_FTP {
* Set file permissions
*
* @access public
- * @param string the file path
+ * @param string the file path
* @param string the permissions
* @return bool
*/
diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index 806d942ba..99225600f 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -26,7 +26,7 @@
*/
class CI_Image_lib {
- var $image_library = 'gd2'; // Can be: imagemagick, netpbm, gd, gd2
+ var $image_library = 'gd2'; // Can be: imagemagick, netpbm, gd, gd2
var $library_path = '';
var $dynamic_output = FALSE; // Whether to send to browser or write to disk
var $source_image = '';
@@ -36,7 +36,7 @@ class CI_Image_lib {
var $quality = '90';
var $create_thumb = FALSE;
var $thumb_marker = '_thumb';
- var $maintain_ratio = TRUE; // Whether to maintain aspect ratio when resizing or use hard values
+ var $maintain_ratio = TRUE; // Whether to maintain aspect ratio when resizing or use hard values
var $master_dim = 'auto'; // auto, height, or width. Determines what to use as the master dimension
var $rotation_angle = '';
var $x_axis = '';
@@ -54,11 +54,11 @@ class CI_Image_lib {
var $wm_hor_alignment = 'C'; // Horizontal alignment: L R C
var $wm_padding = 0; // Padding around text
var $wm_hor_offset = 0; // Lets you push text to the right
- var $wm_vrt_offset = 0; // Lets you push text down
+ var $wm_vrt_offset = 0; // Lets you push text down
var $wm_font_color = '#ffffff'; // Text color
var $wm_shadow_color = ''; // Dropshadow color
var $wm_shadow_distance = 2; // Dropshadow distance
- var $wm_opacity = 50; // Image opacity: 1 - 100 Only works with image
+ var $wm_opacity = 50; // Image opacity: 1 - 100 Only works with image
// Private Vars
var $source_folder = '';
@@ -147,7 +147,7 @@ class CI_Image_lib {
if ($this->source_image == '')
{
$this->set_error('imglib_source_image_required');
- return FALSE;
+ return FALSE;
}
/*
@@ -190,7 +190,7 @@ class CI_Image_lib {
// Set the Image Properties
if ( ! $this->get_image_properties($this->source_folder.$this->source_image))
{
- return FALSE;
+ return FALSE;
}
/*
@@ -400,7 +400,7 @@ class CI_Image_lib {
if ($this->rotation_angle == '' OR ! in_array($this->rotation_angle, $degs))
{
$this->set_error('imglib_rotation_angle_required');
- return FALSE;
+ return FALSE;
}
// Reassign the width and height
@@ -455,8 +455,8 @@ class CI_Image_lib {
{
if ($this->orig_width == $this->width AND $this->orig_height == $this->height)
{
- if ($this->source_image != $this->new_image)
- {
+ if ($this->source_image != $this->new_image)
+ {
if (@copy($this->full_src_path, $this->full_dst_path))
{
@chmod($this->full_dst_path, FILE_WRITE_MODE);
@@ -494,14 +494,14 @@ class CI_Image_lib {
return FALSE;
}
- // Create The Image
+ // Create The Image
//
// old conditional which users report cause problems with shared GD libs who report themselves as "2.0 or greater"
// it appears that this is no longer the issue that it was in 2004, so we've removed it, retaining it in the comment
// below should that ever prove inaccurate.
//
// if ($this->image_library == 'gd2' AND function_exists('imagecreatetruecolor') AND $v2_override == FALSE)
- if ($this->image_library == 'gd2' AND function_exists('imagecreatetruecolor'))
+ if ($this->image_library == 'gd2' AND function_exists('imagecreatetruecolor'))
{
$create = 'imagecreatetruecolor';
$copy = 'imagecopyresampled';
@@ -519,7 +519,7 @@ class CI_Image_lib {
imagealphablending($dst_img, FALSE);
imagesavealpha($dst_img, TRUE);
}
-
+
$copy($dst_img, $src_img, 0, 0, $this->x_axis, $this->y_axis, $this->width, $this->height, $this->orig_width, $this->orig_height);
// Show the image
@@ -584,9 +584,9 @@ class CI_Image_lib {
{
switch ($this->rotation_angle)
{
- case 'hor' : $angle = '-flop';
+ case 'hor' : $angle = '-flop';
break;
- case 'vrt' : $angle = '-flip';
+ case 'vrt' : $angle = '-flip';
break;
default : $angle = '-rotate '.$this->rotation_angle;
break;
@@ -664,7 +664,7 @@ class CI_Image_lib {
break;
case 180 : $angle = 'r180';
break;
- case 270 : $angle = 'r90';
+ case 270 : $angle = 'r90';
break;
case 'vrt' : $angle = 'tb';
break;
@@ -889,7 +889,7 @@ class CI_Image_lib {
$this->get_image_properties();
// Fetch watermark image properties
- $props = $this->get_image_properties($this->wm_overlay_path, TRUE);
+ $props = $this->get_image_properties($this->wm_overlay_path, TRUE);
$wm_img_type = $props['image_type'];
$wm_width = $props['width'];
$wm_height = $props['height'];
@@ -944,7 +944,7 @@ class CI_Image_lib {
if ($wm_img_type == 3 AND function_exists('imagealphablending'))
{
@imagealphablending($src_img, TRUE);
- }
+ }
// Set RGB values for text and shadow
$rgba = imagecolorat($wm_img, $this->wm_x_transp, $this->wm_y_transp);
@@ -1266,7 +1266,7 @@ class CI_Image_lib {
switch ($this->image_type)
{
- case 1 : imagegif($resource);
+ case 1 : imagegif($resource);
break;
case 2 : imagejpeg($resource, '', $this->quality);
break;
@@ -1384,8 +1384,8 @@ class CI_Image_lib {
* new variable needs to be known
*
* $props = array(
- * 'width' => $width,
- * 'height' => $height,
+ * 'width' => $width,
+ * 'height' => $height,
* 'new_width' => 40,
* 'new_height' => ''
* );
@@ -1446,7 +1446,7 @@ class CI_Image_lib {
{
$ext = strrchr($source_image, '.');
$name = ($ext === FALSE) ? $source_image : substr($source_image, 0, -strlen($ext));
-
+
return array('ext' => $ext, 'name' => $name);
}
diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php
index efaaab4bf..30b62e1c2 100644
--- a/system/libraries/Javascript.php
+++ b/system/libraries/Javascript.php
@@ -22,16 +22,16 @@
* @subpackage Libraries
* @category Javascript
* @author ExpressionEngine Dev Team
- * @link http://codeigniter.com/user_guide/general/errors.html
+ * @link http://codeigniter.com/user_guide/libraries/javascript.html
*/
class CI_Javascript {
var $_javascript_location = 'js';
function CI_Javascript($params = array())
- {
+ {
$defaults = array('js_library_driver' => 'jquery', 'autoload' => TRUE);
-
+
foreach ($defaults as $key => $val)
{
if (isset($params[$key]) && $params[$key] !== "")
@@ -39,7 +39,7 @@ class CI_Javascript {
$defaults[$key] = $params[$key];
}
}
-
+
extract($defaults);
$this->CI =& get_instance();
@@ -48,13 +48,13 @@ class CI_Javascript {
$this->CI->load->library('javascript/'.$js_library_driver, array('autoload' => $autoload));
// make js to refer to current library
$this->js =& $this->CI->$js_library_driver;
-
+
log_message('debug', "Javascript Class Initialized and loaded. Driver used: $js_library_driver");
}
- // --------------------------------------------------------------------
- // Event Code
// --------------------------------------------------------------------
+ // Event Code
+ // --------------------------------------------------------------------
/**
* Blur
@@ -70,9 +70,9 @@ class CI_Javascript {
{
return $this->js->_blur($element, $js);
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Change
*
@@ -87,9 +87,9 @@ class CI_Javascript {
{
return $this->js->_change($element, $js);
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Click
*
@@ -107,7 +107,7 @@ class CI_Javascript {
}
// --------------------------------------------------------------------
-
+
/**
* Double Click
*
@@ -124,7 +124,7 @@ class CI_Javascript {
}
// --------------------------------------------------------------------
-
+
/**
* Error
*
@@ -141,7 +141,7 @@ class CI_Javascript {
}
// --------------------------------------------------------------------
-
+
/**
* Focus
*
@@ -158,7 +158,7 @@ class CI_Javascript {
}
// --------------------------------------------------------------------
-
+
/**
* Hover
*
@@ -168,7 +168,7 @@ class CI_Javascript {
* @param string - element
* @param string - Javascript code for mouse over
* @param string - Javascript code for mouse out
- * @return string
+ * @return string
*/
function hover($element = 'this', $over, $out)
{
@@ -176,7 +176,7 @@ class CI_Javascript {
}
// --------------------------------------------------------------------
-
+
/**
* Keydown
*
@@ -193,7 +193,7 @@ class CI_Javascript {
}
// --------------------------------------------------------------------
-
+
/**
* Keyup
*
@@ -207,10 +207,10 @@ class CI_Javascript {
function keyup($element = 'this', $js = '')
{
return $this->js->_keyup($element, $js);
- }
+ }
// --------------------------------------------------------------------
-
+
/**
* Load
*
@@ -224,10 +224,10 @@ class CI_Javascript {
function load($element = 'this', $js = '')
{
return $this->js->_load($element, $js);
- }
-
+ }
+
// --------------------------------------------------------------------
-
+
/**
* Mousedown
*
@@ -244,7 +244,7 @@ class CI_Javascript {
}
// --------------------------------------------------------------------
-
+
/**
* Mouse Out
*
@@ -261,7 +261,7 @@ class CI_Javascript {
}
// --------------------------------------------------------------------
-
+
/**
* Mouse Over
*
@@ -360,7 +360,7 @@ class CI_Javascript {
{
return $this->js->_scroll($element, $js);
}
-
+
// --------------------------------------------------------------------
/**
@@ -378,9 +378,9 @@ class CI_Javascript {
return $this->js->_unload($element, $js);
}
- // --------------------------------------------------------------------
- // Effects
// --------------------------------------------------------------------
+ // Effects
+ // --------------------------------------------------------------------
/**
@@ -391,14 +391,14 @@ class CI_Javascript {
* @access public
* @param string - element
* @param string - Class to add
- * @return string
+ * @return string
*/
function addClass($element = 'this', $class = '')
{
return $this->js->_addClass($element, $class);
}
- // --------------------------------------------------------------------
+ // --------------------------------------------------------------------
/**
* Animate
@@ -409,7 +409,7 @@ class CI_Javascript {
* @param string - element
* @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
* @param string - Javascript callback function
- * @return string
+ * @return string
*/
function animate($element = 'this', $params = array(), $speed = '', $extra = '')
{
@@ -417,7 +417,7 @@ class CI_Javascript {
}
// --------------------------------------------------------------------
-
+
/**
* Fade In
*
@@ -427,15 +427,15 @@ class CI_Javascript {
* @param string - element
* @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
* @param string - Javascript callback function
- * @return string
+ * @return string
*/
function fadeIn($element = 'this', $speed = '', $callback = '')
{
return $this->js->_fadeIn($element, $speed, $callback);
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Fade Out
*
@@ -445,14 +445,14 @@ class CI_Javascript {
* @param string - element
* @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
* @param string - Javascript callback function
- * @return string
+ * @return string
*/
function fadeOut($element = 'this', $speed = '', $callback = '')
{
return $this->js->_fadeOut($element, $speed, $callback);
}
// --------------------------------------------------------------------
-
+
/**
* Slide Up
*
@@ -462,14 +462,14 @@ class CI_Javascript {
* @param string - element
* @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
* @param string - Javascript callback function
- * @return string
+ * @return string
*/
function slideUp($element = 'this', $speed = '', $callback = '')
{
return $this->js->_slideUp($element, $speed, $callback);
}
-
+
// --------------------------------------------------------------------
/**
@@ -480,15 +480,15 @@ class CI_Javascript {
* @access public
* @param string - element
* @param string - Class to add
- * @return string
+ * @return string
*/
function removeClass($element = 'this', $class = '')
{
return $this->js->_removeClass($element, $class);
}
- // --------------------------------------------------------------------
-
+ // --------------------------------------------------------------------
+
/**
* Slide Down
*
@@ -498,7 +498,7 @@ class CI_Javascript {
* @param string - element
* @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
* @param string - Javascript callback function
- * @return string
+ * @return string
*/
function slideDown($element = 'this', $speed = '', $callback = '')
{
@@ -506,7 +506,7 @@ class CI_Javascript {
}
// --------------------------------------------------------------------
-
+
/**
* Slide Toggle
*
@@ -516,14 +516,14 @@ class CI_Javascript {
* @param string - element
* @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
* @param string - Javascript callback function
- * @return string
+ * @return string
*/
function slideToggle($element = 'this', $speed = '', $callback = '')
{
return $this->js->_slideToggle($element, $speed, $callback);
}
-
+
// --------------------------------------------------------------------
/**
@@ -535,15 +535,15 @@ class CI_Javascript {
* @param string - element
* @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
* @param string - Javascript callback function
- * @return string
+ * @return string
*/
function hide($element = 'this', $speed = '', $callback = '')
{
return $this->js->_hide($element, $speed, $callback);
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Toggle
*
@@ -551,16 +551,16 @@ class CI_Javascript {
*
* @access public
* @param string - element
- * @return string
+ * @return string
*/
function toggle($element = 'this')
{
return $this->js->_toggle($element);
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Toggle Class
*
@@ -568,15 +568,15 @@ class CI_Javascript {
*
* @access public
* @param string - element
- * @return string
+ * @return string
*/
function toggleClass($element = 'this', $class='')
{
return $this->js->_toggleClass($element, $class);
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Show
*
@@ -586,7 +586,7 @@ class CI_Javascript {
* @param string - element
* @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
* @param string - Javascript callback function
- * @return string
+ * @return string
*/
function show($element = 'this', $speed = '', $callback = '')
{
@@ -604,12 +604,12 @@ class CI_Javascript {
* @access public
* @param string The element to attach the event to
* @return string
- */
+ */
function compile($view_var = 'script_foot', $script_tags = TRUE)
{
$this->js->_compile($view_var, $script_tags);
}
-
+
/**
* Clear Compile
*
@@ -624,7 +624,7 @@ class CI_Javascript {
}
// --------------------------------------------------------------------
-
+
/**
* External
*
@@ -645,16 +645,16 @@ class CI_Javascript {
if ($this->CI->config->item('javascript_location') != '')
{
$this->_javascript_location = $this->CI->config->item('javascript_location');
- }
+ }
}
-
+
if ($relative === TRUE OR strncmp($external_file, 'http://', 7) == 0 OR strncmp($external_file, 'https://', 8) == 0)
{
- $str = $this->_open_script($external_file);
+ $str = $this->_open_script($external_file);
}
elseif (strpos($this->_javascript_location, 'http://') !== FALSE)
{
- $str = $this->_open_script($this->_javascript_location.$external_file);
+ $str = $this->_open_script($this->_javascript_location.$external_file);
}
else
{
@@ -664,13 +664,13 @@ class CI_Javascript {
$str .= $this->_close_script();
return $str;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Inline
*
- * Outputs a <script> tag
+ * Outputs a <script> tag
*
* @access public
* @param string The element to attach the event to
@@ -682,19 +682,19 @@ class CI_Javascript {
$str = $this->_open_script();
$str .= ($cdata) ? "\n// <![CDATA[\n{$script}\n// ]]>\n" : "\n{$script}\n";
$str .= $this->_close_script();
-
+
return $str;
}
-
- // --------------------------------------------------------------------
+ // --------------------------------------------------------------------
+
/**
* Open Script
*
- * Outputs an opening <script>
+ * Outputs an opening <script>
*
* @access private
- * @param string
+ * @param string
* @return string
*/
function _open_script($src = '')
@@ -705,22 +705,22 @@ class CI_Javascript {
}
// --------------------------------------------------------------------
-
+
/**
* Close Script
*
- * Outputs an closing </script>
+ * Outputs an closing </script>
*
* @access private
- * @param string
+ * @param string
* @return string
*/
function _close_script($extra = "\n")
{
return "</script>$extra";
}
-
-
+
+
// --------------------------------------------------------------------
// --------------------------------------------------------------------
// AJAX-Y STUFF - still a testbed
@@ -736,15 +736,15 @@ class CI_Javascript {
* @param string - element
* @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
* @param string - Javascript callback function
- * @return string
+ * @return string
*/
function update($element = 'this', $speed = '', $callback = '')
{
return $this->js->_updater($element, $speed, $callback);
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Generate JSON
*
@@ -780,7 +780,7 @@ class CI_Javascript {
$json = array();
$_is_assoc = TRUE;
-
+
if ( ! is_array($json_result) AND empty($json_result))
{
show_error("Generate JSON Failed - Illegal key, value pair.");
@@ -805,11 +805,11 @@ class CI_Javascript {
$json = implode(',', $json);
return $_is_assoc ? "{".$json."}" : "[".$json."]";
-
+
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Is associative array
*
@@ -828,12 +828,12 @@ class CI_Javascript {
return TRUE;
}
}
-
+
return FALSE;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Prep Args
*
@@ -862,7 +862,7 @@ class CI_Javascript {
return $result;
}
}
-
+
// --------------------------------------------------------------------
}
// END Javascript Class
diff --git a/system/libraries/Log.php b/system/libraries/Log.php
index 4e6b3bc39..99ed126f4 100644
--- a/system/libraries/Log.php
+++ b/system/libraries/Log.php
@@ -40,27 +40,27 @@ class CI_Log {
function CI_Log()
{
$config =& get_config();
-
+
$this->log_path = ($config['log_path'] != '') ? $config['log_path'] : BASEPATH.'logs/';
-
+
if ( ! is_dir($this->log_path) OR ! is_really_writable($this->log_path))
{
$this->_enabled = FALSE;
}
-
+
if (is_numeric($config['log_threshold']))
{
$this->_threshold = $config['log_threshold'];
}
-
+
if ($config['log_date_format'] != '')
{
$this->_date_fmt = $config['log_date_format'];
}
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Write Log File
*
@@ -71,42 +71,42 @@ class CI_Log {
* @param string the error message
* @param bool whether the error is a native PHP error
* @return bool
- */
+ */
function write_log($level = 'error', $msg, $php_error = FALSE)
- {
+ {
if ($this->_enabled === FALSE)
{
return FALSE;
}
-
+
$level = strtoupper($level);
-
+
if ( ! isset($this->_levels[$level]) OR ($this->_levels[$level] > $this->_threshold))
{
return FALSE;
}
-
+
$filepath = $this->log_path.'log-'.date('Y-m-d').EXT;
$message = '';
-
+
if ( ! file_exists($filepath))
{
$message .= "<"."?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ?".">\n\n";
}
-
+
if ( ! $fp = @fopen($filepath, FOPEN_WRITE_CREATE))
{
return FALSE;
}
$message .= $level.' '.(($level == 'INFO') ? ' -' : '-').' '.date($this->_date_fmt). ' --> '.$msg."\n";
-
- flock($fp, LOCK_EX);
+
+ flock($fp, LOCK_EX);
fwrite($fp, $message);
flock($fp, LOCK_UN);
fclose($fp);
-
- @chmod($filepath, FILE_WRITE_MODE);
+
+ @chmod($filepath, FILE_WRITE_MODE);
return TRUE;
}
diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
index 3a0632d09..b3175f997 100644
--- a/system/libraries/Pagination.php
+++ b/system/libraries/Pagination.php
@@ -30,11 +30,11 @@ class CI_Pagination {
var $prefix = ''; // A custom prefix added to the path.
var $suffix = ''; // A custom suffix added to the path.
- var $total_rows = ''; // Total number of items (database results)
- var $per_page = 10; // Max number of items you want shown per page
+ var $total_rows = ''; // Total number of items (database results)
+ var $per_page = 10; // Max number of items you want shown per page
var $num_links = 2; // Number of "digit" links to show before/after the currently viewed page
- var $cur_page = 0; // The current page being viewed
- var $first_link = '&lsaquo; First';
+ var $cur_page = 0; // The current page being viewed
+ var $first_link = '&lsaquo; First';
var $next_link = '&gt;';
var $prev_link = '&lt;';
var $last_link = 'Last &rsaquo;';
@@ -190,7 +190,7 @@ class CI_Pagination {
$this->base_url = rtrim($this->base_url, '/') .'/';
}
- // And here we go...
+ // And here we go...
$output = '';
// Render the "First" link
@@ -204,17 +204,17 @@ class CI_Pagination {
if ($this->prev_link !== FALSE AND $this->cur_page != 1)
{
$i = $uri_page_number - $this->per_page;
-
+
if ($i == 0 && $this->first_url != '')
{
- $output .= $this->prev_tag_open.'<a '.$this->anchor_class.'href="'.$this->first_url.'">'.$this->prev_link.'</a>'.$this->prev_tag_close;
+ $output .= $this->prev_tag_open.'<a '.$this->anchor_class.'href="'.$this->first_url.'">'.$this->prev_link.'</a>'.$this->prev_tag_close;
}
else
{
$i = ($i == 0) ? '' : $this->prefix.$i.$this->suffix;
$output .= $this->prev_tag_open.'<a '.$this->anchor_class.'href="'.$this->base_url.$i.'">'.$this->prev_link.'</a>'.$this->prev_tag_close;
}
-
+
}
// Render the pages
@@ -234,7 +234,7 @@ class CI_Pagination {
else
{
$n = ($i == 0) ? '' : $i;
-
+
if ($n == '' && $this->first_url != '')
{
$output .= $this->num_tag_open.'<a '.$this->anchor_class.'href="'.$this->first_url.'">'.$loop.'</a>'.$this->num_tag_close;
@@ -242,7 +242,7 @@ class CI_Pagination {
else
{
$n = ($n == '') ? '' : $this->prefix.$n.$this->suffix;
-
+
$output .= $this->num_tag_open.'<a '.$this->anchor_class.'href="'.$this->base_url.$n.'">'.$loop.'</a>'.$this->num_tag_close;
}
}
diff --git a/system/libraries/Parser.php b/system/libraries/Parser.php
index 41a438bac..b969ce4d4 100644
--- a/system/libraries/Parser.php
+++ b/system/libraries/Parser.php
@@ -94,7 +94,7 @@ class CI_Parser {
{
if (is_array($val))
{
- $template = $this->_parse_pair($key, $val, $template);
+ $template = $this->_parse_pair($key, $val, $template);
}
else
{
@@ -110,9 +110,9 @@ class CI_Parser {
return $template;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Set the left/right variable delimiters
*
@@ -126,9 +126,9 @@ class CI_Parser {
$this->l_delim = $l;
$this->r_delim = $r;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Parse a single key/value
*
@@ -142,9 +142,9 @@ class CI_Parser {
{
return str_replace($this->l_delim.$key.$this->r_delim, $val, $string);
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Parse a tag pair
*
@@ -157,7 +157,7 @@ class CI_Parser {
* @return string
*/
function _parse_pair($variable, $data, $string)
- {
+ {
if (FALSE === ($match = $this->_match_pair($string, $variable)))
{
return $string;
@@ -178,15 +178,15 @@ class CI_Parser {
$temp = $this->_parse_pair($key, $val, $temp);
}
}
-
+
$str .= $temp;
}
-
+
return str_replace($match['0'], $str, $string);
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Matches a variable pair
*
@@ -201,7 +201,7 @@ class CI_Parser {
{
return FALSE;
}
-
+
return $match;
}
diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php
index db179976b..796db2d6b 100644
--- a/system/libraries/Profiler.php
+++ b/system/libraries/Profiler.php
@@ -33,7 +33,7 @@
class CI_Profiler {
var $CI;
-
+
var $_available_sections = array(
'benchmarks',
'get',
@@ -46,11 +46,11 @@ class CI_Profiler {
'config'
);
- function CI_Profiler($config = array())
- {
- $this->CI =& get_instance();
- $this->CI->load->language('profiler');
-
+ function CI_Profiler($config = array())
+ {
+ $this->CI =& get_instance();
+ $this->CI->load->language('profiler');
+
// default all sections to display
foreach ($this->_available_sections as $section)
{
@@ -59,10 +59,10 @@ class CI_Profiler {
$this->_compile_{$section} = TRUE;
}
}
-
+
$this->set_sections($config);
- }
-
+ }
+
// --------------------------------------------------------------------
/**
@@ -80,13 +80,13 @@ class CI_Profiler {
{
if (in_array($method, $this->_available_sections))
{
- $this->_compile_{$method} = ($enable !== FALSE) ? TRUE : FALSE;
+ $this->_compile_{$method} = ($enable !== FALSE) ? TRUE : FALSE;
}
}
}
// --------------------------------------------------------------------
-
+
/**
* Auto Profiler
*
@@ -98,45 +98,45 @@ class CI_Profiler {
* @access private
* @return array
*/
- function _compile_benchmarks()
- {
- $profile = array();
- foreach ($this->CI->benchmark->marker as $key => $val)
- {
- // 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 (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);
- }
- }
- }
+ function _compile_benchmarks()
+ {
+ $profile = array();
+ foreach ($this->CI->benchmark->marker as $key => $val)
+ {
+ // 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 (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);
+ }
+ }
+ }
// Build a table containing the profile data.
// 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 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;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_benchmarks').'&nbsp;&nbsp;</legend>';
- $output .= "\n";
+ $output .= "\n";
$output .= "\n\n<table cellpadding='4' cellspacing='1' border='0' width='100%'>\n";
-
+
foreach ($profile as $key => $val)
{
$key = ucwords(str_replace(array('_', '-'), ' ', $key));
$output .= "<tr><td style='width:50%;color:#000;font-weight:bold;background-color:#ddd;'>".$key."&nbsp;&nbsp;</td><td style='width:50%;color:#900;font-weight:normal;background-color:#ddd;'>".$val."</td></tr>\n";
}
-
+
$output .= "</table>\n";
$output .= "</fieldset>";
-
- return $output;
- }
-
+
+ return $output;
+ }
+
// --------------------------------------------------------------------
/**
@@ -144,7 +144,7 @@ class CI_Profiler {
*
* @access private
* @return string
- */
+ */
function _compile_queries()
{
$dbs = array();
@@ -157,22 +157,22 @@ class CI_Profiler {
$dbs[] = $CI_object;
}
}
-
+
if (count($dbs) == 0)
{
$output = "\n\n";
$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;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_queries').'&nbsp;&nbsp;</legend>';
- $output .= "\n";
+ $output .= "\n";
$output .= "\n\n<table cellpadding='4' cellspacing='1' border='0' style='width:100%'>\n";
$output .="<tr><td style='width:100%;color:#0000FF;font-weight:normal;background-color:#eee;'>".$this->CI->lang->line('profiler_no_db')."</td></tr>\n";
$output .= "</table>\n";
$output .= "</fieldset>";
-
+
return $output;
}
-
+
// Load the text helper so we can highlight the SQL
$this->CI->load->helper('text');
@@ -180,45 +180,45 @@ class CI_Profiler {
$highlight = array('SELECT', 'DISTINCT', 'FROM', 'WHERE', 'AND', 'LEFT&nbsp;JOIN', 'ORDER&nbsp;BY', 'GROUP&nbsp;BY', 'LIMIT', 'INSERT', 'INTO', 'VALUES', 'UPDATE', 'OR&nbsp;', 'HAVING', 'OFFSET', 'NOT&nbsp;IN', 'IN', 'LIKE', 'NOT&nbsp;LIKE', 'COUNT', 'MAX', 'MIN', 'ON', 'AS', 'AVG', 'SUM', '(', ')');
$output = "\n\n";
-
+
foreach ($dbs as $db)
{
$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;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_database').':&nbsp; '.$db->database.'&nbsp;&nbsp;&nbsp;'.$this->CI->lang->line('profiler_queries').': '.count($this->CI->db->queries).'&nbsp;&nbsp;&nbsp;</legend>';
- $output .= "\n";
+ $output .= "\n";
$output .= "\n\n<table cellpadding='4' cellspacing='1' border='0' style='width:100%;'>\n";
-
+
if (count($db->queries) == 0)
{
$output .= "<tr><td style='width:100%;color:#0000FF;font-weight:normal;background-color:#eee;'>".$this->CI->lang->line('profiler_no_queries')."</td></tr>\n";
}
else
- {
+ {
foreach ($db->queries as $key => $val)
- {
+ {
$time = number_format($db->query_times[$key], 4);
$val = highlight_code($val, ENT_QUOTES);
-
+
foreach ($highlight as $bold)
{
- $val = str_replace($bold, '<strong>'.$bold.'</strong>', $val);
+ $val = str_replace($bold, '<strong>'.$bold.'</strong>', $val);
}
-
+
$output .= "<tr><td valign='top' style='width:1%;color:#900;font-weight:normal;background-color:#ddd;'>".$time."&nbsp;&nbsp;</td><td style='color:#000;font-weight:normal;background-color:#ddd;'>".$val."</td></tr>\n";
}
}
-
+
$output .= "</table>\n";
$output .= "</fieldset>";
-
+
}
-
+
return $output;
}
-
+
// --------------------------------------------------------------------
/**
@@ -226,15 +226,15 @@ class CI_Profiler {
*
* @access private
* @return string
- */
+ */
function _compile_get()
- {
+ {
$output = "\n\n";
$output .= '<fieldset 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;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_get_data').'&nbsp;&nbsp;</legend>';
$output .= "\n";
-
+
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>";
@@ -242,14 +242,14 @@ class CI_Profiler {
else
{
$output .= "\n\n<table cellpadding='4' cellspacing='1' border='0' width='100%'>\n";
-
+
foreach ($_GET as $key => $val)
{
if ( ! is_numeric($key))
{
$key = "'".$key."'";
}
-
+
$output .= "<tr><td width='50%' style='color:#000;background-color:#ddd;'>&#36;_GET[".$key."]&nbsp;&nbsp; </td><td width='50%' style='color:#cd6e00;font-weight:normal;background-color:#ddd;'>";
if (is_array($val))
{
@@ -261,30 +261,30 @@ class CI_Profiler {
}
$output .= "</td></tr>\n";
}
-
+
$output .= "</table>\n";
}
$output .= "</fieldset>";
- return $output;
+ return $output;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Compile $_POST Data
*
* @access private
* @return string
- */
+ */
function _compile_post()
- {
+ {
$output = "\n\n";
$output .= '<fieldset 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;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_post_data').'&nbsp;&nbsp;</legend>';
$output .= "\n";
-
+
if (count($_POST) == 0)
{
$output .= "<div style='color:#009900;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->lang->line('profiler_no_post')."</div>";
@@ -292,14 +292,14 @@ class CI_Profiler {
else
{
$output .= "\n\n<table cellpadding='4' cellspacing='1' border='0' width='100%'>\n";
-
+
foreach ($_POST as $key => $val)
{
if ( ! is_numeric($key))
{
$key = "'".$key."'";
}
-
+
$output .= "<tr><td width='50%' style='color:#000;background-color:#ddd;'>&#36;_POST[".$key."]&nbsp;&nbsp; </td><td width='50%' style='color:#009900;font-weight:normal;background-color:#ddd;'>";
if (is_array($val))
{
@@ -311,70 +311,70 @@ class CI_Profiler {
}
$output .= "</td></tr>\n";
}
-
+
$output .= "</table>\n";
}
$output .= "</fieldset>";
- return $output;
+ return $output;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Show query string
*
* @access private
* @return string
- */
+ */
function _compile_uri_string()
- {
+ {
$output = "\n\n";
$output .= '<fieldset 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;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_uri_string').'&nbsp;&nbsp;</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 .= "<div style='color:#000;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->uri->uri_string."</div>";
}
-
+
$output .= "</fieldset>";
- return $output;
+ return $output;
}
// --------------------------------------------------------------------
-
+
/**
* Show the controller and function that were called
*
* @access private
* @return string
- */
+ */
function _compile_controller_info()
- {
+ {
$output = "\n\n";
$output .= '<fieldset 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;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_controller_info').'&nbsp;&nbsp;</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 .= "<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 $output;
}
// --------------------------------------------------------------------
-
+
/**
* Compile memory usage
*
@@ -390,23 +390,23 @@ class CI_Profiler {
$output .= "\n";
$output .= '<legend style="color:#5a0099;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_memory_usage').'&nbsp;&nbsp;</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_usage')."</div>";
+ $output .= "<div style='color:#5a0099;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->lang->line('profiler_no_memory_usage')."</div>";
}
-
+
$output .= "</fieldset>";
return $output;
}
// --------------------------------------------------------------------
-
+
/**
* Compile header information
*
@@ -463,7 +463,7 @@ class CI_Profiler {
{
$val = print_r($val, TRUE);
}
-
+
$output .= "<tr><td valign='top' style='color:#900;background-color:#ddd;'>".$config."&nbsp;&nbsp;</td><td style='color:#000;background-color:#ddd;'>".htmlspecialchars($val)."</td></tr>\n";
}
@@ -474,18 +474,18 @@ class CI_Profiler {
}
// --------------------------------------------------------------------
-
+
/**
* Run the Profiler
*
* @access private
* @return string
- */
+ */
function run()
{
$output = "<div id='codeigniter_profiler' style='clear:both;background-color:#fff;padding:10px;'>";
$fields_displayed = 0;
-
+
foreach ($this->_available_sections as $section)
{
if ($this->_compile_{$section} !== FALSE)
@@ -500,7 +500,7 @@ class CI_Profiler {
{
$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;
diff --git a/system/libraries/Security.php b/system/libraries/Security.php
index 9a1590b5c..fa5317ea3 100644
--- a/system/libraries/Security.php
+++ b/system/libraries/Security.php
@@ -25,12 +25,12 @@
* @link http://codeigniter.com/user_guide/libraries/sessions.html
*/
class CI_Security {
- var $xss_hash = '';
- var $csrf_hash = '';
+ var $xss_hash = '';
+ var $csrf_hash = '';
var $csrf_expire = 7200; // Two hours (in seconds)
var $csrf_token_name = 'ci_csrf_token';
var $csrf_cookie_name = 'ci_csrf_token';
-
+
/* never allowed, string replacement */
var $never_allowed_str = array(
'document.cookie' => '[removed]',
@@ -63,7 +63,7 @@ class CI_Security {
}
// --------------------------------------------------------------------
-
+
/**
* Verify Cross Site Request Forgery Protection
*
@@ -92,7 +92,7 @@ class CI_Security {
// We kill this since we're done and we don't want to polute the _POST array
unset($_POST[$this->csrf_token_name]);
-
+
// Nothing should last forever
unset($_COOKIE[$this->csrf_cookie_name]);
$this->_csrf_set_hash();
@@ -100,9 +100,9 @@ class CI_Security {
log_message('debug', "CSRF token verified ");
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Set Cross Site Request Forgery Protection Cookie
*
@@ -114,12 +114,12 @@ class CI_Security {
$expire = time() + $this->csrf_expire;
setcookie($this->csrf_cookie_name, $this->csrf_hash, $expire, config_item('cookie_path'), config_item('cookie_domain'), 0);
-
- log_message('debug', "CRSF cookie Set");
+
+ log_message('debug', "CRSF cookie Set");
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Set Cross Site Request Forgery Protection Cookie
*
@@ -146,7 +146,7 @@ class CI_Security {
}
// --------------------------------------------------------------------
-
+
/**
* Show CSRF Error
*
@@ -159,7 +159,7 @@ class CI_Security {
}
// --------------------------------------------------------------------
-
+
/**
* XSS Clean
*
@@ -198,7 +198,7 @@ class CI_Security {
{
$str[$key] = $this->xss_clean($str[$key]);
}
-
+
return $str;
}
@@ -210,9 +210,9 @@ class CI_Security {
/*
* Protect GET variables in URLs
*/
-
+
// 901119URL5918AMP18930PROTECT8198
-
+
$str = preg_replace('|\&([a-z\_0-9\-]+)\=([a-z\_0-9\-]+)|i', $this->xss_hash()."\\1=\\2", $str);
/*
@@ -225,7 +225,7 @@ class CI_Security {
$str = preg_replace('#(&\#?[0-9a-z]{2,})([\x00-\x20])*;?#i', "\\1;\\2", $str);
/*
- * Validate UTF16 two byte encoding (x00)
+ * Validate UTF16 two byte encoding (x00)
*
* Just as above, adds a semicolon if missing.
*
@@ -248,9 +248,9 @@ class CI_Security {
*
*/
$str = rawurldecode($str);
-
+
/*
- * Convert character entities to ASCII
+ * Convert character entities to ASCII
*
* This permits our tests below to work reliably.
* We only convert entities that are within tags since
@@ -259,14 +259,14 @@ class CI_Security {
*/
$str = preg_replace_callback("/[a-z]+=([\'\"]).*?\\1/si", array($this, '_convert_attribute'), $str);
-
+
$str = preg_replace_callback("/<\w+.*?(?=>|<|$)/si", array($this, '_decode_entity'), $str);
/*
* Remove Invisible Characters Again!
*/
$str = remove_invisible_characters($str);
-
+
/*
* Convert all tabs to spaces
*
@@ -276,29 +276,29 @@ class CI_Security {
* so we use str_replace.
*
*/
-
+
if (strpos($str, "\t") !== FALSE)
{
$str = str_replace("\t", ' ', $str);
}
-
+
/*
* Capture converted string for later comparison
*/
$converted_string = $str;
-
+
/*
* Not Allowed Under Any Conditions
*/
-
+
foreach ($this->never_allowed_str as $key => $val)
{
- $str = str_replace($key, $val, $str);
+ $str = str_replace($key, $val, $str);
}
-
+
foreach ($this->never_allowed_regex as $key => $val)
{
- $str = preg_replace("#".$key."#i", $val, $str);
+ $str = preg_replace("#".$key."#i", $val, $str);
}
/*
@@ -321,7 +321,7 @@ class CI_Security {
{
$str = str_replace(array('<?', '?'.'>'), array('&lt;?', '?&gt;'), $str);
}
-
+
/*
* Compact any exploded words
*
@@ -333,7 +333,7 @@ class CI_Security {
foreach ($words as $word)
{
$temp = '';
-
+
for ($i = 0, $wordlen = strlen($word); $i < $wordlen; $i++)
{
$temp .= substr($word, $i, 1)."\s*";
@@ -343,7 +343,7 @@ class CI_Security {
// That way valid stuff like "dealer to" does not become "dealerto"
$str = preg_replace_callback('#('.substr($temp, 0, -3).')(\W)#is', array($this, '_compact_exploded_words'), $str);
}
-
+
/*
* Remove disallowed Javascript in links or img tags
* We used to do some version comparisons and use of stripos for PHP5, but it is dog slow compared
@@ -352,17 +352,17 @@ class CI_Security {
do
{
$original = $str;
-
+
if (preg_match("/<a/i", $str))
{
$str = preg_replace_callback("#<a\s+([^>]*?)(>|$)#si", array($this, '_js_link_removal'), $str);
}
-
+
if (preg_match("/<img/i", $str))
{
$str = preg_replace_callback("#<img\s+([^>]*?)(\s?/?>|$)#si", array($this, '_js_img_removal'), $str);
}
-
+
if (preg_match("/script/i", $str) OR preg_match("/xss/i", $str))
{
$str = preg_replace("#<(/*)(script|xss)(.*?)\>#si", '[removed]', $str);
@@ -385,14 +385,14 @@ class CI_Security {
if ($is_image === TRUE)
{
/*
- * Adobe Photoshop puts XML metadata into JFIF images, including namespacing,
+ * Adobe Photoshop puts XML metadata into JFIF images, including namespacing,
* so we have to allow this for images. -Paul
*/
unset($event_handlers[array_search('xmlns', $event_handlers)]);
}
$str = preg_replace("#<([^><]+?)(".implode('|', $event_handlers).")(\s*=\s*[^><]*)([><]*)#i", "<\\1\\4", $str);
-
+
/*
* Sanitize naughty HTML elements
*
@@ -420,7 +420,7 @@ class CI_Security {
*
*/
$str = preg_replace('#(alert|cmd|passthru|eval|exec|expression|system|fopen|fsockopen|file|file_get_contents|readfile|unlink)(\s*)\((.*?)\)#si', "\\1\\2&#40;\\3&#41;", $str);
-
+
/*
* Final clean up
*
@@ -430,9 +430,9 @@ class CI_Security {
*/
foreach ($this->never_allowed_str as $key => $val)
{
- $str = str_replace($key, $val, $str);
+ $str = str_replace($key, $val, $str);
}
-
+
foreach ($this->never_allowed_regex as $key => $val)
{
$str = preg_replace("#".$key."#i", $val, $str);
@@ -457,13 +457,13 @@ class CI_Security {
return FALSE;
}
}
-
+
log_message('debug', "XSS Filtering completed");
return $str;
}
// --------------------------------------------------------------------
-
+
/**
* Random Hash for protecting URLs
*
@@ -471,22 +471,22 @@ class CI_Security {
* @return string
*/
function xss_hash()
- {
+ {
if ($this->xss_hash == '')
{
if (phpversion() >= 4.2)
mt_srand();
else
mt_srand(hexdec(substr(md5(microtime()), -8)) & 0x7fffffff);
-
+
$this->xss_hash = md5(time() + mt_rand(0, 1999999999));
}
-
+
return $this->xss_hash;
}
// --------------------------------------------------------------------
-
+
/**
* Compact Exploded Words
*
@@ -501,9 +501,9 @@ class CI_Security {
{
return preg_replace('/\s+/s', '', $matches[1]).$matches[2];
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Sanitize Naughty HTML
*
@@ -517,15 +517,15 @@ class CI_Security {
{
// encode opening brace
$str = '&lt;'.$matches[1].$matches[2].$matches[3];
-
+
// encode captured opening or closing brace to prevent recursive vectors
$str .= str_replace(array('>', '<'), array('&gt;', '&lt;'), $matches[4]);
-
+
return $str;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* JS Link Removal
*
@@ -543,7 +543,7 @@ class CI_Security {
$attributes = $this->_filter_attributes(str_replace(array('<', '>'), '', $match[1]));
return str_replace($match[1], preg_replace("#href=.*?(alert\(|alert&\#40;|javascript\:|charset\=|window\.|document\.|\.cookie|<script|<xss|base64\s*,)#si", "", $attributes), $match[0]);
}
-
+
/**
* JS Image Removal
*
@@ -563,7 +563,7 @@ class CI_Security {
}
// --------------------------------------------------------------------
-
+
/**
* Attribute Conversion
*
@@ -577,7 +577,7 @@ class CI_Security {
{
return str_replace(array('>', '<', '\\'), array('&gt;', '&lt;', '\\\\'), $match[0]);
}
-
+
// --------------------------------------------------------------------
/**
@@ -644,35 +644,35 @@ class CI_Security {
function entity_decode($str, $charset='UTF-8')
{
if (stristr($str, '&') === FALSE) return $str;
-
+
// The reason we are not using html_entity_decode() by itself is because
// while it is not technically correct to leave out the semicolon
// at the end of an entity most browsers will still interpret the entity
// correctly. html_entity_decode() does not convert entities without
// semicolons, so we are left with our own little solution here. Bummer.
-
+
if (function_exists('html_entity_decode') && (strtolower($charset) != 'utf-8' OR is_php('5.0.0')))
{
$str = html_entity_decode($str, ENT_COMPAT, $charset);
$str = preg_replace('~&#x(0*[0-9a-f]{2,5})~ei', 'chr(hexdec("\\1"))', $str);
return preg_replace('~&#([0-9]{2,4})~e', 'chr(\\1)', $str);
}
-
+
// Numeric Entities
$str = preg_replace('~&#x(0*[0-9a-f]{2,5});{0,1}~ei', 'chr(hexdec("\\1"))', $str);
$str = preg_replace('~&#([0-9]{2,4});{0,1}~e', 'chr(\\1)', $str);
-
+
// Literal Entities - Slightly slow so we do another check
if (stristr($str, '&') === FALSE)
{
$str = strtr($str, array_flip(get_html_translation_table(HTML_ENTITIES)));
}
-
+
return $str;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Filename Security
*
@@ -680,11 +680,10 @@ class CI_Security {
* @param string
* @return string
*/
- function sanitize_filename($str)
+ function sanitize_filename($str, $relative_path = FALSE)
{
$bad = array(
"../",
- "./",
"<!--",
"-->",
"<",
@@ -701,22 +700,27 @@ class CI_Security {
'=',
';',
'?',
- '/',
"%20",
"%22",
"%3c", // <
- "%253c", // <
- "%3e", // >
- "%0e", // >
- "%28", // (
- "%29", // )
- "%2528", // (
- "%26", // &
- "%24", // $
- "%3f", // ?
- "%3b", // ;
+ "%253c", // <
+ "%3e", // >
+ "%0e", // >
+ "%28", // (
+ "%29", // )
+ "%2528", // (
+ "%26", // &
+ "%24", // $
+ "%3f", // ?
+ "%3b", // ;
"%3d" // =
);
+
+ if ( ! $relative_path)
+ {
+ $bad[] = './';
+ $bad[] = '/';
+ }
return stripslashes(str_replace($bad, '', $str));
}
diff --git a/system/libraries/Session.php b/system/libraries/Session.php
index fc3ee0542..1e606de9c 100644
--- a/system/libraries/Session.php
+++ b/system/libraries/Session.php
@@ -39,7 +39,7 @@ class CI_Session {
var $cookie_domain = '';
var $sess_time_to_update = 300;
var $encryption_key = '';
- var $flashdata_key = 'flash';
+ var $flashdata_key = 'flash';
var $time_reference = 'time';
var $gc_probability = 5;
var $userdata = array();
@@ -61,7 +61,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_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', 'sess_time_to_update', 'time_reference', 'cookie_prefix', 'encryption_key') as $key)
{
$this->$key = (isset($params[$key])) ? $params[$key] : $this->CI->config->item($key);
}
@@ -96,7 +96,7 @@ class CI_Session {
{
$this->sess_expiration = (60*60*24*365*2);
}
-
+
// Set the cookie name
$this->sess_cookie_name = $this->cookie_prefix.$this->sess_cookie_name;
@@ -112,10 +112,10 @@ class CI_Session {
}
// Delete 'old' flashdata (from last request)
- $this->_flashdata_sweep();
+ $this->_flashdata_sweep();
// Mark all new flashdata as old (data will be deleted before next request)
- $this->_flashdata_mark();
+ $this->_flashdata_mark();
// Delete expired sessions if necessary
$this->_sess_gc();
@@ -313,9 +313,9 @@ class CI_Session {
$sessid .= $this->CI->input->ip_address();
$this->userdata = array(
- 'session_id' => md5(uniqid($sessid, TRUE)),
- 'ip_address' => $this->CI->input->ip_address(),
- 'user_agent' => substr($this->CI->input->user_agent(), 0, 50),
+ 'session_id' => md5(uniqid($sessid, TRUE)),
+ 'ip_address' => $this->CI->input->ip_address(),
+ 'user_agent' => substr($this->CI->input->user_agent(), 0, 50),
'last_activity' => $this->now
);
@@ -656,9 +656,9 @@ class CI_Session {
// if encryption is not used, we provide an md5 hash to prevent userside tampering
$cookie_data = $cookie_data.md5($cookie_data.$this->encryption_key);
}
-
+
$expire = ($this->sess_expire_on_close === TRUE) ? 0 : $this->sess_expiration + time();
-
+
// Set the cookie
setcookie(
$this->sess_cookie_name,
@@ -690,7 +690,7 @@ class CI_Session {
{
if (is_string($val))
{
- $data[$key] = str_replace('\\', '{{slash}}', $val);
+ $data[$key] = str_replace('\\', '{{slash}}', $val);
}
}
}
@@ -698,7 +698,7 @@ class CI_Session {
{
if (is_string($data))
{
- $data = str_replace('\\', '{{slash}}', $data);
+ $data = str_replace('\\', '{{slash}}', $data);
}
}
@@ -727,7 +727,7 @@ class CI_Session {
{
if (is_string($val))
{
- $data[$key] = str_replace('{{slash}}', '\\', $val);
+ $data[$key] = str_replace('{{slash}}', '\\', $val);
}
}
diff --git a/system/libraries/Sha1.php b/system/libraries/Sha1.php
index f9611a8a5..ff7e72033 100644
--- a/system/libraries/Sha1.php
+++ b/system/libraries/Sha1.php
@@ -55,7 +55,7 @@ class CI_SHA {
* @access public
* @param string
* @return string
- */
+ */
function generate($str)
{
$n = ((strlen($str) + 8) >> 6) + 1;
@@ -117,7 +117,7 @@ class CI_SHA {
return $this->_hex($a).$this->_hex($b).$this->_hex($c).$this->_hex($d).$this->_hex($e);
}
-
+
// --------------------------------------------------------------------
/**
@@ -126,7 +126,7 @@ class CI_SHA {
* @access private
* @param string
* @return string
- */
+ */
function _hex($str)
{
$str = dechex($str);
@@ -138,7 +138,7 @@ class CI_SHA {
return $str;
}
-
+
// --------------------------------------------------------------------
/**
@@ -146,7 +146,7 @@ class CI_SHA {
*
* @access private
* @return string
- */
+ */
function _ft($t, $b, $c, $d)
{
if ($t < 20)
@@ -166,7 +166,7 @@ class CI_SHA {
*
* @access private
* @return string
- */
+ */
function _kt($t)
{
if ($t < 20)
@@ -186,7 +186,7 @@ class CI_SHA {
return -899497514;
}
}
-
+
// --------------------------------------------------------------------
/**
@@ -194,7 +194,7 @@ class CI_SHA {
*
* @access private
* @return string
- */
+ */
function _safe_add($x, $y)
{
$lsw = ($x & 0xFFFF) + ($y & 0xFFFF);
@@ -202,7 +202,7 @@ class CI_SHA {
return ($msw << 16) | ($lsw & 0xFFFF);
}
-
+
// --------------------------------------------------------------------
/**
@@ -210,7 +210,7 @@ class CI_SHA {
*
* @access private
* @return integer
- */
+ */
function _rol($num, $cnt)
{
return ($num << $cnt) | $this->_zero_fill($num, 32 - $cnt);
@@ -223,7 +223,7 @@ class CI_SHA {
*
* @access private
* @return string
- */
+ */
function _zero_fill($a, $b)
{
$bin = decbin($a);
diff --git a/system/libraries/Table.php b/system/libraries/Table.php
index 1f920ea9e..2fc1b634d 100644
--- a/system/libraries/Table.php
+++ b/system/libraries/Table.php
@@ -30,13 +30,13 @@ class CI_Table {
var $rows = array();
var $heading = array();
- var $auto_heading = TRUE;
- var $caption = NULL;
- var $template = NULL;
+ var $auto_heading = TRUE;
+ var $caption = NULL;
+ var $template = NULL;
var $newline = "\n";
var $empty_cells = "";
var $function = FALSE;
-
+
function CI_Table()
{
log_message('debug', "Table Class Initialized");
@@ -57,7 +57,7 @@ class CI_Table {
{
return FALSE;
}
-
+
$this->template = $template;
}
@@ -97,21 +97,21 @@ class CI_Table {
{
return FALSE;
}
-
- // Turn off the auto-heading feature since it's doubtful we
+
+ // Turn off the auto-heading feature since it's doubtful we
// will want headings from a one-dimensional array
$this->auto_heading = FALSE;
-
+
if ($col_limit == 0)
{
return $array;
}
-
+
$new = array();
while(count($array) > 0)
- {
- $temp = array_splice($array, 0, $col_limit);
-
+ {
+ $temp = array_splice($array, 0, $col_limit);
+
if (count($temp) < $col_limit)
{
for ($i = count($temp); $i < $col_limit; $i++)
@@ -119,10 +119,10 @@ class CI_Table {
$temp[] = '&nbsp;';
}
}
-
+
$new[] = $temp;
}
-
+
return $new;
}
@@ -141,7 +141,7 @@ class CI_Table {
{
$this->empty_cells = $value;
}
-
+
// --------------------------------------------------------------------
/**
@@ -160,7 +160,7 @@ class CI_Table {
}
// --------------------------------------------------------------------
-
+
/**
* Prep Args
*
@@ -188,9 +188,9 @@ class CI_Table {
}
else
{
- $args[$key] = array('data' => $val);
+ $args[$key] = array('data' => $val);
}
- }
+ }
}
}
else
@@ -203,12 +203,12 @@ class CI_Table {
}
}
}
-
+
return $args;
}
// --------------------------------------------------------------------
-
+
/**
* Add a table caption
*
@@ -219,7 +219,7 @@ class CI_Table {
function set_caption($caption)
{
$this->caption = $caption;
- }
+ }
// --------------------------------------------------------------------
@@ -246,23 +246,23 @@ class CI_Table {
$this->_set_from_array($table_data, $set_heading);
}
}
-
+
// Is there anything to display? No? Smite them!
if (count($this->heading) == 0 AND count($this->rows) == 0)
{
return 'Undefined table data';
}
-
+
// Compile and validate the template date
$this->_compile_template();
-
+
// set a custom cell manipulation function to a locally scoped variable so its callable
$function = $this->function;
-
+
// Build the table!
-
+
$out = $this->template['table_open'];
- $out .= $this->newline;
+ $out .= $this->newline;
// Add any caption here
if ($this->caption)
@@ -283,16 +283,16 @@ class CI_Table {
foreach($this->heading as $heading)
{
$temp = $this->template['heading_cell_start'];
-
+
foreach ($heading as $key => $val)
{
if ($key != 'data')
{
$temp = str_replace('<th', "<th $key='$val'", $temp);
- }
+ }
}
- $out .= $temp;
+ $out .= $temp;
$out .= isset($heading['data']) ? $heading['data'] : '';
$out .= $this->template['heading_cell_end'];
}
@@ -302,13 +302,13 @@ class CI_Table {
$out .= $this->template['thead_close'];
$out .= $this->newline;
}
-
+
// Build the table rows
if (count($this->rows) > 0)
{
$out .= $this->template['tbody_open'];
$out .= $this->newline;
-
+
$i = 1;
foreach($this->rows as $row)
{
@@ -316,25 +316,25 @@ class CI_Table {
{
break;
}
-
+
// We use modulus to alternate the row colors
$name = (fmod($i++, 2)) ? '' : 'alt_';
-
+
$out .= $this->template['row_'.$name.'start'];
- $out .= $this->newline;
-
+ $out .= $this->newline;
+
foreach($row as $cell)
{
$temp = $this->template['cell_'.$name.'start'];
-
+
foreach ($cell as $key => $val)
{
if ($key != 'data')
{
$temp = str_replace('<td', "<td $key='$val'", $temp);
- }
+ }
}
-
+
$cell = isset($cell['data']) ? $cell['data'] : '';
$out .= $temp;
@@ -353,23 +353,23 @@ class CI_Table {
$out .= $cell;
}
}
-
+
$out .= $this->template['cell_'.$name.'end'];
}
-
+
$out .= $this->template['row_'.$name.'end'];
- $out .= $this->newline;
+ $out .= $this->newline;
}
-
+
$out .= $this->template['tbody_close'];
$out .= $this->newline;
}
$out .= $this->template['table_close'];
-
+
return $out;
}
-
+
// --------------------------------------------------------------------
/**
@@ -382,9 +382,9 @@ class CI_Table {
{
$this->rows = array();
$this->heading = array();
- $this->auto_heading = TRUE;
+ $this->auto_heading = TRUE;
}
-
+
// --------------------------------------------------------------------
/**
@@ -400,7 +400,7 @@ class CI_Table {
{
return FALSE;
}
-
+
// First generate the headings from the table column names
if (count($this->heading) == 0)
{
@@ -408,12 +408,12 @@ class CI_Table {
{
return FALSE;
}
-
+
$this->heading = $this->_prep_args($query->list_fields());
}
-
+
// Next blast through the result array and build out the rows
-
+
if ($query->num_rows() > 0)
{
foreach ($query->result_array() as $row)
@@ -438,10 +438,10 @@ class CI_Table {
{
return FALSE;
}
-
+
$i = 0;
foreach ($data as $row)
- {
+ {
// If a heading hasn't already been set we'll use the first row of the array as the heading
if ($i == 0 AND count($data) > 1 AND count($this->heading) == 0 AND $set_heading == TRUE)
{
@@ -451,7 +451,7 @@ class CI_Table {
{
$this->rows[] = $this->_prep_args($row);
}
-
+
$i++;
}
}
@@ -464,14 +464,14 @@ class CI_Table {
* @access private
* @return void
*/
- function _compile_template()
- {
- if ($this->template == NULL)
- {
- $this->template = $this->_default_template();
- return;
- }
-
+ function _compile_template()
+ {
+ if ($this->template == NULL)
+ {
+ $this->template = $this->_default_template();
+ return;
+ }
+
$this->temp = $this->_default_template();
foreach (array('table_open', 'thead_open', 'thead_close', 'heading_row_start', 'heading_row_end', 'heading_cell_start', 'heading_cell_end', 'tbody_open', 'tbody_close', 'row_start', 'row_end', 'cell_start', 'cell_end', 'row_alt_start', 'row_alt_end', 'cell_alt_start', 'cell_alt_end', 'table_close') as $val)
{
@@ -479,9 +479,9 @@ class CI_Table {
{
$this->template[$val] = $this->temp[$val];
}
- }
- }
-
+ }
+ }
+
// --------------------------------------------------------------------
/**
@@ -493,33 +493,33 @@ class CI_Table {
function _default_template()
{
return array (
- 'table_open' => '<table border="0" cellpadding="4" cellspacing="0">',
-
+ 'table_open' => '<table border="0" cellpadding="4" cellspacing="0">',
+
'thead_open' => '<thead>',
'thead_close' => '</thead>',
-
- 'heading_row_start' => '<tr>',
- 'heading_row_end' => '</tr>',
+
+ 'heading_row_start' => '<tr>',
+ 'heading_row_end' => '</tr>',
'heading_cell_start' => '<th>',
'heading_cell_end' => '</th>',
'tbody_open' => '<tbody>',
'tbody_close' => '</tbody>',
-
- 'row_start' => '<tr>',
- 'row_end' => '</tr>',
+
+ 'row_start' => '<tr>',
+ 'row_end' => '</tr>',
'cell_start' => '<td>',
'cell_end' => '</td>',
- 'row_alt_start' => '<tr>',
- 'row_alt_end' => '</tr>',
+ 'row_alt_start' => '<tr>',
+ 'row_alt_end' => '</tr>',
'cell_alt_start' => '<td>',
'cell_alt_end' => '</td>',
- 'table_close' => '</table>'
- );
+ 'table_close' => '</table>'
+ );
}
-
+
}
diff --git a/system/libraries/Trackback.php b/system/libraries/Trackback.php
index a27914487..a8be8a877 100644
--- a/system/libraries/Trackback.php
+++ b/system/libraries/Trackback.php
@@ -27,7 +27,7 @@
* @link http://codeigniter.com/user_guide/libraries/trackback.html
*/
class CI_Trackback {
-
+
var $time_format = 'local';
var $charset = 'UTF-8';
var $data = array('url' => '', 'title' => '', 'excerpt' => '', 'blog_name' => '', 'charset' => '');
@@ -44,24 +44,24 @@ class CI_Trackback {
{
log_message('debug', "Trackback Class Initialized");
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Send Trackback
*
* @access public
* @param array
* @return bool
- */
+ */
function send($tb_data)
- {
+ {
if ( ! is_array($tb_data))
{
$this->set_error('The send() method must be passed an array');
return FALSE;
}
-
+
// Pre-process the Trackback Data
foreach (array('url', 'title', 'excerpt', 'blog_name', 'ping_url') as $item)
{
@@ -70,14 +70,14 @@ class CI_Trackback {
$this->set_error('Required item missing: '.$item);
return FALSE;
}
-
+
switch ($item)
{
case 'ping_url' : $$item = $this->extract_urls($tb_data[$item]);
break;
case 'excerpt' : $$item = $this->limit_characters($this->convert_xml(strip_tags(stripslashes($tb_data[$item]))));
break;
- case 'url' : $$item = str_replace('&#45;', '-', $this->convert_xml(strip_tags(stripslashes($tb_data[$item]))));
+ case 'url' : $$item = str_replace('&#45;', '-', $this->convert_xml(strip_tags(stripslashes($tb_data[$item]))));
break;
default : $$item = $this->convert_xml(strip_tags(stripslashes($tb_data[$item])));
break;
@@ -103,9 +103,9 @@ class CI_Trackback {
// Build the Trackback data string
$charset = ( ! isset($tb_data['charset'])) ? $this->charset : $tb_data['charset'];
-
+
$data = "url=".rawurlencode($url)."&title=".rawurlencode($title)."&blog_name=".rawurlencode($blog_name)."&excerpt=".rawurlencode($excerpt)."&charset=".rawurlencode($charset);
-
+
// Send Trackback(s)
$return = TRUE;
if (count($ping_url) > 0)
@@ -116,14 +116,14 @@ class CI_Trackback {
{
$return = FALSE;
}
- }
+ }
}
return $return;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Receive Trackback Data
*
@@ -134,9 +134,9 @@ class CI_Trackback {
*
* @access public
* @return bool
- */
+ */
function receive()
- {
+ {
foreach (array('url', 'title', 'blog_name', 'excerpt') as $val)
{
if ( ! isset($_POST[$val]) OR $_POST[$val] == '')
@@ -144,29 +144,29 @@ class CI_Trackback {
$this->set_error('The following required POST variable is missing: '.$val);
return FALSE;
}
-
+
$this->data['charset'] = ( ! isset($_POST['charset'])) ? 'auto' : strtoupper(trim($_POST['charset']));
-
+
if ($val != 'url' && function_exists('mb_convert_encoding'))
{
$_POST[$val] = mb_convert_encoding($_POST[$val], $this->charset, $this->data['charset']);
}
-
+
$_POST[$val] = ($val != 'url') ? $this->convert_xml(strip_tags($_POST[$val])) : strip_tags($_POST[$val]);
-
+
if ($val == 'excerpt')
{
$_POST['excerpt'] = $this->limit_characters($_POST['excerpt']);
}
-
+
$this->data[$val] = $_POST[$val];
}
return TRUE;
- }
-
+ }
+
// --------------------------------------------------------------------
-
+
/**
* Send Trackback Error Message
*
@@ -177,15 +177,15 @@ class CI_Trackback {
* @access public
* @param string
* @return void
- */
+ */
function send_error($message = 'Incomplete Information')
{
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?".">\n<response>\n<error>1</error>\n<message>".$message."</message>\n</response>";
exit;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Send Trackback Success Message
*
@@ -194,29 +194,29 @@ class CI_Trackback {
*
* @access public
* @return void
- */
+ */
function send_success()
{
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?".">\n<response>\n<error>0</error>\n</response>";
exit;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Fetch a particular item
*
* @access public
* @param string
* @return string
- */
+ */
function data($item)
{
return ( ! isset($this->data[$item])) ? '' : $this->data[$item];
}
// --------------------------------------------------------------------
-
+
/**
* Process Trackback
*
@@ -227,11 +227,11 @@ class CI_Trackback {
* @param string
* @param string
* @return bool
- */
+ */
function process($url, $data)
{
$target = parse_url($url);
-
+
// Open the socket
if ( ! $fp = @fsockopen($target['host'], 80))
{
@@ -241,7 +241,7 @@ class CI_Trackback {
// Build the path
$ppath = ( ! isset($target['path'])) ? $url : $target['path'];
-
+
$path = (isset($target['query']) && $target['query'] != "") ? $ppath.'?'.$target['query'] : $ppath;
// Add the Trackback ID to the data string
@@ -260,32 +260,32 @@ class CI_Trackback {
// Was it successful?
$this->response = "";
-
+
while( ! feof($fp))
{
$this->response .= fgets($fp, 128);
}
@fclose($fp);
-
-
+
+
if (stristr($this->response, '<error>0</error>') === FALSE)
{
$message = 'An unknown error was encountered';
-
+
if (preg_match("/<message>(.*?)<\/message>/is", $this->response, $match))
{
$message = trim($match['1']);
}
-
+
$this->set_error($message);
return FALSE;
}
return TRUE;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Extract Trackback URLs
*
@@ -296,34 +296,34 @@ class CI_Trackback {
* @access public
* @param string
* @return string
- */
+ */
function extract_urls($urls)
- {
+ {
// Remove the pesky white space and replace with a comma.
$urls = preg_replace("/\s*(\S+)\s*/", "\\1,", $urls);
-
+
// If they use commas get rid of the doubles.
$urls = str_replace(",,", ",", $urls);
-
+
// Remove any comma that might be at the end
if (substr($urls, -1) == ",")
{
$urls = substr($urls, 0, -1);
}
-
+
// Break into an array via commas
$urls = preg_split('/[,]/', $urls);
-
+
// Removes duplicates
$urls = array_unique($urls);
-
+
array_walk($urls, array($this, 'validate_url'));
-
+
return $urls;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Validate URL
*
@@ -332,7 +332,7 @@ class CI_Trackback {
* @access public
* @param string
* @return string
- */
+ */
function validate_url($url)
{
$url = trim($url);
@@ -342,46 +342,46 @@ class CI_Trackback {
$url = "http://".$url;
}
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Find the Trackback URL's ID
*
* @access public
* @param string
* @return string
- */
+ */
function get_id($url)
- {
+ {
$tb_id = "";
-
+
if (strpos($url, '?') !== FALSE)
{
$tb_array = explode('/', $url);
$tb_end = $tb_array[count($tb_array)-1];
-
+
if ( ! is_numeric($tb_end))
{
$tb_end = $tb_array[count($tb_array)-2];
}
-
+
$tb_array = explode('=', $tb_end);
$tb_id = $tb_array[count($tb_array)-1];
}
else
{
$url = rtrim($url, '/');
-
+
$tb_array = explode('/', $url);
$tb_id = $tb_array[count($tb_array)-1];
-
+
if ( ! is_numeric($tb_id))
{
$tb_id = $tb_array[count($tb_array)-2];
}
- }
-
+ }
+
if ( ! preg_match ("/^([0-9]+)$/", $tb_id))
{
return FALSE;
@@ -389,11 +389,11 @@ class CI_Trackback {
else
{
return $tb_id;
- }
+ }
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Convert Reserved XML characters to Entities
*
@@ -404,22 +404,22 @@ class CI_Trackback {
function convert_xml($str)
{
$temp = '__TEMP_AMPERSANDS__';
-
+
$str = preg_replace("/&#(\d+);/", "$temp\\1;", $str);
$str = preg_replace("/&(\w+);/", "$temp\\1;", $str);
-
+
$str = str_replace(array("&","<",">","\"", "'", "-"),
- array("&amp;", "&lt;", "&gt;", "&quot;", "&#39;", "&#45;"),
- $str);
-
+ array("&amp;", "&lt;", "&gt;", "&quot;", "&#39;", "&#45;"),
+ $str);
+
$str = preg_replace("/$temp(\d+);/","&#\\1;",$str);
$str = preg_replace("/$temp(\w+);/","&\\1;", $str);
-
+
return $str;
- }
-
+ }
+
// --------------------------------------------------------------------
-
+
/**
* Character limiter
*
@@ -437,27 +437,27 @@ class CI_Trackback {
{
return $str;
}
-
+
$str = preg_replace("/\s+/", ' ', str_replace(array("\r\n", "\r", "\n"), ' ', $str));
-
+
if (strlen($str) <= $n)
{
return $str;
}
-
+
$out = "";
foreach (explode(' ', trim($str)) as $val)
{
- $out .= $val.' ';
+ $out .= $val.' ';
if (strlen($out) >= $n)
{
return trim($out).$end_char;
- }
+ }
}
}
-
+
// --------------------------------------------------------------------
-
+
/**
* High ASCII to Entities
*
@@ -470,58 +470,58 @@ class CI_Trackback {
*/
function convert_ascii($str)
{
- $count = 1;
- $out = '';
- $temp = array();
-
- for ($i = 0, $s = strlen($str); $i < $s; $i++)
- {
- $ordinal = ord($str[$i]);
-
- if ($ordinal < 128)
- {
- $out .= $str[$i];
- }
- else
- {
- if (count($temp) == 0)
- {
- $count = ($ordinal < 224) ? 2 : 3;
- }
-
- $temp[] = $ordinal;
-
- if (count($temp) == $count)
- {
- $number = ($count == 3) ? (($temp['0'] % 16) * 4096) + (($temp['1'] % 64) * 64) + ($temp['2'] % 64) : (($temp['0'] % 32) * 64) + ($temp['1'] % 64);
-
- $out .= '&#'.$number.';';
- $count = 1;
- $temp = array();
- }
- }
- }
-
- return $out;
+ $count = 1;
+ $out = '';
+ $temp = array();
+
+ for ($i = 0, $s = strlen($str); $i < $s; $i++)
+ {
+ $ordinal = ord($str[$i]);
+
+ if ($ordinal < 128)
+ {
+ $out .= $str[$i];
+ }
+ else
+ {
+ if (count($temp) == 0)
+ {
+ $count = ($ordinal < 224) ? 2 : 3;
+ }
+
+ $temp[] = $ordinal;
+
+ if (count($temp) == $count)
+ {
+ $number = ($count == 3) ? (($temp['0'] % 16) * 4096) + (($temp['1'] % 64) * 64) + ($temp['2'] % 64) : (($temp['0'] % 32) * 64) + ($temp['1'] % 64);
+
+ $out .= '&#'.$number.';';
+ $count = 1;
+ $temp = array();
+ }
+ }
+ }
+
+ return $out;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Set error message
*
* @access public
* @param string
* @return void
- */
+ */
function set_error($msg)
{
log_message('error', $msg);
$this->error_msg[] = $msg;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Show error messages
*
@@ -529,15 +529,15 @@ class CI_Trackback {
* @param string
* @param string
* @return string
- */
+ */
function display_errors($open = '<p>', $close = '</p>')
- {
+ {
$str = '';
foreach ($this->error_msg as $val)
{
$str .= $open.$val.$close;
}
-
+
return $str;
}
diff --git a/system/libraries/Typography.php b/system/libraries/Typography.php
index 0f0a8b7a2..d8b295e7b 100644
--- a/system/libraries/Typography.php
+++ b/system/libraries/Typography.php
@@ -28,22 +28,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';
-
+
// Elements that should not have <p> and <br /> tags within them.
var $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';
-
+
// array of block level elements that require inner content to be within another block level element
var $inner_block_required = array('blockquote');
-
+
// the last block element parsed
var $last_block_element = '';
-
+
// whether or not to protect quotes within { curly braces }
var $protect_braced_quotes = FALSE;
-
+
/**
* Nothing to do here...
*
@@ -56,11 +56,11 @@ class CI_Typography {
* Auto Typography
*
* This function converts text, making it typographically correct:
- * - Converts double spaces into paragraphs.
- * - Converts single line breaks into <br /> tags
- * - Converts single and double quotes into correctly facing curly quote entities.
- * - Converts three dots into ellipsis.
- * - Converts double dashes into em-dashes.
+ * - Converts double spaces into paragraphs.
+ * - Converts single line breaks into <br /> tags
+ * - Converts single and double quotes into correctly facing curly quote entities.
+ * - Converts three dots into ellipsis.
+ * - Converts double dashes into em-dashes.
* - Converts two spaces into entities
*
* @access public
@@ -78,15 +78,15 @@ class CI_Typography {
// Standardize Newlines to make matching easier
if (strpos($str, "\r") !== FALSE)
{
- $str = str_replace(array("\r\n", "\r"), "\n", $str);
+ $str = str_replace(array("\r\n", "\r"), "\n", $str);
}
-
+
// Reduce line breaks. If there are more than two consecutive linebreaks
// we'll compress them down to a maximum of two since there's no benefit to more.
if ($reduce_linebreaks === TRUE)
{
$str = preg_replace("/\n\n+/", "\n\n", $str);
- }
+ }
// HTML comment tags don't conform to patterns of normal tags, so pull them out separately, only if needed
$html_comments = array();
@@ -101,50 +101,50 @@ class CI_Typography {
}
}
}
-
+
// match and yank <pre> tags if they exist. It's cheaper to do this separately since most content will
// not contain <pre> tags, and it keeps the PCRE patterns below simpler and faster
if (strpos($str, '<pre') !== FALSE)
{
$str = preg_replace_callback("#<pre.*?>.*?</pre>#si", array($this, '_protect_characters'), $str);
}
-
+
// Convert quotes within tags to temporary markers.
$str = preg_replace_callback("#<.+?>#si", array($this, '_protect_characters'), $str);
// Do the same with braces if necessary
if ($this->protect_braced_quotes === TRUE)
{
- $str = preg_replace_callback("#\{.+?\}#si", array($this, '_protect_characters'), $str);
+ $str = preg_replace_callback("#\{.+?\}#si", array($this, '_protect_characters'), $str);
}
-
- // Convert "ignore" tags to temporary marker. The parser splits out the string at every tag
- // it encounters. Certain inline tags, like image tags, links, span tags, etc. will be
+
+ // Convert "ignore" tags to temporary marker. The parser splits out the string at every tag
+ // it encounters. Certain inline tags, like image tags, links, span tags, etc. will be
// 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...
- // }
+ //
+ // [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
+
+ // 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)
- {
+ {
$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))
@@ -153,7 +153,7 @@ class CI_Typography {
{
$process = ($match[1] == '/') ? TRUE : FALSE;
}
-
+
if ($match[1] == '')
{
$this->last_block_element = $match[2];
@@ -162,32 +162,32 @@ class CI_Typography {
$str .= $chunk;
continue;
}
-
+
if ($process == FALSE)
{
$str .= $chunk;
continue;
}
-
+
// Force a newline to make sure end tags get processed by _format_newlines()
if ($current_chunk == $total_chunks)
{
- $chunk .= "\n";
+ $chunk .= "\n";
}
-
+
// Convert Newlines into <p> and <br /> tags
$str .= $this->_format_newlines($chunk);
}
-
+
// No opening block level tag? Add it if needed.
if ( ! preg_match("/^\s*<(?:".$this->block_elements.")/i", $str))
{
$str = preg_replace("/^(.*?)<(".$this->block_elements.")/i", '<p>$1</p><$2', $str);
}
-
+
// Convert quotes, elipsis, em-dashes, non-breaking spaces, and ampersands
$str = $this->format_characters($str);
-
+
// restore HTML comments
for ($i = 0, $total = count($html_comments); $i < $total; $i++)
{
@@ -196,18 +196,18 @@ class CI_Typography {
// if '<p>{@HC1}' then replace <p>{@HC1}</p> with the comment, else replace only {@HC1} with the comment
$str = preg_replace('#(?(?=<p>\{@HC'.$i.'\})<p>\{@HC'.$i.'\}(\s*</p>)|\{@HC'.$i.'\})#s', $html_comments[$i], $str);
}
-
+
// Final clean up
$table = array(
-
+
// If the user submitted their own paragraph tags within the text
// we will retain them instead of using our tags.
- '/(<p[^>*?]>)<p>/' => '$1', // <?php BBEdit syntax coloring bug fix
-
+ '/(<p[^>*?]>)<p>/' => '$1', // <?php BBEdit syntax coloring bug fix
+
// Reduce multiple instances of opening/closing paragraph tags to a single one
'#(</p>)+#' => '</p>',
'/(<p>\W*<p>)+/' => '<p>',
-
+
// Clean up stray paragraph tags that appear before block level elements
'#<p></p><('.$this->block_elements.')#' => '<$1',
@@ -219,10 +219,19 @@ class CI_Typography {
'/\{@DQ\}/' => '"',
'/\{@SQ\}/' => "'",
'/\{@DD\}/' => '--',
- '/\{@NBS\}/' => ' '
+ '/\{@NBS\}/' => ' ',
+
+ // An unintended consequence of the _format_newlines function is that
+ // some of the newlines get truncated, resulting in <p> tags
+ // starting immediately after <block> tags on the same line.
+ // This forces a newline after such occurrences, which looks much nicer.
+ "/><p>\n/" => ">\n<p>",
+ // Similarly, there might be cases where a closing </block> will follow
+ // a closing </p> tag, so we'll correct it by adding a newline in between
+ "#</p></#" => "</p>\n</"
);
-
+
// Do we need to reduce empty lines?
if ($reduce_linebreaks === TRUE)
{
@@ -234,13 +243,13 @@ class CI_Typography {
// otherwise most browsers won't treat them as true paragraphs
$table['#<p></p>#'] = '<p>&nbsp;</p>';
}
-
+
return preg_replace(array_keys($table), $table, $str);
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Format Characters
*
@@ -255,10 +264,10 @@ class CI_Typography {
function format_characters($str)
{
static $table;
-
+
if ( ! isset($table))
{
- $table = array(
+ $table = array(
// nested smart quotes, opening and closing
// note that rules for grammar (English) allow only for two levels deep
// and that single quotes are _supposed_ to always be on the outside
@@ -304,7 +313,7 @@ class CI_Typography {
return preg_replace(array_keys($table), $table, $str);
}
-
+
// --------------------------------------------------------------------
/**
@@ -315,47 +324,50 @@ class CI_Typography {
* @access public
* @param string
* @return string
- */
+ */
function _format_newlines($str)
{
if ($str == '')
{
return $str;
}
-
+
if (strpos($str, "\n") === FALSE && ! in_array($this->last_block_element, $this->inner_block_required))
{
return $str;
}
-
+
// Convert two consecutive newlines to paragraphs
$str = str_replace("\n\n", "</p>\n\n<p>", $str);
-
+
// Convert single spaces to <br /> tags
$str = preg_replace("/([^\n])(\n)([^\n])/", "\\1<br />\\2\\3", $str);
-
+
// Wrap the whole enchilada in enclosing paragraphs
if ($str != "\n")
{
- $str = '<p>'.$str.'</p>';
+ // We trim off the right-side new line so that the closing </p> tag
+ // will be positioned immediately following the string, matching
+ // the behavior of the opening <p> tag
+ $str = '<p>'.rtrim($str).'</p>';
}
// Remove empty paragraphs if they are on the first line, as this
// is a potential unintended consequence of the previous code
$str = preg_replace("/<p><\/p>(.*)/", "\\1", $str, 1);
-
+
return $str;
}
-
+
// ------------------------------------------------------------------------
-
+
/**
* Protect Characters
*
* Protects special characters from being formatted later
* We don't want quotes converted within tags so we'll temporarily convert them to {@DQ} and {@SQ}
- * 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
+ * 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
* @param array
@@ -367,19 +379,19 @@ class CI_Typography {
}
// --------------------------------------------------------------------
-
+
/**
* Convert newlines to HTML line breaks except within PRE tags
*
* @access public
* @param string
* @return string
- */
+ */
function nl2br_except_pre($str)
{
$ex = explode("pre>",$str);
$ct = count($ex);
-
+
$newstr = "";
for ($i = 0; $i < $ct; $i++)
{
@@ -391,14 +403,14 @@ class CI_Typography {
{
$newstr .= $ex[$i];
}
-
+
if ($ct - 1 != $i)
$newstr .= "pre>";
}
-
+
return $newstr;
}
-
+
}
// END Typography Class
diff --git a/system/libraries/Unit_test.php b/system/libraries/Unit_test.php
index c47143637..9a90cb47c 100644
--- a/system/libraries/Unit_test.php
+++ b/system/libraries/Unit_test.php
@@ -29,9 +29,9 @@
class CI_Unit_test {
var $active = TRUE;
- var $results = array();
+ var $results = array();
var $strict = FALSE;
- var $_template = NULL;
+ var $_template = NULL;
var $_template_rows = NULL;
var $_test_items_visible = array();
@@ -82,32 +82,32 @@ class CI_Unit_test {
* @param mixed
* @param string
* @return string
- */
+ */
function run($test, $expected = TRUE, $test_name = 'undefined', $notes = '')
{
if ($this->active == FALSE)
{
return FALSE;
}
-
+
if (in_array($expected, array('is_object', 'is_string', 'is_bool', 'is_true', 'is_false', 'is_int', 'is_numeric', 'is_float', 'is_double', 'is_array', 'is_null'), TRUE))
{
$expected = str_replace('is_float', 'is_double', $expected);
- $result = ($expected($test)) ? TRUE : FALSE;
+ $result = ($expected($test)) ? TRUE : FALSE;
$extype = str_replace(array('true', 'false'), 'bool', str_replace('is_', '', $expected));
}
else
{
if ($this->strict == TRUE)
- $result = ($test === $expected) ? TRUE : FALSE;
+ $result = ($test === $expected) ? TRUE : FALSE;
else
- $result = ($test == $expected) ? TRUE : FALSE;
-
+ $result = ($test == $expected) ? TRUE : FALSE;
+
$extype = gettype($expected);
}
-
+
$back = $this->_backtrace();
-
+
$report[] = array (
'test_name' => $test_name,
'test_datatype' => gettype($test),
@@ -124,7 +124,7 @@ class CI_Unit_test {
}
// --------------------------------------------------------------------
-
+
/**
* Generate a report
*
@@ -175,9 +175,9 @@ class CI_Unit_test {
return $r;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Use strict comparison
*
@@ -191,9 +191,9 @@ class CI_Unit_test {
{
$this->strict = ($state == FALSE) ? FALSE : TRUE;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Make Unit testing active
*
@@ -207,9 +207,9 @@ class CI_Unit_test {
{
$this->active = ($state == FALSE) ? FALSE : TRUE;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Result Array
*
@@ -219,15 +219,15 @@ class CI_Unit_test {
* @return array
*/
function result($results = array())
- {
+ {
$CI =& get_instance();
$CI->load->language('unit_test');
-
+
if (count($results) == 0)
{
$results = $this->results;
}
-
+
$retval = array();
foreach ($results as $result)
{
@@ -246,8 +246,8 @@ class CI_Unit_test {
if (FALSE !== ($line = $CI->lang->line(strtolower('ut_'.$v))))
{
$v = $line;
- }
- $temp[$CI->lang->line('ut_'.$k)] = $v;
+ }
+ $temp[$CI->lang->line('ut_'.$k)] = $v;
}
}
else
@@ -255,19 +255,19 @@ class CI_Unit_test {
if (FALSE !== ($line = $CI->lang->line(strtolower('ut_'.$val))))
{
$val = $line;
- }
+ }
$temp[$CI->lang->line('ut_'.$key)] = $val;
}
}
-
+
$retval[] = $temp;
}
-
+
return $retval;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Set the template
*
@@ -276,14 +276,14 @@ class CI_Unit_test {
* @access public
* @param string
* @return void
- */
+ */
function set_template($template)
{
$this->_template = $template;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Generate a backtrace
*
@@ -297,17 +297,17 @@ class CI_Unit_test {
if (function_exists('debug_backtrace'))
{
$back = debug_backtrace();
-
+
$file = ( ! isset($back['1']['file'])) ? '' : $back['1']['file'];
$line = ( ! isset($back['1']['line'])) ? '' : $back['1']['line'];
-
+
return array('file' => $file, 'line' => $line);
}
return array('file' => 'Unknown', 'line' => 'Unknown');
}
// --------------------------------------------------------------------
-
+
/**
* Get Default Template
*
@@ -315,17 +315,17 @@ class CI_Unit_test {
* @return string
*/
function _default_template()
- {
+ {
$this->_template = "\n".'<table style="width:100%; font-size:small; margin:10px 0; border-collapse:collapse; border:1px solid #CCC;">';
$this->_template .= '{rows}';
$this->_template .= "\n".'</table>';
-
+
$this->_template_rows = "\n\t".'<tr>';
$this->_template_rows .= "\n\t\t".'<th style="text-align: left; border-bottom:1px solid #CCC;">{item}</th>';
$this->_template_rows .= "\n\t\t".'<td style="border-bottom:1px solid #CCC;">{result}</td>';
- $this->_template_rows .= "\n\t".'</tr>';
+ $this->_template_rows .= "\n\t".'</tr>';
}
-
+
// --------------------------------------------------------------------
/**
@@ -336,29 +336,29 @@ class CI_Unit_test {
* @access private
* @return void
*/
- function _parse_template()
- {
- if ( ! is_null($this->_template_rows))
- {
- return;
- }
-
- if (is_null($this->_template))
- {
- $this->_default_template();
- return;
- }
-
+ function _parse_template()
+ {
+ if ( ! is_null($this->_template_rows))
+ {
+ return;
+ }
+
+ if (is_null($this->_template))
+ {
+ $this->_default_template();
+ return;
+ }
+
if ( ! preg_match("/\{rows\}(.*?)\{\/rows\}/si", $this->_template, $match))
{
- $this->_default_template();
- return;
+ $this->_default_template();
+ return;
}
$this->_template_rows = $match['1'];
- $this->_template = str_replace($match['0'], '{rows}', $this->_template);
- }
-
+ $this->_template = str_replace($match['0'], '{rows}', $this->_template);
+ }
+
}
// END Unit_test Class
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index c18c178df..c83d0aeaa 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -25,7 +25,7 @@
* @link http://codeigniter.com/user_guide/libraries/file_uploading.html
*/
class CI_Upload {
-
+
var $max_size = 0;
var $max_width = 0;
var $max_height = 0;
@@ -51,9 +51,9 @@ class CI_Upload {
var $xss_clean = FALSE;
var $temp_prefix = "temp_file_";
var $client_name = '';
-
+
var $_file_name_override = ''; //@PHP4 (should be private)
-
+
/**
* Constructor
*
@@ -65,19 +65,19 @@ class CI_Upload {
{
$this->initialize($props);
}
-
+
log_message('debug', "Upload Class Initialized");
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Initialize preferences
*
* @access public
* @param array
* @return void
- */
+ */
function initialize($config = array())
{
@@ -107,9 +107,9 @@ class CI_Upload {
'xss_clean' => FALSE,
'temp_prefix' => "temp_file_",
'client_name' => ''
- );
-
-
+ );
+
+
foreach ($defaults as $key => $val)
{
if (isset($config[$key]))
@@ -122,27 +122,27 @@ class CI_Upload {
else
{
$this->$key = $config[$key];
- }
+ }
}
else
{
$this->$key = $val;
}
}
-
+
// if a file_name was provided in the config, use it instead of the user input
// supplied file name for all uploads until initialized again
$this->_file_name_override = $this->file_name;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Perform the file upload
*
* @access public
* @return bool
- */
+ */
function do_upload($field = 'userfile')
{
// Is $_FILES[$field] set? If not, no reason to continue.
@@ -151,7 +151,7 @@ class CI_Upload {
$this->set_error('upload_no_file_selected');
return FALSE;
}
-
+
// Is the upload path valid?
if ( ! $this->validate_upload_path())
{
@@ -173,10 +173,10 @@ class CI_Upload {
$this->set_error('upload_file_exceeds_form_limit');
break;
case 3: // UPLOAD_ERR_PARTIAL
- $this->set_error('upload_file_partial');
+ $this->set_error('upload_file_partial');
break;
case 4: // UPLOAD_ERR_NO_FILE
- $this->set_error('upload_no_file_selected');
+ $this->set_error('upload_no_file_selected');
break;
case 6: // UPLOAD_ERR_NO_TMP_DIR
$this->set_error('upload_no_temp_directory');
@@ -196,14 +196,14 @@ class CI_Upload {
// Set the uploaded data as class variables
- $this->file_temp = $_FILES[$field]['tmp_name'];
- $this->file_size = $_FILES[$field]['size'];
+ $this->file_temp = $_FILES[$field]['tmp_name'];
+ $this->file_size = $_FILES[$field]['size'];
$this->file_type = preg_replace("/^(.+?);.*$/", "\\1", $_FILES[$field]['type']);
$this->file_type = strtolower(trim(stripslashes($this->file_type), '"'));
$this->file_name = $this->_prep_filename($_FILES[$field]['name']);
$this->file_ext = $this->get_extension($this->file_name);
$this->client_name = $this->file_name;
-
+
// Is the file type allowed to be uploaded?
if ( ! $this->is_allowed_filetype())
{
@@ -220,10 +220,10 @@ class CI_Upload {
if ( ! $this->is_allowed_filetype(TRUE))
{
$this->set_error('upload_invalid_filetype');
- return FALSE;
+ return FALSE;
}
}
-
+
// Convert the file size to kilobytes
if ($this->file_size > 0)
{
@@ -247,7 +247,7 @@ class CI_Upload {
// Sanitize the file name for security
$this->file_name = $this->clean_file_name($this->file_name);
-
+
// Truncate the file name if it's too long
if ($this->max_filename > 0)
{
@@ -271,7 +271,7 @@ class CI_Upload {
if ($this->overwrite == FALSE)
{
$this->file_name = $this->set_filename($this->upload_path, $this->file_name);
-
+
if ($this->file_name === FALSE)
{
return FALSE;
@@ -304,8 +304,8 @@ class CI_Upload {
{
if ( ! @move_uploaded_file($this->file_temp, $this->upload_path.$this->file_name))
{
- $this->set_error('upload_destination_error');
- return FALSE;
+ $this->set_error('upload_destination_error');
+ return FALSE;
}
}
@@ -319,18 +319,18 @@ class CI_Upload {
return TRUE;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Finalized Data Array
- *
+ *
* Returns an associative array containing all of the information
* related to the upload, allowing the developer easy access in one array.
*
* @access public
* @return array
- */
+ */
function data()
{
return array (
@@ -350,24 +350,24 @@ class CI_Upload {
'image_size_str' => $this->image_size_str,
);
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Set Upload Path
*
* @access public
* @param string
* @return void
- */
+ */
function set_upload_path($path)
{
// Make sure it has a trailing slash
$this->upload_path = rtrim($path, '/').'/';
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Set the file name
*
@@ -379,25 +379,25 @@ class CI_Upload {
* @param string
* @param string
* @return string
- */
+ */
function set_filename($path, $filename)
{
if ($this->encrypt_name == TRUE)
- {
+ {
mt_srand();
- $filename = md5(uniqid(mt_rand())).$this->file_ext;
+ $filename = md5(uniqid(mt_rand())).$this->file_ext;
}
-
+
if ( ! file_exists($path.$filename))
{
return $filename;
}
-
+
$filename = str_replace($this->file_ext, '', $filename);
-
+
$new_filename = '';
for ($i = 1; $i < 100; $i++)
- {
+ {
if ( ! file_exists($path.$filename.$i.$this->file_ext))
{
$new_filename = $filename.$i.$this->file_ext;
@@ -415,72 +415,72 @@ class CI_Upload {
return $new_filename;
}
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Set Maximum File Size
*
* @access public
* @param integer
* @return void
- */
+ */
function set_max_filesize($n)
{
$this->max_size = ((int) $n < 0) ? 0: (int) $n;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Set Maximum File Name Length
*
* @access public
* @param integer
* @return void
- */
+ */
function set_max_filename($n)
{
$this->max_filename = ((int) $n < 0) ? 0: (int) $n;
}
// --------------------------------------------------------------------
-
+
/**
* Set Maximum Image Width
*
* @access public
* @param integer
* @return void
- */
+ */
function set_max_width($n)
{
$this->max_width = ((int) $n < 0) ? 0: (int) $n;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Set Maximum Image Height
*
* @access public
* @param integer
* @return void
- */
+ */
function set_max_height($n)
{
$this->max_height = ((int) $n < 0) ? 0: (int) $n;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Set Allowed File Types
*
* @access public
* @param string
* @return void
- */
+ */
function set_allowed_types($types)
{
if ( ! is_array($types) && $types == '*')
@@ -490,9 +490,9 @@ class CI_Upload {
}
$this->allowed_types = explode('|', $types);
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Set Image Properties
*
@@ -501,7 +501,7 @@ class CI_Upload {
* @access public
* @param string
* @return void
- */
+ */
function set_image_properties($path = '')
{
if ( ! $this->is_image())
@@ -512,7 +512,7 @@ class CI_Upload {
if (function_exists('getimagesize'))
{
if (FALSE !== ($D = @getimagesize($path)))
- {
+ {
$types = array(1 => 'gif', 2 => 'jpeg', 3 => 'png');
$this->image_width = $D['0'];
@@ -522,9 +522,9 @@ class CI_Upload {
}
}
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Set XSS Clean
*
@@ -539,15 +539,15 @@ class CI_Upload {
{
$this->xss_clean = ($flag == TRUE) ? TRUE : FALSE;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Validate the image
*
* @access public
* @return bool
- */
+ */
function is_image()
{
// IE will sometimes return odd mime-types during upload, so here we just standardize all
@@ -555,12 +555,12 @@ class CI_Upload {
$png_mimes = array('image/x-png');
$jpeg_mimes = array('image/jpg', 'image/jpe', 'image/jpeg', 'image/pjpeg');
-
+
if (in_array($this->file_type, $png_mimes))
{
$this->file_type = 'image/png';
}
-
+
if (in_array($this->file_type, $jpeg_mimes))
{
$this->file_type = 'image/jpeg';
@@ -570,80 +570,80 @@ class CI_Upload {
'image/gif',
'image/jpeg',
'image/png',
- );
+ );
return (in_array($this->file_type, $img_mimes, TRUE)) ? TRUE : FALSE;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Verify that the filetype is allowed
*
* @access public
* @return bool
- */
+ */
function is_allowed_filetype($ignore_mime = FALSE)
{
if ($this->allowed_types == '*')
{
return TRUE;
}
-
+
if (count($this->allowed_types) == 0 OR ! is_array($this->allowed_types))
{
$this->set_error('upload_no_file_types');
return FALSE;
}
-
+
$ext = strtolower(ltrim($this->file_ext, '.'));
-
+
if ( ! in_array($ext, $this->allowed_types))
{
return FALSE;
}
- // Images get some additional checks
+ // Images get some additional checks
$image_types = array('gif', 'jpg', 'jpeg', 'png', 'jpe');
-
+
if (in_array($ext, $image_types))
{
if (getimagesize($this->file_temp) === FALSE)
{
return FALSE;
- }
+ }
}
-
+
if ($ignore_mime === TRUE)
{
return TRUE;
}
-
+
$mime = $this->mimes_types($ext);
-
+
if (is_array($mime))
{
if (in_array($this->file_type, $mime, TRUE))
{
return TRUE;
- }
+ }
}
elseif ($mime == $this->file_type)
{
return TRUE;
}
-
+
return FALSE;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Verify that the file is within the allowed size
*
* @access public
* @return bool
- */
+ */
function is_allowed_filesize()
{
if ($this->max_size != 0 AND $this->file_size > $this->max_size)
@@ -655,15 +655,15 @@ class CI_Upload {
return TRUE;
}
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Verify that the image is within the allowed width/height
*
* @access public
* @return bool
- */
+ */
function is_allowed_dimensions()
{
if ( ! $this->is_image())
@@ -690,9 +690,9 @@ class CI_Upload {
return TRUE;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Validate Upload Path
*
@@ -701,7 +701,7 @@ class CI_Upload {
*
* @access public
* @return bool
- */
+ */
function validate_upload_path()
{
if ($this->upload_path == '')
@@ -709,7 +709,7 @@ class CI_Upload {
$this->set_error('upload_no_filepath');
return FALSE;
}
-
+
if (function_exists('realpath') AND @realpath($this->upload_path) !== FALSE)
{
$this->upload_path = str_replace("\\", "/", realpath($this->upload_path));
@@ -730,31 +730,31 @@ class CI_Upload {
$this->upload_path = preg_replace("/(.+?)\/*$/", "\\1/", $this->upload_path);
return TRUE;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Extract the file extension
*
* @access public
* @param string
* @return string
- */
+ */
function get_extension($filename)
{
$x = explode('.', $filename);
return '.'.end($x);
- }
-
+ }
+
// --------------------------------------------------------------------
-
+
/**
* Clean the file name for security
*
* @access public
* @param string
* @return string
- */
+ */
function clean_file_name($filename)
{
$bad = array(
@@ -773,40 +773,40 @@ class CI_Upload {
"%20",
"%22",
"%3c", // <
- "%253c", // <
- "%3e", // >
- "%0e", // >
- "%28", // (
- "%29", // )
- "%2528", // (
- "%26", // &
- "%24", // $
- "%3f", // ?
- "%3b", // ;
+ "%253c", // <
+ "%3e", // >
+ "%0e", // >
+ "%28", // (
+ "%29", // )
+ "%2528", // (
+ "%26", // &
+ "%24", // $
+ "%3f", // ?
+ "%3b", // ;
"%3d" // =
);
-
+
$filename = str_replace($bad, '', $filename);
return stripslashes($filename);
}
// --------------------------------------------------------------------
-
+
/**
* Limit the File Name Length
*
* @access public
* @param string
* @return string
- */
+ */
function limit_filename_length($filename, $length)
{
if (strlen($filename) < $length)
{
return $filename;
}
-
+
$ext = '';
if (strpos($filename, '.') !== FALSE)
{
@@ -814,12 +814,12 @@ class CI_Upload {
$ext = '.'.array_pop($parts);
$filename = implode('.', $parts);
}
-
+
return substr($filename, 0, ($length - strlen($ext))).$ext;
}
// --------------------------------------------------------------------
-
+
/**
* Runs the file through the XSS clean function
*
@@ -829,26 +829,26 @@ class CI_Upload {
*
* @access public
* @return void
- */
+ */
function do_xss_clean()
- {
+ {
$file = $this->file_temp;
-
+
if (filesize($file) == 0)
{
return FALSE;
}
-
+
if (function_exists('memory_get_usage') && memory_get_usage() && ini_get('memory_limit') != '')
{
$current = ini_get('memory_limit') * 1024 * 1024;
-
+
// There was a bug/behavioural change in PHP 5.2, where numbers over one million get output
// into scientific notation. number_format() ensures this number is an integer
// http://bugs.php.net/bug.php?id=43053
-
+
$new_memory = number_format(ceil(filesize($file) + $current), 0, '.', '');
-
+
ini_set('memory_limit', $new_memory); // When an integer is used, the value is measured in bytes. - PHP.net
}
@@ -856,18 +856,18 @@ class CI_Upload {
// IE can be fooled into mime-type detecting a malformed image as an html file, thus executing an XSS attack on anyone
// using IE who looks at the image. It does this by inspecting the first 255 bytes of an image. To get around this
// CI will itself look at the first 255 bytes of an image to determine its relative safety. This can save a lot of
- // processor power and time if it is actually a clean image, as it will be in nearly all instances _except_ an
+ // processor power and time if it is actually a clean image, as it will be in nearly all instances _except_ an
// attempted XSS attack.
if (function_exists('getimagesize') && @getimagesize($file) !== FALSE)
{
- if (($file = @fopen($file, 'rb')) === FALSE) // "b" to force binary
- {
+ if (($file = @fopen($file, 'rb')) === FALSE) // "b" to force binary
+ {
return FALSE; // Couldn't open the file, return FALSE
- }
+ }
- $opening_bytes = fread($file, 256);
- fclose($file);
+ $opening_bytes = fread($file, 256);
+ fclose($file);
// These are known to throw IE into mime-type detection chaos
// <a, <body, <head, <html, <img, <plaintext, <pre, <script, <table, <title
@@ -885,37 +885,37 @@ class CI_Upload {
}
$CI =& get_instance();
-
+
if ( ! isset($CI->security))
{
$CI->load->library('security');
}
-
+
return $CI->security->xss_clean($data, TRUE);
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Set an error message
*
* @access public
* @param string
* @return void
- */
+ */
function set_error($msg)
{
- $CI =& get_instance();
+ $CI =& get_instance();
$CI->lang->load('upload');
-
+
if (is_array($msg))
{
foreach ($msg as $val)
{
- $msg = ($CI->lang->line($val) == FALSE) ? $val : $CI->lang->line($val);
+ $msg = ($CI->lang->line($val) == FALSE) ? $val : $CI->lang->line($val);
$this->error_msg[] = $msg;
log_message('error', $msg);
- }
+ }
}
else
{
@@ -924,9 +924,9 @@ class CI_Upload {
log_message('error', $msg);
}
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Display the error message
*
@@ -934,7 +934,7 @@ class CI_Upload {
* @param string
* @param string
* @return string
- */
+ */
function display_errors($open = '<p>', $close = '</p>')
{
$str = '';
@@ -942,12 +942,12 @@ class CI_Upload {
{
$str .= $open.$val.$close;
}
-
+
return $str;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* List of Mime Types
*
@@ -957,11 +957,11 @@ class CI_Upload {
* @access public
* @param string
* @return string
- */
+ */
function mimes_types($mime)
{
global $mimes;
-
+
if (count($this->mimes) == 0)
{
if (@require_once(APPPATH.'config/mimes'.EXT))
@@ -970,12 +970,12 @@ class CI_Upload {
unset($mimes);
}
}
-
+
return ( ! isset($this->mimes[$mime])) ? FALSE : $this->mimes[$mime];
}
// --------------------------------------------------------------------
-
+
/**
* Prep Filename
*
@@ -1010,7 +1010,7 @@ class CI_Upload {
}
$filename .= '.'.$ext;
-
+
return $filename;
}
diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php
index a7c7a7609..00cbf6967 100644
--- a/system/libraries/User_agent.php
+++ b/system/libraries/User_agent.php
@@ -29,25 +29,25 @@
class CI_User_agent {
var $agent = NULL;
-
+
var $is_browser = FALSE;
var $is_robot = FALSE;
var $is_mobile = FALSE;
var $languages = array();
var $charsets = array();
-
+
var $platforms = array();
var $browsers = array();
var $mobiles = array();
var $robots = array();
-
+
var $platform = '';
var $browser = '';
var $version = '';
var $mobile = '';
var $robot = '';
-
+
/**
* Constructor
*
@@ -55,14 +55,14 @@ class CI_User_agent {
*
* @access public
* @return void
- */
+ */
function CI_User_agent()
{
if (isset($_SERVER['HTTP_USER_AGENT']))
{
$this->agent = trim($_SERVER['HTTP_USER_AGENT']);
}
-
+
if ( ! is_null($this->agent))
{
if ($this->_load_agent_file())
@@ -70,27 +70,27 @@ class CI_User_agent {
$this->_compile_data();
}
}
-
+
log_message('debug', "User Agent Class Initialized");
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Compile the User Agent Data
*
* @access private
* @return bool
- */
+ */
function _load_agent_file()
{
if ( ! @include(APPPATH.'config/user_agents'.EXT))
{
return FALSE;
}
-
+
$return = FALSE;
-
+
if (isset($platforms))
{
$this->platforms = $platforms;
@@ -111,7 +111,7 @@ class CI_User_agent {
unset($mobiles);
$return = TRUE;
}
-
+
if (isset($robots))
{
$this->robots = $robots;
@@ -121,36 +121,36 @@ class CI_User_agent {
return $return;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Compile the User Agent Data
*
* @access private
* @return bool
- */
+ */
function _compile_data()
{
$this->_set_platform();
-
+
foreach (array('_set_browser', '_set_robot', '_set_mobile') as $function)
{
if ($this->$function() === TRUE)
{
break;
}
- }
+ }
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Set the Platform
*
* @access private
* @return mixed
- */
+ */
function _set_platform()
{
if (is_array($this->platforms) AND count($this->platforms) > 0)
@@ -168,19 +168,19 @@ class CI_User_agent {
}
// --------------------------------------------------------------------
-
+
/**
* Set the Browser
*
* @access private
* @return bool
- */
+ */
function _set_browser()
{
if (is_array($this->browsers) AND count($this->browsers) > 0)
{
foreach ($this->browsers as $key => $val)
- {
+ {
if (preg_match("|".preg_quote($key).".*?([0-9\.]+)|i", $this->agent, $match))
{
$this->is_browser = TRUE;
@@ -193,19 +193,19 @@ class CI_User_agent {
}
return FALSE;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Set the Robot
*
* @access private
* @return bool
- */
+ */
function _set_robot()
{
if (is_array($this->robots) AND count($this->robots) > 0)
- {
+ {
foreach ($this->robots as $key => $val)
{
if (preg_match("|".preg_quote($key)."|i", $this->agent))
@@ -220,17 +220,17 @@ class CI_User_agent {
}
// --------------------------------------------------------------------
-
+
/**
* Set the Mobile Device
*
* @access private
* @return bool
- */
+ */
function _set_mobile()
{
if (is_array($this->mobiles) AND count($this->mobiles) > 0)
- {
+ {
foreach ($this->mobiles as $key => $val)
{
if (FALSE !== (strpos(strtolower($this->agent), $key)))
@@ -240,261 +240,261 @@ class CI_User_agent {
return TRUE;
}
}
- }
+ }
return FALSE;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Set the accepted languages
*
* @access private
* @return void
- */
+ */
function _set_languages()
{
if ((count($this->languages) == 0) AND isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) AND $_SERVER['HTTP_ACCEPT_LANGUAGE'] != '')
{
$languages = preg_replace('/(;q=[0-9\.]+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_LANGUAGE'])));
-
+
$this->languages = explode(',', $languages);
}
-
+
if (count($this->languages) == 0)
{
$this->languages = array('Undefined');
- }
+ }
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Set the accepted character sets
*
* @access private
* @return void
- */
+ */
function _set_charsets()
- {
+ {
if ((count($this->charsets) == 0) AND isset($_SERVER['HTTP_ACCEPT_CHARSET']) AND $_SERVER['HTTP_ACCEPT_CHARSET'] != '')
{
$charsets = preg_replace('/(;q=.+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_CHARSET'])));
-
+
$this->charsets = explode(',', $charsets);
}
-
+
if (count($this->charsets) == 0)
{
$this->charsets = array('Undefined');
- }
+ }
}
// --------------------------------------------------------------------
-
+
/**
* Is Browser
*
* @access public
* @return bool
- */
+ */
function is_browser()
{
return $this->is_browser;
}
// --------------------------------------------------------------------
-
+
/**
* Is Robot
*
* @access public
* @return bool
- */
+ */
function is_robot()
{
return $this->is_robot;
}
// --------------------------------------------------------------------
-
+
/**
* Is Mobile
*
* @access public
* @return bool
- */
+ */
function is_mobile()
{
return $this->is_mobile;
- }
+ }
// --------------------------------------------------------------------
-
+
/**
* Is this a referral from another site?
*
* @access public
* @return bool
- */
+ */
function is_referral()
{
return ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '') ? FALSE : TRUE;
}
// --------------------------------------------------------------------
-
+
/**
* Agent String
*
* @access public
* @return string
- */
+ */
function agent_string()
{
return $this->agent;
}
// --------------------------------------------------------------------
-
+
/**
* Get Platform
*
* @access public
* @return string
- */
+ */
function platform()
{
return $this->platform;
}
// --------------------------------------------------------------------
-
+
/**
* Get Browser Name
*
* @access public
* @return string
- */
+ */
function browser()
{
return $this->browser;
}
// --------------------------------------------------------------------
-
+
/**
* Get the Browser Version
*
* @access public
* @return string
- */
+ */
function version()
{
return $this->version;
}
// --------------------------------------------------------------------
-
+
/**
* Get The Robot Name
*
* @access public
* @return string
- */
+ */
function robot()
{
return $this->robot;
}
// --------------------------------------------------------------------
-
+
/**
* Get the Mobile Device
*
* @access public
* @return string
- */
+ */
function mobile()
{
return $this->mobile;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Get the referrer
*
* @access public
* @return bool
- */
+ */
function referrer()
{
return ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '') ? '' : trim($_SERVER['HTTP_REFERER']);
}
// --------------------------------------------------------------------
-
+
/**
* Get the accepted languages
*
* @access public
* @return array
- */
+ */
function languages()
{
if (count($this->languages) == 0)
{
$this->_set_languages();
}
-
+
return $this->languages;
}
// --------------------------------------------------------------------
-
+
/**
* Get the accepted Character Sets
*
* @access public
* @return array
- */
+ */
function charsets()
{
if (count($this->charsets) == 0)
{
$this->_set_charsets();
}
-
+
return $this->charsets;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Test for a particular language
*
* @access public
* @return bool
- */
+ */
function accept_lang($lang = 'en')
{
return (in_array(strtolower($lang), $this->languages(), TRUE)) ? TRUE : FALSE;
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Test for a particular character set
*
* @access public
* @return bool
- */
+ */
function accept_charset($charset = 'utf-8')
{
return (in_array(strtolower($charset), $this->charsets(), TRUE)) ? TRUE : FALSE;
}
-
-
+
+
}
diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php
index ff03a503a..54ee70771 100644
--- a/system/libraries/Xmlrpc.php
+++ b/system/libraries/Xmlrpc.php
@@ -14,7 +14,7 @@
*/
if ( ! function_exists('xml_parser_create'))
-{
+{
show_error('Your PHP installation does not support XML');
}
@@ -32,34 +32,34 @@ if ( ! function_exists('xml_parser_create'))
*/
class CI_Xmlrpc {
- var $debug = FALSE; // Debugging on or off
+ var $debug = FALSE; // Debugging on or off
var $xmlrpcI4 = 'i4';
var $xmlrpcInt = 'int';
var $xmlrpcBoolean = 'boolean';
- var $xmlrpcDouble = 'double';
+ var $xmlrpcDouble = 'double';
var $xmlrpcString = 'string';
var $xmlrpcDateTime = 'dateTime.iso8601';
var $xmlrpcBase64 = 'base64';
var $xmlrpcArray = 'array';
var $xmlrpcStruct = 'struct';
-
+
var $xmlrpcTypes = array();
var $valid_parents = array();
var $xmlrpcerr = array(); // Response numbers
var $xmlrpcstr = array(); // Response strings
-
+
var $xmlrpc_defencoding = 'UTF-8';
var $xmlrpcName = 'XML-RPC for CodeIgniter';
var $xmlrpcVersion = '1.1';
var $xmlrpcerruser = 800; // Start of user errors
var $xmlrpcerrxml = 100; // Start of XML Parse errors
var $xmlrpc_backslash = ''; // formulate backslashes for escaping regexp
-
+
var $client;
var $method;
var $data;
var $message = '';
- var $error = ''; // Error string for request
+ var $error = ''; // Error string for request
var $result;
var $response = array(); // Response from remote server
@@ -71,22 +71,22 @@ class CI_Xmlrpc {
function CI_Xmlrpc ($config = array())
{
- $this->xmlrpcName = $this->xmlrpcName;
+ $this->xmlrpcName = $this->xmlrpcName;
$this->xmlrpc_backslash = chr(92).chr(92);
-
+
// Types for info sent back and forth
$this->xmlrpcTypes = array(
- $this->xmlrpcI4 => '1',
- $this->xmlrpcInt => '1',
- $this->xmlrpcBoolean => '1',
- $this->xmlrpcString => '1',
- $this->xmlrpcDouble => '1',
- $this->xmlrpcDateTime => '1',
- $this->xmlrpcBase64 => '1',
- $this->xmlrpcArray => '2',
- $this->xmlrpcStruct => '3'
+ $this->xmlrpcI4 => '1',
+ $this->xmlrpcInt => '1',
+ $this->xmlrpcBoolean => '1',
+ $this->xmlrpcString => '1',
+ $this->xmlrpcDouble => '1',
+ $this->xmlrpcDateTime => '1',
+ $this->xmlrpcBase64 => '1',
+ $this->xmlrpcArray => '2',
+ $this->xmlrpcStruct => '3'
);
-
+
// Array of Valid Parents for Various XML-RPC elements
$this->valid_parents = array('BOOLEAN' => array('VALUE'),
'I4' => array('VALUE'),
@@ -106,8 +106,8 @@ class CI_Xmlrpc {
'FAULT' => array('METHODRESPONSE'),
'VALUE' => array('MEMBER', 'DATA', 'PARAM', 'FAULT')
);
-
-
+
+
// XML-RPC Responses
$this->xmlrpcerr['unknown_method'] = '1';
$this->xmlrpcstr['unknown_method'] = 'This is not a known method for this XML-RPC Server';
@@ -121,13 +121,13 @@ class CI_Xmlrpc {
$this->xmlrpcstr['http_error'] = "Did not receive a '200 OK' response from remote server.";
$this->xmlrpcerr['no_data'] = '6';
$this->xmlrpcstr['no_data'] ='No data received from server.';
-
+
$this->initialize($config);
-
+
log_message('debug', "XML-RPC Class Initialized");
}
-
-
+
+
//-------------------------------------
// Initialize Prefs
//-------------------------------------
@@ -140,13 +140,13 @@ class CI_Xmlrpc {
{
if (isset($this->$key))
{
- $this->$key = $val;
+ $this->$key = $val;
}
}
}
}
// END
-
+
//-------------------------------------
// Take URL and parse it
//-------------------------------------
@@ -157,20 +157,20 @@ class CI_Xmlrpc {
{
$url = "http://".$url;
}
-
+
$parts = parse_url($url);
-
+
$path = ( ! isset($parts['path'])) ? '/' : $parts['path'];
-
+
if (isset($parts['query']) && $parts['query'] != '')
{
$path .= '?'.$parts['query'];
- }
-
+ }
+
$this->client = new XML_RPC_Client($path, $parts['host'], $port);
}
// END
-
+
//-------------------------------------
// Set Timeout
//-------------------------------------
@@ -183,7 +183,7 @@ class CI_Xmlrpc {
}
}
// END
-
+
//-------------------------------------
// Set Methods
//-------------------------------------
@@ -193,7 +193,7 @@ class CI_Xmlrpc {
$this->method = $function;
}
// END
-
+
//-------------------------------------
// Take Array of Data and Create Objects
//-------------------------------------
@@ -204,17 +204,17 @@ class CI_Xmlrpc {
{
// Send Error
}
-
+
$this->data = array();
-
+
foreach($incoming as $key => $value)
{
$this->data[$key] = $this->values_parsing($value);
}
}
// END
-
-
+
+
//-------------------------------------
// Set Debug
//-------------------------------------
@@ -223,7 +223,7 @@ class CI_Xmlrpc {
{
$this->debug = ($flag == TRUE) ? TRUE : FALSE;
}
-
+
//-------------------------------------
// Values Parsing
//-------------------------------------
@@ -249,7 +249,7 @@ class CI_Xmlrpc {
{
$value['0'][$k] = $this->values_parsing($value['0'][$k], TRUE);
}
-
+
$temp = new XML_RPC_Values($value['0'], $value['1']);
}
else
@@ -275,7 +275,7 @@ class CI_Xmlrpc {
{
$this->message = new XML_RPC_Message($this->method,$this->data);
$this->message->debug = $this->debug;
-
+
if ( ! $this->result = $this->client->send($this->message))
{
$this->error = $this->result->errstr;
@@ -286,13 +286,13 @@ class CI_Xmlrpc {
$this->error = $this->result->errstr;
return FALSE;
}
-
+
$this->response = $this->result->decode();
-
+
return TRUE;
}
// END
-
+
//-------------------------------------
// Returns Error
//-------------------------------------
@@ -302,7 +302,7 @@ class CI_Xmlrpc {
return $this->error;
}
// END
-
+
//-------------------------------------
// Returns Remote Server Response
//-------------------------------------
@@ -312,37 +312,37 @@ class CI_Xmlrpc {
return $this->response;
}
// END
-
+
//-------------------------------------
// Sends an Error Message for Server Request
//-------------------------------------
-
+
function send_error_message($number, $message)
{
return new XML_RPC_Response('0',$number, $message);
}
// END
-
-
+
+
//-------------------------------------
// Send Response for Server Request
//-------------------------------------
-
+
function send_response($response)
{
// $response should be array of values, which will be parsed
// based on their data and type into a valid group of XML-RPC values
-
+
$response = $this->values_parsing($response);
-
+
return new XML_RPC_Response($response);
}
// END
-
+
} // END XML_RPC Class
-
-
+
+
/**
* XML-RPC Client class
*
@@ -363,12 +363,12 @@ class XML_RPC_Client extends CI_Xmlrpc
function XML_RPC_Client($path, $server, $port=80)
{
parent::CI_Xmlrpc();
-
+
$this->port = $port;
$this->server = $server;
$this->path = $path;
}
-
+
function send($msg)
{
if (is_array($msg))
@@ -382,22 +382,22 @@ class XML_RPC_Client extends CI_Xmlrpc
}
function sendPayload($msg)
- {
+ {
$fp = @fsockopen($this->server, $this->port,$this->errno, $this->errstr, $this->timeout);
-
+
if ( ! is_resource($fp))
{
error_log($this->xmlrpcstr['http_error']);
$r = new XML_RPC_Response(0, $this->xmlrpcerr['http_error'],$this->xmlrpcstr['http_error']);
return $r;
}
-
+
if(empty($msg->payload))
{
// $msg = XML_RPC_Messages
$msg->createPayload();
}
-
+
$r = "\r\n";
$op = "POST {$this->path} HTTP/1.0$r";
$op .= "Host: {$this->server}$r";
@@ -405,7 +405,7 @@ class XML_RPC_Client extends CI_Xmlrpc
$op .= "User-Agent: {$this->xmlrpcName}$r";
$op .= "Content-Length: ".strlen($msg->payload). "$r$r";
$op .= $msg->payload;
-
+
if ( ! fputs($fp, $op, strlen($op)))
{
@@ -437,7 +437,7 @@ class XML_RPC_Response
var $xss_clean = TRUE;
function XML_RPC_Response($val, $code = 0, $fstr = '')
- {
+ {
if ($code != 0)
{
// error
@@ -470,7 +470,7 @@ class XML_RPC_Response
{
return $this->val;
}
-
+
function prepare_response()
{
$result = "<methodResponse>\n";
@@ -500,7 +500,7 @@ class XML_RPC_Response
$result .= "\n</methodResponse>";
return $result;
}
-
+
function decode($array=FALSE)
{
$CI =& get_instance();
@@ -523,13 +523,13 @@ class XML_RPC_Response
$array[$key] = ($this->xss_clean) ? $CI->security->xss_clean($array[$key]) : $array[$key];
}
}
-
+
$result = $array;
}
else
{
$result = $this->xmlrpc_decoder($this->val);
-
+
if (is_array($result))
{
$result = $this->decode($result);
@@ -539,12 +539,12 @@ class XML_RPC_Response
$result = ($this->xss_clean) ? $CI->security->xss_clean($result) : $result;
}
}
-
+
return $result;
}
-
-
+
+
//-------------------------------------
// XML-RPC Object to PHP Types
//-------------------------------------
@@ -562,7 +562,7 @@ class XML_RPC_Response
reset($xmlrpc_val->me);
list($a,$b) = each($xmlrpc_val->me);
$size = count($b);
-
+
$arr = array();
for($i = 0; $i < $size; $i++)
@@ -583,8 +583,8 @@ class XML_RPC_Response
return $arr;
}
}
-
-
+
+
//-------------------------------------
// ISO-8601 time to server or UTC time
//-------------------------------------
@@ -602,7 +602,7 @@ class XML_RPC_Response
}
return $t;
}
-
+
} // End Response Class
@@ -619,12 +619,12 @@ class XML_RPC_Message extends CI_Xmlrpc
var $payload;
var $method_name;
var $params = array();
- var $xh = array();
+ var $xh = array();
function XML_RPC_Message($method, $pars=0)
{
parent::CI_Xmlrpc();
-
+
$this->method_name = $method;
if (is_array($pars) && count($pars) > 0)
{
@@ -635,51 +635,51 @@ class XML_RPC_Message extends CI_Xmlrpc
}
}
}
-
+
//-------------------------------------
// Create Payload to Send
//-------------------------------------
-
+
function createPayload()
{
$this->payload = "<?xml version=\"1.0\"?".">\r\n<methodCall>\r\n";
$this->payload .= '<methodName>' . $this->method_name . "</methodName>\r\n";
$this->payload .= "<params>\r\n";
-
+
for($i=0; $i<count($this->params); $i++)
{
// $p = XML_RPC_Values
$p = $this->params[$i];
$this->payload .= "<param>\r\n".$p->serialize_class()."</param>\r\n";
}
-
+
$this->payload .= "</params>\r\n</methodCall>\r\n";
}
-
+
//-------------------------------------
// Parse External XML-RPC Server's Response
//-------------------------------------
-
+
function parseResponse($fp)
{
$data = '';
-
+
while($datum = fread($fp, 4096))
{
$data .= $datum;
}
-
+
//-------------------------------------
// DISPLAY HTTP CONTENT for DEBUGGING
//-------------------------------------
-
+
if ($this->debug === TRUE)
{
echo "<pre>";
echo "---DATA---\n" . htmlspecialchars($data) . "\n---END DATA---\n\n";
echo "</pre>";
}
-
+
//-------------------------------------
// Check for data
//-------------------------------------
@@ -690,32 +690,32 @@ class XML_RPC_Message extends CI_Xmlrpc
$r = new XML_RPC_Response(0, $this->xmlrpcerr['no_data'], $this->xmlrpcstr['no_data']);
return $r;
}
-
-
+
+
//-------------------------------------
// Check for HTTP 200 Response
//-------------------------------------
-
+
if (strncmp($data, 'HTTP', 4) == 0 && ! preg_match('/^HTTP\/[0-9\.]+ 200 /', $data))
{
$errstr= substr($data, 0, strpos($data, "\n")-1);
$r = new XML_RPC_Response(0, $this->xmlrpcerr['http_error'], $this->xmlrpcstr['http_error']. ' (' . $errstr . ')');
return $r;
}
-
+
//-------------------------------------
// Create and Set Up XML Parser
//-------------------------------------
-
+
$parser = xml_parser_create($this->xmlrpc_defencoding);
- $this->xh[$parser] = array();
- $this->xh[$parser]['isf'] = 0;
- $this->xh[$parser]['ac'] = '';
- $this->xh[$parser]['headers'] = array();
- $this->xh[$parser]['stack'] = array();
- $this->xh[$parser]['valuestack'] = array();
- $this->xh[$parser]['isf_reason'] = 0;
+ $this->xh[$parser] = array();
+ $this->xh[$parser]['isf'] = 0;
+ $this->xh[$parser]['ac'] = '';
+ $this->xh[$parser]['headers'] = array();
+ $this->xh[$parser]['stack'] = array();
+ $this->xh[$parser]['valuestack'] = array();
+ $this->xh[$parser]['isf_reason'] = 0;
xml_set_object($parser, $this);
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);
@@ -727,7 +727,7 @@ class XML_RPC_Message extends CI_Xmlrpc
//-------------------------------------
// GET HEADERS
//-------------------------------------
-
+
$lines = explode("\r\n", $data);
while (($line = array_shift($lines)))
{
@@ -738,11 +738,11 @@ class XML_RPC_Message extends CI_Xmlrpc
$this->xh[$parser]['headers'][] = $line;
}
$data = implode("\r\n", $lines);
-
-
+
+
//-------------------------------------
// PARSE XML DATA
- //-------------------------------------
+ //-------------------------------------
if ( ! xml_parse($parser, $data, count($data)))
{
@@ -755,11 +755,11 @@ class XML_RPC_Message extends CI_Xmlrpc
return $r;
}
xml_parser_free($parser);
-
+
// ---------------------------------------
// Got Ourselves Some Badness, It Seems
// ---------------------------------------
-
+
if ($this->xh[$parser]['isf'] > 1)
{
if ($this->debug === TRUE)
@@ -768,7 +768,7 @@ class XML_RPC_Message extends CI_Xmlrpc
echo $this->xh[$parser]['isf_reason'];
echo "---Invalid Return---\n\n";
}
-
+
$r = new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'],$this->xmlrpcstr['invalid_return'].' '.$this->xh[$parser]['isf_reason']);
return $r;
}
@@ -777,15 +777,15 @@ class XML_RPC_Message extends CI_Xmlrpc
$r = new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'],$this->xmlrpcstr['invalid_return'].' '.$this->xh[$parser]['isf_reason']);
return $r;
}
-
+
//-------------------------------------
// DISPLAY XML CONTENT for DEBUGGING
- //-------------------------------------
-
+ //-------------------------------------
+
if ($this->debug === TRUE)
{
echo "<pre>";
-
+
if (count($this->xh[$parser]['headers'] > 0))
{
echo "---HEADERS---\n";
@@ -795,20 +795,20 @@ class XML_RPC_Message extends CI_Xmlrpc
}
echo "---END HEADERS---\n\n";
}
-
+
echo "---DATA---\n" . htmlspecialchars($data) . "\n---END DATA---\n\n";
-
+
echo "---PARSED---\n" ;
var_dump($this->xh[$parser]['value']);
echo "\n---END PARSED---</pre>";
}
-
+
//-------------------------------------
// SEND RESPONSE
//-------------------------------------
-
+
$v = $this->xh[$parser]['value'];
-
+
if ($this->xh[$parser]['isf'])
{
$errno_v = $v->me['struct']['faultCode'];
@@ -831,11 +831,11 @@ class XML_RPC_Message extends CI_Xmlrpc
$r->headers = $this->xh[$parser]['headers'];
return $r;
}
-
+
// ------------------------------------
// Begin Return Message Parsing section
// ------------------------------------
-
+
// quick explanation of components:
// ac - used to accumulate values
// isf - used to indicate a fault
@@ -854,9 +854,9 @@ class XML_RPC_Message extends CI_Xmlrpc
{
// If invalid nesting, then return
if ($this->xh[$the_parser]['isf'] > 1) return;
-
+
// Evaluate and check for correct nesting of XML elements
-
+
if (count($this->xh[$the_parser]['stack']) == 0)
{
if ($name != 'METHODRESPONSE' && $name != 'METHODCALL')
@@ -876,16 +876,16 @@ class XML_RPC_Message extends CI_Xmlrpc
return;
}
}
-
+
switch($name)
{
case 'STRUCT':
case 'ARRAY':
// Creates array for child elements
-
+
$cur_val = array('value' => array(),
'type' => $name);
-
+
array_unshift($this->xh[$the_parser]['valuestack'], $cur_val);
break;
case 'METHODNAME':
@@ -917,13 +917,13 @@ class XML_RPC_Message extends CI_Xmlrpc
$this->xh[$the_parser]['isf_reason'] = "'Twas a $name element following a ".$this->xh[$the_parser]['vt']." element inside a single value";
return;
}
-
+
$this->xh[$the_parser]['ac'] = '';
break;
case 'MEMBER':
// Set name of <member> to nothing to prevent errors later if no <name> is found
$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;
break;
@@ -939,7 +939,7 @@ class XML_RPC_Message extends CI_Xmlrpc
$this->xh[$the_parser]['isf_reason'] = "Invalid XML-RPC element found: $name";
break;
}
-
+
// Add current element name to stack, to allow validation of nesting
array_unshift($this->xh[$the_parser]['stack'], $name);
@@ -955,14 +955,14 @@ class XML_RPC_Message extends CI_Xmlrpc
function closing_tag($the_parser, $name)
{
if ($this->xh[$the_parser]['isf'] > 1) return;
-
+
// Remove current element from stack and set variable
// NOTE: If the XML validates, then we do not have to worry about
// the opening and closing of elements. Nesting is checked on the opening
// tag so we be safe there as well.
-
+
$curr_elem = array_shift($this->xh[$the_parser]['stack']);
-
+
switch($name)
{
case 'STRUCT':
@@ -982,7 +982,7 @@ class XML_RPC_Message extends CI_Xmlrpc
case 'DATETIME.ISO8601':
case 'BASE64':
$this->xh[$the_parser]['vt'] = strtolower($name);
-
+
if ($name == 'STRING')
{
$this->xh[$the_parser]['value'] = $this->xh[$the_parser]['ac'];
@@ -1044,10 +1044,10 @@ class XML_RPC_Message extends CI_Xmlrpc
$this->xh[$the_parser]['value'] = $this->xh[$the_parser]['ac'];
$this->xh[$the_parser]['vt'] = $this->xmlrpcString;
}
-
+
// build the XML-RPC value out of the data received, and substitute it
$temp = new XML_RPC_Values($this->xh[$the_parser]['value'], $this->xh[$the_parser]['vt']);
-
+
if (count($this->xh[$the_parser]['valuestack']) && $this->xh[$the_parser]['valuestack'][0]['type'] == 'ARRAY')
{
// Array
@@ -1061,7 +1061,7 @@ class XML_RPC_Message extends CI_Xmlrpc
break;
case 'MEMBER':
$this->xh[$the_parser]['ac']='';
-
+
// If value add to array in the stack for the last element built
if ($this->xh[$the_parser]['value'])
{
@@ -1099,7 +1099,7 @@ class XML_RPC_Message extends CI_Xmlrpc
function character_data($the_parser, $data)
{
if ($this->xh[$the_parser]['isf'] > 1) return; // XML Fault found already
-
+
// If a value has not been found
if ($this->xh[$the_parser]['lv'] != 3)
{
@@ -1107,28 +1107,28 @@ class XML_RPC_Message extends CI_Xmlrpc
{
$this->xh[$the_parser]['lv'] = 2; // Found a value
}
-
+
if( ! @isset($this->xh[$the_parser]['ac']))
{
$this->xh[$the_parser]['ac'] = '';
}
-
+
$this->xh[$the_parser]['ac'] .= $data;
}
}
-
-
+
+
function addParam($par) { $this->params[]=$par; }
-
+
function output_parameters($array=FALSE)
{
- $CI =& get_instance();
+ $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))
@@ -1144,17 +1144,17 @@ class XML_RPC_Message extends CI_Xmlrpc
$array[$key] = ($key == 'bits' OR $this->xss_clean == FALSE) ? $array[$key] : $CI->security->xss_clean($array[$key]);
}
}
-
+
$parameters = $array;
}
else
{
$parameters = array();
-
+
for ($i = 0; $i < count($this->params); $i++)
{
$a_param = $this->decode_message($this->params[$i]);
-
+
if (is_array($a_param))
{
$parameters[] = $this->output_parameters($a_param);
@@ -1163,13 +1163,13 @@ class XML_RPC_Message extends CI_Xmlrpc
{
$parameters[] = ($this->xss_clean) ? $CI->security->xss_clean($a_param) : $a_param;
}
- }
+ }
}
-
+
return $parameters;
}
-
-
+
+
function decode_message($param)
{
$kind = $param->kindOf();
@@ -1182,31 +1182,31 @@ class XML_RPC_Message extends CI_Xmlrpc
{
reset($param->me);
list($a,$b) = each($param->me);
-
+
$arr = array();
for($i = 0; $i < count($b); $i++)
{
$arr[] = $this->decode_message($param->me['array'][$i]);
}
-
+
return $arr;
}
elseif($kind == 'struct')
{
reset($param->me['struct']);
-
+
$arr = array();
while(list($key,$value) = each($param->me['struct']))
{
$arr[$key] = $this->decode_message($value);
}
-
+
return $arr;
}
}
-
+
} // End XML_RPC_Messages class
@@ -1220,17 +1220,17 @@ class XML_RPC_Message extends CI_Xmlrpc
*/
class XML_RPC_Values extends CI_Xmlrpc
{
- var $me = array();
+ var $me = array();
var $mytype = 0;
function XML_RPC_Values($val=-1, $type='')
- {
+ {
parent::CI_Xmlrpc();
-
+
if ($val != -1 OR $type != '')
{
$type = $type == '' ? 'string' : $type;
-
+
if ($this->xmlrpcTypes[$type] == 1)
{
$this->addScalar($val,$type);
@@ -1249,13 +1249,13 @@ class XML_RPC_Values extends CI_Xmlrpc
function addScalar($val, $type='string')
{
$typeof = $this->xmlrpcTypes[$type];
-
+
if ($this->mytype==1)
{
echo '<strong>XML_RPC_Values</strong>: scalar can have only one value<br />';
return 0;
}
-
+
if ($typeof != 1)
{
echo '<strong>XML_RPC_Values</strong>: not a scalar type (${typeof})<br />';
@@ -1392,12 +1392,12 @@ class XML_RPC_Values extends CI_Xmlrpc
{
$ar = $o->me;
reset($ar);
-
+
list($typ, $val) = each($ar);
$rs = "<value>\n".$this->serializedata($typ, $val)."</value>\n";
return $rs;
}
-
+
function scalarval()
{
reset($this->me);
@@ -1409,11 +1409,11 @@ class XML_RPC_Values extends CI_Xmlrpc
//-------------------------------------
// Encode time in ISO-8601 form.
//-------------------------------------
-
+
// Useful for sending time in XML-RPC
function iso8601_encode($time, $utc=0)
- {
+ {
if ($utc == 1)
{
$t = strftime("%Y%m%dT%H:%M:%S", $time);
@@ -1427,7 +1427,7 @@ class XML_RPC_Values extends CI_Xmlrpc
}
return $t;
}
-
+
}
// END XML_RPC_Values Class
diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php
index c1fe649f9..56fd655df 100644
--- a/system/libraries/Xmlrpcs.php
+++ b/system/libraries/Xmlrpcs.php
@@ -14,7 +14,7 @@
*/
if ( ! function_exists('xml_parser_create'))
-{
+{
show_error('Your PHP installation does not support XML');
}
@@ -36,11 +36,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 $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 $system_methods = array(); // XML RPC Server methods
var $controller_obj;
-
+
var $object = FALSE;
@@ -49,49 +49,49 @@ class CI_Xmlrpcs extends CI_Xmlrpc
//-------------------------------------
function CI_Xmlrpcs($config=array())
- {
+ {
parent::CI_Xmlrpc();
$this->set_system_methods();
-
+
if (isset($config['functions']) && is_array($config['functions']))
{
$this->methods = array_merge($this->methods, $config['functions']);
}
-
+
log_message('debug', "XML-RPC Server Class Initialized");
}
-
+
//-------------------------------------
// Initialize Prefs and Serve
//-------------------------------------
-
+
function initialize($config=array())
- {
+ {
if (isset($config['functions']) && is_array($config['functions']))
{
$this->methods = array_merge($this->methods, $config['functions']);
}
-
+
if (isset($config['debug']))
{
$this->debug = $config['debug'];
}
-
+
if (isset($config['object']) && is_object($config['object']))
{
$this->object = $config['object'];
}
-
+
if (isset($config['xss_clean']))
{
$this->xss_clean = $config['xss_clean'];
}
}
-
+
//-------------------------------------
// Setting of System Methods
//-------------------------------------
-
+
function set_system_methods ()
{
$this->methods = array(
@@ -118,14 +118,14 @@ class CI_Xmlrpcs extends CI_Xmlrpc
//-------------------------------------
// Main Server Function
//-------------------------------------
-
+
function serve()
{
$r = $this->parseRequest();
$payload = '<?xml version="1.0" encoding="'.$this->xmlrpc_defencoding.'"?'.'>'."\n";
$payload .= $this->debug_msg;
$payload .= $r->prepare_response();
-
+
header("Content-Type: text/xml");
header("Content-Length: ".strlen($payload));
exit($payload);
@@ -134,7 +134,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
//-------------------------------------
// Add Method to Class
//-------------------------------------
-
+
function add_to_map($methodname,$function,$sig,$doc)
{
$this->methods[$methodname] = array(
@@ -148,11 +148,11 @@ class CI_Xmlrpcs extends CI_Xmlrpc
//-------------------------------------
// Parse Server Request
//-------------------------------------
-
+
function parseRequest($data='')
{
global $HTTP_RAW_POST_DATA;
-
+
//-------------------------------------
// Get Data
//-------------------------------------
@@ -165,10 +165,10 @@ class CI_Xmlrpcs extends CI_Xmlrpc
//-------------------------------------
// Set up XML Parser
//-------------------------------------
-
+
$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'] = '';
@@ -182,12 +182,12 @@ class CI_Xmlrpcs extends CI_Xmlrpc
xml_set_element_handler($parser, 'open_tag', 'closing_tag');
xml_set_character_data_handler($parser, 'character_data');
//xml_set_default_handler($parser, 'default_handler');
-
-
+
+
//-------------------------------------
// PARSE + PROCESS XML DATA
- //-------------------------------------
-
+ //-------------------------------------
+
if ( ! xml_parse($parser, $data, 1))
{
// return XML error as a faultCode
@@ -205,53 +205,53 @@ class CI_Xmlrpcs extends CI_Xmlrpc
else
{
xml_parser_free($parser);
-
+
$m = new XML_RPC_Message($parser_object->xh[$parser]['method']);
$plist='';
-
+
for($i=0; $i < count($parser_object->xh[$parser]['params']); $i++)
{
if ($this->debug === TRUE)
{
$plist .= "$i - " . print_r(get_object_vars($parser_object->xh[$parser]['params'][$i]), TRUE). ";\n";
}
-
+
$m->addParam($parser_object->xh[$parser]['params'][$i]);
}
-
+
if ($this->debug === TRUE)
{
echo "<pre>";
echo "---PLIST---\n" . $plist . "\n---PLIST END---\n\n";
echo "</pre>";
}
-
+
$r = $this->_execute($m);
}
-
+
//-------------------------------------
// SET DEBUGGING MESSAGE
- //-------------------------------------
-
+ //-------------------------------------
+
if ($this->debug === TRUE)
{
$this->debug_msg = "<!-- DEBUG INFO:\n\n".$plist."\n END DEBUG-->\n";
}
-
+
return $r;
}
//-------------------------------------
// Executes the Method
//-------------------------------------
-
+
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;
-
+
if ($this->xss_clean == FALSE)
{
$m->xss_clean = FALSE;
@@ -260,19 +260,19 @@ class CI_Xmlrpcs extends CI_Xmlrpc
//-------------------------------------
// Valid Method
//-------------------------------------
-
+
if ( ! isset($this->methods[$methName]['function']))
{
return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']);
}
-
+
//-------------------------------------
// Check for Method (and Object)
//-------------------------------------
-
+
$method_parts = explode(".", $this->methods[$methName]['function']);
$objectCall = (isset($method_parts['1']) && $method_parts['1'] != "") ? TRUE : FALSE;
-
+
if ($system_call === TRUE)
{
if ( ! is_callable(array($this,$method_parts['1'])))
@@ -291,30 +291,30 @@ class CI_Xmlrpcs extends CI_Xmlrpc
return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']);
}
}
-
+
//-------------------------------------
// Checking Methods Signature
//-------------------------------------
-
+
if (isset($this->methods[$methName]['signature']))
{
$sig = $this->methods[$methName]['signature'];
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++)
{
$p = $m->params[$n];
$pt = ($p->kindOf() == 'scalar') ? $p->scalarval() : $p->kindOf();
-
+
if ($pt != $current_sig[$n+1])
{
$pno = $n+1;
$wanted = $current_sig[$n+1];
-
+
return new XML_RPC_Response(0,
$this->xmlrpcerr['incorrect_params'],
$this->xmlrpcstr['incorrect_params'] .
@@ -354,22 +354,22 @@ class CI_Xmlrpcs extends CI_Xmlrpc
return call_user_func($this->methods[$methName]['function'], $m);
}
}
-
-
+
+
//-------------------------------------
// Server Function: List Methods
//-------------------------------------
-
+
function listMethods($m)
{
$v = new XML_RPC_Values();
$output = array();
-
+
foreach($this->methods as $key => $value)
{
$output[] = new XML_RPC_Values($key, 'string');
}
-
+
foreach($this->system_methods as $key => $value)
{
$output[]= new XML_RPC_Values($key, 'string');
@@ -378,23 +378,23 @@ class CI_Xmlrpcs extends CI_Xmlrpc
$v->addArray($output);
return new XML_RPC_Response($v);
}
-
+
//-------------------------------------
// Server Function: Return Signature for Method
//-------------------------------------
-
+
function methodSignature($m)
{
$parameters = $m->output_parameters();
$method_name = $parameters[0];
-
+
if (isset($this->methods[$method_name]))
{
if ($this->methods[$method_name]['signature'])
{
$sigs = array();
$signature = $this->methods[$method_name]['signature'];
-
+
for($i=0; $i < count($signature); $i++)
{
$cursig = array();
@@ -418,20 +418,20 @@ class CI_Xmlrpcs extends CI_Xmlrpc
}
return $r;
}
-
+
//-------------------------------------
// Server Function: Doc String for Method
//-------------------------------------
-
+
function methodHelp($m)
{
$parameters = $m->output_parameters();
$method_name = $parameters[0];
-
+
if (isset($this->methods[$method_name]))
{
$docstring = isset($this->methods[$method_name]['docstring']) ? $this->methods[$method_name]['docstring'] : '';
-
+
return new XML_RPC_Response(new XML_RPC_Values($docstring, 'string'));
}
else
@@ -448,7 +448,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
{
// Disabled
return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']);
-
+
$parameters = $m->output_parameters();
$calls = $parameters[0];
@@ -457,15 +457,15 @@ class CI_Xmlrpcs extends CI_Xmlrpc
foreach ($calls as $value)
{
//$attempt = $this->_execute(new XML_RPC_Message($value[0], $value[1]));
-
+
$m = new XML_RPC_Message($value[0]);
$plist='';
-
+
for($i=0; $i < count($value[1]); $i++)
{
$m->addParam(new XML_RPC_Values($value[1][$i], 'string'));
}
-
+
$attempt = $this->_execute($m);
if ($attempt->faultCode() != 0)
@@ -478,8 +478,8 @@ class CI_Xmlrpcs extends CI_Xmlrpc
return new XML_RPC_Response(new XML_RPC_Values($result, 'array'));
}
-
-
+
+
//-------------------------------------
// Multi-call Function: Error Handling
//-------------------------------------
@@ -488,28 +488,28 @@ class CI_Xmlrpcs extends CI_Xmlrpc
{
$str = is_string($err) ? $this->xmlrpcstr["multicall_${err}"] : $err->faultString();
$code = is_string($err) ? $this->xmlrpcerr["multicall_${err}"] : $err->faultCode();
-
+
$struct['faultCode'] = new XML_RPC_Values($code, 'int');
$struct['faultString'] = new XML_RPC_Values($str, 'string');
-
+
return new XML_RPC_Values($struct, 'struct');
}
-
-
+
+
//-------------------------------------
// Multi-call Function: Processes method
//-------------------------------------
-
+
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')
@@ -518,7 +518,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
return $this->multicall_error('noparams');
elseif ($params->kindOf() != 'array')
return $this->multicall_error('notarray');
-
+
list($a,$b)=each($params->me);
$numParams = count($b);
@@ -536,8 +536,8 @@ class CI_Xmlrpcs extends CI_Xmlrpc
}
return new XML_RPC_Values(array($result->value()), 'array');
- }
-
+ }
+
}
// END XML_RPC_Server class
diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php
index 92dfc814d..da3e5eb63 100644
--- a/system/libraries/Zip.php
+++ b/system/libraries/Zip.php
@@ -32,17 +32,17 @@
*/
class CI_Zip {
- var $zipdata = '';
- var $directory = '';
- var $entries = 0;
- var $file_num = 0;
+ var $zipdata = '';
+ var $directory = '';
+ var $entries = 0;
+ var $file_num = 0;
var $offset = 0;
var $now;
function CI_Zip()
{
log_message('debug', "Zip Compression Class Initialized");
-
+
$this->now = time();
}
@@ -72,24 +72,24 @@ class CI_Zip {
}
}
- // --------------------------------------------------------------------
+ // --------------------------------------------------------------------
/**
* Get file/directory modification time
- *
+ *
* If this is a newly created file/dir, we will set the time to 'now'
*
* @param string path to file
- * @return array filemtime/filemdate
+ * @return array filemtime/filemdate
*/
function _get_mod_time($dir)
{
// filemtime() will return false, but it does raise an error.
- $date = (@filemtime($dir)) ? filemtime($dir) : getdate($this->now);
+ $date = (@filemtime($dir)) ? filemtime($dir) : getdate($this->now);
$time['file_mtime'] = ($date['hours'] << 11) + ($date['minutes'] << 5) + $date['seconds'] / 2;
$time['file_mdate'] = (($date['year'] - 1980) << 9) + ($date['mon'] << 5) + $date['mday'];
-
+
return $time;
}
@@ -103,7 +103,7 @@ class CI_Zip {
* @return void
*/
function _add_dir($dir, $file_mtime, $file_mdate)
- {
+ {
$dir = str_replace("\\", "/", $dir);
$this->zipdata .=
@@ -140,7 +140,7 @@ class CI_Zip {
$this->offset = strlen($this->zipdata);
$this->entries++;
}
-
+
// --------------------------------------------------------------------
/**
@@ -154,14 +154,14 @@ class CI_Zip {
* @param mixed
* @param string
* @return void
- */
+ */
function add_data($filepath, $data = NULL)
- {
+ {
if (is_array($filepath))
{
foreach ($filepath as $path => $data)
{
- $file_data = $this->_get_mod_time($path);
+ $file_data = $this->_get_mod_time($path);
$this->_add_data($path, $data, $file_data['file_mtime'], $file_data['file_mdate']);
}
@@ -169,7 +169,7 @@ class CI_Zip {
else
{
$file_data = $this->_get_mod_time($filepath);
-
+
$this->_add_data($filepath, $data, $file_data['file_mtime'], $file_data['file_mdate']);
}
}
@@ -183,7 +183,7 @@ class CI_Zip {
* @param string the file name/path
* @param string the data to be encoded
* @return void
- */
+ */
function _add_data($filepath, $data, $file_mtime, $file_mdate)
{
$filepath = str_replace("\\", "/", $filepath);
@@ -227,7 +227,7 @@ class CI_Zip {
$this->entries++;
$this->file_num++;
}
-
+
// --------------------------------------------------------------------
/**
@@ -235,7 +235,7 @@ class CI_Zip {
*
* @access public
* @return bool
- */
+ */
function read_file($path, $preserve_filepath = FALSE)
{
if ( ! file_exists($path))
@@ -246,7 +246,7 @@ class CI_Zip {
if (FALSE !== ($data = file_get_contents($path)))
{
$name = str_replace("\\", "/", $path);
-
+
if ($preserve_filepath === FALSE)
{
$name = preg_replace("|.*/(.+)|", "\\1", $name);
@@ -259,7 +259,7 @@ class CI_Zip {
}
// ------------------------------------------------------------------------
-
+
/**
* Read a directory and add it to the zip.
*
@@ -321,7 +321,7 @@ class CI_Zip {
*
* @access public
* @return binary string
- */
+ */
function get_zip()
{
// Is there any data to return?
@@ -340,7 +340,7 @@ class CI_Zip {
return $zip_data;
}
-
+
// --------------------------------------------------------------------
/**
@@ -351,7 +351,7 @@ class CI_Zip {
* @access public
* @param string the file name
* @return bool
- */
+ */
function archive($filepath)
{
if ( ! ($fp = @fopen($filepath, FOPEN_WRITE_CREATE_DESTRUCTIVE)))
@@ -359,12 +359,12 @@ class CI_Zip {
return FALSE;
}
- flock($fp, LOCK_EX);
+ flock($fp, LOCK_EX);
fwrite($fp, $this->get_zip());
flock($fp, LOCK_UN);
fclose($fp);
- return TRUE;
+ return TRUE;
}
// --------------------------------------------------------------------
@@ -404,7 +404,7 @@ class CI_Zip {
*
* @access public
* @return void
- */
+ */
function clear_data()
{
$this->zipdata = '';
@@ -413,7 +413,7 @@ class CI_Zip {
$this->file_num = 0;
$this->offset = 0;
}
-
+
}
/* End of file Zip.php */
diff --git a/system/libraries/javascript/Jquery.php b/system/libraries/javascript/Jquery.php
index f6b8dce69..db80c1428 100644
--- a/system/libraries/javascript/Jquery.php
+++ b/system/libraries/javascript/Jquery.php
@@ -173,7 +173,7 @@ class CI_Jquery extends CI_Javascript {
* @param string - element
* @param string - Javascript code for mouse over
* @param string - Javascript code for mouse out
- * @return string
+ * @return string
*/
function _hover($element = 'this', $over, $out)
{
@@ -390,7 +390,7 @@ class CI_Jquery extends CI_Javascript {
*
* @access private
* @param string - element
- * @return string
+ * @return string
*/
function _addClass($element = 'this', $class='')
{
@@ -410,7 +410,7 @@ class CI_Jquery extends CI_Javascript {
* @param string - element
* @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
* @param string - Javascript callback function
- * @return string
+ * @return string
*/
function _animate($element = 'this', $params = array(), $speed = '', $extra = '')
{
@@ -452,7 +452,7 @@ class CI_Jquery extends CI_Javascript {
* @param string - element
* @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
* @param string - Javascript callback function
- * @return string
+ * @return string
*/
function _fadeIn($element = 'this', $speed = '', $callback = '')
{
@@ -480,7 +480,7 @@ class CI_Jquery extends CI_Javascript {
* @param string - element
* @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
* @param string - Javascript callback function
- * @return string
+ * @return string
*/
function _fadeOut($element = 'this', $speed = '', $callback = '')
{
@@ -508,7 +508,7 @@ class CI_Jquery extends CI_Javascript {
* @param string - element
* @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
* @param string - Javascript callback function
- * @return string
+ * @return string
*/
function _hide($element = 'this', $speed = '', $callback = '')
{
@@ -534,7 +534,7 @@ class CI_Jquery extends CI_Javascript {
*
* @access private
* @param string - element
- * @return string
+ * @return string
*/
function _removeClass($element = 'this', $class='')
{
@@ -554,7 +554,7 @@ class CI_Jquery extends CI_Javascript {
* @param string - element
* @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
* @param string - Javascript callback function
- * @return string
+ * @return string
*/
function _slideUp($element = 'this', $speed = '', $callback = '')
{
@@ -582,7 +582,7 @@ class CI_Jquery extends CI_Javascript {
* @param string - element
* @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
* @param string - Javascript callback function
- * @return string
+ * @return string
*/
function _slideDown($element = 'this', $speed = '', $callback = '')
{
@@ -610,7 +610,7 @@ class CI_Jquery extends CI_Javascript {
* @param string - element
* @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
* @param string - Javascript callback function
- * @return string
+ * @return string
*/
function _slideToggle($element = 'this', $speed = '', $callback = '')
{
@@ -636,7 +636,7 @@ class CI_Jquery extends CI_Javascript {
*
* @access private
* @param string - element
- * @return string
+ * @return string
*/
function _toggle($element = 'this')
{
@@ -654,7 +654,7 @@ class CI_Jquery extends CI_Javascript {
*
* @access private
* @param string - element
- * @return string
+ * @return string
*/
function _toggleClass($element = 'this', $class='')
{
@@ -674,7 +674,7 @@ class CI_Jquery extends CI_Javascript {
* @param string - element
* @param string - One of 'slow', 'normal', 'fast', or time in milliseconds
* @param string - Javascript callback function
- * @return string
+ * @return string
*/
function _show($element = 'this', $speed = '', $callback = '')
{
@@ -884,7 +884,7 @@ class CI_Jquery extends CI_Javascript {
}
// --------------------------------------------------------------------
-
+
/**
* Table Sorter Plugin
*