forked from cubiq/KiiConf
-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathsave.php
More file actions
23 lines (15 loc) · 722 Bytes
/
save.php
File metadata and controls
23 lines (15 loc) · 722 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
header('Content-Type: application/json');
$map = !empty( $_POST['map'] ) ? $_POST['map'] : '';
if ( !$map ) {
die( json_encode( array( 'error' => 'Malformed request' ) ) );
}
$map = json_decode( $map );
$name = !empty( $map->header->Name ) ? preg_replace('/[^a-z0-9._]/i', '', str_replace(' ', '_', $map->header->Name)) : '';
$layout = !empty( $map->header->Layout ) ? preg_replace('/[^a-z0-9._]/i', '', str_replace(' ', '_', $map->header->Layout)) : '';
if ( !$name || !$layout ) {
die( json_encode( array( 'error' => 'Malformed header' ) ) );
}
$filename = './layouts/' . $name . '-' . $layout . '.json';
file_put_contents($filename, json_encode( $map ));
echo json_encode( array( 'success' => true ) );