Bootstrap Help

Matthewza

Posting Freak
Apr 20, 2012
777
77
How did FabboRP make it so when the server goes offline it changes the color of the button. I have Bootstrap already as you can see if you go on my status page it doesn't look really good. Could anybody please help me.

vwxuro.png


Thanks,
Matthew
 

Matthewza

Posting Freak
Apr 20, 2012
777
77
Lol I found something similar

And It says if its up and running
Code:
<?
function isSiteAvailable($url)
  {
 
if(!filter_var($url, FILTER_VALIDATE_URL))
              {
                      return 'URL provided wasn\'t valid';
              }
 
              //make the connection with curl
              $cl = curl_init($url);
              curl_setopt($cl,CURLOPT_CONNECTTIMEOUT,10);
              curl_setopt($cl,CURLOPT_HEADER,true);
              curl_setopt($cl,CURLOPT_NOBODY,true);
              curl_setopt($cl,CURLOPT_RETURNTRANSFER,true);
 
              //get response
              $response = curl_exec($cl);
 
              curl_close($cl);
 
              if ($response) return 'Site seems to be up and running!';
 
              return 'Oops nothing found, the site is either offline or the domain doesn\'t exist';
      }
 
 
    // check if site exists / is up
    if($_GET['url']){
 
      $response = isSiteAvailable($_GET['url']);
      $message = '<div class="response">'.$response.'</div>';
    }
    ?>
<?php echo $message; ?>


I think I got it, But I have a problem How do I make it so it'll say like example Site Online

Here's my code:

if ($sock != @fsockopen($ip, $port, $num, $error, 5))
echo '<span class="btn btn-danger">Offline</span>';
else{
echo '<span class="btn btn-success"">Online</span>';
} ?>
 

Sysode

Front-End Developer
Dec 11, 2012
1,673
848
I think I got it, But I have a problem How do I make it so it'll say like example Site Online

Here's my code:
Try using what I have added, not sure if it because of the use of buttons you are using. Let me know what that looks like?


PHP:
f ($sock != @fsockopen($ip, $port, $num, $error, 5))
echo '<span class="label label-important">Offline</span>';
else{
echo '<span class="label label-success">Online</span>';
} ?>
 

Adil

DevBest CEO
May 28, 2011
1,278
716
Using a PHP solution is a bit heavy, imo.
You could wire up a basic node backend using socket.io, or just use plain old websockets to listen for any events on the server and apply them on the client.
 

Divide

Member
Jul 13, 2013
45
11
Even easier is to find when the serverstatus time stamp was last updated, If it's longer than 3 minutes then the emulator is offline (or not been updated correctly) - You could also create an automatic maintenance page using this system (I use this in some of my projects)
 

Matthewza

Posting Freak
Apr 20, 2012
777
77
Even easier is to find when the serverstatus time stamp was last updated, If it's longer than 3 minutes then the emulator is offline (or not been updated correctly) - You could also create an automatic maintenance page using this system (I use this in some of my projects)


That's a good idea! :confused:
 

Users who are viewing this thread

Top