本地测试安装成功
discuzcode.func.php
查找
- function codedisp($code) {
- global $discuzcodes;
- $discuzcodes['pcodecount']++;
- $code = htmlspecialchars(str_replace('\"', '"', preg_replace("/^[\n\r]*(.+?)[\n\r]*$/is", "\\1", $code)));
- $discuzcodes['codehtml'][$discuzcodes['pcodecount']] = "<br><br><div class="smalltxt" style="margin-left: 2em; margin-right: 2em; font-weight: bold"><div style="float: left">CODE:</div><div style="text-align: right; float: right"><a href="###" class="smalltxt" onclick="copycode(findobj('code$discuzcodes[codecount]'));">[Copy to clipboard]</a></div></div><div class="altbg2" style="margin: 2em; margin-top: 3px; clear: both; padding: 10px; padding-top: 5px; border: ".INNERBORDERWIDTH."px solid ".BORDERCOLOR."; word-break: break-all" id="code$discuzcodes[codecount]">$code</div>";
- $discuzcodes['codecount']++;
- return "[\tDISCUZ_CODE_$discuzcodes[pcodecount]\t]";
- }
复制代码
换成
- function codedisp($code) {
- global $discuzcodes;
- $discuzcodes['pcodecount']++;
- $code = htmlspecialchars(str_replace('\"', '"', preg_replace("/^[\n\r]*(.+?)[\n\r]*$/is", "\\1", $code)));
- $discuzcodes['codehtml'][$discuzcodes['pcodecount']] = "<form><textarea style='border:solid 1px #5589AA;width:100%' name='dbg' rows='8'>$code</textarea>
- <br><input type='button' class='button' value='运行此代码' style='width:80px' onclick='runCode(this.form.dbg)'> <input type='button' class='button' value='复制到剪贴板' style='width:90px' onclick='copyCode(this.form.dbg)'> <input type='button' class='button' value='代码另存为' style='width:80px' onclick='saveCode(this.form.dbg)'> 提示:你可以先修改部分代码再运行</form><br>";
- $discuzcodes['codecount']++;
- return "[\tDISCUZ_CODE_$discuzcodes[pcodecount]\t]";
- }
复制代码
修改include/common.js
查找
- function copycode(obj) {
- var rng = document.body.createTextRange();
- rng.moveToElementText(obj);
- rng.scrollIntoView();
- rng.select();
- rng.execCommand("Copy");
- rng.collapse(false);
- }
复制代码
改成
- function copyCode(obj) {
- var rng = document.body.createTextRange();
- rng.moveToElementText(obj);
- rng.scrollIntoView();
- rng.select();
- rng.execCommand("Copy");
- rng.collapse(false);
- }
- function runCode(obj) {
- var winname = window.open('', "_blank", '');
- winname.document.open('text/html', 'replace');
- winname.document.writeln(obj.value);
- winname.document.close();
- }
- function saveCode(obj) {
- var winname = window.open('', '_blank', 'top=10000');
- winname.document.open('text/html', 'replace');
- winname.document.writeln(obj.value);
- winname.document.execCommand('saveas','','code.htm');
- winname.close();
- }
复制代码
完成 |