Simple Vote Script +Add Coins for Vote
Here is a remake of Vote for coins with mysql.
Works on PHP 4 and PHP 5.
Instructions:
- create new db called "vote"
- import "users.sql"
- import "points.sql"
- edit "vote.php" and fill in mysql
- edit "vote.php" to change amount of coins to your own wishes
- Upload vote.php and votenow.php
- go to yousite/votenow.php
vote.php
PHP Code:
<html>
<head>
<title>Vote Now!</title>
<style>
body { background-color: #202020;
color: yellow;
}
</style>
</head>
<body>
<?php
// Report all PHP errors (see changelog)
error_reporting(E_ALL);
//----------------------------------------------------------
// Give amount of coins
$coins = 2;
// Yout website after vote was successfull
// Add http:// in your list
$webpage = "http://localhost";//link to vote website
// Time needed to vote again
// You need to remove 1 minut from the time
// 720 should be 12hours
$time_needed = "719"; // in mintutes
// Insert your MYSQL info here
$mysql = array(
'host' => "localhost",
'user' => "root",
'pass' => "mysqlrootpassword",
'db' => "vote" // Do not change it the DB is vote
);
//---DO NOT EDIT ANYTHING BELOW HERE UNLESS YOU KNOW WHAT YOU ARE DOING!! ---
function clean($str){
return is_array($str) ? array_map('clean', $str) : str_replace("\\", "\\\\", htmlspecialchars((get_magic_quotes_gpc() ? stripslashes($str) : $str), ENT_QUOTES));
}
$mylink = mysql_Connect($mysql['host'], $mysql['user'], $mysql['pass']);
mysql_select_db($mysql['db'],$mylink);
$ip = getenv("REMOTE_ADDR");
$httpref = getenv ("HTTP_REFERER");
$httpagent = getenv ("HTTP_USER_AGENT");
$account = clean($_POST['account']);
$date = date("Y-m-d G:i");
if (empty($account)){
echo '<SCRIPT LANGUAGE="JavaScript">alert("You didnt enter a account name! \n Please try again.")</script>';
echo "<script type='text/javascript'>window.location='votenow.php';</script>";
} elseif(!preg_match("/[0-9a-zA-Z]?/", $account)) {
echo '<SCRIPT LANGUAGE="JavaScript">alert("Incorrect account name format. \n Please try again.")</script>';
echo "<script type='text/javascript'>window.location='votenow.php';</script>";
} else {
$result2 = mysql_query("SELECT * FROM users WHERE account = '".$account."' OR ip='".$ip."' ");
$row2 = mysql_fetch_row($result2);
$count2 = mysql_num_rows($result2);
if($count2 == 1){
$voted_ip = $row2[2];
$voted_date = $row2[3];
$voted_id = $row2[0];
$voted_account = $row2[1];
$to_time = strtotime($voted_date);
$from_time = strtotime($date);
if (round(abs($to_time - $from_time) / 60,2) > $time_needed) {
$amount = $coins;
mysql_query("UPDATE users SET date = '".$date."' WHERE account = '".$account."' ");
mysql_query("UPDATE points SET reward_points =reward_points+'".$coins."' WHERE account = '".$account."' ");
echo '<SCRIPT LANGUAGE="JavaScript">alert("Thank you for you vote!")</script>';
echo "<script type='text/javascript'>window.location='$webpage';</script>";
} else {
echo '<SCRIPT LANGUAGE="JavaScript">alert("You cant vote anymore! \n Please try again later.")</script>';
echo "<script type='text/javascript'>window.location='votenow.php';</script>";
}
} else {
$amount = $coins;
$sql4 = mysql_query("INSERT INTO users (account,ip,date) VALUES ('".$account."','".$ip."','".$date."' ) ");
mysql_query("INSERT INTO points (account,reward_points) VALUES ('".$account."','".$coins."')");
echo '<SCRIPT LANGUAGE="JavaScript">alert("Thank you for you vote!")</script>';
echo "<script type='text/javascript'>window.location='$webpage';</script>";
}
}
mysql_close($mylink);
// mssql_close($mslink);
?>
</body>
</html>
votenow.php
PHP Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title> vote for coins</title>
<style type="text/css">
div#container
{
width: 350px;
position: relative;
margin-top: 0px;
margin-left: auto;
margin-right: auto;
text-align: left;
}
body
{
text-align: center;
margin: 0;
}
</style>
</head>
<body bgcolor="#202020" text="#FFD700">
<div id="wb_Text1" style="position:absolute;left:10px;top:120px;width:240px;height:14px;z-index:0;" align="left">
<font style="font-size:11px" color="#ffffff" face="Arial">You can vote every 12 hours. 1 vote = 2 coins</font>
</div>
<img src="http://www.xtremeTop100.com/votenew.jpg" border="0" style="position:absolute;left:250px;top:34px; >
<div id="container">
<div id="wb_Form1" style="position:absolute;left:0px;top:0px;width:239px;height:135px;z-index:3;" align="left">
<form name="Form1" method="post" action="vote.php" id="Form1">
<div id="wb_Text1" style="position:absolute;left:10px;top:15px;width:78px;height:14px;z-index:0;" align="left">
<font style="font-size:11px" color="#FFD700" face="Arial">Account name:</font></div>
<input type="text" id="Editbox1" style="position:absolute;left:10px;top:34px;width:200px;font-family:Courier New;font-size:16px;z-index:1" name="account" value="">
<input type="submit" id="Button1" name="Button1" value="Vote" style="position:absolute;left:10px;top:65px;width:96px;height:25px;font-family:Arial;font-size:13px;z-index:2">
</form>
</div>
</div>
</div>
</body>
</html>
points.sql
Code:
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `points`
-- ----------------------------
DROP TABLE IF EXISTS `points`;
CREATE TABLE `points` (
`account` varchar(30) NOT NULL default '',
`reward_points` int(255) default NULL,
PRIMARY KEY (`account`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
users.sql
Code:
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `users`
-- ----------------------------
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
`id` bigint(11) NOT NULL auto_increment,
`account` varchar(30) default NULL,
`ip` varchar(30) default NULL,
`date` datetime default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
I hope it will be useful for this community.
Re: Simple Vote Script +Add Coins for Vote
Simple but nice!! how about adding points to toll_count..
Re: Simple Vote Script +Add Coins for Vote
Quote:
Originally Posted by
hisync
Simple but nice!! how about adding points to toll_count..
Import "users.sql" into aion login database;
search in vote.php for :
mysql_query("UPDATE points SET reward_points =reward_points+'".$coins."' WHERE account = '".$account."' ");
and change to our account_data table.
ex:mysql_query("UPDATE account_data SET credits =credits+'".$coins."' WHERE name = '".$account."' ");:thumbup1:
Re: Simple Vote Script +Add Coins for Vote
a question where I add the link to vote? or as it is to vote for the top?
Re: Simple Vote Script +Add Coins for Vote
Quote:
require_once("libs/AccountData.class.php");
can you share this file too? thanks
Re: Simple Vote Script +Add Coins for Vote
Quote:
Originally Posted by
hisync
require_once("libs/AccountData.class.php");can you share this file too? thanks
you can delete this is not needed.
Quote:
Originally Posted by
charnolds
a question where I add the link to vote? or as it is to vote for the top?
vote.php
search for:
$webpage = "http://localhost";//link to vote website
and change to our top website vote
Re: Simple Vote Script +Add Coins for Vote
Quote:
Originally Posted by
elvis24b
Import "users.sql" into aion login database;
search in vote.php for :
mysql_query("UPDATE points SET reward_points =reward_points+'".$coins."' WHERE account = '".$account."' ");
and change to our account_data table.
ex:mysql_query("UPDATE account_data SET credits =credits+'".$coins."' WHERE name = '".$account."' ");:thumbup1:
i do this but are not add the points in account_data credits !!!
in user table are add the username but the points are not add.
i try with the 2 tables (user and points) and vote db and are working fine can somewan help me?
I try to replace here to but are dont work :
mysql_query("INSERT INTO points (account,reward_points) VALUES ('".$account."','".$coins."')");
with
mysql_query("INSERT INTO account_data (name,credits) VALUES ('".$account."','".$coins."')");
are dont work please post the adapted vote.php (for aion!!!) with the working full script!!!
Thanks
Re: Simple Vote Script +Add Coins for Vote
Very good friend, is simple and easy
Re: Simple Vote Script +Add Coins for Vote
Somewan can help me with this issue ?
Re: Simple Vote Script +Add Coins for Vote
@cyfren, what is your issue ?
Re: Simple Vote Script +Add Coins for Vote
I took some time to read the code and edited by the Aion voting script that supports serval voting sites and made it use logged in user name to submit vote and credit.
Here is the form part :
Code:
<form name="Form1" method="post" action="vote_**********.php" id="Form1">
<input type="hidden" id="Editbox1" name="account" value="<?php echo $_SESSION['login_name'] ?>">
<input type='hidden' name='voteid' value='1' />
<input type="image" src="images/v1.gif" id="Button1" name="Button1" value="<?php echo $_SESSION['login_name'] ?>">
</form>
Other then that everything is same :)
Re: Simple Vote Script +Add Coins for Vote
I tried the same but it counts only for one vote site.. when you try out to vote on the second link, it says that i've already voted. Any ideas why? oO