Guest User

Untitled

a guest
Oct 23rd, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.38 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. /**
  5. *Check if environment is development
  6. */
  7.  
  8. function setReporting()
  9. {
  10. if (DEVELOPMENT_ENVIRONMENT == true)
  11. {
  12. error_reporting(E_ALL);
  13. ini_set('display_errors','On');
  14. }
  15. else
  16. {
  17. error_reporting(E_ALL);
  18. ini_set('display_errors','Off');
  19. ini_set('log_errors', 'On');
  20. ini_set('error_log', ROOT.DS.'tmp'.DS.'logs'.DS.'error.log');
  21. }
  22. }
  23.  
  24.  
  25.  
  26. /**
  27. * Check for Magic Quotes and remove them
  28. */
  29. function stripSlashesDeep($value)
  30. {
  31. $value = is_array($value) ? array_map('stripSlashesDeep', $value) : stripslashes($value);
  32. return $value;
  33. }
  34.  
  35. function removeMagicQuotes()
  36. {
  37. if ( get_magic_quotes_gpc() )
  38. {
  39. $_GET = stripSlashesDeep($_GET );
  40. $_POST = stripSlashesDeep($_POST );
  41. $_COOKIE = stripSlashesDeep($_COOKIE);
  42. }
  43. }
  44.  
  45.  
  46. /**
  47. * This function loads the appropriate
  48. * controller and executes the requested
  49. * function on that controller
  50. */
  51. function callHook() {
  52.  
  53. global $controllerAction;
  54.  
  55. if(!empty($controllerAction))
  56. {
  57. $urlArray = array();
  58. $urlArray = explode("/",$controllerAction);
  59.  
  60. $controller = $urlArray[0];
  61. array_shift($urlArray);
  62. $action = isset($urlArray[0])?$urlArray[0]:'';
  63.  
  64. array_shift($urlArray);
  65. $queryString = $urlArray;
  66. }
  67. else
  68. {
  69. $controller = "portal";
  70. $action = "home";
  71. $queryString = array();
  72. }
  73.  
  74. $controllerName = $controller;
  75. $controller = ucfirst($controller).'Controller';
  76.  
  77.  
  78. $dispatch = new $controller($controllerName,$action);
  79.  
  80. if ((int)method_exists($controller, $action))
  81. {
  82. call_user_func_array(array($dispatch,$action),$queryString);
  83. }
  84. }
  85.  
  86.  
  87.  
  88.  
  89. /**
  90. * This function autoloads the controller
  91. * for the call hook function
  92. */
  93. function __autoload($className)
  94. {
  95.  
  96. if (file_exists(ROOT . DS . 'core' . DS . strtolower($className) . '.class.php'))
  97. {
  98. require_once(ROOT . DS . 'core' . DS . strtolower($className) . '.class.php');
  99. }
  100. else if (file_exists(ROOT . DS . 'application' . DS . 'controllers' . DS . strtolower($className) . '.php'))
  101. {
  102. require_once(ROOT . DS . 'application' . DS . 'controllers' . DS . strtolower($className) . '.php');
  103. }
  104. else if (file_exists(ROOT . DS . 'application' . DS . 'models' . DS . strtolower($className) . '.php'))
  105. {
  106. require_once(ROOT . DS . 'application' . DS . 'models' . DS . strtolower($className) . '.php');
  107. }
  108. }
  109.  
  110.  
  111. setReporting();
  112. removeMagicQuotes();
  113. callHook();
Add Comment
Please, Sign In to add comment