INCENTIVE VOTING


To set your postback URL go to My Dashboard, click your site or server then use Edit Configuration option.


  1. 1. Set your Postback URL (on Infinite Servers)


http://YOURDOMAIN/callback.php
To set this link use Edit Settings option from your server page. The name of file callback.php is just an example and it's not mandatory, feel free to name it as you like.


  1. 2. Update your voting link and add parameter to the end


http://infservers.com/server/vote/key/unique_server_id-PARAMETER
Your Infinite Server voting link should have an extra - and PARAMETER on end. Copy the LINK from Voting Code and add -USERNAME or -123456 or whatever you keep track of (PARAMETER can be only numbers, letters and _ ). For example if I want to check if username `jon` votes or not I make the link http://topg.org/CATEGORY/in-SITEID-jon.


  1. 3. Our response


Infinite Server will call your site after voting and the callback will look like this link: http://YOURDOMAIN/callback.php?u_resp=PARAMETER&ip=USERIP We sent you back the same PARAMETER and the call is made ONLY if the user has voted for you. Your callback.php should UPDATE at this point the user PARAMETER as Valid. In case he didn't voted we don't send any response.



Example



How your voting link should look like for User ID (first) or Username (second):
http://infservers.com/server/vote/key/unique_server_id-1234
http://infservers.com/server/vote/key/unique_server_id-jon


Our response, due first or second case, will be: http://YOURDOMAIN/callback.php?u_resp=1234&ip=125.125.125.125 http://YOURDOMAIN/callback.php?u_resp=jon&ip=125.125.125.125 Conclusion: The player with account id 1234 or username jon has voted for you in case we called your postback link with parameter. 125.125.125.125 is the IP address used by the player to vote on infinite servers. Please read our PHP example to understand how to capture our response. We will send you the http request callback ONLY when the user has voted for you. If you need help setting this up please contact us.



callback.php example

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

$ip_request = $_SERVER['REMOTE_ADDR']; //for Cloudflare $ip_request = $_SERVER["HTTP_CF_CONNECTING_IP"];
if($ip_request == INFINITE_IP) //check if response is coming from INFINITE SEREVERS
{
  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
  $u = preg_replace('/[^A-Za-z0-9\_]+/','',$_GET['u_resp']); //can be only numbers letters and _
  $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)
  //$u = mysql_escape_string($u); 
  //$user_ip = mysql_escape_string($user_ip);
  
  //or if using MySQLi (change $DB name to correct one)
  //$u = $DB->;real_escape_string($u);
  //$user_ip = $DB->;real_escape_string($user_ip);
  
  if(DEBUG == true) { 
   error_log(date('[Y-m-d H:i] ')."[GET] Parameters [u_resp]=$u [ip]=$user_ip".PHP_EOL, 3, LOG_FILE); 
  }
  
  //Note: we send the parameters $_GET['u_resp'] and $_GET['ip'] back ONLY! if user $u has voted
  //here run your code
  //first you should check if account $u is valid and exists in your database
  //also check if the user has voted in the last 12 hours
  //give points to user $u 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 INFINITE SERVERS.
  //ignore or log the $ip_request as invalid request in your database
}

CHECK IP

Check user IP voting records directly on our database


Just query this page to use it:


http://infservers.com/index/checkip?serverid=SERVER_ID&userip=USER_IP


The page will return 1 if the user has voted in the last 12 hours and 0 if he did not.
In case of any error like missing parameter or invalid values the page will return blank.
Best practice is to define a delaied time to check for the user IP, 10 minutes after user has voted. To do that you will need to create a function that runs every 10 minutes and checks ONLY the users that voted 10 minutes or more ago.
Probably a good solution for delay check is to Create a Cron Job or Windows Task Scheduler depending on your OS.
Our example is simply just for the call + result but we can help with more if needed. Just contact us.


IP CHECK EXAMPLE

 

 $_SERVER['REMOTE_ADDR']; //get your player or user IP address
          //or if Cloudflare $userip = $_SERVER["HTTP_CF_CONNECTING_IP"];
          define(INFINITE_URL_CHECK,"http://infservers.com/index/checkip?serverid=SERVER_ID&userip=".$userip.")"; //replace SERVER_ID with yours
          $voted = @file_get_contents(INFINITE_URL_CHECK); //check url to see response for UserIP
          if($voted)
          {
            echo 'Valid! User with IP '.$userip.' has voted!';
          }
          


Votifier


Minecraft Votifier

For Minecraft we use a special plugin called votifier. The voting process flow is like this:


  1. 1.Your player enters his username on our Voting Gateway.
  2. 2.We send response to your server if he has voted so you can reward him.

To auto-fill Minecraft username field change your voting link to this syntax:


 http://infservers.com/server/vote/key/unique_server_id-username
          

How to enable Votifier

You can enable and set this plugin on Dashboard while you add or edit your server.


Download and install the plugin

You can get votifier plugin from Bukkit or from Curse: Download Votifier . Second steep is to search bukkit forums for a good working votifier listener compatible with your minecraft version.


Get your votifier settings

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

Copyright 2017 infinite servers