The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Maintenance mode
#1
I just set my website to "offline", in the admin panel. But I was missing a maintenance mode. So I did the following;

added this to header.php

<pre>
Code:
if ($user->data()->username == 'admin'){ $maintenance_text=' your website is in maintance mode! ';}

else{
if ($settings->site_offline==1){

        $urlasstring = $_SERVER['REQUEST_URI'];
        $findme   = 'login.php';
        $pos = strpos($urlasstring, $findme);
                //not login.php
        if ($pos === false) {
            Redirect::to($us_url_root.'users/login.php');
        }
        else {$maintenance_text = ' Website is not available due to maintenance. ';}
}}
</pre>


in the login.php

I added an echo for the $maintenance_text.

I guess you should remove
Code:
if ($settings->site_offline==1){die("The site is currently offline.");}?>

from line 10 in the user_settings.php or you won't be able to see this as "admin"

Now I can work on my site, without the user using the website Smile
  Reply
#2
I love it! I need to do this!
  Reply
#3
heres what I've done,

create a new file maintenance.php, add the usual require init.php, header.php & navigation.php. add your html as you please and don't forget to require your footers aswell. anything is possible here including the use of fancy coming soon pages with countdowns etc.

in header.php

i changed:

<pre>
Code:
//dealing with if the user is logged in
if($user->isLoggedIn()){
    if (($settings->site_offline==1) && (!in_array($user->data()->id, $master_account)) && ($currentPage != 'login.php')){
        die("The site is currently offline.");
    }
}

//deal with non logged in users
if(!$user->isLoggedIn()){
    if (($settings->site_offline==1) && ($currentPage != 'login.php')){
        die("The site is currently offline.");
    }
}
//notifiy master_account that the site is offline
if($user->isLoggedIn()){
    if (($settings->site_offline==1) && (in_array($user->data()->id, $master_account)) && ($currentPage != 'login.php')){
        err("<br>The site is currently offline.");
    }
}
</pre>


and replaced with:

`//dealing with if the user is logged in
if($user->isLoggedIn() && !checkMenu(2,$user->data()->id)){
if (($settings->site_offline==1) && (!in_array($user->data()->id, $master_account)) && ($currentPage != 'login.php') && ($currentPage != 'maintenance.php')){
Redirect::to($us_url_root.'users/maintenance.php');
}
}

//deal with non logged in users
if(!$user->isLoggedIn() && !checkMenu(2,$user->data()->id)){
if (($settings->site_offline==1) && ($currentPage != 'login.php') && ($currentPage != 'maintenance.php')){
Redirect::to($us_url_root.'users/maintenance.php');
}
}

//notifiy master_account that the site is offline
if($user->isLoggedIn()){
if (($settings->site_offline==1) && (in_array($user->data()->id, $master_account)) && ($currentPage != 'login.php') && ($currentPage != 'maintenance.php')){

err("<br>The site is currently offline.");
}
}
'

now users are redirected to the maintenance page, you can go one further and have a link available only to admins to login

hope thats some use
  Reply
#4
This is similar to what I did, and it works quite well! It is much nicer to have a full page than it is to just die the page and say offline lol.

In addition, I also added a setting in the db called offlinemsg and modified my offline page to echo this. The admin_panels.php page has this added:

https://hastebin.com/owiciluhuj.php

https://hastebin.com/xutucowupu.xml

That way you can modify the offline message to whatever you want without manually coding everytime!
  Reply
#5
over looked that lol ? perfect.
  Reply
#6
Love this. I'm adding it to my list.
  Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)