Exemple #1
0
 /**
  * Update the server with current bzfquery information
  * return self
  */
 public function forceUpdate()
 {
     $this->info = @bzfquery($this->address);
     $this->updated = TimeDate::now();
     $this->db->query("UPDATE servers SET info = ?, updated = UTC_TIMESTAMP() WHERE id = ?", "si", array(serialize($this->info), $this->id));
     $this->updateOnline();
     return $this;
 }
function query_servers()
{
    global $site;
    global $connection;
    $query = 'SELECT `id`, `servername`, `serveraddress` FROM `servertracker`' . ' ORDER BY `id`';
    if (!($result = $site->execute_query('servertracker', $query, $connection))) {
        die('Could not find out servername and serveraddress to be updated.');
    }
    // need to include game specific backend
    include dirname(dirname(dirname(__FILE__))) . "/Servertracker/bzfquery.php";
    // update each entry
    while ($row = mysql_fetch_array($result)) {
        // get raw query result
        $data = bzfquery($row['serveraddress']);
        // build the query with the result
        if (isset($data['numPlayers'])) {
            $query = 'UPDATE `servertracker` SET' . ' `cur_players_total`=' . sqlSafeStringQuotes($data['numPlayers']) . ' WHERE `id`=' . sqlSafeStringQuotes($row['id']) . ' LIMIT 1';
            // execute the update query
            $site->execute_query('servertracker', $query, $connection);
        }
    }
    mysql_free_result($result);
    //		$query = 'UPDATE `misc_data` SET `last_servertracker_query`=' . sqlSafeStringQuotes($current_time);
    //		if (!($result = @$site->execute_query('misc_data', $query, $connection)))
    //		{
    //			die('Could not set newest last_servertracker_query value.');
    //		}
}
Exemple #3
0
 /**
  * Update the server with current bzfquery information
  * return self
  */
 public function forceUpdate()
 {
     $this->info = bzfquery($this->getAddress());
     $this->updated = TimeDate::now();
     $this->online = !isset($this->info['error']);
     $this->db->execute("UPDATE servers SET info = ?, online = ?, updated = UTC_TIMESTAMP() WHERE id = ?", array(serialize($this->info), $this->online, $this->id));
     // If a server is offline, log it
     if (!$this->online) {
         if ($logger = \Service::getContainer()->get('logger')) {
             $id = $this->getId();
             $address = $this->getAddress();
             $reason = $this->info['error'];
             $logger->notice("Connection to server #{$id} ({$address}) failed: {$reason}");
         }
     }
     return $this;
 }
Exemple #4
0
function formatbzfquery_last($server, $connection)
{
    global $site;
    global $connection;
    global $use_internal_db;
    if ($use_internal_db) {
        @(!mysql_select_db($site->db_used_name(), $connection));
    } else {
        if (@(!mysql_select_db("playerlist", $connection))) {
            @mysql_close($connection);
            unset($connection);
        }
    }
    if (isset($_GET['server'])) {
        echo '<p>' . $server . '</p>' . "\n";
    } else {
        echo '<p><a href="?server=' . urlencode($server) . '">' . $server . '</a></p>' . "\n";
    }
    // Query the server
    if (!function_exists('pcntl_fork')) {
        ob_start();
    }
    $data = bzfquery($server);
    $ausgabe = '';
    if (!function_exists('pcntl_fork')) {
        $ausgabe .= ob_get_contents();
        ob_end_clean();
    }
    if (!isset($data['player'])) {
        if (!isset($data['protocol'])) {
            echo '<p>' . KEINEVERBINDUNG . ' ';
            if (!strcmp($ausgabe, '') == 0) {
                echo GEMELDETERFEHLER . $ausgabe . '.';
            }
            echo '</p>' . "\n";
        } else {
            echo '<p>' . KEINESPIELER . '</p>' . "\n";
        }
    } else {
        $zaehler = $data['maxTime'] - $data['timeElapsed'];
        if ($zaehler > 0) {
            echo '<p class="zaehler">' . ZAEHLER . '<span class="zaehler">' . round($zaehler / 60, 2) . VON . round($data['maxTime'] / 60, 2) . '</span>' . RESTZEIT . '</p>' . "\n";
        }
        // Display the server info
        $teamName = array(0 => "schurke", 1 => "rot", 2 => "gruen", 3 => "blau", 4 => "violett", 5 => "zuschauer", 6 => "hase");
        $teamColour = array(0 => "yellow", 1 => "red", 2 => "green", 3 => "blue", 4 => "purple", 5 => "gray", 6 => "orange");
        usort($data['player'], "cmp");
        //		echo 'count punkte:!' . print_r($data['player']['0']['team']);
        if (isset($data['player']['0']['team']) && !(strcmp($data['player']['0']['team'], '5') === 0)) {
            echo '<table class="punkte">' . "\n";
            echo '  <tbody>' . "\n";
            while (list($key, $val) = each($data['team'])) {
                if ($data['team'][$key]['size'] > 0) {
                    echo '    ';
                    // Mannschaftsfarbe
                    marke('tr', $teamName[$key]);
                    // Punktzahl
                    echo '<td>';
                    echo $data['team'][$key]['won'] - $data['team'][$key]['lost'];
                    echo '</td>';
                    // Gewonnen
                    echo '<td>';
                    echo '(' . $data['team'][$key]['won'] . ' - ';
                    // Verloren
                    echo $data['team'][$key]['lost'] . ')';
                    echo '</td>';
                    // #Spieler
                    echo '<td>';
                    echo $data['team'][$key]['size'];
                    echo '</td>';
                    // Ende Mannschaftsfarbe
                    echo '</tr>' . "\n";
                }
            }
            echo '  </tbody>' . "\n" . '</table>' . "\n";
        }
        reset($data);
        echo "\n\n" . '<table class="spieler" border="0">' . "\n";
        echo '  <tbody>';
        while (list($key, $val) = each($data['player'])) {
            echo "\n" . '<tr>' . "\n";
            // Zuschauer spielen nicht -> keine Punktzahl
            if (!strcmp($teamName[$data['player'][$key]['team']], 'zuschauer') == 0) {
                echo '<td>';
                echo $data['player'][$key]['won'] - $data['player'][$key]['lost'];
                echo '</td>' . "\n";
                echo '<td>(' . $data['player'][$key]['won'] . '-' . $data['player'][$key]['lost'] . ')</td><td>[' . $data['player'][$key]['tks'] . ']</td>';
            } else {
                echo '<td></td>' . "\n" . '<td></td>' . "\n" . '<td></td>' . "\n";
            }
            // Mannschaftsfarbe
            marke('td', $teamName[$data['player'][$key]['team']]);
            $playername = $data['player'][$key]['sign'];
            // Spielernamen eventuell kuerzen
            if ($site->mobile_version()) {
                // Name ziemlich lang
                if (strlen($playername) > 13) {
                    $playername = str_split($playername, 10);
                    echo htmlent($playername[0]) . "...";
                } else {
                    echo htmlent($playername);
                }
            } else {
                echo htmlentities($playername);
            }
            echo '</td>' . "\n";
            // Mehl
            marke('td', 'mehl');
            if (!strcmp($data['player'][$key]['motto'], '') == 0) {
                $motto = $data['player'][$key]['motto'];
                // motto ziemlich lang
                if (strlen($motto) > 17) {
                    $motto = str_split($motto, 14);
                    $motto = htmlent($motto[0]) . '...';
                }
                echo '(' . htmlent($motto) . ')';
            }
            echo '</td>' . "\n";
            // Existiert Datenbankverbindung?
            if ($connection) {
                // team herausfinden
                marke('td', 'team');
                $callsign = $data['player'][$key]['sign'];
                $query = 'SELECT `teamid` from users WHERE `name`=' . sqlSafeStringQuotes($callsign) . ' LIMIT 1';
                $result = mysql_query($query, $connection);
                if (!$result) {
                    print mysql_error();
                    die("<br>\nQuery {$query} ist ung&uuml;ltiges SQL.");
                }
                $resultarray = mysql_fetch_array($result);
                $teamid = $resultarray['teamid'];
                if ($teamid > 0) {
                    if ($use_internal_db) {
                        $query = 'SELECT `name` from teams WHERE `id`=' . sqlSafeStringQuotes($teamid) . ' LIMIT 1';
                    } else {
                        $query = 'SELECT `name` from teams WHERE `teamid`=' . sqlSafeStringQuotes($teamid) . ' LIMIT 1';
                    }
                    $result = mysql_query($query, $connection);
                    if (!$result) {
                        print mysql_error();
                        die("<br>\nQuery {$query} ist ung&uuml;ltiges SQL.");
                    }
                    $resultarray = mysql_fetch_array($result);
                    mysql_free_result($result);
                    echo $resultarray['name'];
                }
                echo '</td>' . "\n";
            }
            echo '</tr>' . "\n";
        }
        echo '  </tbody>' . "\n" . '</table>' . "\n";
    }
}
Exemple #5
0
<?php

include 'bzfquery.php';
// Query the server
$data = bzfquery("localhost:5154");
// Display the server info
echo '<pre>';
bzfdump($data);
echo '</pre>';