6 mysql_connect(DB_HOST
, DB_USER
, DB_PASS
);
7 mysql_select_db(DB_NAME
);
11 $id = (int)$_REQUEST['id'];
13 $id = 0; // show first tree by default
17 'VW' => null, # whole board visible
18 'SO' => 'The Depths of Internet', # source
21 'SZ' => 19, # board size
23 'ST' => 0, # variation display contorl
26 'GN' => 'Open Joseki Dictionary (until someone thinks of a cooler name)',
27 'CP' => 'Public Domain for now',
28 'GC' => 'Surely this is gonna be the next big thing in Go!');
32 function get_sgf_nodes($version)
34 $sgf_query = mysql_query("SELECT code, value FROM sgf_node WHERE tnode = '$version'");
35 $nodes = array('_V' => $version);
36 while ($node = mysql_fetch_assoc($sgf_query)) {
37 if ($nodes[$node['code']]) {
38 if (is_array($nodes[$node['code']])) {
39 array_push($nodes[$node['code']], $node['value']);
41 $nodes[$node['code']] = array($nodes[$node['code']], $node['value']);
44 $nodes[$node['code']] = $node['value'];
51 $tree_query = mysql_query("SELECT tn.id AS id, tn.parent AS parent, tna.id AS version, tna.editorial AS editorial
53 LEFT JOIN tree_node_archive AS tna ON tna.id = tn.version
54 WHERE IFNULL(tn.parent, 0) = '".mysql_real_escape_string($id)."'");
57 echo "Error loading game data.";
59 while ($node = mysql_fetch_assoc($tree_query)) {
60 $tree['id'] = $node['id'];
61 $tree['parent'] = $node['parent']; if ($tree['parent'] == null) $tree['parent'] = 0;
62 $tree['nodes'] = array(array_merge($sgf_start, array_merge(array('_I' => $node['id'], 'C' => $node['editorial']), get_sgf_nodes($node['version']))));
63 $tree['trees'] = array();
66 $json = new Services_JSON();
67 echo $json->encode(array(