global_error_message.inc.php 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This script displays error messages on fatal errors during initialization.
  5. *
  6. * @package chamilo.include
  7. * @author Ivan Tcholakov, 2009-2010
  8. */
  9. $Organisation = '<a href="http://www.chamilo.org" target="_blank">Chamilo Homepage</a>';
  10. $PoweredBy = 'Platform <a href="http://www.chamilo.org" target="_blank"> Chamilo </a> &copy; '.date('Y');
  11. /**
  12. * English language variables.
  13. */
  14. // Sections.
  15. $SectionSystemRequirementsProblem = 'System requirements problem';
  16. $SectionInstallation = 'Installation';
  17. $SectionDatabaseUnavailable = 'Database is unavailable';
  18. $SectionTechnicalIssues = 'Technical issues';
  19. $SectionProtection = 'Protection measure';
  20. // Error code.
  21. $ErrorCode = 'Error code';
  22. // Error code 1.
  23. $IncorrectPhpVersionTitle = 'Incorrect PHP version';
  24. $IncorrectPhpVersionDescription = 'Scripting language version %s1 on your server is incorrect. PHP %s2 should be supported. %s3 Read the installation guide.';
  25. // Error code 2.
  26. $InstallationTitle = 'Chamilo has not been installed';
  27. $InstallationDescription = 'Click to INSTALL Chamilo %s or read the installation guide';
  28. // Error code 3.
  29. // Error code 4.
  30. // Error code 5.
  31. $DatabaseUnavailableTitle = 'Database is unavailable';
  32. $DatabaseUnavailableDescription = 'This portal is currently experiencing database issues. Please report this to the portal administrator. Thank you for your help.';
  33. // Error code 6.
  34. $AlreadyInstalledTitle = 'Chamilo has already been installed';
  35. $AlreadyInstalledDescription = 'The system has already been installed. In order its content to be protected you are not allowed to start the installation script again.';
  36. // Unspecified error.
  37. $TechnicalIssuesTitle = 'Technical issues';
  38. $TechnicalIssuesDescription = 'This portal is currently experiencing technical issues. Please report this to the portal administrator. Thank you for your help.';
  39. if (is_int($global_error_code) && $global_error_code > 0) {
  40. $theme = 'chamilo/';
  41. $css_path = 'main/css/';
  42. $css_file = $css_path.$theme.'default.css';
  43. $css_base_file = $css_path.'base.css';
  44. $css_base_chamilo_file = $css_path.'base_chamilo.css';
  45. $root_sys = str_replace('\\', '/', realpath(dirname(__FILE__).'/../../')).'/';
  46. $root_rel = htmlentities($_SERVER['PHP_SELF']);
  47. if (!empty($root_rel)) {
  48. $pos = strrpos($root_rel, '/');
  49. $root_rel = substr($root_rel, 0, $pos - strlen($root_rel) + 1);
  50. if (strpos($root_rel, '/main/') !== false) {
  51. $pos = 0;
  52. while (($test_pos = strpos(substr($root_rel, $pos, strlen($root_rel)), '/main/')) !== false) {
  53. $pos = $test_pos + 1;
  54. }
  55. $root_rel = substr($root_rel, 0, $pos);
  56. }
  57. elseif (strpos($root_rel, '/courses/') !== false) {
  58. $pos = 0;
  59. while (($test_pos = strpos(substr($root_rel, $pos, strlen($root_rel)), '/courses/')) !== false) {
  60. $pos = $test_pos + 1;
  61. }
  62. $root_rel = substr($root_rel, 0, $pos);
  63. }
  64. }
  65. $installation_guide_url = $root_rel.'documentation/installation_guide.html';
  66. $css_def = '';
  67. $css_base_chamilo_file = $root_sys.$css_base_chamilo_file;
  68. if (file_exists($css_base_chamilo_file)) {
  69. $css_def .= @file_get_contents($css_base_chamilo_file);
  70. }
  71. $css_base_file = $root_sys.$css_base_file;
  72. if (file_exists($css_base_file)) {
  73. $css_def .= @file_get_contents($css_base_file);
  74. }
  75. $css_file = $root_sys.$css_file;
  76. if (file_exists($css_file)) {
  77. $css_def .= @file_get_contents($css_file);
  78. }
  79. $css_def = str_replace('behavior:url("/main/css/csshover3.htc");', '', $css_def);
  80. $css_def = str_replace('main/', $root_rel.'main/', $css_def);
  81. $css_def = str_replace('images/', $root_rel.$css_path.$theme.'images/', $css_def);
  82. $css_def = str_replace('../../img/', $root_rel.'main/img/', $css_def);
  83. $global_error_message = array();
  84. switch ($global_error_code) {
  85. case 1:
  86. $global_error_message['section'] = $SectionSystemRequirementsProblem;
  87. $global_error_message['title'] = $IncorrectPhpVersionTitle;
  88. $php_version = function_exists('phpversion') ? phpversion() : (defined('PHP_VERSION') ? PHP_VERSION : '');
  89. $php_version = empty($php_version) ? '' : '(PHP '.$php_version.')';
  90. $IncorrectPhpVersionDescription = str_replace('%s1', $php_version, $IncorrectPhpVersionDescription);
  91. $IncorrectPhpVersionDescription = str_replace('%s2', REQUIRED_PHP_VERSION, $IncorrectPhpVersionDescription);
  92. $pos = strpos($IncorrectPhpVersionDescription, '%s3');
  93. if ($pos !== false) {
  94. $length = strlen($IncorrectPhpVersionDescription);
  95. $read_installation_guide = substr($IncorrectPhpVersionDescription, $pos + 3, $length);
  96. $IncorrectPhpVersionDescription = substr($IncorrectPhpVersionDescription, 0, $pos);
  97. $IncorrectPhpVersionDescription .= '<br /><a href="'.$installation_guide_url.'" target="_blank">'.$read_installation_guide.'</a>';
  98. }
  99. $global_error_message['description'] = $IncorrectPhpVersionDescription;
  100. break;
  101. case 2:
  102. $global_error_message['section'] = $SectionInstallation;
  103. $global_error_message['title'] = $InstallationTitle;
  104. if (($pos = strpos($InstallationDescription, '%s')) === false) {
  105. $InstallationDescription = 'Click to INSTALL Chamilo %s or read the installation guide';
  106. }
  107. $click_to_install = substr($InstallationDescription, 0, $pos);
  108. $read_installation_guide = substr($InstallationDescription, $pos + 2);
  109. $InstallationDescription = '<form action="'.$root_rel.'main/install/index.php" method="get">
  110. <button class="a_button blue" type="submit" value="&nbsp;&nbsp; '.$click_to_install.' &nbsp;&nbsp;" >
  111. '.$click_to_install.'</button>
  112. </form><br />
  113. <a href="'.$installation_guide_url.'" target="_blank">'.$read_installation_guide.'</a>';
  114. $global_error_message['description'] = $InstallationDescription;
  115. break;
  116. case 3:
  117. case 4:
  118. case 5:
  119. $global_error_message['section'] = $SectionDatabaseUnavailable;
  120. $global_error_message['title'] = $DatabaseUnavailableTitle;
  121. $global_error_message['description'] = $DatabaseUnavailableDescription;
  122. break;
  123. case 6:
  124. $global_error_message['section'] = $SectionProtection;
  125. $global_error_message['title'] = $AlreadyInstalledTitle;
  126. $global_error_message['description'] = $AlreadyInstalledDescription;
  127. break;
  128. default:
  129. $global_error_message['section'] = $SectionTechnicalIssues;
  130. $global_error_message['title'] = $TechnicalIssuesTitle;
  131. $global_error_message['description'] = $TechnicalIssuesDescription;
  132. break;
  133. }
  134. $show_error_codes = defined('SHOW_ERROR_CODES') && SHOW_ERROR_CODES && $global_error_code != 2;
  135. $global_error_message['code'] = $show_error_codes ? $ErrorCode.': '.$global_error_code.'<br /><br />' : '';
  136. $global_error_message['details'] = empty($global_error_message['details']) ? '' : ($show_error_codes ? ': '.$global_error_message['details'] : $global_error_message['details']);
  137. $global_error_message['organisation'] = $Organisation;
  138. $global_error_message['powered_by'] = $PoweredBy;
  139. $global_error_message['encoding'] = 'UTF-8';
  140. $global_error_message['css'] = $css_def;
  141. $global_error_message['chamilo_logo'] = $root_rel.$css_path.$theme.'images/header-logo.png';
  142. // {ORGANISATION} moved from the header
  143. $global_error_message_page =
  144. <<<EOM
  145. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  146. <html>
  147. <head>
  148. <title>{TITLE}</title>
  149. <meta http-equiv="Content-Type" content="text/html; charset={ENCODING}" />
  150. <style type="text/css" media="screen, projection">
  151. /*<![CDATA[*/
  152. {CSS}
  153. /*]]>*/
  154. </style>
  155. </head>
  156. <body>
  157. <div id="wrapper">
  158. <div id="header">
  159. <div id="header1">
  160. <div id="logo">
  161. <img vspace="10" hspace="10" alt="Chamilo" src="{CHAMILO_LOGO}">
  162. </div>
  163. </div>
  164. <div class="clear"></div>
  165. <div id="header2"></div>
  166. <div id="header3">
  167. <ul>
  168. <li id="current"><a href="#"><span id="tab_active">{SECTION}</span></a></li>
  169. </ul>
  170. <div style="clear: both;" class="clear"></div>
  171. </div>
  172. </div>
  173. <div class="clear"> </div>
  174. <div id="main">
  175. <div style="text-align: center;">
  176. {DESCRIPTION}
  177. {CODE}
  178. </div>
  179. </div>
  180. <div class="push"/></div>
  181. </div>
  182. <div id="footer">
  183. <div class="copyright">&nbsp;<br />{POWERED_BY}</div>
  184. &nbsp;
  185. </div>
  186. </body>
  187. </html>
  188. EOM;
  189. foreach ($global_error_message as $key => $value) {
  190. $global_error_message_page = str_replace('{'.strtoupper($key).'}', $value, $global_error_message_page);
  191. }
  192. header('Content-Type: text/html; charset='.$global_error_message['encoding']);
  193. die($global_error_message_page);
  194. }