diff options
Diffstat (limited to 'system')
-rw-r--r-- | system/libraries/Calendar.php | 147 | ||||
-rw-r--r-- | system/libraries/Cart.php | 199 | ||||
-rw-r--r-- | system/libraries/Driver.php | 15 | ||||
-rw-r--r-- | system/libraries/Email.php | 478 | ||||
-rw-r--r-- | system/libraries/Ftp.php | 102 | ||||
-rw-r--r-- | system/libraries/Image_lib.php | 148 | ||||
-rw-r--r-- | system/libraries/Log.php | 20 | ||||
-rw-r--r-- | system/libraries/Parser.php | 40 | ||||
-rw-r--r-- | system/libraries/Trackback.php | 54 | ||||
-rw-r--r-- | system/libraries/Upload.php | 14 |
10 files changed, 480 insertions, 737 deletions
diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index f5ef4d576..605765bf6 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -1,13 +1,13 @@ -<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); +<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); /** * CodeIgniter * * An open source application development framework for PHP 5.1.6 or newer * * NOTICE OF LICENSE - * + * * Licensed under the Open Software License version 3.0 - * + * * This source file is subject to the Open Software License (OSL 3.0) that is * bundled with this package in the files license.txt / license.rst. It is * also available through the world wide web at this URL: @@ -40,15 +40,15 @@ */ class CI_Calendar { - var $CI; - var $lang; - var $local_time; - var $template = ''; - var $start_day = 'sunday'; - var $month_type = 'long'; - var $day_type = 'abr'; - var $show_next_prev = FALSE; - var $next_prev_url = ''; + private $CI; + public $lang; + public $local_time; + public $template = ''; + public $start_day = 'sunday'; + public $month_type = 'long'; + public $day_type = 'abr'; + public $show_next_prev = FALSE; + public $next_prev_url = ''; /** * Constructor @@ -85,7 +85,7 @@ class CI_Calendar { * @param array config preferences * @return void */ - function initialize($config = array()) + public function initialize($config = array()) { foreach ($config as $key => $val) { @@ -107,23 +107,30 @@ class CI_Calendar { * @param array the data to be shown in the calendar cells * @return string */ - function generate($year = '', $month = '', $data = array()) + public function generate($year = '', $month = '', $data = array()) { // Set and validate the supplied month/year if ($year == '') - $year = date("Y", $this->local_time); - - if ($month == '') - $month = date("m", $this->local_time); - - if (strlen($year) == 1) + { + $year = date('Y', $this->local_time); + } + elseif (strlen($year) === 1) + { $year = '200'.$year; - - if (strlen($year) == 2) + } + elseif (strlen($year) === 2) + { $year = '20'.$year; + } - if (strlen($month) == 1) + if ($month == '') + { + $month = date('m', $this->local_time); + } + elseif (strlen($month) === 1) + { $month = '0'.$month; + } $adjusted_date = $this->adjust_date($month, $year); @@ -149,9 +156,9 @@ class CI_Calendar { // Set the current month/year/day // We use this to determine the "today" date - $cur_year = date("Y", $this->local_time); - $cur_month = date("m", $this->local_time); - $cur_day = date("j", $this->local_time); + $cur_year = date('Y', $this->local_time); + $cur_month = date('m', $this->local_time); + $cur_day = date('j', $this->local_time); $is_current_month = ($cur_year == $year AND $cur_month == $month) ? TRUE : FALSE; @@ -159,12 +166,7 @@ class CI_Calendar { $this->parse_template(); // Begin building the calendar output - $out = $this->temp['table_open']; - $out .= "\n"; - - $out .= "\n"; - $out .= $this->temp['heading_row_start']; - $out .= "\n"; + $out = $this->temp['table_open']."\n\n".$this->temp['heading_row_start']."\n"; // "previous" month link if ($this->show_next_prev == TRUE) @@ -173,18 +175,16 @@ class CI_Calendar { $this->next_prev_url = preg_replace("/(.+?)\/*$/", "\\1/", $this->next_prev_url); $adjusted_date = $this->adjust_date($month - 1, $year); - $out .= str_replace('{previous_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_previous_cell']); - $out .= "\n"; + $out .= str_replace('{previous_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_previous_cell'])."\n"; } // Heading containing the month/year $colspan = ($this->show_next_prev == TRUE) ? 5 : 7; - $this->temp['heading_title_cell'] = str_replace('{colspan}', $colspan, $this->temp['heading_title_cell']); - $this->temp['heading_title_cell'] = str_replace('{heading}', $this->get_month_name($month)." ".$year, $this->temp['heading_title_cell']); + $this->temp['heading_title_cell'] = str_replace('{colspan}', $colspan, + str_replace('{heading}', $this->get_month_name($month).' '.$year, $this->temp['heading_title_cell'])); - $out .= $this->temp['heading_title_cell']; - $out .= "\n"; + $out .= $this->temp['heading_title_cell']."\n"; // "next" month link if ($this->show_next_prev == TRUE) @@ -193,14 +193,9 @@ class CI_Calendar { $out .= str_replace('{next_url}', $this->next_prev_url.$adjusted_date['year'].'/'.$adjusted_date['month'], $this->temp['heading_next_cell']); } - $out .= "\n"; - $out .= $this->temp['heading_row_end']; - $out .= "\n"; - - // Write the cells containing the days of the week - $out .= "\n"; - $out .= $this->temp['week_row_start']; - $out .= "\n"; + $out .= "\n".$this->temp['heading_row_end']."\n\n" + // Write the cells containing the days of the week + .$this->temp['week_row_start']."\n"; $day_names = $this->get_day_names(); @@ -209,33 +204,31 @@ class CI_Calendar { $out .= str_replace('{week_day}', $day_names[($start_day + $i) %7], $this->temp['week_day_cell']); } - $out .= "\n"; - $out .= $this->temp['week_row_end']; - $out .= "\n"; + $out .= "\n".$this->temp['week_row_end']."\n"; // Build the main body of the calendar while ($day <= $total_days) { - $out .= "\n"; - $out .= $this->temp['cal_row_start']; - $out .= "\n"; + $out .= "\n".$this->temp['cal_row_start']."\n"; for ($i = 0; $i < 7; $i++) { - $out .= ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_start_today'] : $this->temp['cal_cell_start']; + $out .= ($is_current_month === TRUE AND $day == $cur_day) ? $this->temp['cal_cell_start_today'] : $this->temp['cal_cell_start']; if ($day > 0 AND $day <= $total_days) { if (isset($data[$day])) { // Cells with content - $temp = ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_content_today'] : $this->temp['cal_cell_content']; - $out .= str_replace('{day}', $day, str_replace('{content}', $data[$day], $temp)); + $temp = ($is_current_month === TRUE AND $day == $cur_day) ? + $this->temp['cal_cell_content_today'] : $this->temp['cal_cell_content']; + $out .= str_replace(array('{content}', '{day}'), array($data[$day], $day), $temp); } else { // Cells with no content - $temp = ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_no_content_today'] : $this->temp['cal_cell_no_content']; + $temp = ($is_current_month === TRUE AND $day == $cur_day) ? + $this->temp['cal_cell_no_content_today'] : $this->temp['cal_cell_no_content']; $out .= str_replace('{day}', $day, $temp); } } @@ -245,17 +238,14 @@ class CI_Calendar { $out .= $this->temp['cal_cell_blank']; } - $out .= ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_end_today'] : $this->temp['cal_cell_end']; + $out .= ($is_current_month === TRUE AND $day == $cur_day) ? $this->temp['cal_cell_end_today'] : $this->temp['cal_cell_end']; $day++; } - $out .= "\n"; - $out .= $this->temp['cal_row_end']; - $out .= "\n"; + $out .= "\n".$this->temp['cal_row_end']."\n"; } - $out .= "\n"; - $out .= $this->temp['table_close']; + $out .= "\n".$this->temp['table_close']; return $out; } @@ -272,7 +262,7 @@ class CI_Calendar { * @param integer the month * @return string */ - function get_month_name($month) + public function get_month_name($month) { if ($this->month_type == 'short') { @@ -287,7 +277,7 @@ class CI_Calendar { if ($this->CI->lang->line($month) === FALSE) { - return ucfirst(str_replace('cal_', '', $month)); + return ucfirst(substr($month, 4)); } return $this->CI->lang->line($month); @@ -305,10 +295,12 @@ class CI_Calendar { * @param string * @return array */ - function get_day_names($day_type = '') + public function get_day_names($day_type = '') { if ($day_type != '') + { $this->day_type = $day_type; + } if ($this->day_type == 'long') { @@ -324,9 +316,9 @@ class CI_Calendar { } $days = array(); - foreach ($day_names as $val) + for ($i = 0, $c = count($day_names); $i < $c; $i++) { - $days[] = ($this->CI->lang->line('cal_'.$val) === FALSE) ? ucfirst($val) : $this->CI->lang->line('cal_'.$val); + $days[] = ($this->CI->lang->line('cal_'.$day_names[$i]) === FALSE) ? ucfirst($day_names[$i]) : $this->CI->lang->line('cal_'.$day_names[$i]); } return $days; @@ -346,7 +338,7 @@ class CI_Calendar { * @param integer the year * @return array */ - function adjust_date($month, $year) + public function adjust_date($month, $year) { $date = array(); @@ -365,7 +357,7 @@ class CI_Calendar { $date['year']--; } - if (strlen($date['month']) == 1) + if (strlen($date['month']) === 1) { $date['month'] = '0'.$date['month']; } @@ -383,7 +375,7 @@ class CI_Calendar { * @param integer the year * @return integer */ - function get_total_days($month, $year) + public function get_total_days($month, $year) { $days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); @@ -414,7 +406,7 @@ class CI_Calendar { * @access public * @return array */ - function default_template() + public function default_template() { return array ( 'table_open' => '<table border="0" cellpadding="4" cellspacing="0">', @@ -452,7 +444,7 @@ class CI_Calendar { * @access public * @return void */ - function parse_template() + public function parse_template() { $this->temp = $this->default_template(); @@ -467,14 +459,11 @@ class CI_Calendar { { if (preg_match("/\{".$val."\}(.*?)\{\/".$val."\}/si", $this->template, $match)) { - $this->temp[$val] = $match['1']; + $this->temp[$val] = $match[1]; } - else + elseif (in_array($val, $today, TRUE)) { - if (in_array($val, $today, TRUE)) - { - $this->temp[$val] = $this->temp[str_replace('_today', '', $val)]; - } + $this->temp[$val] = $this->temp[substr($val, 0, -6)]; } } } @@ -484,4 +473,4 @@ class CI_Calendar { // END CI_Calendar class /* End of file Calendar.php */ -/* Location: ./system/libraries/Calendar.php */
\ No newline at end of file +/* Location: ./system/libraries/Calendar.php */ diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php index 717ccd9fb..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,13 +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 - var $product_name_safe = true; // only allow safe product names + 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(); /** @@ -59,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"); @@ -95,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; @@ -132,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; @@ -150,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; @@ -170,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) @@ -186,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; @@ -196,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 ( $this->product_name_safe && ! 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; @@ -204,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'])) @@ -244,33 +229,13 @@ 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 - if (isset($this->_cart_contents[$rowid]['qty'])) - { - // set our old quantity - $old_quantity = (int)$this->_cart_contents[$rowid]['qty']; - } - else - { - // we have no old quantity but - we don't want to throw an error - $old_quantity = 0; - } - - // let's unset this first, just to make sure our index contains only the data from this submission - unset($this->_cart_contents[$rowid]); + $old_quantity = isset($this->_cart_contents[$rowid]['qty']) ? (int) $this->_cart_contents[$rowid]['qty'] : 0; - // 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; - } - - // add old quantity back in - $this->_cart_contents[$rowid]['qty'] = ($this->_cart_contents[$rowid]['qty'] + $old_quantity); - - // Woot! return $rowid; } @@ -289,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; } @@ -302,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; } @@ -313,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; } @@ -324,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; @@ -347,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']])) @@ -356,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'])) @@ -393,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 @@ -410,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) { @@ -446,13 +400,13 @@ class CI_Cart { * @access public * @return integer */ - function total() + public function total() { return $this->_cart_contents['cart_total']; } - + // -------------------------------------------------------------------- - + /** * Remove Item * @@ -463,16 +417,12 @@ class CI_Cart { */ public function remove($rowid) { - // just do an unset + // unset & save unset($this->_cart_contents[$rowid]); - - // we need to save the cart now we've made our changes $this->_save_cart(); - - // completed - return true; + return TRUE; } - + // -------------------------------------------------------------------- /** @@ -483,7 +433,7 @@ class CI_Cart { * @access public * @return integer */ - function total_items() + public function total_items() { return $this->_cart_contents['total_items']; } @@ -498,19 +448,10 @@ class CI_Cart { * @access public * @return array */ - function contents($newest_first = false) + public function contents($newest_first = FALSE) { // do we want the newest first? - if($newest_first) - { - // reverse the array - $cart = array_reverse($this->_cart_contents); - } - else - { - // just added first to last - $cart = $this->_cast_contents; - } + $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']); @@ -528,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; } // -------------------------------------------------------------------- @@ -550,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(); } // -------------------------------------------------------------------- @@ -568,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 == '') { @@ -578,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, '.', ','); } @@ -591,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'); } @@ -608,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/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 2ed488c7e..20ca1f055 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -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,7 +114,7 @@ class CI_Image_lib { * @access public * @return void */ - function clear() + public function clear() { $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'); @@ -158,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 @@ -379,7 +379,7 @@ class CI_Image_lib { * @access public * @return bool */ - function resize() + public function resize() { $protocol = 'image_process_'.$this->image_library; @@ -402,7 +402,7 @@ class CI_Image_lib { * @access public * @return bool */ - function crop() + public function crop() { $protocol = 'image_process_'.$this->image_library; @@ -425,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'); @@ -478,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; @@ -590,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 == '') @@ -660,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 == '') { @@ -743,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())) @@ -796,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()) { @@ -882,7 +882,7 @@ class CI_Image_lib { * @param string * @return bool */ - function watermark() + public function watermark() { if ($this->wm_type == 'overlay') { @@ -902,7 +902,7 @@ class CI_Image_lib { * @access public * @return bool */ - function overlay_watermark() + public function overlay_watermark() { if ( ! function_exists('imagecolortransparent')) { @@ -1015,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())) { @@ -1159,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; @@ -1216,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) { @@ -1277,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}"); @@ -1312,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; @@ -1354,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 @@ -1414,7 +1414,7 @@ class CI_Image_lib { * @param array * @return array */ - function size_calculator($vals) + public function size_calculator($vals) { if ( ! is_array($vals)) { @@ -1462,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)); @@ -1478,7 +1478,7 @@ class CI_Image_lib { * @access public * @return bool */ - function gd_loaded() + public function gd_loaded() { if ( ! extension_loaded('gd')) { @@ -1499,7 +1499,7 @@ class CI_Image_lib { * @access public * @return mixed */ - function gd_version() + public function gd_version() { if (function_exists('gd_info')) { @@ -1521,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'); @@ -1553,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 46c5b6ed2..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; } @@ -112,7 +110,7 @@ class CI_Log { if ( ! file_exists($filepath)) { $newfile = TRUE; - $message .= "<"."?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ?".">\n\n"; + $message .= "<"."?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ?".">\n\n"; } if ( ! $fp = @fopen($filepath, FOPEN_WRITE_CREATE)) 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 = '…') + public function limit_characters($str, $n = 500, $end_char = '…') { 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 */ |