MBCompilerOnline/midlet.php
2024-05-11 17:47:33 +03:00

39 lines
1.3 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<html>
<head>
<meta http-equiv="Content-Type" content="application/html; charset=utf-8"/>
<meta http-equiv="Copyright" content="Андрей Рейгант (HoldFast)"/>
<link rel="stylesheet" media="all" type="text/css" href="mbstyle/mbs.css"/>
<title>Сервис для работы с BAS файлами</title>
</head>
<body>
<h2>Сборщик мидлета</h2>
<?php
if (($_GET['midlet'] ?? '')!="yes") {
echo '<form action="?midlet=yes" method="post" enctype="multipart/form-data">
Выберите ваш bas файл:<br>
<input type="file" name="bas"><br>
<input type="submit" value="Собрать">
</form>';
} else {
if (is_uploaded_file($_FILES["bas"]["tmp_name"])) {
$name_bas = $_FILES["bas"]["tmp_name"];
$name = 'tmp/midlet'.rand(1000,99999).".jar";
$jar = new ZipArchive();
$jar->open($name, ZIPARCHIVE::CREATE);
$jar->addFile("midlet/META-INF/MANIFEST.MF" , "META-INF/MANIFEST.MF");
$jar->addFile($name_bas, "Autorun.bas");
$classes = ["Main", "a", "b", "c", "d", "e", "f", "g", "h", "s"];
foreach ($classes as $cl) {
$class = "$cl.class";
$jar->addFile("midlet/$class" , $class);
}
$jar->close();
echo 'Мидлет успешно собран!<br><a href="'.$name.'">Скачать</a>';
}
}
?>
</body>
</html>