CakePHP "down for maintenance" page

Posted by user1852176 on Stack Overflow See other posts from Stack Overflow or by user1852176
Published on 2013-10-20T03:50:58Z Indexed on 2013/10/20 3:53 UTC
Read the original article Hit count: 101

Filed under:
|

I found this post about how to create a "down for maintenance" page but I'm having some trouble getting it to work properly.

define('MAINTENANCE', 1); 
if(MAINTENANCE > 0){
    require('maintenance.php'); die(); 
}

When I place this code in /webroot.index.php it works. However, the answer suggests adding an IP address check so that if it's down, I would still be able to view it and make sure any updates went through smoothly.

So, it would look something like this

define('MAINTENANCE', 0); 
if(MAINTENANCE > 0 && $_SERVER['REMOTE_ADDR'] !='188.YOUR.IP.HERE'){
    require('maintenance.php'); die(); 
}

The issue is, my IP address will NOT be detected by cake. I've typed echo $_SERVER['REMOTE_ADDR'] and it just shows ::1. I also tried using my user_id but I got the following error Class 'AuthComponent' not found in....

I tried /index.php and /App/index.php but the maintenance page wasn't triggered and the page loads normally.

© Stack Overflow or respective owner

Related posts about php

Related posts about cakephp