소스 검색

Report a better error message when db is offline.

Laurent Destailleur 5 년 전
부모
커밋
019cbc501d
1개의 변경된 파일19개의 추가작업 그리고 0개의 파일을 삭제
  1. 19 0
      htdocs/master.inc.php

+ 19 - 0
htdocs/master.inc.php

@@ -121,6 +121,25 @@ if (! defined('NOREQUIREDB'))
 
 	if ($db->error)
 	{
+		// If we were into a website context
+		if (! defined('USEDOLIBARREDITOR') && ! defined('USEDOLIBARRSERVER') && ! empty($_SERVER['SCRIPT_FILENAME']) && (strpos($_SERVER['SCRIPT_FILENAME'], DOL_DATA_ROOT.'/website') === 0))
+		{
+			$sapi_type = php_sapi_name();
+			if (substr($sapi_type, 0, 3) != 'cgi') http_response_code(503);				// To tel search engine this is a temporary error
+			print '<div class="center" style="text-align: center; margin: 100px;">';
+			if (is_object($langs))
+			{
+				$langs->setDefaultLang('auto');
+				$langs->load("website");
+				print $langs->trans("SorryWebsiteIsCurrentlyOffLine");
+			}
+			else
+			{
+				print "SorryWebsiteIsCurrentlyOffLine";
+			}
+			print '</div>';
+			exit;
+		}
 		dol_print_error($db, "host=".$conf->db->host.", port=".$conf->db->port.", user=".$conf->db->user.", databasename=".$conf->db->name.", ".$db->error);
 		exit;
 	}