Upgrade to CodeIgniter 2.0.3

This commit is contained in:
Eike Foken
2011-09-13 19:15:50 +02:00
parent 8dd1099e04
commit a8c2551be2
53 changed files with 1949 additions and 578 deletions

View File

@@ -10,29 +10,29 @@
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 2.0
* @filesource
* @filesource
*/
// ------------------------------------------------------------------------
/**
* CodeIgniter Dummy Caching Class
* CodeIgniter Dummy Caching Class
*
* @package CodeIgniter
* @subpackage Libraries
* @category Core
* @author ExpressionEngine Dev Team
* @link
* @link
*/
class CI_Cache_dummy extends CI_Driver {
/**
* Get
* Get
*
* Since this is the dummy class, it's always going to return FALSE.
*
* @param string
* @param string
* @return Boolean FALSE
*/
public function get($id)
@@ -40,8 +40,8 @@ class CI_Cache_dummy extends CI_Driver {
return FALSE;
}
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
/**
* Cache Save
*
@@ -55,7 +55,7 @@ class CI_Cache_dummy extends CI_Driver {
{
return TRUE;
}
// ------------------------------------------------------------------------
/**
@@ -112,7 +112,7 @@ class CI_Cache_dummy extends CI_Driver {
/**
* Is this caching driver supported on the system?
* Of course this one is.
*
*
* @return TRUE;
*/
public function is_supported()
@@ -121,9 +121,9 @@ class CI_Cache_dummy extends CI_Driver {
}
// ------------------------------------------------------------------------
}
// End Class
/* End of file Cache_apc.php */
/* Location: ./system/libraries/Cache/drivers/Cache_apc.php */
/* End of file Cache_dummy.php */
/* Location: ./system/libraries/Cache/drivers/Cache_dummy.php */

View File

@@ -47,7 +47,7 @@ class CI_Calendar {
{
$this->CI =& get_instance();
if ( ! in_array('calendar_lang'.EXT, $this->CI->lang->is_loaded, TRUE))
if ( ! in_array('calendar_lang.php', $this->CI->lang->is_loaded, TRUE))
{
$this->CI->lang->load('calendar');
}

View File

@@ -374,6 +374,7 @@ class CI_Cart {
// Lets add up the individual prices and set the cart sub-total
$total = 0;
$items = 0;
foreach ($this->_cart_contents as $key => $val)
{
// We make sure the array contains the proper indexes
@@ -383,13 +384,14 @@ class CI_Cart {
}
$total += ($val['price'] * $val['qty']);
$items += $val['qty'];
// Set the subtotal
$this->_cart_contents[$key]['subtotal'] = ($this->_cart_contents[$key]['price'] * $this->_cart_contents[$key]['qty']);
}
// Set the cart total and total items.
$this->_cart_contents['total_items'] = count($this->_cart_contents);
$this->_cart_contents['total_items'] = $items;
$this->_cart_contents['cart_total'] = $total;
// Is our cart empty? If so we delete it from the session

View File

@@ -43,11 +43,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 = strtolower(preg_replace('/^CI_/', '', $this->lib_name));
$driver_name = strtolower(preg_replace('/^CI_/', '', $child_class));
$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
@@ -59,7 +59,7 @@ class CI_Driver_Library {
// loves me some nesting!
foreach (array(ucfirst($driver_name), $driver_name) as $class)
{
$filepath = $path.'libraries/'.$lib_name.'/drivers/'.$class.EXT;
$filepath = $path.'libraries/'.$lib_name.'/drivers/'.$class.'.php';
if (file_exists($filepath))
{
@@ -226,4 +226,4 @@ class CI_Driver {
// END CI_Driver CLASS
/* End of file Driver.php */
/* Location: ./system/libraries/Driver.php */
/* Location: ./system/libraries/Driver.php */

View File

@@ -395,7 +395,7 @@ class CI_Email {
public function attach($filename, $disposition = 'attachment')
{
$this->_attach_name[] = $filename;
$this->_attach_type[] = $this->_mime_types(next(explode('.', basename($filename))));
$this->_attach_type[] = $this->_mime_types(pathinfo($filename, PATHINFO_EXTENSION));
$this->_attach_disp[] = $disposition; // Can also be 'inline' Not sure if it matters
return $this;
}
@@ -722,7 +722,7 @@ class CI_Email {
{
if ( ! is_array($email))
{
$this->_set_error_message('email_must_be_array');
$this->_set_error_message('lang:email_must_be_array');
return FALSE;
}
@@ -730,7 +730,7 @@ class CI_Email {
{
if ( ! $this->valid_email($val))
{
$this->_set_error_message('email_invalid_address', $val);
$this->_set_error_message('lang:email_invalid_address', $val);
return FALSE;
}
}
@@ -1131,7 +1131,7 @@ class CI_Email {
if ( ! file_exists($filename))
{
$this->_set_error_message('email_attachment_missing', $filename);
$this->_set_error_message('lang:email_attachment_missing', $filename);
return FALSE;
}
@@ -1146,7 +1146,7 @@ class CI_Email {
if ( ! $fp = fopen($filename, FOPEN_READ))
{
$this->_set_error_message('email_attachment_unreadable', $filename);
$this->_set_error_message('lang:email_attachment_unreadable', $filename);
return FALSE;
}
@@ -1353,7 +1353,7 @@ class CI_Email {
( ! isset($this->_bcc_array) AND ! isset($this->_headers['Bcc'])) AND
( ! isset($this->_headers['Cc'])))
{
$this->_set_error_message('email_no_recipients');
$this->_set_error_message('lang:email_no_recipients');
return FALSE;
}
@@ -1484,7 +1484,7 @@ class CI_Email {
if ( ! $this->_send_with_mail())
{
$this->_set_error_message('email_send_failure_phpmail');
$this->_set_error_message('lang:email_send_failure_phpmail');
return FALSE;
}
break;
@@ -1492,7 +1492,7 @@ class CI_Email {
if ( ! $this->_send_with_sendmail())
{
$this->_set_error_message('email_send_failure_sendmail');
$this->_set_error_message('lang:email_send_failure_sendmail');
return FALSE;
}
break;
@@ -1500,14 +1500,14 @@ class CI_Email {
if ( ! $this->_send_with_smtp())
{
$this->_set_error_message('email_send_failure_smtp');
$this->_set_error_message('lang:email_send_failure_smtp');
return FALSE;
}
break;
}
$this->_set_error_message('email_sent', $this->_get_protocol());
$this->_set_error_message('lang:email_sent', $this->_get_protocol());
return TRUE;
}
@@ -1578,8 +1578,8 @@ class CI_Email {
if ($status != 0)
{
$this->_set_error_message('email_exit_status', $status);
$this->_set_error_message('email_no_socket');
$this->_set_error_message('lang:email_exit_status', $status);
$this->_set_error_message('lang:email_no_socket');
return FALSE;
}
@@ -1598,7 +1598,7 @@ class CI_Email {
{
if ($this->smtp_host == '')
{
$this->_set_error_message('email_no_hostname');
$this->_set_error_message('lang:email_no_hostname');
return FALSE;
}
@@ -1647,7 +1647,7 @@ class CI_Email {
if (strncmp($reply, '250', 3) != 0)
{
$this->_set_error_message('email_smtp_error', $reply);
$this->_set_error_message('lang:email_smtp_error', $reply);
return FALSE;
}
@@ -1674,7 +1674,7 @@ class CI_Email {
if ( ! is_resource($this->_smtp_connect))
{
$this->_set_error_message('email_smtp_error', $errno." ".$errstr);
$this->_set_error_message('lang:email_smtp_error', $errno." ".$errstr);
return FALSE;
}
@@ -1737,7 +1737,7 @@ class CI_Email {
if (substr($reply, 0, 3) != $resp)
{
$this->_set_error_message('email_smtp_error', $reply);
$this->_set_error_message('lang:email_smtp_error', $reply);
return FALSE;
}
@@ -1766,7 +1766,7 @@ class CI_Email {
if ($this->smtp_user == "" AND $this->smtp_pass == "")
{
$this->_set_error_message('email_no_smtp_unpw');
$this->_set_error_message('lang:email_no_smtp_unpw');
return FALSE;
}
@@ -1776,7 +1776,7 @@ class CI_Email {
if (strncmp($reply, '334', 3) != 0)
{
$this->_set_error_message('email_failed_smtp_login', $reply);
$this->_set_error_message('lang:email_failed_smtp_login', $reply);
return FALSE;
}
@@ -1786,7 +1786,7 @@ class CI_Email {
if (strncmp($reply, '334', 3) != 0)
{
$this->_set_error_message('email_smtp_auth_un', $reply);
$this->_set_error_message('lang:email_smtp_auth_un', $reply);
return FALSE;
}
@@ -1796,7 +1796,7 @@ class CI_Email {
if (strncmp($reply, '235', 3) != 0)
{
$this->_set_error_message('email_smtp_auth_pw', $reply);
$this->_set_error_message('lang:email_smtp_auth_pw', $reply);
return FALSE;
}
@@ -1815,7 +1815,7 @@ class CI_Email {
{
if ( ! fwrite($this->_smtp_connect, $data . $this->newline))
{
$this->_set_error_message('email_smtp_data_failure', $data);
$this->_set_error_message('lang:email_smtp_data_failure', $data);
return FALSE;
}
else
@@ -1942,7 +1942,7 @@ class CI_Email {
$CI =& get_instance();
$CI->lang->load('email');
if (FALSE === ($line = $CI->lang->line($msg)))
if (substr($msg, 0, 5) != 'lang:' || FALSE === ($line = $CI->lang->line(substr($msg, 5))))
{
$this->_debug_msg[] = str_replace('%s', $val, $msg)."<br />";
}
@@ -2059,4 +2059,4 @@ class CI_Email {
// END CI_Email class
/* End of file Email.php */
/* Location: ./system/libraries/Email.php */
/* Location: ./system/libraries/Email.php */

View File

@@ -524,7 +524,7 @@ class CI_Encrypt {
{
if ( ! function_exists('mhash'))
{
require_once(BASEPATH.'libraries/Sha1'.EXT);
require_once(BASEPATH.'libraries/Sha1.php');
$SH = new CI_SHA;
return $SH->generate($str);
}

View File

@@ -628,6 +628,10 @@ class CI_Form_validation {
$this->_field_data[$row['field']]['postdata'] = (is_bool($result)) ? $postdata : $result;
}
}
else
{
log_message('debug', "Unable to find validation rule: ".$rule);
}
continue;
}
@@ -1357,4 +1361,4 @@ class CI_Form_validation {
// END Form Validation Class
/* End of file Form_validation.php */
/* Location: ./system/libraries/Form_validation.php */
/* Location: ./system/libraries/Form_validation.php */

View File

@@ -83,7 +83,7 @@ class CI_Log {
return FALSE;
}
$filepath = $this->_log_path.'log-'.date('Y-m-d').EXT;
$filepath = $this->_log_path.'log-'.date('Y-m-d').'.php';
$message = '';
if ( ! file_exists($filepath))

View File

@@ -30,7 +30,7 @@ class CI_Pagination {
var $prefix = ''; // A custom prefix added to the path.
var $suffix = ''; // A custom suffix added to the path.
var $total_rows = ''; // Total number of items (database results)
var $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

View File

@@ -32,8 +32,6 @@
*/
class CI_Profiler {
var $CI;
protected $_available_sections = array(
'benchmarks',
'get',
@@ -43,14 +41,27 @@ class CI_Profiler {
'controller_info',
'queries',
'http_headers',
'session_data',
'config'
);
protected $_query_toggle_count = 25;
protected $CI;
// --------------------------------------------------------------------
public function __construct($config = array())
{
$this->CI =& get_instance();
$this->CI->load->language('profiler');
if (isset($config['query_toggle_count']))
{
$this->_query_toggle_count = (int) $config['query_toggle_count'];
unset($config['query_toggle_count']);
}
// default all sections to display
foreach ($this->_available_sections as $section)
{
@@ -162,7 +173,7 @@ class CI_Profiler {
$output .= "\n";
$output .= '<legend style="color:#0000FF;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_queries').'&nbsp;&nbsp;</legend>';
$output .= "\n";
$output .= "\n\n<table style='border:none; width:100%'>\n";
$output .= "\n\n<table style='border:none; width:100%;'>\n";
$output .="<tr><td style='width:100%;color:#0000FF;font-weight:normal;background-color:#eee;padding:5px'>".$this->CI->lang->line('profiler_no_db')."</td></tr>\n";
$output .= "</table>\n";
$output .= "</fieldset>";
@@ -178,13 +189,26 @@ class CI_Profiler {
$output = "\n\n";
$count = 0;
foreach ($dbs as $db)
{
$count++;
$hide_queries = (count($db->queries) > $this->_query_toggle_count) ? ' display:none' : '';
$show_hide_js = '(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_queries_db_'.$count.'\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_hide').'\'?\''.$this->CI->lang->line('profiler_section_show').'\':\''.$this->CI->lang->line('profiler_section_hide').'\';">'.$this->CI->lang->line('profiler_section_hide').'</span>)';
if ($hide_queries != '')
{
$show_hide_js = '(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_queries_db_'.$count.'\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_show').'\'?\''.$this->CI->lang->line('profiler_section_hide').'\':\''.$this->CI->lang->line('profiler_section_show').'\';">'.$this->CI->lang->line('profiler_section_show').'</span>)';
}
$output .= '<fieldset style="border:1px solid #0000FF;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
$output .= "\n";
$output .= '<legend style="color:#0000FF;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_database').':&nbsp; '.$db->database.'&nbsp;&nbsp;&nbsp;'.$this->CI->lang->line('profiler_queries').': '.count($db->queries).'&nbsp;&nbsp;&nbsp;</legend>';
$output .= '<legend style="color:#0000FF;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_database').':&nbsp; '.$db->database.'&nbsp;&nbsp;&nbsp;'.$this->CI->lang->line('profiler_queries').': '.count($db->queries).'&nbsp;&nbsp;'.$show_hide_js.'</legend>';
$output .= "\n";
$output .= "\n\n<table style='width:100%;'>\n";
$output .= "\n\n<table style='width:100%;{$hide_queries}' id='ci_profiler_queries_db_{$count}'>\n";
if (count($db->queries) == 0)
{
@@ -388,7 +412,7 @@ class CI_Profiler {
}
else
{
$output .= "<div style='color:#5a0099;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->lang->line('profiler_no_memory_usage')."</div>";
$output .= "<div style='color:#5a0099;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->lang->line('profiler_no_memory')."</div>";
}
$output .= "</fieldset>";
@@ -410,10 +434,10 @@ class CI_Profiler {
$output = "\n\n";
$output .= '<fieldset id="ci_profiler_http_headers" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
$output .= "\n";
$output .= '<legend style="color:#000;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_headers').'&nbsp;&nbsp;</legend>';
$output .= '<legend style="color:#000;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_headers').'&nbsp;&nbsp;(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_httpheaders_table\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_show').'\'?\''.$this->CI->lang->line('profiler_section_hide').'\':\''.$this->CI->lang->line('profiler_section_show').'\';">'.$this->CI->lang->line('profiler_section_show').'</span>)</legend>';
$output .= "\n";
$output .= "\n\n<table style='width:100%'>\n";
$output .= "\n\n<table style='width:100%;display:none' id='ci_profiler_httpheaders_table'>\n";
foreach (array('HTTP_ACCEPT', 'HTTP_USER_AGENT', 'HTTP_CONNECTION', 'SERVER_PORT', 'SERVER_NAME', 'REMOTE_ADDR', 'SERVER_SOFTWARE', 'HTTP_ACCEPT_LANGUAGE', 'SCRIPT_NAME', 'REQUEST_METHOD',' HTTP_HOST', 'REMOTE_HOST', 'CONTENT_TYPE', 'SERVER_PROTOCOL', 'QUERY_STRING', 'HTTP_ACCEPT_ENCODING', 'HTTP_X_FORWARDED_FOR') as $header)
{
@@ -441,10 +465,10 @@ class CI_Profiler {
$output = "\n\n";
$output .= '<fieldset id="ci_profiler_config" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
$output .= "\n";
$output .= '<legend style="color:#000;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_config').'&nbsp;&nbsp;</legend>';
$output .= '<legend style="color:#000;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_config').'&nbsp;&nbsp;(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_config_table\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_show').'\'?\''.$this->CI->lang->line('profiler_section_hide').'\':\''.$this->CI->lang->line('profiler_section_show').'\';">'.$this->CI->lang->line('profiler_section_show').'</span>)</legend>';
$output .= "\n";
$output .= "\n\n<table style='width:100%'>\n";
$output .= "\n\n<table style='width:100%; display:none' id='ci_profiler_config_table'>\n";
foreach ($this->CI->config->config as $config=>$val)
{
@@ -464,6 +488,39 @@ class CI_Profiler {
// --------------------------------------------------------------------
/**
* Compile session userdata
*
* @return string
*/
private function _compile_session_data()
{
if ( ! isset($this->CI->session))
{
return;
}
$output = '<fieldset id="ci_profiler_csession" style="border:1px solid #000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
$output .= '<legend style="color:#000;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_session_data').'&nbsp;&nbsp;(<span style="cursor: pointer;" onclick="var s=document.getElementById(\'ci_profiler_session_data\').style;s.display=s.display==\'none\'?\'\':\'none\';this.innerHTML=this.innerHTML==\''.$this->CI->lang->line('profiler_section_show').'\'?\''.$this->CI->lang->line('profiler_section_hide').'\':\''.$this->CI->lang->line('profiler_section_show').'\';">'.$this->CI->lang->line('profiler_section_show').'</span>)</legend>';
$output .= "<table style='width:100%;display:none' id='ci_profiler_session_data'>";
foreach ($this->CI->session->all_userdata() as $key => $val)
{
if (is_array($val))
{
$val = print_r($val, TRUE);
}
$output .= "<tr><td style='padding:5px; vertical-align: top;color:#900;background-color:#ddd;'>".$key."&nbsp;&nbsp;</td><td style='padding:5px; color:#000;background-color:#ddd;'>".htmlspecialchars($val)."</td></tr>\n";
}
$output .= '</table>';
$output .= "</fieldset>";
return $output;
}
// --------------------------------------------------------------------
/**
* Run the Profiler
*
@@ -493,7 +550,6 @@ class CI_Profiler {
return $output;
}
}
// END CI_Profiler class

View File

@@ -189,7 +189,7 @@ class CI_Session {
}
// Does the User Agent Match?
if ($this->sess_match_useragent == TRUE AND trim($session['user_agent']) != trim(substr($this->CI->input->user_agent(), 0, 50)))
if ($this->sess_match_useragent == TRUE AND trim($session['user_agent']) != trim(substr($this->CI->input->user_agent(), 0, 120)))
{
$this->sess_destroy();
return FALSE;
@@ -316,7 +316,7 @@ class CI_Session {
$this->userdata = array(
'session_id' => md5(uniqid($sessid, TRUE)),
'ip_address' => $this->CI->input->ip_address(),
'user_agent' => substr($this->CI->input->user_agent(), 0, 50),
'user_agent' => substr($this->CI->input->user_agent(), 0, 120),
'last_activity' => $this->now
);
@@ -435,11 +435,11 @@ class CI_Session {
* Fetch all session data
*
* @access public
* @return mixed
* @return array
*/
function all_userdata()
{
return ( ! isset($this->userdata)) ? FALSE : $this->userdata;
return $this->userdata;
}
// --------------------------------------------------------------------

View File

@@ -945,13 +945,13 @@ class CI_Upload {
if (count($this->mimes) == 0)
{
if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT))
if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'))
{
include(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT);
include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php');
}
elseif (is_file(APPPATH.'config/mimes'.EXT))
elseif (is_file(APPPATH.'config/mimes.php'))
{
include(APPPATH.'config//mimes'.EXT);
include(APPPATH.'config//mimes.php');
}
else
{

View File

@@ -84,13 +84,13 @@ class CI_User_agent {
*/
private function _load_agent_file()
{
if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/user_agents'.EXT))
if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php'))
{
include(APPPATH.'config/'.ENVIRONMENT.'/user_agents'.EXT);
include(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php');
}
elseif (is_file(APPPATH.'config/user_agents'.EXT))
elseif (is_file(APPPATH.'config/user_agents.php'))
{
include(APPPATH.'config/user_agents'.EXT);
include(APPPATH.'config/user_agents.php');
}
else
{