웹에디터 시작"; if ($is_dhtml_editor) { if ($js) { $js = false; } $html .= ""; $html .= " "; $html .= ""; } else { $html .= "\n"; } $html .= "웹 에디터 끝"; return $html; } // 에디터 내용 저장 (TEXTAREA → DIV 대응) function get_editor_js($id, $is_dhtml_editor = true) { if ($is_dhtml_editor) { return " const iframe_{$id} = document.getElementById('rb-editor-frame-{$id}').querySelector('iframe'); if (iframe_{$id} && iframe_{$id}.contentWindow) { iframe_{$id}.contentWindow.postMessage({ type: 'rbeditor-get-content', editorId: '{$id}' }, '*'); } "; } else { return "var {$id}_editor = document.getElementById('{$id}');\n"; } } // 에디터 값이 비어 있는지 검사 (TEXTAREA → DIV 대응) function chk_editor_js($id, $is_dhtml_editor = true) { if ($is_dhtml_editor) { return " var content = document.getElementById('rb-{$id}-hidden').value; if (!content || content.trim() === '') { alert('내용을 입력해 주십시오.'); return false; } "; } else { return "if (!{$id}_editor.value) { alert(\"내용을 입력해 주십시오.\"); {$id}_editor.focus(); return false; }\n"; } } // Nonce 관련 상수 및 함수 정의 if (!defined('FT_NONCE_UNIQUE_KEY')) define('FT_NONCE_UNIQUE_KEY', sha1($_SERVER['SERVER_SOFTWARE'] . G5_MYSQL_USER . session_id() . G5_TABLE_PREFIX)); if (!defined('FT_NONCE_SESSION_KEY')) define('FT_NONCE_SESSION_KEY', substr(md5(FT_NONCE_UNIQUE_KEY), 5)); if (!defined('FT_NONCE_DURATION')) define('FT_NONCE_DURATION', 60 * 60); if (!defined('FT_NONCE_KEY')) define('FT_NONCE_KEY', '_nonce'); if (session_status() === PHP_SESSION_NONE) { session_start(); } function ft_nonce_create($action = '', $user = '', $timeoutSeconds = FT_NONCE_DURATION) { $secret = ft_get_secret_key($action . $user); set_session('token_' . FT_NONCE_SESSION_KEY, $secret); $salt = ft_nonce_generate_hash(); $time = time(); $maxTime = $time + $timeoutSeconds; $nonce = $salt . '|' . $maxTime . '|' . sha1($salt . $secret . $maxTime); return $nonce; } function ft_nonce_is_valid($nonce, $action = '', $user = '') { $secret = ft_get_secret_key($action.$user); $token = get_session('token_'.FT_NONCE_SESSION_KEY); if ($secret != $token) return false; if (!is_string($nonce)) return false; $a = explode('|', $nonce); if (count($a) != 3) return false; $salt = $a[0]; $maxTime = intval($a[1]); $hash = $a[2]; $back = sha1($salt . $secret . $maxTime); if ($back != $hash || time() > $maxTime) return false; return true; } function ft_get_secret_key($secret) { return md5(FT_NONCE_UNIQUE_KEY . $secret); } function ft_nonce_generate_hash() { $length = 10; $chars = '1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM'; $ll = strlen($chars) - 1; $o = ''; while (strlen($o) < $length) { $o .= $chars[rand(0, $ll)]; } return $o; }