我正在爲DJ(真的)做一個DJ面板。有時技術人員希望更新網站,因此需要有一個「維護腳本」來禁用整個網站。如果用戶是管理員禁用維護,如果用戶是正常的啓用維護
// The website is connected to DB and session is running
// if maintenance is enabled, throw the maintenance page in there and exit everything else
if($maintenance) {include("inc/maintenance.php");exit();}
// fetch the db info for the maintenance script
$statussen1 = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT * FROM status3 WHERE naam='onderhoud'");
$statussen = mysqli_fetch_array($statussen1);
// check if 'maintenance' row in the DB is set to AAN (means ON in Dutch)
if(htmlentities($statussen['status']) == 'AAN') {
// if maintenance is AAN, check if the user is an staff member
if(htmlentities($gegevens['rang']) == '1' // owner
OR htmlentities($gegevens['rang']) == '2' // head dj
OR htmlentities($gegevens['rang']) == '3' // assistant head dj
OR htmlentities($gegevens['rang']) == '4' // pilot dj
OR htmlentities($gegevens['rang']) == '5' // test dj
OR htmlentities($gegevens['rang']) == '6' // something else, not sure what 6 is called :P
OR htmlentities($gegevens['nieuwsreporter']) == '1'
OR htmlentities($gegevens['moderator']) == '1') {
// disable the maintenance script if staff
$maintenance = false;
} else {
// or if the user is no staff, enable the maintenance script
$maintenance = true;
}
}
我想我已經做得很好,試圖在腳本中解釋它是什麼,所以你會明白它更好一點。但是,當DB中的維護設置爲AAN時,該腳本給了我一個空白頁面。
我已經檢查了100次腳本,但找不到與問題相關的任何內容。是啊,我已經設置錯誤報告給E_ALL
,只給了我這個錯誤:7
Notice: Undefined variable: maintenance in xxx on line 7
線是
if($maintenance) {include("inc/maintenance.php");exit();}
但是,這不應該是導致空白頁的實際問題。我一定在某個地方做錯了事。請幫助我。
它看起來像你使用$維護之前,你正在設置它。 –
@ Cayde6嘿Cayde,我編輯了我的代碼,但沒有成功。 – Carl
你能否爲我們確定第7行?據我所知,第7行有一條評論,並且PHP將不得不超出fubar才能發生。謝謝。 – MonkeyZeus