$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' => '', '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' => '', 'n' => 'Unnamed', 'd' => '' ])); } } } ++$lastid; fwrite($file, "}"); fclose($file); echo "Transfer complete, incrementing internal counter...\n"; file_put_contents("$world/libskinupload_nextid.txt", $lastid);