-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmap.php
More file actions
32 lines (31 loc) · 779 Bytes
/
map.php
File metadata and controls
32 lines (31 loc) · 779 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
if (file_exists('maps.txt')) {
$maps = file('maps.txt', FILE_IGNORE_NEW_LINES);
} else {
$maps = [];
}
if (isset($_GET['maptext'])) {
if (strlen($_GET['maptext']) > 10000) {
print 'too big map';
exit();
}
$newMap = rawurlencode($_GET['maptext']);
foreach($maps as $i => $map) {
if ($map == $newMap) {
print $i;
exit();
}
}
$count = count($maps);
$maps[] = $newMap;
file_put_contents('maps.txt', implode("\n", $maps));
print $count;
} elseif (isset($_GET['mapid'])) {
if (isset($maps[$_GET['mapid']])) {
header('Location: index.html?maptext=' . $maps[$_GET['mapid']]);
} else {
print 'unknown map id';
}
} else {
print 'wrong parameters';
}