1 |
447611c4
|
Scott Ullrich
|
<?php
|
2 |
a7f908db
|
Scott Ullrich
|
/*
|
3 |
6173d1f5
|
Colin Fleming
|
* diag_edit.php
|
4 |
fd9ebcd5
|
Stephen Beaver
|
*
|
5 |
c5d81585
|
Renato Botelho
|
* part of pfSense (https://www.pfsense.org)
|
6 |
b8f91b7c
|
Luiz Souza
|
* Copyright (c) 2004-2018 Rubicon Communications, LLC (Netgate)
|
7 |
c5d81585
|
Renato Botelho
|
* All rights reserved.
|
8 |
fd9ebcd5
|
Stephen Beaver
|
*
|
9 |
b12ea3fb
|
Renato Botelho
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
10 |
|
|
* you may not use this file except in compliance with the License.
|
11 |
|
|
* You may obtain a copy of the License at
|
12 |
fd9ebcd5
|
Stephen Beaver
|
*
|
13 |
b12ea3fb
|
Renato Botelho
|
* http://www.apache.org/licenses/LICENSE-2.0
|
14 |
fd9ebcd5
|
Stephen Beaver
|
*
|
15 |
b12ea3fb
|
Renato Botelho
|
* Unless required by applicable law or agreed to in writing, software
|
16 |
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
17 |
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
18 |
|
|
* See the License for the specific language governing permissions and
|
19 |
|
|
* limitations under the License.
|
20 |
fd9ebcd5
|
Stephen Beaver
|
*/
|
21 |
a7f908db
|
Scott Ullrich
|
|
22 |
9fbb3599
|
Ermal
|
##|+PRIV
|
23 |
|
|
##|*IDENT=page-diagnostics-edit
|
24 |
9599211d
|
jim-p
|
##|*NAME=Diagnostics: Edit File
|
25 |
9fbb3599
|
Ermal
|
##|*DESCR=Allow access to the 'Diagnostics: Edit File' page.
|
26 |
57188e47
|
Phil Davis
|
##|*WARN=standard-warning-root
|
27 |
a09f3d8e
|
Phil Davis
|
##|*MATCH=diag_edit.php*
|
28 |
c0f613e2
|
Ermal
|
##|*MATCH=browser.php*
|
29 |
18e7bc46
|
Stephen Beaver
|
##|*MATCH=vendor/filebrowser/browser.php*
|
30 |
9fbb3599
|
Ermal
|
##|-PRIV
|
31 |
|
|
|
32 |
a6a6ee00
|
k-paulius
|
$pgtitle = array(gettext("Diagnostics"), gettext("Edit File"));
|
33 |
c81ef6e2
|
Phil Davis
|
require_once("guiconfig.inc");
|
34 |
859329c8
|
Scott Ullrich
|
|
35 |
41b1ff89
|
Phil Davis
|
if ($_POST['action']) {
|
36 |
|
|
switch ($_POST['action']) {
|
37 |
0d6a185a
|
Scott Ullrich
|
case 'load':
|
38 |
288a2a0f
|
Phil Davis
|
if (strlen($_POST['file']) < 1) {
|
39 |
1bd5e62d
|
k-paulius
|
print('|5|');
|
40 |
ed98ef92
|
Phil Davis
|
print_info_box(gettext("No file name specified."), 'danger');
|
41 |
1bd5e62d
|
k-paulius
|
print('|');
|
42 |
288a2a0f
|
Phil Davis
|
} elseif (is_dir($_POST['file'])) {
|
43 |
1bd5e62d
|
k-paulius
|
print('|4|');
|
44 |
ed98ef92
|
Phil Davis
|
print_info_box(gettext("Loading a directory is not supported."), 'danger');
|
45 |
1bd5e62d
|
k-paulius
|
print('|');
|
46 |
288a2a0f
|
Phil Davis
|
} elseif (!is_file($_POST['file'])) {
|
47 |
1bd5e62d
|
k-paulius
|
print('|3|');
|
48 |
ed98ef92
|
Phil Davis
|
print_info_box(gettext("File does not exist or is not a regular file."), 'danger');
|
49 |
1bd5e62d
|
k-paulius
|
print('|');
|
50 |
0d6a185a
|
Scott Ullrich
|
} else {
|
51 |
55344e2c
|
Ermal
|
$data = file_get_contents(urldecode($_POST['file']));
|
52 |
288a2a0f
|
Phil Davis
|
if ($data === false) {
|
53 |
1bd5e62d
|
k-paulius
|
print('|1|');
|
54 |
ed98ef92
|
Phil Davis
|
print_info_box(gettext("Failed to read file."), 'danger');
|
55 |
1bd5e62d
|
k-paulius
|
print('|');
|
56 |
0d6a185a
|
Scott Ullrich
|
} else {
|
57 |
b71f0cbb
|
Ermal
|
$data = base64_encode($data);
|
58 |
45d6ada5
|
Sjon Hortensius
|
print("|0|{$_POST['file']}|{$data}|");
|
59 |
0d6a185a
|
Scott Ullrich
|
}
|
60 |
|
|
}
|
61 |
|
|
exit;
|
62 |
45d6ada5
|
Sjon Hortensius
|
|
63 |
0d6a185a
|
Scott Ullrich
|
case 'save':
|
64 |
288a2a0f
|
Phil Davis
|
if (strlen($_POST['file']) < 1) {
|
65 |
1bd5e62d
|
k-paulius
|
print('|');
|
66 |
ed98ef92
|
Phil Davis
|
print_info_box(gettext("No file name specified."), 'danger');
|
67 |
1bd5e62d
|
k-paulius
|
print('|');
|
68 |
0d6a185a
|
Scott Ullrich
|
} else {
|
69 |
55344e2c
|
Ermal
|
$_POST['data'] = str_replace("\r", "", base64_decode($_POST['data']));
|
70 |
|
|
$ret = file_put_contents($_POST['file'], $_POST['data']);
|
71 |
41b1ff89
|
Phil Davis
|
if ($_POST['file'] == "/conf/config.xml" || $_POST['file'] == "/cf/conf/config.xml") {
|
72 |
|
|
if (file_exists("/tmp/config.cache")) {
|
73 |
5f05c1e8
|
Scott Ullrich
|
unlink("/tmp/config.cache");
|
74 |
41b1ff89
|
Phil Davis
|
}
|
75 |
0f806eca
|
Erik Fonnesbeck
|
disable_security_checks();
|
76 |
|
|
}
|
77 |
288a2a0f
|
Phil Davis
|
if ($ret === false) {
|
78 |
1bd5e62d
|
k-paulius
|
print('|');
|
79 |
ed98ef92
|
Phil Davis
|
print_info_box(gettext("Failed to write file."), 'danger');
|
80 |
1bd5e62d
|
k-paulius
|
print('|');
|
81 |
288a2a0f
|
Phil Davis
|
} elseif ($ret != strlen($_POST['data'])) {
|
82 |
1bd5e62d
|
k-paulius
|
print('|');
|
83 |
ed98ef92
|
Phil Davis
|
print_info_box(gettext("Error while writing file."), 'danger');
|
84 |
1bd5e62d
|
k-paulius
|
print('|');
|
85 |
0d6a185a
|
Scott Ullrich
|
} else {
|
86 |
1bd5e62d
|
k-paulius
|
print('|');
|
87 |
ed98ef92
|
Phil Davis
|
print_info_box(gettext("File saved successfully."), 'success');
|
88 |
1bd5e62d
|
k-paulius
|
print('|');
|
89 |
0d6a185a
|
Scott Ullrich
|
}
|
90 |
|
|
}
|
91 |
|
|
exit;
|
92 |
5124d619
|
Scott Ullrich
|
}
|
93 |
0d6a185a
|
Scott Ullrich
|
exit;
|
94 |
5124d619
|
Scott Ullrich
|
}
|
95 |
|
|
|
96 |
c81ef6e2
|
Phil Davis
|
require_once("head.inc");
|
97 |
ee092d36
|
Jared Dillard
|
|
98 |
|
|
print_callout(gettext("The capabilities offered here can be dangerous. No support is available. Use them at your own risk!"), 'danger', gettext('Advanced Users Only'));
|
99 |
|
|
|
100 |
5b237745
|
Scott Ullrich
|
?>
|
101 |
45d6ada5
|
Sjon Hortensius
|
<!-- file status box -->
|
102 |
|
|
<div style="display:none; background:#eeeeee;" id="fileStatusBox">
|
103 |
1bd5e62d
|
k-paulius
|
<div id="fileStatus"></div>
|
104 |
45d6ada5
|
Sjon Hortensius
|
</div>
|
105 |
|
|
|
106 |
|
|
<div class="panel panel-default">
|
107 |
3d7a8696
|
k-paulius
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext("Save / Load a File from the Filesystem")?></h2></div>
|
108 |
45d6ada5
|
Sjon Hortensius
|
<div class="panel-body">
|
109 |
2ca4eec2
|
Jared Dillard
|
<div class="content">
|
110 |
|
|
<form>
|
111 |
e5343844
|
Stephen Beaver
|
<p><input type="text" class="form-control" id="fbTarget" placeholder="<?=gettext('Path to file to be edited')?>"/></p>
|
112 |
37676f4e
|
jim-p
|
<div class="btn-group">
|
113 |
ee092d36
|
Jared Dillard
|
<p>
|
114 |
|
|
<button type="button" class="btn btn-default btn-sm" onclick="loadFile();" value="<?=gettext('Load')?>">
|
115 |
|
|
<i class="fa fa-file-text-o"></i>
|
116 |
|
|
<?=gettext('Load')?>
|
117 |
|
|
</button>
|
118 |
|
|
<button type="button" class="btn btn-default btn-sm" id="fbOpen" value="<?=gettext('Browse')?>">
|
119 |
|
|
<i class="fa fa-list"></i>
|
120 |
|
|
<?=gettext('Browse')?>
|
121 |
|
|
</button>
|
122 |
|
|
<button type="button" class="btn btn-default btn-sm" onclick="saveFile();" value="<?=gettext('Save')?>">
|
123 |
|
|
<i class="fa fa-save"></i>
|
124 |
|
|
<?=gettext('Save')?>
|
125 |
|
|
</button>
|
126 |
|
|
</p>
|
127 |
37676f4e
|
jim-p
|
</div>
|
128 |
ee092d36
|
Jared Dillard
|
<p class="pull-right">
|
129 |
|
|
<button id="btngoto" class="btn btn-default btn-sm"><i class="fa fa-forward"></i><?=gettext("GoTo Line #")?></button> <input type="number" id="gotoline" size="6" style="padding: 3px 0px;"/>
|
130 |
|
|
</p>
|
131 |
2ca4eec2
|
Jared Dillard
|
</form>
|
132 |
45d6ada5
|
Sjon Hortensius
|
|
133 |
ee092d36
|
Jared Dillard
|
<div id="fbBrowser" style="display:none; border:1px dashed gray; width:98%; padding:10px"></div>
|
134 |
45d6ada5
|
Sjon Hortensius
|
|
135 |
ee092d36
|
Jared Dillard
|
<script type="text/javascript">
|
136 |
|
|
//<![CDATA[
|
137 |
|
|
window.onload=function() {
|
138 |
|
|
document.getElementById("fileContent").wrap='off';
|
139 |
|
|
}
|
140 |
|
|
//]]>
|
141 |
|
|
</script>
|
142 |
|
|
<textarea id="fileContent" name="fileContent" class="form-control" rows="30" cols="20"></textarea>
|
143 |
45d6ada5
|
Sjon Hortensius
|
</div>
|
144 |
|
|
</div>
|
145 |
|
|
</div>
|
146 |
|
|
|
147 |
8fd9052f
|
Colin Fleming
|
<script type="text/javascript">
|
148 |
|
|
//<![CDATA[
|
149 |
b54c2035
|
Stephen Beaver
|
events.push(function(){
|
150 |
|
|
|
151 |
|
|
function showLine(tarea, lineNum) {
|
152 |
|
|
|
153 |
|
|
lineNum--; // array starts at 0
|
154 |
|
|
var lines = tarea.value.split("\n");
|
155 |
|
|
|
156 |
|
|
// calculate start/end
|
157 |
|
|
var startPos = 0, endPos = tarea.value.length;
|
158 |
9d3e8723
|
Phil Davis
|
for (var x = 0; x < lines.length; x++) {
|
159 |
|
|
if (x == lineNum) {
|
160 |
b54c2035
|
Stephen Beaver
|
break;
|
161 |
|
|
}
|
162 |
|
|
startPos += (lines[x].length+1);
|
163 |
|
|
|
164 |
|
|
}
|
165 |
|
|
|
166 |
|
|
var endPos = lines[lineNum].length+startPos;
|
167 |
|
|
|
168 |
|
|
// do selection
|
169 |
|
|
// Chrome / Firefox
|
170 |
|
|
|
171 |
9d3e8723
|
Phil Davis
|
if (typeof(tarea.selectionStart) != "undefined") {
|
172 |
b54c2035
|
Stephen Beaver
|
tarea.focus();
|
173 |
|
|
tarea.selectionStart = startPos;
|
174 |
|
|
tarea.selectionEnd = endPos;
|
175 |
|
|
return true;
|
176 |
|
|
}
|
177 |
|
|
|
178 |
|
|
// IE
|
179 |
|
|
if (document.selection && document.selection.createRange) {
|
180 |
|
|
tarea.focus();
|
181 |
|
|
tarea.select();
|
182 |
|
|
var range = document.selection.createRange();
|
183 |
|
|
range.collapse(true);
|
184 |
|
|
range.moveEnd("character", endPos);
|
185 |
|
|
range.moveStart("character", startPos);
|
186 |
|
|
range.select();
|
187 |
|
|
return true;
|
188 |
|
|
}
|
189 |
|
|
|
190 |
|
|
return false;
|
191 |
|
|
}
|
192 |
|
|
|
193 |
|
|
$("#btngoto").prop('type','button');
|
194 |
|
|
|
195 |
fd778d8b
|
Stephen Beaver
|
//On clicking the GoTo button, validate the entered value
|
196 |
|
|
// and highlight the required line
|
197 |
b54c2035
|
Stephen Beaver
|
$('#btngoto').click(function() {
|
198 |
|
|
var tarea = document.getElementById("fileContent");
|
199 |
fd778d8b
|
Stephen Beaver
|
var gtl = $('#gotoline').val();
|
200 |
|
|
var lines = $("#fileContent").val().split(/\r|\r\n|\n/).length;
|
201 |
|
|
|
202 |
|
|
if (gtl < 1) {
|
203 |
|
|
gtl = 1;
|
204 |
|
|
}
|
205 |
|
|
|
206 |
|
|
if (gtl > lines) {
|
207 |
|
|
gtl = lines;
|
208 |
|
|
}
|
209 |
|
|
|
210 |
|
|
showLine(tarea, gtl);
|
211 |
b54c2035
|
Stephen Beaver
|
});
|
212 |
86e94bec
|
Stephen Beaver
|
|
213 |
|
|
// Goto the specified line on pressing the Enter key within the "Goto line" input element
|
214 |
|
|
$('#gotoline').keyup(function(e) {
|
215 |
|
|
if(e.keyCode == 13) {
|
216 |
|
|
$('#btngoto').click();
|
217 |
|
|
}
|
218 |
|
|
});
|
219 |
|
|
|
220 |
|
|
}); // e-o-events.push()
|
221 |
b54c2035
|
Stephen Beaver
|
|
222 |
0d6a185a
|
Scott Ullrich
|
function loadFile() {
|
223 |
3f98044a
|
Francisco Cavalcante
|
$("#fileStatus").html("");
|
224 |
|
|
$("#fileStatusBox").show(500);
|
225 |
|
|
$.ajax(
|
226 |
45d6ada5
|
Sjon Hortensius
|
"<?=$_SERVER['SCRIPT_NAME']?>", {
|
227 |
e3c1ea9b
|
Vinicius Coque
|
type: "post",
|
228 |
3f98044a
|
Francisco Cavalcante
|
data: "action=load&file=" + $("#fbTarget").val(),
|
229 |
e3c1ea9b
|
Vinicius Coque
|
complete: loadComplete
|
230 |
0d6a185a
|
Scott Ullrich
|
}
|
231 |
|
|
);
|
232 |
|
|
}
|
233 |
5b237745
|
Scott Ullrich
|
|
234 |
0d6a185a
|
Scott Ullrich
|
function loadComplete(req) {
|
235 |
3f98044a
|
Francisco Cavalcante
|
$("#fileContent").show(1000);
|
236 |
0d6a185a
|
Scott Ullrich
|
var values = req.responseText.split("|");
|
237 |
|
|
values.shift(); values.pop();
|
238 |
|
|
|
239 |
41b1ff89
|
Phil Davis
|
if (values.shift() == "0") {
|
240 |
0d6a185a
|
Scott Ullrich
|
var file = values.shift();
|
241 |
557e0826
|
Steve Beaver
|
var fileContent = window.Base64.decode(values.join("|"));
|
242 |
0d6a185a
|
Scott Ullrich
|
|
243 |
3f98044a
|
Francisco Cavalcante
|
$("#fileContent").val(fileContent);
|
244 |
947141fd
|
Phil Davis
|
} else {
|
245 |
3f98044a
|
Francisco Cavalcante
|
$("#fileStatus").html(values[0]);
|
246 |
|
|
$("#fileContent").val("");
|
247 |
0d6a185a
|
Scott Ullrich
|
}
|
248 |
45d6ada5
|
Sjon Hortensius
|
|
249 |
3f98044a
|
Francisco Cavalcante
|
$("#fileContent").show(1000);
|
250 |
0d6a185a
|
Scott Ullrich
|
}
|
251 |
5b237745
|
Scott Ullrich
|
|
252 |
0d6a185a
|
Scott Ullrich
|
function saveFile(file) {
|
253 |
3f98044a
|
Francisco Cavalcante
|
$("#fileStatus").html("");
|
254 |
|
|
$("#fileStatusBox").show(500);
|
255 |
41b1ff89
|
Phil Davis
|
|
256 |
3f98044a
|
Francisco Cavalcante
|
var fileContent = Base64.encode($("#fileContent").val());
|
257 |
6c07db48
|
Phil Davis
|
fileContent = fileContent.replace(/\+/g, "%2B");
|
258 |
45d6ada5
|
Sjon Hortensius
|
|
259 |
3f98044a
|
Francisco Cavalcante
|
$.ajax(
|
260 |
45d6ada5
|
Sjon Hortensius
|
"<?=$_SERVER['SCRIPT_NAME']?>", {
|
261 |
e3c1ea9b
|
Vinicius Coque
|
type: "post",
|
262 |
3f98044a
|
Francisco Cavalcante
|
data: "action=save&file=" + $("#fbTarget").val() +
|
263 |
ee650539
|
Scott Ullrich
|
"&data=" + fileContent,
|
264 |
e3c1ea9b
|
Vinicius Coque
|
complete: function(req) {
|
265 |
0d6a185a
|
Scott Ullrich
|
var values = req.responseText.split("|");
|
266 |
3f98044a
|
Francisco Cavalcante
|
$("#fileStatus").html(values[1]);
|
267 |
0d6a185a
|
Scott Ullrich
|
}
|
268 |
|
|
}
|
269 |
|
|
);
|
270 |
|
|
}
|
271 |
|
|
|
272 |
e561ccdf
|
Stephen Beaver
|
/**
|
273 |
|
|
*
|
274 |
|
|
* Base64 encode / decode
|
275 |
|
|
* http://www.webtoolkit.info/
|
276 |
|
|
* http://www.webtoolkit.info/licence
|
277 |
|
|
**/
|
278 |
|
|
|
279 |
|
|
var Base64 = {
|
280 |
|
|
|
281 |
|
|
// private property
|
282 |
|
|
_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
|
283 |
|
|
|
284 |
|
|
// public method for encoding
|
285 |
|
|
encode : function (input) {
|
286 |
|
|
var output = "";
|
287 |
|
|
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
|
288 |
|
|
var i = 0;
|
289 |
|
|
|
290 |
|
|
input = Base64._utf8_encode(input);
|
291 |
|
|
|
292 |
|
|
while (i < input.length) {
|
293 |
|
|
|
294 |
|
|
chr1 = input.charCodeAt(i++);
|
295 |
|
|
chr2 = input.charCodeAt(i++);
|
296 |
|
|
chr3 = input.charCodeAt(i++);
|
297 |
|
|
|
298 |
|
|
enc1 = chr1 >> 2;
|
299 |
|
|
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
|
300 |
|
|
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
|
301 |
|
|
enc4 = chr3 & 63;
|
302 |
|
|
|
303 |
|
|
if (isNaN(chr2)) {
|
304 |
|
|
enc3 = enc4 = 64;
|
305 |
|
|
} else if (isNaN(chr3)) {
|
306 |
|
|
enc4 = 64;
|
307 |
|
|
}
|
308 |
|
|
|
309 |
|
|
output = output +
|
310 |
|
|
this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
|
311 |
|
|
this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
|
312 |
|
|
|
313 |
|
|
}
|
314 |
|
|
|
315 |
|
|
return output;
|
316 |
|
|
},
|
317 |
|
|
|
318 |
|
|
// public method for decoding
|
319 |
|
|
decode : function (input) {
|
320 |
|
|
var output = "";
|
321 |
|
|
var chr1, chr2, chr3;
|
322 |
|
|
var enc1, enc2, enc3, enc4;
|
323 |
|
|
var i = 0;
|
324 |
|
|
|
325 |
|
|
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
|
326 |
|
|
|
327 |
|
|
while (i < input.length) {
|
328 |
|
|
|
329 |
|
|
enc1 = this._keyStr.indexOf(input.charAt(i++));
|
330 |
|
|
enc2 = this._keyStr.indexOf(input.charAt(i++));
|
331 |
|
|
enc3 = this._keyStr.indexOf(input.charAt(i++));
|
332 |
|
|
enc4 = this._keyStr.indexOf(input.charAt(i++));
|
333 |
|
|
|
334 |
|
|
chr1 = (enc1 << 2) | (enc2 >> 4);
|
335 |
|
|
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
|
336 |
|
|
chr3 = ((enc3 & 3) << 6) | enc4;
|
337 |
|
|
|
338 |
|
|
output = output + String.fromCharCode(chr1);
|
339 |
|
|
|
340 |
|
|
if (enc3 != 64) {
|
341 |
|
|
output = output + String.fromCharCode(chr2);
|
342 |
|
|
}
|
343 |
|
|
if (enc4 != 64) {
|
344 |
|
|
output = output + String.fromCharCode(chr3);
|
345 |
|
|
}
|
346 |
|
|
|
347 |
|
|
}
|
348 |
|
|
|
349 |
|
|
output = Base64._utf8_decode(output);
|
350 |
|
|
|
351 |
|
|
return output;
|
352 |
|
|
|
353 |
|
|
},
|
354 |
|
|
|
355 |
|
|
// private method for UTF-8 encoding
|
356 |
|
|
_utf8_encode : function (string) {
|
357 |
|
|
string = string.replace(/\r\n/g,"\n");
|
358 |
|
|
var utftext = "";
|
359 |
|
|
|
360 |
|
|
for (var n = 0; n < string.length; n++) {
|
361 |
|
|
|
362 |
|
|
var c = string.charCodeAt(n);
|
363 |
|
|
|
364 |
|
|
if (c < 128) {
|
365 |
|
|
utftext += String.fromCharCode(c);
|
366 |
947141fd
|
Phil Davis
|
} else if ((c > 127) && (c < 2048)) {
|
367 |
e561ccdf
|
Stephen Beaver
|
utftext += String.fromCharCode((c >> 6) | 192);
|
368 |
|
|
utftext += String.fromCharCode((c & 63) | 128);
|
369 |
947141fd
|
Phil Davis
|
} else {
|
370 |
e561ccdf
|
Stephen Beaver
|
utftext += String.fromCharCode((c >> 12) | 224);
|
371 |
|
|
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
|
372 |
|
|
utftext += String.fromCharCode((c & 63) | 128);
|
373 |
|
|
}
|
374 |
|
|
|
375 |
|
|
}
|
376 |
|
|
|
377 |
|
|
return utftext;
|
378 |
|
|
},
|
379 |
|
|
|
380 |
|
|
// private method for UTF-8 decoding
|
381 |
|
|
_utf8_decode : function (utftext) {
|
382 |
|
|
var string = "";
|
383 |
|
|
var i = 0;
|
384 |
|
|
var c = c1 = c2 = 0;
|
385 |
|
|
|
386 |
947141fd
|
Phil Davis
|
while (i < utftext.length) {
|
387 |
e561ccdf
|
Stephen Beaver
|
|
388 |
|
|
c = utftext.charCodeAt(i);
|
389 |
|
|
|
390 |
|
|
if (c < 128) {
|
391 |
|
|
string += String.fromCharCode(c);
|
392 |
|
|
i++;
|
393 |
947141fd
|
Phil Davis
|
} else if ((c > 191) && (c < 224)) {
|
394 |
e561ccdf
|
Stephen Beaver
|
c2 = utftext.charCodeAt(i+1);
|
395 |
|
|
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
|
396 |
|
|
i += 2;
|
397 |
947141fd
|
Phil Davis
|
} else {
|
398 |
e561ccdf
|
Stephen Beaver
|
c2 = utftext.charCodeAt(i+1);
|
399 |
|
|
c3 = utftext.charCodeAt(i+2);
|
400 |
|
|
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
|
401 |
|
|
i += 3;
|
402 |
|
|
}
|
403 |
|
|
|
404 |
|
|
}
|
405 |
|
|
|
406 |
|
|
return string;
|
407 |
|
|
}
|
408 |
|
|
|
409 |
|
|
};
|
410 |
|
|
|
411 |
7f4268b6
|
Steve Beaver
|
<?php if ($_POST['action'] == "load"): ?>
|
412 |
45d6ada5
|
Sjon Hortensius
|
events.push(function() {
|
413 |
7f4268b6
|
Steve Beaver
|
$("#fbTarget").val("<?=htmlspecialchars($_POST['path'])?>");
|
414 |
45d6ada5
|
Sjon Hortensius
|
loadFile();
|
415 |
|
|
});
|
416 |
0d6a185a
|
Scott Ullrich
|
<?php endif; ?>
|
417 |
86e94bec
|
Stephen Beaver
|
|
418 |
8fd9052f
|
Colin Fleming
|
//]]>
|
419 |
0d6a185a
|
Scott Ullrich
|
</script>
|
420 |
ab541dbb
|
Scott Ullrich
|
|
421 |
45d6ada5
|
Sjon Hortensius
|
<?php include("foot.inc");
|
422 |
|
|
|
423 |
18e7bc46
|
Stephen Beaver
|
outputJavaScriptFileInline("vendor/filebrowser/browser.js");
|