converted to unix-style eol
[www-register-wizard.git] / codeigniter / CodeIgniter.php
index 27094d2..fa4bf77 100644 (file)
-<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');\r
-/**\r
- * CodeIgniter\r
- *\r
- * An open source application development framework for PHP 4.3.2 or newer\r
- *\r
- * @package            CodeIgniter\r
- * @author             ExpressionEngine Dev Team\r
- * @copyright  Copyright (c) 2008, EllisLab, Inc.\r
- * @license            http://codeigniter.com/user_guide/license.html\r
- * @link               http://codeigniter.com\r
- * @since              Version 1.0\r
- * @filesource\r
- */\r
-\r
-// ------------------------------------------------------------------------\r
-\r
-/**\r
- * System Front Controller\r
- *\r
- * Loads the base classes and executes the request.\r
- *\r
- * @package            CodeIgniter\r
- * @subpackage codeigniter\r
- * @category   Front-controller\r
- * @author             ExpressionEngine Dev Team\r
- * @link               http://codeigniter.com/user_guide/\r
- */\r
-\r
-// CI Version\r
-define('CI_VERSION',   '1.7.0');\r
-\r
-/*\r
- * ------------------------------------------------------\r
- *  Load the global functions\r
- * ------------------------------------------------------\r
- */\r
-require(BASEPATH.'codeigniter/Common'.EXT);\r
-\r
-/*\r
- * ------------------------------------------------------\r
- *  Load the compatibility override functions\r
- * ------------------------------------------------------\r
- */\r
-require(BASEPATH.'codeigniter/Compat'.EXT);\r
-\r
-/*\r
- * ------------------------------------------------------\r
- *  Load the framework constants\r
- * ------------------------------------------------------\r
- */\r
-require(APPPATH.'config/constants'.EXT);\r
-\r
-/*\r
- * ------------------------------------------------------\r
- *  Define a custom error handler so we can log PHP errors\r
- * ------------------------------------------------------\r
- */\r
-set_error_handler('_exception_handler');\r
-set_magic_quotes_runtime(0); // Kill magic quotes\r
-\r
-/*\r
- * ------------------------------------------------------\r
- *  Start the timer... tick tock tick tock...\r
- * ------------------------------------------------------\r
- */\r
-\r
-$BM =& load_class('Benchmark');\r
-$BM->mark('total_execution_time_start');\r
-$BM->mark('loading_time_base_classes_start');\r
-\r
-/*\r
- * ------------------------------------------------------\r
- *  Instantiate the hooks class\r
- * ------------------------------------------------------\r
- */\r
-\r
-$EXT =& load_class('Hooks');\r
-\r
-/*\r
- * ------------------------------------------------------\r
- *  Is there a "pre_system" hook?\r
- * ------------------------------------------------------\r
- */\r
-$EXT->_call_hook('pre_system');\r
-\r
-/*\r
- * ------------------------------------------------------\r
- *  Instantiate the base classes\r
- * ------------------------------------------------------\r
- */\r
-\r
-$CFG =& load_class('Config');\r
-$URI =& load_class('URI');\r
-$RTR =& load_class('Router');\r
-$OUT =& load_class('Output');\r
-\r
-/*\r
- * ------------------------------------------------------\r
- *     Is there a valid cache file?  If so, we're done...\r
- * ------------------------------------------------------\r
- */\r
-\r
-if ($EXT->_call_hook('cache_override') === FALSE)\r
-{\r
-       if ($OUT->_display_cache($CFG, $URI) == TRUE)\r
-       {\r
-               exit;\r
-       }\r
-}\r
-\r
-/*\r
- * ------------------------------------------------------\r
- *  Load the remaining base classes\r
- * ------------------------------------------------------\r
- */\r
-\r
-$IN            =& load_class('Input');\r
-$LANG  =& load_class('Language');\r
-\r
-/*\r
- * ------------------------------------------------------\r
- *  Load the app controller and local controller\r
- * ------------------------------------------------------\r
- *\r
- *  Note: Due to the poor object handling in PHP 4 we'll\r
- *  conditionally load different versions of the base\r
- *  class.  Retaining PHP 4 compatibility requires a bit of a hack.\r
- *\r
- *  Note: The Loader class needs to be included first\r
- *\r
- */\r
-if (floor(phpversion()) < 5)\r
-{\r
-       load_class('Loader', FALSE);\r
-       require(BASEPATH.'codeigniter/Base4'.EXT);\r
-}\r
-else\r
-{\r
-       require(BASEPATH.'codeigniter/Base5'.EXT);\r
-}\r
-\r
-// Load the base controller class\r
-load_class('Controller', FALSE);\r
-\r
-// Load the local application controller\r
-// Note: The Router class automatically validates the controller path.  If this include fails it \r
-// means that the default controller in the Routes.php file is not resolving to something valid.\r
-if ( ! file_exists(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT))\r
-{\r
-       show_error('Unable to load your default controller.  Please make sure the controller specified in your Routes.php file is valid.');\r
-}\r
-\r
-include(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT);\r
-\r
-// Set a mark point for benchmarking\r
-$BM->mark('loading_time_base_classes_end');\r
-\r
-\r
-/*\r
- * ------------------------------------------------------\r
- *  Security check\r
- * ------------------------------------------------------\r
- *\r
- *  None of the functions in the app controller or the\r
- *  loader class can be called via the URI, nor can\r
- *  controller functions that begin with an underscore\r
- */\r
-$class  = $RTR->fetch_class();\r
-$method = $RTR->fetch_method();\r
-\r
-if ( ! class_exists($class)\r
-       OR $method == 'controller'\r
-       OR strncmp($method, '_', 1) == 0\r
-       OR in_array(strtolower($method), array_map('strtolower', get_class_methods('Controller')))\r
-       )\r
-{\r
-       show_404("{$class}/{$method}");\r
-}\r
-\r
-/*\r
- * ------------------------------------------------------\r
- *  Is there a "pre_controller" hook?\r
- * ------------------------------------------------------\r
- */\r
-$EXT->_call_hook('pre_controller');\r
-\r
-/*\r
- * ------------------------------------------------------\r
- *  Instantiate the controller and call requested method\r
- * ------------------------------------------------------\r
- */\r
-\r
-// Mark a start point so we can benchmark the controller\r
-$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_start');\r
-\r
-$CI = new $class();\r
-\r
-// Is this a scaffolding request?\r
-if ($RTR->scaffolding_request === TRUE)\r
-{\r
-       if ($EXT->_call_hook('scaffolding_override') === FALSE)\r
-       {\r
-               $CI->_ci_scaffolding();\r
-       }\r
-}\r
-else\r
-{\r
-       /*\r
-        * ------------------------------------------------------\r
-        *  Is there a "post_controller_constructor" hook?\r
-        * ------------------------------------------------------\r
-        */\r
-       $EXT->_call_hook('post_controller_constructor');\r
-       \r
-       // Is there a "remap" function?\r
-       if (method_exists($CI, '_remap'))\r
-       {\r
-               $CI->_remap($method);\r
-       }\r
-       else\r
-       {\r
-               // is_callable() returns TRUE on some versions of PHP 5 for private and protected\r
-               // methods, so we'll use this workaround for consistent behavior\r
-               if ( ! in_array(strtolower($method), array_map('strtolower', get_class_methods($CI))))\r
-               {\r
-                       show_404("{$class}/{$method}");\r
-               }\r
-\r
-               // Call the requested method.\r
-               // Any URI segments present (besides the class/function) will be passed to the method for convenience\r
-               call_user_func_array(array(&$CI, $method), array_slice($URI->rsegments, 2));\r
-       }\r
-}\r
-\r
-// Mark a benchmark end point\r
-$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_end');\r
-\r
-/*\r
- * ------------------------------------------------------\r
- *  Is there a "post_controller" hook?\r
- * ------------------------------------------------------\r
- */\r
-$EXT->_call_hook('post_controller');\r
-\r
-/*\r
- * ------------------------------------------------------\r
- *  Send the final rendered output to the browser\r
- * ------------------------------------------------------\r
- */\r
-\r
-if ($EXT->_call_hook('display_override') === FALSE)\r
-{\r
-       $OUT->_display();\r
-}\r
-\r
-/*\r
- * ------------------------------------------------------\r
- *  Is there a "post_system" hook?\r
- * ------------------------------------------------------\r
- */\r
-$EXT->_call_hook('post_system');\r
-\r
-/*\r
- * ------------------------------------------------------\r
- *  Close the DB connection if one exists\r
- * ------------------------------------------------------\r
- */\r
-if (class_exists('CI_DB') AND isset($CI->db))\r
-{\r
-       $CI->db->close();\r
-}\r
-\r
-\r
-/* End of file CodeIgniter.php */\r
+<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 4.3.2 or newer
+ *
+ * @package            CodeIgniter
+ * @author             ExpressionEngine Dev Team
+ * @copyright  Copyright (c) 2008, EllisLab, Inc.
+ * @license            http://codeigniter.com/user_guide/license.html
+ * @link               http://codeigniter.com
+ * @since              Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * System Front Controller
+ *
+ * Loads the base classes and executes the request.
+ *
+ * @package            CodeIgniter
+ * @subpackage codeigniter
+ * @category   Front-controller
+ * @author             ExpressionEngine Dev Team
+ * @link               http://codeigniter.com/user_guide/
+ */
+
+// CI Version
+define('CI_VERSION',   '1.7.0');
+
+/*
+ * ------------------------------------------------------
+ *  Load the global functions
+ * ------------------------------------------------------
+ */
+require(BASEPATH.'codeigniter/Common'.EXT);
+
+/*
+ * ------------------------------------------------------
+ *  Load the compatibility override functions
+ * ------------------------------------------------------
+ */
+require(BASEPATH.'codeigniter/Compat'.EXT);
+
+/*
+ * ------------------------------------------------------
+ *  Load the framework constants
+ * ------------------------------------------------------
+ */
+require(APPPATH.'config/constants'.EXT);
+
+/*
+ * ------------------------------------------------------
+ *  Define a custom error handler so we can log PHP errors
+ * ------------------------------------------------------
+ */
+set_error_handler('_exception_handler');
+set_magic_quotes_runtime(0); // Kill magic quotes
+
+/*
+ * ------------------------------------------------------
+ *  Start the timer... tick tock tick tock...
+ * ------------------------------------------------------
+ */
+
+$BM =& load_class('Benchmark');
+$BM->mark('total_execution_time_start');
+$BM->mark('loading_time_base_classes_start');
+
+/*
+ * ------------------------------------------------------
+ *  Instantiate the hooks class
+ * ------------------------------------------------------
+ */
+
+$EXT =& load_class('Hooks');
+
+/*
+ * ------------------------------------------------------
+ *  Is there a "pre_system" hook?
+ * ------------------------------------------------------
+ */
+$EXT->_call_hook('pre_system');
+
+/*
+ * ------------------------------------------------------
+ *  Instantiate the base classes
+ * ------------------------------------------------------
+ */
+
+$CFG =& load_class('Config');
+$URI =& load_class('URI');
+$RTR =& load_class('Router');
+$OUT =& load_class('Output');
+
+/*
+ * ------------------------------------------------------
+ *     Is there a valid cache file?  If so, we're done...
+ * ------------------------------------------------------
+ */
+
+if ($EXT->_call_hook('cache_override') === FALSE)
+{
+       if ($OUT->_display_cache($CFG, $URI) == TRUE)
+       {
+               exit;
+       }
+}
+
+/*
+ * ------------------------------------------------------
+ *  Load the remaining base classes
+ * ------------------------------------------------------
+ */
+
+$IN            =& load_class('Input');
+$LANG  =& load_class('Language');
+
+/*
+ * ------------------------------------------------------
+ *  Load the app controller and local controller
+ * ------------------------------------------------------
+ *
+ *  Note: Due to the poor object handling in PHP 4 we'll
+ *  conditionally load different versions of the base
+ *  class.  Retaining PHP 4 compatibility requires a bit of a hack.
+ *
+ *  Note: The Loader class needs to be included first
+ *
+ */
+if (floor(phpversion()) < 5)
+{
+       load_class('Loader', FALSE);
+       require(BASEPATH.'codeigniter/Base4'.EXT);
+}
+else
+{
+       require(BASEPATH.'codeigniter/Base5'.EXT);
+}
+
+// Load the base controller class
+load_class('Controller', FALSE);
+
+// Load the local application controller
+// Note: The Router class automatically validates the controller path.  If this include fails it 
+// means that the default controller in the Routes.php file is not resolving to something valid.
+if ( ! file_exists(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT))
+{
+       show_error('Unable to load your default controller.  Please make sure the controller specified in your Routes.php file is valid.');
+}
+
+include(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT);
+
+// Set a mark point for benchmarking
+$BM->mark('loading_time_base_classes_end');
+
+
+/*
+ * ------------------------------------------------------
+ *  Security check
+ * ------------------------------------------------------
+ *
+ *  None of the functions in the app controller or the
+ *  loader class can be called via the URI, nor can
+ *  controller functions that begin with an underscore
+ */
+$class  = $RTR->fetch_class();
+$method = $RTR->fetch_method();
+
+if ( ! class_exists($class)
+       OR $method == 'controller'
+       OR strncmp($method, '_', 1) == 0
+       OR in_array(strtolower($method), array_map('strtolower', get_class_methods('Controller')))
+       )
+{
+       show_404("{$class}/{$method}");
+}
+
+/*
+ * ------------------------------------------------------
+ *  Is there a "pre_controller" hook?
+ * ------------------------------------------------------
+ */
+$EXT->_call_hook('pre_controller');
+
+/*
+ * ------------------------------------------------------
+ *  Instantiate the controller and call requested method
+ * ------------------------------------------------------
+ */
+
+// Mark a start point so we can benchmark the controller
+$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_start');
+
+$CI = new $class();
+
+// Is this a scaffolding request?
+if ($RTR->scaffolding_request === TRUE)
+{
+       if ($EXT->_call_hook('scaffolding_override') === FALSE)
+       {
+               $CI->_ci_scaffolding();
+       }
+}
+else
+{
+       /*
+        * ------------------------------------------------------
+        *  Is there a "post_controller_constructor" hook?
+        * ------------------------------------------------------
+        */
+       $EXT->_call_hook('post_controller_constructor');
+       
+       // Is there a "remap" function?
+       if (method_exists($CI, '_remap'))
+       {
+               $CI->_remap($method);
+       }
+       else
+       {
+               // is_callable() returns TRUE on some versions of PHP 5 for private and protected
+               // methods, so we'll use this workaround for consistent behavior
+               if ( ! in_array(strtolower($method), array_map('strtolower', get_class_methods($CI))))
+               {
+                       show_404("{$class}/{$method}");
+               }
+
+               // Call the requested method.
+               // Any URI segments present (besides the class/function) will be passed to the method for convenience
+               call_user_func_array(array(&$CI, $method), array_slice($URI->rsegments, 2));
+       }
+}
+
+// Mark a benchmark end point
+$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_end');
+
+/*
+ * ------------------------------------------------------
+ *  Is there a "post_controller" hook?
+ * ------------------------------------------------------
+ */
+$EXT->_call_hook('post_controller');
+
+/*
+ * ------------------------------------------------------
+ *  Send the final rendered output to the browser
+ * ------------------------------------------------------
+ */
+
+if ($EXT->_call_hook('display_override') === FALSE)
+{
+       $OUT->_display();
+}
+
+/*
+ * ------------------------------------------------------
+ *  Is there a "post_system" hook?
+ * ------------------------------------------------------
+ */
+$EXT->_call_hook('post_system');
+
+/*
+ * ------------------------------------------------------
+ *  Close the DB connection if one exists
+ * ------------------------------------------------------
+ */
+if (class_exists('CI_DB') AND isset($CI->db))
+{
+       $CI->db->close();
+}
+
+
+/* End of file CodeIgniter.php */
 /* Location: ./system/codeigniter/CodeIgniter.php */
\ No newline at end of file