From c8efb8033ae775a5c1c840f867def4e6253b3d9a Mon Sep 17 00:00:00 2001 From: "Thor (atiredmachine)" Date: Tue, 24 Jan 2012 13:33:39 -0800 Subject: Output class now sets HTTP headers match caching settings. --- system/core/Output.php | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/core/Output.php b/system/core/Output.php index abd8a0ea9..1f214a0b3 100755 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -466,6 +466,9 @@ class CI_Output { @chmod($cache_path, FILE_WRITE_MODE); log_message('debug', 'Cache file written: '.$cache_path); + + // Send HTTP cache-control headers to browser to match file cache settings. + $this->set_cache_header($_SERVER['REQUEST_TIME'],$expire); } // -------------------------------------------------------------------- @@ -503,13 +506,22 @@ class CI_Output { return FALSE; } - // Has the file expired? If so we'll delete it. - if (time() >= trim(str_replace('TS--->', '', $match[1])) && is_really_writable($cache_path)) + $last_modified = filemtime($cache_path); + $expire = trim(str_replace('TS--->', '', $match[1])); + + // Has the file expired? + if ($_SERVER['REQUEST_TIME'] >= $expire && is_really_writable($cache_path)) { + // If so we'll delete it. @unlink($filepath); log_message('debug', 'Cache file has expired. File deleted.'); return FALSE; } + else + { + // Or else send the HTTP cache control headers. + $this->set_cache_header($last_modified,$expire); + } // Display the cache $this->_display(str_replace($match[0], '', $cache)); @@ -517,6 +529,35 @@ class CI_Output { return TRUE; } + + // -------------------------------------------------------------------- + /** + * Set the HTTP headers to match the server-side file cache settings + * in order to reduce bandwidth. + * + * @param int timestamp of when the page was last modified + * @param int timestamp of when should the requested page expire from cache + * @return void + */ + public function set_cache_header($last_modified,$expiration) + { + $max_age = $expiration - $_SERVER['REQUEST_TIME']; + + if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && ($last_modified <= strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']))) + { + $this->set_status_header(304); + exit; + } + else + { + header('Pragma: public'); + header('Cache-Control: max-age=' . $max_age . ', public'); + header('Expires: '.gmdate('D, d M Y H:i:s', $expiration).' GMT'); + header('Last-modified: '.gmdate('D, d M Y H:i:s', $last_modified).' GMT'); + } + } + + } /* End of file Output.php */ -- cgit v1.2.3-24-g4f1b From 63678a27864fdd6bb0ed89e6940a1d331121072a Mon Sep 17 00:00:00 2001 From: "Thor (atiredmachine)" Date: Tue, 24 Jan 2012 16:56:01 -0800 Subject: Rudimentary minifying of output. --- system/core/Output.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'system') diff --git a/system/core/Output.php b/system/core/Output.php index 1f214a0b3..55a505c34 100755 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -323,6 +323,15 @@ class CI_Output { { $output =& $this->final_output; } + + // -------------------------------------------------------------------- + + // Is minify requested? + if ($CFG->item('minify_output') === TRUE) + { + $output = $this->minify($output); + } + // -------------------------------------------------------------------- @@ -558,6 +567,33 @@ class CI_Output { } + + + // -------------------------------------------------------------------- + /** + * Reduce excessive size of HTML content. + * + * @param string + * @param string + * @return string + */ + public function minify($output,$type='html') + { + switch ($type) + { + case 'html': + + // Replaces multiple spaces with a single space. + $output = preg_replace('!\s{2,}!',' ',$output); + + // ... + break; + } + + return $output; + } + + } /* End of file Output.php */ -- cgit v1.2.3-24-g4f1b From 79db4cdba1a1a80634cd76ab8fc69fce7b1a7ea6 Mon Sep 17 00:00:00 2001 From: "Thor (atiredmachine)" Date: Tue, 24 Jan 2012 20:44:51 -0800 Subject: Improved minifier to restore
 contents, remove even more spaces,
 and process CSS with its own rules.

---
 system/core/Output.php | 35 ++++++++++++++++++++++++++++++++++-
 1 file changed, 34 insertions(+), 1 deletion(-)

(limited to 'system')

diff --git a/system/core/Output.php b/system/core/Output.php
index 55a505c34..bb39a7f31 100755
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -582,12 +582,45 @@ class CI_Output {
 		switch ($type)
 		{
 			case 'html':
+			
+				// Keep track of 
 tags as they were before processing.
+				// We'll want to return them to this state later.
+				preg_match_all('{}msU',$output,$pres_clean);
+
+				// Keep track of 
 tags as they were before processing.
+				// We'll want to return them to this state later.
+				preg_match_all('{}msU',$output,$style_clean);
 				
+				// Run }msU',$output,$style_clean);
-				
-				// Run }msU',$output,$style_clean);
 				foreach ($style_clean[0] as $s)
 				{
-					$output = str_replace($s, $this->minify($s,'css'), $output);
+					$output = str_replace($s, $this->minify($s,'text/css'), $output);
 				}
 
 				// Replace multiple spaces with a single space.
@@ -614,7 +614,7 @@ class CI_Output {
 			break;
 			
 			
-			case 'css':
+			case 'text/css':
 			
 				// Remove spaces around curly brackets, colons, and semi-colons
 				$output = preg_replace('!\s*(:|;|}|{)\s*!','$1',$output);
-- 
cgit v1.2.3-24-g4f1b


From 5de117549f69465a1ce0f2e128428d9adadd8a6d Mon Sep 17 00:00:00 2001
From: "Thor (atiredmachine)" 
Date: Tue, 24 Jan 2012 22:08:36 -0800
Subject: Strips out HTML comments.

---
 system/core/Output.php | 3 +++
 1 file changed, 3 insertions(+)

(limited to 'system')

diff --git a/system/core/Output.php b/system/core/Output.php
index 47c00acd8..8992fc1f1 100755
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -600,6 +600,9 @@ class CI_Output {
 				// Replace multiple spaces with a single space.
 				$output = preg_replace('!\s{2,}!',"\n",$output);
 				
+				// Remove comments (non-MSIE conditionals)
+				$output = preg_replace('{\s*\s*}msU','',$output);
+
 				// Remove spaces around block-level elements.
 				$output = preg_replace('{\s*()\s*}', '$1', $output);
 
-- 
cgit v1.2.3-24-g4f1b


From f59ec6fe4fab3bd5ff71d920e13f983454a9fb65 Mon Sep 17 00:00:00 2001
From: "Thor (atiredmachine)" 
Date: Tue, 24 Jan 2012 22:19:14 -0800
Subject: Logs 'debug' message that shows how much % was shaved off.

---
 system/core/Output.php | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

(limited to 'system')

diff --git a/system/core/Output.php b/system/core/Output.php
index 8992fc1f1..c95f551ec 100755
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -582,7 +582,9 @@ class CI_Output {
 		switch ($type)
 		{
 			case 'text/html':
-			
+
+				$size_before = strlen($output);
+
 				// Keep track of 
  and }msU',$output,$textareas_clean);
+				preg_match_all('{}msU', $output, $pres_clean);
+				preg_match_all('{}msU', $output, $codes_clean);
+				preg_match_all('{}msU', $output, $textareas_clean);
 
 				// Minify the CSS in all the }msU',$output,$style_clean);
+				preg_match_all('{}msU', $output, $style_clean);
 				foreach ($style_clean[0] as $s)
 				{
 					$output = str_replace($s, $this->minify($s,'text/css'), $output);
 				}
 
 				// Replace multiple spaces with a single space.
-				$output = preg_replace('!\s{2,}!',"\n",$output);
+				$output = preg_replace('!\s{2,}!', "\n", $output);
 				
 				// Remove comments (non-MSIE conditionals)
-				$output = preg_replace('{\s*\s*}msU','',$output);
+				$output = preg_replace('{\s*\s*}msU', '', $output);
 
 				// Remove spaces around block-level elements.
 				$output = preg_replace('{\s*()\s*}', '$1', $output);
 
 				// Replace mangled 
 etc. tags with unprocessed ones.
-				preg_match_all('{}msU',$output,$pres_messed);
-				preg_match_all('{}msU',$output,$codes_messed);
-				preg_match_all('{}msU',$output,$textareas_messed);
-				$output = str_replace($pres_messed[0],$pres_clean[0],$output);
-				$output = str_replace($codes_messed[0],$codes_clean[0],$output);
-				$output = str_replace($textareas_messed[0],$textareas_clean[0],$output);
+				preg_match_all('{}msU', $output, $pres_messed);
+				preg_match_all('{}msU', $output, $codes_messed);
+				preg_match_all('{}msU', $output, $textareas_messed);
+				$output = str_replace($pres_messed[0], $pres_clean[0], $output);
+				$output = str_replace($codes_messed[0], $codes_clean[0], $output);
+				$output = str_replace($textareas_messed[0], $textareas_clean[0], $output);
 				
 				$size_after = strlen($output);
 				$savings_percent = round(100 - ($size_after / $size_before * 100));
@@ -640,10 +635,10 @@ class CI_Output {
 			case 'text/css':
 			
 				// Remove spaces around curly brackets, colons, and semi-colons
-				$output = preg_replace('!\s*(:|;|}|{)\s*!','$1',$output);
+				$output = preg_replace('!\s*(:|;|}|{)\s*!', '$1', $output);
 				
 				// Replace spaces with line breaks to limit line lengths
-				$output = preg_replace('!\s+!',"\n",$output);
+				$output = preg_replace('!\s+!', "\n", $output);
 
 			break;
 		}
-- 
cgit v1.2.3-24-g4f1b


From 5c078ceeb926119fc3b4e55ca7c33ff2d1a207cd Mon Sep 17 00:00:00 2001
From: "Thor (atiredmachine)" 
Date: Thu, 26 Jan 2012 17:18:35 -0800
Subject: Added javascript. Improved based on comments.

---
 system/core/Output.php | 74 +++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 55 insertions(+), 19 deletions(-)

(limited to 'system')

diff --git a/system/core/Output.php b/system/core/Output.php
index 9bc02fc84..c4eba30bb 100755
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -593,12 +593,12 @@ class CI_Output {
 
 				$size_before = strlen($output);
 
-				// Keep track of 
  and }msU', $output, $textareas_clean);
+				preg_match_all('{}msU', $output, $javascript_clean);
 
 				// Minify the CSS in all the }msU', $output, $style_clean);
@@ -606,39 +606,75 @@ class CI_Output {
 				{
 					$output = str_replace($s, $this->minify($s,'text/css'), $output);
 				}
+				
+				// Minify the javascript in }msU', $output, $javascript_messed);
+					$output = str_replace($javascript_messed[0], $javascript_mini, $output);
+				}
+				
+				$size_removed = $size_before - strlen($output);
+				$savings_percent = round(($size_removed / $size_before * 100));
+
+				log_message('debug', 'Minifier shaved '.($size_removed / 1000).'KB ('.$savings_percent.'%) off final HTML output.');
 
 			break;
 			
 			
 			case 'text/css':
 			
-				// Remove spaces around curly brackets, colons, and semi-colons
-				$output = preg_replace('!\s*(:|;|}|{)\s*!', '$1', $output);
-				
-				// Replace spaces with line breaks to limit line lengths
-				$output = preg_replace('!\s+!', "\n", $output);
+				//Remove CSS comments
+				$output = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $output);
+			
+				// Remove spaces around curly brackets, colons,
+				// semi-colons, parenthesis, commas
+				$output = preg_replace('!\s*(:|;|,|}|{|\(|\))\s*!', '$1', $output);
+
+			break;
+			
+			
+			case 'text/javascript':
+
+				// Replace multiple spaces with a single newline.
+				$output = preg_replace('!\s{2,}!',"\n", $output);
+
+				// Remove excessive newlines.
+				$output = preg_replace('!(;|{|})\n!','$1', $output);
 
 			break;
 		}
-- 
cgit v1.2.3-24-g4f1b


From 6c5992da5cf3579a29079b0aae3e9ba0700fda5c Mon Sep 17 00:00:00 2001
From: "Thor (atiredmachine)" 
Date: Thu, 26 Jan 2012 18:45:57 -0800
Subject: Removed javascript for now...

---
 system/core/Output.php | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'system')

diff --git a/system/core/Output.php b/system/core/Output.php
index c4eba30bb..d8c230968 100755
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -670,11 +670,11 @@ class CI_Output {
 			
 			case 'text/javascript':
 
-				// Replace multiple spaces with a single newline.
-				$output = preg_replace('!\s{2,}!',"\n", $output);
+				// Replace multiple whitespace characters with a single newline.
+				//$output = preg_replace('!\s{2,}!',"\n", $output);
 
 				// Remove excessive newlines.
-				$output = preg_replace('!(;|{|})\n!','$1', $output);
+				//$output = preg_replace('!(;|{|})\n!','$1', $output);
 
 			break;
 		}
-- 
cgit v1.2.3-24-g4f1b


From 1b8d0ef6491b77375bb068711bc5e10fe4ca4b8f Mon Sep 17 00:00:00 2001
From: Thor 
Date: Sat, 28 Jan 2012 01:48:04 -0800
Subject: Fixed some spaces.

---
 system/core/Output.php | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

(limited to 'system')

diff --git a/system/core/Output.php b/system/core/Output.php
index d8c230968..468274002 100755
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -604,17 +604,17 @@ class CI_Output {
 				preg_match_all('{}msU', $output, $style_clean);
 				foreach ($style_clean[0] as $s)
 				{
-					$output = str_replace($s, $this->minify($s,'text/css'), $output);
+					$output = str_replace($s, $this->minify($s, 'text/css'), $output);
 				}
 				
 				// Minify the javascript in }msU', $output, $javascript_messed);
 					$output = str_replace($javascript_messed[0], $javascript_mini, $output);
 				}
-				
+
 				$size_removed = $size_before - strlen($output);
 				$savings_percent = round(($size_removed / $size_before * 100));
 
 				log_message('debug', 'Minifier shaved '.($size_removed / 1000).'KB ('.$savings_percent.'%) off final HTML output.');
 
 			break;
-			
-			
+
 			case 'text/css':
-			
+
 				//Remove CSS comments
 				$output = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $output);
-			
+
 				// Remove spaces around curly brackets, colons,
 				// semi-colons, parenthesis, commas
 				$output = preg_replace('!\s*(:|;|,|}|{|\(|\))\s*!', '$1', $output);
 
 			break;
-			
-			
+
 			case 'text/javascript':
 
 				// Currently leaves JavaScript untouched.
 			break;
+
+			default: break;
 		}
-		
+
 		return $output;
 	}
 
-
 }
 
 /* End of file Output.php */
-/* Location: ./system/core/Output.php */
+/* Location: ./system/core/Output.php */
\ No newline at end of file
diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php
index d96088c14..1e961f6df 100644
--- a/system/libraries/Profiler.php
+++ b/system/libraries/Profiler.php
@@ -116,6 +116,12 @@ class CI_Profiler {
 	 */
 	public function set_sections($config)
 	{
+		if (isset($config['query_toggle_count']))
+		{
+			$this->_query_toggle_count = (int) $config['query_toggle_count'];
+			unset($config['query_toggle_count']);
+		}
+
 		foreach ($config as $method => $enable)
 		{
 			if (in_array($method, $this->_available_sections))
-- 
cgit v1.2.3-24-g4f1b


From d24160cc4348c32c0c1ec7350e2e2dada2c9291a Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Sat, 16 Jun 2012 03:21:20 +0300
Subject: Changed order_by() default escaping to _protect_identifiers

---
 system/database/DB_query_builder.php | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

(limited to 'system')

diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index 486fda963..5eb6bbb4e 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -967,7 +967,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
 	 * @param	bool	enable field name escaping
 	 * @return	object
 	 */
-	public function order_by($orderby, $direction = '', $escape = TRUE)
+	public function order_by($orderby, $direction = '', $escape = NULL)
 	{
 		if (strtolower($direction) === 'random')
 		{
@@ -979,8 +979,9 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
 			$direction = in_array(strtoupper(trim($direction)), array('ASC', 'DESC'), TRUE) ? ' '.$direction : ' ASC';
 		}
 
+		is_bool($escape) OR $escape = $this->_protect_identifiers;
 
-		if ((strpos($orderby, ',') !== FALSE) && $escape === TRUE)
+		if ($escape === TRUE && strpos($orderby, ',') !== FALSE)
 		{
 			$temp = array();
 			foreach (explode(',', $orderby) as $part)
-- 
cgit v1.2.3-24-g4f1b


From 498c1e027e67dfd8108e0e255ff18fb914742b63 Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Sat, 16 Jun 2012 03:34:10 +0300
Subject: Added an escape parameter to where_in(), or_where_in(),
 where_not_in(), or_where_not_in() and made where(), or_where() to default the
 escape setting to the value of _protect_identifiers

---
 system/database/DB_query_builder.php               | 26 ++++++++++++----------
 system/database/drivers/postgre/postgre_driver.php |  5 +----
 2 files changed, 15 insertions(+), 16 deletions(-)

(limited to 'system')

diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index 5eb6bbb4e..85dd77da9 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -405,7 +405,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
 	 * @param	bool
 	 * @return	object
 	 */
-	public function where($key, $value = NULL, $escape = TRUE)
+	public function where($key, $value = NULL, $escape = NULL)
 	{
 		return $this->_where($key, $value, 'AND ', $escape);
 	}
@@ -423,7 +423,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
 	 * @param	bool
 	 * @return	object
 	 */
-	public function or_where($key, $value = NULL, $escape = TRUE)
+	public function or_where($key, $value = NULL, $escape = NULL)
 	{
 		return $this->_where($key, $value, 'OR ', $escape);
 	}
@@ -504,9 +504,9 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
 	 * @param	array	The values searched on
 	 * @return	object
 	 */
-	public function where_in($key = NULL, $values = NULL)
+	public function where_in($key = NULL, $values = NULL, $escape = NULL)
 	{
-		return $this->_where_in($key, $values);
+		return $this->_where_in($key, $values, FALSE, 'AND ', $escape);
 	}
 
 	// --------------------------------------------------------------------
@@ -521,9 +521,9 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
 	 * @param	array	The values searched on
 	 * @return	object
 	 */
-	public function or_where_in($key = NULL, $values = NULL)
+	public function or_where_in($key = NULL, $values = NULL, $escape = NULL)
 	{
-		return $this->_where_in($key, $values, FALSE, 'OR ');
+		return $this->_where_in($key, $values, FALSE, 'OR ', $escape);
 	}
 
 	// --------------------------------------------------------------------
@@ -538,9 +538,9 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
 	 * @param	array	The values searched on
 	 * @return	object
 	 */
-	public function where_not_in($key = NULL, $values = NULL)
+	public function where_not_in($key = NULL, $values = NULL, $escape = NULL)
 	{
-		return $this->_where_in($key, $values, TRUE);
+		return $this->_where_in($key, $values, TRUE, 'AND ', $escape);
 	}
 
 	// --------------------------------------------------------------------
@@ -555,9 +555,9 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
 	 * @param	array	The values searched on
 	 * @return	object
 	 */
-	public function or_where_not_in($key = NULL, $values = NULL)
+	public function or_where_not_in($key = NULL, $values = NULL, $escape = NULL)
 	{
-		return $this->_where_in($key, $values, TRUE, 'OR ');
+		return $this->_where_in($key, $values, TRUE, 'OR ', $escape);
 	}
 
 	// --------------------------------------------------------------------
@@ -573,7 +573,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
 	 * @param	string
 	 * @return	object
 	 */
-	protected function _where_in($key = NULL, $values = NULL, $not = FALSE, $type = 'AND ')
+	protected function _where_in($key = NULL, $values = NULL, $not = FALSE, $type = 'AND ', $escape = NULL)
 	{
 		if ($key === NULL OR $values === NULL)
 		{
@@ -587,6 +587,8 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
 			$values = array($values);
 		}
 
+		is_bool($escape) OR $escape = $this->_protect_identifiers;
+
 		$not = ($not) ? ' NOT' : '';
 
 		foreach ($values as $value)
@@ -595,7 +597,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
 		}
 
 		$prefix = (count($this->qb_where) === 0) ? '' : $type;
-		$this->qb_where[] = $where_in = $prefix.$this->protect_identifiers($key).$not.' IN ('.implode(', ', $this->qb_wherein).') ';
+		$this->qb_where[] = $where_in = $prefix.$this->protect_identifiers($key, FALSE, $escape).$not.' IN ('.implode(', ', $this->qb_wherein).') ';
 
 		if ($this->qb_caching === TRUE)
 		{
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index ad9ac9000..3d25b25ee 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -606,10 +606,7 @@ class CI_DB_postgre_driver extends CI_DB {
 		}
 
 		// If the escape value was not set will will base it on the global setting
-		if ( ! is_bool($escape))
-		{
-			$escape = $this->_protect_identifiers;
-		}
+		is_bool($escape) OR $escape = $this->_protect_identifiers;
 
 		foreach ($key as $k => $v)
 		{
-- 
cgit v1.2.3-24-g4f1b


From fe642dadd6ba62d597ccf1c7cb91e28059caeebf Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Sat, 16 Jun 2012 03:47:33 +0300
Subject: All Query Builder methods to respect _protect_identifiers by default

---
 system/database/DB_query_builder.php | 42 ++++++++++++++++++++----------------
 1 file changed, 24 insertions(+), 18 deletions(-)

(limited to 'system')

diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index 85dd77da9..1ac9af901 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -327,7 +327,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
 	 * @param	string	wether not to try to escape identifiers
 	 * @return	object
 	 */
-	public function join($table, $cond, $type = '', $escape = TRUE)
+	public function join($table, $cond, $type = '', $escape = NULL)
 	{
 		if ($type !== '')
 		{
@@ -347,6 +347,8 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
 		// in the protect_identifiers to know whether to add a table prefix
 		$this->_track_aliases($table);
 
+		is_bool($escape) OR $escape = $this->_protect_identifiers;
+
 		// Split multiple conditions
 		if ($escape === TRUE && preg_match_all('/\sAND\s|\sOR\s/i', $cond, $m, PREG_SET_ORDER | PREG_OFFSET_CAPTURE))
 		{
@@ -888,7 +890,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
 	 * @param	bool
 	 * @return	object
 	 */
-	public function having($key, $value = '', $escape = TRUE)
+	public function having($key, $value = '', $escape = NULL)
 	{
 		return $this->_having($key, $value, 'AND ', $escape);
 	}
@@ -905,7 +907,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
 	 * @param	bool
 	 * @return	object
 	 */
-	public function or_having($key, $value = '', $escape = TRUE)
+	public function or_having($key, $value = '', $escape = NULL)
 	{
 		return $this->_having($key, $value, 'OR ', $escape);
 	}
@@ -923,13 +925,15 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
 	 * @param	bool
 	 * @return	object
 	 */
-	protected function _having($key, $value = '', $type = 'AND ', $escape = TRUE)
+	protected function _having($key, $value = '', $type = 'AND ', $escape = NULL)
 	{
 		if ( ! is_array($key))
 		{
 			$key = array($key => $value);
 		}
 
+		is_bool($escape) OR $escape = $this->_protect_identifiers;
+
 		foreach ($key as $k => $v)
 		{
 			$prefix = (count($this->qb_having) === 0) ? '' : $type;
@@ -1057,14 +1061,16 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
 	// --------------------------------------------------------------------
 
 	/**
-	 * The "set" function.  Allows key/value pairs to be set for inserting or updating
+	 * The "set" function.
+	 *
+	 * Allows key/value pairs to be set for inserting or updating
 	 *
 	 * @param	mixed
 	 * @param	string
 	 * @param	bool
 	 * @return	object
 	 */
-	public function set($key, $value = '', $escape = TRUE)
+	public function set($key, $value = '', $escape = NULL)
 	{
 		$key = $this->_object_to_array($key);
 
@@ -1073,16 +1079,12 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
 			$key = array($key => $value);
 		}
 
+		is_bool($escape) OR $escape = $this->_protect_identifiers;
+
 		foreach ($key as $k => $v)
 		{
-			if ($escape === FALSE)
-			{
-				$this->qb_set[$this->protect_identifiers($k)] = $v;
-			}
-			else
-			{
-				$this->qb_set[$this->protect_identifiers($k, FALSE, TRUE)] = $this->escape($v);
-			}
+			$this->qb_set[$this->protect_identifiers($k, FALSE, $escape)] = ($escape)
+				? $this->escape($v) : $v;
 		}
 
 		return $this;
@@ -1288,7 +1290,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
 	 * @param	bool
 	 * @return	object
 	 */
-	public function set_insert_batch($key, $value = '', $escape = TRUE)
+	public function set_insert_batch($key, $value = '', $escape = NULL)
 	{
 		$key = $this->_object_to_array_batch($key);
 
@@ -1297,6 +1299,8 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
 			$key = array($key => $value);
 		}
 
+		is_bool($escape) OR $escape = $this->_protect_identifiers;
+
 		$keys = array_keys($this->_object_to_array(current($key)));
 		sort($keys);
 
@@ -1328,7 +1332,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
 
 		foreach ($keys as $k)
 		{
-			$this->qb_keys[] = $this->protect_identifiers($k);
+			$this->qb_keys[] = $this->protect_identifiers($k, FALSE, $escape);
 		}
 
 		return $this;
@@ -1727,7 +1731,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
 	 * @param	bool
 	 * @return	object
 	 */
-	public function set_update_batch($key, $index = '', $escape = TRUE)
+	public function set_update_batch($key, $index = '', $escape = NULL)
 	{
 		$key = $this->_object_to_array_batch($key);
 
@@ -1736,6 +1740,8 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
 			// @todo error
 		}
 
+		is_bool($escape) OR $escape = $this->_protect_identifiers;
+
 		foreach ($key as $k => $v)
 		{
 			$index_set = FALSE;
@@ -1747,7 +1753,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
 					$index_set = TRUE;
 				}
 
-				$clean[$this->protect_identifiers($k2)] = ($escape === FALSE) ? $v2 : $this->escape($v2);
+				$clean[$this->protect_identifiers($k2, FALSE, $escape)] = ($escape === FALSE) ? $v2 : $this->escape($v2);
 			}
 
 			if ($index_set === FALSE)
-- 
cgit v1.2.3-24-g4f1b


From f512b73bc78760198a5409f2c4da71fe749b1301 Mon Sep 17 00:00:00 2001
From: Alex Bilbie 
Date: Sat, 16 Jun 2012 11:15:19 +0100
Subject: Spelling fixes - `wether` to `whether`

Interestingly `wether` means a castrated ram in old English
---
 system/core/Hooks.php                | 4 ++--
 system/core/Output.php               | 2 +-
 system/database/DB_query_builder.php | 2 +-
 system/helpers/download_helper.php   | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

(limited to 'system')

diff --git a/system/core/Hooks.php b/system/core/Hooks.php
index 29fd88201..afbf4b453 100644
--- a/system/core/Hooks.php
+++ b/system/core/Hooks.php
@@ -39,7 +39,7 @@
 class CI_Hooks {
 
 	/**
-	 * Determines wether hooks are enabled
+	 * Determines whether hooks are enabled
 	 *
 	 * @var bool
 	 */
@@ -53,7 +53,7 @@ class CI_Hooks {
 	public $hooks =	array();
 
 	/**
-	 * Determines wether hook is in progress, used to prevent infinte loops
+	 * Determines whether hook is in progress, used to prevent infinte loops
 	 *
 	 * @var bool
 	 */
diff --git a/system/core/Output.php b/system/core/Output.php
index 570d4ebc9..ed294f116 100644
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -74,7 +74,7 @@ class CI_Output {
 	protected $mime_type		= 'text/html';
 
 	/**
-	 * Determines wether profiler is enabled
+	 * Determines whether profiler is enabled
 	 *
 	 * @var book
 	 */
diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index 1ac9af901..531ca9eb7 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -324,7 +324,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
 	 * @param	string
 	 * @param	string	the join condition
 	 * @param	string	the type of join
-	 * @param	string	wether not to try to escape identifiers
+	 * @param	string	whether not to try to escape identifiers
 	 * @return	object
 	 */
 	public function join($table, $cond, $type = '', $escape = NULL)
diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php
index 5efbc4930..09c4de578 100644
--- a/system/helpers/download_helper.php
+++ b/system/helpers/download_helper.php
@@ -46,7 +46,7 @@ if ( ! function_exists('force_download'))
 	 *
 	 * @param	string	filename
 	 * @param	mixed	the data to be downloaded
-	 * @param	bool	wether to try and send the actual file MIME type
+	 * @param	bool	whether to try and send the actual file MIME type
 	 * @return	void
 	 */
 	function force_download($filename = '', $data = '', $set_mime = FALSE)
-- 
cgit v1.2.3-24-g4f1b


From 3c32a11549d31cac470b92f995add25d7fdeff50 Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Sat, 16 Jun 2012 18:05:34 +0300
Subject: Small improvements to form_open()

---
 system/helpers/form_helper.php | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

(limited to 'system')

diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index 984634315..0c5d55037 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -62,9 +62,11 @@ if ( ! function_exists('form_open'))
 		{
 			$action = $CI->config->site_url($action);
 		}
-
-		// If no action is provided then set to the current url
-		$action OR $action = $CI->config->site_url($CI->uri->uri_string());
+		elseif ( ! $action)
+		{
+			// If no action is provided then set to the current url
+			$action = $CI->config->site_url($CI->uri->uri_string());
+		}
 
 		$form = '
\n"; @@ -76,7 +78,7 @@ if ( ! function_exists('form_open')) if (is_array($hidden) && count($hidden) > 0) { - $form .= sprintf('
%s
', form_hidden($hidden)); + $form .= '
'.form_hidden($hidden).'
'; } return $form; -- cgit v1.2.3-24-g4f1b From 1764dd7d4ab6e6e5c799eaa9ce007fce48fa0b63 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 16 Jun 2012 18:48:19 +0300 Subject: Fix issue #938 + some related improvements --- system/core/Config.php | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'system') diff --git a/system/core/Config.php b/system/core/Config.php index 3de1bcb96..656382716 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -225,12 +225,12 @@ class CI_Config { * Site URL * Returns base_url . index_page [. uri_string] * - * @param string the URI string + * @param mixed the URI string or an array of segments * @return string */ public function site_url($uri = '') { - if ($uri === '') + if (empty($uri)) { return $this->slash_item('base_url').$this->item('index_page'); } @@ -240,10 +240,12 @@ class CI_Config { $suffix = ($this->item('url_suffix') === FALSE) ? '' : $this->item('url_suffix'); return $this->slash_item('base_url').$this->slash_item('index_page').$this->_uri_string($uri).$suffix; } - else + elseif (is_array($uri) OR strpos($uri, '?') === FALSE) { - return $this->slash_item('base_url').$this->item('index_page').'?'.$this->_uri_string($uri); + $uri = '?'.$this->_uri_string($uri); } + + return $this->slash_item('base_url').$this->item('index_page').$uri; } // ------------------------------------------------------------- @@ -280,15 +282,7 @@ class CI_Config { } elseif (is_array($uri)) { - $i = 0; - $str = ''; - foreach ($uri as $key => $val) - { - $prefix = ($i === 0) ? '' : '&'; - $str .= $prefix.$key.'='.$val; - $i++; - } - return $str; + return http_build_query($uri); } return $uri; -- cgit v1.2.3-24-g4f1b From b089e15b1510de6b6a034631c80d3d5e830ff9f3 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 16 Jun 2012 19:11:40 +0300 Subject: Fix local_to_gmt() --- system/helpers/date_helper.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'system') diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php index 065a223ef..cafb6ba95 100644 --- a/system/helpers/date_helper.php +++ b/system/helpers/date_helper.php @@ -304,13 +304,13 @@ if ( ! function_exists('local_to_gmt')) $time = time(); } - return gmmktime( - date('G', $time), - date('i', $time), - date('s', $time), - date('n', $time), - date('j', $time), - date('Y', $time) + return mktime( + gmdate('G', $time), + gmdate('i', $time), + gmdate('s', $time), + gmdate('n', $time), + gmdate('j', $time), + gmdate('Y', $time) ); } } -- cgit v1.2.3-24-g4f1b From 95d78cf4f78c0fb685a789c280d106ab242318ef Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 16 Jun 2012 19:54:33 +0300 Subject: Fix issue #999 --- system/core/Config.php | 18 +++++++++++++++--- system/core/URI.php | 6 ++++-- 2 files changed, 19 insertions(+), 5 deletions(-) (limited to 'system') diff --git a/system/core/Config.php b/system/core/Config.php index 656382716..4b4e5a7ba 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -235,14 +235,26 @@ class CI_Config { return $this->slash_item('base_url').$this->item('index_page'); } + $uri = $this->_uri_string($uri); + if ($this->item('enable_query_strings') === FALSE) { $suffix = ($this->item('url_suffix') === FALSE) ? '' : $this->item('url_suffix'); - return $this->slash_item('base_url').$this->slash_item('index_page').$this->_uri_string($uri).$suffix; + + if ($suffix !== '' && ($offset = strpos($uri, '?')) !== FALSE) + { + $uri = substr($uri, 0, $offset).$suffix.substr($uri, $offset); + } + else + { + $uri .= $suffix; + } + + return $this->slash_item('base_url').$this->slash_item('index_page').$uri; } - elseif (is_array($uri) OR strpos($uri, '?') === FALSE) + elseif (strpos($uri, '?') === FALSE) { - $uri = '?'.$this->_uri_string($uri); + $uri = '?'.$uri; } return $this->slash_item('base_url').$this->item('index_page').$uri; diff --git a/system/core/URI.php b/system/core/URI.php index 208d311a5..6a8b1a5ac 100644 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -302,9 +302,11 @@ class CI_URI { */ public function _remove_url_suffix() { - if ($this->config->item('url_suffix') !== '') + $suffix = (string) $this->config->item('url_suffix'); + + if ($suffix !== '' && ($offset = strrpos($this->uri_string, $suffix)) !== FALSE) { - $this->uri_string = preg_replace('|'.preg_quote($this->config->item('url_suffix')).'$|', '', $this->uri_string); + $this->uri_string = substr_replace($this->uri_string, '', $offset, strlen($suffix)); } } -- cgit v1.2.3-24-g4f1b From f51b1fbafcf280d69633a37f4fc87c0ffcef78ad Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 16 Jun 2012 20:02:23 +0300 Subject: Fix CI_Calendar::generate() not accepting NULLs (introduced in d261b1e89c3d4d5191036d5a5660ef6764e593a0) --- system/libraries/Calendar.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php index 969a7610a..a49f171b9 100644 --- a/system/libraries/Calendar.php +++ b/system/libraries/Calendar.php @@ -155,7 +155,7 @@ class CI_Calendar { public function generate($year = '', $month = '', $data = array()) { // Set and validate the supplied month/year - if ($year === '') + if (empty($year)) { $year = date('Y', $this->local_time); } @@ -168,7 +168,7 @@ class CI_Calendar { $year = '20'.$year; } - if ($month === '') + if (empty($month)) { $month = date('m', $this->local_time); } -- cgit v1.2.3-24-g4f1b From 95b2f4fa070f34084c78ccc68e67ecca51f40adf Mon Sep 17 00:00:00 2001 From: vkeranov Date: Sat, 16 Jun 2012 20:37:11 +0300 Subject: Really important space fix :) --- system/libraries/Zip.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index e0dc637ad..5c4c257f8 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -40,7 +40,7 @@ * @author EllisLab Dev Team * @link http://codeigniter.com/user_guide/libraries/zip.html */ -class CI_Zip { +class CI_Zip { /** * Zip data in string form -- cgit v1.2.3-24-g4f1b From f0a8410a5cbe080b377ec352320872d27ce7d91f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 16 Jun 2012 20:52:20 +0300 Subject: Fix two anchor_popup() issues --- system/helpers/url_helper.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'system') diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php index 2bd41b04d..58bde17b4 100644 --- a/system/helpers/url_helper.php +++ b/system/helpers/url_helper.php @@ -204,7 +204,7 @@ if ( ! function_exists('anchor_popup')) if ( ! is_array($attributes)) { - $attributes = array(); + $attributes = array($attributes); } foreach (array('width' => '800', 'height' => '600', 'scrollbars' => 'yes', 'status' => 'yes', 'resizable' => 'yes', 'screenx' => '0', 'screeny' => '0', ) as $key => $val) @@ -213,10 +213,7 @@ if ( ! function_exists('anchor_popup')) unset($attributes[$key]); } - if ($attributes !== '') - { - $attributes = _parse_attributes($attributes); - } + $attributes = empty($attributes) ? '' : _parse_attributes($attributes); return ''.$title.''; } -- cgit v1.2.3-24-g4f1b From 81c3208b79cca353b27ecd4bdf00d4b6e7c91b2c Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 16 Jun 2012 21:21:46 +0300 Subject: anchor_popup() improvements --- system/helpers/url_helper.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php index 58bde17b4..40ce807df 100644 --- a/system/helpers/url_helper.php +++ b/system/helpers/url_helper.php @@ -199,15 +199,23 @@ if ( ! function_exists('anchor_popup')) if ($attributes === FALSE) { - return '".$title.''; + return '".$title.''; } if ( ! is_array($attributes)) { $attributes = array($attributes); + + // Ref: http://www.w3schools.com/jsref/met_win_open.asp + $window_name = '_blank'; + } + elseif ( ! empty($attributes['window_name'])) + { + $window_name = $attributes['window_name']; + unset($attributes['window_name']); } - foreach (array('width' => '800', 'height' => '600', 'scrollbars' => 'yes', 'status' => 'yes', 'resizable' => 'yes', 'screenx' => '0', 'screeny' => '0', ) as $key => $val) + foreach (array('width' => '800', 'height' => '600', 'scrollbars' => 'yes', 'status' => 'yes', 'resizable' => 'yes', 'screenx' => '0', 'screeny' => '0') as $key => $val) { $atts[$key] = isset($attributes[$key]) ? $attributes[$key] : $val; unset($attributes[$key]); @@ -215,7 +223,9 @@ if ( ! function_exists('anchor_popup')) $attributes = empty($attributes) ? '' : _parse_attributes($attributes); - return ''.$title.''; + return ''.$title.''; } } -- cgit v1.2.3-24-g4f1b From d60e700640c2a67f74acff090b94d06117bfc203 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 17 Jun 2012 00:03:03 +0300 Subject: Add an option to disable MIME detection in the Upload library (issue #1494) --- system/libraries/Upload.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index c96daaf15..d381440cd 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -59,6 +59,7 @@ class CI_Upload { public $error_msg = array(); public $mimes = array(); public $remove_spaces = TRUE; + public $detect_mime = TRUE; public $xss_clean = FALSE; public $temp_prefix = 'temp_file_'; public $client_name = ''; @@ -116,6 +117,7 @@ class CI_Upload { 'image_size_str' => '', 'error_msg' => array(), 'remove_spaces' => TRUE, + 'detect_mime' => TRUE, 'xss_clean' => FALSE, 'temp_prefix' => 'temp_file_', 'client_name' => '' @@ -209,7 +211,13 @@ class CI_Upload { // Set the uploaded data as class variables $this->file_temp = $_FILES[$field]['tmp_name']; $this->file_size = $_FILES[$field]['size']; - $this->_file_mime_type($_FILES[$field]); + + // Skip MIME type detection? + if ($this->detect_mime !== FALSE) + { + $this->_file_mime_type($_FILES[$field]); + } + $this->file_type = preg_replace('/^(.+?);.*$/', '\\1', $this->file_type); $this->file_type = strtolower(trim(stripslashes($this->file_type), '"')); $this->file_name = $this->_prep_filename($_FILES[$field]['name']); @@ -990,7 +998,7 @@ class CI_Upload { */ if (function_exists('finfo_file')) { - $finfo = finfo_open(FILEINFO_MIME); + $finfo = @finfo_open(FILEINFO_MIME); if (is_resource($finfo)) // It is possible that a FALSE value is returned, if there is no magic MIME database file found on the system { $mime = @finfo_file($finfo, $file['tmp_name']); @@ -1021,7 +1029,9 @@ class CI_Upload { */ if (DIRECTORY_SEPARATOR !== '\\') { - $cmd = 'file --brief --mime '.escapeshellarg($file['tmp_name']).' 2>&1'; + $cmd = function_exists('escapeshellarg') + ? 'file --brief --mime '.escapeshellarg($file['tmp_name']).' 2>&1' + : 'file --brief --mime '.$file['tmp_name'].' 2>&1'; if (function_exists('exec')) { -- cgit v1.2.3-24-g4f1b From 88c47278f775413b5a408f48d30bd279e34e601a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 17 Jun 2012 02:32:31 +0300 Subject: Pagination: fixed 'rel' attribute handling, added custom attributes support, deprecated 'anchor_class' setting --- system/libraries/Pagination.php | 86 ++++++++++++++++++++++++++++------------- 1 file changed, 59 insertions(+), 27 deletions(-) (limited to 'system') diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index cdec736ff..9a5a0bf62 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -67,8 +67,8 @@ class CI_Pagination { public $page_query_string = FALSE; public $query_string_segment = 'per_page'; public $display_pages = TRUE; - public $anchor_class = ''; - public $attr_rel = TRUE; + protected $_attributes = ''; + protected $_link_types = array(); /** * Constructor @@ -92,15 +92,29 @@ class CI_Pagination { */ public function initialize($params = array()) { + $attributes = array(); + + if (isset($params['attributes']) && is_array($params['attributes'])) + { + $attributes = $params['attributes']; + unset($params['attributes']); + } + + // Deprecated legacy support for the anchor_class option + // Should be removed in CI 3.1+ + if (isset($params['anchor_class'])) + { + empty($params['anchor_class']) OR $attributes['class'] = $params['anchor_class']; + unset($params['anchor_class']); + } + + $this->_parse_attributes($attributes); + if (count($params) > 0) { foreach ($params as $key => $val) { - if ($key === 'anchor_class') - { - $this->anchor_class = ($val) ? 'class="'.$val.'" ' : ''; - } - elseif (isset($this->$key)) + if (isset($this->$key)) { $this->$key = $val; } @@ -213,7 +227,7 @@ class CI_Pagination { if ($this->first_link !== FALSE && $this->cur_page > ($this->num_links + 1)) { $first_url = ($this->first_url === '') ? $this->base_url : $this->first_url; - $output .= $this->first_tag_open.'anchor_class.'href="'.$first_url.'"'.$this->_attr_rel('start').'>' + $output .= $this->first_tag_open.'_attributes.$this->_attr_rel('start').'>' .$this->first_link.''.$this->first_tag_close; } @@ -224,13 +238,13 @@ class CI_Pagination { if ($i === $base_page && $this->first_url !== '') { - $output .= $this->prev_tag_open.'anchor_class.'href="'.$this->first_url.'"'.$this->_attr_rel('prev').'>' + $output .= $this->prev_tag_open.'_attributes.$this->_attr_rel('prev').'>' .$this->prev_link.''.$this->prev_tag_close; } else { $i = ($i === $base_page) ? '' : $this->prefix.$i.$this->suffix; - $output .= $this->prev_tag_open.'anchor_class.'href="'.$this->base_url.$i.'"'.$this->_attr_rel('prev').'>' + $output .= $this->prev_tag_open.'_attributes.$this->_attr_rel('prev').'>' .$this->prev_link.''.$this->prev_tag_close; } @@ -243,7 +257,6 @@ class CI_Pagination { for ($loop = $start -1; $loop <= $end; $loop++) { $i = ($this->use_page_numbers) ? $loop : ($loop * $this->per_page) - $this->per_page; - if ($i >= $base_page) { if ($this->cur_page === $loop) @@ -253,17 +266,15 @@ class CI_Pagination { else { $n = ($i === $base_page) ? '' : $i; - - if ($n === '' && $this->first_url !== '') + if ($n === '' && ! empty($this->first_url)) { - $output .= $this->num_tag_open.'anchor_class.'href="'.$this->first_url.'"'.$this->_attr_rel('start').'>' + $output .= $this->num_tag_open.'_attributes.$this->_attr_rel('start').'>' .$loop.''.$this->num_tag_close; } else { $n = ($n === '') ? '' : $this->prefix.$n.$this->suffix; - - $output .= $this->num_tag_open.'anchor_class.'href="'.$this->base_url.$n.'"'.$this->_attr_rel().'>' + $output .= $this->num_tag_open.'_attributes.$this->_attr_rel('start').'>' .$loop.''.$this->num_tag_close; } } @@ -276,8 +287,8 @@ class CI_Pagination { { $i = ($this->use_page_numbers) ? $this->cur_page + 1 : $this->cur_page * $this->per_page; - $output .= $this->next_tag_open.'anchor_class.'href="'.$this->base_url.$this->prefix.$i.$this->suffix.'"'.$this->_attr_rel('next').'>' - .$this->next_link.''.$this->next_tag_close; + $output .= $this->next_tag_open.'_attributes + .$this->_attr_rel('next').'>'.$this->next_link.''.$this->next_tag_close; } // Render the "Last" link @@ -285,7 +296,7 @@ class CI_Pagination { { $i = ($this->use_page_numbers) ? $num_pages : ($num_pages * $this->per_page) - $this->per_page; - $output .= $this->last_tag_open.'anchor_class.'href="'.$this->base_url.$this->prefix.$i.$this->suffix.'"'.$this->_attr_rel().'>' + $output .= $this->last_tag_open.'_attributes.'>' .$this->last_link.''.$this->last_tag_close; } @@ -299,24 +310,45 @@ class CI_Pagination { // -------------------------------------------------------------------- + /** + * Parse attributes + * + * @param array + * @return void + */ + protected function _parse_attributes($attributes) + { + isset($attributes['rel']) OR $attributes['rel'] = TRUE; + $this->_link_types = ($attributes['rel']) + ? array('start' => 'start', 'prev' => 'prev', 'next' => 'next') + : array(); + unset($attributes['rel']); + + $this->_attributes = ''; + foreach ($attributes as $key => $value) + { + $this->_attributes .= ' '.$key.'="'.$value.'"'; + } + } + + // -------------------------------------------------------------------- + /** * Add "rel" attribute * + * @link http://www.w3.org/TR/html5/links.html#linkTypes * @param string * @return string */ - protected function _attr_rel($value = '') + protected function _attr_rel($type) { - if (empty($this->attr_rel) OR ($this->attr_rel === TRUE && empty($value))) - { - return ''; - } - elseif ( ! is_bool($this->attr_rel)) + if (isset($this->_link_types[$type])) { - $value = $this->attr_rel; + unset($this->_link_types[$type]); + return ' rel="'.$type.'"'; } - return ' rel="'.$value.'"'; + return ''; } } -- cgit v1.2.3-24-g4f1b From 0159ae7d492cccca7a30a2f5b5c2b107d399e7ea Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 17 Jun 2012 02:33:43 +0300 Subject: AND -> && --- system/libraries/Cache/drivers/Cache_file.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php index 028875b7d..37d77c268 100644 --- a/system/libraries/Cache/drivers/Cache_file.php +++ b/system/libraries/Cache/drivers/Cache_file.php @@ -73,7 +73,7 @@ class CI_Cache_file extends CI_Driver { $data = unserialize(file_get_contents($this->_cache_path.$id)); - if ($data['ttl'] > 0 AND time() > $data['time'] + $data['ttl']) + if ($data['ttl'] > 0 && time() > $data['time'] + $data['ttl']) { unlink($this->_cache_path.$id); return FALSE; -- cgit v1.2.3-24-g4f1b From d1cace76965f71107aca63df1057b98df8d3b85a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 17 Jun 2012 03:01:00 +0300 Subject: Add deprecated docblock tags for do_hash() and read_file() --- system/helpers/file_helper.php | 1 + system/helpers/security_helper.php | 1 + 2 files changed, 2 insertions(+) (limited to 'system') diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php index be616f62d..7270ee32c 100644 --- a/system/helpers/file_helper.php +++ b/system/helpers/file_helper.php @@ -47,6 +47,7 @@ if ( ! function_exists('read_file')) * This function is DEPRECATED and should be removed in * CodeIgniter 3.1+. Use file_get_contents() instead. * + * @deprecated * @param string path to file * @return string */ diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php index 7fcb18437..7968f9e9f 100644 --- a/system/helpers/security_helper.php +++ b/system/helpers/security_helper.php @@ -80,6 +80,7 @@ if ( ! function_exists('do_hash')) * This function is DEPRECATED and should be removed in * CodeIgniter 3.1+. Use hash() instead. * + * @deprecated * @param string * @param string * @return string -- cgit v1.2.3-24-g4f1b From 929fd2d52beb779e46681d35f8ff138aa65cb8df Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 17 Jun 2012 17:29:57 +0300 Subject: Improve escaping, support for table names with spaces and fix where() for strings with no spaces around operators --- system/database/DB_driver.php | 56 ++++++++++------------ system/database/DB_query_builder.php | 4 +- system/database/drivers/postgre/postgre_driver.php | 4 +- 3 files changed, 30 insertions(+), 34 deletions(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 28d665fdf..4ec20f45d 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1085,6 +1085,20 @@ abstract class CI_DB_driver { // -------------------------------------------------------------------- + /** + * Returns the SQL string operator + * + * @param string + * @return string + */ + protected function _get_operator($str) + { + return preg_match('/(=|!|<|>| IS NULL| IS NOT NULL| BETWEEN)/i', $str, $match) + ? $match[1] : FALSE; + } + + // -------------------------------------------------------------------- + /** * Enables a native PHP function to be run, using a platform agnostic wrapper. * @@ -1336,39 +1350,21 @@ abstract class CI_DB_driver { // Convert tabs or multiple spaces into single spaces $item = preg_replace('/\s+/', ' ', $item); - static $preg_ec = array(); - - if (empty($preg_ec)) + // If the item has an alias declaration we remove it and set it aside. + // Note: strripos() is used in order to support spaces in table names + if ($offset = strripos($item, ' AS ')) { - if (is_array($this->_escape_char)) - { - $preg_ec = array(preg_quote($this->_escape_char[0]), preg_quote($this->_escape_char[1])); - } - else - { - $preg_ec[0] = $preg_ec[1] = preg_quote($this->_escape_char); - } + $alias = ($protect_identifiers) + ? substr($item, $offset, 4).$this->escape_identifiers(substr($item, $offset + 4)) + : substr($item, $offset); + $item = substr($item, 0, $offset); } - - // If the item has an alias declaration we remove it and set it aside. - // Basically we remove everything to the right of the first space - preg_match('/^(('.$preg_ec[0].'[^'.$preg_ec[1].']+'.$preg_ec[1].')|([^'.$preg_ec[0].'][^\s]+))( AS)*(.+)*$/i', $item, $matches); - - if (isset($matches[4])) + elseif ($offset = strrpos($item, ' ')) { - $item = $matches[1]; - - // Escape the alias, if needed - if ($protect_identifiers === TRUE) - { - $alias = empty($matches[5]) - ? ' '.$this->escape_identifiers(ltrim($matches[4])) - : $matches[4].' '.$this->escape_identifiers(ltrim($matches[5])); - } - else - { - $alias = $matches[4].$matches[5]; - } + $alias = ($protect_identifiers) + ? ' '.$this->escape_identifiers(substr($item, $offset + 1)) + : substr($item, $offset); + $item = substr($item, 0, $offset); } else { diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index 531ca9eb7..27f9f363b 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -459,8 +459,8 @@ abstract class CI_DB_query_builder extends CI_DB_driver { { $prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0) ? '' : $type; - $k = $this->_has_operator($k) - ? $this->protect_identifiers(substr($k, 0, strpos(rtrim($k), ' ')), FALSE, $escape).strchr(rtrim($k), ' ') + $k = (($op = $this->_get_operator($k)) !== FALSE) + ? $this->protect_identifiers(substr($k, 0, strpos($k, $op)), FALSE, $escape).strstr($k, $op) : $this->protect_identifiers($k, FALSE, $escape); if (is_null($v) && ! $this->_has_operator($k)) diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php index 3d25b25ee..23826a0ae 100644 --- a/system/database/drivers/postgre/postgre_driver.php +++ b/system/database/drivers/postgre/postgre_driver.php @@ -612,8 +612,8 @@ class CI_DB_postgre_driver extends CI_DB { { $prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0) ? '' : $type; - $k = $this->_has_operator($k) - ? $this->protect_identifiers(substr($k, 0, strpos(rtrim($k), ' ')), FALSE, $escape).strchr(rtrim($k), ' ') + $k = (($op = $this->_get_operator($k)) !== FALSE) + ? $this->protect_identifiers(substr($k, 0, strpos($k, $op)), FALSE, $escape).strstr($k, $op) : $this->protect_identifiers($k, FALSE, $escape); if (is_null($v) && ! $this->_has_operator($k)) -- cgit v1.2.3-24-g4f1b From 3751f9362b731f5f3d2e63176c364d6281fdf415 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 17 Jun 2012 18:07:48 +0300 Subject: Add join() USING support --- system/database/DB_query_builder.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'system') diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index 27f9f363b..4c54b1c0a 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -368,12 +368,20 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $newcond .= $m[0][$i][0]; } - $cond = $newcond; + $cond = ' ON '.$newcond; } // Split apart the condition and protect the identifiers elseif ($escape === TRUE && preg_match('/([\[\w\.-]+)([\W\s]+)(.+)/i', $cond, $match)) { - $cond = $this->protect_identifiers($match[1]).$match[2].$this->protect_identifiers($match[3]); + $cond = ' ON '.$this->protect_identifiers($match[1]).$match[2].$this->protect_identifiers($match[3]); + } + elseif ( ! $this->_has_operator($cond)) + { + $cond = ' USING ('.($escape ? $this->escape_identifiers($cond) : $cond).')'; + } + else + { + $cond = ' ON '.$cond; } // Do we want to escape the table name? @@ -383,7 +391,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { } // Assemble the JOIN statement - $this->qb_join[] = $join = $type.'JOIN '.$table.' ON '.$cond; + $this->qb_join[] = $join = $type.'JOIN '.$table.$cond; if ($this->qb_caching === TRUE) { -- cgit v1.2.3-24-g4f1b From 6ac514484fffd9700c6ecc57cfa1b1fd105e37f6 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 18 Jun 2012 13:05:17 +0300 Subject: Fix issue #1328 --- system/libraries/Form_validation.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'system') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index fb1c69caf..db773e252 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -649,7 +649,12 @@ class CI_Form_validation { } else { - $postdata = $this->_field_data[$row['field']]['postdata']; + // If we get an array field, but it's not expected - then it is most likely + // somebody messing with the form on the client side, so we'll just consider + // it an empty field + $postdata = is_array($this->_field_data[$row['field']]['postdata']) + ? NULL + : $this->_field_data[$row['field']]['postdata']; } // Is the rule a callback? -- cgit v1.2.3-24-g4f1b From fad14b25148ca7202a036dc2b764feb0c8518838 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 18 Jun 2012 13:23:24 +0300 Subject: Fix ODBC _limit() --- system/database/drivers/odbc/odbc_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php index 222c311c0..5ebba7aeb 100644 --- a/system/database/drivers/odbc/odbc_driver.php +++ b/system/database/drivers/odbc/odbc_driver.php @@ -342,7 +342,7 @@ class CI_DB_odbc_driver extends CI_DB { */ protected function _limit($sql, $limit, $offset) { - return $sql.($offset == 0 ? '' : $offset.', ').$limit; + return $sql.' LIMIT '.($offset == 0 ? '' : $offset.', ').$limit; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 777153d8362ed884fc3d47ea4a5e1fa0f1ce8ca9 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 18 Jun 2012 13:30:45 +0300 Subject: Changed limit() and offset() to ignore NULL values --- system/database/DB_query_builder.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'system') diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index 4c54b1c0a..d21f15066 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -1042,12 +1042,8 @@ abstract class CI_DB_query_builder extends CI_DB_driver { */ public function limit($value, $offset = NULL) { - $this->qb_limit = (int) $value; - - if ( ! empty($offset)) - { - $this->qb_offset = (int) $offset; - } + is_null($value) OR $this->qb_limit = (int) $value; + empty($offset) OR $this->qb_offset = (int) $offset; return $this; } @@ -1062,7 +1058,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { */ public function offset($offset) { - $this->qb_offset = (int) $offset; + empty($offset) OR $this->qb_offset = (int) $offset; return $this; } -- cgit v1.2.3-24-g4f1b From 9e5a9b55d6bd3588a35f42d62f76934b4a7582f4 Mon Sep 17 00:00:00 2001 From: Dumk0 Date: Tue, 19 Jun 2012 12:02:27 +0300 Subject: Property values aligned into one vertical line --- system/libraries/Pagination.php | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'system') diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index 9a5a0bf62..5a4ca8f10 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -36,36 +36,36 @@ */ class CI_Pagination { - public $base_url = ''; // The page we are linking to - public $prefix = ''; // A custom prefix added to the path. - public $suffix = ''; // A custom suffix added to the path. - public $total_rows = 0; // Total number of items (database results) - public $per_page = 10; // Max number of items you want shown per page - public $num_links = 2; // Number of "digit" links to show before/after the currently viewed page - public $cur_page = 0; // The current page being viewed - public $use_page_numbers = FALSE; // Use page number for segment instead of offset - public $first_link = '‹ First'; - public $next_link = '>'; - public $prev_link = '<'; - public $last_link = 'Last ›'; - public $uri_segment = 3; + public $base_url = ''; // The page we are linking to + public $prefix = ''; // A custom prefix added to the path. + public $suffix = ''; // A custom suffix added to the path. + public $total_rows = 0; // Total number of items (database results) + public $per_page = 10; // Max number of items you want shown per page + public $num_links = 2; // Number of "digit" links to show before/after the currently viewed page + public $cur_page = 0; // The current page being viewed + public $use_page_numbers = FALSE; // Use page number for segment instead of offset + public $first_link = '‹ First'; + public $next_link = '>'; + public $prev_link = '<'; + public $last_link = 'Last ›'; + public $uri_segment = 3; public $full_tag_open = ''; public $full_tag_close = ''; public $first_tag_open = ''; public $first_tag_close = ' '; public $last_tag_open = ' '; public $last_tag_close = ''; - public $first_url = ''; // Alternative URL for the First Page. - public $cur_tag_open = ' '; + public $first_url = ''; // Alternative URL for the First Page. + public $cur_tag_open = ' '; public $cur_tag_close = ''; public $next_tag_open = ' '; public $next_tag_close = ' '; public $prev_tag_open = ' '; public $prev_tag_close = ''; - public $num_tag_open = ' '; + public $num_tag_open = ' '; public $num_tag_close = ''; public $page_query_string = FALSE; - public $query_string_segment = 'per_page'; + public $query_string_segment = 'per_page'; public $display_pages = TRUE; protected $_attributes = ''; protected $_link_types = array(); -- cgit v1.2.3-24-g4f1b From af6d85088d54ed35f7c36ed010384ff7592f8959 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Tue, 19 Jun 2012 15:30:47 -0500 Subject: Fixed Migrations and an incorrect strict comparison. --- system/language/english/migration_lang.php | 2 +- system/libraries/Migration.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/language/english/migration_lang.php b/system/language/english/migration_lang.php index 9e3e18807..af920660c 100644 --- a/system/language/english/migration_lang.php +++ b/system/language/english/migration_lang.php @@ -26,7 +26,7 @@ */ $lang['migration_none_found'] = "No migrations were found."; -$lang['migration_not_found'] = "This migration could not be found."; +$lang['migration_not_found'] = "No migration could be found with the version number: %d."; $lang['migration_multiple_version'] = "This are multiple migrations with the same version number: %d."; $lang['migration_class_doesnt_exist'] = "The migration class \"%s\" could not be found."; $lang['migration_missing_up_method'] = "The migration class \"%s\" is missing an 'up' method."; diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php index 4391b235d..3a1e7a0ad 100644 --- a/system/libraries/Migration.php +++ b/system/libraries/Migration.php @@ -179,7 +179,7 @@ class CI_Migration { // We now prepare to actually DO the migrations // But first let's make sure that everything is the way it should be - for ($i = $start; $i !== $stop; $i += $step) + for ($i = $start; $i != $stop; $i += $step) { $f = glob(sprintf($this->_migration_path.'%03d_*.php', $i)); -- cgit v1.2.3-24-g4f1b From 2f0dce0fa788c442c85318afc30122afb20a880b Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 20 Jun 2012 11:05:01 +0300 Subject: Small adjustment due to 079fbfcde095230f304e889217f897031a948f61 --- system/database/DB_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 4ec20f45d..a99444167 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1281,7 +1281,7 @@ abstract class CI_DB_driver { if (isset($call['file']) && strpos($call['file'], BASEPATH.'database') === FALSE) { // Found it - use a relative path for safety - $message[] = 'Filename: '.str_replace(array(BASEPATH, APPPATH), '', $call['file']); + $message[] = 'Filename: '.str_replace(array(APPPATH, BASEPATH), '', $call['file']); $message[] = 'Line Number: '.$call['line']; break; } -- cgit v1.2.3-24-g4f1b From 8d3099d4e5261e0f044c7fcd8b3ab7724645aa8d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 21 Jun 2012 16:00:20 +0300 Subject: Fix issue #79 --- system/libraries/Form_validation.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'system') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index db773e252..4bb29e41b 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -571,8 +571,7 @@ class CI_Form_validation { { foreach ($postdata as $key => $val) { - $this->_execute($row, $rules, $val, $cycles); - $cycles++; + $this->_execute($row, $rules, $val, $key); } return; -- cgit v1.2.3-24-g4f1b From 3b6af434b13168828429d06aae7699f6f9537a87 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Thu, 21 Jun 2012 09:21:17 -0500 Subject: Replaced block tag minification regex with a less greedy solution. --- system/core/Output.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system') diff --git a/system/core/Output.php b/system/core/Output.php index ed294f116..4fdf18f14 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -652,7 +652,7 @@ class CI_Output { $output = preg_replace('{\s*\s*}msU', '', $output); // Remove spaces around block-level elements. - $output = preg_replace('{\s*()\s+}msU', '$1', $output); + $output = preg_replace('/\s*(<\/?(html|head|title|meta|script|link|style|body|h[1-6]|div|p|br)[^>]*>)\s*/is', '$1', $output); // Replace mangled
 etc. tags with unprocessed ones.
 
-- 
cgit v1.2.3-24-g4f1b


From bc69f369eba2f1188be6d89ebd1df8c48e96db5d Mon Sep 17 00:00:00 2001
From: WanWizard 
Date: Fri, 22 Jun 2012 00:10:11 +0200
Subject: fixed query grouping when using where($array) syntax

on request of Phil
---
 system/database/DB_query_builder.php | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

(limited to 'system')

diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php
index d21f15066..62e02129b 100644
--- a/system/database/DB_query_builder.php
+++ b/system/database/DB_query_builder.php
@@ -453,8 +453,6 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
 	 */
 	protected function _where($key, $value = NULL, $type = 'AND ', $escape = NULL)
 	{
-		$type = $this->_group_get_type($type);
-
 		if ( ! is_array($key))
 		{
 			$key = array($key => $value);
@@ -465,7 +463,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
 
 		foreach ($key as $k => $v)
 		{
-			$prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0) ? '' : $type;
+			$prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0) ? $this->_group_get_type('') : $this->_group_get_type($type);
 
 			$k = (($op = $this->_get_operator($k)) !== FALSE)
 				? $this->protect_identifiers(substr($k, 0, strpos($k, $op)), FALSE, $escape).strstr($k, $op)
@@ -590,8 +588,6 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
 			return $this;
 		}
 
-		$type = $this->_group_get_type($type);
-
 		if ( ! is_array($values))
 		{
 			$values = array($values);
@@ -606,7 +602,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
 			$this->qb_wherein[] = $this->escape($value);
 		}
 
-		$prefix = (count($this->qb_where) === 0) ? '' : $type;
+		$prefix = (count($this->qb_where) === 0) ? $this->_group_get_type('') : $this->_group_get_type($type);
 		$this->qb_where[] = $where_in = $prefix.$this->protect_identifiers($key, FALSE, $escape).$not.' IN ('.implode(', ', $this->qb_wherein).') ';
 
 		if ($this->qb_caching === TRUE)
@@ -702,8 +698,6 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
 	 */
 	protected function _like($field, $match = '', $type = 'AND ', $side = 'both', $not = '')
 	{
-		$type = $this->_group_get_type($type);
-
 		if ( ! is_array($field))
 		{
 			$field = array($field => $match);
@@ -712,7 +706,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
 		foreach ($field as $k => $v)
 		{
 			$k = $this->protect_identifiers($k);
-			$prefix = (count($this->qb_like) === 0) ? '' : $type;
+			$prefix = (count($this->qb_like) === 0) ? $this->_group_get_type('') : $this->_group_get_type($type);
 			$v = $this->escape_like_str($v);
 
 			if ($side === 'none')
@@ -2393,4 +2387,4 @@ abstract class CI_DB_query_builder extends CI_DB_driver {
 }
 
 /* End of file DB_query_builder.php */
-/* Location: ./system/database/DB_query_builder.php */
\ No newline at end of file
+/* Location: ./system/database/DB_query_builder.php */
-- 
cgit v1.2.3-24-g4f1b


From 7540dede0f01acd7aa1ffd224defc5189305a815 Mon Sep 17 00:00:00 2001
From: Mat Whitney 
Date: Fri, 22 Jun 2012 12:02:10 -0700
Subject: Added optional fourth parameter to timezone_menu
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

allows setting one or more attributes on the generated select tag.
This allows passing attributes needed for Section 508 compliance ยง
1194.22(n), such as an id.
http://access-board.gov/sec508/guide/1194.22.htm#(n)
http://www.w3.org/TR/WCAG10-HTML-TECHS/#forms-labels
---
 system/helpers/date_helper.php | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

(limited to 'system')

diff --git a/system/helpers/date_helper.php b/system/helpers/date_helper.php
index cafb6ba95..fc790c585 100644
--- a/system/helpers/date_helper.php
+++ b/system/helpers/date_helper.php
@@ -547,9 +547,10 @@ if ( ! function_exists('timezone_menu'))
 	 * @param	string	timezone
 	 * @param	string	classname
 	 * @param	string	menu name
+	 * @param	mixed	attributes
 	 * @return	string
 	 */
-	function timezone_menu($default = 'UTC', $class = '', $name = 'timezones')
+	function timezone_menu($default = 'UTC', $class = '', $name = 'timezones', $attributes = '')
 	{
 		$CI =& get_instance();
 		$CI->lang->load('date');
@@ -563,7 +564,22 @@ if ( ! function_exists('timezone_menu'))
 			$menu .= ' class="'.$class.'"';
 		}
 
-		$menu .= ">\n";
+		// 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";
 
 		foreach (timezones() as $key => $val)
 		{
-- 
cgit v1.2.3-24-g4f1b


From f82b92999e8309155df3e665e25a261c26b0e93d Mon Sep 17 00:00:00 2001
From: Phil Sturgeon 
Date: Sat, 23 Jun 2012 15:49:23 +0100
Subject: Added ['reuse_query_string'] to Pagination. This allows automatic
 repopulation of query string arguments, combined with normal URI segments.

---
 system/libraries/Pagination.php | 98 ++++++++++++++++++++++++-----------------
 1 file changed, 58 insertions(+), 40 deletions(-)

(limited to 'system')

diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
index 5a4ca8f10..75745dd48 100644
--- a/system/libraries/Pagination.php
+++ b/system/libraries/Pagination.php
@@ -36,39 +36,40 @@
  */
 class CI_Pagination {
 
-	public $base_url		= ''; // The page we are linking to
-	public $prefix			= ''; // A custom prefix added to the path.
-	public $suffix			= ''; // A custom suffix added to the path.
-	public $total_rows		= 0; // Total number of items (database results)
-	public $per_page		= 10; // Max number of items you want shown per page
-	public $num_links		= 2; // Number of "digit" links to show before/after the currently viewed page
-	public $cur_page		= 0; // The current page being viewed
-	public $use_page_numbers	= FALSE; // Use page number for segment instead of offset
-	public $first_link		= '‹ First';
-	public $next_link		= '>';
-	public $prev_link		= '<';
-	public $last_link		= 'Last ›';
-	public $uri_segment		= 3;
-	public $full_tag_open		= '';
-	public $full_tag_close		= '';
-	public $first_tag_open		= '';
-	public $first_tag_close		= ' ';
-	public $last_tag_open		= ' ';
-	public $last_tag_close		= '';
-	public $first_url		= ''; // Alternative URL for the First Page.
-	public $cur_tag_open		= ' ';
-	public $cur_tag_close		= '';
-	public $next_tag_open		= ' ';
-	public $next_tag_close		= ' ';
-	public $prev_tag_open		= ' ';
-	public $prev_tag_close		= '';
-	public $num_tag_open		= ' ';
-	public $num_tag_close		= '';
-	public $page_query_string	= FALSE;
-	public $query_string_segment 	= 'per_page';
-	public $display_pages		= TRUE;
-	protected $_attributes		= '';
-	protected $_link_types		= array();
+	protected $base_url				= ''; // The page we are linking to
+	protected $prefix				= ''; // A custom prefix added to the path.
+	protected $suffix				= ''; // A custom suffix added to the path.
+	protected $total_rows			= 0; // Total number of items (database results)
+	protected $per_page				= 10; // Max number of items you want shown per page
+	protected $num_links			= 2; // Number of "digit" links to show before/after the currently viewed page
+	protected $cur_page				= 0; // The current page being viewed
+	protected $use_page_numbers		= FALSE; // Use page number for segment instead of offset
+	protected $first_link			= '‹ First';
+	protected $next_link			= '>';
+	protected $prev_link			= '<';
+	protected $last_link			= 'Last ›';
+	protected $uri_segment			= 3;
+	protected $full_tag_open		= '';
+	protected $full_tag_close		= '';
+	protected $first_tag_open		= '';
+	protected $first_tag_close		= ' ';
+	protected $last_tag_open		= ' ';
+	protected $last_tag_close		= '';
+	protected $first_url			= ''; // Alternative URL for the First Page.
+	protected $cur_tag_open			= ' ';
+	protected $cur_tag_close		= '';
+	protected $next_tag_open		= ' ';
+	protected $next_tag_close		= ' ';
+	protected $prev_tag_open		= ' ';
+	protected $prev_tag_close		= '';
+	protected $num_tag_open			= ' ';
+	protected $num_tag_close		= '';
+	protected $page_query_string	= FALSE;
+	protected $query_string_segment 	= 'per_page';
+	protected $display_pages		= TRUE;
+	protected $_attributes			= '';
+	protected $_link_types			= array();
+	protected $reuse_query_string   = FALSE;
 
 	/**
 	 * Constructor
@@ -222,6 +223,23 @@ class CI_Pagination {
 
 		// And here we go...
 		$output = '';
+		$query_string = '';
+
+		// Add anything in the query string back to the links
+		// Note: Nothing to do with query_string_segment or any other query string options
+		if ($this->reuse_query_string === TRUE)
+		{
+			$get = $CI->input->get();
+			
+			// Unset the controll, method, old-school routing options
+			unset($get['c'], $get['m'], $get[$this->query_string_segment]);
+
+			// Put everything else onto the end
+			$query_string = (strpos($this->base_url, '&') !== FALSE ? '&' : '?') . http_build_query($get, '', '&');
+
+			// Add this after the suffix to put it into more links easily
+			$this->suffix .= $query_string;
+		}
 
 		// Render the "First" link
 		if ($this->first_link !== FALSE && $this->cur_page > ($this->num_links + 1))
@@ -232,19 +250,19 @@ class CI_Pagination {
 		}
 
 		// Render the "previous" link
-		if  ($this->prev_link !== FALSE && $this->cur_page !== 1)
+		if ($this->prev_link !== FALSE && $this->cur_page !== 1)
 		{
 			$i = ($this->use_page_numbers) ? $uri_page_number - 1 : $uri_page_number - $this->per_page;
 
 			if ($i === $base_page && $this->first_url !== '')
 			{
-				$output .= $this->prev_tag_open.'_attributes.$this->_attr_rel('prev').'>'
+				$output .= $this->prev_tag_open.'_attributes.$this->_attr_rel('prev').'>'
 					.$this->prev_link.''.$this->prev_tag_close;
 			}
 			else
 			{
-				$i = ($i === $base_page) ? '' : $this->prefix.$i.$this->suffix;
-				$output .= $this->prev_tag_open.'_attributes.$this->_attr_rel('prev').'>'
+				$append = ($i === $base_page) ? $query_string : $this->prefix.$i.$this->suffix;
+				$output .= $this->prev_tag_open.'_attributes.$this->_attr_rel('prev').'>'
 					.$this->prev_link.''.$this->prev_tag_close;
 			}
 
@@ -268,13 +286,13 @@ class CI_Pagination {
 						$n = ($i === $base_page) ? '' : $i;
 						if ($n === '' && ! empty($this->first_url))
 						{
-							$output .= $this->num_tag_open.'_attributes.$this->_attr_rel('start').'>'
+							$output .= $this->num_tag_open.'_attributes.$this->_attr_rel('start').'>'
 								.$loop.''.$this->num_tag_close;
 						}
 						else
 						{
-							$n = ($n === '') ? '' : $this->prefix.$n.$this->suffix;
-							$output .= $this->num_tag_open.'_attributes.$this->_attr_rel('start').'>'
+							$append = ($n === '') ? $query_string : $this->prefix.$n.$this->suffix;
+							$output .= $this->num_tag_open.'_attributes.$this->_attr_rel('start').'>'
 								.$loop.''.$this->num_tag_close;
 						}
 					}
-- 
cgit v1.2.3-24-g4f1b


From 7a744a8ba8f07ba1ec3a48f1d5de641b4025ce20 Mon Sep 17 00:00:00 2001
From: Phil Sturgeon 
Date: Sat, 23 Jun 2012 17:21:00 +0100
Subject: If there is no output then no need to try minifying it

---
 system/core/Output.php | 5 +++++
 1 file changed, 5 insertions(+)

(limited to 'system')

diff --git a/system/core/Output.php b/system/core/Output.php
index 4fdf18f14..5ec8c4bc0 100644
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -625,6 +625,11 @@ class CI_Output {
 
 				$size_before = strlen($output);
 
+				if ($size_before === 0)
+				{
+					return '';
+				}
+
 				// Find all the 
,,