2006-04-26 12:28:53 +00:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
LICENSE
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License (GPL)
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
|
|
|
----------------------------------------------------------------------
|
|
|
|
*/
|
2017-10-12 15:54:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* File editor part of AlternC file manager / browser.
|
|
|
|
*
|
|
|
|
* @copyright AlternC-Team 2000-2017 https://alternc.com/
|
|
|
|
*/
|
|
|
|
|
|
|
|
require_once("../class/config.php");
|
2006-04-26 12:28:53 +00:00
|
|
|
|
2016-08-09 14:40:11 +00:00
|
|
|
// We check it ourself : not fatal
|
|
|
|
define("NOCSRF",true);
|
|
|
|
|
2012-08-22 16:47:18 +00:00
|
|
|
$fields = array (
|
2016-05-23 14:08:23 +00:00
|
|
|
"editfile" => array ("request", "string", ""),
|
2012-08-22 16:47:18 +00:00
|
|
|
"texte" => array ("post", "string", ""),
|
|
|
|
"save" => array ("post", "string", ""),
|
|
|
|
"saveret" => array ("post", "string", ""),
|
|
|
|
"cancel" => array ("post", "string", ""),
|
2016-05-23 14:08:23 +00:00
|
|
|
"R" => array ("request", "string", ""),
|
2012-08-22 16:47:18 +00:00
|
|
|
);
|
|
|
|
getFields($fields);
|
|
|
|
|
2016-08-09 14:40:11 +00:00
|
|
|
$editing=false;
|
2011-03-28 12:00:33 +00:00
|
|
|
$editfile=ssla($editfile);
|
2006-04-26 12:28:53 +00:00
|
|
|
$texte=ssla($texte);
|
|
|
|
|
|
|
|
$R=$bro->convertabsolute($R,1);
|
|
|
|
$p=$bro->GetPrefs();
|
|
|
|
|
2012-06-19 15:26:48 +00:00
|
|
|
if (isset($cancel) && $cancel) {
|
2006-04-26 12:28:53 +00:00
|
|
|
include("bro_main.php");
|
|
|
|
exit();
|
|
|
|
}
|
2014-01-10 15:37:50 +00:00
|
|
|
|
2012-06-19 15:26:48 +00:00
|
|
|
if (isset($saveret) && $saveret) {
|
2016-08-09 14:40:11 +00:00
|
|
|
$editing=true;
|
|
|
|
|
|
|
|
// Thanks to this, we bring you back to the EDIT form if the CSRF is invalid.
|
|
|
|
// Allows you to re-submit
|
2017-08-16 00:44:54 +00:00
|
|
|
// FIXME - doesn't work
|
|
|
|
/* $csrf_check=false;
|
2016-08-09 14:40:11 +00:00
|
|
|
if (count($_POST) && !defined("NOCSRF")) {
|
|
|
|
if (csrf_check()<=0) {
|
2017-08-16 00:44:54 +00:00
|
|
|
$csrf_check = true;
|
2016-08-09 14:40:11 +00:00
|
|
|
}
|
2017-08-16 00:44:54 +00:00
|
|
|
}*/
|
2016-08-09 14:40:11 +00:00
|
|
|
|
2017-08-16 00:44:54 +00:00
|
|
|
if ($bro->save($editfile,$R,$texte)) {
|
2017-10-06 16:04:36 +00:00
|
|
|
$msg->raise("INFO", "bro", _("Your file %s has been saved")." (".format_date(_('%3$d-%2$d-%1$d %4$d:%5$d'),date("Y-m-d H:i:s")).")", $editfile);
|
2016-08-09 14:40:11 +00:00
|
|
|
include("bro_main.php");
|
|
|
|
exit();
|
|
|
|
}
|
2006-04-26 12:28:53 +00:00
|
|
|
}
|
2012-06-19 15:26:48 +00:00
|
|
|
if (isset($save) && $save) {
|
2014-01-10 15:54:18 +00:00
|
|
|
if ($bro->save($editfile,$R,$texte)) {
|
2017-10-06 16:04:36 +00:00
|
|
|
$msg->raise("INFO", "bro", _("Your file %s has been saved")." (".format_date(_('%3$d-%2$d-%1$d %4$d:%5$d'),date("Y-m-d H:i:s")).")", $editfile);
|
2011-06-04 14:28:57 +00:00
|
|
|
}
|
2006-04-26 12:28:53 +00:00
|
|
|
}
|
|
|
|
|
2018-06-24 14:49:43 +00:00
|
|
|
$addhead['css'][]='<link rel="stylesheet" href="/javascript/prettify/prettify.css" type="text/css" />';
|
2018-07-12 13:57:29 +00:00
|
|
|
$addhead['js'][]='<script src="/javascript/prettify/prettify.js" type="text/javascript"></script>';
|
2009-09-08 05:29:38 +00:00
|
|
|
include_once("head.php");
|
|
|
|
|
2006-04-26 12:28:53 +00:00
|
|
|
?>
|
|
|
|
<p>
|
2017-08-16 00:44:54 +00:00
|
|
|
<?php
|
|
|
|
echo $msg->msg_html_all();
|
|
|
|
?>
|
2016-05-23 14:08:23 +00:00
|
|
|
<h3><?php echo _("File editing")." <code>".ehe($R,false)."/<b>".ehe($editfile,false)."</b></code><br />"; ?></h3>
|
2006-04-26 12:28:53 +00:00
|
|
|
</p>
|
2014-01-10 15:37:50 +00:00
|
|
|
|
|
|
|
<?php
|
|
|
|
$content=$bro->content($R,$editfile);
|
|
|
|
?>
|
|
|
|
|
2009-09-08 05:29:38 +00:00
|
|
|
<form action="bro_editor.php" method="post"><br />
|
2016-05-20 12:21:47 +00:00
|
|
|
<?php csrf_get(); ?>
|
2014-01-10 15:37:50 +00:00
|
|
|
<div id="tabsfile">
|
|
|
|
<ul>
|
|
|
|
<li class="view"><a href="#tabsfile-view"><?php __("View"); ?></a></li>
|
|
|
|
<li class="edit"><a href="#tabsfile-edit"><?php __("Edit"); ?></a></li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<div id="tabsfile-view">
|
|
|
|
<?php
|
|
|
|
echo "<pre class='prettyprint' id='file_content_view' >$content</pre>";
|
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="tabsfile-edit">
|
|
|
|
<textarea id='file_content_editor' class="int" style="font-family: <?php echo $p["editor_font"]; ?>; font-size: <?php echo $p["editor_size"]; ?>; width: 90%; height: 400px;" name="texte"><?php
|
2012-08-29 07:25:33 +00:00
|
|
|
if (empty($content)) {
|
2013-01-31 17:00:39 +00:00
|
|
|
$error=_("This file is empty");
|
2012-08-29 07:25:33 +00:00
|
|
|
} else {
|
|
|
|
echo $content;
|
|
|
|
}
|
2011-06-04 14:28:57 +00:00
|
|
|
?></textarea>
|
2014-01-10 15:37:50 +00:00
|
|
|
</div>
|
|
|
|
</div><!-- tabsfile -->
|
|
|
|
<br/>
|
2013-10-18 09:59:03 +00:00
|
|
|
<?php if (!empty($error)) echo "<p class=\"alert alert-danger\">".$error."</p>"; ?>
|
2016-05-22 18:14:26 +00:00
|
|
|
<input type="hidden" name="editfile" value="<?php ehe($editfile); ?>" />
|
2016-05-23 14:08:23 +00:00
|
|
|
<input type="hidden" name="R" value="<?php ehe($R); ?>" />
|
2006-04-26 12:28:53 +00:00
|
|
|
|
|
|
|
<input type="submit" class="inb" value="<?php __("Save"); ?>" name="save" />
|
2009-09-08 05:29:38 +00:00
|
|
|
<input type="submit" class="inb" value="<?php __("Save & Quit"); ?>" name="saveret" />
|
2006-04-26 12:28:53 +00:00
|
|
|
<input type="submit" class="inb" value="<?php __("Quit"); ?>" name="cancel" />
|
2009-09-08 05:29:38 +00:00
|
|
|
<br />
|
2006-04-26 12:28:53 +00:00
|
|
|
</form>
|
2014-01-10 15:37:50 +00:00
|
|
|
|
|
|
|
<script type="text/javascript">
|
2016-08-09 14:40:11 +00:00
|
|
|
$(function() {
|
2018-06-24 14:49:43 +00:00
|
|
|
prettyPrint();
|
|
|
|
$( "#tabsfile" ).tabs();
|
2016-08-09 14:40:11 +00:00
|
|
|
<?php if ($editing) { ?>
|
2018-06-24 14:49:43 +00:00
|
|
|
$( "#tabsfile-edit" ).tabs( "option", "active", 1 );
|
2016-08-09 14:40:11 +00:00
|
|
|
<?php } ?>
|
|
|
|
});
|
2014-01-10 15:37:50 +00:00
|
|
|
|
|
|
|
$('#tabsfile').on('tabsbeforeactivate', function(event, ui){
|
2018-06-24 14:49:43 +00:00
|
|
|
var b = $('#file_content_editor').val();
|
|
|
|
$('#file_content_view').text( b );
|
|
|
|
$('#file_content_view').removeClass('prettyprinted');
|
|
|
|
PR.prettyPrint();
|
2014-01-10 15:37:50 +00:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
2011-05-18 20:26:12 +00:00
|
|
|
<?php include_once("foot.php"); ?>
|