Improve core/Common.php
diff --git a/system/core/Common.php b/system/core/Common.php
index f42bb64..abbe789 100644
--- a/system/core/Common.php
+++ b/system/core/Common.php
@@ -1,13 +1,13 @@
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 /**
  * CodeIgniter
  *
  * An open source application development framework for PHP 5.1.6 or newer
  *
  * NOTICE OF LICENSE
- * 
+ *
  * Licensed under the Open Software License version 3.0
- * 
+ *
  * This source file is subject to the Open Software License (OSL 3.0) that is
  * bundled with this package in the files license.txt / license.rst.  It is
  * also available through the world wide web at this URL:
@@ -73,10 +73,10 @@
  * Tests for file writability
  *
  * is_writable() returns TRUE on Windows servers when you really can't write to
- * the file, based on the read-only attribute.  is_writable() is also unreliable
+ * the file, based on the read-only attribute. is_writable() is also unreliable
  * on Unix servers if safe_mode is on.
  *
- * @access	private
+ * @access	public
  * @return	void
  */
 if ( ! function_exists('is_really_writable'))
@@ -84,17 +84,17 @@
 	function is_really_writable($file)
 	{
 		// If we're on a Unix server with safe_mode off we call is_writable
-		if (DIRECTORY_SEPARATOR == '/' AND @ini_get("safe_mode") == FALSE)
+		if (DIRECTORY_SEPARATOR === '/' AND @ini_get('safe_mode') == FALSE)
 		{
 			return is_writable($file);
 		}
 
-		// For windows servers and safe_mode "on" installations we'll actually
-		// write a file then read it.  Bah...
+		/* For Windows servers and safe_mode "on" installations we'll actually
+		 * write a file then read it. Bah...
+		 */
 		if (is_dir($file))
 		{
-			$file = rtrim($file, '/').'/'.md5(mt_rand(1,100).mt_rand(1,100));
-
+			$file = rtrim($file, '/\\').DIRECTORY_SEPARATOR.md5(mt_rand(1,100).mt_rand(1,100));
 			if (($fp = @fopen($file, FOPEN_WRITE_CREATE)) === FALSE)
 			{
 				return FALSE;
@@ -136,7 +136,7 @@
 	{
 		static $_classes = array();
 
-		// Does the class exist?  If so, we're done...
+		// Does the class exist? If so, we're done...
 		if (isset($_classes[$class]))
 		{
 			return $_classes[$class];
@@ -148,27 +148,27 @@
 		// then in the native system/libraries folder
 		foreach (array(APPPATH, BASEPATH) as $path)
 		{
-			if (file_exists($path.$directory.'/'.$class.'.php'))
+			if (file_exists($path.$directory.DIRECTORY_SEPARATOR.$class.'.php'))
 			{
 				$name = $prefix.$class;
 
 				if (class_exists($name) === FALSE)
 				{
-					require($path.$directory.'/'.$class.'.php');
+					require($path.$directory.DIRECTORY_SEPARATOR.$class.'.php');
 				}
 
 				break;
 			}
 		}
 
-		// Is the request a class extension?  If so we load it too
-		if (file_exists(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.'.php'))
+		// Is the request a class extension? If so we load it too
+		if (file_exists(APPPATH.$directory.DIRECTORY_SEPARATOR.config_item('subclass_prefix').$class.'.php'))
 		{
 			$name = config_item('subclass_prefix').$class;
 
 			if (class_exists($name) === FALSE)
 			{
-				require(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.'.php');
+				require(APPPATH.$directory.DIRECTORY_SEPARATOR.config_item('subclass_prefix').$class.'.php');
 			}
 		}
 
@@ -235,9 +235,9 @@
 		}
 
 		// Is the config file in the environment folder?
-		if ( ! defined('ENVIRONMENT') OR ! file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/config.php'))
+		if ( ! defined('ENVIRONMENT') OR ! file_exists($file_path = APPPATH.'config'.DIRECTORY_SEPARATOR.ENVIRONMENT.DIRECTORY_SEPARATOR.'config.php'))
 		{
-			$file_path = APPPATH.'config/config.php';
+			$file_path = APPPATH.'config'.DIRECTORY_SEPARATOR.'config.php';
 		}
 
 		// Fetch the config file
@@ -387,47 +387,47 @@
 	function set_status_header($code = 200, $text = '')
 	{
 		$stati = array(
-							200	=> 'OK',
-							201	=> 'Created',
-							202	=> 'Accepted',
-							203	=> 'Non-Authoritative Information',
-							204	=> 'No Content',
-							205	=> 'Reset Content',
-							206	=> 'Partial Content',
+					200	=> 'OK',
+					201	=> 'Created',
+					202	=> 'Accepted',
+					203	=> 'Non-Authoritative Information',
+					204	=> 'No Content',
+					205	=> 'Reset Content',
+					206	=> 'Partial Content',
 
-							300	=> 'Multiple Choices',
-							301	=> 'Moved Permanently',
-							302	=> 'Found',
-							304	=> 'Not Modified',
-							305	=> 'Use Proxy',
-							307	=> 'Temporary Redirect',
+					300	=> 'Multiple Choices',
+					301	=> 'Moved Permanently',
+					302	=> 'Found',
+					304	=> 'Not Modified',
+					305	=> 'Use Proxy',
+					307	=> 'Temporary Redirect',
 
-							400	=> 'Bad Request',
-							401	=> 'Unauthorized',
-							403	=> 'Forbidden',
-							404	=> 'Not Found',
-							405	=> 'Method Not Allowed',
-							406	=> 'Not Acceptable',
-							407	=> 'Proxy Authentication Required',
-							408	=> 'Request Timeout',
-							409	=> 'Conflict',
-							410	=> 'Gone',
-							411	=> 'Length Required',
-							412	=> 'Precondition Failed',
-							413	=> 'Request Entity Too Large',
-							414	=> 'Request-URI Too Long',
-							415	=> 'Unsupported Media Type',
-							416	=> 'Requested Range Not Satisfiable',
-							417	=> 'Expectation Failed',
-							422	=> 'Unprocessable Entity',
+					400	=> 'Bad Request',
+					401	=> 'Unauthorized',
+					403	=> 'Forbidden',
+					404	=> 'Not Found',
+					405	=> 'Method Not Allowed',
+					406	=> 'Not Acceptable',
+					407	=> 'Proxy Authentication Required',
+					408	=> 'Request Timeout',
+					409	=> 'Conflict',
+					410	=> 'Gone',
+					411	=> 'Length Required',
+					412	=> 'Precondition Failed',
+					413	=> 'Request Entity Too Large',
+					414	=> 'Request-URI Too Long',
+					415	=> 'Unsupported Media Type',
+					416	=> 'Requested Range Not Satisfiable',
+					417	=> 'Expectation Failed',
+					422	=> 'Unprocessable Entity',
 
-							500	=> 'Internal Server Error',
-							501	=> 'Not Implemented',
-							502	=> 'Bad Gateway',
-							503	=> 'Service Unavailable',
-							504	=> 'Gateway Timeout',
-							505	=> 'HTTP Version Not Supported'
-						);
+					500	=> 'Internal Server Error',
+					501	=> 'Not Implemented',
+					502	=> 'Bad Gateway',
+					503	=> 'Service Unavailable',
+					504	=> 'Gateway Timeout',
+					505	=> 'HTTP Version Not Supported'
+			);
 
 		if ($code == '' OR ! is_numeric($code))
 		{
@@ -441,12 +441,12 @@
 
 		if ($text == '')
 		{
-			show_error('No status text available.  Please check your status code number or supply your own message text.', 500);
+			show_error('No status text available. Please check your status code number or supply your own message text.', 500);
 		}
 
 		$server_protocol = (isset($_SERVER['SERVER_PROTOCOL'])) ? $_SERVER['SERVER_PROTOCOL'] : FALSE;
 
-		if (substr(php_sapi_name(), 0, 3) == 'cgi')
+		if (strpos(php_sapi_name(), 'cgi') === 0)
 		{
 			header("Status: {$code} {$text}", TRUE);
 		}
@@ -527,16 +527,15 @@
 	function remove_invisible_characters($str, $url_encoded = TRUE)
 	{
 		$non_displayables = array();
-		
-		// every control character except newline (dec 10)
-		// carriage return (dec 13), and horizontal tab (dec 09)
-		
+
+		// every control character except newline (dec 10),
+		// carriage return (dec 13) and horizontal tab (dec 09)
 		if ($url_encoded)
 		{
 			$non_displayables[] = '/%0[0-8bcef]/';	// url encoded 00-08, 11, 12, 14, 15
 			$non_displayables[] = '/%1[0-9a-f]/';	// url encoded 16-31
 		}
-		
+
 		$non_displayables[] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S';	// 00-08, 11, 12, 14-31, 127
 
 		do
@@ -574,4 +573,4 @@
 }
 
 /* End of file Common.php */
-/* Location: ./system/core/Common.php */
\ No newline at end of file
+/* Location: ./system/core/Common.php */