1
johnwyp
Block problems
  • 2003/11/21 15:59

  • johnwyp

  • Just popping in

  • Posts: 10

  • Since: 2003/3/20


I have the code that I've put in an HTML block that works fantastic in preview, but prints the code on the actual page. Any ideas what I can do to fix that?

<?php
$smonXML 
'http://www.serverspy.net/bin/smonXml.mpl?mid=32285';
$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($fp4096))    
// Parse each 4KB chunk with the XML parser created above
xml_parse($xml_parser$datafeof($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);

// Details
print "<b>".$smon['DETAILS']['name']." Server Details</b><br>n";
while (list (
$key$val) = each ($smon['DETAILS'])){
    print 
"$key = $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>";

// Rules
print "<b>Players</b> (player-kills-connected/ping)<br>n";
while (list (
$key$val) = each ($smon['PLAYERS'])){
    print 
"$key  - ".$smon['PLAYERS'][$key]['KILLS']." - ".$smon['PLAYERS'][$key]['CONNECTED']."<br>n";
}

// end of file

?>


I just looked at the code block and the URL is showing up as a link, but rest assured it is NOT like that in the actual code block.

2
robekras
Re: Block problems
  • 2003/11/21 16:06

  • robekras

  • Documentation Writer

  • Posts: 187

  • Since: 2002/12/10


Remove the <?php from the beginning and the ?> from the end
and save the block as a PHP-script.

3
johnwyp
Re: Block problems
  • 2003/11/21 17:55

  • johnwyp

  • Just popping in

  • Posts: 10

  • Since: 2003/3/20


Awesome! That worked. Next issue....

<SCRIPT LANGUAGE="JavaScript" SRC="http://share1.serverspy.net/cgi-bin/monitor.js?mid=32285">
</
SCRIPT>


That is going to bring up a graphic that, again, works PERFECTLY in preview, but displays completely squished on the site.

Ideas?

Login

Who's Online

194 user(s) are online (112 user(s) are browsing Support Forums)


Members: 0


Guests: 194


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Jun 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits