diff --git a/libraries/optimizer.php b/libraries/optimizer.php index afc9b22..2573536 100644 --- a/libraries/optimizer.php +++ b/libraries/optimizer.php @@ -1,4 +1,5 @@ get_library()[$key]["path"] ?? ""; + if (!file_exists($path)) return ""; + + $name = "session/osz/" . basename($path) . ".osz"; + if (file_exists($name)) return $name; + + $zip = new ZipArchive; + + try + { + $zip->open($name, ZipArchive::CREATE); + utils::recursive_zip_map($zip, $path, $path); + } + catch (Exception $e) + { + return ""; + } + finally + { + $zip->close(); + } + + return $name; + } } \ No newline at end of file diff --git a/libraries/utils.php b/libraries/utils.php index 7ade7c2..edcea09 100644 --- a/libraries/utils.php +++ b/libraries/utils.php @@ -17,7 +17,7 @@ class utils { if (is_dir($file)) { - recursive_zip_map($zip, $root, $file); + self::recursive_zip_map($zip, $root, $file); } else { @@ -26,15 +26,4 @@ class utils } } } - // $folder = $my_db[$beatmap_id]; - // $name = basename($folder) . ".osz"; - - // echo "Zipping " . $name; - - // $path = $collection_location . "/" . $name; - // $zip = new ZipArchive; - // $zip->open($path, ZipArchive::CREATE); - // echo "."; - - // recursive_zip_map($zip, $fol } \ No newline at end of file diff --git a/macska.jpg b/macska.jpg new file mode 100644 index 0000000..4be5ef6 Binary files /dev/null and b/macska.jpg differ diff --git a/main.php b/main.php index b314ee4..23600de 100644 --- a/main.php +++ b/main.php @@ -45,6 +45,13 @@ if ($display == "main") redirect("./"); } + if (isset($_GET["repack"]) && !empty($_GET["key"])) + { + $key = $_GET["key"]; + $dl = @optimizer::repack($lib, $key); + redirect("./" . $dl); + } + if (isset($_GET["blacken"])) { @optimizer::blacken_backgrounds($lib); diff --git a/templates/main-browser-script.js b/templates/main-browser-script.js index d5ff95e..52c7c1e 100644 --- a/templates/main-browser-script.js +++ b/templates/main-browser-script.js @@ -1,30 +1,86 @@ var xmlhttp = new XMLHttpRequest(); var page = 1; -var url = "./splitter.php?format=json&page=" + page.toString(); +var url = "./splitter.php?format=json&page="; +updateBrowser(); + xmlhttp.onreadystatechange = function() { // done & success if (this.readyState == 4 && this.status == 200) { var result = JSON.parse(this.responseText); - alert(result); changeBrowser(result); } }; -xmlhttp.open("GET", url, true); -xmlhttp.send(); +function requestPage(uri) { + xmlhttp.open("GET", uri, true); + xmlhttp.send(); +} + +function updateBrowser() { + requestPage(url + page.toString()); +} + + + +function prevPage() { + page -= 1; + if (page < 0) page = 0; + updateBrowser(); +} + +function nextPage() { + page += 1; + updateBrowser(); +} function changeBrowser(mapsets) { var browser = document.getElementById("browser"); - var output = ""; + var output = "
{{ MAP_TITLE }}
\{\{ MAP_TITLE \}\}
+\{\{ MAP_ARTIST \}\}
+\{\{ MAP_MAPPER \}\}
+\{\{ MAP_DIFFICULTY \}\}
+