Safe Alert Request Error step 的解决办法
来源:互联网 发布:网络运维管理论坛 编辑:程序博客网 时间:2024/06/04 18:48
dedecms功能很强大,但总有些东西无法满足我们自己的需求,这就需要我们在设计模板时使用<dede:php>这个标记来编写程序,也总免不了要查询、更新、修改数据库。但是不是欣喜的编写完程序后运行程序系统却提示你Safe Alert Request Error step 1 或 Safe Alert Request Error step 2。引起这个的主要原因是dedecms 5.6开启了安全检测的功能,避免sql注入,提高系统的稳定性、安全性!我们完全可以在不关闭安全检测的前提下,实现这些功能!
比如下面这段代码:
{dede:php runphp='yes'}
$tag = trim($_SERVER['QUERY_STRING']);
$tags = explode('/', $tag);
if(isset($tags[1]))
{
$tag = urldecode($tags[1]);
}
if(isset($tags[2]))
{
$PageNo = intval($tags[2]);
}
if(empty($PageNo))$PageNo=1;
$PageNo=($PageNo-1);
$sql_tag="select * from `dede_archives` where `id` in (select `aid` from `dede_taglist` where `tag` like '$tag') and `litpic`<>'' order by click desc limit $PageNo,8";
if(!isset($dsql)||!is_object($dsql)){
$dsql=new DedeSql(false);}
$dsql->SetQuery($sql_tag);
$dsql->Execute();
@me=""
while($row=$dsql->GetArray()){
$me=$me."<img src='".$row['litpic']."'>";
}
{/dede:php}
该段代码理论上是实现查询某个TGA标签所对应的图片文章,而且是能翻页的!(这个只是个举例!)
但在实际执行过程中却提示“Safe Alert: Request Error step 2”;
经过研究发现,dedecms在执行自己编写的代码时会进行安全检测,以防被注入。牵扯到“select union”等数据库语句
有两种方法可以解决这个问题:
第一个方法:
在include文件夹中找到dedesql.class.php文件,打开后找到$this->safeCheck = true;
将“true”修改为false即可屏蔽掉安全检测。当然,这样存在一定的安全隐患
第二种方法:不屏蔽安全检测
dedecms不是对selecet等语句敏感吗,那我就不用select语句进行查询,自己创立一个select的代替者,如用chaxun代替select,这样上面的查询语句就可以写成:
$sql_tag="chaxun * from `dede_archives` where `id` in (chaxun `aid` from `dede_taglist` where `tag` like '$tag') and `litpic`<>'' order by click desc limit $PageNo,8";
估计你就要问了,这样怎么可能正常执行啊,瞎搞嘛!是的,这样肯定是不行的。我们需要对dedesql.class.php进行一定的修改。
原理就是将之前代替的“select”别名"chaxun"在安全检测后更正为select
在dedesql.class.php中找到函数function CheckSql($db_string,$querytype='select')
将函数的返回语句
return $db_string;
替换为
return str_replace("dede_database_chaxun","select",$db_string);
然后在查找CheckSql()这个函数,共有2处调用
一处为if($this->safeCheck) CheckSql($this->queryString,'update');
另一处为if($this->safeCheck)
{
CheckSql($this->queryString);
}
将这两处分别修改为
if($this->safeCheck) $this->queryString=CheckSql($this->queryString,'update');
和if($this->safeCheck)
{
$this->queryString=CheckSql($this->queryString);
}
好了,大功告成!如果需要使用到union,update等语句时都可以照此进行修改!
比如下面这段代码:
{dede:php runphp='yes'}
$tag = trim($_SERVER['QUERY_STRING']);
$tags = explode('/', $tag);
if(isset($tags[1]))
{
$tag = urldecode($tags[1]);
}
if(isset($tags[2]))
{
$PageNo = intval($tags[2]);
}
if(empty($PageNo))$PageNo=1;
$PageNo=($PageNo-1);
$sql_tag="select * from `dede_archives` where `id` in (select `aid` from `dede_taglist` where `tag` like '$tag') and `litpic`<>'' order by click desc limit $PageNo,8";
if(!isset($dsql)||!is_object($dsql)){
$dsql=new DedeSql(false);}
$dsql->SetQuery($sql_tag);
$dsql->Execute();
@me=""
while($row=$dsql->GetArray()){
$me=$me."<img src='".$row['litpic']."'>";
}
{/dede:php}
该段代码理论上是实现查询某个TGA标签所对应的图片文章,而且是能翻页的!(这个只是个举例!)
但在实际执行过程中却提示“Safe Alert: Request Error step 2”;
经过研究发现,dedecms在执行自己编写的代码时会进行安全检测,以防被注入。牵扯到“select union”等数据库语句
有两种方法可以解决这个问题:
第一个方法:
在include文件夹中找到dedesql.class.php文件,打开后找到$this->safeCheck = true;
将“true”修改为false即可屏蔽掉安全检测。当然,这样存在一定的安全隐患
第二种方法:不屏蔽安全检测
dedecms不是对selecet等语句敏感吗,那我就不用select语句进行查询,自己创立一个select的代替者,如用chaxun代替select,这样上面的查询语句就可以写成:
$sql_tag="chaxun * from `dede_archives` where `id` in (chaxun `aid` from `dede_taglist` where `tag` like '$tag') and `litpic`<>'' order by click desc limit $PageNo,8";
估计你就要问了,这样怎么可能正常执行啊,瞎搞嘛!是的,这样肯定是不行的。我们需要对dedesql.class.php进行一定的修改。
原理就是将之前代替的“select”别名"chaxun"在安全检测后更正为select
在dedesql.class.php中找到函数function CheckSql($db_string,$querytype='select')
将函数的返回语句
return $db_string;
替换为
return str_replace("dede_database_chaxun","select",$db_string);
然后在查找CheckSql()这个函数,共有2处调用
一处为if($this->safeCheck) CheckSql($this->queryString,'update');
另一处为if($this->safeCheck)
{
CheckSql($this->queryString);
}
将这两处分别修改为
if($this->safeCheck) $this->queryString=CheckSql($this->queryString,'update');
和if($this->safeCheck)
{
$this->queryString=CheckSql($this->queryString);
}
好了,大功告成!如果需要使用到union,update等语句时都可以照此进行修改!
- Safe Alert Request Error step 的解决办法
- Safe Alert Request Error step 的解决办法
- dedecms安全警告:Safe Alert: Request Error step 2!
- DEDE CMS安全警告:Safe Alert: Request Error step 2!
- DEDECMS安全警告:Safe Alert: Request Error step 2!
- Web_PHP_DedeCMS_织梦DedeCMS出现Safe Alert: Request Error step 1 ! 或Safe Alert: Request Error step 2!解决方法
- 织梦DedeCms中出现Safe Alert: Request Error step 1/2 的解决方法
- 织梦DedeCms出现Safe Alert: Request Error step 1/2 ! 解决方法
- Dedecms自定义sql 出现错误Safe Alert: Request Error step 2!
- 如何解决dedecms的Safe Alert
- request error请求错误S7-200 PLC连接step 7
- hadoop Safe mode is ON 的解决办法
- FCKeditor出现"XML request error: Internal Server Error(500)"错误的解决办法
- Error:Your step-into request resulted in an automatic step-over of a property or operator.
- "A transport-level error has occurred when sending the request to the server"的解决办法
- The server encountered an internal error that prevented it from fulfilling this request的一种解决办法
- 忘记 VSS(visual source safe) Admin 密码的解决办法!
- 五种360safe不能运行,启动,打开的解决办法。
- 哈夫曼编码简介
- 9-2 个人所得税计算器
- 城市新56个漂泊族 你是哪漂泊一族?
- 设置SharePoint2010列表的项目级权限
- Android:进程UID定义
- Safe Alert Request Error step 的解决办法
- 寄存器使用结构体进行空间地址的映射
- Activity LaunchMode & TaskAffinity
- 控件(CMSComm)进行串口编程
- asp.net 数组
- 10-25带条件查询
- iPhone应用程序编程指南---事件处理
- cout格式控制
- IOS CoreData 多表查询(上)