PDA

View Full Version : Don't understand this code. :S


Fronix
04-02-2008, 11:59 AM
Ive been trying to make a vote reward system for my website. And i found some that already had done it but they don't work for FireFox. So i decided to make an own. But don't know how to start off this code here is the start of the one that did not work. How do i understand the code cause i have never worked with cookies and the $nochar=false; can't get that either. Just need a quick explanation of what this code means. After that ill be able to do it my self.

CODE:

<?php
$user="root";
$password="*****";
$database="website"; //Char+login DB

$nochar=false;
$voted=false;
$disp = true;
if(($_COOKIE['vote']) != '1')
{
if(!empty($_POST['name']))
{
mysql_connect(localhost,$user,$password);
@mysql_select_db($database) or die( "Unable to select database");
$name = strtolower(mysql_real_escape_string($_POST['name']));
$today = date("mdHi");
$query="SELECT * FROM characters WHERE name='$name' LIMIT 1";
$result = mysql_query($query);
if($row = mysql_fetch_array($result))
{
$guid = $row['guid'];
$acct = $row['acct'];
$res = mysql_query("SELECT * FROM votewatch WHERE acct='$acct' LIMIT 1");
if($r2 = mysql_fetch_array($res))
{
$ct = $r2['ctime'];
if($today-$ct < 1200)
{
$disp = false;
mysql_close();
return;
}
else
{
mysql_query("DELETE FROM votewatch WHERE acct='$acct' LIMIT 1");
}
}
$reward = mysql_real_escape_string($_POST['reward']);
if($reward == 0)
{
mysql_query("INSERT INTO mailbox_insert_queue(sender_guid, receiver_guid, subject, body, stationary, money, item_id, item_stack) VALUES ($guid, $guid, 'Thank you for voting for Ghost WoW', 'Here is your reward you chose', 0, 5000000, 0, 1)");
}
else
{
mysql_query("INSERT INTO mailbox_insert_queue(sender_guid, receiver_guid, subject, body, stationary, money, item_id, item_stack) VALUES ($guid, $guid, 'Thank you for voting for Ghost WoW', 'Here is your reward you chose', 0, 0, $reward, 1)");
}
mysql_query("INSERT INTO votewatch(acct, ctime) VALUES($acct, $today)");
$voted = true;
}
else
{
$nochar = true;
}
mysql_close();
}
}
else
{
$disp = false;
}

?>

edbr
04-03-2008, 04:50 AM
the strings are conditions for the if / else statements checking true or false . can i suggest you might be better looking on the nwt for a script you can use from fresh. if this doesnt work in a particular browser perhaps the security setting are not accepting cookies