|
29 | 29 | $content = ''; |
30 | 30 | $path = $_REQUEST['path']; |
31 | 31 | if (!empty($_POST['save'])) { |
| 32 | + |
| 33 | + // Check token |
| 34 | + if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) { |
| 35 | + header('Location: /login/'); |
| 36 | + exit(); |
| 37 | + } |
| 38 | + |
| 39 | + exec (HESTIA_CMD . "v-open-fs-file ".escapeshellarg($user)." ".escapeshellarg($path), $devnull, $return_var); |
| 40 | + if ($return_var != 0) { |
| 41 | + print 'Error while opening file'; |
| 42 | + exit; |
| 43 | + } |
| 44 | + $devnull=null; |
| 45 | + |
32 | 46 | $fn = tempnam ('/tmp', 'vst-save-file-'); |
33 | 47 | if ($fn) { |
34 | 48 | $contents = $_POST['contents']; |
|
39 | 53 | chmod($fn, 0644); |
40 | 54 |
|
41 | 55 | if ($f) { |
42 | | - exec (HESTIA_CMD . "v-copy-fs-file {$user} {$fn} ".escapeshellarg($path), $output, $return_var); |
| 56 | + exec (HESTIA_CMD . "v-copy-fs-file ".escapeshellarg($user)." ".escapeshellarg($fn)." ".escapeshellarg($path), $output, $return_var); |
43 | 57 | $error = check_return_code($return_var, $output); |
44 | 58 | if ($return_var != 0) { |
45 | 59 | print('<p style="color: white">Error while saving file</p>'); |
|
50 | 64 | } |
51 | 65 | } |
52 | 66 |
|
53 | | - exec (HESTIA_CMD . "v-open-fs-file {$user} ".escapeshellarg($path), $content, $return_var); |
| 67 | + exec (HESTIA_CMD . "v-open-fs-file ".escapeshellarg($user)." ".escapeshellarg($path), $content, $return_var); |
54 | 68 | if ($return_var != 0) { |
55 | 69 | print 'Error while opening file'; // todo: handle this more styled |
56 | 70 | exit; |
|
64 | 78 | <form id="edit-file-form" method="post"> |
65 | 79 | <!-- input id="do-backup" type="button" onClick="javascript:void(0);" name="save" value="backup (ctrl+F2)" class="backup" / --> |
66 | 80 | <input type="submit" name="save" value="Save" class="save" /> |
| 81 | +<input type="hidden" name="token" value="<?=$_SESSION['token']?>" /> |
67 | 82 |
|
68 | 83 |
|
69 | 84 | <textarea name="contents" class="editor" id="editor" rows="4" style="display:none;width: 100%; height: 100%;"><?=htmlentities($content)?></textarea> |
|
0 commit comments