PageRenderTime 49ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/index.php

https://github.com/danboy/Croissierd
PHP | 124 lines | 72 code | 23 blank | 29 comment | 17 complexity | 6f3b73a6376c13beb1dfe9051f111749 MD5 | raw file
  1. <?php
  2. /*
  3. =====================================================
  4. ExpressionEngine - by EllisLab
  5. -----------------------------------------------------
  6. http://expressionengine.com/
  7. -----------------------------------------------------
  8. Copyright (c) 2003 - 2010 EllisLab, Inc.
  9. =====================================================
  10. THIS IS COPYRIGHTED SOFTWARE
  11. PLEASE READ THE LICENSE AGREEMENT
  12. http://expressionengine.com/docs/license.html
  13. =====================================================
  14. File: index.php
  15. -----------------------------------------------------
  16. Purpose: Triggers the main engine
  17. =====================================================
  18. */
  19. // URI Type
  20. // This variable allows you to hard-code the URI type.
  21. // For most servers, 0 works fine.
  22. // 0 = auto
  23. // 1 = path_info
  24. // 2 = query_string
  25. $qtype = 0;
  26. // DO NOT EDIT BELOW THIS!!!
  27. error_reporting(0);
  28. if (isset($_GET['URL']))
  29. {
  30. /** ---------------------------------
  31. /** URL Redirect for CP and Links in Comments
  32. /** ---------------------------------*/
  33. $_GET['URL'] = str_replace(array("\r", "\r\n", "\n", '%3A','%3a','%2F','%2f', '%0D', '%0A', '%09', 'document.cookie'),
  34. array('', '', '', ':', ':', '/', '/', '', '', '', ''),
  35. $_GET['URL']);
  36. if (substr($_GET['URL'], 0, 4) != "http" AND ! stristr($_GET['URL'], '://') AND substr($_GET['URL'], 0, 1) != '/')
  37. $_GET['URL'] = "http://".$_GET['URL'];
  38. $_GET['URL'] = str_replace( array('"', "'", ')', '(', ';', '}', '{', 'script%', 'script&', '&#40', '&#41', '<'),
  39. '',
  40. strip_tags($_GET['URL']));
  41. $host = ( ! isset($_SERVER['HTTP_HOST'])) ? '' : (substr($_SERVER['HTTP_HOST'],0,4) == 'www.' ? substr($_SERVER['HTTP_HOST'], 4) : $_SERVER['HTTP_HOST']);
  42. if ( ! isset($_SERVER['HTTP_REFERER']) OR ! stristr($_SERVER['HTTP_REFERER'], $host))
  43. {
  44. // Possibly not from our site, so we give the user the option
  45. // Of clicking the link or not
  46. $str = "<html>\n<head>\n<title>Redirect</title>\n</head>\n<body>".
  47. "<p>To proceed to the URL you have requested, click the link below:</p>".
  48. "<p><a href='".$_GET['URL']."'>".$_GET['URL']."</a></p>\n</body>\n</html>";
  49. }
  50. else
  51. {
  52. $str = "<html>\n<head>\n<title>Redirect</title>\n".
  53. '<meta http-equiv="refresh" content="0; URL='.$_GET['URL'].'">'.
  54. "\n</head>\n<body>\n</body>\n</html>";
  55. }
  56. exit($str);
  57. }
  58. $uri = '';
  59. $pathinfo = pathinfo(__FILE__);
  60. $ext = ( ! isset($pathinfo['extension'])) ? '.php' : '.'.$pathinfo['extension'];
  61. $self = ( ! isset($pathinfo['basename'])) ? 'index'.$ext : $pathinfo['basename'];
  62. $path_info = (isset($_SERVER['PATH_INFO'])) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO');
  63. $query_str = (isset($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING');
  64. switch ($qtype)
  65. {
  66. case 0 : $uri = ($path_info != '' AND $path_info != "/".$self) ? $path_info : $query_str;
  67. break;
  68. case 1 : $uri = $path_info;
  69. break;
  70. case 2 : $uri = $query_str;
  71. break;
  72. }
  73. unset($system_path);
  74. unset($config_file);
  75. unset($path_info);
  76. unset($query_str);
  77. unset($qstr);
  78. require 'path'.$ext;
  79. if ((isset($template_group) AND isset($template)) && $uri != '' && $uri != '/')
  80. {
  81. $template_group = '';
  82. $template = '';
  83. }
  84. if ( ! isset($system_path))
  85. {
  86. if (file_exists('install'.$ext))
  87. {
  88. header("location: install".$ext);
  89. exit;
  90. }
  91. else
  92. {
  93. exit("The system does not appear to be installed. Click <a href='install.php'>here</a> to install it.");
  94. }
  95. }
  96. $system_path = rtrim($system_path, '/').'/';
  97. if ( ! @include($system_path.'core/core.system'.$ext))
  98. {
  99. exit("The system path does not appear to be set correctly. Please open your path.php file and correct the path.");
  100. }
  101. ?>