投票检查是什么?

通过在投票网关输入正确的验证安全码来检查玩家是否为您的站点或服务器投票的一个系统。

Postback PHP

Whitelist IP: monitor.topg.org in your Firewall Settings.

如要设置您的回发URL,请至控制面板,点击您的站点或服务器,然后使用编辑配置选项。

1. 请设置您的回发URL(在TopG上):

https://YOURDOMAIN/postback.php
如要设置此链接,请使用您的服务器页面的编辑设置选项。
文件名称postback.php只是一个范例,并不是强制性的,您可以随便给它命名。


2. 更新您的投票链接,并在末尾添加参数:

https://topg.org/CATEGORY/in-SITEID-PARAMETER
您的TopG投票链在末尾应有一个额外的“-”和参数。从投票代码中复制链接,加上-USERNAME或-123456或您监控的其他参数(参数只可以是数字、字母和下划线 _)。例如,如果想要检查用户名`Razor`是否投票,链接为: https://topg.org/CATEGORY/in-SITEID-Razor.

3. 我们的响应:

投票后,TopG会调用您的站点,回叫将类似于该链接:
https://YOURDOMAIN/postback.php?p_resp=PARAMETER&ip=USERIP
只有在用户为您投了票时,我们才会发回相同的参数并调用, 这时,您的postback.php会更新该用户参数为有效。如果他没有投票,我们不会发送任何响应。


例如:

对于用户ID(第1个)或用户名(第2个),您的投票链接会是怎么样的?:
https://topg.org/CATEGORY/in-SITEID-1234
https://topg.org/CATEGORY/in-SITEID-Razor

对于第1个或第2个案例,我们的响应将是:
https://YOURDOMAIN/postback.php?p_resp=1234&ip=123.123.123.123
https://YOURDOMAIN/postback.php?p_resp=Razor&ip=123.123.123.123
如果我们用参数调用您的回发链接,结果:ID为1234或用户名为Razor的玩家已经为您投票。
123.123.123.123 is the IP address used by the player to vote on Topg.
请阅读我们的PHP示例来了解如何捕获我们的响应。只有当用户为您投票时,我们才能给您送http请求调用。如果您需要帮助设置,请联系我们。

How to fix voting callback on topg for Fusion CMS:
If you are using Fusion CMS go to /applications/modules/vote/plugins/topg.php and change line 21 to this:
return $this->CI->input->ip_address() == gethostbyname('monitor.topg.org');

postback.php example


define("DEBUG", 0); //set to 1 to enable debuger
define("LOG_FILE", "_postback.log"); //if debug is enabled will create this file for logs
define("TOPG_IP", gethostbyname("monitor.topg.org")); //This is TopG IP address

$ip_request = $_SERVER['REMOTE_ADDR']; //for Cloudflare $ip_request = $_SERVER["HTTP_CF_CONNECTING_IP"];
if($ip_request == TOPG_IP) //check if response is coming from TopG
{
	if(DEBUG == true) {	
	 error_log(date('[Y-m-d H:i] ')."[OK] Valid callback: $ip_request".PHP_EOL, 3, LOG_FILE);	 
	}
	
	//get the parameters response from us and clean them
	$p = preg_replace('/[^A-Za-z0-9\_\-]+/','',$_GET['p_resp']); //can be only numbers letters, minus and underscore
	$user_ip = preg_replace('/[^0-9\.]+/','',$_GET['ip']); //can be only numbers and dots
	
	//connect to database
	
	//if using MySQL uncomment the following lines (remove slashes)
	//$p = mysql_escape_string($p); 
	//$user_ip = mysql_escape_string($user_ip);
	
	//or if using MySQLi (change $DB name to correct one)
	//$p = $DB->real_escape_string($p);
	//$user_ip = $DB->real_escape_string($user_ip);
	
	if(DEBUG == true) {	
	 error_log(date('[Y-m-d H:i] ')."[GET] Parameters [p_resp]=$p [ip]=$user_ip".PHP_EOL, 3, LOG_FILE); 
	}
	
	//Note: we send the parameters $_GET['p_resp'] and $_GET['ip'] back ONLY! if user $p has voted
	//here run your code
	//first you should check if account $p is valid and exists in your database
	//also check if the user has voted in the last 12 hours
	//give points to user $p that voted with ip $user_ip
	//close database
}
else
{
	if(DEBUG == true) {	
	 error_log(date('[Y-m-d H:i] ')."[Invalid] Invalid request: $ip_request".PHP_EOL, 3, LOG_FILE); 
	}
	//handle invalid request when callback is NOT from TopG.
	//ignore or log the $ip_request as invalid request in your database
}

Minecraft Votifier

Minecraft Votifier

Whitelist IP: monitor.topg.org in your Firewall Settings.

对于Minecraft,我们使用一个叫做votifier的特殊插件。投票流程像这样:
  1. 您的玩家在我们投票网关输入他的用户名。
  2. 如果他已投票,我们会发送响应到您的服务器
TOP: To auto-fill Minecraft username field change your voting link to this syntax:
https://topg.org/Minecraft/in-SITEID-username

如何启用Votifier

在添加或编辑您的服务器时,您可以在控制面板启用并设置该插件。

下载并安装插件

您可以从Bukkit或Curse获得votifier插件: Download Votifier . 第二步是搜索bukkit论坛,寻找与您的minecraft兼容的能良好运行的votifier监听器。

获取您的votifier设置

PUBLIC KEY it's a long string file located: /plugins/Votifier/rsa/public.key. Copy-paste ALL of it.
VOTIFIER IP and VOTIFIER PORT settings can be found inside: /plugins/Votifier/config.yml
host: VOTIFIER IP //your external IP address, the one used to connect to play
port: VOTIFIER PORT //the default votifier port is 8192
debug: false //set to true to see connection details in console 
listener_folder: plugins/Votifier/listeners
我们强烈建议在测试新topsites时,启用调试模式(debug: true)。