diff --git a/tables.sql b/tables.sql index 7d1fa2b..91000e8 100644 --- a/tables.sql +++ b/tables.sql @@ -465,3 +465,24 @@ CREATE TABLE `amoj_news` ( `text` text(65535) NOT NULL, PRIMARY KEY (`id`) ); + +# Zen Nihon GT Senshuken (AGTJ) +CREATE TABLE `agtj_ghosts` ( + `course` tinyint(3) unsigned NOT NULL, + `weather` tinyint(3) unsigned NOT NULL, + `car` tinyint(3) unsigned NOT NULL, + `trans` tinyint(3) unsigned NOT NULL, + `gear` tinyint(3) unsigned NOT NULL, + `steer` tinyint(3) unsigned NOT NULL, + `brake` tinyint(3) unsigned NOT NULL, + `tire` tinyint(3) unsigned NOT NULL, + `aero` tinyint(3) unsigned NOT NULL, + `excrs` tinyint(3) unsigned NOT NULL, + `handicap` smallint(5) unsigned NOT NULL, + `name` binary(22) NOT NULL, + `time` int(11) unsigned NOT NULL, + `date` datetime NOT NULL, + `id` int(11) unsigned NOT NULL, + `input_data` blob(12124), + `dl_ok` datetime +); diff --git a/web/cgb/download/18/AGB-AMSJ/30.something.cgb b/web/cgb/download/18/AGB-AMSJ/30.something.cgb new file mode 100644 index 0000000..e69de29 diff --git a/web/cgb/download/18/AGB-AMSJ/menu.txt b/web/cgb/download/18/AGB-AMSJ/menu.txt new file mode 100644 index 0000000..405c521 --- /dev/null +++ b/web/cgb/download/18/AGB-AMSJ/menu.txt @@ -0,0 +1 @@ +30.something.cgb \ No newline at end of file diff --git a/web/cgb/download/28/AGB-AGTJ/ghost.php b/web/cgb/download/28/AGB-AGTJ/ghost.php new file mode 100644 index 0000000..0d61cde --- /dev/null +++ b/web/cgb/download/28/AGB-AGTJ/ghost.php @@ -0,0 +1,26 @@ +prepare("select * from agtj_ghosts where dl_ok is not null and id = ? limit 1") + $stmt->bind_param("i", $id); + $result = fancy_get_result($stmt); + if (sizeof($result) == 0) { + http_response_code(404); + return; + } + + echo makeRankingEntry($result[0]); + echo $result[0]["input_data"]; +?> diff --git a/web/cgb/download/28/AGB-AGTJ/gtconfig.php b/web/cgb/download/28/AGB-AGTJ/gtconfig.php new file mode 100644 index 0000000..61c242f --- /dev/null +++ b/web/cgb/download/28/AGB-AGTJ/gtconfig.php @@ -0,0 +1,45 @@ +prepare("select count(*) from agtj_ghosts where (course = ? or course = ?) and dl_ok is not null limit 1"); + $stmt->bind_param("ii", $i, $i + 9); + } else { + $stmt = $db->prepare("select count(*) from agtj_ghosts where (course = 6 or course = 7 or course = 8 or course = 15 or course = 16 or course = 17) and dl_ok is not null and excrs = ? limit 1"); + $stmt->bind_param("i", $excrs); + } + $stmt->execute(); + $result = fancy_get_result($stmt); + $ghosts_avail &= ~($result["count(*)"] << $i); + } + echo pack("C", $ghosts_avail); + $cksum = $cksum + $ghosts_avail; + + echo pack("C", $excrs); + $cksum = $cksum + $excrs; + echo pack("C", $excrs); + $cksum = $cksum + $excrs; + + $ranking_prefix = "http://gameboy.datacenter.ne.jp/cgb/download?name=/01/AGB-AGTJ/kemco/"; + echo $ranking_prefix; + $i = 0; + while ($i < strlen($ranking_prefix)) { + $cksum = $cksum + ord($ranking_prefix[$i]); + $i++; + } + while ($i < 0xC0) { + echo "\0"; + $i++; + } + + echo pack("V", $cksum); +?> diff --git a/web/cgb/download/28/AGB-AGTJ/gtgst00.php b/web/cgb/download/28/AGB-AGTJ/gtgst00.php new file mode 100644 index 0000000..c0bca3d --- /dev/null +++ b/web/cgb/download/28/AGB-AGTJ/gtgst00.php @@ -0,0 +1,6 @@ + diff --git a/web/cgb/download/28/AGB-AGTJ/gtgst01.php b/web/cgb/download/28/AGB-AGTJ/gtgst01.php new file mode 100644 index 0000000..d1d6cdf --- /dev/null +++ b/web/cgb/download/28/AGB-AGTJ/gtgst01.php @@ -0,0 +1,6 @@ + diff --git a/web/cgb/download/28/AGB-AGTJ/gtgst02.php b/web/cgb/download/28/AGB-AGTJ/gtgst02.php new file mode 100644 index 0000000..83dbed7 --- /dev/null +++ b/web/cgb/download/28/AGB-AGTJ/gtgst02.php @@ -0,0 +1,6 @@ + diff --git a/web/cgb/download/28/AGB-AGTJ/gtgst03.php b/web/cgb/download/28/AGB-AGTJ/gtgst03.php new file mode 100644 index 0000000..3850fa3 --- /dev/null +++ b/web/cgb/download/28/AGB-AGTJ/gtgst03.php @@ -0,0 +1,6 @@ + diff --git a/web/cgb/download/28/AGB-AGTJ/gtgst04.php b/web/cgb/download/28/AGB-AGTJ/gtgst04.php new file mode 100644 index 0000000..664c578 --- /dev/null +++ b/web/cgb/download/28/AGB-AGTJ/gtgst04.php @@ -0,0 +1,6 @@ + diff --git a/web/cgb/download/28/AGB-AGTJ/gtgst05.php b/web/cgb/download/28/AGB-AGTJ/gtgst05.php new file mode 100644 index 0000000..d616d4e --- /dev/null +++ b/web/cgb/download/28/AGB-AGTJ/gtgst05.php @@ -0,0 +1,6 @@ + diff --git a/web/cgb/download/28/AGB-AGTJ/gtgst06.php b/web/cgb/download/28/AGB-AGTJ/gtgst06.php new file mode 100644 index 0000000..b4659a6 --- /dev/null +++ b/web/cgb/download/28/AGB-AGTJ/gtgst06.php @@ -0,0 +1,6 @@ + diff --git a/web/cgb/download/28/AGB-AGTJ/kemco/gtrk00.php b/web/cgb/download/28/AGB-AGTJ/kemco/gtrk00.php new file mode 100644 index 0000000..4db417e --- /dev/null +++ b/web/cgb/download/28/AGB-AGTJ/kemco/gtrk00.php @@ -0,0 +1,6 @@ + diff --git a/web/cgb/download/28/AGB-AGTJ/kemco/gtrk01.php b/web/cgb/download/28/AGB-AGTJ/kemco/gtrk01.php new file mode 100644 index 0000000..55baf6c --- /dev/null +++ b/web/cgb/download/28/AGB-AGTJ/kemco/gtrk01.php @@ -0,0 +1,6 @@ + diff --git a/web/cgb/download/28/AGB-AGTJ/kemco/gtrk02.php b/web/cgb/download/28/AGB-AGTJ/kemco/gtrk02.php new file mode 100644 index 0000000..682f648 --- /dev/null +++ b/web/cgb/download/28/AGB-AGTJ/kemco/gtrk02.php @@ -0,0 +1,6 @@ + diff --git a/web/cgb/download/28/AGB-AGTJ/kemco/gtrk03.php b/web/cgb/download/28/AGB-AGTJ/kemco/gtrk03.php new file mode 100644 index 0000000..4eb73c6 --- /dev/null +++ b/web/cgb/download/28/AGB-AGTJ/kemco/gtrk03.php @@ -0,0 +1,6 @@ + diff --git a/web/cgb/download/28/AGB-AGTJ/kemco/gtrk04.php b/web/cgb/download/28/AGB-AGTJ/kemco/gtrk04.php new file mode 100644 index 0000000..982c154 --- /dev/null +++ b/web/cgb/download/28/AGB-AGTJ/kemco/gtrk04.php @@ -0,0 +1,6 @@ + diff --git a/web/cgb/download/28/AGB-AGTJ/kemco/gtrk05.php b/web/cgb/download/28/AGB-AGTJ/kemco/gtrk05.php new file mode 100644 index 0000000..cb7cca5 --- /dev/null +++ b/web/cgb/download/28/AGB-AGTJ/kemco/gtrk05.php @@ -0,0 +1,6 @@ + diff --git a/web/cgb/download/28/AGB-AGTJ/kemco/gtrk06.php b/web/cgb/download/28/AGB-AGTJ/kemco/gtrk06.php new file mode 100644 index 0000000..422315b --- /dev/null +++ b/web/cgb/download/28/AGB-AGTJ/kemco/gtrk06.php @@ -0,0 +1,6 @@ + diff --git a/web/cgb/download/28/AGB-AGTJ/kemco/gtrkconfig.php b/web/cgb/download/28/AGB-AGTJ/kemco/gtrkconfig.php new file mode 100644 index 0000000..174cdc3 --- /dev/null +++ b/web/cgb/download/28/AGB-AGTJ/kemco/gtrkconfig.php @@ -0,0 +1,21 @@ +prepare("select count(*) from agtj_ghosts where course = ? or course = ? limit 1"); + $stmt->bind_param("ii", $i, $i + 9); + } else { + $stmt = $db->prepare("select count(*) from agtj_ghosts where (course = 6 or course = 7 or course = 8 or course = 15 or course = 16 or course = 17) and excrs = ? limit 1"); + $stmt->bind_param("i", $excrs); + } + $stmt->execute(); + $result = fancy_get_result($stmt); + $rankings_avail &= ~($result["count(*)"] << $i); + } + echo pack("C", $rankings_avail)."\0\0\0"; + echo pack("V", $rankings_avail); +?> diff --git a/web/cgb/download/A4/AGB-AMBJ/200.member.cgb b/web/cgb/download/A4/AGB-AMBJ/200.member.cgb new file mode 100644 index 0000000..63b19e8 Binary files /dev/null and b/web/cgb/download/A4/AGB-AMBJ/200.member.cgb differ diff --git a/web/cgb/download/A4/AGB-AMBJ/counter.cgb b/web/cgb/download/A4/AGB-AMBJ/counter.cgb new file mode 100644 index 0000000..6b2aaa7 --- /dev/null +++ b/web/cgb/download/A4/AGB-AMBJ/counter.cgb @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/web/cgb/download/E5/AGB-ADRJ/10.dora_key.cgb b/web/cgb/download/E5/AGB-ADRJ/10.dora_key.cgb new file mode 100644 index 0000000..e69de29 diff --git a/web/cgb/mario_kart.php b/web/cgb/mario_kart.php index f035fd0..8e31a7f 100644 --- a/web/cgb/mario_kart.php +++ b/web/cgb/mario_kart.php @@ -72,8 +72,10 @@ function decodePlayerID($myid) { } function checkPlayerID($myid, $dion_id) { + $config = getConfig(); + $decoded = decodePlayerID($myid); - if (!$decoded["valid"] || $decoded["email_svr"] !== "on") { + if (!$decoded["valid"] || $decoded["email_svr"] !== substr($config["email_domain_dion"], 2, 2)) { return false; } diff --git a/web/cgb/monopoly.php b/web/cgb/monopoly.php index 788db91..eb7fd63 100644 --- a/web/cgb/monopoly.php +++ b/web/cgb/monopoly.php @@ -1,10 +1,17 @@ \ No newline at end of file diff --git a/web/cgb/upload/A7/AGB-AMOJ/0.regist.php b/web/cgb/upload/A7/AGB-AMOJ/0.regist.php index e547ce0..7b589f6 100644 --- a/web/cgb/upload/A7/AGB-AMOJ/0.regist.php +++ b/web/cgb/upload/A7/AGB-AMOJ/0.regist.php @@ -1,6 +1,9 @@ begin_transaction(); try { @@ -75,8 +76,11 @@ //http_response_code(400); return; } + if (empty($config["amoj_regist"])) { + $today = 0; + } $stmt = $db->prepare("update amoj_ranking set today = ?, today2 = ? where id = ?"); - $stmt->bind_param("iii", empty($config["amoj_regist"]) ? 0 : $today, $today, $result[0]["id"]); + $stmt->bind_param("iii", $today, $today2, $result[0]["id"]); $stmt->execute(); if (substr($config["amoj_regist"], 0, 1) === "h") { http_response_code(intval(substr($config["amoj_regist"], 1))); diff --git a/web/cgb/zen_nihon.php b/web/cgb/zen_nihon.php new file mode 100644 index 0000000..84c30d1 --- /dev/null +++ b/web/cgb/zen_nihon.php @@ -0,0 +1,145 @@ +>= 1; + if (realpath(__DIR__.DIRECTORY_SEPARATOR.sprintf("gtexcrs%03d.cgb", $excrs)) !== false) { + $excrs += $excrs_bit; + } else { + $excrs -= max($excrs_bit, 1); + } + } + return $excrs; + } + + function gtgst($course) { + $db = connectMySQL(); + if ($course != 6) { + $stmt = $db->prepare("select * from agtj_ghosts where (course = ? or course = ?) and dl_ok is not null order by dl_ok desc limit 30"); + $stmt->bind_param($course, $course + 9); + } else { + $stmt = $db->prepare("select * from agtj_ghosts where (course = 6 or course = 7 or course = 8 or course = 15 or course = 16 or course = 17) and dl_ok is not null and excrs = ? order by dl_ok desc limit 30"); + $stmt->bind_param(getExtraCourse()); + } + $stmt->execute(); + $result = fancy_get_result($stmt); + if (sizeof($result) == 0) { + http_response_code(404); + return; + } + + echo pack("v", (int)substr($result[0]["dl_ok"], 0, 4)); + echo pack("C", (int)substr($result[0]["dl_ok"], 5, 2)); + echo pack("C", (int)substr($result[0]["dl_ok"], 8, 2)); + echo pack("C", (int)substr($result[0]["dl_ok"], 11, 2)); + echo pack("C", (int)substr($result[0]["dl_ok"], 14, 2)); + echo pack("C", (int)substr($result[0]["dl_ok"], 17, 2)); + echo "\0"; + + for ($i = 0; $i < sizeof($result); $i++) { + echo makeRankingEntry($result[$i]); + $filename = sprintf("ghost.cgb&agtj=%08x", $result[$i]["id"]); + if ($result[$i]["price"] != 0) { + $filename = sprintf("%d", $result[$i]["price"]).".".$filename; + } + echo $filename; + for ($j = strlen($filename); $j < 32; $j++) { + echo "\0"; + } + } + for ($i = sizeof($result) * 84; $i < 2520; $i++) { + // 2520 = 30 * 84 + echo "\0"; + } + } + + function gtrk($course) { + $db = connectMySQL(); + if ($course != 6) { + $stmt = $db->prepare("select * from agtj_ghosts where course = ? or course = ? order by time desc limit 50"); + $stmt->bind_param($course, $course + 9); + } else { + $stmt = $db->prepare("select * from agtj_ghosts where (course = 6 or course = 7 or course = 8 or course = 15 or course = 16 or course = 17) and excrs = ? order by time desc limit 50"); + $stmt->bind_param(getExtraCourse()); + } + $stmt->execute(); + $result = fancy_get_result($stmt); + if (sizeof($result) == 0) { + http_response_code(404); + return; + } + + $date = $result[0]["date"]; + for ($i = 1; $i < sizeof($result); $i++) { + $date = max($date, $result[$i]["date"]); + } + $date_array = array( + (int)substr($date, 0, 4), + (int)substr($date, 5, 2), + (int)substr($date, 8, 2), + (int)substr($date, 11, 2) + 9, + (int)substr($date, 14, 2), + (int)substr($date, 17, 2) + ); + if ($date_array[3] >= 24) { + $date_array[3] -= 24; + $date_array[2]++; + } + if ($date_array[2] == cal_days_in_month(CAL_GREGORIAN, $date_array[1], $date_array[0]) + 1) { + $date_array[2] = 1; + $date_array[1]++; + } + if ($date_array[1] == 13) { + $date_array[1] = 1; + $date_array[0]++; + } + + echo pack("v", $date_array[0]); + echo pack("C", $date_array[1]); + echo pack("C", $date_array[2]); + echo pack("C", $date_array[3]); + echo pack("C", $date_array[4]); + echo pack("C", $date_array[5]); + echo "\0"; + + for ($i = 0; $i < sizeof($result); $i++) { + echo makeRankingEntry($result[$i]); + } + for ($i = sizeof($result) * 52; $i < 2600; $i++) { + // 2600 = 50 * 52 + echo "\0"; + } + } +?>