Jump to content

pictures wont load


salvador2001

Recommended Posts

Hello,

 

I am using a server status script from GameQ and it works fine.

But i want to add some map pictures and i cant get it to work.

 

I have added a little script into it, but somehow it wont work at all.

I do hope someone can help me out on this, my knowledge of PHP is poor at this time.

 

Here is the code, i have marked up the inserted part:

 

 <?php
error_reporting(E_ALL);
require_once 'GameQ.php';

// Define your servers,
// see list.php for all supported games and identifiers.
$servers = array(
    ' ' => array('bf2', '69.12.98.120', 29900),

);



// Call the class, and add your servers.
$gq = new GameQ();
$gq->addServers($servers);

    
// You can optionally specify some settings
$gq->setOption('timeout', 200);


// You can optionally specify some output filters,
// these will be applied to the results obtained.
$gq->setFilter('normalise');
$gq->setFilter('sortplayers', 'gq_ping');

// Send requests, and parse the data
$results = $gq->requestData();

// Some functions to print the results
function print_results($results) {

    foreach ($results as $id => $data) {

        printf("<h2>%s</h2>\n", $id);
        print_table($data);
    }

}

function print_table($data) {

    $gqs = array('gq_online', 'gq_address', 'gq_port', 'gq_prot', 'gq_type');
    

    if (!$data['gq_online']) {
        printf("");
        return;
    }

    	print("<h1>$data[hostname]</h1>");
	print("<h1>$data[gamename]</h1>");
	print("<h3>$data[gq_mapname]</h3>");
	print("<h3>$data[gq_gametype]</h3>");
	print("<h3>$data[game_descr]</h3>");
	print("<h3>$data[gq_address]</h3>");

$map_plaatje = array (
    'zatar_wetlands' => 'zatar_wetlands.jpg',
    'Road To Jalalabad' => 'road_to_jalalabad.jpg',
);		
// the code i inserted
if(array_key_exisits($data['gq_mapname'], $map_image))
{
    $image = $map_image[$data['gq_mapname']];
}
else
{
    $image = 'noserver.jpg';
}

echo '<img src="'.$image.'" />';

// End inserted code	

    foreach ($data as $key => $val) {

        if (is_array($val)) continue;

        $cls = empty($cls) ? ' class="uneven"' : '';

        if (substr($key, 0, 3) == 'gq_') {
            $kcls = (in_array($key, $gqs)) ? 'always' : 'normalise';
            $key = sprintf("<span class=\"key-%s\">%s</span>", $kcls, $key);
        }

        printf("", $cls, $key, $val);
    }

    print("");

    
}


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <title>GameQ - Example script</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
	<meta http-equiv="refresh" content="9">
        <style type="text/css">
            * {
                font-size: 9pt;
                font-family: Verdana, sans-serif;
            }
            h1 {
                font-size: 9pt;
            }
            h2 {
               
                font-size: 10pt;
            }
		h3{
			font-size:12px;
			font-weight:normal;
			margin:0;
		}
            table {
                border: 1px solid #000;
                background-color: #DDD;
                border-spacing:1px 1px;
            }
            table thead {
                font-weight: bold;
                background-color: #CCC;
            }
            table tr.uneven td {
                background-color:#FFF;
            }
            table td {
                padding: 5px 8px;
            }
            table tbody {
                background-color: #F9F9F9;
            }
            .note {
                color: #333;
                font-style:italic;
            }
            .key-always {
                color:red;
                font-weight:bold;
            }
            .key-normalise {
                color:red;
            }
</style>
    </head>
    <body>

<?php
    print_results($results);

?>
    </body>
</html>

Link to comment
Share on other sites

not sure if this is how it is in your actual code or not, but you have an extra ' on this line:

else

{

    $image= noimage.jpg';<<<<get rid of the '

}

I'd suggest doing a print_r() on the array $data to be sure you know whats in it.... Post the results of the print_r() if your still not getting desired effect.

Link to comment
Share on other sites

you edited it since your first post...  :-\

any ways, in my pre-lunch glance, I told you to remove rather than adding the ' before the string...

 

back from lunch and refreshed!

try:

 <?php
error_reporting(E_ALL);
require_once 'GameQ.php';

// Define your servers,
// see list.php for all supported games and identifiers.
$servers = array(
    ' ' => array('bf2', '69.12.98.120', 29900),

);



// Call the class, and add your servers.
$gq = new GameQ();
$gq->addServers($servers);

    
// You can optionally specify some settings
$gq->setOption('timeout', 200);


// You can optionally specify some output filters,
// these will be applied to the results obtained.
$gq->setFilter('normalise');
$gq->setFilter('sortplayers', 'gq_ping');

// Send requests, and parse the data
$results = $gq->requestData();

// Some functions to print the results
function print_results($results) {

    foreach ($results as $id => $data) {

        printf("<h2>%s</h2>\n", $id);
        print_table($data);
    }

}

function print_table($data) {

    $gqs = array('gq_online', 'gq_address', 'gq_port', 'gq_prot', 'gq_type');
    

    if (!$data['gq_online']) {
        printf("");
        return;
    }

       print("<h1>$data[hostname]</h1>");
      print("<h1>$data[gamename]</h1>");
      print("<h3>$data[gq_mapname]</h3>");
      print("<h3>$data[gq_gametype]</h3>");
      print("<h3>$data[game_descr]</h3>");
      print("<h3>$data[gq_address]</h3>");

$map_plaatje = array (
    'zatar_wetlands' => 'zatar_wetlands.jpg',
    'Road To Jalalabad' => 'road_to_jalalabad.jpg',
);      
// the code i inserted
if(array_key_exisits($data['gq_mapname'], $map_image))
{
    $image = $map_image[$data['gq_mapname']];
}
else
{
    $image = 'noserver.jpg';
}

echo '<img src="'.$image.'" />';

// End inserted code
die(nl2br("Give us this output:\n".print_r($data, true)));   

    foreach ($data as $key => $val) {

        if (is_array($val)) continue;

        $cls = empty($cls) ? ' class="uneven"' : '';

        if (substr($key, 0, 3) == 'gq_') {
            $kcls = (in_array($key, $gqs)) ? 'always' : 'normalise';
            $key = sprintf("<span class=\"key-%s\">%s</span>", $kcls, $key);
        }

        printf("", $cls, $key, $val);
    }

    print("");
   
    
}


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <title>GameQ - Example script</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
      <meta http-equiv="refresh" content="9">
        <style type="text/css">
            * {
                font-size: 9pt;
                font-family: Verdana, sans-serif;
            }
            h1 {
                font-size: 9pt;
            }
            h2 {
               
                font-size: 10pt;
            }
         h3{
            font-size:12px;
            font-weight:normal;
            margin:0;
         }
            table {
                border: 1px solid #000;
                background-color: #DDD;
                border-spacing:1px 1px;
            }
            table thead {
                font-weight: bold;
                background-color: #CCC;
            }
            table tr.uneven td {
                background-color:#FFF;
            }
            table td {
                padding: 5px 8px;
            }
            table tbody {
                background-color: #F9F9F9;
            }
            .note {
                color: #333;
                font-style:italic;
            }
            .key-always {
                color:red;
                font-weight:bold;
            }
            .key-normalise {
                color:red;
            }
</style>
    </head>
    <body>

<?php
    print_results($results);
   
?>
    </body>
</html>

Link to comment
Share on other sites

I think you ment the source code of the website page ?

Here it is:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <title>GameQ - Example script</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
      <meta http-equiv="refresh" content="9">
        <style type="text/css">
            * {
                font-size: 9pt;
                font-family: Verdana, sans-serif;
            }
            h1 {
                font-size: 9pt;
            }
            h2 {
               
                font-size: 10pt;
            }
         h3{
            font-size:12px;
            font-weight:normal;
            margin:0;
         }
            table {
                border: 1px solid #000;
                background-color: #DDD;
                border-spacing:1px 1px;
            }
            table thead {
                font-weight: bold;
                background-color: #CCC;
            }
            table tr.uneven td {
                background-color:#FFF;
            }
            table td {
                padding: 5px 8px;
            }
            table tbody {
                background-color: #F9F9F9;
            }
            .note {
                color: #333;
                font-style:italic;
            }
            .key-always {
                color:red;
                font-weight:bold;
            }
            .key-normalise {
                color:red;
            }
</style>
    </head>

    <body>

<h2> </h2>
<h1>24/7 Road to Jalalabad Robert Reed's House of A.I.D.S</h1><h1>battlefield2</h1><h3>Road To Jalalabad</h3><h3>gpm_cq</h3><h3></h3><h3>69.12.98.120</h3>

Link to comment
Share on other sites

I don't even see any output of the image tags there... so its not even getting that for or you've changed the code again.

Repost your exact code if it has changed from the original code you posted at all even including the changes I've mentioned. I'm stumped as to why the image tags wouldn't at least show up.

 

Link to comment
Share on other sites

First of all, thanks that you ar willing to help me with this, i appreciate it very much !

 

Here is the code that is running at this moment:

I correct a little type mismatch, and now it is showing nothing at all !

The error was in $map_image= array (  Originaly there was another string declared. ($map_plaatje.....  )

 

<?php
error_reporting(E_ALL);
require_once 'GameQ.php';

// Define your servers,
// see list.php for all supported games and identifiers.
$servers = array(
    ' ' => array('bf2', '69.12.98.120', 29900),

);



// Call the class, and add your servers.
$gq = new GameQ();
$gq->addServers($servers);

    
// You can optionally specify some settings
$gq->setOption('timeout', 200);


// You can optionally specify some output filters,
// these will be applied to the results obtained.
$gq->setFilter('normalise');
$gq->setFilter('sortplayers', 'gq_ping');

// Send requests, and parse the data
$results = $gq->requestData();

// Some functions to print the results
function print_results($results) {

    foreach ($results as $id => $data) {

        printf("<h2>%s</h2>\n", $id);
        print_table($data);
    }

}

function print_table($data) {

    $gqs = array('gq_online', 'gq_address', 'gq_port', 'gq_prot', 'gq_type');
    

    if (!$data['gq_online']) {
        printf("");
        return;
    }

       print("<h1>$data[hostname]</h1>");
      print("<h1>$data[gamename]</h1>");
      print("<h3>$data[gq_mapname]</h3>");
      print("<h3>$data[gq_gametype]</h3>");
      print("<h3>$data[game_descr]</h3>");
      print("<h3>$data[gq_address]</h3>");

$map_image= array (
    'zatar_wetlands' => 'zatar_wetlands.jpg',
    'Road To Jalalabad' => 'road_to_jalalabad.jpg',
);      
// the code i inserted
if(array_key_exisits($data['gq_mapname'], $map_image))
{
    $image = $map_image[$data['gq_mapname']];
}
else
{
    $image = 'noserver.jpg';
}

echo '<img src="'.$image.'" />';

// End inserted code
die(nl2br("Give us this output:\n".print_r($data, true)));   

    foreach ($data as $key => $val) {

        if (is_array($val)) continue;

        $cls = empty($cls) ? ' class="uneven"' : '';

        if (substr($key, 0, 3) == 'gq_') {
            $kcls = (in_array($key, $gqs)) ? 'always' : 'normalise';
            $key = sprintf("<span class=\"key-%s\">%s</span>", $kcls, $key);
        }

        printf("", $cls, $key, $val);
    }

    print("");
   
    
}


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <title>GameQ - Example script</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
      <meta http-equiv="refresh" content="9">
        <style type="text/css">
            * {
                font-size: 9pt;
                font-family: Verdana, sans-serif;
            }
            h1 {
                font-size: 9pt;
            }
            h2 {
               
                font-size: 10pt;
            }
         h3{
            font-size:12px;
            font-weight:normal;
            margin:0;
         }
            table {
                border: 1px solid #000;
                background-color: #DDD;
                border-spacing:1px 1px;
            }
            table thead {
                font-weight: bold;
                background-color: #CCC;
            }
            table tr.uneven td {
                background-color:#FFF;
            }
            table td {
                padding: 5px 8px;
            }
            table tbody {
                background-color: #F9F9F9;
            }
            .note {
                color: #333;
                font-style:italic;
            }
            .key-always {
                color:red;
                font-weight:bold;
            }
            .key-normalise {
                color:red;
            }
</style>
    </head>
    <body>

<?php
    print_results($results);
   
?>
    </body>
</html>

Link to comment
Share on other sites

wow, I'm not having such a good day I guess. Nothing wants to line up with my brain...

 

you still have my die statement in there, which should kill the app and output the array $data. There is no suggestion that it has happened in the source code you posted last (the output).

Try this and post the source code...

<?php
error_reporting(E_ALL);
require_once 'GameQ.php';

// Define your servers,
// see list.php for all supported games and identifiers.
$servers = array(
    ' ' => array('bf2', '69.12.98.120', 29900),

);



// Call the class, and add your servers.
$gq = new GameQ();
$gq->addServers($servers);

    
// You can optionally specify some settings
$gq->setOption('timeout', 200);


// You can optionally specify some output filters,
// these will be applied to the results obtained.
$gq->setFilter('normalise');
$gq->setFilter('sortplayers', 'gq_ping');

// Send requests, and parse the data
$results = $gq->requestData();

// Some functions to print the results
function print_results($results) {

    foreach ($results as $id => $data) {

        printf("<h2>%s</h2>\n", $id);
        print_table($data);
    }

}

function print_table($data) {

    $gqs = array('gq_online', 'gq_address', 'gq_port', 'gq_prot', 'gq_type');
    

    if (!$data['gq_online']) {
        printf("");
        return;
    }

       print("<h1>$data[hostname]</h1>\n");
      print("<h1>$data[gamename]</h1>\n");
      print("<h3>$data[gq_mapname]</h3>\n");
      print("<h3>$data[gq_gametype]</h3>\n");
      print("<h3>$data[game_descr]</h3>\n");
      print("<h3>$data[gq_address]</h3>\n");

$map_image= array (
	'zatar_wetlands' => 'zatar_wetlands.jpg',
	'Road To Jalalabad' => 'road_to_jalalabad.jpg',
);      
// the code i inserted
if(array_key_exisits($data['gq_mapname'], $map_image))
{
	$image = $map_image[$data['gq_mapname']];
}
else
{
	$image = 'noserver.jpg';
}

echo "<img src=\"".$image."\" />\n";

// End inserted code
//die(nl2br("Give us this output:\n".print_r($data, true)));//This is for testing...

    foreach ($data as $key => $val) {

        if (is_array($val)) continue;

        $cls = empty($cls) ? ' class="uneven"' : '';

        if (substr($key, 0, 3) == 'gq_') {
            $kcls = (in_array($key, $gqs)) ? 'always' : 'normalise';
            $key = sprintf("<span class=\"key-%s\">%s</span>", $kcls, $key);
        }

        printf("", $cls, $key, $val);
    }

    print("");
   
    
}


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <title>GameQ - Example script</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
      <meta http-equiv="refresh" content="9">
        <style type="text/css">
            * {
                font-size: 9pt;
                font-family: Verdana, sans-serif;
            }
            h1 {
                font-size: 9pt;
            }
            h2 {
               
                font-size: 10pt;
            }
         h3{
            font-size:12px;
            font-weight:normal;
            margin:0;
         }
            table {
                border: 1px solid #000;
                background-color: #DDD;
                border-spacing:1px 1px;
            }
            table thead {
                font-weight: bold;
                background-color: #CCC;
            }
            table tr.uneven td {
                background-color:#FFF;
            }
            table td {
                padding: 5px 8px;
            }
            table tbody {
                background-color: #F9F9F9;
            }
            .note {
                color: #333;
                font-style:italic;
            }
            .key-always {
                color:red;
                font-weight:bold;
            }
            .key-normalise {
                color:red;
            }
</style>
    </head>
    <body>

<?php
    print_results($results);
   
?>
    </body>
</html>

Link to comment
Share on other sites

only the regular server info... ??? is the extra script in the right position ? it is just a thougt...

[code<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
    <head>
        <title>GameQ - Example script</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
      <meta http-equiv="refresh" content="9">
        <style type="text/css">
            * {
                font-size: 9pt;
                font-family: Verdana, sans-serif;
            }
            h1 {
                font-size: 9pt;
            }
            h2 {
               
                font-size: 10pt;
            }
         h3{
            font-size:12px;
            font-weight:normal;
            margin:0;
         }
            table {
                border: 1px solid #000;
                background-color: #DDD;
                border-spacing:1px 1px;
            }
            table thead {
                font-weight: bold;
                background-color: #CCC;
            }
            table tr.uneven td {
                background-color:#FFF;
            }
            table td {
                padding: 5px 8px;
            }
            table tbody {
                background-color: #F9F9F9;
            }
            .note {
                color: #333;
                font-style:italic;
            }
            .key-always {
                color:red;
                font-weight:bold;
            }
            .key-normalise {
                color:red;
            }
</style>
    </head>

    <body>

<h2> </h2>
<h1>24/7 Road to Jalalabad Robert Reed's House of A.I.D.S</h1>
<h1>battlefield2</h1>
<h3>Road To Jalalabad</h3>
<h3>gpm_cq</h3>
<h3></h3>
<h3>69.12.98.120</h3>

Link to comment
Share on other sites

Got two work arounds, wich doesnt solve the original problem but it is better than zip.

My guess is that there must be something wrong with the coding, it doesnt accept images for some reason i cant figure out... Damn...

 

But i am creative, i have placed a background image top left and that image says, now playing (bla bla)

Under the print $  i have put a img tag with a image wich says that the server is off-line.

 

This page i loaded into a iframe with solid dimensions.

 

Now, when there is no server, its got nothing to print and the first it will show on the page is the offline image.

When there is a server, the script will print out its collected data and the image underneath it will shift down due to the text that is printed. Automaticly you can see the background image wich says the server is running plus the printed data.

 

I hope you understand what i did.

 

The second workaround is a extra script, also loaded in a iframe which only shows map images. But i didnt have found a secondary script wich can do that job.

 

Thanks for youre effords to help me, and if you got any clou, please let me know !

 

Thanks again !

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.