Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Timed Voting System

Joined
Jun 2, 2010
Messages
3
Reaction score
18
Make a file called vote.php

PHP:
<center><p>
<table cellspacing=1 cellpadding=5>
<tr>
<form action="vote1.php" method="POST">
<tr><td class=list align=right><font size="5">Username:</font></td><td class=list><input type=text name=name maxlength="15"></td></tr>
<tr><td colspan=2 class=list><font color="#FF0000">This will give you 'one' votepoint. <br /> </font></td></tr>
<tr><td class=listtitle align=center colspan=2><input type=submit name=submit value='Vote'></td></tr>
</form>
</table>
</center>

then a file called vote1.php

PHP:
				<?php

$conn = mysql_connect("localhost", "root", "root") or die ('Error connecting to MySQL!');
mysql_select_db("shootsource");

$earnedpoints = false;
$account = $_POST['name'];
$account = mysql_real_escape_string($account);

if ($account == "") {
	echo 'Enter an account name!';
	exit();
}

$ip = $_SERVER['REMOTE_ADDR'];
$time = time();

$query = mysql_query("SELECT *, SUM(`times`) as amount FROM votingrecords WHERE account='$account' OR ip='$ip'");
$lasttime = mysql_fetch_array($query);
$amount = $lasttime['amount'];
$insertnew = false;	
if ($amount == "") {
	$insertnew = true;
}
$timecalc = $time - $lasttime['date'];
if (!$insertnew) {
	if ($timecalc < 43200) { 
		echo ' Hello '. $account .' you have already voted with this account ('. $account .') or IP ('. $ip .') in the last 12 hours!';
		echo ' Last voted on: '. date('M d\, h:i:s A', $lasttime['date']) .'';
		echo '<html>';
		echo '<head>';
		echo '<meta HTTP-EQUIV="REFRESH" content="10; url=/">';
		echo '</head>';
		echo '<body>';
		echo '<br><br>You will be redirected to the main website in 10 seconds.';
		echo '</body>';
		echo '</html>';
		exit();
	} else {				
		$update = mysql_query("UPDATE votingrecords SET account='$account', date='$time', times=times+1 WHERE ip='$ip'");
			if (!$update) {
    			$message  = 'Invalid query: ' . mysql_error() . "\n";
    			$message .= 'Whole query: ' . $update;
    			die($message);
			} else {
				$earnedpoints = true;
			}
		}
} else {
	$success = mysql_query("INSERT INTO votingrecords (`account`, `ip`, `date`, `times`) VALUES ('$account', '$ip', '$time', 1)");
	if (!$success) {
    		$message  = 'Invalid query: ' . mysql_error() . "\n";
    		$message .= 'Whole query: ' . $success;
    		die($message);
	} else {
		$earnedpoints = true;
	}
}




if ($earnedpoints) {
	$points = mysql_query("UPDATE accounts SET votingpoints = votingpoints + 1 WHERE name='$account'");               
	if (!$points) {

    		$message  = 'Invalid query: ' . mysql_error() . "\n";
    		$message .= 'Whole query: ' . $query;
    		die($message);
	}
	mysql_close($conn);
	echo '<html>';
	echo '<head>';
	echo '<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.gtop100.com/in.php?site=9999999">';
	echo '</head>';
	echo '</html>';
} else {
	echo 'There was an error processing your request.';
	exit();
}
?>

Execute this SQL

PHP:
DROP TABLE IF EXISTS `votingrecords`;
CREATE TABLE `votingrecords` (
  `account` varchar(13) NOT NULL default '0',
  `ip` varchar(30) NOT NULL default '0',
  `date` int(11) NOT NULL default '0',
  `times` bigint(20) unsigned NOT NULL default '0',
  PRIMARY KEY  (`account`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

and edit accounts and put in

votingpoints int(11) (tick notnull) (untick autoinc, unsigned and zerofill) and put 0 in the end.

Edit: Try and guess my real account :)
 
Last edited:
Newbie Spellweaver
Joined
May 13, 2008
Messages
90
Reaction score
4
Re: [Release]Timed Voting System

lol thanks..
 
Newbie Spellweaver
Joined
May 13, 2008
Messages
90
Reaction score
4
Re: [Release]Timed Voting System

I tried it, works perfectly. I lubs ju :3
 
Newbie Spellweaver
Joined
Jul 3, 2008
Messages
5
Reaction score
0
Re: [Release]Timed Voting System

yoo can u teach me how to code this stuff. like do i put those codes in text. documents and drag em in arber Source. than make SQL files.
 

Yum

Experienced Elementalist
Joined
Jan 30, 2009
Messages
265
Reaction score
3
Re: [Release]Timed Voting System

goodjob :D
 
Newbie Spellweaver
Joined
Aug 7, 2009
Messages
41
Reaction score
1
Re: [Release]Timed Voting System

Great job! Thanks a lot!
 
Zzzz...
Loyal Member
Joined
Dec 26, 2008
Messages
781
Reaction score
225
Re: [Release]Timed Voting System

LeakedVoting
Posts: 1

o_O name says it all?

Real account: no idea, could be the original maker or some leeching noob
 
Zzzz...
Loyal Member
Joined
Dec 26, 2008
Messages
781
Reaction score
225
Re: [Release]Timed Voting System

Off Topic: I should release the one I made for my friends server but I kinda like having a custom one

Ontopic: Yeah o.o
 
Joined
Jun 2, 2010
Messages
3
Reaction score
18
Well not really, AngyTheBitch released hers before Surface's vote timed system.

Sincerely, iAkira

I believe you have to type ("@votepoints") to acually gain it ingame, people are lazy nowadays. + thats alot more confusing. Not to mention it has like. 5 Tables.
 
Back
Top