Need help with a raven shield query block Posted:
Wed Oct 21, 2009 8:28 pm |
|
|
|
|
|
Hey all,
I got another minor problem with a portion of my website content. Below I will include the complete original script that I used for this block. The problem I am having is the map image display.
So the way it's set up is as follows:
Determine what the map file name is and look in a certain directory for the matching file name in lower case characters and display that image in the allotted location. If the image is not found it displays nothing, well it displays the traditional broken image link box.
I have no concept of how to code this, but the way I want it to be literally is:
IF the picture for this map exists THEN display the matching image
ELSE display the image no-pic.jpg
Here is the code for the entire block:
| Code:
|
<?php
/* #####################################################################################
*
*
* project: RvS Block
* description: Display Server Details
*
* Copyright (C) 2009 FcUK_A
* A@fcuk.org.uk
*
* 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-rvs-server.php",$PHP_SELF)) {
Header("Location: index.php");
die();
}
$port="port";
$host="udp://xxx.xIx.xPx.xxx";
$message="REPORT";
$status=senddatab3($host,$port,$message);
//print "$status";
// Use List and split command to parse the data
list($ServerBeaconPort,
$BeaconPort,
$Cmap,
$name,//server name
$Ctype,
$MaxP,
$Locked,//works 0 or 1
$Ded,
$Plist,
$Ptime,
$Pping,
$Pkills,
$Numplay,
$Rounds,
$Rtime,
$Btime,
$bomb,
$sname,
$Iserver,//????
$Ffire,
$Balteam,
$TK,
$Ver,//server version
$Radar,//radar on/off
$Lid,
$Gid,
$Bport,
$Numter,
$AIback,
$Rmap,
$PlayerKills,
$Killedby,
$FPW,//1st person wep on/off
$mname,//game name ? ie rvs or asword
$pb,//pb on/off
$Maps,//mapl on rotation
$GType)= split ("¶", $status
, 36);
if ($Ctype == 'F1 3 ' || $Ctype == 'F1 5 ' || $Ctype == 'F1 7 ') // check if co-op
{ list($ServerBeaconPort, //
$BeaconPort,
$Cmap,
$name,
$Ctype,
$MaxP,
$Locked,
$Ded,
$Plist,
$Ptime,
$Pping,
$Pkills,
$Numplay,
$Rounds,
$Rtime,
$Btime,
$bomb,
$sname,
$Iserver,
$Ffire,
$Balteam,
$TK,
$Ver,
$Radar,
$Lid,
$Gid,
$Bport,
$Numter,
$AIback,
$Rmap,
$FPW,
$mname,
$pb,
$Killedby,
$PlayerKills,
$Maps,
$GType)= split ("¶", $status
, 36);
//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);
list($A,$PlayerKills) = split (" ", $PlayerKills, 2);
$gctype = preg_replace ($patterns, $replace, $Ctype);
$content .= "<B><img src=\"images/rvs-maps/" . strtolower(trim($Cmap)) . ".jpg\" hight=164 width=126 ></B>";
$content .= "<BR><b>$Cmap</b><BR>";
$content .= "<BR><b>Current Players </b><b>$Numplay/$MaxP</b><BR>";
$content .= "<div class=\"container\"><BR><div class=\"left\"><b>Players</b></div><div class=\"right\"><b>Kills</b></div></div><BR>";
$parray = split("/", $Plist);
$tarray = split("/", $Ptime);
$Parray = split("/", $Pping);
$karray = split("/", $Pkills);
$count = count($parray);
for ($i=0; $i<=$count; $i++)
{
$content .= "<div class=\"container\"><div class=\"left\">$parray[$i]</div><div class=\"right\">$karray[$i]</div></div>";
//print " $parray[$i] $tarray[$i] $Parray[$i] $karray[$i] <BR>"; // add appropiate HTML tags here
}
$content .= "<BR><a href=\"modules.php?name=ServerQuery\"><B>Detailed Server Info</B></a><BR>";
function senddatab3($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;
}
?>
|
And here is the section in that coding that refers specifically to the area in question:
| Code:
|
$content .= "<B><img src=\"images/rvs-maps/" . strtolower(trim($Cmap)) . ".jpg\" hight=164 width=126 ></B>";
$content .= "<BR><b>$Cmap</b><BR>";
|
Thanks in advance for any ideas you guys can offer.
|
|
|