From 417ac8f4d1c5966bed51c576d6a5700566ed37de Mon Sep 17 00:00:00 2001 From: IoTcat Date: Wed, 20 Mar 2019 16:25:11 +0800 Subject: [PATCH] add moe api log --- server/cn/home/www/api/www-api/moe/index.php | 2 +- server/cn/home/www/functions.php | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/server/cn/home/www/api/www-api/moe/index.php b/server/cn/home/www/api/www-api/moe/index.php index a8755de..d652537 100644 --- a/server/cn/home/www/api/www-api/moe/index.php +++ b/server/cn/home/www/api/www-api/moe/index.php @@ -10,7 +10,6 @@ $n_loli = 120; $n_normal = 149; $n_star = 10; - $r = $_REQUEST['i']; if(isset($_REQUEST['i'])) $r = $_REQUEST['i']; @@ -70,6 +69,7 @@ if(!isset($_REQUEST['k'])){ } } +yimian__log("log_api", array("api" => "moe", "timestamp" => date('Y-m-d H:i:s', time()), "ip" => ip2long(get_ip()), "_from" => get_from(), "content" => $r."/".$id)); die(); diff --git a/server/cn/home/www/functions.php b/server/cn/home/www/functions.php index 953cccb..66fca00 100644 --- a/server/cn/home/www/functions.php +++ b/server/cn/home/www/functions.php @@ -365,9 +365,18 @@ function db__antisql($str) } +/*****log******/ +function yimian__log($table, $val){ + + db__pushData(db__connect("log"), $table, $val); +} + + + + /***tools***/ //fnct of get usr ip::()::(ip) -function getip() +function get_ip() { if (getenv("HTTP_CLIENT_IP") && strcasecmp(getenv("HTTP_CLIENT_IP"), "unknown")) { @@ -395,6 +404,15 @@ function getip() return ($ip); } +/** get from address **/ +function get_from(){ + + if($_SERVER['remote_addr']) return $_SERVER['remote_addr']; + elseif($_SERVER['HTTP_HOST']) return $_SERVER['HTTP_HOST']; + elseif($_SERVER['HTTP_REFERER']) return $_SERVER['HTTP_REFERER']; + elseif($_REQUEST['from']) return $_REQUEST['from']; +} + /**functions for aplayer**/ //put this function to where you want the aplayer to dispaly