2021-02-01 20:41:40 -08:00
|
|
|
<?php
|
|
|
|
// MTSM - Minetest Server Manager
|
|
|
|
// (C) Chris Dorman, 2021
|
|
|
|
// License: CC-BY-SA version 3.0
|
|
|
|
// http://github.com/Pentium44/MTSM
|
|
|
|
|
2021-02-03 16:02:15 -08:00
|
|
|
include("config.php");
|
|
|
|
|
2021-02-01 20:41:40 -08:00
|
|
|
function recurse_copy($src,$dst) {
|
|
|
|
$dir = opendir($src);
|
|
|
|
@mkdir($dst);
|
|
|
|
while(false !== ( $file = readdir($dir)) ) {
|
|
|
|
if (( $file != '.' ) && ( $file != '..' )) {
|
|
|
|
if ( is_dir($src . '/' . $file) ) {
|
|
|
|
recurse_copy($src . '/' . $file,$dst . '/' . $file);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
copy($src . '/' . $file,$dst . '/' . $file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir($dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
function generateToken() {
|
|
|
|
$length = 12;
|
|
|
|
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
|
|
$charactersLength = strlen($characters);
|
|
|
|
$randomToken = '';
|
|
|
|
for ($i = 0; $i < $length; $i++) {
|
|
|
|
$randomToken .= $characters[rand(0, $charactersLength - 1)];
|
|
|
|
}
|
|
|
|
|
|
|
|
file_put_contents("mtm_db/token.php", "<?php \$reg_token = \"$randomToken\"; ?>");
|
|
|
|
}
|
|
|
|
|
|
|
|
function loginForm() {
|
|
|
|
?>
|
|
|
|
<br />
|
|
|
|
<div class="login">
|
|
|
|
Don't have an account? No problem, <a href="<?php echo $_SERVER['PHP_SELF']; ?>?forms=register">register here</a>!<br /><br />
|
|
|
|
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?do=login" method="post">
|
|
|
|
<table><tr><td>
|
|
|
|
Username:</td><td> <input class="text" type="text" name="username"></td></tr><tr><td>
|
|
|
|
Password:</td><td> <input class="text" type="password" name="password"></td></tr></table>
|
|
|
|
<input style="padding: 2px;" class="text" type="submit" name="submitBtn" value="Login">
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
|
|
|
|
function changePassForm() {
|
|
|
|
?>
|
|
|
|
<br />
|
|
|
|
<div class="chgpass">
|
|
|
|
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?do=changepass" method="post">
|
|
|
|
<table><tr><td>
|
|
|
|
Old password:</td><td> <input class="text" type="password" name="oldpass"></td></tr><tr><td>
|
|
|
|
Password:</td><td> <input class="text" type="password" name="password"></td></tr><tr><td>
|
|
|
|
Password Again:</td><td> <input class="text" type="password" name="password_again"></td></tr>
|
|
|
|
</table>
|
|
|
|
<input class="text" type="submit" name="submitBtn" value="Change">
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
|
|
|
|
/*function uploadForm() {
|
|
|
|
|
|
|
|
print <<<EOD
|
|
|
|
Upload
|
|
|
|
<table style="margin:auto;">
|
|
|
|
|
|
|
|
<form action="upload.php" method="post" enctype="multipart/form-data">
|
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
<input type="file" name="file[]" id="file" multiple><br>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<input type="submit" name="submit" value="Upload">
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
</table>
|
|
|
|
EOD;
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
2021-02-03 14:21:00 -08:00
|
|
|
function modUploadForm() {
|
|
|
|
?>
|
|
|
|
<p>
|
|
|
|
Warning: Mod uploads MUST be in ZIP archive format and MUST have the mod contents WITHIN a parent directory
|
|
|
|
within the archive. Failure to do so would cause for non-working mod installations into your user mods menu.
|
|
|
|
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?do=upload-modzip" method="POST" enctype="multipart/form-data">
|
|
|
|
<input type="file" name="file"></input>
|
|
|
|
<input style="padding: 2px;" class="text" type="submit" name="upload-btn" value="Upload">
|
|
|
|
</form>
|
|
|
|
</p>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
|
2021-02-01 20:41:40 -08:00
|
|
|
function modsForm() {
|
|
|
|
?>
|
|
|
|
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?do=configure-mods" method="post">
|
2021-02-10 16:08:07 -08:00
|
|
|
<table><tr>
|
2021-02-01 20:41:40 -08:00
|
|
|
<?php
|
|
|
|
chdir("mods");
|
2021-02-10 16:08:07 -08:00
|
|
|
$docount = 0;
|
2021-02-01 20:41:40 -08:00
|
|
|
foreach(glob("*") as $filename) {
|
2021-02-10 16:08:07 -08:00
|
|
|
echo "<td><input class='text' type='checkbox' name='$filename'> $filename</td>\n";
|
|
|
|
$docount++;
|
|
|
|
if($docount == 3) {
|
|
|
|
echo "</tr><tr>";
|
|
|
|
$docount = 0;
|
|
|
|
}
|
2021-02-01 20:41:40 -08:00
|
|
|
}
|
|
|
|
chdir("..");
|
|
|
|
?>
|
2021-02-10 16:08:07 -08:00
|
|
|
</tr></table>
|
2021-02-01 20:41:40 -08:00
|
|
|
<input style="padding: 2px;" class="text" type="submit" name="submitBtn" value="Set mods">
|
|
|
|
</form>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
|
2021-02-03 14:21:00 -08:00
|
|
|
function userModsForm($username) {
|
|
|
|
|
|
|
|
if(count(glob("mtm_db/usermods/$username/*")) !== 0) {
|
|
|
|
?>
|
|
|
|
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?do=configure-user-mods" method="post">
|
|
|
|
<?php
|
|
|
|
chdir("mtm_db/usermods/$username/");
|
|
|
|
foreach(glob("*") as $filename) {
|
|
|
|
echo "<input class='text' type='checkbox' name='$filename'> $filename<br />\n";
|
|
|
|
}
|
|
|
|
chdir("../../../");
|
|
|
|
?>
|
|
|
|
<input style="padding: 2px;" class="text" type="submit" name="submitBtn" value="Set mods">
|
|
|
|
</form>
|
|
|
|
<?php
|
|
|
|
} else {
|
|
|
|
echo "No user mods available!";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-01 20:41:40 -08:00
|
|
|
function settingsForm() {
|
|
|
|
?>
|
|
|
|
<div class="login">
|
|
|
|
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?do=configure-server" method="post">
|
|
|
|
<input class="text" type="checkbox" name="enablepvp"> Enable PVP<br />
|
|
|
|
<input class="text" type="checkbox" name="creative"> Creative Mode<br />
|
|
|
|
<input class="text" type="checkbox" name="enabledamage"> Enable Damage<br />
|
|
|
|
<input class="text" type="checkbox" name="serverannounce"> Server Announcement<br />
|
|
|
|
Server Name: <input class="text" type="text" name="servername"><br />
|
|
|
|
Server Desc: <input class="text" type="text" name="serverdesc"><br />
|
|
|
|
Server Website: <input class="text" type="text" name="serverurl"><br />
|
|
|
|
Server MOTD: <input class="text" type="text" name="motd"><br />
|
2021-02-13 10:45:08 -08:00
|
|
|
Map Generation: <select name="mgname">
|
|
|
|
<option value="v7">v7</option>
|
|
|
|
<option value="v6">v6</option>
|
|
|
|
<option value="v5">v5</option>
|
|
|
|
<option value="valleys">valleys</option>
|
|
|
|
<option value="carpathian">carpathian</option>
|
|
|
|
<option value="flat">flat</option>
|
|
|
|
<option value="fractal">fractal</option>
|
2021-02-13 11:27:29 -08:00
|
|
|
</select><br />
|
2021-02-10 16:24:23 -08:00
|
|
|
Default Privs: <input class="text" type="text" name="defaultprivs" value="shout, interact, home"><br />
|
2021-02-01 20:41:40 -08:00
|
|
|
Spawnpoint (Format example: '32, 20, -140')<br /> <input class="text" type="text" name="staticspawnpoint"><br />
|
2021-02-06 23:12:48 -08:00
|
|
|
Player Transfer Distance (Value in chunks, 0 = unlimited)<br />
|
|
|
|
<input class="text" type="text" style="width: 50px;" name="playertransferdistance"><br />
|
2021-02-01 20:41:40 -08:00
|
|
|
<input class="text" type="submit" name="submitBtn" value="Set">
|
|
|
|
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
|
|
|
|
function registerForm() {
|
|
|
|
?>
|
|
|
|
<br />
|
|
|
|
<div class="login">
|
|
|
|
Don't have a registration code? Reach out! cddo [at] riseup [dot] net<br />
|
|
|
|
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?do=register" method="post">
|
|
|
|
<table><tr><td>
|
|
|
|
Username:</td><td> <input class="text" type="text" name="username"></td></tr><tr><td>
|
|
|
|
Full name:</td><td> <input class="text" type="text" name="fullname"></td></tr><tr><td>
|
|
|
|
Email:</td><td><input class="text" type="text" name="email"></td></tr><tr><td>
|
|
|
|
Password:</td><td> <input class="text" type="password" name="password"></td></tr><tr><td>
|
|
|
|
Password again:</td><td> <input class="text" type="password" name="password-again"></td></tr><tr><td>
|
2021-02-03 16:02:15 -08:00
|
|
|
<?php if($GLOBALS['reg_token_required'] == "true") { echo 'Registration token (required):</td><td> <input class="text" type="text" name="codeword"></td></tr><tr><td>'; } ?>
|
|
|
|
Go:</td><td> <input class="text" type="submit" name="submitBtn" value="Register">
|
2021-02-01 20:41:40 -08:00
|
|
|
</td></tr></table>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
?>
|