mirror of
https://git.code.sf.net/p/seeddms/code
synced 2024-11-26 15:32:13 +00:00
fix possible CSRF attack by setting document name
This commit is contained in:
parent
dfb6061b41
commit
ab546099f1
|
@ -614,29 +614,34 @@ switch($command) {
|
|||
break; /* }}} */
|
||||
|
||||
case 'setdocumentname': /* {{{ */
|
||||
if(1||$user) {
|
||||
$document = $dms->getDocument($_REQUEST['id']);
|
||||
if($document) {
|
||||
if ($document->getAccessMode($user) >= M_READWRITE) {
|
||||
$oldname = $document->getName();
|
||||
if (!$document->setName($_REQUEST['name'])) {
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode(array('success'=>false, 'message'=>'Error setting name', 'data'=>''));
|
||||
} else {
|
||||
if($notifier) {
|
||||
$notifier->sendChangedNameMail($document, $user, $oldname);
|
||||
if($user) {
|
||||
if(checkFormKey('setdocumentname')) {
|
||||
$document = $dms->getDocument($_REQUEST['id']);
|
||||
if($document) {
|
||||
if ($document->getAccessMode($user) >= M_READWRITE) {
|
||||
$oldname = $document->getName();
|
||||
if (!$document->setName($_REQUEST['name'])) {
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode(array('success'=>false, 'message'=>'Error setting name', 'data'=>''));
|
||||
} else {
|
||||
if($notifier) {
|
||||
$notifier->sendChangedNameMail($document, $user, $oldname);
|
||||
}
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode(array('success'=>true, 'message'=>getMLText('splash_document_name_changed'), 'data'=>''));
|
||||
add_log_line();
|
||||
}
|
||||
} else {
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode(array('success'=>true, 'message'=>getMLText('splash_document_name_changed'), 'data'=>''));
|
||||
add_log_line();
|
||||
echo json_encode(array('success'=>false, 'message'=>getMLText('access_denied'), 'data'=>''));
|
||||
}
|
||||
} else {
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode(array('success'=>false, 'message'=>getMLText('access_denied'), 'data'=>''));
|
||||
echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_doc_id'), 'data'=>''));
|
||||
}
|
||||
} else {
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_doc_id'), 'data'=>''));
|
||||
echo json_encode(array('success'=>false, 'message'=>getMLText('invalid_request_token'), 'data'=>''));
|
||||
}
|
||||
}
|
||||
break; /* }}} */
|
||||
|
|
|
@ -2307,7 +2307,7 @@ $(function() {
|
|||
if(!empty($this->params['settings']->_inlineEditing)) {
|
||||
echo "<span class=\"editable\" contenteditable=\"true\"";
|
||||
if($object->isType('document'))
|
||||
echo " data-document=\"".$object->getId()."\"";
|
||||
echo " data-document=\"".$object->getId()."\" data-formtoken=\"".createFormKey('setdocumentname')."\"";
|
||||
echo ">".$text;
|
||||
echo "</span>\n";
|
||||
} else
|
||||
|
|
|
@ -2348,7 +2348,7 @@ $(function() {
|
|||
if(!empty($this->params['settings']->_inlineEditing)) {
|
||||
echo "<span class=\"editable\" contenteditable=\"true\"";
|
||||
if($object->isType('document'))
|
||||
echo " data-document=\"".$object->getId()."\"";
|
||||
echo " data-document=\"".$object->getId()."\" data-formtoken=\"".createFormKey('setdocumentname')."\"";
|
||||
echo ">".$text;
|
||||
echo "</span>\n";
|
||||
} else
|
||||
|
|
|
@ -617,9 +617,8 @@ $(document).ready( function() {
|
|||
|
||||
$("body").on("blur", "span.editable", function(e) { /* {{{ */
|
||||
console.log($(this).data('document'));
|
||||
console.log('Hallo'+$(this).text());
|
||||
e.preventDefault();
|
||||
$.post( "../op/op.Ajax.php", { command: "setdocumentname", id: $(this).data('document'), name: $(this).text() })
|
||||
$.post( "../op/op.Ajax.php", { command: "setdocumentname", id: $(this).data('document'), formtoken: $(this).data('formtoken'), name: $(this).text() })
|
||||
.done(function( data ) {
|
||||
noty({
|
||||
text: data.message,
|
||||
|
|
Loading…
Reference in New Issue
Block a user