Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:/EllisLab/CodeIgniter into load_…
Browse files Browse the repository at this point in the history
…config_units
  • Loading branch information
dchill42 committed Oct 15, 2012
2 parents e3621cc + c771928 commit 63391f7
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 65 deletions.
48 changes: 28 additions & 20 deletions system/core/Input.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -390,31 +390,32 @@ public function ip_address()
} }


// Convert the REMOTE_ADDR IP address to binary, if needed // Convert the REMOTE_ADDR IP address to binary, if needed
if ( ! isset($ip, $convert_func)) if ( ! isset($ip, $sprintf))
{ {
if ($separator === ':') if ($separator === ':')
{ {
// Make sure we're have the "full" IPv6 format // Make sure we're have the "full" IPv6 format
$ip = str_replace('::', str_repeat(':', 9 - substr_count($this->ip_address, ':')), $this->ip_address); $ip = explode(':',
$convert_func = is_php('5.3') str_replace('::',
? function ($value) str_repeat(':', 9 - substr_count($this->ip_address, ':')),
{ $this->ip_address
return str_pad(base_convert($value, 16, 2), 16, '0', STR_PAD_LEFT); )
} );
: create_function('$value', 'return str_pad(base_convert($value, 16, 2), 16, "0", STR_PAD_LEFT);');
for ($i = 0; $i < 8; $i++)
{
$ip[$i] = intval($ip[$i], 16);
}

$sprintf = '%016b%016b%016b%016b%016b%016b%016b%016b';
} }
else else
{ {
$ip = $this->ip_address; $ip = explode('.', $this->ip_address);
$convert_func = is_php('5.3') $sprintf = '%08b%08b%08b%08b';
? function ($value)
{
return str_pad(decbin($value), 8, '0', STR_PAD_LEFT);
}
: create_function('$value', 'return str_pad(decbin($value), 8, "0", STR_PAD_LEFT);');
} }


$ip = implode(array_map($convert_func, explode($separator, $ip))); $ip = vsprintf($sprintf, $ip);
} }


// Split the netmask length off the network address // Split the netmask length off the network address
Expand All @@ -423,12 +424,19 @@ public function ip_address()
// Again, an IPv6 address is most likely in a compressed form // Again, an IPv6 address is most likely in a compressed form
if ($separator === ':') if ($separator === ':')
{ {
$netaddr = str_replace('::', str_repeat(':', 9 - substr_count($netaddr, ':')), $netaddr); $netaddr = explode(':', str_replace('::', str_repeat(':', 9 - substr_count($netaddr, ':')), $netaddr));
for ($i = 0; $i < 8; $i++)
{
$netaddr[$i] = intval($netaddr[$i], 16);
}
}
else
{
$netaddr = explode('.', $netaddr);
} }


// Convert to a binary form and finally compare // Convert to binary and finally compare
$netaddr = implode(array_map($convert_func, explode($separator, $netaddr))); if (strncmp($ip, vsprintf($sprintf, $netaddr), $masklen) === 0)
if (strncmp($ip, $netaddr, $masklen) === 0)
{ {
$this->ip_address = $spoof; $this->ip_address = $spoof;
break; break;
Expand Down
2 changes: 1 addition & 1 deletion system/database/drivers/mysqli/mysqli_driver.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function db_connect($persistent = FALSE)
? 'p:'.$this->hostname : $this->hostname; ? 'p:'.$this->hostname : $this->hostname;
$port = empty($this->port) ? NULL : $this->port; $port = empty($this->port) ? NULL : $this->port;
$client_flags = ($this->compress === TRUE) ? MYSQLI_CLIENT_COMPRESS : 0; $client_flags = ($this->compress === TRUE) ? MYSQLI_CLIENT_COMPRESS : 0;
$mysqli = new mysqli(); $mysqli = mysqli_init();


return @$mysqli->real_connect($hostname, $this->username, $this->password, $this->database, $port, NULL, $client_flags) return @$mysqli->real_connect($hostname, $this->username, $this->password, $this->database, $port, NULL, $client_flags)
? $mysqli : FALSE; ? $mysqli : FALSE;
Expand Down
41 changes: 0 additions & 41 deletions system/libraries/Email.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1753,47 +1753,6 @@ protected function _get_hostname()


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


/**
* Get IP
*
* @return string
*/
protected function _get_ip()
{
if ($this->_IP !== FALSE)
{
return $this->_IP;
}

$cip = ( ! empty($_SERVER['HTTP_CLIENT_IP'])) ? $_SERVER['HTTP_CLIENT_IP'] : FALSE;
$rip = ( ! empty($_SERVER['REMOTE_ADDR'])) ? $_SERVER['REMOTE_ADDR'] : FALSE;
if ($cip) $this->_IP = $cip;
elseif ($rip) $this->_IP = $rip;
else
{
$fip = ( ! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : FALSE;
if ($fip)
{
$this->_IP = $fip;
}
}

if (strpos($this->_IP, ',') !== FALSE)
{
$x = explode(',', $this->_IP);
$this->_IP = end($x);
}

if ( ! preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $this->_IP))
{
$this->_IP = '0.0.0.0';
}

return $this->_IP;
}

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

/** /**
* Get Debug Message * Get Debug Message
* *
Expand Down
2 changes: 1 addition & 1 deletion system/libraries/Session/drivers/Session_cookie.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ protected function _sess_read()
} }


// Is the session current? // Is the session current?
if (($session['last_activity'] + $this->sess_expiration) < $this->now) if (($session['last_activity'] + $this->sess_expiration) < $this->now OR $session['last_activity'] > $this->now)
{ {
$this->sess_destroy(); $this->sess_destroy();
return FALSE; return FALSE;
Expand Down
2 changes: 1 addition & 1 deletion system/libraries/Session/drivers/Session_native.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected function initialize()
// Check session expiration, ip, and agent // Check session expiration, ip, and agent
$now = time(); $now = time();
$destroy = FALSE; $destroy = FALSE;
if (isset($_SESSION['last_activity']) && ($_SESSION['last_activity'] + $expire) < $now) if (isset($_SESSION['last_activity']) && (($_SESSION['last_activity'] + $expire) < $now OR $_SESSION['last_activity'] > $now))
{ {
// Expired - destroy // Expired - destroy
$destroy = TRUE; $destroy = TRUE;
Expand Down
4 changes: 3 additions & 1 deletion user_guide_src/source/changelog.rst
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ Release Date: Not Released
- Removed the second parameter (character limit) from internal method ``_prep_quoted_printable()`` as it is never used. - Removed the second parameter (character limit) from internal method ``_prep_quoted_printable()`` as it is never used.
- Internal method ``_prep_quoted_printable()`` will now utilize the native ``quoted_printable_encode()``, ``imap_8bit()`` functions (if available) when CRLF is set to "\r\n". - Internal method ``_prep_quoted_printable()`` will now utilize the native ``quoted_printable_encode()``, ``imap_8bit()`` functions (if available) when CRLF is set to "\r\n".
- Default charset now relies on the global ``$config['charset']`` setting. - Default charset now relies on the global ``$config['charset']`` setting.
- Removed unused protected method ``_get_ip()`` (:doc:`Input Library <libraries/input>`'s ``ip_address()`` should be used anyway).
- :doc:`Pagination Library <libraries/pagination>` changes include: - :doc:`Pagination Library <libraries/pagination>` changes include:
- Added support for the anchor "rel" attribute. - Added support for the anchor "rel" attribute.
- Added support for setting custom attributes. - Added support for setting custom attributes.
Expand Down Expand Up @@ -360,7 +361,8 @@ Bug fixes for 3.0
- Fixed a bug (#1765) - :doc:`Database Library <database/index>` didn't properly detect connection errors for MySQLi. - Fixed a bug (#1765) - :doc:`Database Library <database/index>` didn't properly detect connection errors for MySQLi.
- Fixed a bug (#1257) - :doc:`Query Builder <database/query_builder>` used to (unnecessarily) group FROM clause contents, which breaks certain queries and is invalid for some databases. - Fixed a bug (#1257) - :doc:`Query Builder <database/query_builder>` used to (unnecessarily) group FROM clause contents, which breaks certain queries and is invalid for some databases.
- Fixed a bug (#1709) - :doc:`Email <libraries/email>` headers were broken when using long email subjects and \r\n as CRLF. - Fixed a bug (#1709) - :doc:`Email <libraries/email>` headers were broken when using long email subjects and \r\n as CRLF.
- Fixed a bug where MB_ENABLED was only declared if UTF8_ENABLED was set to TRUE. - Fixed a bug where ``MB_ENABLED`` was only declared if ``UTF8_ENABLED`` was set to TRUE.
- Fixed a bug where the :doc:`Session Library <libraries/session>` accepted cookies with *last_activity* values being in the future.


Version 2.1.3 Version 2.1.3
============= =============
Expand Down

0 comments on commit 63391f7

Please sign in to comment.