Skip to content

Commit

Permalink
Merge upstream branch
Browse files Browse the repository at this point in the history
  • Loading branch information
narfbg committed Feb 29, 2012
2 parents ecb2fdd + b692ccb commit 5908b30
Show file tree
Hide file tree
Showing 37 changed files with 1,429 additions and 1,440 deletions.
2 changes: 2 additions & 0 deletions application/config/database.php
Expand Up @@ -37,6 +37,7 @@
| EXPLANATION OF VARIABLES
| -------------------------------------------------------------------
|
| ['dsn'] The full DSN string describe a connection to the database.
| ['hostname'] The hostname of your database server.
| ['username'] The username used to connect to the database
| ['password'] The password used to connect to the database
Expand Down Expand Up @@ -74,6 +75,7 @@
$active_group = 'default';
$active_record = TRUE;

$db['default']['dsn'] = '';
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = '';
$db['default']['password'] = '';
Expand Down
4 changes: 2 additions & 2 deletions application/config/mimes.php
Expand Up @@ -121,8 +121,8 @@
'avi' => array('video/x-msvideo', 'video/msvideo', 'video/avi', 'application/x-troff-msvideo'),
'movie' => 'video/x-sgi-movie',
'doc' => 'application/msword',
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'docx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip'),
'xlsx' => array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/zip'),
'word' => array('application/msword', 'application/octet-stream'),
'xl' => 'application/excel',
'eml' => 'message/rfc822',
Expand Down
2 changes: 2 additions & 0 deletions index.php
Expand Up @@ -218,6 +218,7 @@
{
if ( ! is_dir(BASEPATH.$application_folder.'/'))
{
header('HTTP/1.1 503 Service Unavailable.', TRUE, '503');
exit('Your application folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF);
}

Expand All @@ -233,6 +234,7 @@
{
if ( ! is_dir(APPPATH.'views/'))
{
header('HTTP/1.1 503 Service Unavailable.', TRUE, '503');
exit('Your view folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF);
}

Expand Down
4 changes: 2 additions & 2 deletions readme.rst
Expand Up @@ -23,7 +23,7 @@ Changelog and New Features
**************************

You can find a list of all changes for each release in the `user
guide change log <https://github.com/EllisLab/CodeIgniter/blob/develop/user_guide/changelog.html>`_.
guide change log <https://github.com/EllisLab/CodeIgniter/blob/develop/user_guide_src/source/changelog.rst>`_.

*******************
Server Requirements
Expand Down Expand Up @@ -193,4 +193,4 @@ Acknowledgement
***************

The EllisLab team and The Reactor Engineers would like to thank all the
contributors to the CodeIgniter project and you, the CodeIgniter user.
contributors to the CodeIgniter project and you, the CodeIgniter user.
34 changes: 16 additions & 18 deletions system/core/Common.php
Expand Up @@ -56,7 +56,7 @@
function is_php($version = '5.0.0')
{
static $_is_php;
$version = (string)$version;
$version = (string) $version;

if ( ! isset($_is_php[$version]))
{
Expand Down Expand Up @@ -84,7 +84,7 @@ function is_php($version = '5.0.0')
function is_really_writable($file)
{
// If we're on a Unix server with safe_mode off we call is_writable
if (DIRECTORY_SEPARATOR === '/' AND @ini_get('safe_mode') == FALSE)
if (DIRECTORY_SEPARATOR === '/' && (bool) @ini_get('safe_mode') === FALSE)
{
return is_writable($file);
}
Expand Down Expand Up @@ -120,7 +120,7 @@ function is_really_writable($file)
/**
* Class registry
*
* This function acts as a singleton. If the requested class does not
* This function acts as a singleton. If the requested class does not
* exist it is instantiated and set to a static variable. If it has
* previously been instantiated the variable is returned.
*
Expand Down Expand Up @@ -177,6 +177,7 @@ function &load_class($class, $directory = 'libraries', $prefix = 'CI_')
{
// Note: We use exit() rather then show_error() in order to avoid a
// self-referencing loop with the Excptions class
set_status_header(503);
exit('Unable to locate the specified class: '.$class.'.php');
}

Expand All @@ -191,7 +192,7 @@ function &load_class($class, $directory = 'libraries', $prefix = 'CI_')
// --------------------------------------------------------------------

/**
* Keeps track of which libraries have been loaded. This function is
* Keeps track of which libraries have been loaded. This function is
* called by the load_class() function above
*
* @access public
Expand Down Expand Up @@ -243,6 +244,7 @@ function &get_config($replace = array())
// Fetch the config file
if ( ! file_exists($file_path))
{
set_status_header(503);
exit('The configuration file does not exist.');
}

Expand All @@ -251,6 +253,7 @@ function &get_config($replace = array())
// Does the $config array exist in the file?
if ( ! isset($config) OR ! is_array($config))
{
set_status_header(503);
exit('Your config file does not appear to be formatted correctly.');
}

Expand Down Expand Up @@ -434,7 +437,7 @@ function set_status_header($code = 200, $text = '')
show_error('Status codes must be numeric', 500);
}

if (isset($stati[$code]) AND $text == '')
if (isset($stati[$code]) && $text == '')
{
$text = $stati[$code];
}
Expand All @@ -444,19 +447,19 @@ function set_status_header($code = 200, $text = '')
show_error('No status text available. Please check your status code number or supply your own message text.', 500);
}

$server_protocol = (isset($_SERVER['SERVER_PROTOCOL'])) ? $_SERVER['SERVER_PROTOCOL'] : FALSE;
$server_protocol = isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : FALSE;

if (strpos(php_sapi_name(), 'cgi') === 0)
{
header("Status: {$code} {$text}", TRUE);
header('Status: '.$code.' '.$text, TRUE);
}
elseif ($server_protocol == 'HTTP/1.1' OR $server_protocol == 'HTTP/1.0')
elseif ($server_protocol === 'HTTP/1.0')
{
header($server_protocol." {$code} {$text}", TRUE, $code);
header('HTTP/1.0 '.$code.' '.$text, TRUE, $code);
}
else
{
header("HTTP/1.1 {$code} {$text}", TRUE, $code);
header('HTTP/1.1 '.$code.' '.$text, TRUE, $code);
}
}
}
Expand Down Expand Up @@ -561,14 +564,9 @@ function remove_invisible_characters($str, $url_encoded = TRUE)
{
function html_escape($var)
{
if (is_array($var))
{
return array_map('html_escape', $var);
}
else
{
return htmlspecialchars($var, ENT_QUOTES, config_item('charset'));
}
return is_array($var)
? array_map('html_escape', $var)
: htmlspecialchars($var, ENT_QUOTES, config_item('charset'));
}
}

Expand Down
2 changes: 1 addition & 1 deletion system/core/Config.php
Expand Up @@ -80,7 +80,7 @@ public function __construct()
{
if (isset($_SERVER['HTTP_HOST']))
{
$base_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http';
$base_url = ! empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http';
$base_url .= '://'. $_SERVER['HTTP_HOST']
. str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
}
Expand Down
67 changes: 30 additions & 37 deletions system/core/Input.php
Expand Up @@ -25,8 +25,6 @@
* @filesource
*/

// ------------------------------------------------------------------------

/**
* Input Class
*
Expand Down Expand Up @@ -152,7 +150,7 @@ protected function _fetch_from_array(&$array, $index = '', $xss_clean = FALSE)
public function get($index = NULL, $xss_clean = FALSE)
{
// Check if a field has been provided
if ($index === NULL AND ! empty($_GET))
if ($index === NULL && ! empty($_GET))
{
$get = array();

Expand All @@ -179,7 +177,7 @@ public function get($index = NULL, $xss_clean = FALSE)
public function post($index = NULL, $xss_clean = FALSE)
{
// Check if a field has been provided
if ($index === NULL AND ! empty($_POST))
if ($index === NULL && ! empty($_POST))
{
$post = array();

Expand All @@ -206,9 +204,9 @@ public function post($index = NULL, $xss_clean = FALSE)
*/
public function get_post($index = '', $xss_clean = FALSE)
{
return ( ! isset($_POST[$index]))
? $this->get($index, $xss_clean)
: $this->post($index, $xss_clean);
return isset($_POST[$index])
? $this->post($index, $xss_clean)
: $this->get($index, $xss_clean);
}

// --------------------------------------------------------------------
Expand Down Expand Up @@ -256,19 +254,19 @@ public function set_cookie($name = '', $value = '', $expire = '', $domain = '',
}
}

if ($prefix == '' AND config_item('cookie_prefix') != '')
if ($prefix == '' && config_item('cookie_prefix') != '')
{
$prefix = config_item('cookie_prefix');
}
if ($domain == '' AND config_item('cookie_domain') != '')
if ($domain == '' && config_item('cookie_domain') != '')
{
$domain = config_item('cookie_domain');
}
if ($path == '/' AND config_item('cookie_path') != '/')
if ($path == '/' && config_item('cookie_path') !== '/')
{
$path = config_item('cookie_path');
}
if ($secure == FALSE AND config_item('cookie_secure') != FALSE)
if ($secure == FALSE && config_item('cookie_secure') != FALSE)
{
$secure = config_item('cookie_secure');
}
Expand Down Expand Up @@ -320,11 +318,11 @@ public function ip_address()

$this->ip_address = in_array($_SERVER['REMOTE_ADDR'], $proxies) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
}
elseif ( ! $this->server('HTTP_CLIENT_IP') AND $this->server('REMOTE_ADDR'))
elseif ( ! $this->server('HTTP_CLIENT_IP') && $this->server('REMOTE_ADDR'))
{
$this->ip_address = $_SERVER['REMOTE_ADDR'];
}
elseif ($this->server('REMOTE_ADDR') AND $this->server('HTTP_CLIENT_IP'))
elseif ($this->server('REMOTE_ADDR') && $this->server('HTTP_CLIENT_IP'))
{
$this->ip_address = $_SERVER['HTTP_CLIENT_IP'];
}
Expand Down Expand Up @@ -414,7 +412,7 @@ public function user_agent()
return $this->user_agent;
}

return $this->user_agent = ( ! isset($_SERVER['HTTP_USER_AGENT'])) ? FALSE : $_SERVER['HTTP_USER_AGENT'];
return $this->user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : FALSE;
}

// --------------------------------------------------------------------
Expand Down Expand Up @@ -469,19 +467,16 @@ protected function _sanitize_globals()
{
$_GET = array();
}
else
elseif (is_array($_GET) && count($_GET) > 0)
{
if (is_array($_GET) AND count($_GET) > 0)
foreach ($_GET as $key => $val)
{
foreach ($_GET as $key => $val)
{
$_GET[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
}
$_GET[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
}
}

// Clean $_POST Data
if (is_array($_POST) AND count($_POST) > 0)
if (is_array($_POST) && count($_POST) > 0)
{
foreach ($_POST as $key => $val)
{
Expand All @@ -490,7 +485,7 @@ protected function _sanitize_globals()
}

// Clean $_COOKIE Data
if (is_array($_COOKIE) AND count($_COOKIE) > 0)
if (is_array($_COOKIE) && count($_COOKIE) > 0)
{
// Also get rid of specially treated cookies that might be set by a server
// or silly application, that are of no use to a CI application anyway
Expand Down Expand Up @@ -568,7 +563,7 @@ protected function _clean_input_data($str)
}

// Standardize newlines if needed
if ($this->_standardize_newlines == TRUE AND strpos($str, "\r") !== FALSE)
if ($this->_standardize_newlines == TRUE && strpos($str, "\r") !== FALSE)
{
return str_replace(array("\r\n", "\r", "\r\n\n"), PHP_EOL, $str);
}
Expand All @@ -592,6 +587,7 @@ protected function _clean_input_keys($str)
{
if ( ! preg_match('/^[a-z0-9:_\/-]+$/i', $str))
{
set_status_header(503);
exit('Disallowed Key Characters.');
}

Expand Down Expand Up @@ -624,7 +620,7 @@ public function request_headers($xss_clean = FALSE)
}
else
{
$headers['Content-Type'] = (isset($_SERVER['CONTENT_TYPE'])) ? $_SERVER['CONTENT_TYPE'] : @getenv('CONTENT_TYPE');
$headers['Content-Type'] = isset($_SERVER['CONTENT_TYPE']) ? $_SERVER['CONTENT_TYPE'] : @getenv('CONTENT_TYPE');

foreach ($_SERVER as $key => $val)
{
Expand Down Expand Up @@ -654,9 +650,9 @@ public function request_headers($xss_clean = FALSE)
*
* Returns the value of a single member of the headers class member
*
* @param string array key for $this->headers
* @param boolean XSS Clean or not
* @return mixed FALSE on failure, string on success
* @param string array key for $this->headers
* @param bool XSS Clean or not
* @return mixed FALSE on failure, string on success
*/
public function get_request_header($index, $xss_clean = FALSE)
{
Expand All @@ -670,12 +666,9 @@ public function get_request_header($index, $xss_clean = FALSE)
return FALSE;
}

if ($xss_clean === TRUE)
{
return $this->security->xss_clean($this->headers[$index]);
}

return $this->headers[$index];
return ($xss_clean === TRUE)
? $this->security->xss_clean($this->headers[$index])
: $this->headers[$index];
}

// --------------------------------------------------------------------
Expand All @@ -685,11 +678,11 @@ public function get_request_header($index, $xss_clean = FALSE)
*
* Test to see if a request contains the HTTP_X_REQUESTED_WITH header
*
* @return boolean
* @return bool
*/
public function is_ajax_request()
{
return ($this->server('HTTP_X_REQUESTED_WITH') === 'XMLHttpRequest');
return ( ! empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest');
}

// --------------------------------------------------------------------
Expand All @@ -699,11 +692,11 @@ public function is_ajax_request()
*
* Test to see if a request was made from the command line
*
* @return boolean
* @return bool
*/
public function is_cli_request()
{
return (php_sapi_name() === 'cli') or defined('STDIN');
return (php_sapi_name() === 'cli' OR defined('STDIN'));
}

}
Expand Down
1 change: 1 addition & 0 deletions system/database/DB.php
Expand Up @@ -82,6 +82,7 @@ function &DB($params = '', $active_record_override = NULL)
$params = array(
'dbdriver' => $dns['scheme'],
'hostname' => (isset($dns['host'])) ? rawurldecode($dns['host']) : '',
'port' => (isset($dns['port'])) ? rawurldecode($dns['port']) : '',
'username' => (isset($dns['user'])) ? rawurldecode($dns['user']) : '',
'password' => (isset($dns['pass'])) ? rawurldecode($dns['pass']) : '',
'database' => (isset($dns['path'])) ? rawurldecode(substr($dns['path'], 1)) : ''
Expand Down

0 comments on commit 5908b30

Please sign in to comment.