3 nce (ntch cloud environment.)
4 name: nc_write_file.php
5 author: Akira Ohta (akohta001.gmail.com)
10 include_once "account.php";
11 include_once "preference.php";
12 include_once "database.php";
13 include_once "log.php";
14 include_once "http_util.php";
15 include_once "error_code.php";
17 $user_id = $_POST['user'];
18 $token = $_POST['token'];
19 $file_name = $_POST['file_name'];
20 $data = $_POST['data'];
22 $user = chk_passwd( $user_id, $token);
28 if(!chk_file_name($file_name) || !$data){
33 $home_dir = OUTPUT_DIR."/{$user->home_dir}";
35 if(!is_dir($home_dir)){
36 $rc = mkdir($home_dir, 0755, true);
38 nc_logging("Failed to create folders: $home_dir");
44 $data = replace_urlencodeTo64symbol($data);
46 $file_path = $home_dir.'/'.$file_name;
48 @$fp=fopen($file_path, 'w');
50 nc_logging("Failed to create file: $file_path");
55 if(FALSE === fwrite($fp, $data."\n")){
57 nc_logging("Failed to write file: $file_path");