Welcome Guest, Not a member yet? Register   Sign In
How to make a notice "Website closing to updating"?
#1

[eluser]cavi1905[/eluser]
Hello everybody!

I want to make a notice when user views my website. That notice is "Website closing to updating (example)"... and when anybody enter site then redirect to this notice.

How can I do? Help me, please! Thanks!
#2

[eluser]Dam1an[/eluser]
You could just replace index.php with the temporary message. Then once you've made your changes swap it back
#3

[eluser]Yorick Peterse[/eluser]
Dam's idea is bad, use this instead

Code:
<?php
// $online is a variable that contains the website's status, as retrieved from the db
If($online == 'online')
{
    // show the normal page
}
else
{
    $this->load->helper('url');

    // redirect
    redirect('someclass/function');
}
?>
#4

[eluser]bigtony[/eluser]
[quote author="Yorick Peterse" date="1250501146"]Dam's idea is bad, use this instead

Code:
<?php
// $online is a variable that contains the website's status, as retrieved from the db
If($online == 'online')
{
    // show the normal page
}
else
{
    $this->load->helper('url');

    // redirect
    redirect('someclass/function');
}
?>
[/quote]
Sorry Yorick, but your approach is far more complicated than it needs to be. Why on earth would you need to create a database table just to store a website status? Dam's idea of just replacing with a temporary index.php that gives a message is far better since it is simple to do, requires no database, and handles any incoming URL since in CI everything is automatically routed through it.

Simple example of index.php (maintenance version)
Code:
<?php
echo 'Website is undergoing maintenance and will be back shortly';
?>
A bit easier, don't you think?
#5

[eluser]davidbehler[/eluser]
Some people prefer to use the admin-panel to set wether a website is being updated or not and might want to allow access for only a specific user group if the website is undergoing maintenance.

For that you could create a pre_controller hook that does your check and either shows the maintenance message or does nothing.

Look here for more info on hooks: http://ellislab.com/codeigniter/user-gui...hooks.html
#6

[eluser]adamp1[/eluser]
My issue with having an option in the admin panel to set whether a site is being updated is If that update page is created by CI, what happens if someone visits and you are mid-updating the CI core files? Something may break, or show an error.

Best way is make an index.html script which uses no php, database connections.

This is the exact reason I removed this feature form BackendPro, it just is making it far to complex and leaving it open to the possibility of breaking.
#7

[eluser]jdfwarrior[/eluser]
Am I stupid or would it not be easy to just throw in a route to catch any request and pass it to an "updating" page? Then when your done, just remove the route? That way you dont modify your view or controllers at all?
#8

[eluser]davidbehler[/eluser]
adamp1s point is a good one, what if you update CI core files? That might cause your page to not work propably and therefor your routing or my hook would not work.
#9

[eluser]jdfwarrior[/eluser]
[quote author="waldmeister" date="1250544597"]adamp1s point is a good one, what if you update CI core files? That might cause your page to not work propably and therefor your routing or my hook would not work.[/quote]

I guess it really comes down to what kind of update is being performed as to whether a route or something would work.
#10

[eluser]jcavard[/eluser]
Make a switch that will create 'Index.htm' when turned on, and delete the same file when turned off.




Theme © iAndrew 2016 - Forum software by © MyBB