function alias_pid($player_id) { $aliases = query_as_array("SELECT * FROM `player_alias` WHERE `enabled` = 1 AND `alias` = '{$player_id}'"); $player_ids = array(); if (count($aliases) > 0) { foreach ($aliases as $alias) { array_push($player_ids, $alias->player_id); } } else { array_push($player_ids, $player_id); } return $player_ids; }
<rss version="2.0"> <channel> <title>MOGG.fr Tournaments</title> <link>http://mogg.fr</link> <description>Tournaments on mogg.fr</description> <?php // List pending tournaments if ($status != '') { $q_status = "AND `status` = '{$status}'"; } else { $q_status = ''; } $query = query("SELECT id, name, type, creation_date, status FROM `tournament` WHERE `min_players` > 1 {$q_status} ORDER BY `id` DESC LIMIT 0, 10"); while ($row = mysql_fetch_object($query)) { // List this tournament's registered players $players = query_as_array("SELECT nick FROM `registration` WHERE `tournament_id`='" . $row->id . "' ; "); $with = ''; if (count($players) > 0) { $players_names = array(); foreach ($players as $player) { $players_names[] = $player->nick; } $with = ' with ' . implode(', ', $players_names); } $link = ''; if ($row->status != '0' && $row->status != '6') { $link = $url . '/tournament/?id=' . $row->id; } // Display item ?> <item>
$tmp['rarity'] = $arr_ext['rarity']; $tmp['images'] = array(); $filename = '../img/FULL/' . $arr_ext['se'] . '/' . $card_bdd['name'] . '.full.jpg'; if (is_file($filename)) { $tmp['images'][] = $filename; } $imgnb = 1; $filename = '../img/FULL/' . $arr_ext['se'] . '/' . $card_bdd['name'] . $imgnb . '.full.jpg'; while (is_file($filename)) { $tmp['images'][] = $filename; $filename = '../img/FULL/' . $arr_ext['se'] . '/' . $card_bdd['name'] . ++$imgnb . '.full.jpg'; } $ext[$tmp['se']] = $tmp; } // Languages $langs = query_as_array("SELECT * FROM cardname WHERE card_id = {$id}"); ?> <a href="http://magiccards.info/query?q=!<?php echo $card_bdd['name']; ?> &v=card&s=cname">View on MCI</a> <table> <tr> <th>Extensions</th> <td> <ul> <?php $json = JSON_decode($card_bdd['attrs']); foreach ($ext as $i => $value) { if ($ext[$i]['nbpics'] == 0) { echo ' <li>' . $ext[$i]['name'] . ' (' . $ext[$i]['rarity'] . ')</li>';
if ($starter == '') { $starter_lost++; } else { if ($starter == $action->sender) { $starter_lost++; } else { $starter_won++; } } } break; } } } } $g = query_as_array("SELECT * FROM `registration` WHERE `registration`.`tournament_id` = '" . $d->id . "'"); $lparsed = 0; foreach ($g as $r) { if (!property_exists($data->score, $r->player_id)) { echo "Unparsed : no score for " . $g->nick . "\n"; continue; } if (!property_exists($data->score->{$r->player_id}, 'gamepoints')) { echo "Unparsed : no gamepoints for " . $r->nick . "\n"; continue; } $tournaments[$d->id] = $d->name; $deck_start = microtime(true); $deck = new Deck($r->deck); $deck_parse += microtime(true) - $deck_start; $rounds_number = 1;
<?php $r = query_as_array("SELECT * FROM `round` WHERE `tournament` = '{$id}' ORDER BY `round` ASC, `id` ASC ;"); $c_r = 0; foreach ($r as $round) { if ($round->round != $c_r) { echo ' <h3>Round ' . $round->round . '</h3>' . "\n" . '<ul>'; } echo '<li>' . $round->creator_nick . ' ' . $round->creator_score . ' - ' . $round->joiner_score . ' ' . $round->joiner_nick . '</li>'; } ?> </ul> <h2>Log</h2> <ul> <?php $l = query_as_array("SELECT * FROM `tournament_log` WHERE `tournament_id` = '{$id}' ;"); foreach ($l as $log) { if (array_key_exists($log->sender, $registrations)) { $sender = $registrations[$log->sender][0]->nick; } else { $sender = 'server'; } echo ' <li>' . $sender . ' : ' . $log->type; if (!empty($log->value)) { echo ' : ' . $log->value; } echo '</li>' . "\n"; } ?> </ul> </div>
$t = query_as_array("SELECT `id`, `data` FROM `tournament` WHERE `id` = '{$tid}' ; "); } foreach ($t as $tournament) { $players = tournament_all_players($tournament); if (count($players) < 1) { continue; } echo $tournament->id . ' : ' . count($players) . ' players'; $round = 1; $data = json_decode($tournament->data); unset($data->results); // Will be recomputed $data->results = NULL; // Re-compute rounds data do { $rdata = query_as_array("SELECT `id`, `creator_id`, `creator_score`, `joiner_id`, `joiner_score` FROM `round`\n\t\t\tWHERE `tournament` = '" . $tournament->id . "' AND `round` = '{$round}' ; "); if (count($rdata) > 0) { $data->results->{$round} = $rdata; } $round++; } while (count($rdata) > 0); echo ', ' . count($data->results) . ' rounds'; if (count($data->results) < 1) { // Can't compute scores without rounds echo ' : aborting<br>' . "\n"; continue; } unset($data->score); // Define players scores and tie breakers foreach ($players as $player) { // First loop to update all players scores
<?php include '../lib.php'; include '../includes/db.php'; $query = "SELECT * FROM `shout` ORDER BY `id` DESC LIMIT 0, 20"; $shouts = query_as_array($query); header('Content-Type: text/xml; charset=UTF-8'); echo '<?xml version="1.0" encoding="UTF-8" ?>'; ?> <rss version="2.0"> <channel> <title>MOGG.fr shouts</title> <link>http://mogg.fr</link> <description>Shouts on mogg.fr</description> <?php foreach ($shouts as $shout) { $display = htmlspecialchars($shout->sender_nick) . ' : ' . htmlspecialchars($shout->message); ?> <item> <guid><?php echo $shout->id; ?> </guid> <pubDate><?php echo date("D, d M Y H:i:s", strtotime($shout->time)); ?> </pubDate> <title><?php echo $display; ?> </title>
echo '</ul>'; } } $ret = true; } if (array_key_exists('clean_id', $_GET) && array_key_exists('nick', $_GET)) { $from = $_GET['clean_id']; $to = $_GET['nick']; query("UPDATE `round` SET `last_update_date` = `last_update_date`, `creator_nick` = '{$to}' WHERE `creator_id` = '{$from}' AND `creator_nick` = 'Nickname' ; "); $i = mysql_affected_rows(); query("UPDATE `round` SET `last_update_date` = `last_update_date`, `joiner_nick` = '{$to}' WHERE `joiner_id` = '{$from}' AND `joiner_nick` = 'Nickname' ; "); echo $i + mysql_affected_rows() . ' games updated'; $ret = true; } // Displaying $rounds = query_as_array("SELECT\n\t`creator_nick`, `creator_id`,\n\t`joiner_nick`, `joiner_id`\nFROM `round`\nWHERE `creator_id` != `joiner_id`\nORDER BY `id` DESC"); $players = array(); // For each ID found, a list of nicknames the player has foreach ($rounds as $round) { // Creator if ($round->creator_id != '') { if (!array_key_exists($round->creator_id, $players)) { $players[$round->creator_id] = array(); } if (array_search($round->creator_nick, $players[$round->creator_id]) === false) { $players[$round->creator_id][] = $round->creator_nick; } } // Joiner if ($round->joiner_id != '') { if (!array_key_exists($round->joiner_id, $players)) {
} if ($res = query_oneshot("SELECT `id` FROM `extension` WHERE `se` = 'CUBL' ; ")) { $cubl_id = $res->id; } if ($res = query_oneshot("SELECT `id` FROM `extension` WHERE `se` = 'CUBS' ; ")) { $cubs_id = $res->id; } // Cleanup if (query("DELETE FROM `card_ext` WHERE `ext` = '{$cubl_id}' ; ")) { echo mysql_affected_rows() . ' cards removed from CUBL<br>'; } if (query("DELETE FROM `card_ext` WHERE `ext` = '{$cubs_id}' ; ")) { echo mysql_affected_rows() . ' cards removed from CUBS<br>'; } // Get if ($cards = query_as_array("SELECT `card`, `rarity` FROM `card_ext` WHERE `ext` = '{$cub_id}' ; ")) { echo count($cards) . ' cards in CUB to dispatch<br>'; } // Dispatch $err = 0; $cubl_nb = 0; $cubs_nb = 0; //while ( $card = mysql_fetch_object($cards) ) { foreach ($cards as $card) { switch ($card->rarity) { case 'U': if (query("INSERT INTO `mtg`.`card_ext` (`card`, `ext`, `rarity`, `nbpics`) VALUES ('" . $card->card . "', '" . $cubl_id . "', 'C', '0');")) { $cubl_nb++; } else { $err++; }
include '../includes/player_alias.php'; $player_id = param_or_die($_GET, 'player_id'); $player_ids = alias_pid($player_id); $where = pid2wheret($player_ids); $data = new stdClass(); // List registered tournaments $delay = param_or_die($_GET, 'tournaments_delay'); $query = "\nSELECT\n\t`tournament`.`id`, \n\t`tournament`.`data`,\n\t`tournament`.`creation_date`,\n\t`tournament`.`type`,\n\t`tournament`.`name`,\n\t`tournament`.`min_players`,\n\t`tournament`.`status`\nFROM\n\t`registration`, `tournament`\nWHERE\n\t({$where}) AND\n\t`registration`.`tournament_id` = `tournament`.`id`"; if ($delay != '') { $query .= " AND `date` > TIMESTAMPADD({$delay}, -1, NOW())"; } $query .= " ;"; $data->suscribed_tournaments = query_as_array($query); foreach ($data->suscribed_tournaments as $i => $tournament) { // Players $query = "SELECT `player_id`, `nick` FROM `registration`\n\t\tWHERE `registration`.`tournament_id` = {$tournament->id}"; $tournament->players = query_as_array($query); // Results $query = "SELECT `creator_id`, `creator_score`, `joiner_id`, `joiner_score`, `round`\n\t\tFROM `round`\n\t\tWHERE `tournament` = {$tournament->id} ORDER BY `round` ASC"; $matches = query_as_array($query); // By round $results = array(); foreach ($matches as $match) { while (count($results) < $match->round) { array_push($results, array()); } array_push($results[$match->round - 1], $match); } $tournament->results = $results; } die(json_encode($data));
<?php include '../lib.php'; include '../includes/db.php'; include '../includes/player_alias.php'; $player_id = param_or_die($_GET, 'player_id'); $data = new stdClass(); // List past games $delay = param_or_die($_GET, 'games_delay'); $player_ids = alias_pid($player_id); $where = pid2where($player_ids); $query = "SELECT\n\t\t*,\n\t\tTIMESTAMPDIFF(SECOND, `creation_date`, NOW()) as age\n\tFROM `round`\n\tWHERE\n\t\t`creator_id` != `joiner_id`\n\t\tAND `status` != '0'\n\t\tAND `status` != '1' \n\t\tAND `tournament` = '0'\n\t\tAND ( {$where} )"; if ($delay != '') { $query .= " AND `creation_date` > TIMESTAMPADD({$delay}, -1, NOW()) "; } $query .= "ORDER BY `id` ASC"; $data->suscribed_games = query_as_array($query); die(json_encode($data));
</head> <body> <?php if (!$apply) { echo '<p>Changes will NOT be applied <a href="?file=' . $file . '">Apply</a>'; } $masterlog = ''; $query = query("SELECT * FROM extension WHERE `se` = '{$ext}'"); if ($res = mysql_fetch_object($query)) { $ext_id = $res->id; if ($apply) { query("DELETE FROM `card_ext` WHERE `ext` = '{$ext_id}'"); $masterlog = mysql_affected_rows() . ' cards unlinked from ' . $ext . "\n"; } else { $links = query_as_array("SELECT * FROM `card_ext` WHERE `ext` = '{$ext_id}'"); $masterlog = count($links) . ' cards are already in ' . $ext . "\n"; } } else { if ($apply) { $query = query("INSERT INTO extension (`se`, `name`) VALUES ('{$ext}', '" . $cards[0] . "')"); } $ext_id = mysql_insert_id(); } ?> <table> <tr> <th>Name</th> <th>Action</th> </tr> <?php
<?php include 'lib.php'; include 'includes/db.php'; include 'includes/player_alias.php'; if (array_key_exists('id', $_GET)) { $player_id = $_GET['id']; } $player_ids = alias_pid($player_id); $where = pid2where($player_ids); $rounds = query_as_array("SELECT\n\t`creator_nick`, `creator_id`, `creator_score`,\n\t`joiner_nick`, `joiner_id`, `joiner_score`, \n\t`tournament`\nFROM `round` WHERE {$where}"); if (count($rounds) < 1) { die('No game found for that player'); } $self_nicks = array(); foreach ($rounds as $round) { if (array_search($round->creator_id, $player_ids) !== false) { $self_nick = $round->creator_nick; $opponent_id = $round->joiner_id; } else { if (array_search($round->joiner_id, $player_ids) !== false) { $self_nick = $round->joiner_nick; $opponent_id = $round->creator_id; } else { echo $round->creator_id . ' ' . $round->creator_nick . ' ' . $round->joiner_nick . ' ' . $round->joiner_id . '<br>'; } } if ($opponent_id == '') { continue; } if (array_search($self_nick, $self_nicks) === false) {
">Import from <?php echo $source; ?> Sitemap</a> <table> <tr> <th>DB se</th> <th>DB sea</th> <th>DB name</th> <th>MCI se</th> <th>MCI name</th> <th>Comment</th> </tr> <?php $db_exts = query_as_array("SELECT * FROM extension ORDER BY release_date;"); foreach ($db_exts as $db_i => $db_ext) { foreach ($exts as $mci_i => $mci_ext) { if (strtoupper($db_ext->se) == $mci_ext->code || strtoupper($db_ext->sea) == $mci_ext->code) { echo ' <tr>'; echo ' <td>' . $db_ext->se . '</td>'; echo ' <td>' . $db_ext->sea . '</td>'; echo ' <td>' . $db_ext->name . '</td>'; echo ' <td>' . $mci_ext->code . '</td>'; echo ' <td>' . $mci_ext->name . '</td>'; if ($db_ext->name != $mci_ext->name) { echo ' <td>Non identical names</td>'; } else { echo ' <td>All OK</td>'; } echo ' </tr>';
$mcicode = $arr['sea']; } else { $mcicode = $arr['se']; } $mcicode = strtolower($mcicode); echo " <tr>\n"; echo ' <td><a title="Open extension\'s admin page" href="/admin/cards/extension.php?ext=' . $arr['se'] . '">' . $arr['se'] . "</a></td>\n"; echo ' <td><a title="Open extension on MCI" href="http://magiccards.info/' . $mcicode . '/en.html">' . $arr['name'] . "</a></td>\n"; echo " <td>{$nbcards}</td>\n"; foreach ($langs as $code => $lang) { if ($code == 'en') { continue; } $nbtranslations = 0; foreach ($links as $link) { $langlink = query_as_array("SELECT * FROM cardname WHERE `cardname`.`card_id` = " . $link->card . " AND `lang` = '{$code}' "); if (count($langlink) > 0) { $nbtranslations++; } } $text = $nbtranslations; if ($nbtranslations == $nbcards) { $class = 'yes'; } else { if ($nbtranslations == 0) { $class = 'no'; } else { $class = 'little'; } } echo " <td class=\"{$class}\">{$text}</td>\n";
<?php if (array_key_exists('ext', $_GET)) { include '../../../lib.php'; include '../../../includes/db.php'; include '../../../includes/card.php'; $connec = card_connect(); $ext = param_or_die($_GET, 'ext'); $rarity = param($_GET, 'rarity', false); $text = param($_GET, 'text', false); $where = ''; if ($rarity) { $where .= 'AND `card_ext`.`rarity` = \'' . $rarity . '\' '; } if ($text) { $where .= 'AND `card`.`text` LIKE \'%' . $text . '%\' '; } die(json_encode(query_as_array("SELECT * FROM card_ext, card WHERE `card_ext`.`ext` = '{$ext}' AND `card`.`id` = `card_ext`.`card` {$where} ORDER BY `card`.`name`", 'Card list', $connec))); } else { die("{'msg' : 'No ext in param'}"); }