PHPWIND 5.3 運行代碼 功能實現(xiàn)代碼
更新時間:2009年06月01日 00:53:45 作者:
天架設了一個PHPWIND的論壇,想著要弄個運行代碼的功能出來,不過我只懂點ASP,又沒接觸過PHP,想著看看有沒前人樹,咱乘下涼就是了。查了下,發(fā)現(xiàn)只有老版本的插件可以實現(xiàn)這個功能。
照樣子弄了一下,發(fā)現(xiàn)數(shù)據(jù)格式已經(jīng)換了,想著弄弄看,隨便弄了下,感覺還有搞頭。不過里面有<br />,PHP的字符替換我也不懂,試了下preg_replace發(fā)現(xiàn)只能替換一個,搞笑了。上網(wǎng)猛查資料,發(fā)現(xiàn)大多人說要用函數(shù),汗汗。然后發(fā)現(xiàn)還有str_replace,試了下,總算可以了。
具體方法如下:
在template/你的模板名/read.html
在合適的地方加入:
<script>
function run_Code(code)
{
var pop=window.open("about:blank","");
pop.document.writeln(code);
//pop.location.reload();
}
function copy_Code(obj)
{
obj.focus();
obj.select();
document.execCommand('copy');
}
function save_Code(code)
{
var pop=window.open('','_blank','top=10000');
pop.document.writeln(code);
pop.document.execCommand('saveas','','code.html');
pop.close();
}
</script>
我是直接放到頂部了,嘎嘎。
然后到require/bbscode.php文件
找到
function phpcode($code){
將
$phpcode_htm[$codeid]="<h6 class="quote"><a href="javascript:" onclick="CopyCode(document.getElementById('code$codeid'));">Copy code</a></h6><blockquote id="code$codeid">".preg_replace("/^(<br />)?(.*)/is","\2",$code)."</blockquote>";
改成
$phpcode_htm[$codeid]="<form><font color=red>Code:</font><BR><TEXTAREA name ='codeArea' rows='10' style='WIDTH:100%;'>".str_replace("<br />"," ",$code)."</textarea><br> <input type=button class=btn value=運行代碼 onclick=run_Code(codeArea.value)> <input type=button class=btn value=復制代碼 onclick=copy_Code(codeArea)> <input type=button value=保存代碼 class=btn onclick=save_Code(codeArea.value) > <input type=reset value=清除再來 class=btn name=codeAre> <font color=blue size=2>[可以先修改代碼再運行]</font><form>";
傳上去覆蓋下:
不過發(fā)現(xiàn)我放了
<script>
alert("111");
</script>
居然彈出兩個框,悶悶,試試其他JS函數(shù),還算正常。
再次更新,已經(jīng)正常了
具體方法如下:
在template/你的模板名/read.html
在合適的地方加入:
復制代碼 代碼如下:
<script>
function run_Code(code)
{
var pop=window.open("about:blank","");
pop.document.writeln(code);
//pop.location.reload();
}
function copy_Code(obj)
{
obj.focus();
obj.select();
document.execCommand('copy');
}
function save_Code(code)
{
var pop=window.open('','_blank','top=10000');
pop.document.writeln(code);
pop.document.execCommand('saveas','','code.html');
pop.close();
}
</script>
我是直接放到頂部了,嘎嘎。
然后到require/bbscode.php文件
找到
復制代碼 代碼如下:
function phpcode($code){
將
復制代碼 代碼如下:
$phpcode_htm[$codeid]="<h6 class="quote"><a href="javascript:" onclick="CopyCode(document.getElementById('code$codeid'));">Copy code</a></h6><blockquote id="code$codeid">".preg_replace("/^(<br />)?(.*)/is","\2",$code)."</blockquote>";
改成
復制代碼 代碼如下:
$phpcode_htm[$codeid]="<form><font color=red>Code:</font><BR><TEXTAREA name ='codeArea' rows='10' style='WIDTH:100%;'>".str_replace("<br />"," ",$code)."</textarea><br> <input type=button class=btn value=運行代碼 onclick=run_Code(codeArea.value)> <input type=button class=btn value=復制代碼 onclick=copy_Code(codeArea)> <input type=button value=保存代碼 class=btn onclick=save_Code(codeArea.value) > <input type=reset value=清除再來 class=btn name=codeAre> <font color=blue size=2>[可以先修改代碼再運行]</font><form>";
傳上去覆蓋下:
不過發(fā)現(xiàn)我放了
<script>
alert("111");
</script>
居然彈出兩個框,悶悶,試試其他JS函數(shù),還算正常。
再次更新,已經(jīng)正常了
您可能感興趣的文章:
相關文章
wordpress?12個數(shù)據(jù)表結構和字段說明
WordPress安裝的時候數(shù)據(jù)庫會有12個默認的數(shù)據(jù)表,每張表的數(shù)據(jù)都包含了?WordPress?不同的功能??纯催@些表的結構,你能很容易的了解網(wǎng)站不同的部分都是存在哪里的。這篇文章主要介紹了wordpress?12個數(shù)據(jù)表結構和字段說明,需要的朋友可以參考下2023-04-04易優(yōu)eyoucms數(shù)據(jù)表結構和字段說明(數(shù)據(jù)字典)
EyouCms是基于TP5.0框架為核心開發(fā)的免費開源的企業(yè)內(nèi)容管理系統(tǒng),易優(yōu)基本包含了一個常規(guī)企業(yè)網(wǎng)站需要的一切功能。這篇文章主要介紹了易優(yōu)eyoucms數(shù)據(jù)表結構和字段說明(數(shù)據(jù)字典),需要的朋友可以參考下2023-04-04fastAdmin表單驗證validate的錯誤提示信息,如何改變位置?
fastAdmin表單驗證validate的錯誤提示,默認是在右側的n-right,如果放在右側不太好看,想調整到其他位置,該怎么操作呢?2023-08-08zblogphp、Z-Blog PHP數(shù)據(jù)庫結構及表中的字段詳細說明
如果你是一位開發(fā)者,你一定知道Zblog-PHP。它是一款非常流行的開源博客系統(tǒng),許多人使用它來創(chuàng)建自己的博客。在使用Zblog-PHP的過程中,你可能會遇到一些數(shù)據(jù)庫字段,這些字段可能會導致一些困惑。因此,在本文中,我們將詳細解釋Zblog-PHP數(shù)據(jù)庫字段的含義和作用。2023-03-03