TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 790
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 1
  • Guests: 650
  • Total: 651
  • tino

Status Control Panel

Started by brianjw, April 12, 2008, 09:18:12 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

brianjw

The following code will allow you to use some kind of status script in SMF. On my website, I use it to tell my users when the radio is offline, online, or having technical difficulties/maintenance.

Instructions
Copy and paste the following code into your custom action mod (if installed, if not then read next instructions after the code) and name it whatever you want. Edit the following code by following the helpful information of the comments in the script. You can also edit the code to allow the size to fit into a block.


// Change 16 to the user group id you want to be allowed to see it.
// Admins can always see the page.
// It is best to leave this otherwise your members can abuse it.
if (in_array(16, $user_info['groups']) || $context['user']['is_admin'])
   {
       global $scripturl;
global $modSettings;

// The main content. This is just mostly a little control panel I set up.
// The links are a main part of the code. Without it, the status url would have to be manually typed in.
echo ' <center><b>Control Panel</b></center><br>Welcome to the control panel for <!-- MEMBER GROUP NAME -->\'s only! Enjoy!<br><div class="titlebg">Status Settings</div><div class="windowbg">Please remember to set the status to it\'s correct setting.<br><br><a href="' . $scripturl . '?action=' . $_REQUEST['action'] . ';turnon">Switch Online</a><br><a href="' . $scripturl . '?action=' . $_REQUEST['action'] . ';turnoff">Switch Offline</a><br><a href="' . $scripturl . '?action=' . $_REQUEST['action'] . ';maint">Maintenance Mode</a></div><div class="titlebg">Status</div><div class="windowbg">';

// Dont mess with the little bit here unless you know what you are doing
if (isset($_REQUEST['turnon']))
updateSettings(array('status_active' => 1));
elseif (isset($_REQUEST['turnoff']))
updateSettings(array('status_active' => 0));
elseif (isset($_REQUEST['maint']))
        updateSettings(array('status_active' => 3));

// $modSettings['status_active'] would be the variable you can access as per the above code.
if (!empty($modSettings['status_active']))
{
if ($modSettings['status_active'] == 1)
// Edit the following with your images or take out the images and put text/html.
echo '<img src="online.gif"></div>';
else
echo '<img src="maintenance.gif"></div>';
}
else
       echo '<img src="offline.gif"></div>';
   }
else
   {
       echo 'You don\'t have access to use the Control Panel!';
   }

If you want to display the status anywhere on the forum area you can use the following code.


if (!empty($modSettings['radio_active']))
{
if ($modSettings['radio_active'] == 1)
echo '<img src="online.gif"></div>';
else
echo '<img src="maintenance.gif"></div>';
}
else
       echo '<img src="offline.gif"></div>';

also, if you want to include it on an external page outside of the forum, then use this code right after the <?php tag:

require("/path/to/SSI.php");


Instructions for people not using the Custom Actions mod or want to put it in a block
Take the attached files and upload them to their locations by using the following:
CP.php = /Sources/
CP.template.php = /Themes/default/
Then find the following code in index.php

'boardrecount' => array('Admin.php', 'AdminBoardRecount'),

Add After the code above:

'cp' => array('CP.php', 'Control Panel'),

You will need to modify the CP.template.php in order to customize the code the way you want to. You will then also be able to access this script through your website by using the ?action=cp command. This may be able to be used in a ?page= form from TinyPortal however, akabugeyes created it for actions.

Demo: No demo available. Only group 16 and admins can access my code.
Comments/Suggestions: Any comments and suggestions you may have would be greatly appreciated.

Credits: Made user friendly by brianjw. Created by akabugeyes.

stormlrd

brian where is the original release of this? Id like to look at it

brianjw

It's not really an "official release" but it's the following topic on SMF.
http://www.simplemachines.org/community/index.php?topic=197334.0

This website is proudly hosted on Crocweb Cloud Website Hosting.