Aeronux has already released a NX Code Generator that let's someone only get a Code once in evey 24 Hours.
A lot have been having difficulties with getting the script to work and implementing it. So I re-wrote it and cleaned up the Code.
Credits go to Aernoux for the original script.
You will also need to create a new table in your odinms database.
I have attached the sql script (Please rename the file to nxcode_track.sql). All you have to do is open it with MySQL Query Browser or w/e you use. And execute it.
To see a preview of the script go here:
Enjoy!
A lot have been having difficulties with getting the script to work and implementing it. So I re-wrote it and cleaned up the Code.
Credits go to Aernoux for the original script.
PHP:
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="submit" name="GetNX" value="Generate">
</form>
<?php
/* ----------
RE-WRITTEN AND SIMPLIFIED BY BAVILO
ORIGINAL SCRIPT BY AERONUX
This script solution uses IP address and a MySQL Day field
to keep track of giving a user free NX every 24 hours by generating
a 14-digit NX code.
---------- */
/*DATABASE CONFIG: Please fill this out correctly or script will not work. */
$DB_host = "localhost"; //Host; usually localhost
$DB_user = "replace_with_username"; //User Name
$DB_pass = "replace_with_password"; //Password
$DB_db = "replace_with_database_name"; // Database name
if (isset($_POST['GetNX'])){
/*DATABASE CONNECT */
$connect = mysql_connect($DB_host,$DB_user,$DB_pass);
$db = mysql_select_db($DB_db);
/* FUNCTION FOR GENERATING CODES */
function NXCode() {
$chars = "abcdefghijkmnopqrstuvwxyz0123456789";
srand((double)microtime()*1000000);
$i = 0;
$pass = '' ;
while ($i <= 13) {
$num = rand() % 33;
$tmp = substr($chars, $num, 1);
$pass = $pass . $tmp;
$i++;
}
return $pass;
}
/* Get the IP Address */
$IP = $_SERVER['REMOTE_ADDR'];
/* Check to see if they've gotten their NX for the day */
$chk1 = @mysql_query("SELECT * FROM `nxcode_track` WHERE `ip`='$IP'");
$num = @mysql_num_rows($chk1);
$chk = @mysql_fetch_array($chk1);
$lasttime = $chk["Day"];
/* 24 hours? */
if (($num>0) && ($lasttime != date("j")))
/* It's been at least 24 hours */
{ $CANGET = true; }
else if($num == 0)
/* Never requested NX */
{ $CANGET = true; }
else
/* Already received */
{ $CANGET = false; }
/* If you are allowed to get NX */
if($CANGET == true) {
/* Get the NX Code */
$pass = NXCode();
/* Delete last IP entry after 24 hours have passed */
mysql_query("DELETE FROM `nxcode_track` WHERE `IP`='$IP' OR `ID`='$chk[ID]'");
/*Insert the NX Code into the DataBase */
mysql_query("INSERT INTO `nxcode` (code, valid, user, type, item) VALUES ('$pass', 1, NULL, 0, 30000)") or die(mysql_error());
/* Insert new entry to block you for 24 hours to get more NX */
mysql_query("INSERT INTO `nxcode_track` (ID,IP,Day) VALUES (NULL,'$IP',".date("j").")");
/* Display the NX Code */
echo "<p>Your NX Code is: <b>$pass</b></p>";
} else {
/* Otherwise, Display that you have already gotten NX within 24 hours */
echo "<p><b>You have already gotten NX today!</b></p>";
}
}
?>
You will also need to create a new table in your odinms database.
I have attached the sql script (Please rename the file to nxcode_track.sql). All you have to do is open it with MySQL Query Browser or w/e you use. And execute it.
To see a preview of the script go here:
You must be registered to see links
Enjoy!
Attachments
You must be registered for see attachments list