Welcome to Geeklog, Anonymous Monday, October 14 2024 @ 05:53 pm EDT

Geeklog Forums

need a block that is calling for info to have a time out feature


not sure

Anonymous
determined
I have a block for showing teamspeak on my site. Works great shows whos online when teamspeak is up. When teamspeak is down it lets the site load and the block shows offline. Now the block that is giving me a problem is for a raven shield server info block. It works great when the raven shield server is up. However if the raven shield server is down the block is calling for info that is not there and the main page of my site wont load. So I need help on how to make the block say offline like the teamspeak one does so my site can load and I dont have to activate and deactivate the block all the time. Can anyone help me. Thanks DmX_Raze
 Quote

Status: offline

DmX_Raze

Forum User
Newbie
Registered: 05/06/05
Posts: 5
Quote by not sure: I have a block for showing teamspeak on my site. Works great shows whos online when teamspeak is up. When teamspeak is down it lets the site load and the block shows offline. Now the block that is giving me a problem is for a raven shield server info block. It works great when the raven shield server is up. However if the raven shield server is down the block is calling for info that is not there and the main page of my site wont load. So I need help on how to make the block say offline like the teamspeak one does so my site can load and I dont have to activate and deactivate the block all the time. Can anyone help me. Thanks DmX_Raze



I am repling under my login now with the code of the block. The block is called block-serverquery.php this is the code i am posting from the blocks folder there is one other file related to this in the root directory called rvs-server.php if you need that also i can post it
 Quote

Status: offline

DmX_Raze

Forum User
Newbie
Registered: 05/06/05
Posts: 5
Ok i will post the file related to that in the root directory also thanks and i hope someone can help. The block works fine i just need it to say offline, or have a timer on it or I frame so if the server isnt up my website loads. Thanks for any help you can give. Here is the file from the root directory (rvs-server.php) that is tied in with block-serverquery.php
 Quote

Status: offline

DmX_Raze

Forum User
Newbie
Registered: 05/06/05
Posts: 5
By the way i have no knowledge of php so go easy on me lol. I hope someone can help thanks.
 Quote

Status: Banned

machinari

Forum User
Full Member
Registered: 03/22/04
Posts: 1512
It would sure be easier to read your code if you used the proper tags to enclose your code.. see the code button above the editor when you post.

otherwise much of your code gets stripped out and is then not legible.
 Quote

Status: offline

DmX_Raze

Forum User
Newbie
Registered: 05/06/05
Posts: 5
determined
Sry my bad Im new at all this i appoligize thanks for help with this I hope someone can help me. This is rvs-server.php in the root directory

Text Formatted Code
<?php
// set up server  info  ver .02
// written by chicago email Chicago@thescreamingeagle.com http://thescreamingeagle.com

$port="8777";
$host="udp://dmx.game-host.org";
$message="REPORT";
$status=senddata($host,$port,$message);

//print "$status";
// Use List and split command to parse the data
list($ServerBeaconPort,
      $BeaconPort,
      $Cmap,
      $name,
      $Ctype,
      $MaxP,
      $Locked,
      $Ded,
      $Maps,
      $GType,
      $Plist,
      $Ptime,
      $Pping,
      $Pkills,
      $Numplay,
      $Rounds,
      $Rtime,
      $Btime,
      $bomb,
      $Snames,
      $Iserver,
      $Ffire,
      $Balteam,
      $TK,
      $Ver,
      $Radar,
      $Lid,
      $Gid,
      $Bport,
      $Numter,
      $AIback,
      $Rmap,
      $FPW)= split ("¶", $status
, 33);
if ($Ctype == 'F1 3 ' ||  $Ctype == 'F1 5 ' || $Ctype == 'F1 7 ') // check if co-op
     { list($ServerBeaconPort,             //
     $BeaconPort,
     $Cmap,
     $name,
     $Ctype,
     $MaxP,
     $Locked,
     $Ded,
     $Maps,
     $GType,
     $Plist,
     $Ptime,
     $Pping,
     $Pkills,
     $Numplay,
     $Rounds,
     $Rtime,
     $Btime,
     $Snames,
     $Iserver,
     $Ffire,
     $Balteam,
     $TK,
     $Ver,
     $Radar,
     $Lid,
     $Gid,
     $Bport,
     $Numter,
     $AIback,
     $Rmap,
     $FPW)= split ("¶", $status
, 32);
//Print "co-op";
}
$patterns = array ("/14/", "/13/", "/8/","/15/","/16/","/3/","/5/","/7/");
$replace = array ("Team Survival", "Survival", "Hostage", "Bomb", "Pilot","Mission","Terrorist Hunt","Hostage Rescue");
list($A,$name) = split (" ", $name, 2);
list($A,$Cmap) = split (" ", $Cmap, 2);
list($A,$MaxP) = split (" ", $MaxP, 2);
list($A,$Numplay) = split (" ", $Numplay, 2);
list($A,$Plist) = split (" ", $Plist, 2);
list($A,$Maps) = split (" ", $Maps, 2);
list($A,$GType) = split (" ", $GType, 2);
list($A,$Ver) = split (" ", $Ver, 2);
list($A,$Ptime) = split (" ", $Ptime, 2);
list($A,$Pping) = split (" ", $Pping, 2);
list($A,$Pkills) = split (" ", $Pkills, 2);
list($A,$Ctype) = split (" ", $Ctype, 2);
$gctype = preg_replace ($patterns, $replace, $Ctype);
?>
<table border="3" cellpadding="0" cellspacing="0" width="50%" align="center">
<?
?>
<tr>
  <th align="center">
  <?= "Server Name" ?>
  </th>
  <th align="center">
  <?= "Server Version" ?>
  </th>
</tr>
<tr>
  <td align="center">
  <?= "$name" ?>
  </td>
  <td align="center">
  <?= "$Ver" ?>
  </td>
</tr>
<?
?>
</Table><BR>
<?
?>
<table border="2" cellpadding="0" cellspacing="0" width="50%" align="center">
<?
?>
<tr>
  <th align="center">
  <?= "Current Map" ?>
  </th>
  <th align="center">
  <?= "Current Game Type" ?>
  </th>
</tr>
<?
?>
<tr>
  <td align="center">
    <? echo "<img src=\"rvsslwebphp/mapimages/" . strtolower(trim($Cmap)) . ".jpg\" >" ?>
  </td>
<?
?>
  <td align="center">
  <?= "$Cmap <BR>" ?>
  <?= "$gctype" ?>
    </td>
</tr>
<?
?>
</Table><BR>
<?
//print "<BR>";
//print "<BR> Server name: $name";
//print "<BR>";
//print "<BR> Server version: $Ver";
//print "<BR>";
//print "<BR> Current map: $Cmap / $gctype";
//print "<BR>";
//print "<BR> Current Players: $Numplay / $MaxP";

//print "<BR> Player Time Ping kills"; // now split out the player list, times, pings and kills
?>
<table border="1" cellpadding="0" cellspacing="0" width="50%" align="center">
<?
?>
<tr>
  <th align="center">
  <?= "Current Players $Numplay/$MaxP" ?>
  </th>
</tr>
<tr>
  <th align="center">
  <?= "Player" ?>
  </th>
  <th align="center">
  <?= "Time" ?>
  </th>
  <th align="center">
  <?= "Ping" ?>
  </th>
  <th align="center">
  <?= "Kills" ?>
  </th>
</tr><br>
<?

$parray = split("/", $Plist);
$tarray = split("/", $Ptime);
$Parray = split("/", $Pping);
$karray = split("/", $Pkills);
$count = count($parray);
for ($i=0; $i<=$count; $i++)
{
?>
<tr>
  <td align="center">
  <?= $parray[$i] ?>
  </td>
  <td align="center">
  <?= $tarray[$i] ?>
  </td>
  <td align="center">
  <?= $Parray[$i] ?>
  <td align="center">
  <?= $karray[$i] ?>
  </td>
</tr>
<?
//print "   $parray[$i] $tarray[$i] $Parray[$i] $karray[$i]  <BR>"; // add appropiate HTML tags here
}
?>
</table>
<?
//print "<BR><tr> Map     Game Type</tr>";
$array = split("/", $Maps); // Split the maps out into a array
$garray = split("/", $GType);

$gtarray = preg_replace ($patterns, $replace, $garray);
$count = count($array);
?>
<table border="1" cellpadding="0" cellspacing="0" width="50%" align="center">
<?

?>
<tr>
  <th align="center">
  <?= "Map List" ?>
  </th>
</tr>
<tr>
  <th align="center">
  <?= "Map Name" ?>
  </th>
  <th align="center">
  <?= "Game Type" ?>
  </th>
</tr><br>
<?
for ($i=1; $i<$count; $i++)
{
?>
<tr>
  <td align="center">
  <?= $array[$i] ?>
  </td>
  <td align="center">
  <?= $gtarray[$i] ?>
  </td>
</tr>
<?
//print "<BR><tr>$array[$i]  $gtarray[$i]</tr> "; // add appropiate HTML tags here
}
?>
</Table>
<?

 function senddata($host,$port,$message) {

#takes in account servers that do not return EOF character
#send data to server and get back input

#function globals
$linenumber="0"; #amount of lines to get rid of before we give input
$lineamount="1"; #amount of lines to read after we give input

$fp = fsockopen("$host", $port, $errno, $errstr, 30);
if (!$fp) {
  echo "$errstr ($errno)";
}
else {
  for ($i = 1; $i < $linenumber+1; $i++) {
     fread ($fp,1);
     $bytes_left = socket_get_status($fp);
     if ($bytes_left > 0) { fread($fp, $bytes_left[unread_bytes]); }
  }
  fputs($fp, "$message");
  for ($i = 1; $i < $lineamount+1; $i++) {
     $status.=fread($fp,1);
     $bytes_left = socket_get_status($fp);
     if ($bytes_left > 0) { $status.=fread($fp, $bytes_left[unread_bytes]); }
  }
  fclose ($fp);
}

return $status;
}



?>
 
 Quote

Status: offline

DmX_Raze

Forum User
Newbie
Registered: 05/06/05
Posts: 5
This is the code for the BLOCK named block-serverquery.php


Text Formatted Code
<?php
/* #####################################################################################
 *
 * $Id: today_events.php,v 1.2 2002/06/23 15:07:46 oliver Exp $
 *
 * project:                     VWar
 * description:         displays todays events
 *
 * vwar for phpnuke $Id: block-today_events.php
 * tekbaron@hotmail.com
 *
 * Copyright (C) 2001 mabu (Oliver K.)
 * pm@ec-league.com
 *
 * Copyright Notes:
 * ----------------
 * - All Rights reserved
 * - All rights reserved to their proper authors.
 * - using the script(s) without the owners permission is prohibited
 *
 * NOTE:
 * This script can be used to include todays calendarevents in a menu on your site
 *
 * YOU CAN CHANGE HTML OUTPUT BELOW THIS LINE AS NEEDED !!!
 * #####################################################################################
 */
if (eregi("block-serverquery.php",$PHP_SELF)) {
        Header("Location: index.php");
        die();
}
 // set up server  info  ver .02
// written by chicago email Chicago@thescreamingeagle.com http://thescreamingeagle.com

$port="8777";
$host="udp://dmx.game-host.org";
$message="REPORT";
$status=senddatab2($host,$port,$message);

//print "$status";
// Use List and split command to parse the data
list($ServerBeaconPort,
      $BeaconPort,
      $Cmap,
      $name,
      $Ctype,
      $MaxP,
      $Maps,
      $GType,
      $Plist,
      $Ptime,
      $Pping,
      $Pkills,
      $Numplay,
      $Rounds,
      $Rtime,
      $Btime,
      $bomb,
      $Snames,
      $Iserver,
      $Ffire,
      $Balteam,
      $TK,
      $Ver,
      $Radar,
      $Lid,
      $Gid,
      $Bport,
      $Numter,
      $AIback,
      $Rmap,
      $FPW)= split ("¶", $status
, 33);
if ($Ctype == 'F1 3 ' ||  $Ctype == 'F1 5 ' || $Ctype == 'F1 7 ') // check if co-op
     { list($ServerBeaconPort,             //
     $BeaconPort,
     $Cmap,
     $name,
     $Ctype,
     $MaxP,
     $Locked,
     $Ded,
     $Maps,
     $GType,
     $Plist,
     $Ptime,
     $Pping,
     $Pkills,
     $Numplay,
     $Rounds,
     $Rtime,
     $Btime,
     $Snames,
     $Iserver,
     $Ffire,
     $Balteam,
     $TK,
     $Ver,
     $Radar,
     $Lid,
     $Gid,
     $Bport,
     $Numter,
     $AIback,
     $Rmap,
     $FPW)= split ("¶", $status
, 32);
//Print "co-op";
}
$patterns = array ("/14/", "/13/", "/8/","/15/","/16/","/3/","/5/","/7/");
$replace = array ("Team Survival", "Survival", "Hostage", "Bomb", "Pilot","Mission","Terrorist Hunt","Hostage Rescue");
list($A,$name) = split (" ", $name, 2);
list($A,$Cmap) = split (" ", $Cmap, 2);
list($A,$MaxP) = split (" ", $MaxP, 2);
list($A,$Numplay) = split (" ", $Numplay, 2);
list($A,$Plist) = split (" ", $Plist, 2);
list($A,$Maps) = split (" ", $Maps, 2);
list($A,$GType) = split (" ", $GType, 2);
list($A,$Ver) = split (" ", $Ver, 2);
list($A,$Ptime) = split (" ", $Ptime, 2);
list($A,$Pping) = split (" ", $Pping, 2);
list($A,$Pkills) = split (" ", $Pkills, 2);
list($A,$Ctype) = split (" ", $Ctype, 2);
$gctype = preg_replace ($patterns, $replace, $Ctype);
$content .= "$name<BR>";
$content .= "<BR>$Cmap<BR>";
$content .= "Team Survival<BR>";
$content .= "<img src=\"rvsslwebphp/mapimages/" . strtolower(trim($Cmap)) . ".jpg\" hight=164 width=126 >";
$content .= "<BR>Current Players $Numplay/$MaxP<BR>";
$content .= "<BR>Players<BR>";

$parray = split("/", $Plist);
$tarray = split("/", $Ptime);
$Parray = split("/", $Pping);
$karray = split("/", $Pkills);
$count = count($parray);
for ($i=0; $i<=$count; $i++)
{
$content .= "$parray[$i]<BR>";
//print "   $parray[$i] $tarray[$i] $Parray[$i] $karray[$i]  <BR>"; // add appropiate HTML tags here
}
$content .= "<BR><a href=\"rvsslwebphp/server.php?beaconport=".$port."&ip=".$host."\">Detailed Server Info</a><BR>";

 function senddatab2($host,$port,$message) {

#takes in account servers that do not return EOF character
#send data to server and get back input

#function globals
$linenumber="0"; #amount of lines to get rid of before we give input
$lineamount="1"; #amount of lines to read after we give input

$fp = fsockopen("$host", $port, $errno, $errstr, 30);
if (!$fp) {
  echo "Offline";
}
else {
  for ($i = 1; $i < $linenumber+1; $i++) {
     fread ($fp,1);
     $bytes_left = socket_get_status($fp);
     if ($bytes_left > 0) { fread($fp, $bytes_left[unread_bytes]); }
  }
  fputs($fp, "$message");
  for ($i = 1; $i < $lineamount+1; $i++) {
     $status.=fread($fp,1);
     $bytes_left = socket_get_status($fp);
     if ($bytes_left > 0) { $status.=fread($fp, $bytes_left[unread_bytes]); }
  }
  fclose ($fp);
}

return $status;
}



?>

 
 Quote

Status: Banned

machinari

Forum User
Full Member
Registered: 03/22/04
Posts: 1512
I've only looked at the senddatab2 function at the bottom of your code. I've changed the echo statement and put the "offline" into the $status variable.
I don't know how you are implementing this code, but that function should now report the server offline properly.
Text Formatted Code
 function senddatab2($host,$port,$message) {

#takes in account servers that do not return EOF character
#send data to server and get back input

#function globals
$linenumber="0"; #amount of lines to get rid of before we give input
$lineamount="1"; #amount of lines to read after we give input

$fp = fsockopen("$host", $port, $errno, $errstr, 30);
if (!$fp) {
  $status = "Offline";
}
else {
  for ($i = 1; $i < $linenumber+1; $i++) {
     fread ($fp,1);
     $bytes_left = socket_get_status($fp);
     if ($bytes_left > 0) { fread($fp, $bytes_left[unread_bytes]); }
  }
  fputs($fp, "$message");
  for ($i = 1; $i < $lineamount+1; $i++) {
     $status.=fread($fp,1);
     $bytes_left = socket_get_status($fp);
     if ($bytes_left > 0) { $status.=fread($fp, $bytes_left[unread_bytes]); }
  }
  fclose ($fp);
}

return $status;
}

 
 Quote

Raze

Anonymous
thanks alot i think its working fine now if the server is down the main page loads on the site fine. It dosent say offline but the site now loads. Thanks alot I appreciate it. My site is here
you can see the block here in action if you like but thanks so much i appreciate it.
 Quote

All times are EDT. The time is now 05:53 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content