summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
Diffstat (limited to 'system')
-rwxr-xr-xsystem/core/CodeIgniter.php8
-rwxr-xr-xsystem/core/Config.php2
-rwxr-xr-xsystem/core/Hooks.php2
-rwxr-xr-xsystem/core/Output.php2
-rwxr-xr-xsystem/core/Security.php2
-rw-r--r--system/database/DB_active_rec.php14
-rw-r--r--system/database/DB_driver.php46
-rw-r--r--system/database/DB_forge.php6
-rw-r--r--system/database/drivers/mysql/mysql_driver.php12
-rw-r--r--system/database/drivers/oci8/oci8_driver.php9
-rw-r--r--system/database/drivers/oci8/oci8_result.php4
-rw-r--r--system/database/drivers/pdo/pdo_driver.php9
-rw-r--r--system/database/drivers/postgre/postgre_forge.php6
-rw-r--r--system/database/drivers/sqlsrv/sqlsrv_driver.php2
-rw-r--r--system/helpers/date_helper.php70
-rw-r--r--system/helpers/form_helper.php2
-rw-r--r--system/helpers/inflector_helper.php108
-rw-r--r--system/helpers/smiley_helper.php2
-rw-r--r--system/libraries/Cache/Cache.php2
-rw-r--r--system/libraries/Calendar.php147
-rw-r--r--system/libraries/Cart.php182
-rw-r--r--system/libraries/Driver.php15
-rw-r--r--system/libraries/Email.php478
-rw-r--r--system/libraries/Form_validation.php21
-rw-r--r--system/libraries/Ftp.php102
-rw-r--r--system/libraries/Image_lib.php186
-rw-r--r--system/libraries/Log.php28
-rw-r--r--system/libraries/Migration.php24
-rw-r--r--system/libraries/Pagination.php93
-rw-r--r--system/libraries/Parser.php40
-rw-r--r--system/libraries/Trackback.php54
-rw-r--r--system/libraries/Upload.php14
-rw-r--r--system/libraries/Zip.php6
33 files changed, 780 insertions, 918 deletions
diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php
index 4d76a5587..97527e5ca 100755
--- a/system/core/CodeIgniter.php
+++ b/system/core/CodeIgniter.php
@@ -106,9 +106,13 @@
* Set a liberal script execution time limit
* ------------------------------------------------------
*/
- if (function_exists("set_time_limit") == TRUE AND @ini_get("safe_mode") == 0)
+ if (function_exists("set_time_limit") AND @ini_get("safe_mode") == 0)
{
- @set_time_limit(300);
+ // Do not override the Time Limit value if running from Command Line
+ if(php_sapi_name() != 'cli')
+ {
+ @set_time_limit(300);
+ }
}
/*
diff --git a/system/core/Config.php b/system/core/Config.php
index 4ad24ab70..5106284e0 100755
--- a/system/core/Config.php
+++ b/system/core/Config.php
@@ -328,7 +328,7 @@ class CI_Config {
$uri = $str;
}
}
- return $uri;
+ return $uri;
}
// --------------------------------------------------------------------
diff --git a/system/core/Hooks.php b/system/core/Hooks.php
index 46bfec02a..aa251a389 100755
--- a/system/core/Hooks.php
+++ b/system/core/Hooks.php
@@ -94,7 +94,7 @@ class CI_Hooks {
if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/hooks.php'))
{
- include(APPPATH.'config/'.ENVIRONMENT.'/hooks.php');
+ include(APPPATH.'config/'.ENVIRONMENT.'/hooks.php');
}
elseif (is_file(APPPATH.'config/hooks.php'))
{
diff --git a/system/core/Output.php b/system/core/Output.php
index 7b53f8e3e..9727a184f 100755
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -108,7 +108,7 @@ class CI_Output {
// Get mime types for later
if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'))
{
- include APPPATH.'config/'.ENVIRONMENT.'/mimes.php';
+ include APPPATH.'config/'.ENVIRONMENT.'/mimes.php';
}
else
{
diff --git a/system/core/Security.php b/system/core/Security.php
index ce3f7d3cc..60a64f358 100755
--- a/system/core/Security.php
+++ b/system/core/Security.php
@@ -182,7 +182,7 @@ class CI_Security {
// Nothing should last forever
unset($_COOKIE[$this->_csrf_cookie_name]);
- $this->_csrf_hash = '';
+ $this->_csrf_hash = '';
$this->_csrf_set_hash();
$this->csrf_set_cookie();
diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php
index 5c4284ff2..1f77e41d7 100644
--- a/system/database/DB_active_rec.php
+++ b/system/database/DB_active_rec.php
@@ -75,7 +75,7 @@ class CI_DB_active_record extends CI_DB_driver {
protected $ar_cache_set = array();
protected $ar_no_escape = array();
- protected $ar_cache_no_escape = array();
+ protected $ar_cache_no_escape = array();
// --------------------------------------------------------------------
@@ -831,9 +831,10 @@ class CI_DB_active_record extends CI_DB_driver {
*
* @param string
* @param string direction: asc or desc
+ * @param bool enable field name escaping
* @return object
*/
- public function order_by($orderby, $direction = '')
+ public function order_by($orderby, $direction = '', $escape = TRUE)
{
if (strtolower($direction) == 'random')
{
@@ -846,7 +847,7 @@ class CI_DB_active_record extends CI_DB_driver {
}
- if (strpos($orderby, ',') !== FALSE)
+ if ((strpos($orderby, ',') !== FALSE) && ($escape === TRUE))
{
$temp = array();
foreach (explode(',', $orderby) as $part)
@@ -864,7 +865,10 @@ class CI_DB_active_record extends CI_DB_driver {
}
else if ($direction != $this->_random_keyword)
{
- $orderby = $this->_protect_identifiers($orderby);
+ if ($escape === TRUE)
+ {
+ $orderby = $this->_protect_identifiers($orderby);
+ }
}
$orderby_statement = $orderby.$direction;
@@ -1425,7 +1429,7 @@ class CI_DB_active_record extends CI_DB_driver {
$this->limit($limit);
}
- $sql = $this->_update($this->_protect_identifiers($this->ar_from[0], TRUE, NULL, FALSE), $this->ar_set, $this->ar_where, $this->ar_orderby, $this->ar_limit);
+ $sql = $this->_update($this->_protect_identifiers($this->ar_from[0], TRUE, NULL, FALSE), $this->ar_set, $this->ar_where, $this->ar_orderby, $this->ar_limit, $this->ar_like);
$this->_reset_write();
return $this->query($sql);
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index cc40ba48a..9d92f2f87 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -126,16 +126,43 @@ class CI_DB_driver {
// Connect to the database and set the connection ID
$this->conn_id = ($this->pconnect == FALSE) ? $this->db_connect() : $this->db_pconnect();
- // No connection resource? Throw an error
+ // No connection resource? Check if there is a failover else throw an error
if ( ! $this->conn_id)
{
- log_message('error', 'Unable to connect to the database');
+ // Check if there is a failover set
+ if ( ! empty($this->failover) && is_array($this->failover))
+ {
+ // Go over all the failovers
+ foreach ($this->failover as $failover)
+ {
+ // Replace the current settings with those of the failover
+ foreach ($failover as $key => $val)
+ {
+ $this->$key = $val;
+ }
- if ($this->db_debug)
+ // Try to connect
+ $this->conn_id = ($this->pconnect == FALSE) ? $this->db_connect() : $this->db_pconnect();
+
+ // If a connection is made break the foreach loop
+ if ($this->conn_id)
+ {
+ break;
+ }
+ }
+ }
+
+ // We still don't have a connection?
+ if ( ! $this->conn_id)
{
- $this->display_error('db_unable_to_connect');
+ log_message('error', 'Unable to connect to the database');
+
+ if ($this->db_debug)
+ {
+ $this->display_error('db_unable_to_connect');
+ }
+ return FALSE;
}
- return FALSE;
}
// ----------------------------------------------------------------
@@ -1037,7 +1064,14 @@ class CI_DB_driver {
{
$args = (func_num_args() > 1) ? array_splice(func_get_args(), 1) : null;
- return call_user_func_array($function, $args);
+ if (is_null($args))
+ {
+ return call_user_func($function);
+ }
+ else
+ {
+ return call_user_func_array($function, $args);
+ }
}
}
diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php
index 1aa2334ea..78bf77a9f 100644
--- a/system/database/DB_forge.php
+++ b/system/database/DB_forge.php
@@ -205,6 +205,12 @@ class CI_DB_forge {
$sql = $this->_create_table($this->db->dbprefix.$table, $this->fields, $this->primary_keys, $this->keys, $if_not_exists);
$this->_reset();
+
+ if (is_bool($sql))
+ {
+ return $sql;
+ }
+
return $this->db->query($sql);
}
diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php
index 828ef006b..6ded6e531 100644
--- a/system/database/drivers/mysql/mysql_driver.php
+++ b/system/database/drivers/mysql/mysql_driver.php
@@ -606,7 +606,7 @@ class CI_DB_mysql_driver extends CI_DB {
* @param array the limit clause
* @return string
*/
- function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
+ function _update($table, $values, $where, $orderby = array(), $limit = FALSE, $like = array())
{
foreach ($values as $key => $val)
{
@@ -620,6 +620,16 @@ class CI_DB_mysql_driver extends CI_DB {
$sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
$sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
+
+ if (count($like) > 0)
+ {
+ $sql .= ($where == '' AND count($where) <1) ? " WHERE " : ' AND ';
+
+ foreach ($like as $st_like)
+ {
+ $sql .= " " . $st_like;
+ }
+ }
$sql .= $orderby.$limit;
diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php
index 190b86bb2..9c38dcbd6 100644
--- a/system/database/drivers/oci8/oci8_driver.php
+++ b/system/database/drivers/oci8/oci8_driver.php
@@ -661,11 +661,10 @@ class CI_DB_oci8_driver extends CI_DB {
*
* Generates a platform-specific insert string from the supplied data
*
- * @access protected
- * @param string the table name
- * @param array the insert keys
- * @param array the insert values
- * @return string
+ * @param string the table name
+ * @param array the insert keys
+ * @param array the insert values
+ * @return string
*/
protected function _insert_batch($table, $keys, $values)
{
diff --git a/system/database/drivers/oci8/oci8_result.php b/system/database/drivers/oci8/oci8_result.php
index 3ec71a9d6..f32559289 100644
--- a/system/database/drivers/oci8/oci8_result.php
+++ b/system/database/drivers/oci8/oci8_result.php
@@ -57,11 +57,11 @@ class CI_DB_oci8_result extends CI_DB_result {
if ($this->num_rows === 0 && count($this->result_array()) > 0)
{
$this->num_rows = count($this->result_array());
- @oci_execute($this->stmt_id);
+ @oci_execute($this->stmt_id, OCI_DEFAULT);
if ($this->curs_id)
{
- @oci_execute($this->curs_id);
+ @oci_execute($this->curs_id, OCI_DEFAULT);
}
}
diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php
index 5f63a3771..457cf714a 100644
--- a/system/database/drivers/pdo/pdo_driver.php
+++ b/system/database/drivers/pdo/pdo_driver.php
@@ -90,7 +90,10 @@ class CI_DB_pdo_driver extends CI_DB {
$this->_like_escape_chr = '!';
}
- $this->hostname .= ";dbname=".$this->database;
+ if (strpos($this->hostname, 'sqlite') === FALSE)
+ {
+ $this->hostname .= ";dbname=".$this->database;
+ }
$this->trans_enabled = FALSE;
@@ -255,11 +258,7 @@ class CI_DB_pdo_driver extends CI_DB {
// Reset the transaction failure flag.
// If the $test_mode flag is set to TRUE transactions will be rolled back
// even if the queries produce a successful result.
-<<<<<<< HEAD
- $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
-=======
$this->_trans_failure = (bool) ($test_mode === TRUE);
->>>>>>> master
return $this->conn_id->beginTransaction();
}
diff --git a/system/database/drivers/postgre/postgre_forge.php b/system/database/drivers/postgre/postgre_forge.php
index 166cc4e6a..f86ba2dda 100644
--- a/system/database/drivers/postgre/postgre_forge.php
+++ b/system/database/drivers/postgre/postgre_forge.php
@@ -81,9 +81,10 @@ class CI_DB_postgre_forge extends CI_DB_forge {
if ($if_not_exists === TRUE)
{
+ // PostgreSQL doesn't support IF NOT EXISTS syntax so we check if table exists manually
if ($this->db->table_exists($table))
{
- return "SELECT * FROM $table"; // Needs to return innocous but valid SQL statement
+ return TRUE;
}
}
@@ -224,9 +225,6 @@ class CI_DB_postgre_forge extends CI_DB_forge {
/**
* Drop Table
- *
- * @access private
- * @return bool
*/
function _drop_table($table)
{
diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php
index 0f9f57836..340cd3a66 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_driver.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php
@@ -98,7 +98,7 @@ class CI_DB_sqlsrv_driver extends CI_DB {
*/
function db_pconnect()
{
- $this->db_connect(TRUE);
+ return $this->db_connect(TRUE);
}
// --------------------------------------------------------------------
diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php
index 07e3c1458..b0d79bea5 100644
--- a/system/helpers/date_helper.php
+++ b/system/helpers/date_helper.php
@@ -5,9 +5,9 @@
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -96,14 +96,14 @@ if ( ! function_exists('mdate'))
{
if ($datestr == '')
{
- return '';
+ return '';
}
$time = ($time == '') ? now() : $time;
$datestr = str_replace(
- '%\\',
- '',
+ '%\\',
+ '',
preg_replace("/([a-z]+?){1}/i", "\\\\\\1", $datestr)
);
@@ -182,15 +182,15 @@ if ( ! function_exists('timespan'))
$seconds = ($time <= $seconds) ? 1 : $time - $seconds;
$str = '';
- $years = floor($seconds / 31536000);
+ $years = floor($seconds / 31557600);
if ($years > 0)
{
$str .= $years.' '.$CI->lang->line((($years > 1) ? 'date_years' : 'date_year')).', ';
}
- $seconds -= $years * 31536000;
- $months = floor($seconds / 2628000);
+ $seconds -= $years * 31557600;
+ $months = floor($seconds / 2629743);
if ($years > 0 OR $months > 0)
{
@@ -199,7 +199,7 @@ if ( ! function_exists('timespan'))
$str .= $months.' '.$CI->lang->line((($months > 1) ? 'date_months' : 'date_month')).', ';
}
- $seconds -= $months * 2628000;
+ $seconds -= $months * 2629743;
}
$weeks = floor($seconds / 604800);
@@ -316,13 +316,13 @@ if ( ! function_exists('local_to_gmt'))
{
$time = time();
}
-
+
return mktime(
- gmdate("H", $time),
- gmdate("i", $time),
- gmdate("s", $time),
- gmdate("m", $time),
- gmdate("d", $time),
+ gmdate("H", $time),
+ gmdate("i", $time),
+ gmdate("s", $time),
+ gmdate("m", $time),
+ gmdate("d", $time),
gmdate("Y", $time)
);
}
@@ -495,17 +495,17 @@ if ( ! function_exists('human_to_unix'))
if (substr($ampm, 0, 1) == 'p' AND $hour < 12)
{
- $hour = $hour + 12;
+ $hour = $hour + 12;
}
if (substr($ampm, 0, 1) == 'a' AND $hour == 12)
{
$hour = '00';
}
-
+
if (strlen($hour) == 1)
{
- $hour = '0'.$hour;
+ $hour = '0'.$hour;
}
}
@@ -518,7 +518,7 @@ if ( ! function_exists('human_to_unix'))
/**
* Turns many "reasonably-date-like" strings into something
* that is actually useful. This only works for dates after unix epoch.
- *
+ *
* @access public
* @param string The terribly formatted date-like string
* @param string Date format to return (same as php date function)
@@ -526,7 +526,7 @@ if ( ! function_exists('human_to_unix'))
*/
if ( ! function_exists('nice_date'))
{
- function nice_date($bad_date = '', $format = FALSE)
+ function nice_date($bad_date = '', $format = FALSE)
{
if (empty($bad_date))
{
@@ -534,47 +534,47 @@ if ( ! function_exists('nice_date'))
}
// Date like: YYYYMM
- if (preg_match('/^\d{6}$/', $bad_date))
+ if (preg_match('/^\d{6}$/', $bad_date))
{
- if (in_array(substr($bad_date, 0, 2),array('19', '20')))
+ if (in_array(substr($bad_date, 0, 2),array('19', '20')))
{
$year = substr($bad_date, 0, 4);
$month = substr($bad_date, 4, 2);
- }
- else
+ }
+ else
{
$month = substr($bad_date, 0, 2);
$year = substr($bad_date, 2, 4);
}
-
+
return date($format, strtotime($year . '-' . $month . '-01'));
}
-
+
// Date Like: YYYYMMDD
- if (preg_match('/^\d{8}$/',$bad_date))
+ if (preg_match('/^\d{8}$/',$bad_date))
{
$month = substr($bad_date, 0, 2);
$day = substr($bad_date, 2, 2);
$year = substr($bad_date, 4, 4);
-
+
return date($format, strtotime($month . '/01/' . $year));
}
-
+
// Date Like: MM-DD-YYYY __or__ M-D-YYYY (or anything in between)
if (preg_match('/^\d{1,2}-\d{1,2}-\d{4}$/',$bad_date))
- {
+ {
list($m, $d, $y) = explode('-', $bad_date);
return date($format, strtotime("{$y}-{$m}-{$d}"));
}
-
+
// Any other kind of string, when converted into UNIX time,
// produces "0 seconds after epoc..." is probably bad...
// return "Invalid Date".
if (date('U', strtotime($bad_date)) == '0')
- {
+ {
return "Invalid Date";
}
-
+
// It's probably a valid-ish date format already
return date($format, strtotime($bad_date));
}
@@ -689,9 +689,9 @@ if ( ! function_exists('timezones'))
{
return $zones;
}
-
+
$tz = ($tz == 'GMT') ? 'UTC' : $tz;
-
+
return ( ! isset($zones[$tz])) ? 0 : $zones[$tz];
}
}
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index 0f02bcf75..347e8be90 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -1000,7 +1000,7 @@ if ( ! function_exists('_attributes_to_string'))
$attributes = (array)$attributes;
}
- if (is_array($attributes) AND count($attributes) > 0)
+ if (is_array($attributes) AND ($formtag === TRUE OR count($attributes) > 0))
{
$atts = '';
diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php
index 513a9c54f..7c5082192 100644
--- a/system/helpers/inflector_helper.php
+++ b/system/helpers/inflector_helper.php
@@ -5,9 +5,9 @@
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -56,35 +56,35 @@ if ( ! function_exists('singular'))
$result = strval($str);
$singular_rules = array(
- '/(matr)ices$/' => '\1ix',
- '/(vert|ind)ices$/' => '\1ex',
- '/^(ox)en/' => '\1',
- '/(alias)es$/' => '\1',
- '/([octop|vir])i$/' => '\1us',
- '/(cris|ax|test)es$/' => '\1is',
- '/(shoe)s$/' => '\1',
- '/(o)es$/' => '\1',
- '/(bus|campus)es$/' => '\1',
- '/([m|l])ice$/' => '\1ouse',
- '/(x|ch|ss|sh)es$/' => '\1',
- '/(m)ovies$/' => '\1\2ovie',
- '/(s)eries$/' => '\1\2eries',
- '/([^aeiouy]|qu)ies$/' => '\1y',
- '/([lr])ves$/' => '\1f',
- '/(tive)s$/' => '\1',
- '/(hive)s$/' => '\1',
- '/([^f])ves$/' => '\1fe',
- '/(^analy)ses$/' => '\1sis',
+ '/(matr)ices$/' => '\1ix',
+ '/(vert|ind)ices$/' => '\1ex',
+ '/^(ox)en/' => '\1',
+ '/(alias)es$/' => '\1',
+ '/([octop|vir])i$/' => '\1us',
+ '/(cris|ax|test)es$/' => '\1is',
+ '/(shoe)s$/' => '\1',
+ '/(o)es$/' => '\1',
+ '/(bus|campus)es$/' => '\1',
+ '/([m|l])ice$/' => '\1ouse',
+ '/(x|ch|ss|sh)es$/' => '\1',
+ '/(m)ovies$/' => '\1\2ovie',
+ '/(s)eries$/' => '\1\2eries',
+ '/([^aeiouy]|qu)ies$/' => '\1y',
+ '/([lr])ves$/' => '\1f',
+ '/(tive)s$/' => '\1',
+ '/(hive)s$/' => '\1',
+ '/([^f])ves$/' => '\1fe',
+ '/(^analy)ses$/' => '\1sis',
'/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/' => '\1\2sis',
- '/([ti])a$/' => '\1um',
- '/(p)eople$/' => '\1\2erson',
- '/(m)en$/' => '\1an',
- '/(s)tatuses$/' => '\1\2tatus',
- '/(c)hildren$/' => '\1\2hild',
- '/(n)ews$/' => '\1\2ews',
- '/([^u])s$/' => '\1',
+ '/([ti])a$/' => '\1um',
+ '/(p)eople$/' => '\1\2erson',
+ '/(m)en$/' => '\1an',
+ '/(s)tatuses$/' => '\1\2tatus',
+ '/(c)hildren$/' => '\1\2hild',
+ '/(n)ews$/' => '\1\2ews',
+ '/([^u])s$/' => '\1',
);
-
+
foreach ($singular_rules as $rule => $replacement)
{
if (preg_match($rule, $result))
@@ -115,27 +115,27 @@ if ( ! function_exists('plural'))
function plural($str, $force = FALSE)
{
$result = strval($str);
-
+
$plural_rules = array(
- '/^(ox)$/' => '\1\2en', // ox
- '/([m|l])ouse$/' => '\1ice', // mouse, louse
- '/(matr|vert|ind)ix|ex$/' => '\1ices', // matrix, vertex, index
- '/(x|ch|ss|sh)$/' => '\1es', // search, switch, fix, box, process, address
- '/([^aeiouy]|qu)y$/' => '\1ies', // query, ability, agency
- '/(hive)$/' => '\1s', // archive, hive
- '/(?:([^f])fe|([lr])f)$/' => '\1\2ves', // half, safe, wife
- '/sis$/' => 'ses', // basis, diagnosis
- '/([ti])um$/' => '\1a', // datum, medium
- '/(p)erson$/' => '\1eople', // person, salesperson
- '/(m)an$/' => '\1en', // man, woman, spokesman
- '/(c)hild$/' => '\1hildren', // child
- '/(buffal|tomat)o$/' => '\1\2oes', // buffalo, tomato
- '/(bu|campu)s$/' => '\1\2ses', // bus, campus
- '/(alias|status|virus)/' => '\1es', // alias
- '/(octop)us$/' => '\1i', // octopus
- '/(ax|cris|test)is$/' => '\1es', // axis, crisis
- '/s$/' => 's', // no change (compatibility)
- '/$/' => 's',
+ '/^(ox)$/' => '\1\2en', // ox
+ '/([m|l])ouse$/' => '\1ice', // mouse, louse
+ '/(matr|vert|ind)ix|ex$/' => '\1ices', // matrix, vertex, index
+ '/(x|ch|ss|sh)$/' => '\1es', // search, switch, fix, box, process, address
+ '/([^aeiouy]|qu)y$/' => '\1ies', // query, ability, agency
+ '/(hive)$/' => '\1s', // archive, hive
+ '/(?:([^f])fe|([lr])f)$/' => '\1\2ves', // half, safe, wife
+ '/sis$/' => 'ses', // basis, diagnosis
+ '/([ti])um$/' => '\1a', // datum, medium
+ '/(p)erson$/' => '\1eople', // person, salesperson
+ '/(m)an$/' => '\1en', // man, woman, spokesman
+ '/(c)hild$/' => '\1hildren', // child
+ '/(buffal|tomat)o$/' => '\1\2oes', // buffalo, tomato
+ '/(bu|campu)s$/' => '\1\2ses', // bus, campus
+ '/(alias|status|virus)/' => '\1es', // alias
+ '/(octop)us$/' => '\1i', // octopus
+ '/(ax|cris|test)is$/' => '\1es', // axis, crisis
+ '/s$/' => 's', // no change (compatibility)
+ '/$/' => 's',
);
foreach ($plural_rules as $rule => $replacement)
@@ -196,20 +196,20 @@ if ( ! function_exists('underscore'))
/**
* Humanize
*
- * Takes multiple words separated by underscores and changes them to spaces
+ * Takes multiple words separated by the separator and changes them to spaces
*
* @access public
- * @param string
+ * @param string $str
+ * @param string $separator
* @return str
*/
if ( ! function_exists('humanize'))
{
- function humanize($str)
+ function humanize($str, $separator = '_')
{
- return ucwords(preg_replace('/[_]+/', ' ', strtolower(trim($str))));
+ return ucwords(preg_replace('/['.$separator.']+/', ' ', strtolower(trim($str))));
}
}
-
/* End of file inflector_helper.php */
/* Location: ./system/helpers/inflector_helper.php */ \ No newline at end of file
diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php
index 991495ee8..38e2965fc 100644
--- a/system/helpers/smiley_helper.php
+++ b/system/helpers/smiley_helper.php
@@ -243,7 +243,7 @@ if ( ! function_exists('_get_smiley_array'))
{
if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys.php'))
{
- include(APPPATH.'config/'.ENVIRONMENT.'/smileys.php');
+ include(APPPATH.'config/'.ENVIRONMENT.'/smileys.php');
}
elseif (file_exists(APPPATH.'config/smileys.php'))
{
diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php
index 269bf9b2d..c296fa770 100644
--- a/system/libraries/Cache/Cache.php
+++ b/system/libraries/Cache/Cache.php
@@ -155,7 +155,7 @@ class CI_Cache extends CI_Driver_Library {
* @return void
*/
private function _initialize($config)
- {
+ {
$default_config = array(
'adapter',
'memcached'
diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php
index f5ef4d576..605765bf6 100644
--- a/system/libraries/Calendar.php
+++ b/system/libraries/Calendar.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -40,15 +40,15 @@
*/
class CI_Calendar {
- var $CI;
- var $lang;
- var $local_time;
- var $template = '';
- var $start_day = 'sunday';
- var $month_type = 'long';
- var $day_type = 'abr';
- var $show_next_prev = FALSE;
- var $next_prev_url = '';
+ private $CI;
+ public $lang;
+ public $local_time;
+ public $template = '';
+ public $start_day = 'sunday';
+ public $month_type = 'long';
+ public $day_type = 'abr';
+ public $show_next_prev = FALSE;
+ public $next_prev_url = '';
/**
* Constructor
@@ -85,7 +85,7 @@ class CI_Calendar {
* @param array config preferences
* @return void
*/
- function initialize($config = array())
+ public function initialize($config = array())
{
foreach ($config as $key => $val)
{
@@ -107,23 +107,30 @@ class CI_Calendar {
* @param array the data to be shown in the calendar cells
* @return string
*/
- function generate($year = '', $month = '', $data = array())
+ public function generate($year = '', $month = '', $data = array())
{
// Set and validate the supplied month/year
if ($year == '')
- $year = date("Y", $this->local_time);
-
- if ($month == '')
- $month = date("m", $this->local_time);
-
- if (strlen($year) == 1)
+ {
+ $year = date('Y', $this->local_time);
+ }
+ elseif (strlen($year) === 1)
+ {
$year = '200'.$year;
-
- if (strlen($year) == 2)
+ }
+ elseif (strlen($year) === 2)
+ {
$year = '20'.$year;
+ }
- if (strlen($month) == 1)
+ if ($month == '')
+ {
+ $month = date('m', $this->local_time);
+ }
+ elseif (strlen($month) === 1)
+ {
$month = '0'.$month;
+ }
$adjusted_date = $this->adjust_date($month, $year);
@@ -149,9 +156,9 @@ class CI_Calendar {
// Set the current month/year/day
// We use this to determine the "today" date
- $cur_year = date("Y", $this->local_time);
- $cur_month = date("m", $this->local_time);
- $cur_day = date("j", $this->local_time);
+ $cur_year = date('Y', $this->local_time);
+ $cur_month = date('m', $this->local_time);
+ $cur_day = date('j', $this->local_time);
$is_current_month = ($cur_year == $year AND $cur_month == $month) ? TRUE : FALSE;
@@ -159,12 +166,7 @@ class CI_Calendar {
$this->parse_template();
// Begin building the calendar output
- $out = $this->temp['table_open'];
- $out .= "\n";
-
- $out .= "\n";
- $out .= $this->temp['heading_row_start'];
- $out .= "\n";
+ $out = $this->temp['table_open']."\n\n".$this->temp['heading_row_start']."\n";
// "previous" month link
if ($this->show_next_prev == TRUE)
@@ -173,18 +175,16 @@ class CI_Calendar {
$this->next_prev_url = preg_replace("/(.+?)\/*$/", "\\1/", $this->next_prev_url);
$adjusted_date = $this->adjust_date($month - 1, $year);
- $out .= str_replace('{previous_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_previous_cell']);
- $out .= "\n";
+ $out .= str_replace('{previous_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_previous_cell'])."\n";
}
// Heading containing the month/year
$colspan = ($this->show_next_prev == TRUE) ? 5 : 7;
- $this->temp['heading_title_cell'] = str_replace('{colspan}', $colspan, $this->temp['heading_title_cell']);
- $this->temp['heading_title_cell'] = str_replace('{heading}', $this->get_month_name($month)."&nbsp;".$year, $this->temp['heading_title_cell']);
+ $this->temp['heading_title_cell'] = str_replace('{colspan}', $colspan,
+ str_replace('{heading}', $this->get_month_name($month).'&nbsp;'.$year, $this->temp['heading_title_cell']));
- $out .= $this->temp['heading_title_cell'];
- $out .= "\n";
+ $out .= $this->temp['heading_title_cell']."\n";
// "next" month link
if ($this->show_next_prev == TRUE)
@@ -193,14 +193,9 @@ class CI_Calendar {
$out .= str_replace('{next_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_next_cell']);
}
- $out .= "\n";
- $out .= $this->temp['heading_row_end'];
- $out .= "\n";
-
- // Write the cells containing the days of the week
- $out .= "\n";
- $out .= $this->temp['week_row_start'];
- $out .= "\n";
+ $out .= "\n".$this->temp['heading_row_end']."\n\n"
+ // Write the cells containing the days of the week
+ .$this->temp['week_row_start']."\n";
$day_names = $this->get_day_names();
@@ -209,33 +204,31 @@ class CI_Calendar {
$out .= str_replace('{week_day}', $day_names[($start_day + $i) %7], $this->temp['week_day_cell']);
}
- $out .= "\n";
- $out .= $this->temp['week_row_end'];
- $out .= "\n";
+ $out .= "\n".$this->temp['week_row_end']."\n";
// Build the main body of the calendar
while ($day <= $total_days)
{
- $out .= "\n";
- $out .= $this->temp['cal_row_start'];
- $out .= "\n";
+ $out .= "\n".$this->temp['cal_row_start']."\n";
for ($i = 0; $i < 7; $i++)
{
- $out .= ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_start_today'] : $this->temp['cal_cell_start'];
+ $out .= ($is_current_month === TRUE AND $day == $cur_day) ? $this->temp['cal_cell_start_today'] : $this->temp['cal_cell_start'];
if ($day > 0 AND $day <= $total_days)
{
if (isset($data[$day]))
{
// Cells with content
- $temp = ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_content_today'] : $this->temp['cal_cell_content'];
- $out .= str_replace('{day}', $day, str_replace('{content}', $data[$day], $temp));
+ $temp = ($is_current_month === TRUE AND $day == $cur_day) ?
+ $this->temp['cal_cell_content_today'] : $this->temp['cal_cell_content'];
+ $out .= str_replace(array('{content}', '{day}'), array($data[$day], $day), $temp);
}
else
{
// Cells with no content
- $temp = ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_no_content_today'] : $this->temp['cal_cell_no_content'];
+ $temp = ($is_current_month === TRUE AND $day == $cur_day) ?
+ $this->temp['cal_cell_no_content_today'] : $this->temp['cal_cell_no_content'];
$out .= str_replace('{day}', $day, $temp);
}
}
@@ -245,17 +238,14 @@ class CI_Calendar {
$out .= $this->temp['cal_cell_blank'];
}
- $out .= ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_end_today'] : $this->temp['cal_cell_end'];
+ $out .= ($is_current_month === TRUE AND $day == $cur_day) ? $this->temp['cal_cell_end_today'] : $this->temp['cal_cell_end'];
$day++;
}
- $out .= "\n";
- $out .= $this->temp['cal_row_end'];
- $out .= "\n";
+ $out .= "\n".$this->temp['cal_row_end']."\n";
}
- $out .= "\n";
- $out .= $this->temp['table_close'];
+ $out .= "\n".$this->temp['table_close'];
return $out;
}
@@ -272,7 +262,7 @@ class CI_Calendar {
* @param integer the month
* @return string
*/
- function get_month_name($month)
+ public function get_month_name($month)
{
if ($this->month_type == 'short')
{
@@ -287,7 +277,7 @@ class CI_Calendar {
if ($this->CI->lang->line($month) === FALSE)
{
- return ucfirst(str_replace('cal_', '', $month));
+ return ucfirst(substr($month, 4));
}
return $this->CI->lang->line($month);
@@ -305,10 +295,12 @@ class CI_Calendar {
* @param string
* @return array
*/
- function get_day_names($day_type = '')
+ public function get_day_names($day_type = '')
{
if ($day_type != '')
+ {
$this->day_type = $day_type;
+ }
if ($this->day_type == 'long')
{
@@ -324,9 +316,9 @@ class CI_Calendar {
}
$days = array();
- foreach ($day_names as $val)
+ for ($i = 0, $c = count($day_names); $i < $c; $i++)
{
- $days[] = ($this->CI->lang->line('cal_'.$val) === FALSE) ? ucfirst($val) : $this->CI->lang->line('cal_'.$val);
+ $days[] = ($this->CI->lang->line('cal_'.$day_names[$i]) === FALSE) ? ucfirst($day_names[$i]) : $this->CI->lang->line('cal_'.$day_names[$i]);
}
return $days;
@@ -346,7 +338,7 @@ class CI_Calendar {
* @param integer the year
* @return array
*/
- function adjust_date($month, $year)
+ public function adjust_date($month, $year)
{
$date = array();
@@ -365,7 +357,7 @@ class CI_Calendar {
$date['year']--;
}
- if (strlen($date['month']) == 1)
+ if (strlen($date['month']) === 1)
{
$date['month'] = '0'.$date['month'];
}
@@ -383,7 +375,7 @@ class CI_Calendar {
* @param integer the year
* @return integer
*/
- function get_total_days($month, $year)
+ public function get_total_days($month, $year)
{
$days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
@@ -414,7 +406,7 @@ class CI_Calendar {
* @access public
* @return array
*/
- function default_template()
+ public function default_template()
{
return array (
'table_open' => '<table border="0" cellpadding="4" cellspacing="0">',
@@ -452,7 +444,7 @@ class CI_Calendar {
* @access public
* @return void
*/
- function parse_template()
+ public function parse_template()
{
$this->temp = $this->default_template();
@@ -467,14 +459,11 @@ class CI_Calendar {
{
if (preg_match("/\{".$val."\}(.*?)\{\/".$val."\}/si", $this->template, $match))
{
- $this->temp[$val] = $match['1'];
+ $this->temp[$val] = $match[1];
}
- else
+ elseif (in_array($val, $today, TRUE))
{
- if (in_array($val, $today, TRUE))
- {
- $this->temp[$val] = $this->temp[str_replace('_today', '', $val)];
- }
+ $this->temp[$val] = $this->temp[substr($val, 0, -6)];
}
}
}
@@ -484,4 +473,4 @@ class CI_Calendar {
// END CI_Calendar class
/* End of file Calendar.php */
-/* Location: ./system/libraries/Calendar.php */ \ No newline at end of file
+/* Location: ./system/libraries/Calendar.php */
diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php
index a0e1bb91e..01a0cb8ce 100644
--- a/system/libraries/Cart.php
+++ b/system/libraries/Cart.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -39,12 +39,13 @@
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
+ public $product_id_rules = '\.a-z0-9_-'; // alpha-numeric, dashes, underscores, or periods
+ public $product_name_rules = '\.\:\-_ a-z0-9'; // alpha-numeric, dashes, underscores, colons or periods
+ public $product_name_safe = true; // only allow safe product names
// Private variables. Do not change!
- var $CI;
- var $_cart_contents = array();
+ private $CI;
+ private $_cart_contents = array();
/**
@@ -58,28 +59,17 @@ class CI_Cart {
$this->CI =& get_instance();
// Are any config settings being passed manually? If so, set them
- $config = array();
- if (count($params) > 0)
- {
- foreach ($params as $key => $val)
- {
- $config[$key] = $val;
- }
- }
+ $config = is_array($params) ? $params : array();
// 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)
- {
- $this->_cart_contents = $this->CI->session->userdata('cart_contents');
- }
- else
+ // Grab the shopping cart array from the session table
+ $this->_cart_contents = $this->CI->session->userdata('cart_contents');
+ if ($this->_cart_contents === FALSE)
{
// 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 = array('cart_total' => 0, 'total_items' => 0);
}
log_message('debug', "Cart Class Initialized");
@@ -94,10 +84,10 @@ class CI_Cart {
* @param array
* @return bool
*/
- function insert($items = array())
+ public function insert($items = array())
{
// Was any cart data passed? No? Bah...
- if ( ! is_array($items) OR count($items) == 0)
+ if ( ! is_array($items) OR count($items) === 0)
{
log_message('error', 'The insert method must be passed an array containing data.');
return FALSE;
@@ -131,7 +121,7 @@ class CI_Cart {
}
// Save the cart data if the insert was successful
- if ($save_cart == TRUE)
+ if ($save_cart === TRUE)
{
$this->_save_cart();
return isset($rowid) ? $rowid : TRUE;
@@ -149,10 +139,10 @@ class CI_Cart {
* @param array
* @return bool
*/
- function _insert($items = array())
+ private function _insert($items = array())
{
// Was any cart data passed? No? Bah...
- if ( ! is_array($items) OR count($items) == 0)
+ if ( ! is_array($items) OR count($items) === 0)
{
log_message('error', 'The insert method must be passed an array containing data.');
return FALSE;
@@ -169,10 +159,8 @@ 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
- $items['qty'] = trim(preg_replace('/(^[0]+)/i', '', $items['qty']));
+ // Prep the quantity. It can only be a number. Duh... also trim any leading zeros
+ $items['qty'] = (float) $items['qty'];
// If the quantity is zero or blank there's nothing for us to do
if ( ! is_numeric($items['qty']) OR $items['qty'] == 0)
@@ -185,7 +173,7 @@ class CI_Cart {
// 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.
- if ( ! preg_match("/^[".$this->product_id_rules."]+$/i", $items['id']))
+ if ( ! preg_match('/^['.$this->product_id_rules.']+$/i', $items['id']))
{
log_message('error', 'Invalid product ID. The product ID can only contain alpha-numeric characters, dashes, and underscores');
return FALSE;
@@ -195,7 +183,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']))
+ if ($this->product_name_safe && ! preg_match('/^['.$this->product_name_rules.']+$/i', $items['name']))
{
log_message('error', 'An invalid name was submitted as the product name: '.$items['name'].' The name can only contain alpha-numeric characters, dashes, underscores, colons, and spaces');
return FALSE;
@@ -203,10 +191,8 @@ class CI_Cart {
// --------------------------------------------------------------------
- // Prep the price. Remove anything that isn't a number or decimal point.
- $items['price'] = trim(preg_replace('/([^0-9\.])/i', '', $items['price']));
- // Trim any leading zeros
- $items['price'] = trim(preg_replace('/(^[0]+)/i', '', $items['price']));
+ // Prep the price. Remove leading zeros and anything that isn't a number or decimal point.
+ $items['price'] = (float) $items['price'];
// Is the price a valid number?
if ( ! is_numeric($items['price']))
@@ -242,20 +228,14 @@ class CI_Cart {
// --------------------------------------------------------------------
// Now that we have our unique "row ID", we'll add our cart items to the master array
+ // grab quantity if it's already there and add it on
+ $old_quantity = isset($this->_cart_contents[$rowid]['qty']) ? (int) $this->_cart_contents[$rowid]['qty'] : 0;
- // let's unset this first, just to make sure our index contains only the data from this submission
- unset($this->_cart_contents[$rowid]);
-
- // Create a new index with our new row ID
- $this->_cart_contents[$rowid]['rowid'] = $rowid;
+ // Re-create the entry, just to make sure our index contains only the data from this submission
+ $items['rowid'] = $rowid;
+ $items['qty'] += $old_quantity;
+ $this->_cart_contents[$rowid] = $items;
- // And add the new items to the cart array
- foreach ($items as $key => $val)
- {
- $this->_cart_contents[$rowid][$key] = $val;
- }
-
- // Woot!
return $rowid;
}
@@ -274,10 +254,10 @@ class CI_Cart {
* @param string
* @return bool
*/
- function update($items = array())
+ public function update($items = array())
{
// Was any cart data passed?
- if ( ! is_array($items) OR count($items) == 0)
+ if ( ! is_array($items) OR count($items) === 0)
{
return FALSE;
}
@@ -287,9 +267,9 @@ class CI_Cart {
// determine the array type is by looking for a required array key named "id".
// If it's not found we assume it's a multi-dimensional array
$save_cart = FALSE;
- if (isset($items['rowid']) AND isset($items['qty']))
+ if (isset($items['rowid'], $items['qty']))
{
- if ($this->_update($items) == TRUE)
+ if ($this->_update($items) === TRUE)
{
$save_cart = TRUE;
}
@@ -298,9 +278,9 @@ class CI_Cart {
{
foreach ($items as $val)
{
- if (is_array($val) AND isset($val['rowid']) AND isset($val['qty']))
+ if (is_array($val) && isset($val['rowid'], $val['qty']))
{
- if ($this->_update($val) == TRUE)
+ if ($this->_update($val) === TRUE)
{
$save_cart = TRUE;
}
@@ -309,7 +289,7 @@ class CI_Cart {
}
// Save the cart data if the insert was successful
- if ($save_cart == TRUE)
+ if ($save_cart === TRUE)
{
$this->_save_cart();
return TRUE;
@@ -332,7 +312,7 @@ class CI_Cart {
* @param array
* @return bool
*/
- function _update($items = array())
+ private function _update($items = array())
{
// Without these array indexes there is nothing we can do
if ( ! isset($items['qty']) OR ! isset($items['rowid']) OR ! isset($this->_cart_contents[$items['rowid']]))
@@ -341,7 +321,7 @@ class CI_Cart {
}
// Prep the quantity
- $items['qty'] = preg_replace('/([^0-9])/i', '', $items['qty']);
+ $items['qty'] = (float) $items['qty'];
// Is the quantity a number?
if ( ! is_numeric($items['qty']))
@@ -378,15 +358,10 @@ class CI_Cart {
* @access private
* @return bool
*/
- function _save_cart()
+ private function _save_cart()
{
- // Unset these so our total can be calculated correctly below
- unset($this->_cart_contents['total_items']);
- unset($this->_cart_contents['cart_total']);
-
// Lets add up the individual prices and set the cart sub-total
- $total = 0;
- $items = 0;
+ $this->_cart_contents['total_items'] = $this->_cart_contents['cart_total'] = 0;
foreach ($this->_cart_contents as $key => $val)
{
// We make sure the array contains the proper indexes
@@ -395,17 +370,11 @@ class CI_Cart {
continue;
}
- $total += ($val['price'] * $val['qty']);
- $items += $val['qty'];
-
- // Set the subtotal
+ $this->_cart_contents['cart_total'] += ($val['price'] * $val['qty']);
+ $this->_cart_contents['total_items'] += $val['qty'];
$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'] = $items;
- $this->_cart_contents['cart_total'] = $total;
-
// Is our cart empty? If so we delete it from the session
if (count($this->_cart_contents) <= 2)
{
@@ -431,7 +400,7 @@ class CI_Cart {
* @access public
* @return integer
*/
- function total()
+ public function total()
{
return $this->_cart_contents['cart_total'];
}
@@ -439,6 +408,24 @@ class CI_Cart {
// --------------------------------------------------------------------
/**
+ * Remove Item
+ *
+ * Removes an item from the cart
+ *
+ * @access public
+ * @return boolean
+ */
+ public function remove($rowid)
+ {
+ // unset & save
+ unset($this->_cart_contents[$rowid]);
+ $this->_save_cart();
+ return TRUE;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Total Items
*
* Returns the total item count
@@ -446,7 +433,7 @@ class CI_Cart {
* @access public
* @return integer
*/
- function total_items()
+ public function total_items()
{
return $this->_cart_contents['total_items'];
}
@@ -461,9 +448,10 @@ class CI_Cart {
* @access public
* @return array
*/
- function contents()
+ public function contents($newest_first = FALSE)
{
- $cart = $this->_cart_contents;
+ // do we want the newest first?
+ $cart = ($newest_first) ? array_reverse($this->_cart_contents) : $this->_cart_contents;
// Remove these so they don't create a problem when showing the cart table
unset($cart['total_items']);
@@ -481,16 +469,11 @@ class CI_Cart {
* that has options associated with it.
*
* @access public
- * @return array
+ * @return bool
*/
- function has_options($rowid = '')
+ public function has_options($rowid = '')
{
- if ( ! isset($this->_cart_contents[$rowid]['options']) OR count($this->_cart_contents[$rowid]['options']) === 0)
- {
- return FALSE;
- }
-
- return TRUE;
+ return (isset($this->_cart_contents[$rowid]['options']) && count($this->_cart_contents[$rowid]['options']) !== 0) ? TRUE : FALSE;
}
// --------------------------------------------------------------------
@@ -503,14 +486,9 @@ class CI_Cart {
* @access public
* @return array
*/
- function product_options($rowid = '')
+ public function product_options($rowid = '')
{
- if ( ! isset($this->_cart_contents[$rowid]['options']))
- {
- return array();
- }
-
- return $this->_cart_contents[$rowid]['options'];
+ return isset($this->_cart_contents[$rowid]['options']) ? $this->_cart_contents[$rowid]['options'] : array();
}
// --------------------------------------------------------------------
@@ -521,9 +499,9 @@ class CI_Cart {
* Returns the supplied number with commas and a decimal point.
*
* @access public
- * @return integer
+ * @return string
*/
- function format_number($n = '')
+ public function format_number($n = '')
{
if ($n == '')
{
@@ -531,7 +509,7 @@ class CI_Cart {
}
// Remove anything that isn't a number or decimal point.
- $n = trim(preg_replace('/([^0-9\.])/i', '', $n));
+ $n = (float) $n;
return number_format($n, 2, '.', ',');
}
@@ -544,15 +522,11 @@ class CI_Cart {
* Empties the cart and kills the session
*
* @access public
- * @return null
+ * @return void
*/
- function destroy()
+ public function destroy()
{
- unset($this->_cart_contents);
-
- $this->_cart_contents['cart_total'] = 0;
- $this->_cart_contents['total_items'] = 0;
-
+ $this->_cart_contents = array('cart_total' => 0, 'total_items' => 0);
$this->CI->session->unset_userdata('cart_contents');
}
@@ -561,4 +535,4 @@ class CI_Cart {
// END Cart Class
/* End of file Cart.php */
-/* Location: ./system/libraries/Cart.php */ \ No newline at end of file
+/* Location: ./system/libraries/Cart.php */
diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php
index 8df137e74..183a95985 100644
--- a/system/libraries/Driver.php
+++ b/system/libraries/Driver.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -46,7 +46,7 @@ class CI_Driver_Library {
// 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)
+ public function __get($child)
{
if ( ! isset($this->lib_name))
{
@@ -55,11 +55,11 @@ class CI_Driver_Library {
// The class will be prefixed with the parent lib
$child_class = $this->lib_name.'_'.$child;
-
+
// Remove the CI_ prefix and lowercase
$lib_name = ucfirst(strtolower(str_replace('CI_', '', $this->lib_name)));
$driver_name = strtolower(str_replace('CI_', '', $child_class));
-
+
if (in_array($driver_name, array_map('strtolower', $this->valid_drivers)))
{
// check and see if the driver is in a separate file
@@ -119,6 +119,7 @@ class CI_Driver_Library {
* @link
*/
class CI_Driver {
+
protected $parent;
private $methods = array();
@@ -238,4 +239,4 @@ class CI_Driver {
// END CI_Driver CLASS
/* End of file Driver.php */
-/* Location: ./system/libraries/Driver.php */ \ No newline at end of file
+/* Location: ./system/libraries/Driver.php */
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index 631b62e86..1066535c7 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -40,54 +40,54 @@
*/
class CI_Email {
- var $useragent = "CodeIgniter";
- var $mailpath = "/usr/sbin/sendmail"; // Sendmail path
- var $protocol = "mail"; // mail/sendmail/smtp
- var $smtp_host = ""; // SMTP Server. Example: mail.earthlink.net
- var $smtp_user = ""; // SMTP Username
- var $smtp_pass = ""; // SMTP Password
- var $smtp_port = "25"; // SMTP Port
- var $smtp_timeout = 5; // SMTP Timeout in seconds
- var $smtp_crypto = ""; // SMTP Encryption. Can be null, tls or ssl.
- var $wordwrap = TRUE; // TRUE/FALSE Turns word-wrap on/off
- var $wrapchars = "76"; // Number of characters to wrap at.
- var $mailtype = "text"; // text/html Defines email formatting
- var $charset = "utf-8"; // Default char set: iso-8859-1 or us-ascii
- var $multipart = "mixed"; // "mixed" (in the body) or "related" (separate)
- var $alt_message = ''; // Alternative message for HTML emails
- var $validate = FALSE; // TRUE/FALSE. Enables email validation
- var $priority = "3"; // Default priority (1 - 5)
- var $newline = "\n"; // Default newline. "\r\n" or "\n" (Use "\r\n" to comply with RFC 822)
- var $crlf = "\n"; // The RFC 2045 compliant CRLF for quoted-printable is "\r\n". Apparently some servers,
+ public $useragent = "CodeIgniter";
+ public $mailpath = "/usr/sbin/sendmail"; // Sendmail path
+ public $protocol = "mail"; // mail/sendmail/smtp
+ public $smtp_host = ""; // SMTP Server. Example: mail.earthlink.net
+ public $smtp_user = ""; // SMTP Username
+ public $smtp_pass = ""; // SMTP Password
+ public $smtp_port = "25"; // SMTP Port
+ public $smtp_timeout = 5; // SMTP Timeout in seconds
+ public $smtp_crypto = ""; // SMTP Encryption. Can be null, tls or ssl.
+ public $wordwrap = TRUE; // TRUE/FALSE Turns word-wrap on/off
+ public $wrapchars = "76"; // Number of characters to wrap at.
+ public $mailtype = "text"; // text/html Defines email formatting
+ public $charset = "utf-8"; // Default char set: iso-8859-1 or us-ascii
+ public $multipart = "mixed"; // "mixed" (in the body) or "related" (separate)
+ public $alt_message = ''; // Alternative message for HTML emails
+ public $validate = FALSE; // TRUE/FALSE. Enables email validation
+ public $priority = "3"; // Default priority (1 - 5)
+ public $newline = "\n"; // Default newline. "\r\n" or "\n" (Use "\r\n" to comply with RFC 822)
+ public $crlf = "\n"; // The RFC 2045 compliant CRLF for quoted-printable is "\r\n". Apparently some servers,
// even on the receiving end think they need to muck with CRLFs, so using "\n", while
// distasteful, is the only thing that seems to work for all environments.
- var $send_multipart = TRUE; // TRUE/FALSE - Yahoo does not like multipart alternative, so this is an override. Set to FALSE for Yahoo.
- var $bcc_batch_mode = FALSE; // TRUE/FALSE Turns on/off Bcc batch feature
- var $bcc_batch_size = 200; // If bcc_batch_mode = TRUE, sets max number of Bccs in each batch
- var $_safe_mode = FALSE;
- var $_subject = "";
- var $_body = "";
- var $_finalbody = "";
- var $_alt_boundary = "";
- var $_atc_boundary = "";
- var $_header_str = "";
- var $_smtp_connect = "";
- var $_encoding = "8bit";
- var $_IP = FALSE;
- var $_smtp_auth = FALSE;
- var $_replyto_flag = FALSE;
- var $_debug_msg = array();
- var $_recipients = array();
- var $_cc_array = array();
- var $_bcc_array = array();
- var $_headers = array();
- var $_attach_name = array();
- var $_attach_type = array();
- var $_attach_disp = array();
- var $_protocols = array('mail', 'sendmail', 'smtp');
- var $_base_charsets = array('us-ascii', 'iso-2022-'); // 7-bit charsets (excluding language suffix)
- var $_bit_depths = array('7bit', '8bit');
- var $_priorities = array('1 (Highest)', '2 (High)', '3 (Normal)', '4 (Low)', '5 (Lowest)');
+ public $send_multipart = TRUE; // TRUE/FALSE - Yahoo does not like multipart alternative, so this is an override. Set to FALSE for Yahoo.
+ public $bcc_batch_mode = FALSE; // TRUE/FALSE Turns on/off Bcc batch feature
+ public $bcc_batch_size = 200; // If bcc_batch_mode = TRUE, sets max number of Bccs in each batch
+ private $_safe_mode = FALSE;
+ private $_subject = "";
+ private $_body = "";
+ private $_finalbody = "";
+ private $_alt_boundary = "";
+ private $_atc_boundary = "";
+ private $_header_str = "";
+ private $_smtp_connect = "";
+ private $_encoding = "8bit";
+ private $_IP = FALSE;
+ private $_smtp_auth = FALSE;
+ private $_replyto_flag = FALSE;
+ private $_debug_msg = array();
+ private $_recipients = array();
+ private $_cc_array = array();
+ private $_bcc_array = array();
+ private $_headers = array();
+ private $_attach_name = array();
+ private $_attach_type = array();
+ private $_attach_disp = array();
+ private $_protocols = array('mail', 'sendmail', 'smtp');
+ private $_base_charsets = array('us-ascii', 'iso-2022-'); // 7-bit charsets (excluding language suffix)
+ private $_bit_depths = array('7bit', '8bit');
+ private $_priorities = array('1 (Highest)', '2 (High)', '3 (Normal)', '4 (Low)', '5 (Lowest)');
/**
@@ -104,7 +104,7 @@ class CI_Email {
else
{
$this->_smtp_auth = ($this->smtp_user == '' AND $this->smtp_pass == '') ? FALSE : TRUE;
- $this->_safe_mode = ((boolean)@ini_get("safe_mode") === FALSE) ? FALSE : TRUE;
+ $this->_safe_mode = (bool) @ini_get("safe_mode");
}
log_message('debug', "Email Class Initialized");
@@ -140,7 +140,7 @@ class CI_Email {
$this->clear();
$this->_smtp_auth = ($this->smtp_user == '' AND $this->smtp_pass == '') ? FALSE : TRUE;
- $this->_safe_mode = ((boolean)@ini_get("safe_mode") === FALSE) ? FALSE : TRUE;
+ $this->_safe_mode = (bool) @ini_get("safe_mode");
return $this;
}
@@ -194,7 +194,7 @@ class CI_Email {
{
if (preg_match( '/\<(.*)\>/', $from, $match))
{
- $from = $match['1'];
+ $from = $match[1];
}
if ($this->validate)
@@ -237,7 +237,7 @@ class CI_Email {
{
if (preg_match( '/\<(.*)\>/', $replyto, $match))
{
- $replyto = $match['1'];
+ $replyto = $match[1];
}
if ($this->validate)
@@ -250,7 +250,7 @@ class CI_Email {
$name = $replyto;
}
- if (strncmp($name, '"', 1) != 0)
+ if (strncmp($name, '"', 1) !== 0)
{
$name = '"'.$name.'"';
}
@@ -280,7 +280,7 @@ class CI_Email {
$this->validate_email($to);
}
- if ($this->_get_protocol() != 'mail')
+ if ($this->_get_protocol() !== 'mail')
{
$this->_set_header('To', implode(", ", $to));
}
@@ -320,7 +320,7 @@ class CI_Email {
$this->_set_header('Cc', implode(", ", $cc));
- if ($this->_get_protocol() == "smtp")
+ if ($this->_get_protocol() === 'smtp')
{
$this->_cc_array = $cc;
}
@@ -354,7 +354,7 @@ class CI_Email {
$this->validate_email($bcc);
}
- if (($this->_get_protocol() == "smtp") OR ($this->bcc_batch_mode && count($bcc) > $this->bcc_batch_size))
+ if ($this->_get_protocol() === 'smtp' OR ($this->bcc_batch_mode && count($bcc) > $this->bcc_batch_size))
{
$this->_bcc_array = $bcc;
}
@@ -538,19 +538,13 @@ class CI_Email {
*/
public function set_priority($n = 3)
{
- if ( ! is_numeric($n))
- {
- $this->priority = 3;
- return;
- }
-
- if ($n < 1 OR $n > 5)
+ if ( ! is_numeric($n) OR $n < 1 OR $n > 5)
{
$this->priority = 3;
return;
}
- $this->priority = $n;
+ $this->priority = (int) $n;
return $this;
}
@@ -565,14 +559,7 @@ class CI_Email {
*/
public function set_newline($newline = "\n")
{
- if ($newline != "\n" AND $newline != "\r\n" AND $newline != "\r")
- {
- $this->newline = "\n";
- return;
- }
-
- $this->newline = $newline;
-
+ $this->newline = in_array($newline, array("\n", "\r\n", "\r")) ? $newline : "\n";
return $this;
}
@@ -587,14 +574,7 @@ class CI_Email {
*/
public function set_crlf($crlf = "\n")
{
- if ($crlf != "\n" AND $crlf != "\r\n" AND $crlf != "\r")
- {
- $this->crlf = "\n";
- return;
- }
-
- $this->crlf = $crlf;
-
+ $this->crlf = ($crlf !== "\n" AND $crlf !== "\r\n" AND $crlf !== "\r") ? "\n" : $crlf;
return $this;
}
@@ -622,9 +602,7 @@ class CI_Email {
*/
protected function _get_message_id()
{
- $from = $this->_headers['Return-Path'];
- $from = str_replace(">", "", $from);
- $from = str_replace("<", "", $from);
+ $from = str_replace(array('>', '<'), '', $this->_headers['Return-Path']);
return "<".uniqid('').strstr($from, '@').">";
}
@@ -664,7 +642,7 @@ class CI_Email {
foreach ($this->_base_charsets as $charset)
{
- if (strncmp($charset, $this->charset, strlen($charset)) == 0)
+ if (strncmp($charset, $this->charset, strlen($charset)) === 0)
{
$this->_encoding = '7bit';
}
@@ -686,15 +664,15 @@ class CI_Email {
*/
protected function _get_content_type()
{
- if ($this->mailtype == 'html' && count($this->_attach_name) == 0)
+ if ($this->mailtype === 'html' && count($this->_attach_name) === 0)
{
return 'html';
}
- elseif ($this->mailtype == 'html' && count($this->_attach_name) > 0)
+ elseif ($this->mailtype === 'html' && count($this->_attach_name) > 0)
{
return 'html-attach';
}
- elseif ($this->mailtype == 'text' && count($this->_attach_name) > 0)
+ elseif ($this->mailtype === 'text' && count($this->_attach_name) > 0)
{
return 'plain-attach';
}
@@ -715,9 +693,9 @@ class CI_Email {
protected function _set_date()
{
$timezone = date("Z");
- $operator = (strncmp($timezone, '-', 1) == 0) ? '-' : '+';
+ $operator = (strncmp($timezone, '-', 1) === 0) ? '-' : '+';
$timezone = abs($timezone);
- $timezone = floor($timezone/3600) * 100 + ($timezone % 3600 ) / 60;
+ $timezone = floor($timezone/3600) * 100 + ($timezone % 3600) / 60;
return sprintf("%s %s%04d", date("D, j M Y H:i:s"), $operator, $timezone);
}
@@ -775,7 +753,7 @@ class CI_Email {
*/
public function valid_email($address)
{
- return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $address)) ? FALSE : TRUE;
+ return (bool) preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $address);
}
// --------------------------------------------------------------------
@@ -791,28 +769,14 @@ class CI_Email {
{
if ( ! is_array($email))
{
- if (preg_match('/\<(.*)\>/', $email, $match))
- {
- return $match['1'];
- }
- else
- {
- return $email;
- }
+ return (preg_match('/\<(.*)\>/', $email, $match)) ? $match[1] : $email;
}
$clean_email = array();
foreach ($email as $addy)
{
- if (preg_match( '/\<(.*)\>/', $addy, $match))
- {
- $clean_email[] = $match['1'];
- }
- else
- {
- $clean_email[] = $addy;
- }
+ $clean_email[] = (preg_match( '/\<(.*)\>/', $addy, $match)) ? $match[1] : $addy;
}
return $clean_email;
@@ -838,32 +802,15 @@ class CI_Email {
return $this->word_wrap($this->alt_message, '76');
}
- if (preg_match('/\<body.*?\>(.*)\<\/body\>/si', $this->_body, $match))
- {
- $body = $match['1'];
- }
- else
- {
- $body = $this->_body;
- }
-
- $body = trim(strip_tags($body));
- $body = preg_replace( '#<!--(.*)--\>#', "", $body);
- $body = str_replace("\t", "", $body);
+ $body = (preg_match('/\<body.*?\>(.*)\<\/body\>/si', $this->_body, $match)) ? $match[1] : $this->_body;
+ $body = str_replace("\t", '', preg_replace('#<!--(.*)--\>#', '', trim(strip_tags($body))));
for ($i = 20; $i >= 3; $i--)
{
- $n = "";
-
- for ($x = 1; $x <= $i; $x ++)
- {
- $n .= "\n";
- }
-
- $body = str_replace($n, "\n\n", $body);
+ $body = str_replace(str_repeat("\n", $i), "\n\n", $body);
}
- return $this->word_wrap($body, '76');
+ return $this->word_wrap($body, 76);
}
// --------------------------------------------------------------------
@@ -881,7 +828,7 @@ class CI_Email {
// Se the character limit
if ($charlim == '')
{
- $charlim = ($this->wrapchars == "") ? "76" : $this->wrapchars;
+ $charlim = ($this->wrapchars == "") ? 76 : $this->wrapchars;
}
// Reduce multiple spaces
@@ -898,10 +845,10 @@ class CI_Email {
$unwrap = array();
if (preg_match_all("|(\{unwrap\}.+?\{/unwrap\})|s", $str, $matches))
{
- for ($i = 0; $i < count($matches['0']); $i++)
+ for ($i = 0, $c = count($matches[0]); $i < $c; $i++)
{
- $unwrap[] = $matches['1'][$i];
- $str = str_replace($matches['1'][$i], "{{unwrapped".$i."}}", $str);
+ $unwrap[] = $matches[1][$i];
+ $str = str_replace($matches[1][$i], "{{unwrapped".$i."}}", $str);
}
}
@@ -923,7 +870,7 @@ class CI_Email {
}
$temp = '';
- while ((strlen($line)) > $charlim)
+ do
{
// If the over-length word is a URL we won't wrap it
if (preg_match("!\[url.+\]|://|wwww.!", $line))
@@ -935,19 +882,16 @@ class CI_Email {
$temp .= substr($line, 0, $charlim-1);
$line = substr($line, $charlim-1);
}
+ while (strlen($line) > $charlim);
// If $temp contains data it means we had to split up an over-length
// word into smaller chunks so we'll add it back to our current line
if ($temp != '')
{
- $output .= $temp.$this->newline.$line;
- }
- else
- {
- $output .= $line;
+ $output .= $temp.$this->newline;
}
- $output .= $this->newline;
+ $output .= $line.$this->newline;
}
// Put our markers back
@@ -990,7 +934,7 @@ class CI_Email {
*/
protected function _write_headers()
{
- if ($this->protocol == 'mail')
+ if ($this->protocol === 'mail')
{
$this->_subject = $this->_headers['Subject'];
unset($this->_headers['Subject']);
@@ -1009,7 +953,7 @@ class CI_Email {
}
}
- if ($this->_get_protocol() == 'mail')
+ if ($this->_get_protocol() === 'mail')
{
$this->_header_str = rtrim($this->_header_str);
}
@@ -1025,7 +969,7 @@ class CI_Email {
*/
protected function _build_message()
{
- if ($this->wordwrap === TRUE AND $this->mailtype != 'html')
+ if ($this->wordwrap === TRUE AND $this->mailtype !== 'html')
{
$this->_body = $this->word_wrap($this->_body);
}
@@ -1033,17 +977,17 @@ class CI_Email {
$this->_set_boundaries();
$this->_write_headers();
- $hdr = ($this->_get_protocol() == 'mail') ? $this->newline : '';
+ $hdr = ($this->_get_protocol() === 'mail') ? $this->newline : '';
$body = '';
switch ($this->_get_content_type())
{
case 'plain' :
- $hdr .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
- $hdr .= "Content-Transfer-Encoding: " . $this->_get_encoding();
+ $hdr .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline
+ . "Content-Transfer-Encoding: " . $this->_get_encoding();
- if ($this->_get_protocol() == 'mail')
+ if ($this->_get_protocol() === 'mail')
{
$this->_header_str .= $hdr;
$this->_finalbody = $this->_body;
@@ -1055,33 +999,32 @@ class CI_Email {
return;
- break;
case 'html' :
if ($this->send_multipart === FALSE)
{
- $hdr .= "Content-Type: text/html; charset=" . $this->charset . $this->newline;
- $hdr .= "Content-Transfer-Encoding: quoted-printable";
+ $hdr .= "Content-Type: text/html; charset=" . $this->charset . $this->newline
+ . "Content-Transfer-Encoding: quoted-printable";
}
else
{
$hdr .= "Content-Type: multipart/alternative; boundary=\"" . $this->_alt_boundary . "\"" . $this->newline . $this->newline;
- $body .= $this->_get_mime_message() . $this->newline . $this->newline;
- $body .= "--" . $this->_alt_boundary . $this->newline;
+ $body .= $this->_get_mime_message() . $this->newline . $this->newline
+ . "--" . $this->_alt_boundary . $this->newline
- $body .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
- $body .= "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline;
- $body .= $this->_get_alt_message() . $this->newline . $this->newline . "--" . $this->_alt_boundary . $this->newline;
+ . "Content-Type: text/plain; charset=" . $this->charset . $this->newline
+ . "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline
+ . $this->_get_alt_message() . $this->newline . $this->newline . "--" . $this->_alt_boundary . $this->newline
- $body .= "Content-Type: text/html; charset=" . $this->charset . $this->newline;
- $body .= "Content-Transfer-Encoding: quoted-printable" . $this->newline . $this->newline;
+ . "Content-Type: text/html; charset=" . $this->charset . $this->newline
+ . "Content-Transfer-Encoding: quoted-printable" . $this->newline . $this->newline;
}
$this->_finalbody = $body . $this->_prep_quoted_printable($this->_body) . $this->newline . $this->newline;
- if ($this->_get_protocol() == 'mail')
+ if ($this->_get_protocol() === 'mail')
{
$this->_header_str .= $hdr;
}
@@ -1098,62 +1041,57 @@ class CI_Email {
return;
- break;
case 'plain-attach' :
$hdr .= "Content-Type: multipart/".$this->multipart."; boundary=\"" . $this->_atc_boundary."\"" . $this->newline . $this->newline;
- if ($this->_get_protocol() == 'mail')
+ if ($this->_get_protocol() === 'mail')
{
$this->_header_str .= $hdr;
}
- $body .= $this->_get_mime_message() . $this->newline . $this->newline;
- $body .= "--" . $this->_atc_boundary . $this->newline;
+ $body .= $this->_get_mime_message() . $this->newline . $this->newline
+ . "--" . $this->_atc_boundary . $this->newline
- $body .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
- $body .= "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline;
+ . "Content-Type: text/plain; charset=" . $this->charset . $this->newline
+ . "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline
- $body .= $this->_body . $this->newline . $this->newline;
+ . $this->_body . $this->newline . $this->newline;
break;
case 'html-attach' :
$hdr .= "Content-Type: multipart/".$this->multipart."; boundary=\"" . $this->_atc_boundary."\"" . $this->newline . $this->newline;
- if ($this->_get_protocol() == 'mail')
+ if ($this->_get_protocol() === 'mail')
{
$this->_header_str .= $hdr;
}
- $body .= $this->_get_mime_message() . $this->newline . $this->newline;
- $body .= "--" . $this->_atc_boundary . $this->newline;
+ $body .= $this->_get_mime_message() . $this->newline . $this->newline
+ . "--" . $this->_atc_boundary . $this->newline
- $body .= "Content-Type: multipart/alternative; boundary=\"" . $this->_alt_boundary . "\"" . $this->newline .$this->newline;
- $body .= "--" . $this->_alt_boundary . $this->newline;
+ . "Content-Type: multipart/alternative; boundary=\"" . $this->_alt_boundary . "\"" . $this->newline .$this->newline
+ . "--" . $this->_alt_boundary . $this->newline
- $body .= "Content-Type: text/plain; charset=" . $this->charset . $this->newline;
- $body .= "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline;
- $body .= $this->_get_alt_message() . $this->newline . $this->newline . "--" . $this->_alt_boundary . $this->newline;
+ . "Content-Type: text/plain; charset=" . $this->charset . $this->newline
+ . "Content-Transfer-Encoding: " . $this->_get_encoding() . $this->newline . $this->newline
+ . $this->_get_alt_message() . $this->newline . $this->newline . "--" . $this->_alt_boundary . $this->newline
- $body .= "Content-Type: text/html; charset=" . $this->charset . $this->newline;
- $body .= "Content-Transfer-Encoding: quoted-printable" . $this->newline . $this->newline;
+ . "Content-Type: text/html; charset=" . $this->charset . $this->newline
+ . "Content-Transfer-Encoding: quoted-printable" . $this->newline . $this->newline
- $body .= $this->_prep_quoted_printable($this->_body) . $this->newline . $this->newline;
- $body .= "--" . $this->_alt_boundary . "--" . $this->newline . $this->newline;
+ . $this->_prep_quoted_printable($this->_body) . $this->newline . $this->newline
+ . "--" . $this->_alt_boundary . "--" . $this->newline . $this->newline;
break;
}
$attachment = array();
-
- $z = 0;
-
- for ($i=0; $i < count($this->_attach_name); $i++)
+ for ($i = 0, $c = count($this->_attach_name), $z = 0; $i < $c; $i++)
{
$filename = $this->_attach_name[$i][0];
- $basename = ( is_null($this->_attach_name[$i][1]) ? basename($filename) : $this->_attach_name[$i][1] );
-
+ $basename = (is_null($this->_attach_name[$i][1])) ? basename($filename) : $this->_attach_name[$i][1];
$ctype = $this->_attach_type[$i];
if ( ! file_exists($filename))
@@ -1162,13 +1100,12 @@ class CI_Email {
return FALSE;
}
- $h = "--".$this->_atc_boundary.$this->newline;
- $h .= "Content-type: ".$ctype."; ";
- $h .= "name=\"".$basename."\"".$this->newline;
- $h .= "Content-Disposition: ".$this->_attach_disp[$i].";".$this->newline;
- $h .= "Content-Transfer-Encoding: base64".$this->newline;
+ $attachment[$z++] = "--".$this->_atc_boundary.$this->newline
+ . "Content-type: ".$ctype."; "
+ . "name=\"".$basename."\"".$this->newline
+ . "Content-Disposition: ".$this->_attach_disp[$i].";".$this->newline
+ . "Content-Transfer-Encoding: base64".$this->newline;
- $attachment[$z++] = $h;
$file = filesize($filename) +1;
if ( ! $fp = fopen($filename, FOPEN_READ))
@@ -1182,17 +1119,7 @@ class CI_Email {
}
$body .= implode($this->newline, $attachment).$this->newline."--".$this->_atc_boundary."--";
-
-
- if ($this->_get_protocol() == 'mail')
- {
- $this->_finalbody = $body;
- }
- else
- {
- $this->_finalbody = $hdr . $body;
- }
-
+ $this->_finalbody = ($this->_get_protocol() === 'mail') ? $body : $hdr . $body;
return;
}
@@ -1214,16 +1141,13 @@ class CI_Email {
// Set the character limit
// Don't allow over 76, as that will make servers and MUAs barf
// all over quoted-printable data
- if ($charlim == '' OR $charlim > '76')
+ if ($charlim == '' OR $charlim > 76)
{
- $charlim = '76';
+ $charlim = 76;
}
- // Reduce multiple spaces
- $str = preg_replace("| +|", " ", $str);
-
- // kill nulls
- $str = preg_replace('/\x00+/', '', $str);
+ // Reduce multiple spaces & remove nulls
+ $str = preg_replace(array("| +|", '/\x00+/'), array(' ', ''), $str);
// Standardize newlines
if (strpos($str, "\r") !== FALSE)
@@ -1235,13 +1159,10 @@ class CI_Email {
// properly and MUAs will behave, so {unwrap} must go!
$str = str_replace(array('{unwrap}', '{/unwrap}'), '', $str);
- // Break into an array of lines
- $lines = explode("\n", $str);
-
$escape = '=';
$output = '';
- foreach ($lines as $line)
+ foreach (explode("\n", $str) as $line)
{
$length = strlen($line);
$temp = '';
@@ -1252,17 +1173,15 @@ class CI_Email {
for ($i = 0; $i < $length; $i++)
{
// Grab the next character
- $char = substr($line, $i, 1);
+ $char = $line[$i];
$ascii = ord($char);
// Convert spaces and tabs but only if it's the end of the line
- if ($i == ($length - 1))
+ if ($i === ($length - 1) && ($ascii === 32 OR $ascii === 9))
{
- $char = ($ascii == '32' OR $ascii == '9') ? $escape.sprintf('%02s', dechex($ascii)) : $char;
+ $char = $escape.sprintf('%02s', dechex($ascii));
}
-
- // encode = signs
- if ($ascii == '61')
+ elseif ($ascii === 61) // encode = signs
{
$char = $escape.strtoupper(sprintf('%02s', dechex($ascii))); // =3D
}
@@ -1325,7 +1244,7 @@ class CI_Email {
for ($i = 0, $length = strlen($str); $i < $length; $i++)
{
// Grab the next character
- $char = substr($str, $i, 1);
+ $char = $str[$i];
$ascii = ord($char);
// convert ALL non-printable ASCII characters and our specials
@@ -1335,7 +1254,7 @@ class CI_Email {
}
// handle regular spaces a bit more compactly than =20
- if ($ascii == 32)
+ if ($ascii === 32)
{
$char = '_';
}
@@ -1386,22 +1305,14 @@ class CI_Email {
$this->_build_headers();
- if ($this->bcc_batch_mode AND count($this->_bcc_array) > 0)
+ if ($this->bcc_batch_mode AND count($this->_bcc_array) > $this->bcc_batch_size)
{
- if (count($this->_bcc_array) > $this->bcc_batch_size)
- return $this->batch_bcc_send();
+ return $this->batch_bcc_send();
}
$this->_build_message();
- if ( ! $this->_spool_email())
- {
- return FALSE;
- }
- else
- {
- return TRUE;
- }
+ return $this->_spool_email();
}
// --------------------------------------------------------------------
@@ -1420,7 +1331,7 @@ class CI_Email {
$chunk = array();
- for ($i = 0; $i < count($this->_bcc_array); $i++)
+ for ($i = 0, $c = count($this->_bcc_array); $i < $c; $i++)
{
if (isset($this->_bcc_array[$i]))
{
@@ -1430,25 +1341,23 @@ class CI_Email {
if ($i == $float)
{
$chunk[] = substr($set, 1);
- $float = $float + $this->bcc_batch_size;
+ $float += $this->bcc_batch_size;
$set = "";
}
- if ($i == count($this->_bcc_array)-1)
+ if ($i === $c-1)
{
$chunk[] = substr($set, 1);
}
}
- for ($i = 0; $i < count($chunk); $i++)
+ for ($i = 0, $c = count($chunk); $i < $c; $i++)
{
unset($this->_headers['Bcc']);
- unset($bcc);
- $bcc = $this->_str_to_array($chunk[$i]);
- $bcc = $this->clean_email($bcc);
+ $bcc = $this->clean_email($this->_str_to_array($chunk[$i]));
- if ($this->protocol != 'smtp')
+ if ($this->protocol !== 'smtp')
{
$this->_set_header('Bcc', implode(", ", $bcc));
}
@@ -1505,33 +1414,10 @@ class CI_Email {
{
$this->_unwrap_specials();
- switch ($this->_get_protocol())
+ $method = '_send_with_' . $this->_get_protocol();
+ if ( ! $this->$method())
{
- case 'mail' :
-
- if ( ! $this->_send_with_mail())
- {
- $this->_set_error_message('lang:email_send_failure_phpmail');
- return FALSE;
- }
- break;
- case 'sendmail' :
-
- if ( ! $this->_send_with_sendmail())
- {
- $this->_set_error_message('lang:email_send_failure_sendmail');
- return FALSE;
- }
- break;
- case 'smtp' :
-
- if ( ! $this->_send_with_smtp())
- {
- $this->_set_error_message('lang:email_send_failure_smtp');
- return FALSE;
- }
- break;
-
+ $this->_set_error_message('lang:email_send_failure_' . ($this->_get_protocol() === 'mail' ? 'phpmail' : $this->_get_protocol()));
}
$this->_set_error_message('lang:email_sent', $this->_get_protocol());
@@ -1550,28 +1436,13 @@ class CI_Email {
{
if ($this->_safe_mode == TRUE)
{
- if ( ! mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str))
- {
- return FALSE;
- }
- else
- {
- return TRUE;
- }
+ return mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str);
}
else
{
// most documentation of sendmail using the "-f" flag lacks a space after it, however
// we've encountered servers that seem to require it to be in place.
-
- if ( ! mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str, "-f ".$this->clean_email($this->_headers['From'])))
- {
- return FALSE;
- }
- else
- {
- return TRUE;
- }
+ return mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str, "-f ".$this->clean_email($this->_headers['From']));
}
}
@@ -1598,12 +1469,7 @@ class CI_Email {
$status = pclose($fp);
- if (version_compare(PHP_VERSION, '4.2.3') == -1)
- {
- $status = $status >> 8 & 0xFF;
- }
-
- if ($status != 0)
+ if ($status !== 0)
{
$this->_set_error_message('lang:email_exit_status', $status);
$this->_set_error_message('lang:email_no_socket');
@@ -1672,7 +1538,7 @@ class CI_Email {
$this->_set_error_message($reply);
- if (strncmp($reply, '250', 3) != 0)
+ if (strncmp($reply, '250', 3) !== 0)
{
$this->_set_error_message('lang:email_smtp_error', $reply);
return FALSE;
@@ -1824,7 +1690,7 @@ class CI_Email {
$reply = $this->_get_smtp_data();
- if (strncmp($reply, '334', 3) != 0)
+ if (strncmp($reply, '334', 3) !== 0)
{
$this->_set_error_message('lang:email_failed_smtp_login', $reply);
return FALSE;
@@ -1834,7 +1700,7 @@ class CI_Email {
$reply = $this->_get_smtp_data();
- if (strncmp($reply, '334', 3) != 0)
+ if (strncmp($reply, '334', 3) !== 0)
{
$this->_set_error_message('lang:email_smtp_auth_un', $reply);
return FALSE;
@@ -1844,7 +1710,7 @@ class CI_Email {
$reply = $this->_get_smtp_data();
- if (strncmp($reply, '235', 3) != 0)
+ if (strncmp($reply, '235', 3) !== 0)
{
$this->_set_error_message('lang:email_smtp_auth_pw', $reply);
return FALSE;
@@ -1868,10 +1734,8 @@ class CI_Email {
$this->_set_error_message('lang:email_smtp_data_failure', $data);
return FALSE;
}
- else
- {
- return TRUE;
- }
+
+ return TRUE;
}
// --------------------------------------------------------------------
@@ -1890,7 +1754,7 @@ class CI_Email {
{
$data .= $str;
- if (substr($str, 3, 1) == " ")
+ if ($str[3] == " ")
{
break;
}
@@ -1929,12 +1793,16 @@ class CI_Email {
$cip = (isset($_SERVER['HTTP_CLIENT_IP']) AND $_SERVER['HTTP_CLIENT_IP'] != "") ? $_SERVER['HTTP_CLIENT_IP'] : FALSE;
$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;
- elseif ($rip) $this->_IP = $rip;
- elseif ($cip) $this->_IP = $cip;
- elseif ($fip) $this->_IP = $fip;
+ if ($cip) $this->_IP = $cip;
+ elseif ($rip) $this->_IP = $rip;
+ else
+ {
+ $fip = (isset($_SERVER['HTTP_X_FORWARDED_FOR']) AND $_SERVER['HTTP_X_FORWARDED_FOR'] != "") ? $_SERVER['HTTP_X_FORWARDED_FOR'] : FALSE;
+ if ($fip)
+ {
+ $this->_IP = $fip;
+ }
+ }
if (strpos($this->_IP, ',') !== FALSE)
{
@@ -1947,10 +1815,6 @@ class CI_Email {
$this->_IP = '0.0.0.0';
}
- unset($cip);
- unset($rip);
- unset($fip);
-
return $this->_IP;
}
@@ -1992,7 +1856,7 @@ class CI_Email {
$CI =& get_instance();
$CI->lang->load('email');
- if (substr($msg, 0, 5) != 'lang:' || FALSE === ($line = $CI->lang->line(substr($msg, 5))))
+ if (substr($msg, 0, 5) !== 'lang:' || FALSE === ($line = $CI->lang->line(substr($msg, 5))))
{
$this->_debug_msg[] = str_replace('%s', $val, $msg)."<br />";
}
@@ -2109,4 +1973,4 @@ class CI_Email {
// END CI_Email class
/* End of file Email.php */
-/* Location: ./system/libraries/Email.php */ \ No newline at end of file
+/* Location: ./system/libraries/Email.php */
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index 5663da981..3f5323233 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -5,9 +5,9 @@
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -746,7 +746,7 @@ class CI_Form_validation {
}
// If the data is an array output them one at a time.
- // E.g: form_input('name[]', set_value('name[]');
+ // E.g: form_input('name[]', set_value('name[]');
if (is_array($this->_field_data[$field]['postdata']))
{
return array_shift($this->_field_data[$field]['postdata']);
@@ -949,7 +949,7 @@ class CI_Form_validation {
return ($str !== $field) ? FALSE : TRUE;
}
-
+
// --------------------------------------------------------------------
/**
@@ -962,11 +962,14 @@ class CI_Form_validation {
*/
public function is_unique($str, $field)
{
- list($table, $field)=explode('.', $field);
- $query = $this->CI->db->limit(1)->get_where($table, array($field => $str));
-
- return $query->num_rows() === 0;
- }
+ list($table, $field) = explode('.', $field);
+ if (isset($this->CI->db))
+ {
+ $query = $this->CI->db->limit(1)->get_where($table, array($field => $str));
+ return $query->num_rows() === 0;
+ }
+ return FALSE;
+ }
// --------------------------------------------------------------------
diff --git a/system/libraries/Ftp.php b/system/libraries/Ftp.php
index 70d7fc897..99850a9e5 100644
--- a/system/libraries/Ftp.php
+++ b/system/libraries/Ftp.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -38,13 +38,13 @@
*/
class CI_FTP {
- var $hostname = '';
- var $username = '';
- var $password = '';
- var $port = 21;
- var $passive = TRUE;
- var $debug = FALSE;
- var $conn_id = FALSE;
+ public $hostname = '';
+ public $username = '';
+ public $password = '';
+ public $port = 21;
+ public $passive = TRUE;
+ public $debug = FALSE;
+ public $conn_id = FALSE;
/**
@@ -71,7 +71,7 @@ class CI_FTP {
* @param array
* @return void
*/
- function initialize($config = array())
+ public function initialize($config = array())
{
foreach ($config as $key => $val)
{
@@ -94,7 +94,7 @@ class CI_FTP {
* @param array the connection values
* @return bool
*/
- function connect($config = array())
+ public function connect($config = array())
{
if (count($config) > 0)
{
@@ -136,7 +136,7 @@ class CI_FTP {
* @access private
* @return bool
*/
- function _login()
+ private function _login()
{
return @ftp_login($this->conn_id, $this->username, $this->password);
}
@@ -149,7 +149,7 @@ class CI_FTP {
* @access private
* @return bool
*/
- function _is_conn()
+ private function _is_conn()
{
if ( ! is_resource($this->conn_id))
{
@@ -179,7 +179,7 @@ class CI_FTP {
* @param bool
* @return bool
*/
- function changedir($path = '', $supress_debug = FALSE)
+ public function changedir($path = '', $supress_debug = FALSE)
{
if ($path == '' OR ! $this->_is_conn())
{
@@ -209,7 +209,7 @@ class CI_FTP {
* @param string
* @return bool
*/
- function mkdir($path = '', $permissions = NULL)
+ public function mkdir($path = '', $permissions = NULL)
{
if ($path == '' OR ! $this->_is_conn())
{
@@ -247,7 +247,7 @@ class CI_FTP {
* @param string
* @return bool
*/
- function upload($locpath, $rempath, $mode = 'auto', $permissions = NULL)
+ public function upload($locpath, $rempath, $mode = 'auto', $permissions = NULL)
{
if ( ! $this->_is_conn())
{
@@ -261,14 +261,14 @@ class CI_FTP {
}
// Set the mode if not specified
- if ($mode == 'auto')
+ if ($mode === 'auto')
{
// Get the file extension so we can set the upload type
$ext = $this->_getext($locpath);
$mode = $this->_settype($ext);
}
- $mode = ($mode == 'ascii') ? FTP_ASCII : FTP_BINARY;
+ $mode = ($mode === 'ascii') ? FTP_ASCII : FTP_BINARY;
$result = @ftp_put($this->conn_id, $rempath, $locpath, $mode);
@@ -301,7 +301,7 @@ class CI_FTP {
* @param string
* @return bool
*/
- function download($rempath, $locpath, $mode = 'auto')
+ public function download($rempath, $locpath, $mode = 'auto')
{
if ( ! $this->_is_conn())
{
@@ -309,14 +309,14 @@ class CI_FTP {
}
// Set the mode if not specified
- if ($mode == 'auto')
+ if ($mode === 'auto')
{
// Get the file extension so we can set the upload type
$ext = $this->_getext($rempath);
$mode = $this->_settype($ext);
}
- $mode = ($mode == 'ascii') ? FTP_ASCII : FTP_BINARY;
+ $mode = ($mode === 'ascii') ? FTP_ASCII : FTP_BINARY;
$result = @ftp_get($this->conn_id, $locpath, $rempath, $mode);
@@ -343,7 +343,7 @@ class CI_FTP {
* @param bool
* @return bool
*/
- function rename($old_file, $new_file, $move = FALSE)
+ public function rename($old_file, $new_file, $move = FALSE)
{
if ( ! $this->_is_conn())
{
@@ -356,9 +356,7 @@ class CI_FTP {
{
if ($this->debug == TRUE)
{
- $msg = ($move == FALSE) ? 'ftp_unable_to_rename' : 'ftp_unable_to_move';
-
- $this->_error($msg);
+ $this->_error('ftp_unable_to_' . ($move == FALSE ? 'rename' : 'move'));
}
return FALSE;
}
@@ -376,7 +374,7 @@ class CI_FTP {
* @param string
* @return bool
*/
- function move($old_file, $new_file)
+ public function move($old_file, $new_file)
{
return $this->rename($old_file, $new_file, TRUE);
}
@@ -390,7 +388,7 @@ class CI_FTP {
* @param string
* @return bool
*/
- function delete_file($filepath)
+ public function delete_file($filepath)
{
if ( ! $this->_is_conn())
{
@@ -421,7 +419,7 @@ class CI_FTP {
* @param string
* @return bool
*/
- function delete_dir($filepath)
+ public function delete_dir($filepath)
{
if ( ! $this->_is_conn())
{
@@ -470,23 +468,13 @@ class CI_FTP {
* @param string the permissions
* @return bool
*/
- function chmod($path, $perm)
+ public function chmod($path, $perm)
{
if ( ! $this->_is_conn())
{
return FALSE;
}
- // Permissions can only be set when running PHP 5
- if ( ! function_exists('ftp_chmod'))
- {
- if ($this->debug == TRUE)
- {
- $this->_error('ftp_unable_to_chmod');
- }
- return FALSE;
- }
-
$result = @ftp_chmod($this->conn_id, $perm, $path);
if ($result === FALSE)
@@ -509,7 +497,7 @@ class CI_FTP {
* @access public
* @return array
*/
- function list_files($path = '.')
+ public function list_files($path = '.')
{
if ( ! $this->_is_conn())
{
@@ -533,7 +521,7 @@ class CI_FTP {
* @param string path to destination - include the base folder with trailing slash
* @return bool
*/
- function mirror($locpath, $rempath)
+ public function mirror($locpath, $rempath)
{
if ( ! $this->_is_conn())
{
@@ -543,24 +531,20 @@ class CI_FTP {
// Open the local file path
if ($fp = @opendir($locpath))
{
- // Attempt to open the remote file path.
- if ( ! $this->changedir($rempath, TRUE))
+ // Attempt to open the remote file path and try to create it, if it doesn't exist
+ if ( ! $this->changedir($rempath, TRUE) AND ( ! $this->mkdir($rempath) OR ! $this->changedir($rempath)))
{
- // If it doesn't exist we'll attempt to create the direcotory
- if ( ! $this->mkdir($rempath) OR ! $this->changedir($rempath))
- {
- return FALSE;
- }
+ return FALSE;
}
// Recursively read the local directory
while (FALSE !== ($file = readdir($fp)))
{
- if (@is_dir($locpath.$file) && substr($file, 0, 1) != '.')
+ if (@is_dir($locpath.$file) && $file[0] !== '.')
{
$this->mirror($locpath.$file."/", $rempath.$file."/");
}
- elseif (substr($file, 0, 1) != ".")
+ elseif ($file[0] !== ".")
{
// Get the file extension so we can se the upload type
$ext = $this->_getext($file);
@@ -585,7 +569,7 @@ class CI_FTP {
* @param string
* @return string
*/
- function _getext($filename)
+ private function _getext($filename)
{
if (FALSE === strpos($filename, '.'))
{
@@ -606,7 +590,7 @@ class CI_FTP {
* @param string
* @return string
*/
- function _settype($ext)
+ private function _settype($ext)
{
$text_types = array(
'txt',
@@ -634,18 +618,16 @@ class CI_FTP {
* Close the connection
*
* @access public
- * @param string path to source
- * @param string path to destination
* @return bool
*/
- function close()
+ public function close()
{
if ( ! $this->_is_conn())
{
return FALSE;
}
- @ftp_close($this->conn_id);
+ return @ftp_close($this->conn_id);
}
// ------------------------------------------------------------------------
@@ -655,9 +637,9 @@ class CI_FTP {
*
* @access private
* @param string
- * @return bool
+ * @return void
*/
- function _error($line)
+ private function _error($line)
{
$CI =& get_instance();
$CI->lang->load('ftp');
@@ -669,4 +651,4 @@ class CI_FTP {
// END FTP Class
/* End of file Ftp.php */
-/* Location: ./system/libraries/Ftp.php */ \ No newline at end of file
+/* Location: ./system/libraries/Ftp.php */
diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index beb463b32..20ca1f055 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -5,9 +5,9 @@
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -38,55 +38,55 @@
*/
class CI_Image_lib {
- 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 = '';
- var $new_image = '';
- var $width = '';
- var $height = '';
- 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 $master_dim = 'auto'; // auto, height, or width. Determines what to use as the master dimension
- var $rotation_angle = '';
- var $x_axis = '';
- var $y_axis = '';
+ public $image_library = 'gd2'; // Can be: imagemagick, netpbm, gd, gd2
+ public $library_path = '';
+ public $dynamic_output = FALSE; // Whether to send to browser or write to disk
+ public $source_image = '';
+ public $new_image = '';
+ public $width = '';
+ public $height = '';
+ public $quality = '90';
+ public $create_thumb = FALSE;
+ public $thumb_marker = '_thumb';
+ public $maintain_ratio = TRUE; // Whether to maintain aspect ratio when resizing or use hard values
+ public $master_dim = 'auto'; // auto, height, or width. Determines what to use as the master dimension
+ public $rotation_angle = '';
+ public $x_axis = '';
+ public $y_axis = '';
// Watermark Vars
- var $wm_text = ''; // Watermark text if graphic is not used
- var $wm_type = 'text'; // Type of watermarking. Options: text/overlay
- var $wm_x_transp = 4;
- var $wm_y_transp = 4;
- var $wm_overlay_path = ''; // Watermark image path
- var $wm_font_path = ''; // TT font
- var $wm_font_size = 17; // Font size (different versions of GD will either use points or pixels)
- var $wm_vrt_alignment = 'B'; // Vertical alignment: T M B
- 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_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
+ public $wm_text = ''; // Watermark text if graphic is not used
+ public $wm_type = 'text'; // Type of watermarking. Options: text/overlay
+ public $wm_x_transp = 4;
+ public $wm_y_transp = 4;
+ public $wm_overlay_path = ''; // Watermark image path
+ public $wm_font_path = ''; // TT font
+ public $wm_font_size = 17; // Font size (different versions of GD will either use points or pixels)
+ public $wm_vrt_alignment = 'B'; // Vertical alignment: T M B
+ public $wm_hor_alignment = 'C'; // Horizontal alignment: L R C
+ public $wm_padding = 0; // Padding around text
+ public $wm_hor_offset = 0; // Lets you push text to the right
+ public $wm_vrt_offset = 0; // Lets you push text down
+ public $wm_font_color = '#ffffff'; // Text color
+ public $wm_shadow_color = ''; // Dropshadow color
+ public $wm_shadow_distance = 2; // Dropshadow distance
+ public $wm_opacity = 50; // Image opacity: 1 - 100 Only works with image
// Private Vars
- var $source_folder = '';
- var $dest_folder = '';
- var $mime_type = '';
- var $orig_width = '';
- var $orig_height = '';
- var $image_type = '';
- var $size_str = '';
- var $full_src_path = '';
- var $full_dst_path = '';
- var $create_fnc = 'imagecreatetruecolor';
- var $copy_fnc = 'imagecopyresampled';
- var $error_msg = array();
- var $wm_use_drop_shadow = FALSE;
- var $wm_use_truetype = FALSE;
+ public $source_folder = '';
+ public $dest_folder = '';
+ public $mime_type = '';
+ public $orig_width = '';
+ public $orig_height = '';
+ public $image_type = '';
+ public $size_str = '';
+ public $full_src_path = '';
+ public $full_dst_path = '';
+ public $create_fnc = 'imagecreatetruecolor';
+ public $copy_fnc = 'imagecopyresampled';
+ public $error_msg = array();
+ public $wm_use_drop_shadow = FALSE;
+ public $wm_use_truetype = FALSE;
/**
* Constructor
@@ -114,17 +114,39 @@ class CI_Image_lib {
* @access public
* @return void
*/
- function clear()
+ public function clear()
{
- $props = array('source_folder', 'dest_folder', 'source_image', 'full_src_path', 'full_dst_path', 'new_image', 'image_type', 'size_str', 'quality', 'orig_width', 'orig_height', 'rotation_angle', 'x_axis', 'y_axis', 'create_fnc', 'copy_fnc', 'wm_overlay_path', 'wm_use_truetype', 'dynamic_output', 'wm_font_size', 'wm_text', 'wm_vrt_alignment', 'wm_hor_alignment', 'wm_padding', 'wm_hor_offset', 'wm_vrt_offset', 'wm_font_color', 'wm_use_drop_shadow', 'wm_shadow_color', 'wm_shadow_distance', 'wm_opacity');
+ $props = array('library_path', 'source_image', 'new_image', 'width', 'height', 'rotation_angle', 'x_axis', 'y_axis', 'wm_text', 'wm_overlay_path', 'wm_font_path', 'wm_shadow_color', 'source_folder', 'dest_folder', 'mime_type', 'orig_width', 'orig_height', 'image_type', 'size_str', 'full_src_path', 'full_dst_path');
foreach ($props as $val)
{
$this->$val = '';
}
- // special consideration for master_dim
- $this->master_dim = 'auto';
+ $this->image_library = 'gd2';
+ $this->dynamic_output = FALSE;
+ $this->quality = '90';
+ $this->create_thumb = FALSE;
+ $this->thumb_marker = '_thumb';
+ $this->maintain_ratio = TRUE;
+ $this->master_dim = 'auto';
+ $this->wm_type = 'text';
+ $this->wm_x_transp = 4;
+ $this->wm_y_transp = 4;
+ $this->wm_font_size = 17;
+ $this->wm_vrt_alignment = 'B';
+ $this->wm_hor_alignment = 'C';
+ $this->wm_padding = 0;
+ $this->wm_hor_offset = 0;
+ $this->wm_vrt_offset = 0;
+ $this->wm_font_color = '#ffffff';
+ $this->wm_shadow_distance = 2;
+ $this->wm_opacity = 50;
+ $this->create_fnc = 'imagecreatetruecolor';
+ $this->copy_fnc = 'imagecopyresampled';
+ $this->error_msg = array();
+ $this->wm_use_drop_shadow = FALSE;
+ $this->wm_use_truetype = FALSE;
}
// --------------------------------------------------------------------
@@ -136,7 +158,7 @@ class CI_Image_lib {
* @param array
* @return bool
*/
- function initialize($props = array())
+ public function initialize($props = array())
{
/*
* Convert array elements into class variables
@@ -158,7 +180,7 @@ class CI_Image_lib {
if ($this->source_image == '')
{
$this->set_error('imglib_source_image_required');
- return FALSE;
+ return FALSE;
}
/*
@@ -201,7 +223,7 @@ class CI_Image_lib {
// Set the Image Properties
if ( ! $this->get_image_properties($this->source_folder.$this->source_image))
{
- return FALSE;
+ return FALSE;
}
/*
@@ -357,7 +379,7 @@ class CI_Image_lib {
* @access public
* @return bool
*/
- function resize()
+ public function resize()
{
$protocol = 'image_process_'.$this->image_library;
@@ -380,7 +402,7 @@ class CI_Image_lib {
* @access public
* @return bool
*/
- function crop()
+ public function crop()
{
$protocol = 'image_process_'.$this->image_library;
@@ -403,7 +425,7 @@ class CI_Image_lib {
* @access public
* @return bool
*/
- function rotate()
+ public function rotate()
{
// Allowed rotation values
$degs = array(90, 180, 270, 'vrt', 'hor');
@@ -411,7 +433,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
@@ -456,7 +478,7 @@ class CI_Image_lib {
* @param string
* @return bool
*/
- function image_process_gd($action = 'resize')
+ public function image_process_gd($action = 'resize')
{
$v2_override = FALSE;
@@ -568,7 +590,7 @@ class CI_Image_lib {
* @param string
* @return bool
*/
- function image_process_imagemagick($action = 'resize')
+ public function image_process_imagemagick($action = 'resize')
{
// Do we have a vaild library path?
if ($this->library_path == '')
@@ -638,7 +660,7 @@ class CI_Image_lib {
* @param string
* @return bool
*/
- function image_process_netpbm($action = 'resize')
+ public function image_process_netpbm($action = 'resize')
{
if ($this->library_path == '')
{
@@ -721,7 +743,7 @@ class CI_Image_lib {
* @access public
* @return bool
*/
- function image_rotate_gd()
+ public function image_rotate_gd()
{
// Create the image handle
if ( ! ($src_img = $this->image_create_gd()))
@@ -774,7 +796,7 @@ class CI_Image_lib {
* @access public
* @return bool
*/
- function image_mirror_gd()
+ public function image_mirror_gd()
{
if ( ! $src_img = $this->image_create_gd())
{
@@ -860,7 +882,7 @@ class CI_Image_lib {
* @param string
* @return bool
*/
- function watermark()
+ public function watermark()
{
if ($this->wm_type == 'overlay')
{
@@ -880,7 +902,7 @@ class CI_Image_lib {
* @access public
* @return bool
*/
- function overlay_watermark()
+ public function overlay_watermark()
{
if ( ! function_exists('imagecolortransparent'))
{
@@ -993,7 +1015,7 @@ class CI_Image_lib {
* @access public
* @return bool
*/
- function text_watermark()
+ public function text_watermark()
{
if ( ! ($src_img = $this->image_create_gd()))
{
@@ -1137,7 +1159,7 @@ class CI_Image_lib {
* @param string
* @return resource
*/
- function image_create_gd($path = '', $image_type = '')
+ public function image_create_gd($path = '', $image_type = '')
{
if ($path == '')
$path = $this->full_src_path;
@@ -1194,7 +1216,7 @@ class CI_Image_lib {
* @param resource
* @return bool
*/
- function image_save_gd($resource)
+ public function image_save_gd($resource)
{
switch ($this->image_type)
{
@@ -1255,7 +1277,7 @@ class CI_Image_lib {
* @param resource
* @return void
*/
- function image_display_gd($resource)
+ public function image_display_gd($resource)
{
header("Content-Disposition: filename={$this->source_image};");
header("Content-Type: {$this->mime_type}");
@@ -1290,7 +1312,7 @@ class CI_Image_lib {
* @access public
* @return void
*/
- function image_reproportion()
+ public function image_reproportion()
{
if ( ! is_numeric($this->width) OR ! is_numeric($this->height) OR $this->width == 0 OR $this->height == 0)
return;
@@ -1332,7 +1354,7 @@ class CI_Image_lib {
* @param string
* @return mixed
*/
- function get_image_properties($path = '', $return = FALSE)
+ public function get_image_properties($path = '', $return = FALSE)
{
// For now we require GD but we should
// find a way to determine this using IM or NetPBM
@@ -1392,7 +1414,7 @@ class CI_Image_lib {
* @param array
* @return array
*/
- function size_calculator($vals)
+ public function size_calculator($vals)
{
if ( ! is_array($vals))
{
@@ -1440,7 +1462,7 @@ class CI_Image_lib {
* @param array
* @return array
*/
- function explode_name($source_image)
+ public function explode_name($source_image)
{
$ext = strrchr($source_image, '.');
$name = ($ext === FALSE) ? $source_image : substr($source_image, 0, -strlen($ext));
@@ -1456,7 +1478,7 @@ class CI_Image_lib {
* @access public
* @return bool
*/
- function gd_loaded()
+ public function gd_loaded()
{
if ( ! extension_loaded('gd'))
{
@@ -1477,7 +1499,7 @@ class CI_Image_lib {
* @access public
* @return mixed
*/
- function gd_version()
+ public function gd_version()
{
if (function_exists('gd_info'))
{
@@ -1499,7 +1521,7 @@ class CI_Image_lib {
* @param string
* @return void
*/
- function set_error($msg)
+ public function set_error($msg)
{
$CI =& get_instance();
$CI->lang->load('imglib');
@@ -1531,19 +1553,13 @@ class CI_Image_lib {
* @param string
* @return string
*/
- function display_errors($open = '<p>', $close = '</p>')
+ public function display_errors($open = '<p>', $close = '</p>')
{
- $str = '';
- foreach ($this->error_msg as $val)
- {
- $str .= $open.$val.$close;
- }
-
- return $str;
+ return (count($this->error_msg) > 0) ? $open . implode($close . $open, $this->error_msg) . $close : '';
}
}
// END Image_lib Class
/* End of file Image_lib.php */
-/* Location: ./system/libraries/Image_lib.php */ \ No newline at end of file
+/* Location: ./system/libraries/Image_lib.php */
diff --git a/system/libraries/Log.php b/system/libraries/Log.php
index 6ea905f73..7f3a307f3 100644
--- a/system/libraries/Log.php
+++ b/system/libraries/Log.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -44,7 +44,7 @@ class CI_Log {
protected $_threshold_array = array();
protected $_date_fmt = 'Y-m-d H:i:s';
protected $_enabled = TRUE;
- protected $_levels = array('ERROR' => '1', 'DEBUG' => '2', 'INFO' => '3', 'ALL' => '4');
+ protected $_levels = array('ERROR' => 1, 'DEBUG' => 2, 'INFO' => 3, 'ALL' => 4);
/**
* Constructor
@@ -62,7 +62,7 @@ class CI_Log {
if (is_numeric($config['log_threshold']))
{
- $this->_threshold = $config['log_threshold'];
+ $this->_threshold = (int) $config['log_threshold'];
}
elseif (is_array($config['log_threshold']))
{
@@ -97,12 +97,10 @@ class CI_Log {
$level = strtoupper($level);
- if ( ! isset($this->_levels[$level]) OR ($this->_levels[$level] > $this->_threshold))
+ if (( ! isset($this->_levels[$level]) OR ($this->_levels[$level] > $this->_threshold))
+ AND ! isset($this->_threshold_array[$this->_levels[$level]]))
{
- if (empty($this->_threshold_array) OR ! isset($this->_threshold_array[$this->_levels[$level]]))
- {
- return FALSE;
- }
+ return FALSE;
}
@@ -111,7 +109,8 @@ class CI_Log {
if ( ! file_exists($filepath))
{
- $message .= "<"."?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ?".">\n\n";
+ $newfile = TRUE;
+ $message .= "<"."?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ?".">\n\n";
}
if ( ! $fp = @fopen($filepath, FOPEN_WRITE_CREATE))
@@ -126,7 +125,10 @@ class CI_Log {
flock($fp, LOCK_UN);
fclose($fp);
- @chmod($filepath, FILE_WRITE_MODE);
+ if (isset($newfile) AND $newfile === TRUE)
+ {
+ @chmod($filepath, FILE_WRITE_MODE);
+ }
return TRUE;
}
@@ -134,4 +136,4 @@ class CI_Log {
// END Log Class
/* End of file Log.php */
-/* Location: ./system/libraries/Log.php */ \ No newline at end of file
+/* Location: ./system/libraries/Log.php */
diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php
index 94961b568..eb5161d76 100644
--- a/system/libraries/Migration.php
+++ b/system/libraries/Migration.php
@@ -1,4 +1,4 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
@@ -101,12 +101,9 @@ class CI_Migration {
}
// Do we auto migrate to the latest migration?
- if ($this->_migration_auto_latest == TRUE)
+ if ($this->_migration_auto_latest === TRUE AND ! $this->latest())
{
- if ( ! $this->latest() )
- {
- show_error($this->error_string());
- }
+ show_error($this->error_string());
}
}
@@ -134,7 +131,6 @@ class CI_Migration {
++$stop;
$step = 1;
}
-
else
{
// Moving Down
@@ -158,11 +154,11 @@ class CI_Migration {
}
// Migration step not found
- if (count($f) == 0)
+ if (count($f) === 0)
{
// If trying to migrate up to a version greater than the last
// existing one, migrate to the last one.
- if ($step == 1)
+ if ($step === 1)
{
break;
}
@@ -214,7 +210,7 @@ class CI_Migration {
log_message('debug', 'Current migration: '.$current_version);
- $version = $i + ($step == 1 ? -1 : 0);
+ $version = $i + ($step === 1 ? -1 : 0);
// If there is nothing to do so quit
if ($migrations === array())
@@ -301,13 +297,11 @@ class CI_Migration {
{
// Load all *_*.php files in the migrations path
$files = glob($this->_migration_path.'*_*.php');
- $file_count = count($files);
- for ($i = 0; $i < $file_count; $i++)
+ for ($i = 0, $c = count($files); $i < $c; $i++)
{
// Mark wrongly formatted files as false for later filtering
- $name = basename($files[$i], '.php');
- if ( ! preg_match('/^\d{3}_(\w+)$/', $name))
+ if ( ! preg_match('/^\d{3}_(\w+)$/', basename($files[$i], '.php')))
{
$files[$i] = FALSE;
}
@@ -364,4 +358,4 @@ class CI_Migration {
}
/* End of file Migration.php */
-/* Location: ./system/libraries/Migration.php */ \ No newline at end of file
+/* Location: ./system/libraries/Migration.php */
diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
index f470debeb..eea953ae4 100644
--- a/system/libraries/Pagination.php
+++ b/system/libraries/Pagination.php
@@ -5,9 +5,9 @@
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -38,39 +38,38 @@
*/
class CI_Pagination {
- var $base_url = ''; // The page we are linking to
- var $prefix = ''; // A custom prefix added to the path.
- var $suffix = ''; // A custom suffix added to the path.
-
- var $total_rows = 0; // 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 $use_page_numbers = FALSE; // Use page number for segment instead of offset
- var $first_link = '&lsaquo; First';
- var $next_link = '&gt;';
- var $prev_link = '&lt;';
- var $last_link = 'Last &rsaquo;';
- var $uri_segment = 3;
- var $full_tag_open = '';
- var $full_tag_close = '';
- var $first_tag_open = '';
- var $first_tag_close = '&nbsp;';
- var $last_tag_open = '&nbsp;';
- var $last_tag_close = '';
- var $first_url = ''; // Alternative URL for the First Page.
- var $cur_tag_open = '&nbsp;<strong>';
- var $cur_tag_close = '</strong>';
- var $next_tag_open = '&nbsp;';
- var $next_tag_close = '&nbsp;';
- var $prev_tag_open = '&nbsp;';
- var $prev_tag_close = '';
- var $num_tag_open = '&nbsp;';
- var $num_tag_close = '';
- var $page_query_string = FALSE;
- var $query_string_segment = 'per_page';
- var $display_pages = TRUE;
- var $anchor_class = '';
+ protected $base_url = ''; // The page we are linking to
+ protected $prefix = ''; // A custom prefix added to the path.
+ protected $suffix = ''; // A custom suffix added to the path.
+ protected $total_rows = 0; // Total number of items (database results)
+ protected $per_page = 10; // Max number of items you want shown per page
+ protected $num_links = 2; // Number of "digit" links to show before/after the currently viewed page
+ protected $cur_page = 0; // The current page being viewed
+ protected $use_page_numbers = FALSE; // Use page number for segment instead of offset
+ protected $first_link = '&lsaquo; First';
+ protected $next_link = '&gt;';
+ protected $prev_link = '&lt;';
+ protected $last_link = 'Last &rsaquo;';
+ protected $uri_segment = 3;
+ protected $full_tag_open = '';
+ protected $full_tag_close = '';
+ protected $first_tag_open = '';
+ protected $first_tag_close = '&nbsp;';
+ protected $last_tag_open = '&nbsp;';
+ protected $last_tag_close = '';
+ protected $first_url = ''; // Alternative URL for the First Page.
+ protected $cur_tag_open = '&nbsp;<strong>';
+ protected $cur_tag_close = '</strong>';
+ protected $next_tag_open = '&nbsp;';
+ protected $next_tag_close = '&nbsp;';
+ protected $prev_tag_open = '&nbsp;';
+ protected $prev_tag_close = '';
+ protected $num_tag_open = '&nbsp;';
+ protected $num_tag_close = '';
+ protected $page_query_string = FALSE;
+ protected $query_string_segment = 'per_page';
+ protected $display_pages = TRUE;
+ protected $anchor_class = '';
/**
* Constructor
@@ -80,16 +79,7 @@ class CI_Pagination {
*/
public function __construct($params = array())
{
- if (count($params) > 0)
- {
- $this->initialize($params);
- }
-
- if ($this->anchor_class != '')
- {
- $this->anchor_class = 'class="'.$this->anchor_class.'" ';
- }
-
+ $this->initialize($params);
log_message('debug', "Pagination Class Initialized");
}
@@ -102,7 +92,7 @@ class CI_Pagination {
* @param array initialization parameters
* @return void
*/
- function initialize($params = array())
+ public function initialize($params = array())
{
if (count($params) > 0)
{
@@ -114,6 +104,11 @@ class CI_Pagination {
}
}
}
+
+ if ($this->anchor_class != '')
+ {
+ $this->anchor_class = 'class="'.$this->anchor_class.'" ';
+ }
}
// --------------------------------------------------------------------
@@ -124,7 +119,7 @@ class CI_Pagination {
* @access public
* @return string
*/
- function create_links()
+ public function create_links()
{
// If our item count or per-page total is zero there is no need to continue.
if ($this->total_rows == 0 OR $this->per_page == 0)
@@ -167,7 +162,7 @@ class CI_Pagination {
$this->cur_page = (int) $this->cur_page;
}
}
-
+
// Set current page to 1 if using page numbers instead of offset
if ($this->use_page_numbers AND $this->cur_page == 0)
{
@@ -204,7 +199,7 @@ class CI_Pagination {
}
$uri_page_number = $this->cur_page;
-
+
if ( ! $this->use_page_numbers)
{
$this->cur_page = floor(($this->cur_page/$this->per_page) + 1);
diff --git a/system/libraries/Parser.php b/system/libraries/Parser.php
index 0e6ab63d8..39aa61e45 100644
--- a/system/libraries/Parser.php
+++ b/system/libraries/Parser.php
@@ -1,13 +1,13 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -38,9 +38,10 @@
*/
class CI_Parser {
- var $l_delim = '{';
- var $r_delim = '}';
- var $object;
+ public $l_delim = '{';
+ public $r_delim = '}';
+ public $object;
+ private $CI;
/**
* Parse a template
@@ -56,8 +57,8 @@ class CI_Parser {
*/
public function parse($template, $data, $return = FALSE)
{
- $CI =& get_instance();
- $template = $CI->load->view($template, $data, TRUE);
+ $this->CI =& get_instance();
+ $template = $this->CI->load->view($template, $data, TRUE);
return $this->_parse($template, $data, $return);
}
@@ -76,7 +77,7 @@ class CI_Parser {
* @param bool
* @return string
*/
- function parse_string($template, $data, $return = FALSE)
+ public function parse_string($template, $data, $return = FALSE)
{
return $this->_parse($template, $data, $return);
}
@@ -89,13 +90,13 @@ class CI_Parser {
* Parses pseudo-variables contained in the specified template,
* replacing them with the data in the second param
*
- * @access public
+ * @access private
* @param string
* @param array
* @param bool
* @return string
*/
- function _parse($template, $data, $return = FALSE)
+ private function _parse($template, $data, $return = FALSE)
{
if ($template == '')
{
@@ -116,8 +117,7 @@ class CI_Parser {
if ($return == FALSE)
{
- $CI =& get_instance();
- $CI->output->append_output($template);
+ $this->CI->output->append_output($template);
}
return $template;
@@ -133,7 +133,7 @@ class CI_Parser {
* @param string
* @return void
*/
- function set_delimiters($l = '{', $r = '}')
+ public function set_delimiters($l = '{', $r = '}')
{
$this->l_delim = $l;
$this->r_delim = $r;
@@ -150,9 +150,9 @@ class CI_Parser {
* @param string
* @return string
*/
- function _parse_single($key, $val, $string)
+ private function _parse_single($key, $val, $string)
{
- return str_replace($this->l_delim.$key.$this->r_delim, $val, $string);
+ return str_replace($this->l_delim.$key.$this->r_delim, (string) $val, $string);
}
// --------------------------------------------------------------------
@@ -168,7 +168,7 @@ class CI_Parser {
* @param string
* @return string
*/
- function _parse_pair($variable, $data, $string)
+ private function _parse_pair($variable, $data, $string)
{
if (FALSE === ($match = $this->_match_pair($string, $variable)))
{
@@ -178,7 +178,7 @@ class CI_Parser {
$str = '';
foreach ($data as $row)
{
- $temp = $match['1'];
+ $temp = $match[1];
foreach ($row as $key => $val)
{
if ( ! is_array($val))
@@ -194,7 +194,7 @@ class CI_Parser {
$str .= $temp;
}
- return str_replace($match['0'], $str, $string);
+ return str_replace($match[0], $str, $string);
}
// --------------------------------------------------------------------
@@ -207,7 +207,7 @@ class CI_Parser {
* @param string
* @return mixed
*/
- function _match_pair($string, $variable)
+ private function _match_pair($string, $variable)
{
if ( ! preg_match("|" . preg_quote($this->l_delim) . $variable . preg_quote($this->r_delim) . "(.+?)". preg_quote($this->l_delim) . '/' . $variable . preg_quote($this->r_delim) . "|s", $string, $match))
{
diff --git a/system/libraries/Trackback.php b/system/libraries/Trackback.php
index e903ea7d0..1e5928314 100644
--- a/system/libraries/Trackback.php
+++ b/system/libraries/Trackback.php
@@ -5,9 +5,9 @@
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -40,12 +40,12 @@
*/
class CI_Trackback {
- var $time_format = 'local';
- var $charset = 'UTF-8';
- var $data = array('url' => '', 'title' => '', 'excerpt' => '', 'blog_name' => '', 'charset' => '');
- var $convert_ascii = TRUE;
- var $response = '';
- var $error_msg = array();
+ public $time_format = 'local';
+ public $charset = 'UTF-8';
+ public $data = array('url' => '', 'title' => '', 'excerpt' => '', 'blog_name' => '', 'charset' => '');
+ public $convert_ascii = TRUE;
+ public $response = '';
+ public $error_msg = array();
/**
* Constructor
@@ -66,7 +66,7 @@ class CI_Trackback {
* @param array
* @return bool
*/
- function send($tb_data)
+ public function send($tb_data)
{
if ( ! is_array($tb_data))
{
@@ -147,7 +147,7 @@ class CI_Trackback {
* @access public
* @return bool
*/
- function receive()
+ public function receive()
{
foreach (array('url', 'title', 'blog_name', 'excerpt') as $val)
{
@@ -190,7 +190,7 @@ class CI_Trackback {
* @param string
* @return void
*/
- function send_error($message = 'Incomplete Information')
+ public 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;
@@ -207,7 +207,7 @@ class CI_Trackback {
* @access public
* @return void
*/
- function send_success()
+ public function send_success()
{
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?".">\n<response>\n<error>0</error>\n</response>";
exit;
@@ -222,7 +222,7 @@ class CI_Trackback {
* @param string
* @return string
*/
- function data($item)
+ public function data($item)
{
return ( ! isset($this->data[$item])) ? '' : $this->data[$item];
}
@@ -240,7 +240,7 @@ class CI_Trackback {
* @param string
* @return bool
*/
- function process($url, $data)
+ public function process($url, $data)
{
$target = parse_url($url);
@@ -309,7 +309,7 @@ class CI_Trackback {
* @param string
* @return string
*/
- function extract_urls($urls)
+ public function extract_urls($urls)
{
// Remove the pesky white space and replace with a comma.
$urls = preg_replace("/\s*(\S+)\s*/", "\\1,", $urls);
@@ -345,7 +345,7 @@ class CI_Trackback {
* @param string
* @return string
*/
- function validate_url($url)
+ public function validate_url($url)
{
$url = trim($url);
@@ -364,7 +364,7 @@ class CI_Trackback {
* @param string
* @return string
*/
- function get_id($url)
+ public function get_id($url)
{
$tb_id = "";
@@ -413,7 +413,7 @@ class CI_Trackback {
* @param string
* @return string
*/
- function convert_xml($str)
+ public function convert_xml($str)
{
$temp = '__TEMP_AMPERSANDS__';
@@ -443,7 +443,7 @@ class CI_Trackback {
* @param string
* @return string
*/
- function limit_characters($str, $n = 500, $end_char = '&#8230;')
+ public function limit_characters($str, $n = 500, $end_char = '&#8230;')
{
if (strlen($str) < $n)
{
@@ -480,7 +480,7 @@ class CI_Trackback {
* @param string
* @return string
*/
- function convert_ascii($str)
+ public function convert_ascii($str)
{
$count = 1;
$out = '';
@@ -526,7 +526,7 @@ class CI_Trackback {
* @param string
* @return void
*/
- function set_error($msg)
+ public function set_error($msg)
{
log_message('error', $msg);
$this->error_msg[] = $msg;
@@ -542,19 +542,13 @@ class CI_Trackback {
* @param string
* @return string
*/
- function display_errors($open = '<p>', $close = '</p>')
+ public function display_errors($open = '<p>', $close = '</p>')
{
- $str = '';
- foreach ($this->error_msg as $val)
- {
- $str .= $open.$val.$close;
- }
-
- return $str;
+ return (count($this->error_msg) > 0) ? $open . implode($close . $open, $this->error_msg) . $close : '';
}
}
// END Trackback Class
/* End of file Trackback.php */
-/* Location: ./system/libraries/Trackback.php */ \ No newline at end of file
+/* Location: ./system/libraries/Trackback.php */
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 66e91c5b6..826bcceb8 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -5,9 +5,9 @@
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -934,13 +934,7 @@ class CI_Upload {
*/
public function display_errors($open = '<p>', $close = '</p>')
{
- $str = '';
- foreach ($this->error_msg as $val)
- {
- $str .= $open.$val.$close;
- }
-
- return $str;
+ return (count($this->error_msg) > 0) ? $open . implode($close . $open, $this->error_msg) . $close : '';
}
// --------------------------------------------------------------------
@@ -1086,4 +1080,4 @@ class CI_Upload {
// END Upload Class
/* End of file Upload.php */
-/* Location: ./system/libraries/Upload.php */ \ No newline at end of file
+/* Location: ./system/libraries/Upload.php */
diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php
index 9101eecb4..52f1bc3d0 100644
--- a/system/libraries/Zip.php
+++ b/system/libraries/Zip.php
@@ -99,9 +99,9 @@ class CI_Zip {
*/
function _get_mod_time($dir)
{
- // filemtime() will return false, but it does raise an error.
- $date = (@filemtime($dir)) ? filemtime($dir) : getdate($this->now);
-
+ // filemtime() may return false, but raises an error for non-existing files
+ $date = (file_exists($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'];