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

What should I do if phpcms does not support iframe?

藏色散人
Release: 2020-01-03 10:38:38
Original
2758 people have browsed it

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 ( &#39;/\<([\/]?)script([^\>]*?)\>/si&#39;, &#39;<\\script\\2>&#39;, $str );
$str = preg_replace ( &#39;/\<([\/]?)iframe([^\>]*?)\>/si&#39;, &#39;<\\iframe\\2>&#39;, $str );
$str = preg_replace ( &#39;/\<([\/]?)frame([^\>]*?)\>/si&#39;, &#39;<\\frame\\2>&#39;, $str );
$str = str_replace ( &#39;javascript:&#39;, &#39;javascript:&#39;, $str );
}
return $str;
}
Copy after login

修改成

function trim_script($str) {
if(is_array($str)){
foreach ($str as $key => $val){
$str[$key] = trim_script($val);
}
}else{
//$str = preg_replace ( &#39;/\<([\/]?)script([^\>]*?)\>/si&#39;, &#39;<\\script\\2>&#39;, $str );
//$str = preg_replace ( &#39;/\<([\/]?)iframe([^\>]*?)\>/si&#39;, &#39;<\\iframe\\2>&#39;, $str );
//$str = preg_replace ( &#39;/\<([\/]?)frame([^\>]*?)\>/si&#39;, &#39;<\\frame\\2>&#39;, $str );
$str = str_replace ( &#39;javascript:&#39;, &#39;javascript:&#39;, $str );
}
return $str;
}
Copy after login

然后再到内容 编辑器里面去插入  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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template