Example #1
0
function JSONSerialize($data)
{
    $json = "";
    if (is_array($data)) {
        $json .= "";
        $elements = "[ ";
        foreach ($data as $v) {
            $elements .= JSONSerialize($v);
            $elements .= " ,";
        }
        $json .= substr($elements, 0, strlen($elements) - 1);
        $json .= " ]";
    } else {
        if (is_object($data)) {
            $json .= "{";
            $elements = "";
            foreach ($data as $k => $v) {
                $elements .= $k . ": " . JSONSerialize($v);
                $elements .= " ,";
            }
            $json .= substr($elements, 0, strlen($elements) - 1);
            $json .= "}";
        } else {
            $json .= "\"" . addslashes($data) . "\"";
        }
    }
    return $json;
}
Example #2
0
$Players = Query("SELECT %%players.*, (SELECT COALESCE(SUM(score),0) FROM %%outcomes WHERE %%outcomes.player=%%players.player_id) AS saldo, (SELECT COALESCE(SUM(score),0) FROM %%outcomes_recent WHERE %%outcomes_recent.player=%%players.player_id) AS saldo_recent, (SELECT COUNT(*) FROM %%games WHERE %%games.game_playera=%%players.player_id OR %%games.game_playerb=%%players.player_id) AS ngames, (SELECT COUNT(*) FROM %%games WHERE (%%games.game_playera=%%players.player_id OR %%games.game_playerb=%%players.player_id) AND DATEDIFF(%%games.game_date,NOW())>-30) AS nrecent, (SELECT COUNT(*) FROM %%winners WHERE %%winners.winner=%%players.player_id) AS nwins, (SELECT COUNT(*) FROM %%winners WHERE %%winners.loser=%%players.player_id) AS nloses,(SELECT COUNT(*) FROM %%winners WHERE %%winners.winner=%%players.player_id AND DATEDIFF(%%winners.game_date,NOW())>-30) AS nwins_recent, (SELECT COUNT(*) FROM %%winners WHERE %%winners.loser=%%players.player_id AND DATEDIFF(%%winners.game_date,NOW())>-30) AS nloses_recent FROM %%players ORDER BY player_level ASC");
$Winners = Query("SELECT winner, loser, COUNT(DISTINCT game_id) AS times FROM %%winners GROUP BY winner, loser");
$Games = Query("SELECT game_playera, game_playerb, playera.player_name AS aname, playerb.player_name AS bname, game_scorea, game_scoreb, DATE_FORMAT(game_date,'%d-%m-%Y') AS game_date FROM %%games LEFT JOIN %%players AS playera ON playera.player_id=game_playera LEFT JOIN %%players AS playerb ON playerb.player_id=game_playerb ORDER BY game_date ASC");
?>

<script type="text/javascript">
	var winners = <?php 
echo JSONSerialize($Winners);
?>
;
	var players = <?php 
echo JSONSerialize($Players);
?>
;
	var games = <?php 
echo JSONSerialize($Games);
?>
;
</script>

<script type="text/javascript" src="pyramid.js"></script>

<div class="content">
	<div class="pyramid">
		<?php 
$numPlayersInThisLayer = 0;
$currentLayer = -1;
$expectedInThisLayer = 0;
for ($a = 0; $a < count($Players); $a++) {
    if ($numPlayersInThisLayer >= $expectedInThisLayer) {
        $numPlayersInThisLayer = 0;
Example #3
0
    }
    $QuotesData .= "</div></li>";
    if ($i % 2 == 0) {
        $QuotesData .= "</ul><ul>";
    }
    $i++;
}
$QuotesData .= "</ul>";
$ReturnData->quotes = str_replace("\n", "", $QuotesData);
// Choose a random campaign to load
$Screens = array();
$dir = opendir($Base . $ScreensDirectory);
while (($file = readdir($dir)) !== false) {
    if ($file[0] != ".") {
        $Screens[] = $file;
    }
}
closedir($dir);
if (!isset($Settings["content.ignore-campaigns"]) || $Settings["content.ignore-campaigns"] != "true") {
    $CurrentScreen = $Screens[rand(0, count($Screens) - 1)];
    LoadScreenSettings($Base . $ScreensDirectory . "/" . $CurrentScreen);
}
// General settings
$ReturnData->hideBar = $Settings["display.hide-bar"];
$ReturnData->hideTicker = $Settings["display.hide-ticker"];
$ReturnData->hideBackground = $Settings["display.hide-background"];
$ReturnData->marqueeText = $Settings["marquee.text"];
$ReturnData->popupText = str_replace("\r\n", "", $Settings["popup.text"]);
$ReturnData->runTime = $Settings["runtime"];
echo JSONSerialize($ReturnData);