diff --git a/app/edit/index.php b/app/edit/index.php index dd41182701..f153ae1616 100644 --- a/app/edit/index.php +++ b/app/edit/index.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2018 + Portions created by the Initial Developer are Copyright (C) 2008-2019 the Initial Developer. All Rights Reserved. Contributor(s): @@ -82,9 +82,14 @@ $favicon = $_SESSION['theme']['favicon']['text']; } else { - $favicon = '/themes/default/favicon.ico'; + $favicon = $project_path .'/themes/default/favicon.ico'; } +//create a token + $key_name = '/app/edit/'.$mode; + $_SESSION['keys'][$key_name] = bin2hex(random_bytes(32)); + $_SESSION['token'] = hash_hmac('sha256', $key_name, $_SESSION['keys'][$key_name]); + ?> @@ -132,6 +137,34 @@ function focus_editor() { editor.focus(); } + + function http_request(url, form_data) { + var http = new XMLHttpRequest(); + http.open('POST', url, true); + //http.onload = function(e) { ... }; + http.onload = function(e) { + if (this.status == 200) { + //data sent successfully + alert(this.responseText); + } + else { + alert(''); + } + }; + http.send(form_data); + } + + function save() { + var form_data = new FormData(); + form_data.append('filepath', document.getElementById('filepath').value); + form_data.append('content', editor.getSession().getValue()); + form_data.append('token',document.getElementById('token').value); + form_data.append('mode',""); + + + http_request('filesave.php', form_data); + } +