global_error_message.inc.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  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 = 'Powered by <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 = 'Warning: we have detected that your version of PHP is %s1. To install Chamilo, you need to have PHP %s2 or superior. If you don\'t know what we\'re talking about, please contact your hosting provider or your support team.
  25. %s3 Read the installation guide.';
  26. // Error code 2.
  27. $InstallationTitle = 'Chamilo has not been installed';
  28. $InstallationDescription = 'Click to INSTALL Chamilo %s or read the installation guide';
  29. // Error code 3.
  30. // Error code 4.
  31. // Error code 5.
  32. $DatabaseUnavailableTitle = 'Database is unavailable';
  33. $DatabaseUnavailableDescription = 'This portal is currently experiencing database issues. Please report this to the portal administrator. Thank you for your help.';
  34. // Error code 6.
  35. $AlreadyInstalledTitle = 'Chamilo has already been installed';
  36. $AlreadyInstalledDescription = 'The system has already been installed. In order to protect its contents, we have to prevent you from starting the installation script again. Please return to the main page.';
  37. // Unspecified error.
  38. $TechnicalIssuesTitle = 'Technical issues';
  39. $TechnicalIssuesDescription = 'This portal is currently experiencing technical issues. Please report this to the portal administrator. Thank you for your help.';
  40. if (is_int($global_error_code) && $global_error_code > 0) {
  41. if (class_exists('Template') && function_exists('api_get_configuration_value')) {
  42. $theme = Template::getThemeFallback().'/';
  43. } else {
  44. $theme = 'chamilo';
  45. }
  46. $root_rel = '';
  47. $installation_guide_url = $root_rel.'documentation/installation_guide.html';
  48. $css_path = 'app/Resources/public/css/';
  49. $css_web_assets = 'web/assets/';
  50. $css_web_path = 'web/css/';
  51. $themePath = $css_path.'themes/'.$theme.'/default.css';
  52. $bootstrap_file = $css_web_assets.'bootstrap/dist/css/bootstrap.min.css';
  53. $css_base_file = $css_web_path.'base.css';
  54. $css_list = array($bootstrap_file, $css_base_file, $themePath);
  55. $web_img = 'main/img';
  56. $root_sys = str_replace('\\', '/', realpath(__DIR__.'/../../')).'/';
  57. $css_def = '';
  58. foreach ($css_list as $cssFile) {
  59. $cssFile = $root_sys.$cssFile;
  60. if (file_exists($cssFile)) {
  61. $css_def .= file_get_contents($cssFile);
  62. }
  63. }
  64. $global_error_message = array();
  65. switch ($global_error_code) {
  66. case 1:
  67. $global_error_message['section'] = $SectionSystemRequirementsProblem;
  68. $global_error_message['title'] = $IncorrectPhpVersionTitle;
  69. $php_version = function_exists('phpversion') ? phpversion() : (defined('PHP_VERSION') ? PHP_VERSION : '');
  70. $php_version = empty($php_version) ? '' : '(PHP '.$php_version.')';
  71. $IncorrectPhpVersionDescription = str_replace('%s1', $php_version, $IncorrectPhpVersionDescription);
  72. $IncorrectPhpVersionDescription = str_replace('%s2', REQUIRED_PHP_VERSION, $IncorrectPhpVersionDescription);
  73. $pos = strpos($IncorrectPhpVersionDescription, '%s3');
  74. if ($pos !== false) {
  75. $length = strlen($IncorrectPhpVersionDescription);
  76. $read_installation_guide = substr($IncorrectPhpVersionDescription, $pos + 3, $length);
  77. $IncorrectPhpVersionDescription = substr($IncorrectPhpVersionDescription, 0, $pos);
  78. $IncorrectPhpVersionDescription .= '<br /><a class="btn btn-default" href="'.$installation_guide_url.'" target="_blank">'.$read_installation_guide.'</a>';
  79. }
  80. $global_error_message['description'] = $IncorrectPhpVersionDescription;
  81. break;
  82. case 2:
  83. require __DIR__.'/../install/version.php';
  84. $global_error_message['section'] = $SectionInstallation;
  85. $global_error_message['title'] = $InstallationTitle;
  86. if (($pos = strpos($InstallationDescription, '%s')) === false) {
  87. $InstallationDescription = 'Click to INSTALL Chamilo %s or read the installation guide';
  88. }
  89. $read_installation_guide = substr($InstallationDescription, $pos + 2);
  90. $versionStatus = (!empty($new_version_status) && $new_version_status != 'stable' ? $new_version_status : '');
  91. $InstallationDescription = '<form action="'.$root_rel.'main/install/index.php" method="get">
  92. <div class="row">
  93. <div class="col-md-12">
  94. <div class="office">
  95. <h2 class="title">Welcome to the Chamilo '.$new_version.' '.$new_version_status.' installation wizard</h2>
  96. <p class="text">Let\'s start hunting skills down with Chamilo LMS! This wizard will guide you through the Chamilo installation and configuration process.</p>
  97. <p class="download-info">
  98. <button class="btn btn-primary btn-lg" type="submit" value="INSTALL Chamilo" ><i class="fa fa-download" aria-hidden="true"></i> Install Chamilo</button>
  99. <a class="btn btn-success btn-lg" href="'.$installation_guide_url.'" target="_blank"> '.$read_installation_guide.'</a>
  100. </p>
  101. </div>
  102. </div>
  103. </div>
  104. </form>';
  105. $global_error_message['description'] = $InstallationDescription;
  106. break;
  107. case 3:
  108. case 4:
  109. case 5:
  110. $global_error_message['section'] = $SectionDatabaseUnavailable;
  111. $global_error_message['title'] = $DatabaseUnavailableTitle;
  112. $global_error_message['description'] = $DatabaseUnavailableDescription;
  113. break;
  114. case 6:
  115. $global_error_message['section'] = $SectionProtection;
  116. $global_error_message['title'] = $AlreadyInstalledTitle;
  117. $global_error_message['description'] = $AlreadyInstalledDescription;
  118. break;
  119. default:
  120. $global_error_message['section'] = $SectionTechnicalIssues;
  121. $global_error_message['title'] = $TechnicalIssuesTitle;
  122. $global_error_message['description'] = $TechnicalIssuesDescription;
  123. break;
  124. }
  125. $show_error_codes = defined('SHOW_ERROR_CODES') && SHOW_ERROR_CODES && $global_error_code != 2;
  126. $global_error_message['code'] = $show_error_codes ? $ErrorCode.': '.$global_error_code.'<br /><br />' : '';
  127. $global_error_message['details'] = empty($global_error_message['details']) ? '' : ($show_error_codes ? ': '.$global_error_message['details'] : $global_error_message['details']);
  128. $global_error_message['organisation'] = $Organisation;
  129. $global_error_message['powered_by'] = $PoweredBy;
  130. $global_error_message['encoding'] = 'UTF-8';
  131. $global_error_message['chamilo_logo'] = "data:image/png;base64,".base64_encode(file_get_contents($root_sys.'web/css/themes/'.$theme.'/images/header-logo.png'));
  132. $bgImage = base64_encode(file_get_contents("$root_sys/main/img/bg_space.png"));
  133. $bgMoon = base64_encode(file_get_contents("$root_sys/main/img/bg_moon_two.png"));
  134. $installChamiloImage = "data:image/png;base64,".base64_encode(file_get_contents("$root_sys/main/img/mr_chamilo_install.png"));
  135. $global_error_message['mr_chamilo'] = $installChamiloImage;
  136. if ($global_error_code == 2) {
  137. $global_error_message_page =
  138. <<<EOM
  139. <!DOCTYPE html>
  140. <html>
  141. <head>
  142. <title>{TITLE}</title>
  143. <meta charset="{ENCODING}" />
  144. <style>
  145. $css_def
  146. html, body {min-height:100%; padding:0; margin:0;}
  147. #wrapper {padding:0; position:absolute; top:0; bottom:0; left:0; right:0;}
  148. @keyframes animatedBackground {
  149. from { background-position: 0 0; }
  150. to { background-position: 100% 0; }
  151. }
  152. @-webkit-keyframes animatedBackground {
  153. from { background-position: 0 0; }
  154. to { background-position: 100% 0; }
  155. }
  156. @-ms-keyframes animatedBackground {
  157. from { background-position: 0 0; }
  158. to { background-position: 100% 0; }
  159. }
  160. @-moz-keyframes animatedBackground {
  161. from { background-position: 0 0; }
  162. to { background-position: 100% 0; }
  163. }
  164. .install-home{
  165. background-image: url("data:image/png;base64,$bgImage");
  166. background-position: 0px 0px;
  167. background-repeat: repeat;
  168. animation: animatedBackground 40s linear infinite;
  169. -ms-animation: animatedBackground 40s linear infinite;
  170. -moz-animation: animatedBackground 40s linear infinite;
  171. -webkit-animation: animatedBackground 40s linear infinite;
  172. }
  173. .installer{
  174. background: url("data:image/png;base64,$bgMoon") no-repeat center 390px;
  175. }
  176. .avatar{
  177. text-align: center;
  178. }
  179. .avatar .img-responsive{
  180. display: initial;
  181. }
  182. .office{
  183. padding: 10px 20px;
  184. //background-color: rgba(35, 40, 56, 0.7);
  185. background-color: rgba(0, 22, 48, 0.8);
  186. border-radius: 5px;
  187. }
  188. @media (max-width: 480px) {
  189. .download-info .btn-success{
  190. margin-top: 10px;
  191. }
  192. }
  193. </style>
  194. </head>
  195. <body class="install-home">
  196. <div id="wrapper" class="installer">
  197. <header>
  198. <div class="container">
  199. <div class="row">
  200. <div class="col-md-12">
  201. <div class="logo">
  202. <img src="{CHAMILO_LOGO}"/>
  203. </div>
  204. </div>
  205. </div>
  206. </div>
  207. </header>
  208. <div id="content">
  209. <div class="container">
  210. <div class="welcome-install">
  211. <div class="avatar">
  212. <img class="img-responsive" src="{MR_CHAMILO}"/>
  213. </div>
  214. <div class="row">
  215. <div class="col-md-12">
  216. <div class="office">
  217. <p class="text">
  218. {DESCRIPTION}
  219. {CODE}
  220. </p>
  221. </div>
  222. </div>
  223. </div>
  224. </div>
  225. </div>
  226. </div>
  227. </div>
  228. </body>
  229. </html>
  230. EOM;
  231. } else {
  232. $global_error_message_page =
  233. <<<EOM
  234. <!DOCTYPE html>
  235. <html>
  236. <head>
  237. <title>{TITLE}</title>
  238. <meta charset="{ENCODING}" />
  239. <style>
  240. $css_def
  241. </style>
  242. </head>
  243. <body>
  244. <div id="page-error">
  245. <div class="page-wrap">
  246. <header>
  247. <div class="container">
  248. <div class="row">
  249. <div class="col-md-12">
  250. <div class="logo">
  251. <img src="{CHAMILO_LOGO}"/>
  252. </div>
  253. </div>
  254. </div>
  255. </div>
  256. </header>
  257. <section id="menu-bar">
  258. <nav class="navbar navbar-default">
  259. <div class="container">
  260. <div class="navbar-header">
  261. <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#menuone" aria-expanded="false">
  262. <span class="sr-only">Toggle navigation</span>
  263. <span class="icon-bar"></span>
  264. <span class="icon-bar"></span>
  265. <span class="icon-bar"></span>
  266. </button>
  267. </div>
  268. <div class="collapse navbar-collapse" id="menuone">
  269. <ul class="nav navbar-nav">
  270. <li id="current" class="active tab-homepage"><a href="#" target="_self">Homepage</a></li>
  271. </ul>
  272. </div>
  273. </div>
  274. </nav>
  275. </section>
  276. <section id="content-error">
  277. <div class="container">
  278. <div class="panel panel-default">
  279. <div class="panel-body">
  280. <div class="alert alert-danger" role="alert">
  281. {DESCRIPTION}
  282. {CODE}
  283. </div>
  284. </div>
  285. </div>
  286. </div>
  287. </section>
  288. </div>
  289. </div>
  290. </body>
  291. </html>
  292. EOM;
  293. }
  294. foreach ($global_error_message as $key => $value) {
  295. $global_error_message_page = str_replace('{'.strtoupper($key).'}', $value, $global_error_message_page);
  296. }
  297. header('Content-Type: text/html; charset='.$global_error_message['encoding']);
  298. die($global_error_message_page);
  299. }