mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-05 09:41:40 +09:00
fix #2229 자동저장 기능에 IP 대신 암호키를 대조하도록 변경
This commit is contained in:
parent
6a51d5a753
commit
f72ea052f1
7 changed files with 99 additions and 41 deletions
|
|
@ -409,32 +409,48 @@ class editorModel extends editor
|
|||
function getSavedDoc($upload_target_srl)
|
||||
{
|
||||
$auto_save_args = new stdClass();
|
||||
// Find a document by using member_srl for logged-in user and ipaddress for non-logged user
|
||||
if(Context::get('is_logged'))
|
||||
{
|
||||
$logged_info = Context::get('logged_info');
|
||||
$auto_save_args->member_srl = $logged_info->member_srl;
|
||||
}
|
||||
else
|
||||
{
|
||||
$auto_save_args->ipaddress = $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
$auto_save_args->module_srl = Context::get('module_srl');
|
||||
|
||||
// Get the current module if module_srl doesn't exist
|
||||
if(!$auto_save_args->module_srl)
|
||||
{
|
||||
$current_module_info = Context::get('current_module_info');
|
||||
$auto_save_args->module_srl = $current_module_info->module_srl;
|
||||
}
|
||||
|
||||
// Find a document by using member_srl for logged-in user and ipaddress for non-logged user
|
||||
if(Context::get('is_logged'))
|
||||
{
|
||||
$logged_info = Context::get('logged_info');
|
||||
$auto_save_args->member_srl = $logged_info->member_srl;
|
||||
}
|
||||
elseif($_COOKIE['autosave_certify_key_' . $auto_save_args->module_srl])
|
||||
{
|
||||
$auto_save_args->certify_key = $_COOKIE['autosave_certify_key_' . $auto_save_args->module_srl];
|
||||
}
|
||||
else
|
||||
{
|
||||
$auto_save_args->ipaddress = RX_CLIENT_IP;
|
||||
}
|
||||
|
||||
// Extract auto-saved data from the DB
|
||||
$output = executeQuery('editor.getSavedDocument', $auto_save_args);
|
||||
$saved_doc = $output->data;
|
||||
|
||||
// Return null if no result is auto-saved
|
||||
if(!$saved_doc) return;
|
||||
|
||||
// Return null if certify key does not match
|
||||
if($saved_doc->certify_key && !isset($auto_save_args->certify_key))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the auto-saved document already exists
|
||||
$oDocumentModel = getModel('document');
|
||||
$oSaved = $oDocumentModel->getDocument($saved_doc->document_srl);
|
||||
if($oSaved->isExists()) return;
|
||||
|
||||
// Move all the files if the auto-saved data contains document_srl and file
|
||||
// Then set document_srl to editor_sequence
|
||||
if($saved_doc->document_srl && $upload_target_srl && !Context::get('document_srl'))
|
||||
|
|
@ -443,8 +459,18 @@ class editorModel extends editor
|
|||
$oFileController = getController('file');
|
||||
$oFileController->moveFile($saved_doc->document_srl, $saved_doc->module_srl, $upload_target_srl);
|
||||
}
|
||||
else if($upload_target_srl) $saved_doc->document_srl = $upload_target_srl;
|
||||
elseif($upload_target_srl)
|
||||
{
|
||||
$saved_doc->document_srl = $upload_target_srl;
|
||||
}
|
||||
|
||||
// Change auto-saved data
|
||||
$saved_doc->certify_key = $auto_save_args->certify_key;
|
||||
if(!$saved_doc->certify_key)
|
||||
{
|
||||
$saved_doc->certify_key = Rhymix\Framework\Security::getRandom(32);
|
||||
setcookie('autosave_certify_key_' . $saved_doc->module_srl, $saved_doc->certify_key, time() + 86400, null, null, RX_SSL, true);
|
||||
}
|
||||
$oEditorController = getController('editor');
|
||||
$oEditorController->deleteSavedDoc(false);
|
||||
$oEditorController->doSaveDoc($saved_doc);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue