I need to use a DIV tag, need a bit of help.

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   I need to use a DIV tag, need a bit of help.
tribaljohn
CZ Newbie
tribaljohn has been a member for over 19 year's 19 Year Member
Gender: Male
Status: Offline
Joined: Jan 29, 2005
0.00 posts per day
Posts: 6
Points: 902
   
Hi

I have some code for serverspy's mini-monitor, the user names on the game server keeps breaking the block, when a user has a name to long, I want to prevent this and thought I might use this piece of code

<div style="width:200;overflow:hidden">


here is the block code I am not sure where to place this DIV tag, or if there is another method for preventing blocks from breaking when user names are to long.

here is the code.

<?php

/************************************************************************/
/* PHP-NUKE: Web Portal System                                          */
/* ===========================                                          */
/*                                                                      */
/* Copyright (c) 2002 by Francisco Burzi                                */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/

if (eregi("block-Sample_Block.php",$_SERVER['PHP_SELF'])) {
    Header("Location: index.html");
    die();
}

ECHO "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"
codebase=\"http://download.macromedia.com/pub/shockwave/cabs/
flash/swflash.cab#version=6,0,29,0\" width=\"150\" height=\"100\"> "
. "<param name=\"movie\" value=\"http://www.somesite.com/small-logo.swf\"> "
. "<param name=quality value=high> "
. "<embed src=\"http://www.somesite.com/small-logo.swf\" quality=high
pluginspage=\"http://www.macromedia.com/shockwave/
download/index.cgi?P1_Prod_Version=ShockwaveFlash\"
type=\"application/x-shockwave-flash\"
width=\"150\" height=\"100\"></embed>"
. "</object>";


// NOTE: XML FEEDS ARE ONLY AVALIBLE TO EXCLUSIVE SUBSCRIBERS

// Simple script to print out a very basic server status page using the ServerSpy.net Monitor xml
//
// Use this code in a 'block' on php-Nuke websites. Should also work as a simple webpage for
// others that have php/xml support.
//
// Tutorial for XML/PHP http://www.webmasterbase.com/article/560
//
// This PHP script is developed as an example method of retrieving ServerSPy data via XML


ob_start();

$smonXML = 'http://www.serverspy.net/bin/smonXml.mpl?mid=#####';
// This is the XML URL of the servermonitor you wish to query.

// Scroll down to amend the HTML output to the style you wish to achieve.

$smon = Array();
global $smon;
$smon['PLAYERS'] = Array();
$smon['DETAILS'] = Array();
$smon['RULES'] = Array();
$smon['SERVERSPY'] = Array();

function startElement($parser, $tagName, $attrs) {
global $smon;
if ($tagName == 'PLAYERS'){
$smon['PLAYERS'][$attrs['NAME']] = Array();
$smon['PLAYERS'][$attrs['NAME']]['CONNECTED'] = $attrs['CONNECTED'];
$smon['PLAYERS'][$attrs['NAME']]['KILLS'] = $attrs['KILLS'];

} elseif ($tagName == 'SERVERSPY'){
$smon['SERVERSPY'][$attrs['NAME']] = $attrs['VALUE'];

} elseif ($tagName == 'RULES'){
$smon['RULES'][$attrs['NAME']] = $attrs['VALUE'];

} elseif ($tagName == 'DETAILS'){
$smon['DETAILS'][$attrs['NAME']] = $attrs['VALUE'];
}

// while (list ($key, $val) = each ($attrs)) {
// } // end while
}


function characterData($parser, $data) {
// no wrapped data used
}


function endElement($parser, $tagName) {
// no wrapped data used
}



// Create an XML parser
$xml_parser = xml_parser_create();

// Set the functions to handle opening and closing tags
xml_set_element_handler($xml_parser, "startElement", "endElement");

// Set the function to handle blocks of character data
xml_set_character_data_handler($xml_parser, "characterData");

// Open the XML file for reading
$fp = fopen($smonXML,"r") or die("Error reading ServerSpy.net XML feed. Either the URL is invalid or the XML feed has been updated.");

// Read the XML file 4KB at a time
while ($data = fread($fp, 4096))
// Parse each 4KB chunk with the XML parser created above
xml_parse($xml_parser, $data, feof($fp))
or die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
// Close the XML filef
fclose($fp);

// Free up memory used by the XML parser
xml_parser_free($xml_parser);


// Print EXAMPLE HTML layout.
// Below is just the sample code to get you started on creating your own layout.
// We're assuming that if you want to use the XML/PHP API solution that
// you'd rather tweak this output yourself. So we've kept it simple for you below.


print "<TABLE BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\" WIDTH=\"100%\">\n";
print "<TR><TD ALIGN=\"left\" WIDTH=\"100%\" VALIGN=\"top\" >\n";

// Details
print "<b><center>".$smon['DETAILS']['name']."</center></b>\n";
print "<b><center>".$smon['DETAILS']['ip']."</center></b><br>\n";
print "Map: ".$smon['DETAILS']['map']."<br>\n";
print "Players: <b>".$smon['DETAILS']['currentPlayers']."/".$smon['DETAILS']['maxPlayers']."</b><br>\n";




//while (list ($key, $val) = each ($smon['DETAILS'])){
// print "$val<br>\n";
//}
print "<br><br>";

// Players
//print "<b>Server Rules</b><br>\n";
//while (list ($key, $val) = each ($smon['RULES'])){
// print "$key = $val<br>\n";
//}
//print "<br><br>";

// Players
print "<b><center>-Players Online-</center></b><br>\n";
while (list ($key, $val) = each ($smon['PLAYERS'])){
print "$key<br>\n";
}

print "</TD></TR>";
print "</TABLE><BR>";


// end of file

$output = ob_get_contents();
ob_end_clean();
$content = $output;
$content .= "<center><A HREF=\"http://www.serverspy.net/site/serverranks/\"><img src=\"http://www.serverspy.net/bin/srank.mpl?a=IP ADDRESS:PORT\" width=\"120\" height=\"100\" border=\"0\"></A><br></center>";


// end of file


?>


It would be great if I could get this little annoyance fixed, it makes the whole site look warped when users on our game server have names over 14 characters.

Thanks


Back to top Reply with quote
#2   re: I need to use a DIV tag, need a bit of help.
grantb
CZ Newbie
grantb has been a member for over 19 year's 19 Year Member
Status: Offline
Joined: Oct 20, 2004
0.00 posts per day
Posts: 3
Points: 596
   
Not sure if you can insert a div tag inside a table tag but I would look at insterting that code before the players names list:
print "<b><center>-Players Online-</center></b><br>\n";
while (list ($key, $val) = each ($smon['PLAYERS'])){
print "$key<br>\n";
}
Possibly like:
print "<b><center>-Players Online-</center></b><br>\n";
while (list ($key, $val) = each ($smon['PLAYERS'])){
print "<div coding starts here>$key<br></div>\n";
}


Play around with it... sorry if it doesn't help much


Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum