phpBB.com     phpBB Academy     phpBB Modders     phpBB Weekly     ktuk     phpBB Hacks     Vlad Studio  

Custom Disable Board Page

Better customisation of the disabled board message

Not enough for a full proper MOD, but too useful not to share
Forum rules
Please read over our forum guidelines

Custom Disable Board Page

Postby kenny » 04 Jun 2009, 23:52

Requested by stokerpiller in this topic, this snippet allows a lot better customisation of the disabled board message that your users see when the board is disabled. It chages the trigger_error to a completely new page, styled using the ACP as a template.

You can easily changeany aspect of this page - all you need is some simple HTML/CSS knowledge. You can add any custom variables you wish also :)

Comment:
#
#-----[ OPEN ]------------------------------------------
#
includes/session.php
#
#-----[ FIND ]------------------------------------------
#
Code: Select all
    // Is board disabled and user not an admin or moderator?
          if ($config['board_disable'] && !defined('IN_LOGIN') && !$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_'))
          {
             header('HTTP/1.1 503 Service Unavailable');

             $message = (!empty($config['board_disable_msg'])) ? $config['board_disable_msg'] : 'BOARD_DISABLE';
             trigger_error($message);
          }  

#
#-----[ REPLACE WITH ]------------------------------------------
#
Code: Select all
            // Is board disabled and user not an admin or moderator?
            if ($config['board_disable'] && !defined('IN_LOGIN') && !$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_'))
            {
                header('HTTP/1.1 503 Service Unavailable');
                header('Status: 503 Service Unavailable');

                $template->assign_vars(array(
                    'MESSAGE'    => $config['board_disable_msg'],
                    'DISABLE'    => $this->lang['BOARD_DISABLE'])
                );

                page_header($this->lang['OFFLINE']);

                $template->set_filenames(array(
                       'body' => 'board_disable.html'
                ));

                page_footer();

                exit;
            }  

Now, you need to save the following code as board_disable.html and place it in your styles/STYLE_NAME/template/ folder.
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="{S_CONTENT_DIRECTION}" lang="{S_USER_LANG}" xml:lang="{S_USER_LANG}">
<head>

<meta http-equiv="content-type" content="text/html; charset={S_CONTENT_ENCODING}" />
<meta http-equiv="content-style-type" content="text/css" />
<meta http-equiv="content-language" content="{S_USER_LANG}" />
<meta http-equiv="imagetoolbar" content="no" />
<meta name="resource-type" content="document" />
<meta name="distribution" content="global" />
<meta name="copyright" content="2000, 2002, 2005, 2007 phpBB Group" />
<meta name="keywords" content="" />
<meta name="description" content="" />
{META}
<title>{SITENAME} &bull; {PAGE_TITLE}</title>
<link href="../adm/style/admin.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body id="errorpage">
<div id="wrap" style="margin-left:auto; margin-right:auto; width: 70%">
   <div id="page-header">
   </div>
   <div id="page-body">
      <div id="acp">
      <div class="panel">
         <span class="corners-top"><span></span></span>
         <div id="content">
            <h1>{L_INFORMATION}</h1>
            <h2>{DISABLE}</strong></h2>
            <br />
            <p>{MESSAGE}</p>
         </div>
         <span class="corners-bottom"><span></span></span>
      </div>
      </div>
   </div>
   <div id="page-footer">
      Powered by phpBB &copy; 2000, 2002, 2005, 2007 <a href="http://www.phpbb.com/">phpBB Group</a><br />
   </div>
</div>
</body>
</html>

You still disable the forum in the normal way - via the ACP - and add in your custom message. This message will display on the custom page. I've attached a screenshot below as an example.

NB*: If for any reason you disable the board and then log out, simply go to ucp.php?mode=login and you will be able to log back in and re-enable your forum ;) Alternatively, you could add a link to the login page in the HTML file.
disable.PNG
|| 6 String Romance || Myspace || phpBB.com || Need Freelance Work? ||
If you need one of my MODs installed - click here


Are you a musician in the Glasgow area interested in acoustic events? The ArtBox
User avatar
kenny kenny is probably rawking out on RockBand \m/
Project Leader
Project Leader
 
Posts: 647
Joined: 06 Jun 2008, 11:38
Location: Airdrie, UK

Donate to 6 String MODs
If you like any of the work that I do here, please consider donating.
click the image on the left for a list of some of the advantages of donating



Custom Disable Board Page

Postby kenny » 14 Jun 2009, 16:05

After updating a couple of other sites to phpBB 3.0.5 and having their boards disabled, I came up with a few more enhancements for this. Make the following changes (NB* these changes depend on you following the steps in the 1st post).
Comment:
#
#-----[ OPEN ]------------------------------------------
#
includes/functions.php
#
#-----[ FIND ]------------------------------------------
#
Code: Select all
        'S_BOARD_DISABLED'        => ($config['board_disable']) ? true : false, 

#
#-----[ AFTER, ADD ]------------------------------------------
#
Code: Select all
'S_INSTALL_FOLDER_EXISTS'        => (file_exists($phpbb_root_path . 'install')) ? true : false,     

#
#-----[ OPEN ]------------------------------------------
#
includes/session.php
#
#-----[ FIND ]------------------------------------------
#
Code: Select all
        // Disable board if the install/ directory is still present
        // For the brave development army we do not care about this, else we need to comment out this everytime we develop locally
        if (!defined('DEBUG_EXTRA') && !defined('ADMIN_START') && !defined('IN_INSTALL') && !defined('IN_LOGIN') && file_exists($phpbb_root_path . 'install'))
        {
            // Adjust the message slightly according to the permissions
            if ($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))
            {
                $message = 'REMOVE_INSTALL';
            }
            else
            
{
                $message = (!empty($config['board_disable_msg'])) ? $config['board_disable_msg'] : 'BOARD_DISABLE';
            }
            trigger_error($message);
        }

            // Is board disabled and user not an admin or moderator?
            if ($config['board_disable'] && !defined('IN_LOGIN') && !$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_'))
            { 

#
#-----[ REPLACE WITH ]------------------------------------------
#
Code: Select all
        /*
        // Disable board if the install/ directory is still present
        // For the brave development army we do not care about this, else we need to comment out this everytime we develop locally
        if (!defined('DEBUG_EXTRA') && !defined('ADMIN_START') && !defined('IN_INSTALL') && !defined('IN_LOGIN') && file_exists($phpbb_root_path . 'install'))
        {
            // Adjust the message slightly according to the permissions
            if ($auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))
            {
                $message = 'REMOVE_INSTALL';
            }
            else
            {
                $message = (!empty($config['board_disable_msg'])) ? $config['board_disable_msg'] : 'BOARD_DISABLE';
            }
            trigger_error($message);
        }
        */

        // Is board disabled and user not an admin or moderator?
        if ($config['board_disable'] && !defined('IN_LOGIN') && !$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_') && !defined('DEBUG_EXTRA') && !defined('ADMIN_START') && !defined('IN_INSTALL') || file_exists($phpbb_root_path . 'install') && !$auth->acl_gets('a_', 'm_') && !$auth->acl_getf_global('m_') && !defined('IN_LOGIN'))
        { 

#
#-----[ OPEN ]------------------------------------------
#
styles/YOUR_STYLE/template/overall_header.html
#
#-----[ FIND ]------------------------------------------
#
Code: Select all
       <!-- IF S_BOARD_DISABLED and S_USER_LOGGED_IN and (U_MCP or U_ACP) -->
      <div id="message" class="rules">
         <div class="inner"><span class="corners-top"><span></span></span>
            <strong>{L_INFORMATION}:</strong> {L_BOARD_DISABLED}
         <span class="corners-bottom"><span></span></span></div>
      </div>
      <!-- ENDIF -->

#
#-----[ REPLACE WITH ]------------------------------------------
#
Edit: I realise that there is hard coded text here, but you can easily add your own language file for it if you wish

Code: Select all
       <!-- IF S_BOARD_DISABLED and S_USER_LOGGED_IN and (U_MCP or U_ACP) or S_INSTALL_FOLDER_EXISTS -->
      <div id="message" class="rules">
         <div class="inner"><span class="corners-top"><span></span></span>
            <strong>{L_INFORMATION}:</strong> {L_BOARD_DISABLED}<!-- IF S_INSTALL_FOLDER_EXISTS and SCRIPT_NAME neq 'ucp' --> Install folder still resides on the server<!-- ENDIF -->
         <span class="corners-bottom"><span></span></span></div>
      </div>
      <!-- ENDIF -->
|| 6 String Romance || Myspace || phpBB.com || Need Freelance Work? ||
If you need one of my MODs installed - click here


Are you a musician in the Glasgow area interested in acoustic events? The ArtBox
User avatar
kenny kenny is probably rawking out on RockBand \m/
Project Leader
Project Leader
 
Posts: 647
Joined: 06 Jun 2008, 11:38
Location: Airdrie, UK

Custom Disable Board Page

Postby Dakin Quelia » 27 Jun 2010, 01:45

Hello,

I suggest this code for php:
Code: Select all
        // Is board disabled and user not an admin or moderator?
        
if ($config['board_disable'] && !defined('IN_LOGIN') && !$auth->acl_gets('a_''m_') && !$auth->acl_getf_global('m_'))
        {
            if (
$this->data['is_bot'])
            {
                
header('HTTP/1.1 503 Service Unavailable');
                
header('Status: 503 Service Unavailable');
            }

            
$template->assign_vars(array(
                
'MESSAGE'     => (!empty($config['board_disable_msg'])) ? $config['board_disable_msg'] : 'BOARD_DISABLE')
            );

            
page_header($this->lang['OFFLINE']);

            
$template->set_filenames(array(
                
'body' => 'board_disable.html'
            
));

            
page_footer();

            exit;
        }  

Template file:
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="{S_CONTENT_DIRECTION}" lang="{S_USER_LANG}" xml:lang="{S_USER_LANG}">
<head>

<meta http-equiv="content-type" content="text/html; charset={S_CONTENT_ENCODING}" />
<meta http-equiv="content-style-type" content="text/css" />
<meta http-equiv="content-language" content="{S_USER_LANG}" />
<meta http-equiv="imagetoolbar" content="no" />
<meta name="resource-type" content="document" />
<meta name="distribution" content="global" />
<meta name="copyright" content="2000, 2002, 2005, 2007 phpBB Group" />
<meta name="keywords" content="" />
<meta name="description" content="" />
{META}
<title>{SITENAME} &bull; {PAGE_TITLE}</title>
<link href="{ROOT_PATH}/adm/style/admin.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body id="errorpage">
   <div id="wrap" style="margin-left:auto; margin-right:auto; width: 100%">
      <div id="page-header"></div>
      <div id="page-body">
         <div id="acp">
            <div class="panel">
               <span class="corners-top"><span></span></span>
               <div id="content">
                  <h1>{L_INFORMATION}</h1>
                  <hr />
                  <p>{MESSAGE}</p>
               </div>
               <span class="corners-bottom"><span></span></span>
            </div>
         </div>
       </div>
       <div id="page-footer">
          Powered by phpBB &copy; 2000, 2002, 2005, 2007 <a href="http://www.phpbb.com/">phpBB Group</a><br />
       </div>
   </div>
</div>
</body>
</html>


See you soon,
User avatar
Dakin Quelia
Registered User
Registered User
 
Posts: 7
Joined: 04 Oct 2009, 20:45




Return to Code Snippets

Who is online

Google [Bot]


cron