-
Notifications
You must be signed in to change notification settings - Fork 4
/
map.php
39 lines (35 loc) · 814 Bytes
/
map.php
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
33
34
35
36
37
38
39
<?php
$mode='rw';
$dir='maps';
// Récupérer la liste des maps
if(array_key_exists('GET', $_REQUEST)) {
$list = '';
if(is_dir($dir)) {
if($dh=opendir($dir)) {
while(($file=readdir($dh)) !== false) {
if(substr($file, -4) == '.csv') {
if(is_readable($dir.'/'.$file)) {
$list .= substr($file, 0, -4)."\n";
}
}
}
closedir($dh);
}
}
echo $list;
}
// Sauvegarder une map
if((strpos($mode, 'w') !== false) && array_key_exists('PUT', $_REQUEST)) {
$id = $_REQUEST['PUT'];
$content = $_POST['content'];
$filename = 'maps/'.$id.'.csv';
if((is_writable($filename)) || (is_writable('maps') && !file_exists($filename))) {
file_put_contents($filename, $content);
echo 'OK';
} else {
echo 'ERROR'."\n";
echo 'PUT = '.$id."\n";
echo 'content = '.$content."\n";
}
}
?>