<var id="xvh3p"><noframes id="xvh3p"><var id="xvh3p"></var><listing id="xvh3p"><strike id="xvh3p"><listing id="xvh3p"></listing></strike></listing>
<var id="xvh3p"><strike id="xvh3p"><var id="xvh3p"></var></strike></var><th id="xvh3p"><strike id="xvh3p"><th id="xvh3p"></th></strike></th>
<span id="xvh3p"><noframes id="xvh3p"><dl id="xvh3p"></dl>
<span id="xvh3p"><noframes id="xvh3p">
<dl id="xvh3p"><noframes id="xvh3p">
<listing id="xvh3p"><noframes id="xvh3p"><listing id="xvh3p"><strike id="xvh3p"><listing id="xvh3p"></listing></strike></listing><th id="xvh3p"><strike id="xvh3p"><th id="xvh3p"></th></strike></th>
<th id="xvh3p"><strike id="xvh3p"></strike></th>
<dl id="xvh3p"><noframes id="xvh3p">
<th id="xvh3p"><noframes id="xvh3p">

观点

互联网+时代,说建站,谈运营与网络营销

一劳永逸的织梦(dedecms)安全代码

时间:2020-12-21

为了让大家的CMS更安全,有需要的手工在config_base.php里加上
打开
config_base.php
找到

//禁止用户提交某些特殊变量
$ckvs = Array('_GET','_POST','_COOKIE','_FILES');
foreach($ckvs as $ckv){
  if(is_array($$ckv)){
    foreach($$ckv AS $key => $value)
      if(eregi("^(cfg_|globals)",$key)) unset(${$ckv}[$key]);
  }
}

改为下面代码
//把get、post、cookie里的<? 替换成 <?
$ckvs = Array('_GET','_POST','_COOKIE');
foreach($ckvs as $ckv){
  if(is_array($$ckv)){
    foreach($$ckv AS $key => $value)
      if(!empty($value)){
        ${$ckv}[$key] = str_replace('<'.'?','&'.'lt;'.'?',$value);
        ${$ckv}[$key] = str_replace('?'.'>','?'.'&'.'gt;',${$ckv}[$key]); 内容来自dedecms 
      }
      if(eregi("^cfg_|globals",$key)) unset(${$ckv}[$key]);
  }
}
//检测上传的文件中是否有PHP代码,有直接退出处理
if (is_array($_FILES)) {
foreach($_FILES AS $name => $value){
  ${$name} = $value['tmp_name'];
  $fp = @fopen(${$name},'r');
  $fstr = @fread($fp,filesize(${$name}));
  @fclose($fp);
  if($fstr!='' && ereg("<\?",$fstr)){
      echo "你上传的文件中含有危险内容,程序终止处理!";
      exit();
  }
}
}
0
首页
案例
关于
联系