Repacker implemented
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
require_once "libraries/utils.php";
|
||||||
// todo: make it work correctly on mac & linux (case sensitivity on deletion)
|
// todo: make it work correctly on mac & linux (case sensitivity on deletion)
|
||||||
class optimizer
|
class optimizer
|
||||||
{
|
{
|
||||||
@@ -254,4 +255,31 @@ class optimizer
|
|||||||
if (file_exists($file)) unlink($file);
|
if (file_exists($file)) unlink($file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function repack(osu_library $library, string $key) : string
|
||||||
|
{
|
||||||
|
$path = $library->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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+1
-12
@@ -17,7 +17,7 @@ class utils
|
|||||||
{
|
{
|
||||||
if (is_dir($file))
|
if (is_dir($file))
|
||||||
{
|
{
|
||||||
recursive_zip_map($zip, $root, $file);
|
self::recursive_zip_map($zip, $root, $file);
|
||||||
}
|
}
|
||||||
else
|
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
|
|
||||||
}
|
}
|
||||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
@@ -45,6 +45,13 @@ if ($display == "main")
|
|||||||
redirect("./");
|
redirect("./");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($_GET["repack"]) && !empty($_GET["key"]))
|
||||||
|
{
|
||||||
|
$key = $_GET["key"];
|
||||||
|
$dl = @optimizer::repack($lib, $key);
|
||||||
|
redirect("./" . $dl);
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($_GET["blacken"]))
|
if (isset($_GET["blacken"]))
|
||||||
{
|
{
|
||||||
@optimizer::blacken_backgrounds($lib);
|
@optimizer::blacken_backgrounds($lib);
|
||||||
|
|||||||
@@ -1,30 +1,86 @@
|
|||||||
var xmlhttp = new XMLHttpRequest();
|
var xmlhttp = new XMLHttpRequest();
|
||||||
var page = 1;
|
var page = 1;
|
||||||
var url = "./splitter.php?format=json&page=" + page.toString();
|
var url = "./splitter.php?format=json&page=";
|
||||||
|
updateBrowser();
|
||||||
|
|
||||||
|
|
||||||
xmlhttp.onreadystatechange = function() {
|
xmlhttp.onreadystatechange = function() {
|
||||||
// done & success
|
// done & success
|
||||||
if (this.readyState == 4 && this.status == 200) {
|
if (this.readyState == 4 && this.status == 200) {
|
||||||
var result = JSON.parse(this.responseText);
|
var result = JSON.parse(this.responseText);
|
||||||
alert(result);
|
|
||||||
changeBrowser(result);
|
changeBrowser(result);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
xmlhttp.open("GET", url, true);
|
function requestPage(uri) {
|
||||||
xmlhttp.send();
|
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)
|
function changeBrowser(mapsets)
|
||||||
{
|
{
|
||||||
var browser = document.getElementById("browser");
|
var browser = document.getElementById("browser");
|
||||||
|
|
||||||
var output = "";
|
var output = "<div>Page " + page.toString() + "</div>";
|
||||||
|
|
||||||
var template = "<div class=\"map\"><p class=\"map-title\">{{ MAP_TITLE }}</p></div>";
|
var mapsetTemplate = `{{ MAIN_BROWSER_TEMPLATE_MAPSET }}`;
|
||||||
for (var beatmap of mapsets.entries)
|
var template = `{{ MAIN_BROWSER_TEMPLATE_DIFFICULTY }}`;
|
||||||
|
for (var mapsetKey of Object.keys(mapsets))
|
||||||
{
|
{
|
||||||
output += template.replaceAll(/\{\{ MAP_TITLE \}\}/g, beatmap.Metadata.Title);
|
var mapset = mapsets[mapsetKey];
|
||||||
|
var subOutput = "";
|
||||||
|
var summary = true;
|
||||||
|
|
||||||
|
for (var beatmapKey of Object.keys(mapset.difficulties))
|
||||||
|
{
|
||||||
|
var beatmap = mapset.difficulties[beatmapKey];
|
||||||
|
|
||||||
|
if (beatmap.Metadata && beatmap.Metadata.Title)
|
||||||
|
{
|
||||||
|
var path = mapset.path.toString() + "/" + beatmap.background.toString();
|
||||||
|
path = encodeURI(path);
|
||||||
|
path = path.replaceAll(/\+/g, "%2b");
|
||||||
|
line = template;
|
||||||
|
line = line.replaceAll(/\{\{ MAP_TITLE \}\}/g, beatmap.Metadata.Title);
|
||||||
|
line = line.replaceAll(/\{\{ MAP_ARTIST \}\}/g, beatmap.Metadata.Artist);
|
||||||
|
line = line.replaceAll(/\{\{ MAP_MAPPER \}\}/g, beatmap.Metadata.Creator);
|
||||||
|
line = line.replaceAll(/\{\{ MAP_DIFFICULTY \}\}/g, beatmap.Metadata.Version);
|
||||||
|
line = line.replaceAll(/\{\{ MAP_IMAGE \}\}/g, "./proxy.php?path=" + path);
|
||||||
|
|
||||||
|
if (summary)
|
||||||
|
{
|
||||||
|
summary = false;
|
||||||
|
line = "<summary>" + line + "</summary>";
|
||||||
|
}
|
||||||
|
|
||||||
|
subOutput += line;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var uriSafeKey = mapset.key;
|
||||||
|
uriSafeKey = encodeURI(uriSafeKey);
|
||||||
|
uriSafeKey = uriSafeKey.replaceAll(/\+/g, "%2b");
|
||||||
|
subOutput = mapsetTemplate.replaceAll(/\{\{ MAP_DIFFICULTIES \}\}/g, subOutput);
|
||||||
|
subOutput = subOutput.replaceAll(/\{\{ MAPSET_KEY \}\}/g, uriSafeKey);
|
||||||
|
output += subOutput;
|
||||||
}
|
}
|
||||||
|
|
||||||
browser.innerHTML = output;
|
browser.innerHTML = output;
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<div class="map">
|
||||||
|
<div class="map-image">
|
||||||
|
<img src="\{\{ MAP_IMAGE \}\}" />
|
||||||
|
</div>
|
||||||
|
<div class="map-details">
|
||||||
|
<p class="map-title">\{\{ MAP_TITLE \}\}</p>
|
||||||
|
<p class="map-artist">\{\{ MAP_ARTIST \}\}</p>
|
||||||
|
<p class="map-mapper">\{\{ MAP_MAPPER \}\}</p>
|
||||||
|
<p class="map-difficulty">\{\{ MAP_DIFFICULTY \}\}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<div class="mapset-div">
|
||||||
|
<details class="mapset">
|
||||||
|
\{\{ MAP_DIFFICULTIES \}\}
|
||||||
|
</details>
|
||||||
|
<a href="./?repack&key=\{\{ MAPSET_KEY \}\}">REPACK</a>
|
||||||
|
</div>
|
||||||
+3
-1
@@ -15,7 +15,9 @@
|
|||||||
<div class="options">{{ MAIN_OPTIONS }}</div>
|
<div class="options">{{ MAIN_OPTIONS }}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="main-item">
|
<div class="main-item">
|
||||||
<h2>Browser</h2>
|
<h2 id="a">Browser</h2>
|
||||||
|
<a onclick="prevPage()">[ Previous ]</a>
|
||||||
|
<a onclick="nextPage()">[ Next ]</a>
|
||||||
<div id="browser" class="browser">
|
<div id="browser" class="browser">
|
||||||
<!-- todo JS -->
|
<!-- todo JS -->
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+47
-1
@@ -11,9 +11,10 @@ html {
|
|||||||
margin: 5px 0;
|
margin: 5px 0;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
a:link, a:hover, a:active, a:visited {
|
a, a:link, a:hover, a:active, a:visited {
|
||||||
color: HotPink;
|
color: HotPink;
|
||||||
text-decoration: inherit;
|
text-decoration: inherit;
|
||||||
|
cursor:pointer;
|
||||||
}
|
}
|
||||||
.small-background {
|
.small-background {
|
||||||
max-height: 100px;
|
max-height: 100px;
|
||||||
@@ -64,4 +65,49 @@ a:link, a:hover, a:active, a:visited {
|
|||||||
.main-item>h2, .main-item>h3 {
|
.main-item>h2, .main-item>h3 {
|
||||||
margin: 5px;
|
margin: 5px;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
|
}
|
||||||
|
.map {
|
||||||
|
border: 1px solid white;
|
||||||
|
padding: 10px;
|
||||||
|
margin: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.map p {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
.map-title {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
.map-artist, .map-mapper {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
.map-artist::after {
|
||||||
|
content: ' /';
|
||||||
|
}
|
||||||
|
.map-mapper::before {
|
||||||
|
content: '/ ';
|
||||||
|
}
|
||||||
|
.map>div {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
.map-image img {
|
||||||
|
max-height: 64px;
|
||||||
|
max-width: 64px;
|
||||||
|
}
|
||||||
|
.map-details {
|
||||||
|
display: inline-block;
|
||||||
|
vertical-align: top;
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
details.mapset summary::-webkit-details-marker {
|
||||||
|
display:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mapset[open] .map {
|
||||||
|
background-color: #333333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mapset[open] summary .map {
|
||||||
|
background-color: #444444;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user