[Release] PHP Cash Shop NX Code Generator (Per Day)

Page 1 of 5 12345 LastLast
Results 1 to 15 of 73
  1. #1
    Account Inactive aeronux is offline
    InactiveRank
    Jul 2008 Join Date
    16Posts

    Lightbulb [Release] PHP Cash Shop NX Code Generator (Per Day)

    This script allows you to generate a code for NX in the Cash Shop once per day. One IP address may only generate one code per day. Code is good for 20,000 NX. Script requires a new database table called 'nxcode_track', and setup is provided from within the script.

    It has been tested, but please report any errors/bugs/etc to me if you like. Also, you can change the amount of NX by editing the query, and I can also modify it for multiple NX amounts if you're interested.

    Also keep in mind that the Cash Shop must be working on your private server with the ability to input NX codes (coupons) for this to function correctly.

    Lastly, the script's output is not really styled, so it's up to you to make it match your site if you feel so inclined.

    TEST PAGE HERE: http://phail.net/NXGEN.php

    PHP Code:
    <?php

    /* ----------
    WRITTEN BY AERONUX, JULY 2 2008
    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 15-digit NX code.  **However, it will require you make an extra 
    database table to keep track of the users who got it already.

    FOR SETUP, RUN:
    http://yourdomain.com/THIS_SCRIPT.php?go=setup
    ---------- */

    /*DATABASE CONFIG: Please fill this out correctly or script will not work. */
    $DB_host "localhost"//Host; usually localhost
    $DB_user ""//User 
    $DB_pass ""//Password
    $DB_db ""// Database name

    /*DATABASE CONNECT */
    $connect mysql_connect($DB_host,$DB_user,$DB_pass);
    $db mysql_select_db($DB_db);

    extract($_GET); /*So we can use all GET variables without $_GET[] */
    $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"];
    if(
    mysql_error() && $go != "setup")
    {
        echo 
    "<font style='color:red;'>You must fill in the database information ";
        echo 
    "and run the setup page to add a new table to be able to use this script.";
        echo 
    "<br><br>After database information is added, <a href='$PHP_SELF?go=setup'>click here to run setup</a>.";
        die();
    }

    if ((
    $num>0) && ($lasttime != date("j"))) /* 24 hours? */
    $CANGET true; } // It's been at least 24 hours
    else if($num == 0)
    $CANGET true; } // Never requested NX
    else
    $CANGET false; }// Already received
        
    /* FUNCTION FOR GENERATING CODES
       BY BAVILO FROM ODINMS.DE FORUMS */
    function createNXCode() { 
        
    $chars "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
        
    srand((double)microtime()*1000000); 
        
    $i 0
        
    $pass '' 

        while (
    $i <= 13) { 
            
    $num rand() % 33
            
    $tmp substr($chars$num1); 
            
    $pass $pass $tmp
            
    $i++; 
        } 
        return 
    $pass
    }

    /* MAIN PAGES */
    switch($go)
    {
        case 
    "give"/* Give them NX */
            
    if($CANGET == true)
            {
                
    //Delete last one(s)
                
    mysql_query("DELETE FROM `nxcode_track` WHERE `IP`='$IP' OR `ID`='$chk[ID]'");
                
    //Insert new one
                
    mysql_query("INSERT INTO `nxcode_track` (ID,IP,Day) VALUES (NULL,'$IP',".date("j").")") or die(mysql_error());
                
    //Generate and give code
                
    $code createNXCode();
                
    $ins mysql_query('INSERT INTO nxcode (code, valid, type, item ) VALUES ("'.$code.'", "1", "3", "20000")') or die(mysql_error());
                if(
    $ins)
                {
                    echo 
    "Your code is: <font style='font-size:25px;'><b>$code</b></font>";
                    echo 
    "<br>Write this down, and use this in the Cash Shop!<br>";
                    echo 
    "(We cannot show you this code again, so please note it!)";
                }
                else
                {
                    echo 
    "Error generating NX code.";
                }
            }
            else
            {
                echo 
    "You've already gotten NX today.";
            }
        break;
        
        case 
    "setup"/* Setup the script for the database */
            
            
    $set mysql_query('CREATE TABLE `'.$DB_db.'`.`nxcode_track` (`ID` INT(6) NOT NULL AUTO_INCREMENT, `IP` VARCHAR(15) NOT NULL DEFAULT \'000.000.000.000\', `Day` INT(2) NOT NULL, PRIMARY KEY (`ID`), INDEX (`IP`, `Day`)) ENGINE = MyISAM') or die(mysql_error());
            if(
    $set)
                echo 
    "Setup complete, you may use the script.";
            else
                echo 
    "There was an error setting up the database table.";
            
        break;
        
        default: 
    /* Show the form here, etc. */
            
    ?>
            <form action="<?=$PHP_SELF;?>?go=give" method="POST">
            <input type='submit' value='Generate 20,000 NX Code'>
            </form>
            <?php
        
    break;
    }

    ?>
    Last edited by aeronux; 03-07-08 at 09:10 PM. Reason: Changed '' to NULL when inserting into nxcode_track


  2.  
  3. #2
    Hardcore Member JiaSen is offline
    MemberRank
    Jun 2008 Join Date
    SomewhereLocation
    112Posts

    Re: [Release] PHP Cash Shop NX Code Generator (Per Day)

    Lol it works :P

  4. #3
    Account Inactive aeronux is offline
    InactiveRank
    Jul 2008 Join Date
    16Posts

    Re: [Release] PHP Cash Shop NX Code Generator (Per Day)

    Quote Originally Posted by JiaSen View Post
    Lol it works :P
    Umm, I'm glad? 8D

    Did you test it on your own server or on my test page?

  5. #4
    Account Inactive Spyker710 is offline
    InactiveRank
    Apr 2008 Join Date
    ...stalker much...Location
    460Posts

    Re: [Release] PHP Cash Shop NX Code Generator (Per Day)

    GJ aeronux =)

    It works on your test page, it's not a phail o.o

  6. #5
    Account Inactive aeronux is offline
    InactiveRank
    Jul 2008 Join Date
    16Posts

    Re: [Release] PHP Cash Shop NX Code Generator (Per Day)

    Quote Originally Posted by Spyker710 View Post
    GJ aeronux =)

    It works on your test page, it's not a phail o.o
    Haha, yeah, I own that domain (phail.net), so I use it for little projects and miscellaneous things. But thanks ;)

  7. #6
    Account Inactive Amandy is offline
    InactiveRank
    Feb 2007 Join Date
    Crapvile, USALocation
    779Posts

    Re: [Release] PHP Cash Shop NX Code Generator (Per Day)

    I don't see any mysql_real_escape_string's. Tisk Tisk.

  8. #7
    Account Inactive aeronux is offline
    InactiveRank
    Jul 2008 Join Date
    16Posts

    Re: [Release] PHP Cash Shop NX Code Generator (Per Day)

    Quote Originally Posted by Antv912 View Post
    I don't see any mysql_real_escape_string's. Tisk Tisk.
    And where would you suppose I put them since my script doesn't collect any actual input information from the user? ;)

  9. #8
    The End Of The World~~ Night2Dark2 is offline
    True MemberRank
    Feb 2007 Join Date
    Inside a box.Location
    269Posts

    Re: [Release] PHP Cash Shop NX Code Generator (Per Day)

    Antv this is for use inside your control panel. it never collected data from the user because he has it setup inside his control panel. Therefor he does not need to escape and strings.
    Note: Upload is down to 4.75mb due to High Network Usage. Testing external usage of ProjectB Network Lag/Redundency:P. 100/100 mb both ways, Download jumps higher, i've seen 250mb on my seperate modem. :$


  10. #9
    Account Inactive Amandy is offline
    InactiveRank
    Feb 2007 Join Date
    Crapvile, USALocation
    779Posts

    Re: [Release] PHP Cash Shop NX Code Generator (Per Day)

    Mkay then.

  11. #10
    Account Inactive lukyjay is offline
    InactiveRank
    Jul 2006 Join Date
    AustraliaLocation
    755Posts

    Re: [Release] PHP Cash Shop NX Code Generator (Per Day)

    Quote Originally Posted by aeronux View Post
    And where would you suppose I put them since my script doesn't collect any actual input information from the user? ;)
    Oh snap.

  12. #11
    Account Inactive vinniboy6 is offline
    InactiveRank
    Nov 2006 Join Date
    Doesn't matterLocation
    81Posts

    Re: [Release] PHP Cash Shop NX Code Generator (Per Day)

    How could you make this for let's say 4 minutes. I don't want it each day, Could you tell me how to make it for 4 min? I really appriciate if you could give it a try.

  13. #12
    Account Inactive GalaxyJoey is offline
    InactiveRank
    Jun 2008 Join Date
    NetherlandsLocation
    140Posts

    Re: [Release] PHP Cash Shop NX Code Generator (Per Day)

    If i click Generate 20k nx i get this:
    Incorrect integer value: '' for column 'ID' at row 1

  14. #13
    Account Inactive aeronux is offline
    InactiveRank
    Jul 2008 Join Date
    16Posts

    Re: [Release] PHP Cash Shop NX Code Generator (Per Day)

    Quote Originally Posted by vinniboy6 View Post
    How could you make this for let's say 4 minutes. I don't want it each day, Could you tell me how to make it for 4 min? I really appriciate if you could give it a try.
    It would be kinda complicated to do that, because it'd require the database table be modified as well as the script... But, I'll work on it, and see if I can't get it going for you. :]

    Quote Originally Posted by GalaxyJoey View Post
    If i click Generate 20k nx i get this:
    Incorrect integer value: '' for column 'ID' at row 1
    Is that error from my test page or from your server?

  15. #14
    Account Inactive GalaxyJoey is offline
    InactiveRank
    Jun 2008 Join Date
    NetherlandsLocation
    140Posts

    Re: [Release] PHP Cash Shop NX Code Generator (Per Day)

    Guys,, i get this error:
    Incorrect integer value: '' for column 'ID' at row 1

  16. #15
    Account Inactive zekesamaz is offline
    InactiveRank
    May 2007 Join Date
    232Posts

    Re: [Release] PHP Cash Shop NX Code Generator (Per Day)

    Find this line:
    mysql_query("INSERT INTO `nxcode_track` (ID,IP,Day) VALUES ('','$IP',".date("j").")") or die(mysql_error());

    And try to replace it with this:

    mysql_query("INSERT INTO `nxcode_track` (ID,IP,Day) VALUES (NULL,'$IP',".date("j").")") or die(mysql_error());


  17.  

    Latest Gaming Releases

Page 1 of 5 12345 LastLast

Advertisement