Austinb / GameQ

A PHP Gameserver Status Query Library
https://austinb.github.io/GameQ/
GNU Lesser General Public License v3.0
403 stars 138 forks source link

Empty Page #193

Closed Parilar closed 10 years ago

Parilar commented 10 years ago

I've used this Code and only got an empty Page as result. (list.php is empty to)

<?php // Include the main class file require '../GameQ.php';

// Define your servers, // see list.php for all supported games and identifiers. $servers = array( array( 'id' => 'BF3', 'type' => 'ts3', 'host' => '37.120.169.4:9987', ) );

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

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

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

// 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("<p>The server did not respond within the specified time.</p>\n");
    return;
}

print("<table><thead><tr><td>Variable</td><td>Value</td></tr></thead><tbody>\n");

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("<tr%s><td>%s</td><td>%s</td></tr>\n", $cls, $key, $val);
}

print("</tbody></table>\n");

}

?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

GameQ - Example script

GameQ - Example script

Players are never displayed in this example.
Bold, red variables are always set by gameq. Additionally, the normal red variables are always set when the normalise filter is enabled.
gq_online will always contain a boolean indicating if the server responded to the request.

Click here for a list of supported games.
Verox- commented 10 years ago

There is no protocol named "ts3", use "teamspeak3".

Parilar commented 10 years ago

The page is still empty :/

If i use the Source from github it's empty too

Parilar commented 10 years ago

I think the problem is the read function. I've tried $dir = dir($protocols_path); echo $dir->read(); and there is no echo.

Austinb commented 10 years ago

What version of PHP are you using?

Parilar commented 10 years ago

5.4.4

Austinb commented 10 years ago

Do you have any error log information from PHP? You may try adding error_reporting(E_ALL); to the top of your script. Also make sure display_errors is set on as well. Without more information or errors I will be unable to help.

At the least if you are unable to query the script should output an empty array when rendered.

Parilar commented 10 years ago

I've added error_reporting(E_ALL); but the page is completly empty.

Verox- commented 10 years ago

I can only imagine there is a configuration error with your webserver. Using the latest version with your code I get the expected outcome.

Pastebin your PHP error log and post it here.

Parilar commented 10 years ago

The problem is , there is no error log. (That's the problem.) it's a fresh Debian 7 System as basic LAMP Server.

Verox- commented 10 years ago

Have you tried running any other PHP code on your webserver?

Parilar commented 10 years ago

Yes, and it works Fine.

I'm wondering about, that there is no error.

Parilar commented 10 years ago

Changed error reporting to ; error_reporting(-1); ini_set('display_errors', 1);

Error : Fatal error: Class 'GameQ_Protocols' not found in /var/www/site/game/gameq/protocols/gamespy2.php on line 29

EDIT: i don't know why, but after redownloading the project everything is working fine