
Originally Posted by
SaBeRwInG
Ok, but for the nxcredit error? What should I fix?
PHP Code:
<?php
##########Configuration#############
#Voting Script by Cinos11 of RageZone#
#################################
$db['host'] = 'localhost';
$db['user'] = 'root';
$db['pass'] = 'wtfthis';
$db['database'] = 'moopledev';
$links['gtop100'] = 'http://www.gtop100.com/in.php?site=63899';
$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, nxCredit = nxCredit + 10000 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 } ?>