Jump to content

Recommended Posts

i think the script they give isnt complete 

 

too bad im not good with php would be great if someone can help

 

<?php
$whitelistedIp     = "188.165.186.200";
$serverId         = "123";
$privateKey     = "123";

// check if the whitelisted IP is right and the POST elements exist
if ($whitelistedIp == $_SERVER["REMOTE_ADDR"] && isset($_POST["TYPE"]) && isset($_POST["TIMESTAMP"]) && isset($_POST["HASH"]))
{
    // it's a vote
    if ($_POST["TYPE"] == "VOTE" && isset($_POST["USER_ID"]))
    {
        // check the received hash
        if ($_POST["HASH"] == md5(sprintf("%s|%s|%s|%s|%s", $_POST["TYPE"], $serverId, $_POST["TIMESTAMP"], $_POST["USER_ID"], $privateKey)))
        {
            // yeah right hash
            $userId = $_POST["USER_ID"]; // the user id
            // TODO: do what you want to do
        }
        else
        {
            // no, no, no ... wrong hash ;-(
            echo "WRONG HASH";
        }
    }
    // it's a click
    else if ($_POST["TYPE"] == "CLICK")
    {
        if ($_POST["HASH"] == md5(sprintf("%s|%s|%s|%s", $_POST["TYPE"], $serverId, $_POST["TIMESTAMP"], $privateKey)))
        {
            // yeah right hash
            // TODO: do what you want to do
        }
        else
        {
            // no, no, no ... wrong hash ;-(
            echo "WRONG HASH";
        }
    }
    // it's nothing
    else
    {
        echo "NOTHING IS RIGHT";
    }
}
?>
Link to comment
Share on other sites

  • Premium

First of all, you have to create a new file on your site called whatever you like. eg: tm_api.php

Second, you have to put the code specified by them there.

I am using this code:

<?php
session_start();

include "./inc/core.inc.php";

$allowedIP	= "188.165.186.200";
$serverID	= "ID";
$privateKey	= "KEY";

if ($allowedIP == $_SERVER["REMOTE_ADDR"] && isset($_POST["TYPE"], $_POST["TIMESTAMP"], $_POST["HASH"]))
{
	if ($_POST["TYPE"] == "VOTE" && isset($_POST["USER_ID"]))
	{
		if ($_POST["HASH"] == md5(sprintf("%s|%s|%s|%s|%s", $_POST["TYPE"], $serverID, $_POST["TIMESTAMP"], $_POST["USER_ID"], $privateKey)))
		{
			$userId = (int)$_POST["USER_ID"];
			$vote->DoVote($userId);
		}
	}
}
?>

Where:

$serverID is your unique server id from topmetin.org. How you can find it? Go on the site, log in and click on the Serverlist link from header. There you will find your server and the Votelink.

The Votelink have this structure: https://topmetin.org/site/vote/serverID_serverName

Copy serverID and paste it in your file.

Also, you will find, near the Votelink, the private key. Copy that key to your file too and replace KEY (keep quotation).

 

Now replace

$vote->DoVote($userId);

with your code. eg:

mysql_query("UPDATE account.account SET coins=coins+5 WHERE id='$userId'");

Where 5 is how coins you want to give for every vote.

Tip: Do some logs to track votes. Also, you should force them to vote only once at 12 hours per account (even if topmetin.org does that already).

 

Also, replace

include "./inc/core.inc.php";

with your file which connects to database (if you don't know which is take it from another file -.- ).

 

Now the vote link.

First of all, put the link in a file which checks if a user is logged in (like User Panel or something). The link should look like that: https://topmetin.org/site/vote/serverID_serverName/userID

You should be able to get userID from sessions or something.

 

And the last step:

Go to the site and click on the Edit icon from your server (it's somewhere in the right) and in the field called API-Link (optional) put your API file link (eg: http://yourserver.com/tm_api.php).

  • Love 2
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.