Home>Article>CMS Tutorial> What should I do if phpcms does not support iframe?

What should I do if phpcms does not support iframe?

藏色散人
藏色散人 Original
2020-01-03 10:38:38 2661browse

What should I do if phpcms does not support iframe?

phpcms 不支持iframe怎么办?

在网上找过很多的办法试着来解决的在 phpcms的内容编辑器 下标签 iframe和JavaScript 被过滤的问题,结果都不能如愿以偿。

然后再接下来的几天里面。我去把phpcms\libs\functions\global.func.php中的函数函数文件都看了一遍,终于找到了问题所在。

发现149行的 trim_script()这个函数转定义了标签,于是乎注释掉。

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; }

修改成

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; }

然后再到内容 编辑器里面去插入 iframe或者JavaScript 看看吧。是不是能成功的插入了呢!

PHP中文网,大量的免费PHPCMS教程,欢迎在线学习!

The above is the detailed content of What should I do if phpcms does not support iframe?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn