<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE);
$debug_mode = (isset($_GET['d'])) ? $_GET['d'] : 0;
$debug_mode = (isset($_POST['d'])) ? $_POST['d'] : $debug_mode;
$eng_mode = isset($_GET['en']);
include "debug.php";
include "node_fixed.php";

$eng = ($eng_mode) ? "en" : "";
$line_width   = "style='width: 50px;'";
$node_v_width = "style='width: 64px;'";
include "match_fixed.php";

$open = (isset($_GET['open']));

$num = 7;
$sin = 0;

include "sub_players.php";

// 選手登録
$playersfile = "data/players";
//$playersfile = "../m/data/players";
$players = read_players($playersfile);
$m = new match();
reg_players($m, $players);
//$m->p_max = 32;
//$m->seed[4] = 2;
$m->seed[5] = 4;
$m->p_max = 60;

// トーナメント表のデータを作る
$m->make_node_top($sin);

// 試合順の調整
$m->adjust_listing_of_match(4);

// result (clear)
$resultsfile = "data/result.txt";
//$resultsfile = "../m/data/result.txt";
include "sub_results.php";
//if($open)
{
	// 結果を反映する
	$results = read_results($resultsfile);
	reg_results($m, $results);
}

// トーナメント表を作る
$tree = draw_node($m, $m->nodes[0]);

$contents_width = "style='width: 1900px;'";
//$contents_width = "style='width: 1150px;'";
$title = "TOKYO OPEN";
$date = "2025.2.8-2025.2.9";

$reload = ($eng == 'en') ? 'reload' : '画面更新';

print <<<EOH
<!DOCTYPE html>
<html lang="ja">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Tokyo Open 2025</title>

    <!-- Bootstrap -->
    <link href="css/bootstrap.css?x=2" rel="stylesheet">

    <!-- 3C Scoreboard Tourmant -->
    <link rel="stylesheet" href="css/node.css?x=f" >

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <link href="https://fonts.googleapis.com/css?family=Tangerine:700" rel="stylesheet">
  </head>
  <body>
    <div id="contents" $contents_width>
      <div id="header">
		<table><tr><td rowspan="2">
			<div class="xl388">{$title}</div></td>
				<td width="10px"></td>
				<td><div class="xl389"> &nbsp; 2025 &nbsp; 3-CUSHION &nbsp; TOURNAMENT</div></td></tr>
			<tr><td></td>
				<td><div class="xl389 font55">第31回 東京ＯＰＥＮ　～オープン戦への挑戦～</div></td></tr>
		</table>
	<div class="text-right">{$date}</div>
      </div>

	<div class="text-left no_print"><a href="http://plus2.xyz/tokyo2025/index.php?en">English</a> | <a href="http://plus2.xyz/tokyo2025/index.php">Japanese</a> | <a href="http://plus2.xyz/tokyo2025/index.php?$eng">$reload</a></div>

$tree
      <div id="footer">
        <span><img src="2025_plus2_banner_TokyoOP.jpg" class="footer-logo"></span>
      </div>
    </div>

    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="/js/bootstrap.min.js"></script>
    <script src="/js/node.js"></script>
  </body>
</html>

EOH;

