Skip to content

Commit

Permalink
ip block
Browse files Browse the repository at this point in the history
  • Loading branch information
taoyu65 committed Jan 14, 2020
1 parent 1b5748b commit 7cc911e
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/Http/Controllers/dashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,24 +72,24 @@ public function dashboard(Request $request)
$ip = $_SERVER['REMOTE_ADDR'];//'98.176.248.193';//
//$ip = file_get_contents('https://api.ipify.org');
//$query = json_decode(file_get_contents('http://ip-api.com/json/'.$ip));
$query = json_decode(file_get_contents("https://ipinfo.io/$ip/json"));
if(!isset($query->bogon) && !isset($query->error)) {
$country = $query->country;
$region = $query->region;
$city = $query->city;
$add = DB::table('ip_info')->insert([
'user_name' => $userName,
'ip' => $ip,
'country' => $country,
'region' => $region,
'city' => $city
]);

if ($add) {
$period = date('Y-M');
DB::table('ip_info_rate')->where('period', $period)->increment('rate', 1);
}
}
// $query = json_decode(file_get_contents("https://ipinfo.io/$ip/json"));
// if(!isset($query->bogon) && !isset($query->error)) {
// $country = $query->country;
// $region = $query->region;
// $city = $query->city;
// $add = DB::table('ip_info')->insert([
// 'user_name' => $userName,
// 'ip' => $ip,
// 'country' => $country,
// 'region' => $region,
// 'city' => $city
// ]);
//
// if ($add) {
// $period = date('Y-M');
// DB::table('ip_info_rate')->where('period', $period)->increment('rate', 1);
// }
// }
######################################################################

if (session('previousUrl'))
Expand Down

0 comments on commit 7cc911e

Please sign in to comment.