-
Notifications
You must be signed in to change notification settings - Fork 2
/
save.php
executable file
·48 lines (39 loc) · 1.13 KB
/
save.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
40
41
42
43
44
45
46
47
48
<?php
require_once('display_fns.php');
//if(preg_match("/[A-Za-z0-9\_]+/", $_POST['data']) == TRUE){
// $data = test_input($_POST['data']);
//}
$data = $_POST['data'];
if(preg_match("/[A-Za-z0-9\_]+/", $_POST['pathwayID']) == TRUE){
$pathwayID = test_input($_POST['pathwayID']);
}
if(preg_match("/[A-Za-z0-9\_]+/", $_POST['type']) == TRUE){
$type = test_input($_POST['type']);
}
//$data = $_POST['data'];
//$type = $_POST['type'];
//$pathwayID = $_POST['pathwayID'];
if ($type == 'subset'){
$file = '/var/www/data/'.md5(uniqid()) . '.txt';
file_put_contents($file, $data);
}
elseif($type == 'json'){
$file = '/var/www/data/'.$pathwayID.'_subpathway' . '.js';
file_put_contents($file, $data);
}
elseif($type == 'svg'){
$file = '/var/www/data/'.md5(uniqid()) . '.svg';
file_put_contents($file, $data);
}
else{
$file = '/var/www/data/'.md5(uniqid()) . '.png';
$uri = substr($data,strpos($data,',')+1);
// save to file
file_put_contents($file, base64_decode($uri));
}
//$file = 'image/network'. '.png';
// remove "data:image/png;base64,"
// return the filename
//echo json_encode($file);
echo $file;
?>