Пример #1
0
<?php

// Play a game previously created, both players must have registered
include 'lib.php';
include 'includes/db.php';
// Guess game data by comparing client data with mysql data
$id = param_or_die($_GET, 'id');
$replay = param($_GET, 'replay', 0);
// Defaults to no replay, may be changed by tournament status
$row = $db->select("SELECT * FROM `round` WHERE `id` = '{$id}'");
$row = $row[0];
$client_status = 'Unknown';
// Is client creator, joiner, goldfish, or spectactor ?
$goldfish = 'false';
$creator = 'false';
$spectactor = 'false';
$spectactor_id = '';
if ($player_id == $row->joiner_id && $player_id != $row->creator_id) {
    // I am joiner but not a goldfish
    $client_status = 'Joiner';
    // Me : joiner
    $player_nick = $row->joiner_nick;
    $player_avatar = $row->joiner_avatar;
    $player_score = $row->joiner_score;
    // My opponent : creator
    $opponent_nick = $row->creator_nick;
    $opponent_id = $row->creator_id;
    $opponent_avatar = $row->creator_avatar;
    $opponent_score = $row->creator_score;
} else {
    // I'm not a joiner (creator, spectactor) or a goldfish
Пример #2
0
<?php

include_once 'lib.php';
$ext = param_or_die($_GET, 'ext');
html_head('Admin > Cards > Extension', array('style.css', 'admin.css', 'admin_extension.css'), array('lib/jquery.js', 'html.js', 'math.js', 'stats.js', 'lib/Flotr2/flotr2.min.js', 'admin/extension.js'));
?>

 <body>
<?php 
html_menu();
?>
  <div class="section">
<?php 
$query = query("SELECT * FROM extension WHERE `se` = '{$ext}' ; ");
if ($arr = mysql_fetch_array($query)) {
    $ext_bdd = $arr;
    // Backup first extension line (normally only 1)
    echo '  <h1>' . $ext . ' - ' . $ext_bdd['name'] . ' (#' . $ext_bdd['id'] . ')</h1>';
    echo '  <input id="ext" type="hidden" value="' . $ext_bdd['id'] . '">';
}
?>
  <a href="extensions.php">Return to extension list</a>

  <form id="update_ext" action="json/extension.php">
   <input type="hidden" name="ext_id" value="<?php 
echo $ext_bdd['id'];
?>
">
    Code : <input type="text" name="se" size="4" value="<?php 
echo $ext_bdd['se'];
?>
Пример #3
0
<?php

include '../lib.php';
$id = intval(param_or_die($_GET, 'id'));
$pid = param($_GET, 'pid', '');
html_head('Building #' . $id, array('style.css', 'options.css', 'menu.css', 'tournament.css', 'build.css'), array('lib/Flotr2/flotr2.min.js', 'html.js', 'math.js', 'image.js', 'deck.js', 'options.js', 'stats.js', 'websockets.js', 'menu.js', 'spectactor.js', 'tournament/lib.js', 'tournament/limited.js', 'tournament/build.js', '../variables.js.php'));
?>
 <body onload="start(<?php 
echo $id;
?>
, '<?php 
echo $pid;
?>
')">
  <div id="info" class="section">
   <input id="timeleft" type="text" value="Initializing" disabled="disabled" title="Time left for building" size="8"><br>
   <label title="Tournament starts if every player check this box before timer ends"><input id="ready" type="checkbox" disabled="disabled">I'm ready</label>
  </div>

  <div id="stats" class="section">
   <h2>Stats</h2>
   <label><input id="stats_side" type="checkbox">Stats side</label>
   <div id="stats_graphs"></div>
  </div>

  <div id="selectors" class="section"></div>

  <div id="div_side" class="section">
   <h1>Sideboard <?php 
echo ws_indicator();
?>
Пример #4
0
<?php

include '../../lib.php';
include '../../includes/db.php';
if (!array_key_exists('login', $_SESSION) || !array_key_exists('password', $_SESSION)) {
    die('{"msg": "No login or password in session"}');
}
$result = new stdClass();
$json = param_or_die($_POST, 'json');
$email = param_or_die($_SESSION, 'login');
$password = param_or_die($_SESSION, 'password');
$q = query("SELECT `password`, `content` FROM `profile` WHERE `email` = '{$email}' ;");
if (mysql_num_rows($q) == 0) {
    $result->msg = 'Account does not exist. ';
} else {
    if (mysql_num_rows($q) == 1) {
        if ($profile = mysql_fetch_object($q)) {
            if ($password != $profile->password) {
                $result->msg .= 'Wrong password. ';
            } else {
                // Merge stored object and param
                $json = json_decode($json);
                $content = json_decode($profile->content);
                $log = 'Changes' . "\n";
                foreach ($json as $k => $v) {
                    if ($v == null) {
                        unset($content->{$k});
                        $log .= $k . ' deleted' . "\n";
                    } else {
                        if (property_exists($content, $k)) {
                            $log .= $k . ' : ' . $content->{$k} . ' -> ' . $v . "\n";
Пример #5
0
<?php

include_once 'lib.php';
require_once '../../includes/classes/deck.php';
ini_set('max_execution_time', 0);
ini_set('memory_limit', '256M');
$name = param_or_die($_GET, 'name');
$format = param($_GET, 'format', '');
$date = param($_GET, 'date', '');
$exts = param($_GET, 'exts', '');
$mask = param($_GET, 'mask', '');
$imask = param($_GET, 'imask', '');
if (!ereg('([0-9]{4})-([0-9]{2})-([0-9]{2})', $date)) {
    $date = '';
}
$folder = '../../stats/';
$file = $folder . $name;
if ($exts == '') {
    $exts = array();
} else {
    $exts = explode(',', $exts);
    foreach ($exts as $i => $ext) {
        $exts[$i] = trim($ext);
    }
}
$card_connection = card_connect();
// All decks from all sealed events
$q = "SELECT\n\t`tournament`.`id`,\n\t`tournament`.`name`,\n\t`tournament`.`creation_date`,\n\t`tournament`.`data`\nFROM\n\t`tournament`\nWHERE\n\t`tournament`.`min_players` > 1\n\tAND `tournament`.`status` = 6";
echo '<ul>';
if ($date != '') {
    $q .= " AND `tournament`.`creation_date` > '{$date}'";
Пример #6
0
<?php

if (array_key_exists('ext', $_GET) && array_key_exists('card', $_GET)) {
    include '../../../lib.php';
    include '../../../includes/db.php';
    include '../../../includes/card.php';
    $connec = card_connect();
    $ext = param_or_die($_GET, 'ext');
    $card = param_or_die($_GET, 'card');
    $nbpics = param($_GET, 'nbpics', 1);
    $rarity = param($_GET, 'rarity', 'C');
    query("UPDATE `card_ext` SET `nbpics` = '{$nbpics}', `rarity` = '{$rarity}' WHERE `card`={$card} AND `ext`={$ext} ; ", 'Card link updating', $connec);
    die('{"nb": "' . mysql_affected_rows() . '"}');
} else {
    die("{'msg' : 'No ID in param'}");
}
Пример #7
0
<?php

// http://magic.wizards.com/en/MTGO/articles/archive/magic-online-legacy-cube-card-list
include_once 'lib.php';
$url = param_or_die($_GET, 'url');
$html = cache_get($url, 'cache/mtgo_cube', false);
$regex = '@<a href=".*?" class="autocard-link" data-image-url=".*?">(?<name>.*?)</a>@';
if (preg_match_all($regex, $html, $cards, PREG_SET_ORDER) < 1) {
    die('No card found');
}
header('Content-Disposition: attachment; filename=OMC.txt');
foreach ($cards as $card) {
    $name = $card['name'];
    $name = html_entity_decode($name);
    // Far &amp; Away
    $name = str_replace('&', '/', $name);
    echo $name . "\n";
}
Пример #8
0
<?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));
Пример #9
0
<?php

include '../../lib.php';
include '../../includes/db.php';
$result = new stdClass();
$email = param_or_die($_GET, 'email');
$password = md5(param_or_die($_GET, 'password'));
$remember = param_or_die($_GET, 'remember');
$q = query("SELECT `password`, `content` FROM `profile` WHERE `email` = '{$email}' ;");
if (mysql_num_rows($q) == 0) {
    $result->msg = 'E-mail not found, please check it or create an account' . "\n";
} else {
    if (mysql_num_rows($q) == 1) {
        if ($o = mysql_fetch_object($q)) {
            if ($o->password == $password) {
                $result->recieve = $o->content;
                $_SESSION['login'] = $email;
                $_SESSION['password'] = $password;
                setcookie('login', $email, $cookie_expire, '/');
                if ($remember == 'true') {
                    setcookie('password', $password, $cookie_expire, '/');
                } else {
                    setcookie('password', false, 0, '/');
                }
            } else {
                $result->msg = 'Wrong password for adress ' . $email;
            }
        } else {
            $result->msg = 'Profile unfetchable';
        }
    } else {
<?php

include '../lib.php';
include '../includes/db.php';
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);
Пример #11
0
<?php

if (array_key_exists('card_id', $_GET)) {
    include '../../../lib.php';
    include '../../../includes/db.php';
    include '../../../includes/card.php';
    $connec = card_connect();
    $card_id = param_or_die($_GET, 'card_id');
    $fixed_attrs = param_or_die($_GET, 'fixed_attrs');
    $card = array();
    $card['name'] = param_or_die($_GET, 'card_name');
    $card['cost'] = param_or_die($_GET, 'cost');
    $card['types'] = param_or_die($_GET, 'types');
    $card['text'] = param_or_die($_GET, 'text');
    $card['text'] = stripslashes($card['text']);
    $card['text'] = card_text_sanitize($card['text']);
    $attrs = new attrs($card);
    $attrs = JSON_encode($attrs);
    $query = query("UPDATE \n\t\t`card`\n\tSET\n\t\t`cost` = '" . $card['cost'] . "', \n\t\t`name` = '" . mysql_real_escape_string($card['name']) . "', \n\t\t`types` = '" . $card['types'] . "', \n\t\t`text` = '" . mysql_real_escape_string($card['text']) . "', \n\t\t`attrs` = '" . mysql_real_escape_string($attrs) . "',\n\t\t`fixed_attrs` = '" . mysql_real_escape_string($fixed_attrs) . "' \n\tWHERE\n\t\t`id` = {$card_id}\n\t; ", 'Card update', $connec);
    die('{"nb": "' . mysql_affected_rows() . '"}');
} else {
    die("{'msg' : 'No ID in param'}");
}
Пример #12
0
html_head('Admin > Player > Merge', array('style.css', 'admin.css'), array('player_merge.js'));
$player_id = param_or_die($_GET, 'player_id');
?>

 <body>
<?php 
html_menu();
?>

  <div class="section">
   <h1>Identities split</h1>
<?php 
if (isset($_GET['nick'])) {
    $nick = param_or_die($_GET, 'nick');
    $from = $player_id;
    $to = param_or_die($_GET, 'id_to');
    if ($to == '') {
        die('A "to" value is required');
    }
    echo 'Splitting ' . $player_id . ' / ' . $nick . ' into ' . $to . ' :';
    $rounds = query_as_array("\nSELECT id, tournament\nFROM `round`\nWHERE\n\t( `creator_id` = '{$player_id}' AND `creator_nick` = '{$nick}' )\n\tOR ( `joiner_id` = '{$player_id}' AND `joiner_nick` = '{$nick}' )\n");
    $updated = array('tour' => 0, 'notour' => 0, 'registrations' => 0, 'games' => 0, 'actions' => 0, 'tournament_log' => 0);
    foreach ($rounds as $round) {
        $rid = $round->id;
        $tid = $round->tournament;
        if ($tid == '0') {
            $updated['notour']++;
        } else {
            $updated['tour']++;
            // Registrations
            query("UPDATE `registration` SET `player_id` = '{$to}' WHERE `player_id` = '{$from}' AND `tournament_id` = '{$tid}'; ");
Пример #13
0
<?php

if (array_key_exists('ext_id', $_GET)) {
    include '../../../lib.php';
    include '../../../includes/db.php';
    include '../../../includes/card.php';
    $connec = card_connect();
    $ext_id = param_or_die($_GET, 'ext_id');
    $name = param_or_die($_GET, 'name');
    $se = param_or_die($_GET, 'se');
    $sea = param_or_die($_GET, 'sea');
    $priority = param_or_die($_GET, 'priority');
    $release_date = param_or_die($_GET, 'release_date');
    $bloc = param_or_die($_GET, 'bloc');
    $data = param_or_die($_GET, 'data');
    $updates = array();
    if ($se != '') {
        $updates[] = "`se` = '" . mysql_real_escape_string($se) . "'";
    }
    if ($sea != '') {
        $updates[] = "`sea` = '" . mysql_real_escape_string($sea) . "'";
    }
    if ($se != '') {
        $updates[] = "`name` = '" . mysql_real_escape_string($name) . "'";
    }
    if (intval($priority) . '' == $priority) {
        $updates[] = "`priority` = '{$priority}'";
    }
    if (preg_match('/^\\d{4}-\\d{2}-\\d{2}$/', $release_date, $matches)) {
        $updates[] = "`release_date` = '{$release_date}'";
    }
Пример #14
0
?>
</option>
     </optgroup>
    </select>

    <input type="date" name="date" placeholder="Starting date">
    <input type="text" name="exts" placeholder="EXT1,EXT2,...">
    <input type="text" name="mask" placeholder="Name mask">
    <input type="text" name="imask" placeholder="Name ignore mask">
    <input type="submit" value="Create">
   </form>

<?php 
$dir = '../stats/';
if (array_key_exists('delete_report', $_GET)) {
    $spl = split("\\|", param_or_die($_GET, 'name'));
    $name = $spl[0];
    if (unlink($dir . $name)) {
        echo "<p>Deleted {$name}</p>";
    } else {
        echo "<p>Can't delete {$name}</p>";
    }
}
$reports = array_reverse(sorted_scandir($dir));
if (count($reports) > 0) {
    ?>
     <form>
     Load : <select id="report_list" name="name">
     <option selected disabled>Select a report</option>
<?php 
    foreach ($reports as $r) {