<?php
error_reporting(0); 
include("config.php");
date_default_timezone_set('PRC');
$shijian=date('Y-m-d H:i:s' ,time());
$day=date("Y-m-d");
$zuori=date("Y-m-d",strtotime("-1 day"));
$ip=getIP();
$size='50';
function dbinsert($type,$str) {
$strto=mysql_query("INSERT INTO `$type` $str");
return $strto;
}
function dbquery($type,$str) {
$dbq=mysql_query("SELECT * FROM `$type` $str");
while($astr=mysql_fetch_array($dbq)){
$astrq[]=$astr;
}
return $astrq;
}
function dbquerysun($type,$str) {
$dbqsun=mysql_query("SELECT count(id) FROM `$type` $str");
$astrsun=mysql_fetch_array($dbqsun);
return $astrsun;
}
function dbdel($type,$str) {
$dbdel=mysql_query("delete FROM `$type` where $str");
return $rdel;
}
function queryall($type,$str) {
$bstr=mysql_query("SELECT * FROM `$type` $str");
$cstr=mysql_fetch_array($bstr);
return $cstr;
}
function upalldt($type,$str) {
$dbup=mysql_query("UPDATE `$type` SET $str");
return $dbup;
}
function writefile($wstr,$qstr){
$estr=fopen($wstr,"w");
fputs($estr,$qstr);
fclose($estr);
}
function ubo($bstr_str) { 
$rstr=eregi('select|insert|update|delete|script|iframe|\'|\/\*|\*|\.\.\/|\.\/|union|into|load_file|outfile', $bstr_str);    
if($rstr){ 
slog("\r\n操作IP: ".$_SERVER["REMOTE_ADDR"]."\r\n操作时间: ".strftime("%Y-%m-%d %H:%M:%S")."\r\n操作页面:".$_SERVER["PHP_SELF"]."\r\n提交方式: ".$_SERVER["REQUEST_METHOD"]."\r\n提交参数: ".$bstr_str); 
exit(); 
}else{ 
return $bstr_str; 
} 
} 
function random($tstr) { 
$ystr = ''; 
$ustr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz'; 
$istr = strlen($ustr) - 1; 
mt_srand((double)microtime() * 1000000); 
for($ostr = 0; $ostr < $tstr; $ostr++) 
{ 
$ystr .= $ustr[mt_rand(0, $istr)]; 
} 
return $ystr; 
} 
function getIP(){
static $astr;
if (isset($_SERVER)){
if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])){
$astr = $_SERVER["HTTP_X_FORWARDED_FOR"];
} else if (isset($_SERVER["HTTP_CLIENT_IP"])) {
$astr = $_SERVER["HTTP_CLIENT_IP"];
} else {
$astr = $_SERVER["REMOTE_ADDR"];
}
} else {
if (getenv("HTTP_X_FORWARDED_FOR")){
$astr = getenv("HTTP_X_FORWARDED_FOR");
} else if (getenv("HTTP_CLIENT_IP")) {
$astr = getenv("HTTP_CLIENT_IP");
} else {
$astr = getenv("REMOTE_ADDR");
}
}
return $astr;
}
function randColor(){
$sstr = array();
for($ostr = 0;$ostr<6;$ostr++){
$sstr[] = dechex(rand(0,15));
}
return implode('',$sstr);
}
function del_dir($dstr){
if(is_dir($dstr)){
foreach(scandir($dstr) as $cstr){
if($cstr == '.' || $cstr == '..'){
continue;
}
$fstr = $dstr .'/'. $cstr;
if(filetype($fstr) == 'dir'){
del_dir($fstr);
}else{
unlink($fstr);
}
}
rmdir($dstr);
}else{
return false;
}
}
function rarray_rand($gstr){ 
return mt_rand( 0, count( $gstr ) - 1 );
}
function varray_rand($gstr) { 
return $gstr[rarray_rand($gstr)];
}
function fRenamet($dirname,$lx){
$handle = opendir($dirname);
while(($fn = readdir($handle))!==false){
if($fn!='.'&&$fn!='..'){
$curDir = $dirname.'/'.$fn;
if(is_dir($curDir)){
fRename($curDir);
}else{
$suiji=random(20).date("YmdHis");
$path = pathinfo($curDir);
$newname = $path['dirname'].'/'.$suiji.'.'.$path['extension'];
if($lx=='glsp'){
$url = 'shipin/'.$suiji.'.'.$path['extension'];
}else{
$url = 'dlsp/'.$suiji.'.'.$path['extension'];
}
$urlpd=str_replace("../../","",$curDir);
rename($curDir,$newname);
if($lx=='glsp'){
$type="url='$url' where url='$urlpd'";
upalldt(shipin,$type);
}else{
$type="url='$url' where url='$urlpd'";
upalldt(daili,$type);
}
}
}
}
}
function cutstr($str,$cutleng){
$strleng =strlen($str); 
if($cutleng-->$strleng)
return $str;
$notchinanum = 0;
for($i=0;$i<$cutleng;$i++){
if(ord(substr($str,$i,1))<=128){
$notchinanum++;
}
}
if(($cutleng%2==1)&&($notchinanum%2==0)){
$cutleng++;
}
if(($cutleng%2==0)&&($notchinanum%2==1)){
$cutleng++;
}
return substr($str,0,$cutleng);
}

function dwz($dda,$dwzjk) {
if($dwzjk==1){
$dda2=file_get_contents("http://yy.gongju.at/?a=addon&m=wxdwz&token=fe10ece7e8bfdcb0ccc7ee9254830b12&long=".$dda);
$eda = json_decode($dda2,true);
$gda=$eda[short];
return $gda;
}elseif($dwzjk==2){
$dda2=file_get_contents("http://yy.gongju.at/?a=addon&m=wxdwz&token=fe10ece7e8bfdcb0ccc7ee9254830b12&long=".$dda);
$eda = json_decode($dda2,true);
$gda=$eda[short];
return $gda;
}
}
function ubourljc($url) {
$jcurl='http://wxcheck.wxjump-api.cn/926pzfzo/wxcheck/?url='.$url;
$ch = curl_init();
  
curl_setopt($ch, CURLOPT_URL, $jcurl);
   
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   
curl_setopt($ch, CURLOPT_HEADER, 0);

    
$data = curl_exec($ch);
   
curl_close($ch);
   
$paysj=json_decode($data, true); 
return $paysj[status];
}

function err() {
$code=$_SERVER["REQUEST_URI"];
$html ='<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">';
$html.='<html><head>';
$html.='<meta charset="gb2312">';
$html.='<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />';
$html.='<title>404 Not Found</title>';
$html.='</head><body>';
$html.='<h1>Not Found</h1>';
$html.='<p>The requested URL '.$code.' was not found on this server.</p>';
$html.='</body>';
$html.='</html>';
return  $html;
}
function slog($logs) { 
$val = "";
$val.='记录时间:'.date('YmdHis',time());
$val.= "\r\n";
$val.= "提交文本【";
$val.=$logs;
$val.= "\r\n";
$val.= "】";
$toppath=$_SERVER['DOCUMENT_ROOT']."/log/注入攻击记录".date('Ymd',time()).'.html';
$Ts=fopen($toppath,"a+"); 
fputs($Ts,$val."\r\n"); 
fclose($Ts); 
}
/*
foreach($_GET as $key=>$value){
ubo($value);
}
foreach($_POST as $key=>$value){
ubo($value);
}
foreach($_COOKIE as $key=>$value){
ubo($value);
}
*/
?>