关于UBB代码的[code]代码问题(300分)
nba23 2004-06-08 11:21:37 DISCUZ!2.0 论坛
include/discuzcode.php代码
----------------
function codedisp($code) {
global $thisbg, $codecount, $post_codecount, $codehtml;
$post_codecount++;
$code = htmlspecialchars(str_replace("\\\"", "\"", preg_replace("/^[\n\r]*(.+?)[\n\r]*$/is", "\\1", $code)));
$codehtml[$post_codecount] = "<br><br><center><table border=\"0\" width=\"90%\" cellspacing=\"0\" cellpadding=\"0\"><tr><td class=\"smalltxt\"> Code:</td><td align=\"right\"><a href=\"###\" class=\"smalltxt\" onclick=\"copycode(findobj('code$codecount'));\">[Copy to clipboard]</a> </td></tr><tr><td colspan=\"2\"><table border=\"0\" width=\"100%\" cellspacing=\"1\" cellpadding=\"10\" bgcolor=\"".BORDERCOLOR."\"><tr><td width=\"100%\" bgcolor=\"".ALTBG2."\" style=\"word-break:break-all\" id=\"code$codecount\">$code</td></tr></table></td></tr></table></center><br>";
$codecount++;
return "[\tDISCUZ_CODE_$post_codecount\t]";
}
---------------------------------
如何改成$code 在表单中正常显示?
如无忧脚本(51js.com)的这个样式:
function codedisp($code) {
global $thisbg, $codecount, $post_codecount, $codehtml;
$post_codecount++;
$code = textDecode(str_replace("\\\"", "\"", preg_replace("/^[\n\r]*(.+?)[\n\r]*$/is", "\\1", $code)));
$codehtml[$post_codecount] = "<br><textarea id=\"testcode$codecount\" rows=\"10\" cols=\"95\">$code</textarea><br><input type=\"button\" value=\"运行代码\" onclick=\"runCode(testcode$codecount)\"> <input type=\"button\" value=\"复制代码\" onclick=\"copyCode(testcode$codecount)\"> <input type=\"button\" value=\"另存代码\" onclick=\"saveCode(testcode$codecount)\"> 提示:你可以先修改部分代码再运行<br><br>";
$codecount++;
return "|\tDISCUZ_CODE_$post_codecount\t|";
}
------------------------
要解决的问题:
1.如何改成$code 在表单中正常显示?
2.若利用无忧这部分代码,那textDecode() 这个该如何定义?