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 V2 (By Cinos11)

Experienced Elementalist
Joined
Jun 17, 2008
Messages
247
Reaction score
76
I've decided to release to the public my version of the Timed Voting System.
It's been completely rewritten to fix many things that v1's voting system had problems with.

To get TVS V2 up and running, create a php file and paste this in it:

PHP:
<?php
	##########Configuration#############
	#Voting Script by Cinos11 of RageZone#
	#################################
	$db['host'] = 'localhost';
	$db['user'] = 'root';
	$db['pass'] = 'root';
	$db['database'] = 'odinms';
	$links['gtop100'] = 'http://gtop100.com/';
	$settings['require-account'] = false; /* Change to true, if you want to require accounts */
	$settings['action'] = '/page/vote.html'; /* The page your script is located */
	#################################
	$conn = mysql_connect($db['host'], $db['user'], $db['pass']) or die('Error - Could not connect to MySQL!');
	mysql_select_db($db['database']) or die('Error - Could not connect to database!');
	
	$earnedpoints = false;$insertnew = false;
	$ip = mysql_real_escape_string($_SERVER['REMOTE_ADDR']); 
	$time = mysql_real_escape_string(time()); 
	$account = mysql_real_escape_string($_POST['name']); 
	
	if ($account == '' && isset($_POST['submit']) && $settings['require-account'] == true) {$funct_error = 'You\'re required to provide your username!';}
	elseif(isset($_POST['submit'])) {
		$result = mysql_query("SELECT *, SUM(times) as amount FROM votingrecords WHERE NOT account='' AND NOT account='0' AND account='".$account."' OR ip='".$ip."'") or die('Error - Could not look up vote record!'); 
		$row = mysql_fetch_array($result); 
		$timecalc = $time - $row['date'];

		if ($row['amount'] == '' || $timecalc > 43200) {
			if($row['amount'] == '') {
				$result = mysql_query("INSERT INTO votingrecords (ip, account, date, times) VALUES ('".$ip."', '".$account."', '".$time."', '1')") or die ('Error - Could not update vote records!');
			}
			else {
				$result = mysql_query("UPDATE votingrecords SET ip='".$ip."', account='".$account."', date='".$time."', times='1' WHERE ip='".$ip."' OR account='".$account."'") or die ('Error - Could not update vote records!');
			}
			$earnedpoints = true; 
			if ($earnedpoints == true) {
				if ($account != '') {$result = mysql_query("UPDATE accounts SET votingpoints = votingpoints + 1 WHERE name='".$account."'") or die ('Error - Could not update vote points!');}
				$funct_msg = '<meta http-equiv="refresh" content="0; url='.$links['gtop100'].'">';
				$redirect = true;
			}
		}
		elseif($timecalc < 43200 && $row['amount'] != '') {
			$funct_msg = 'You\'ve already voted within the last 12 hours!';
			$funct_msg .= '<br />Vote time: '. date('M d\, h:i A', $row['date']);
		}
		else {
			$funct_error = 'Unknown Error';
		}
	}
	
	mysql_close($conn);

	if($redirect == true) {
		echo $funct_msg;
	}
	
	else { ?>
		
		<table style="border-width:1px;border-style:solid;background:#99CCFF;padding:2px;text-align:center;margin:auto;"> 
			<form action="<?php $settings['action']; ?>" method="post"> 
				<?php 
					if($funct_msg != '') {echo '<tr><td colspan="2"><div style="background-color:#008000;padding:10px 2px 10px 2px;margin:10px 0 15px 0;text-align:center;color:#000000;">'.$funct_msg.'</div></td></tr>';} 
					if($funct_error != '') {echo '<tr><td colspan="2"><div style="background-color:#FF0000;padding:10px 2px 10px 2px;margin:10px 0 15px 0;text-align:center;color:#000000;">'.$funct_error.'</div></td></tr>';} 
				?>
				<tr>
					<td colspan="2" style="padding:5px;"><b>Input your username for 1 votepoint</b></td>
				</tr> 
				<tr> 
					<td>Username:</td>
					<td><input type="text" name="name" maxlength="15" /></td>
				</tr>
				<tr>
					<td colspan="2">
						<input type="submit" name="submit" value="Vote" />
					</td>
				</tr>
			</form>
		</table> 
<?php } ?>

Now that we got that finished, your going to need to adjust the configuration settings:

1) The first 4 should be your obvious database settings.
2) The gtop100 is your voting URL.
3) require-account, is set to false by default. To require accounts to vote, set this to true.
4) action is where your voting script is located.


Now your next step is to execute the SQL script into your database:
PHP:
DROP TABLE IF EXISTS `votingrecords`;
CREATE TABLE `votingrecords` (
  `ip` varchar(30) NOT NULL DEFAULT '0',
  `account` varchar(13) NOT NULL DEFAULT '0',
  `date` int(11) NOT NULL DEFAULT '0',
  `times` bigint(20) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`ip`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

If you decide to release this script to another forum,
please leave the credits in the php code.

I hope this helps many of you! :thumbup:
 
may web.very maple.pls.
Loyal Member
Joined
Aug 12, 2009
Messages
1,810
Reaction score
606
This is a nice cleanup of the original, remove the earnpoints since its useless, also I have a custom voting system, so a little tip, check if they jsut insert white spaces also remvoe this part
PHP:
elseif($timecalc < 43200 && $row['amount'] != '') { [
add a }else{ that unknown error shouldn't occur at all I suppose,unless a hacker goes in db to change that value o.o..
 
Experienced Elementalist
Joined
Jun 17, 2008
Messages
247
Reaction score
76
This is a nice cleanup of the original, remove the earnpoints since its useless, also I have a custom voting system, so a little tip, check if they jsut insert white spaces also remvoe this part
PHP:
elseif($timecalc < 43200 && $row['amount'] != '') { [
add a }else{ that unknown error shouldn't occur at all I suppose,unless a hacker goes in db to change that value o.o..
I prefer to keep those there in case a "new php developer" decides to mess with the code.

If an error occurs because of those changes, it should help them debug the problem.

EDIT: Also if they decide to post "just" white spaces, it falls back to using an IP.
Its useless to double vote if your account doesn't receive any votepoints.
 
Last edited:
may web.very maple.pls.
Loyal Member
Joined
Aug 12, 2009
Messages
1,810
Reaction score
606
Wait, wouldn't that amount calling be useless since there's a default value '0' it would never be ''? (I know that check if they voted before)
 
Experienced Elementalist
Joined
Jun 17, 2008
Messages
247
Reaction score
76
Wait, wouldn't that amount calling be useless since there's a default value '0' it would never be ''? (I know that check if they voted before)

By default the script inputs it as a ''.
By default mysql inputs it as 0.

I keep that part of the script intact in case people use v1's script.
Or if people put in those rows/columns manually.

Most things are in place to keep things compatible.
If someone doesn't need part of the script in it, they can edit it out.
 
Last edited:
Joined
Nov 10, 2009
Messages
269
Reaction score
28
i get an error lol...
how to fix this?

PHP:
( ! ) Notice: Undefined index: name in C:\wamp\www\pages\vote.php on line 19
Call Stack
#	Time	Memory	Function	Location
1	0.0008	397232	{main}( )	..\index.php:0
2	0.0711	484688	include( 'C:\wamp\www\pages\vote.php' )	..\index.php:43

( ! ) Notice: Undefined variable: redirect in C:\wamp\www\pages\vote.php on line 52
Call Stack
#	Time	Memory	Function	Location
1	0.0008	397232	{main}( )	..\index.php:0
2	0.0711	484688	include( 'C:\wamp\www\pages\vote.php' )	..\index.php:43

( ! ) Notice: Undefined variable: funct_msg in C:\wamp\www\pages\vote.php on line 61
Call Stack
#	Time	Memory	Function	Location
1	0.0008	397232	{main}( )	..\index.php:0
2	0.0711	484688	include( 'C:\wamp\www\pages\vote.php' )	..\index.php:43

( ! ) Notice: Undefined variable: funct_error in C:\wamp\www\pages\vote.php on line 62
Call Stack
#	Time	Memory	Function	Location
1	0.0008	397232	{main}( )	..\index.php:0
2	0.0711	484688	include( 'C:\wamp\www\pages\vote.php' )	..\index.php:4
 
Experienced Elementalist
Joined
Jun 17, 2008
Messages
247
Reaction score
76
i get an error lol...
how to fix this?

PHP:
( ! ) Notice: Undefined index: name in C:\wamp\www\pages\vote.php on line 19
Call Stack
#	Time	Memory	Function	Location
1	0.0008	397232	{main}( )	..\index.php:0
2	0.0711	484688	include( 'C:\wamp\www\pages\vote.php' )	..\index.php:43

( ! ) Notice: Undefined variable: redirect in C:\wamp\www\pages\vote.php on line 52
Call Stack
#	Time	Memory	Function	Location
1	0.0008	397232	{main}( )	..\index.php:0
2	0.0711	484688	include( 'C:\wamp\www\pages\vote.php' )	..\index.php:43

( ! ) Notice: Undefined variable: funct_msg in C:\wamp\www\pages\vote.php on line 61
Call Stack
#	Time	Memory	Function	Location
1	0.0008	397232	{main}( )	..\index.php:0
2	0.0711	484688	include( 'C:\wamp\www\pages\vote.php' )	..\index.php:43

( ! ) Notice: Undefined variable: funct_error in C:\wamp\www\pages\vote.php on line 62
Call Stack
#	Time	Memory	Function	Location
1	0.0008	397232	{main}( )	..\index.php:0
2	0.0711	484688	include( 'C:\wamp\www\pages\vote.php' )	..\index.php:4

Those are notice messages.

If they aren't causing issues with the scripts,
just add the variable names pre-defined.
 
Newbie Spellweaver
Joined
Jan 1, 2009
Messages
7
Reaction score
0
so basicly this store info in ur myswl but does it also add the nx to the account?
 
Initiate Mage
Joined
May 6, 2008
Messages
1
Reaction score
0
Hello im having the same issue
PHP Code:
( ! ) Notice: Undefined index: name in C:\wamp\www\pages\vote.php on line 19
Call Stack
# Time Memory Function Location
1 0.0008 397232 {main}( ) ..\index.php:0
2 0.0711 484688 include( 'C:\wamp\www\pages\vote.php' ) ..\index.php:43

( ! ) Notice: Undefined variable: redirect in C:\wamp\www\pages\vote.php on line 52
Call Stack
# Time Memory Function Location
1 0.0008 397232 {main}( ) ..\index.php:0
2 0.0711 484688 include( 'C:\wamp\www\pages\vote.php' ) ..\index.php:43

( ! ) Notice: Undefined variable: funct_msg in C:\wamp\www\pages\vote.php on line 61
Call Stack
# Time Memory Function Location
1 0.0008 397232 {main}( ) ..\index.php:0
2 0.0711 484688 include( 'C:\wamp\www\pages\vote.php' ) ..\index.php:43

( ! ) Notice: Undefined variable: funct_error in C:\wamp\www\pages\vote.php on line 62
Call Stack
# Time Memory Function Location
1 0.0008 397232 {main}( ) ..\index.php:0
2 0.0711 484688 include( 'C:\wamp\www\pages\vote.php' ) ..\index.php:4

I don't know what you mean by "just add the variable names pre-defined" please help me thank you!
 
Newbie Spellweaver
Joined
Apr 23, 2014
Messages
14
Reaction score
0
Any way to fix this problem? [h=1]Not Found[/h]The requested URL /vote1.php was not found on this server.
 
Newbie Spellweaver
Joined
May 24, 2014
Messages
60
Reaction score
0
how can they vote when gtop vote link doesnt pop up? help please?
 
Newbie Spellweaver
Joined
Jul 30, 2012
Messages
59
Reaction score
15
how can they vote when gtop vote link doesnt pop up? help please?

Since this thread was bumped from over a year ago, Could you try to elaborate more?

Any way to fix this problem? [h=1]Not Found[/h]The requested URL /vote1.php was not found on this server.

There was no vote1.php file found in your website folder. If you could elaborate more, that would be useful.
 
Newbie Spellweaver
Joined
Apr 23, 2018
Messages
67
Reaction score
0
How can i do if require character lvl 15 in the account bcs the people create accounts and can vote everhour without enter to the game
 

kaf

Newbie Spellweaver
Joined
Oct 11, 2021
Messages
11
Reaction score
0
solved
 
Last edited:
Back
Top