View Single Post
  #1  
Old 08-08-2005, 09:53 AM
Dan's Avatar
Dan Dan is offline
 
Join Date: Dec 2002
Location: Titusville, Florida
Posts: 1,787
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01684 seconds
  • Memory Usage 1,781KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete