我将如何创建一个简单的脚本来实现该功能, 我只是想能够禁止/跟踪/阻止某些Ips /位置访问我的网站,但是我没有任何办法知道IP的位置,或者我只是想阻止某些IP访问我的网站,例如诸如SpyBots之类的东西:GoogleSpider或BingBOT。
答案 0 :(得分:0)
问题是为什么有人会创造这样的东西? 简单的答案是,这样它们就可以跟踪进入您托管DiscordPHP脚本的网站的IP,只要您愿意,就可以阻止/禁止IP和/或位置。
这就是您一直在寻找的脚本。 它是如此简单,并带有注释,因此任何不了解DiscordPHP-> DiscordWebhook的人都可以看到如何以及做什么:)
可以随意修改您的需求,我想向社区提供一些过去对我有所帮助的东西。
<?php
//======PUT YOUR DISCORD WEBHOOK HERE (RECCOMENDED: MAKE THE CHANNEL SO YOU CAN SEE IT ONLY)========\\
$webhookurl = "https://discordapp.com/api/webhooks/WEBHOOK_ID/WEBHOOK_TOKEN";
//===========IP TO LOCATION & TIME/DATE INFORMATION PULLED BY THE HOSTING SERVER ====================\\
$ip = $_SERVER['REMOTE_ADDR'];
$browser = $_SERVER['HTTP_USER_AGENT'];
$TheirDate = date('d/m/Y');
$TheirTime = date('G:i:s');
$details = json_decode(file_get_contents("http://ip-api.com/json/{$ip}"));
$flag = "https://www.countryflags.io/{$details->countryCode}/shiny/64.png";
$data = "**User IP:** $ip\n**Date:** $TheirDate\n**Time:** $TheirTime \n**Location:** $details->city \n**Region:** $details->region\n**Country** $details->country\n**Postal Code:** $details->zip";
//=====================================DISCORD PHP BOT STUFF=========================================\\
$json_data = array ('content'=>"$data", 'username'=>"New Visitor From $details->country", 'avatar_url'=> "$flag");
$make_json = json_encode($json_data);
$ch = curl_init( $webhookurl );
//==================CURL OPTIONS FOR POSTING THE INFORMATION PROVIDED ABOVE ==========================\\
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $make_json);
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt( $ch, CURLOPT_HEADER, 0);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
//===============THIS OUTPUTS THE CHANNEL SET BY THE WEBHOOK ==========================================\\
$response = curl_exec( $ch );
?>
答案 1 :(得分:-2)
$TheirTime = date('G:i:s');
应该
$TheirTime = time('G:i:s');