|
我在使用的 CI 的时候,如果开启XSS过滤
PHP复制代码 [color=rgb(102, 0, 0)][backcolor=rgb(247, 250, 255)][font="][size=9pt]$config[/size][/font][/backcolor][/color][color=rgb(67, 67, 67)][backcolor=rgb(247, 250, 255)][font="][size=9pt][[/size][/font][/backcolor][/color][color=rgb(119, 119, 119)][backcolor=rgb(247, 250, 255)][font="][size=9pt]'global_xss_filtering'[/size][/font][/backcolor][/color][color=rgb(67, 67, 67)][backcolor=rgb(247, 250, 255)][font="][size=9pt]] [/size][/font][/backcolor][/color][color=rgb(55, 113, 169)][backcolor=rgb(247, 250, 255)][font="][size=9pt]= [/size][/font][/backcolor][/color][color=rgb(0, 0, 255)][backcolor=rgb(247, 250, 255)][font="][size=9pt]TURE[/size][/font][/backcolor][/color][color=rgb(67, 67, 67)][backcolor=rgb(247, 250, 255)][font="][size=9pt];[/size][/font][/backcolor][/color] 复制代码
控制器接收表单数据:
PHP复制代码
[color=#660000]$img = $data['upload_data']['file_name'];
[/backcolor][/color][color=#660000]$title = $this->input->post('title');
[/backcolor][/color][color=#660000]$category = $this->input->post('category');
[/backcolor][/color][color=#660000]$tag = $this->input->post('tag');
[/backcolor][/color][color=#660000]$abstract = $this->input->post('abstract');
[/backcolor][/color][color=#660000]$weight = $this->input->post('weight');
[/backcolor][/color][color=#660000]$content = $this->input->post('content');
复制代码
我在插入数据库的时候CI会自动过滤掉html、js标签,用[recomve]代替。请问怎么解决这个问题?我不想让他过滤掉。
如果我关闭XSS过滤
PHP复制代码 [color=rgb(102, 0, 0)][backcolor=rgb(247, 250, 255)][font="][size=9pt]$config[/size][/font][/backcolor][/color][color=rgb(67, 67, 67)][backcolor=rgb(247, 250, 255)][font="][size=9pt][[/size][/font][/backcolor][/color][color=rgb(119, 119, 119)][backcolor=rgb(247, 250, 255)][font="][size=9pt]'global_xss_filtering'[/size][/font][/backcolor][/color][color=rgb(67, 67, 67)][backcolor=rgb(247, 250, 255)][font="][size=9pt]] [/size][/font][/backcolor][/color][color=rgb(55, 113, 169)][backcolor=rgb(247, 250, 255)][font="][size=9pt]= false[/size][/font][/backcolor][/color][color=rgb(67, 67, 67)][backcolor=rgb(247, 250, 255)][font="][size=9pt];[/size][/font][/backcolor][/color] 复制代码
控制器接收表单数据:
PHP复制代码
[color=#6600]$img = htmlspecialchars($data['upload_data']['file_name']);
[/backcolor][/color][color=#6600]$title = htmlspecialchars($this->input->post('title'));
[/backcolor][/color][color=#6600]$category = htmlspecialchars($this->input->post('category'));
[/backcolor][/color][color=#6600]$tag = htmlspecialchars($this->input->post('tag'));
[/backcolor][/color][color=#6600]$abstract = htmlspecialchars($this->input->post('abstract'));
[/backcolor][/color][color=#6600]$weight = htmlspecialchars($this->input->post('weight'));
[/backcolor][/color][color=#6600]$content = htmlspecialchars($this->input->post('content'));
复制代码
然后我在页面输出的时候,所有的html、js、php标签全都不见了
以下两段对比
CI:
PHP复制代码
connect_error ) {
die("连接失败: " . $conn->connect_error);
}
//查询数据条数的函数
function getCount ($table){
global $con;
$result = $conn->query("select count(*) as linecount from $table");
$count = $result->fetch_all(3);
return $count[0][0];
}
//分页函数
function getPageData ($table,$pageCount,$recoredCount,$order){
global $con;
$pageCount=($pageCount-1)*$recoredCount;
$sql="select * from $table order by $order desc limit $pageCount,$recoredCount";
$result=$conn->query($sql);
$pageDate=$result->fetch_all(3);
return $pageDate;
}
?>
复制代码
原生PHP:
PHP复制代码
<?php
header("Content-type: text/html; charset=utf-8");
$servername = "localhost";
$username = "root";
$password = "root";
$dbname = "dbname";
// 创建连接
$con = new mysqli ($servername, $username, $password, $dbname);
mysqli_set_charset($conn, "utf8");
if ($conn->connect_error) {
die("连接失败: " . $conn->connect_error);
}
//查询数据条数的函数
function getCount ($table){
global $con;
$result = $conn->query("select count(*) as linecount from $table");
$count = $result->fetch_all(3);
return $count[0][0];
}
//分页函数
function getPageData ($table,$pageCount,$recoredCount,$order){
global $con;
$pageCount=($pageCount-1)*$recoredCount;
$sql="select * from $table order by $order desc limit $pageCount,$recoredCount";
$result=$conn->query($sql);
$pageDate=$result->fetch_all(3);
return $pageDate;
}
?>
复制代码
请问这种情况怎么解决???
|
|