DDR爱好者之家 Design By 杰米

针对伪造的数据从URL提交的情况,首先是一个检查前一页来源的如下代码:

<"HTTP_REFERER"]; 
  $sub_len=strlen($servername); 
  $checkfrom=substr($sub_from,7,$sub_len); 
  if($checkfrom!=$servername)die("警告!你正在从外部提交数据!请立即终止!"); 
}
"htmlcode">
/*创建XHR对象*/
function createXHR()
{
  if (window.XMLHttpRequest){
    var oHttp = new XMLHttpRequest();
    return oHttp;
  } 
  else if (window.ActiveXObject){
    var versions = ["MSXML2.XmlHttp.6.0","MSXML2.XmlHttp.3.0"];
    for (var i = 0; i < versions.length; i++){
      try {
        var oHttp = new ActiveXObject(versions[i]);
        return oHttp;
      } catch (error) {}
    }
  }
  throw new Error("你的浏览器不支持AJAX!");
}
/*用AJAX向page页面传递数据*/
function ajaxPost(url,query_string='')
{
  var xhr;
  xhr = createXHR();
  xhr.open('POST',url,false);
  xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=gb2312");
  xhr.onreadystatechange = function(){if (xhr.readyState == 4)if (xhr.status != 200)return;}
  xhr.send(query_string);
}

DDR爱好者之家 Design By 杰米
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
DDR爱好者之家 Design By 杰米