vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Some help please? (https://vborg.vbsupport.ru/showthread.php?t=93854)

Dan 08-08-2005 10:53 AM

Some help please?
 
Because I'm such a n00b at php and everything I thought you very nice fellows *wink* Would be able to help me on a little thing I'm trying to do.

I have this bit of code which is used to tell the server status in a game I run on my box. Well atm it basically pings the server on every page refresh. While that is ok and stuff I'm planning on getting mroe traffic to this script in the near future and don't want to kill the box with that kind of traffic. So what I need to do is convert this script into something I can run with a crontab to generate an html doc which I then can include in the pages it will be on.

Current Script:
PHP Code:


<HTML>
  <META http-equiv="Refresh" content="30">
 <HEAD>
  <TITLE>ZeRO - Server Status</TITLE>
 </HEAD>
 <BODY bgcolor=#FFFFFF>
  <TABLE align="center" border=0 cellspacing=1 cellpadding=2 width="50%">
  <TR style="font-family:Arial;font-weight:x-small;color:#000000;">
   <TH>Server Name</TH><TH>Status</TH>
  </TR>

<?php
error_reporting
(0);

$Servers = array("Login Server"=>"IP:PORT","Char Server"=>"IP","Map Server"=>"IP:PORT","MySQL Server"=>"IP:PORT");

$cntr 1;

while(list(
$ServerName,$IPnPORT)=each($Servers)){
  list(
$IPAddress,$Port)=explode(":",$IPnPORT);
    if((
$cntr%2)== 1){
      
$bgColor "#EDEDED";
    }else{
      
$bgColor "#FFFFFF";
    }
if(
$fp=fsockopen($IPAddress,$Port,$error_no,$error_str,(float)0.5)) {
echo(
"
    <TR align=\"center\" bgcolor=
$bgColor style=\"color:#000000;font-size:small;font-family:Tahoma;\">
        <TD>
$ServerName </TD>
        <TH style=\"color:000000;background-color:66FF00\">ONLINE</TH>
    </TR>
"
);
fclose($fp);
}else{
echo(
"
    <TR align=\"center\" bgcolor=
$bgColor style=\"color:#000000;font-size:small;font-family:Tahoma;\">
        <TD>
$ServerName</TD>
        <TH style=\"color:000000;background-color:FF6633\">OFFLINE</TH>
    </TR>
"
);
}
   
$cntr++;
}
?>
</TABLE>
</BODY>
</HTML>

So anything would be helpful ;)

Edit: Nevermind with the help of the wonderful people on #vBorg *cough*Alan*cough*.... I was able to get this script working correctly how i wanted... thanks ;)


All times are GMT. The time now is 10:14 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01120 seconds
  • Memory Usage 1,720KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (1)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete