global_error_message.inc.php 7.5 KB

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