php记录所有post,get,cookie以及IP地址,来路,访问网址等 不指定

jed , 2018-3-14 11:18 , 代码编程 , 评论(0) , 阅读(8375) , Via 本站原创 | |

<?php
header("Content-type:text/html;charset=utf-8");


/**
* 程序说明:php记录所有post,get,cookie以及IP地址,来路,访问网址
* @author    yujianyue <admin@ewuyi.net>
* @homepage  http://12391.net
*/


//记录得到的
function slog($rr,$StrValue) {
  $logfile = fopen($rr,'a+');
  fwrite($logfile,"\r\n".$StrValue);
  fclose($logfile);
}

function arraforeach($arr) {
  static $str;
  static $keystr;
  if (!is_array($arr)) {
  return $arr;
  }
  foreach ($arr as $key => $val ) {
  $keystr=$keystr.$key;
  if (is_array($val)) {
  arraforeach($val);
  } else {
  $str[] = $val.$keystr;
  }
  }
  return implode($str);
}

function rlog($StrKey,$StrValue,$ArrReq,$method) {
  $StrValue=arraforeach($StrValue);
  return  "<tr><td>$method</td><td>$StrKey</td><td>$StrValue</td></tr>\r\n";
}

$linev = "<h1>".date('Y-m-d H:i:s')."</h1>\r\n";
$linev .= "<table>\r\n";

//逐个GET
  foreach($_GET as $key=>$value) {
$linev .= "\r\n".rlog($key,$value,$getfilter,"GET");
  }

//逐个POST
  foreach($_POST as $key=>$value) {
$linev .= "\r\n".rlog($key,$value,$postfilter,"POST");
  }

//逐个COOKIE
  foreach($_COOKIE as $key=>$value) {
$linev .= "\r\n".rlog($key,$value,$cookiefilter,"COOKIE");
  }

//尝试记录RAW等POST过来的xml,json数据
  $datainput = file_get_contents('php://input');
  if($datainput){
  $datainput=arraforeach($datainput);
$linev .= "\r\n".rlog("Input",$datainput,$datainput,"Input");
  }else{
  $datainput = $GLOBALS['HTTP_RAW_POST_DATA'];
  $datainput = arraforeach($datainput);
if($datainput) $linev .= "\r\n".rlog("Input",$datainput,$datainput,"RAW_POST");
  }

/*
$linev .=  "\r\n MYIP-=>".$_SERVER["REMOTE_ADDR"]."\r\n";
$linev .=  " From-=>".$_SERVER['HTTP_REFERER']."\r\n";
$linev .=  " Uurl-=>".$_SERVER["REQUEST_URI"]."\r\n";
$linev .=  " Agen-=>".$_SERVER['HTTP_USER_AGENT']."\r\n\r\n";
*/

$linev .=  "\r\n".rlog("From",$_SERVER['HTTP_REFERER'],$_SERVER['HTTP_REFERER'],"From");
$linev .=  "\r\n".rlog("Uurl",$_SERVER["REQUEST_URI"],$_SERVER["REQUEST_URI"],"Uurl");
$linev .=  "\r\n".rlog("MYIP",$_SERVER["REMOTE_ADDR"],$_SERVER["REMOTE_ADDR"],"MYIP");
$linev .=  "\r\n".rlog("Agen",$_SERVER['HTTP_USER_AGENT'],$_SERVER['HTTP_USER_AGENT'],"Agen");
$linev .=  "\r\n</table>\r\n";


$lines='<style type="text/css">table{border:1px solid #0180CF; margin:0 auto;font-size:12px;width:92%;}table td{border:1px solid #a2c6d3;padding:5px;word-wrap:break-word;word-break:break-all;}</style>';

$rr = './_12391.net_'.date('Y-m-d').'.html';//按天存放

if(!file_exists($rr)){
slog($rr,$lines);
}

slog($rr,$linev);
echo $lines;
echo $linev;


?>
发表评论

昵称

网址

电邮

打开HTML 打开UBB 打开表情 隐藏 记住我 [登入] [注册]