Exemple #1
0
 /**
  * Cleans a Clonk 4 conform text sting human readable.
  *
  * @param string $message
  * @return string
  */
 public static function cleanString($message)
 {
     $coded = $decoded = array();
     preg_match_all('|\\\\[0-9]{3}|', $message, $coded);
     foreach ($coded[0] as $numstr) {
         $num = ereg_replace("[^0-9]", "", $numstr);
         $decoded[$num] = C4Network::decodeEntitiyString($num);
     }
     foreach ($decoded as $num => $entity) {
         $message = str_replace('\\' . $num, $entity, $message);
     }
     return $message;
 }
Exemple #2
0
function GetGamesList()
{
    if (!gotConnection()) {
        return;
    }
    $games = '';
    $list = references();
    $players = '';
    foreach ($list as $reference) {
        if ($reference['valid']) {
            $games .= '<tr>';
            $games .= '<td>' . htmlspecialchars(ParseINI::parseValue('Title', $reference['data'])) . '</td>';
            $games .= '<td>' . htmlspecialchars(ParseINI::parseValue('State', $reference['data'])) . '</td>';
            $games .= '<td>' . date("Y-m-d H:i", $reference['start']) . '</td>';
            $players = '';
            $player_list = ParseINI::parseValuesByCategory('Name', 'Player', $reference['data']);
            foreach ($player_list as $player) {
                if (!empty($players)) {
                    $players .= ', ';
                }
                $players .= $player;
            }
            $games .= '<td>' . htmlspecialchars($players) . '</td>';
        }
    }
    $games = C4Network::cleanString($games);
    $result = "";
    if (!empty($games)) {
        $result .= '<table>';
        $result .= '<tr><th>Round</th><th>State</th><th>Begin</th><th>Players</th></tr>';
        $result .= $games;
        $result .= '</table>';
    } else {
        $result .= '<p style="color: gray;">No games are currently running.</p>';
    }
    return $result;
}
Exemple #3
0
                }
            }
            foreach ($list as $reference) {
                if (!empty($message)) {
                    $message .= PHP_EOL;
                }
                $message .= $reference['data'];
                $message .= 'GameId=' . $reference['id'] . PHP_EOL;
                $message .= 'OfficialServer=false' . PHP_EOL;
            }
            C4Network::sendAnswer($message);
        }
    }
    mysql_close($link);
} else {
    C4Network::sendAnswer(C4Network::createError('Database error.'));
}
function registerRelease()
{
    global $config, $link, $prefix;
    // check request validity
    if (ParseINI::parseValue('oc_enable_update', $config) != 1) {
        throw new Exception('Update disabled on this server.');
    }
    // mandatory parameters
    if (!isset($_REQUEST['file'])) {
        throw new Exception('Missing mandatory parameter "file"');
    }
    if (!isset($_REQUEST['hash'])) {
        throw new Exception('Missing mandatory parameter "hash"');
    }