auto update

dependabot/npm_and_yarn/ushio/www/session/lodash-4.17.15
iotcat 5 years ago
parent 6d835833ce
commit fddc8fc970
  1. 57
      ushio/www/log/functions.php
  2. 33
      ushio/www/log/iis.php

@ -194,24 +194,63 @@ function db__antisql($str)
/*****log******/
function yimian__log($table, $val, $index = ""){
function yimian__log($table, $val, $index = "", $cnt = null){
if($index != "") db__pushData(db__connect("log"), $table, $val, $index);
else db__pushData(db__connect("log"), $table, $val);
if(!isset($cnt)) $cnt = db__connect("log");
if($index != "") db__pushData($cnt, $table, $val, $index);
else db__pushData($cnt, $table, $val);
}
/** get from address **/
function get_from(){
if($_SERVER['HTTP_REFERER']) return $_SERVER['HTTP_REFERER'];
elseif($_REQUEST['from']) return $_REQUEST['from'];
if($_SERVER['HTTP_REFERER']) return $_SERVER['HTTP_REFERER'];
elseif($_REQUEST['from']) return $_REQUEST['from'];
}
function get_from_domain(){
$str = str_replace("http://","",get_from());
$str = str_replace("https://","",$str);
$strdomain = explode("/",$str);
return $strdomain[0];
$str = str_replace("http://","",get_from());
$str = str_replace("https://","",$str);
$strdomain = explode("/",$str);
return $strdomain[0];
}
/* get IP */
function getIp()
{
if (isset($_SERVER)) {
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$arr = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
foreach ($arr as $ip) {
$ip = trim($ip);
if ($ip != 'unknown') {
$realip = $ip;
break;
}
}
} else if (isset($_SERVER['HTTP_CLIENT_IP'])) {
$realip = $_SERVER['HTTP_CLIENT_IP'];
} else if (isset($_SERVER['REMOTE_ADDR'])) {
$realip = $_SERVER['REMOTE_ADDR'];
} else {
$realip = '0.0.0.0';
}
} else if (getenv('HTTP_X_FORWARDED_FOR')) {
$realip = getenv('HTTP_X_FORWARDED_FOR');
} else if (getenv('HTTP_CLIENT_IP')) {
$realip = getenv('HTTP_CLIENT_IP');
} else {
$realip = getenv('REMOTE_ADDR');
}
preg_match('/[\\d\\.]{7,15}/', $realip, $onlineip);
$realip = (!empty($onlineip[0]) ? $onlineip[0] : '0.0.0.0');
return $realip;
}

@ -4,11 +4,36 @@ include './functions.php';
header("Access-Control-Allow-Origin: *");
$fp=$_REQUEST['fp'];
$ip=$_REQUEST['ip'];
$city=$_REQUEST['city'];
$from=$_SERVER['HTTP_REFERER'];
$ip=getIp();
$domain=$_SERVER['HTTP_HOST'];
$from=$_REQUEST['url'];
$lang=$_REQUEST['lang'];
$timezone=$_REQUEST['timezone'];
$platform=$_REQUEST['platform'];
$ram=$_REQUEST['ram'];
$screen=$_REQUEST['screen'];
$userAgent=$_REQUEST['userAgent'];
$webgl=$_REQUEST['webgl'];
$rsid=$_REQUEST['sid'];
$sessiontime=$_REQUEST['sessiontime'];
if(isset($rsid) && isset($sessiontime)){
yimian__log("log_iis", array("sessiontime"=>$sessiontime), array("sid"=>$rsid));
die();
}
if(!isset($fp) || !isset($ip) || !isset($domain)) die();
yimian__log("log_iis",array("city"=>$city,"fp"=>$fp,"ip"=>ip2long($ip),"domain"=>get_from_domain(),"url"=>$from,"timestamp"=>date('Y-m-d H:i:s', time())));
if(!(isset($from) && strlen($from) > 5)) $from=$_SERVER['HTTP_REFERER'];
$sid=substr(md5(time()*rand()), 0, 16);
ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; 4399Box.560; .NET4.0C; .NET4.0E)');
$ipData = file_get_contents('http://ip-api.com/json/49.64.195.96');
$ipData = json_decode($ipData,true);
yimian__log("log_iis",array("sid"=>$sid,"country"=>$ipData['country'],"region"=>$ipData['regionName'],"city"=>$ipData['city'],"isp"=>$ipData['isp'],"address"=>$ipData['as'],"org"=>$ipData['org'],"latitude"=>$ipData['lat'],"longitude"=>$ipData['lon'],"fp"=>$fp,"ip"=>ip2long($ip),"domain"=>get_from_domain(),"url"=>$from,"timestamp"=>date('Y-m-d H:i:s', time()),"language"=>$lang,"timezone"=>$timezone,"platform"=>$platform,"ram"=>$ram,"screen"=>$screen,"useragent"=>$userAgent,"webgl"=>$webgl));
echo json_encode(array("sid"=>$sid, "ip"=>$ip));

Loading…
Cancel
Save