The Postback Function

Our goal is to make it easy and secure for your users to vote for and support your website and receive incentives such as credits. The system we have in place is quite simple and takes little programming knowledge to impliment.

The Basics

What happens is a user on your site is given a special voting link with their username or userid added to it. When this user votes we then take this username/userid and send it back to your server as a POST to your specified script to process and credit the user for voting. It is really that simple and you just need to enter URL to the script in your user control panel, implement the example script found below, and you are ready to go.

Example Voting Url

https://l2network.eu/index.php?a=in&u=TOPLIST_USERNAME&id=VOTER_USERNAME_OR_ID
You can simply switch out the url in your existing voting code from us as found in your control panel

Example Script

<?php

#Example PHP Postback Script

// Your Database Connection Details
$host = 'localhost';
$db_name = '';
$db_user = ''; 
$db_password = '';


mysql_connect($host, $db_user, $db_password);
mysql_select_db($db_name);

function _VoteReward($userId, $userIp, $valid) {

    if($valid == 1) {

        // Make userid safe to use in query
        $userId = mysql_real_escape_string($userId);
   
        // Check if that user voted already
        // Adjust this query to match your table, column names etc
        $voted = mysql_fetch_array(mysql_query("SELECT voted FROM vote_list WHERE user = '$userId'"));
        if(!$voted[0]) {
            // User has not voted, grant him reward, for example points
            mysql_query("UPDATE votepoints SET points = points + 1 WHERE user = '$userId'");
        }
        else {
            // Do whatever you want if he voted already. Maybe a log of false votes
        }

    }

}

//-------------------------- Don't change anything below this! ----------------------------- //

$ipsWhitelist = array('51.195.47.198','104.26.4.193','104.26.5.193');	

$userId = isset($_POST['userid']) ? $_POST['userid'] : null;
$userIp = isset($_POST['userip']) ? $_POST['userip'] : null;
$valid  = isset($_POST['voted']) ? intval($_POST['voted']) : 0;

$result = false;
if (!empty($userId) && !empty($userIp)) {

    if (in_array($_SERVER['REMOTE_ADDR'], $ipsWhitelist)) {
        $result = true;
        _VoteReward($userId, $userIp, $valid);
    }

}

if ($result) {
    echo 'OK';
}

//Close Connection
mysql_close();

?>


The extern IP check function

If you quickly want to see if a user voted already simply visit this url
https://l2network.eu/index.php?a=in&u=TOPLIST_USERNAME&ipc=THE_IP_TO_CHECK

As you can see this looks like a normal vote link, but will NOT do any vote, instead it only executes a database query and then returns either 0 or 1 (can be used with cUrl etc.) A 0 returned means the user did not vote on that day when the check was called, 1 means the user voted already.