phpcms 不支持iframe怎么辦?
在網(wǎng)上找過(guò)很多的辦法試著來(lái)解決的在 phpcms的內(nèi)容編輯器 下標(biāo)簽 iframe和JavaScript 被過(guò)濾的問(wèn)題,結(jié)果都不能如愿以?xún)敗?/p>
然后再接下來(lái)的幾天里面。我去把phpcmslibsunctionsglobal.func.php中的函數(shù)函數(shù)文件都看了一遍,終于找到了問(wèn)題所在。
發(fā)現(xiàn)149行的? trim_script()這個(gè)函數(shù)轉(zhuǎn)定義了標(biāo)簽,于是乎注釋掉。
function trim_script($str) { if(is_array($str)){ foreach ($str as $key => $val){ $str[$key] = trim_script($val); } }else{ $str = preg_replace ( '/<([/]?)script([^>]*?)>/si', '<\script\2>', $str ); $str = preg_replace ( '/<([/]?)iframe([^>]*?)>/si', '<\iframe\2>', $str ); $str = preg_replace ( '/<([/]?)frame([^>]*?)>/si', '<\frame\2>', $str ); $str = str_replace ( 'javascript:', 'javascript:', $str ); } return $str; }
修改成
立即學(xué)習(xí)“PHP免費(fèi)學(xué)習(xí)筆記(深入)”;
function trim_script($str) { if(is_array($str)){ foreach ($str as $key => $val){ $str[$key] = trim_script($val); } }else{ //$str = preg_replace ( '/<([/]?)script([^>]*?)>/si', '<\script\2>', $str ); //$str = preg_replace ( '/<([/]?)iframe([^>]*?)>/si', '<\iframe\2>', $str ); //$str = preg_replace ( '/<([/]?)frame([^>]*?)>/si', '<\frame\2>', $str ); $str = str_replace ( 'javascript:', 'javascript:', $str ); } return $str; }
然后再到內(nèi)容 編輯器里面去插入? iframe或者JavaScript 看看吧。是不是能成功的插入了呢!
PHP中文網(wǎng),大量的免費(fèi)PHPCMS教程,歡迎在線學(xué)習(xí)!
以上就是phpcms 不支持iframe怎么辦的詳細(xì)內(nèi)容,更多請(qǐng)關(guān)注php中文網(wǎng)其它相關(guān)文章!
PHP怎么學(xué)習(xí)?PHP怎么入門(mén)?PHP在哪學(xué)?PHP怎么學(xué)才快?不用擔(dān)心,這里為大家提供了PHP速學(xué)教程(入門(mén)到精通),有需要的小伙伴保存下載就能學(xué)習(xí)啦!
微信掃碼
關(guān)注PHP中文網(wǎng)服務(wù)號(hào)
QQ掃碼
加入技術(shù)交流群
Copyright 2014-2025 http://www.miracleart.cn/ All Rights Reserved | php.cn | 湘ICP備2023035733號(hào)