Welcome Guest, Not a member yet? Register   Sign In
How would you create a Site On/Off button?
#1

[eluser]NateL[/eluser]
I'm trying to figure out how I could close down a CodeIgniter powered site if I needed to perform maintenance.

Similar to what vBulletin does - only Admins can view the site, and you get a big bar at the top that says something like "Your forums are currently closed" - and viewers get a message stating that the forum is closed for a given reason.

Any ideas for a start?

Thanks Smile
#2

[eluser]umefarooq[/eluser]
if you are saving settings in database create a field offline to make site offline set value 1 for offline or 0 to online or as you want and also one field for message, now create a Public controller extends your MY_Contoller in that public controller's constructor check site is online or not if it offline then show error with your error message from data and extend your all public controllers with that your all public controller will be offline not the admin

Code:
class Public_controller extends MY_Controller{

function Publich_controller(){
  parent::MY_Controller();
   $row = $this->db->select('offline,message')->get('settings')->row();
  if($row->offline)
   show_error($row->message);

}

}

class welcome extends Publich_controller{

  function welcome(){
   parent::Publich_controller();
}

function index(){
  $this->load->view('welcome_messge');
}
}

always you public controller constructor will be called first and it will check the settings value
#3

[eluser]rogierb[/eluser]
Take a pick:

http://codeigniter.com/wiki/I_want_to_ta...intenance/
#4

[eluser]umefarooq[/eluser]
here is simple my controller

Code:
class MY_Controller extends Controller {
    //put your code here

    function MY_Controller(){
        parent::Controller();
    }

}

include(APPPATH . 'libraries/Public_Controller'.EXT);

sorry for misspell Public to Publich
#5

[eluser]NateL[/eluser]
rogierb, Thank you for the wiki link - I shoulda looked there first, i know. hahaha.

OK - This seems like the simplest of them all - because this site will be using a .htaccess file

# Uncomment line below to send site to offline status
#RewriteRule .* offline.php [L]

Is there any possible way to tell .htaccess to ignore my IP address so that I can bypass viewing that offline.php file?

I don't want to lock myself out of the site, because I'll need to test it to make sure everything is working before I open it back up to the public.
#6

[eluser]NateL[/eluser]
k I found this nifty link giving a bit of an explanation on .htaccess files and granting & allowing access.

I'm not sure if this will work - as I'm not really sure how to test it out.

If I put this in my .htaccess file, will it work?
Code:
RewriteRule .* offline.php [L]
order allow,deny
allow from 206.255.xxx.xxx

206.255.xxx.xxx being my IP address.




Theme © iAndrew 2016 - Forum software by © MyBB