Upload files to "/"

This commit is contained in:
Signal 2025-06-01 00:07:40 +00:00
parent be2e79385c
commit ec47e933fe
4 changed files with 1321 additions and 0 deletions

1252
init.lua Normal file

File diff suppressed because it is too large Load diff

2
mod.conf Normal file
View file

@ -0,0 +1,2 @@
name = libskinupload
optional_depends = unified_inventory, u_skins, mcl_skins, 3d_armor

2
settingtypes.txt Normal file
View file

@ -0,0 +1,2 @@
libskinupload.optimize_media (Optimize media load) bool true
libskinupload.allow_search (Allow skin search) bool true

65
uskins_import.php Normal file
View file

@ -0,0 +1,65 @@
<?php
// This PHP script can be used to import an existing u_skins library into libskinupload.
// To do that, set $uskins to the path to the u_skins mod to source from and $world to the path to the target world and run the script.
// The script assumes that you are using a fresh install of libskinupload, i.e. no skins have been uploaded yet.
$uskins = '';
$world = '';
if($uskins == '' or $world == '') {
exit('Make sure that $uskins and $world are set to the desired paths.');
}
$file = fopen("$world/libskinupload_meta.json", 'a');
fwrite($file, "{");
$lastid = 0;
foreach(glob("$uskins/textures/character_*.png") as $fname) {
if(preg_match('#/textures/character_(\d+)\.png#', $fname, $matches)) {
$id = $matches[1];
if(intval($id) > $lastid) $lastid = $id;
if($lastid != 0) fwrite($file, ",");
fwrite($file, "\"$id\":");
echo "Found skin ID $id:\n";
echo " |- Copying image file...\n";
copy($fname, "$world/libskinupload_skins/libskinupload_uploaded_skin_$id.png");
if(file_exists("$uskins/meta/character_$id.txt")) {
echo " |- Migrating meta...\n";
$meta = file_get_contents("$uskins/meta/character_$id.txt");
preg_match('#author = "([^"]+)"#', $meta, $author);
preg_match('#name = "([^"]+)"#', $meta, $name);
preg_match('#comment = "([^"]+)"#', $meta, $comment);
if(!isset($author[1])) {
echo " |- Meta file seems invalid; falling back to default meta...\n";
fwrite($file, json_encode([
'c' => '<Unknown>',
'n' => 'Unnamed',
'd' => ''
]));
} else {
fwrite($file, json_encode([
'c' => $author[1],
'n' => $name[1],
'd' => $comment[1]
]));
}
} else {
echo " |- Appending default meta...\n";
fwrite($file, json_encode([
'c' => '<Unknown>',
'n' => 'Unnamed',
'd' => ''
]));
}
}
}
++$lastid;
fwrite($file, "}");
fclose($file);
echo "Transfer complete, incrementing internal counter...\n";
file_put_contents("$world/libskinupload_nextid.txt", $lastid);