_REQUEST-source<?php
if (!empty($_REQUEST['source']))
{
echo "<hr>_REQUEST-source";
echo "<pre>";
echo htmlspecialchars(file_get_contents($_SERVER['SCRIPT_FILENAME']));
echo "</pre>";
echo "<br>die()";
die();
}
?><html>
<head>
<title>Openarena Map List Generator</title>
</head>
<body>
<pre>
[<a href=".">back</a>]
<b>Openarena Map List Generator</b>
Put your list of maps in the textbox below, one map per line. Click submit, and you'll get a list of maps
ready to go into maps.cfg for your Openarena server. Also works for any Quake 3 or ioquake3 based games. Enjoy!
<b>*Note:</b> <i>No more than 150 entries allowed, and each entry will be cut off at 50 characters!</i>
<b>*Note:</b> <i>You can also <a target="_blank" href="<?php echo $PHP_SELF . "?source=1"; ?>">view source</a> of this tool!</i>
<form method="post" action="<?php echo $PHP_SELF; ?>">
<textarea name="maps" cols="80" rows="12"><?php echo htmlspecialchars($_REQUEST['maps']); ?></textarea>
(optional) start count at: <input type="text" name="start" value="<?php echo (empty($_REQUEST['start'])) ? 0 : htmlspecialchars($_REQUEST['start']);
?>"></input> (0 - 1000)
(optional) skip 5 numbers each count: <input type="checkbox" name="skip" value="surewhynot"<?php echo (isset($_REQUEST['skip'])) ? ' checked="checked"' : ' '; ?>></input>
<input type="submit" value=" Submit "></input>
</form>
<?php
/*
Purpose: Generate a map configuration file for a server running a
Quake 3-based or ioquake3-based game, such as Openarena.
Creator: Dmitriy Vi (me AT thedimi . net)
Version: 0.1
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// These settings prevent potential overloading of the server by malicious users.
define("MAX_ENTRIES", 150); // total number of entries to accept
define("MAX_ENTRY_LENGTH", 50); // maximum number of characters per entry
define("MAX_START_AT", 1000); // do not allow to start count from any number larger than this one
define("INCREMENT_BY", 5); // some users like gaps in their map numbering sequence to insert more maps later
// echo "<hr>";
//echo "start:".$_REQUEST['start']."<hr>";
//echo "skip:".$_REQUEST['skip']."<hr>";
//echo "source:".$_REQUEST['source']."<hr>";
//echo "maps:".$_REQUEST['maps']."<hr>";
if (!empty($_REQUEST['maps']))
{
// echo "<br>found maps";
$start_at = (is_numeric($_REQUEST['start']) && $_REQUEST['start'] > 0 && $_REQUEST['start'] < MAX_START_AT+1) ? $_REQUEST['start'] : 0;
$j = $start_at;
// echo "<br>start_at:".$start_at;
$incr_by = (isset($_REQUEST['skip']) && $_REQUEST['skip'] == "surewhynot") ? INCREMENT_BY : 1;
// echo "<br>incr_by:".$incr_by;
// echo "<br>MAX_ENTRIES: ".MAX_ENTRIES;
// $maps_arr = split("\n", htmlspecialchars($_REQUEST['maps']), MAX_ENTRIES+1);
$maps_arr = explode("\n", $_REQUEST['maps'], MAX_ENTRIES+1);
// echo "<br>maps_arr:".$maps_arr;
if (!empty($maps_arr[MAX_ENTRIES]))
{
die ("ERROR: Can't process your request, too many entries!");
}
echo "Here's your maps.cfg:\n\n//------------------------------\n";
for ($i = 0; $i < count($maps_arr); $i++)
{
$last = ($j - count($maps_arr)*$incr_by + $incr_by == $start_at) ? $start_at : $j+$incr_by;
printf("set m%04d \"map %s ; set nextmap vstr m%04d\"\n", $j, trim(substr($maps_arr[$i], 0, (MAX_ENTRY_LENGTH-1))), $last);
$j += $incr_by;
}
printf("\nwait\n\nvstr m%04d", $start_at);
echo "\n//------------------------------\n";
}
?>
</pre>
Quelle: <a href="https://openarena.ws/board/index.php?topic=2956.0" target=_blank>openarena.ws/board, user: vindimy</a>
</body>
</html>
die()