TopMetin Vote4Coins System


Give your users some coins when they vote your server in TopMetin!

Here is an example Vote4Coins script for your server, remember to keep it in a secret URL, and place that URL in your server configuration so onle TopMetin can send you vote notifications.

<?php

/*
	Database Configuration
*/
$host = 'localhost';
$port = '3306';
$database = 'metin2';
$user = 'dbusername';
$password = 'dbpassword';

/*
	When a user votes for your server, TopMetin will send the information to this script
*/
if (!empty($_POST)) {
	//print_r($_POST); //use this to debug
	if (!empty($_POST['email']) && !empty($_POST['event']) ) {
		$email = mysql_escape_string( $_POST['email'] );
		$event = mysql_escape_string( $_POST['event'] );
		//now we have user's email and 'event type'

		echo 'email: '.$email.', event type: '.$event;
		//currently the only event type is 'vote':
		if ($event == 'vote') {
			//conect to database
			mysql_connect($host.":".$port, $user, $password);
			mysql_select_db($database) or die( "Database does not exist");

			//find user with that email and increase coins by 10
			$query = "UPDATE account.account SET coins=coins+10 WHERE login='$email' LIMIT 1";
			mysql_query($query) or die('Query failed: ' . mysql_error());

			//finish with an OK HTTP status
			exit(header("Status: 200 OK"));
		}
	}
}

?>

Need help with this? Contact us

© TopMetin.net 2013 - 2015
Made with Django. Made with Bootstrap Proudly Hosted by DigitalOcean