summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authordchill42 <dchill42@gmail.com>2012-07-31 15:41:01 +0200
committerdchill42 <dchill42@gmail.com>2012-07-31 15:41:01 +0200
commit7e92b7332ea4d28648e69eabcb93cead35dbca26 (patch)
treeb7714536b89557129ed51fe675725fe28639c1e0 /system
parent57486009573a86d9e286a49c92216ba17aae0d5a (diff)
parent3a2d573a96241c01124d15c1ce517078e07c6235 (diff)
Merge branch 'develop' of github.com:/EllisLab/CodeIgniter into session
Diffstat (limited to 'system')
-rw-r--r--system/core/Common.php39
-rw-r--r--system/core/Input.php25
-rw-r--r--system/core/Output.php6
-rw-r--r--system/helpers/date_helper.php17
-rw-r--r--system/helpers/file_helper.php2
-rw-r--r--system/helpers/html_helper.php24
-rw-r--r--system/helpers/url_helper.php50
-rw-r--r--system/libraries/Email.php20
8 files changed, 94 insertions, 89 deletions
diff --git a/system/core/Common.php b/system/core/Common.php
index 06b162264..57374b07d 100644
--- a/system/core/Common.php
+++ b/system/core/Common.php
@@ -598,5 +598,44 @@ if ( ! function_exists('html_escape'))
}
}
+// ------------------------------------------------------------------------
+
+if ( ! function_exists('_stringify_attributes'))
+{
+ /**
+ * Stringify attributes for use in HTML tags.
+ *
+ * Helper function used to convert a string, array, or object
+ * of attributes to a string.
+ *
+ * @param mixed string, array, object
+ * @param bool
+ * @return string
+ */
+ function _stringify_attributes($attributes, $js = FALSE)
+ {
+ $atts = NULL;
+
+ if (empty($attributes))
+ {
+ return $atts;
+ }
+
+ if (is_string($attributes))
+ {
+ return ' '.$attributes;
+ }
+
+ $attributes = (array) $attributes;
+
+ foreach ($attributes as $key => $val)
+ {
+ $atts .= ($js) ? $key.'='.$val.',' : ' '.$key.'="'.$val.'"';
+ }
+
+ return rtrim($atts, ',');
+ }
+}
+
/* End of file Common.php */
/* Location: ./system/core/Common.php */ \ No newline at end of file
diff --git a/system/core/Input.php b/system/core/Input.php
index 162e40c85..968a42a9a 100644
--- a/system/core/Input.php
+++ b/system/core/Input.php
@@ -330,10 +330,33 @@ class CI_Input {
if (config_item('proxy_ips') != '' && $this->server('HTTP_X_FORWARDED_FOR') && $this->server('REMOTE_ADDR'))
{
+ $has_ranges = strpos($proxies, '/') !== false;
$proxies = preg_split('/[\s,]/', config_item('proxy_ips'), -1, PREG_SPLIT_NO_EMPTY);
$proxies = is_array($proxies) ? $proxies : array($proxies);
+
+ if ($has_ranges)
+ {
+ $long_ip = ip2long($_SERVER['REMOTE_ADDR']);
+ $bit_32 = 1 << 32;
+
+ // Go through each of the IP Addresses to check for and
+ // test against range notation
+ foreach($proxies as $ip)
+ {
+ list($address, $mask_length) = explode('/', $ip);
+
+ // Generate the bitmask for a 32 bit IP Address
+ $bitmask = $bit_32 - (1 << (32 - (int)$mask_length));
+ if (($long_ip & $bitmask) == $address)
+ {
+ $this->ip_address = $_SERVER['HTTP_X_FORWARDED_FOR'];
+ break;
+ }
+ }
- $this->ip_address = in_array($_SERVER['REMOTE_ADDR'], $proxies) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
+ } else {
+ $this->ip_address = in_array($_SERVER['REMOTE_ADDR'], $proxies) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
+ }
}
elseif ( ! $this->server('HTTP_CLIENT_IP') && $this->server('REMOTE_ADDR'))
{
diff --git a/system/core/Output.php b/system/core/Output.php
index 5ec8c4bc0..9842f834d 100644
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -552,13 +552,13 @@ class CI_Output {
fclose($fp);
// Strip out the embedded timestamp
- if ( ! preg_match('/(\d+TS--->)/', $cache, $match))
+ if ( ! preg_match('/\d+TS--->/', $cache, $match))
{
return FALSE;
}
$last_modified = filemtime($cache_path);
- $expire = trim(str_replace('TS--->', '', $match[1]));
+ $expire = str_replace('TS--->', '', $match[0]);
// Has the file expired?
if ($_SERVER['REQUEST_TIME'] >= $expire && is_really_writable($cache_path))
@@ -575,7 +575,7 @@ class CI_Output {
}
// Display the cache
- $this->_display(str_replace($match[0], '', $cache));
+ $this->_display(substr($cache, strlen($match[0])));
log_message('debug', 'Cache file is current. Sending it to browser.');
return TRUE;
}
diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php
index a45b3d7ac..a792f09a2 100644
--- a/system/helpers/date_helper.php
+++ b/system/helpers/date_helper.php
@@ -575,22 +575,7 @@ if ( ! function_exists('timezone_menu'))
$menu .= ' class="'.$class.'"';
}
- // Generate a string from the attributes submitted, if any
- if (is_array($attributes))
- {
- $atts = '';
- foreach ($attributes as $key => $val)
- {
- $atts .= ' '.$key.'="'.$val.'"';
- }
- $attributes = $atts;
- }
- elseif (is_string($attributes) && strlen($attributes) > 0)
- {
- $attributes = ' '.$attributes;
- }
-
- $menu .= $attributes.">\n";
+ $menu .= _stringify_attributes($attributes).">\n";
foreach (timezones() as $key => $val)
{
diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php
index 3834d4895..e68bb7f7a 100644
--- a/system/helpers/file_helper.php
+++ b/system/helpers/file_helper.php
@@ -124,7 +124,7 @@ if ( ! function_exists('delete_files'))
{
delete_files($path.DIRECTORY_SEPARATOR.$filename, $del_dir, $level + 1, $htdocs);
}
- elseif ($htdocs === TRUE && ! preg_match('/^(\.htaccess|index\.(html|htm|php)|web\.config)$/i', $filename))
+ elseif ($htdocs !== TRUE OR ! preg_match('/^(\.htaccess|index\.(html|htm|php)|web\.config)$/i', $filename))
{
@unlink($path.DIRECTORY_SEPARATOR.$filename);
}
diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php
index 6fabf9c05..9843e804e 100644
--- a/system/helpers/html_helper.php
+++ b/system/helpers/html_helper.php
@@ -51,7 +51,7 @@ if ( ! function_exists('heading'))
*/
function heading($data = '', $h = '1', $attributes = '')
{
- return '<h'.$h.($attributes !== '' ? ' ' : '').$attributes.'>'.$data.'</h'.$h.'>';
+ return '<h'.$h._stringify_attributes($attributes).'>'.$data.'</h'.$h.'>';
}
}
@@ -119,23 +119,8 @@ if ( ! function_exists('_list'))
// Set the indentation based on the depth
$out = str_repeat(' ', $depth);
- // Were any attributes submitted? If so generate a string
- if (is_array($attributes))
- {
- $atts = '';
- foreach ($attributes as $key => $val)
- {
- $atts .= ' '.$key.'="'.$val.'"';
- }
- $attributes = $atts;
- }
- elseif (is_string($attributes) && strlen($attributes) > 0)
- {
- $attributes = ' '.$attributes;
- }
-
// Write the opening list tag
- $out .= '<'.$type.$attributes.">\n";
+ $out .= '<'.$type._stringify_attributes($attributes).">\n";
// Cycle through the list elements. If an array is
// encountered we will recursively call _list()
@@ -191,9 +176,10 @@ if ( ! function_exists('img'))
*
* @param mixed
* @param bool
+ * @param mixed
* @return string
*/
- function img($src = '', $index_page = FALSE)
+ function img($src = '', $index_page = FALSE, $attributes = '')
{
if ( ! is_array($src) )
{
@@ -229,7 +215,7 @@ if ( ! function_exists('img'))
}
}
- return $img.'/>';
+ return $img._stringify_attributes($attributes).'/>';
}
}
diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php
index 39e6343a6..57208c948 100644
--- a/system/helpers/url_helper.php
+++ b/system/helpers/url_helper.php
@@ -165,7 +165,7 @@ if ( ! function_exists('anchor'))
if ($attributes !== '')
{
- $attributes = _parse_attributes($attributes);
+ $attributes = _stringify_attributes($attributes);
}
return '<a href="'.$site_url.'"'.$attributes.'>'.$title.'</a>';
@@ -221,10 +221,10 @@ if ( ! function_exists('anchor_popup'))
unset($attributes[$key]);
}
- $attributes = empty($attributes) ? '' : _parse_attributes($attributes);
+ $attributes = _stringify_attributes($attributes);
return '<a href="'.$site_url
- .'" onclick="window.open(\''.$site_url."', '".$window_name."', '"._parse_attributes($atts, TRUE)."'); return false;\""
+ .'" onclick="window.open(\''.$site_url."', '".$window_name."', '"._stringify_attributes($atts, TRUE)."'); return false;\""
.$attributes.'>'.$title.'</a>';
}
}
@@ -250,7 +250,7 @@ if ( ! function_exists('mailto'))
$title = $email;
}
- return '<a href="mailto:'.$email.'"'._parse_attributes($attributes).'>'.$title.'</a>';
+ return '<a href="mailto:'.$email.'"'._stringify_attributes($attributes).'>'.$title.'</a>';
}
}
@@ -560,47 +560,5 @@ if ( ! function_exists('redirect'))
}
}
-// ------------------------------------------------------------------------
-
-if ( ! function_exists('_parse_attributes'))
-{
- /**
- * Parse out the attributes
- *
- * Some of the functions use this
- *
- * @param array
- * @param bool
- * @return string
- */
- function _parse_attributes($attributes, $javascript = FALSE)
- {
- if (is_string($attributes))
- {
- return ($attributes !== '') ? ' '.$attributes : '';
- }
-
- $att = '';
- foreach ($attributes as $key => $val)
- {
- if ($javascript === TRUE)
- {
- $att .= $key.'='.$val.',';
- }
- else
- {
- $att .= ' '.$key.'="'.$val.'"';
- }
- }
-
- if ($javascript === TRUE && $att !== '')
- {
- return substr($att, 0, -1);
- }
-
- return $att;
- }
-}
-
/* End of file url_helper.php */
/* Location: ./system/helpers/url_helper.php */ \ No newline at end of file
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index fdb9be4da..8fd7a79e7 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -1238,7 +1238,7 @@ class CI_Email {
*
* @return bool
*/
- public function send()
+ public function send($auto_clear = TRUE)
{
if ($this->_replyto_flag === FALSE)
{
@@ -1257,11 +1257,25 @@ class CI_Email {
if ($this->bcc_batch_mode && count($this->_bcc_array) > $this->bcc_batch_size)
{
- return $this->batch_bcc_send();
+ $result = $this->batch_bcc_send();
+
+ if ($result && $auto_clear)
+ {
+ $this->clear();
+ }
+
+ return $result;
}
$this->_build_message();
- return $this->_spool_email();
+ $result = $this->_spool_email();
+
+ if ($result && $auto_clear)
+ {
+ $this->clear();
+ }
+
+ return $result;
}
// --------------------------------------------------------------------