[Req] Gift Code Redeemer (Java + PHP)

Discussion in 'Archived: Plugin Requests' started by effortless, Sep 4, 2012.

  1. Offline


    Hey guys,

    I'm looking for a plugin that will help drive hits to server websites, giving players a reason to go there.

    Here's how the plugin should work:

    1. Player types /giftme, and receives a randomly generated code, all chat disabled at this time
    2. Player goes to the website and types code into a small PHP widget (ideal for sidebars)
    3. Widget matches code to the one provided in the plugin and matches to the User that typed it
    4. Widget says "Congratulations <user>! You've won a <Item>" with a picture of the item
    5. Player clicks redeem and the item is /give'd to him
    6. Command is on configurable cooldown (displayed to user, e.g "You have 23mins 59secs before you can receive another gift")
    7. Some items can be blacklisted from the random win
    Even as an admin who doesn't play the game, I think this would be something I'd want to try anyway just to see what I get, and I think a lot of Servers would benefit from it.
    Any help appreciated

    Thanks guys
    ChumChum likes this.
  2. Offline


    How would you store the codes? Do you have access to MySQL?
  3. Offline


    Sure do, and would prefer that method
  4. Offline


    What format do you want the code in? Length, separators etc?

    It could be as long as
    or perhaps as short as:

    Just numeric?
    perhaps 674-868

    And per-player codes?
  5. Offline


    I would say around 6 digits, alphanumeric preferred, something that looks like a code and would be easy to type

    per player is good so each player gets a random gift

    E.g: Your Gift Code has been Generated! Go to <URL> to redeem!

    Your code: 78e25g

    Also, to remind the users that they have a free gift waiting, when the timer reaches 0, perhaps a reminder to the player (You have 1 free gift waiting! Type /giftme to redeem!)
  6. Offline


    Could you give me the URL on which you'll be putting the widget (if you prefer I can make this configurable)?
  7. Offline


    Not to advertise or anything, but this is just the thing to use the Websend framework for. ;)
  8. Offline


    Not to be nit-picky or anything, but could you tell me what this offers over the vanilla RCON protocol?
  9. Offline


    This sounds cool! I want as well :D subscribing to this thread. i hope someone does it!
  10. Offline


    It's an enjin site (which doesn't allow PHP but does allow iframes), so hosted on an external webserver for me personally (or could it run on its own webserver for others?)

    Sorry for the late response, didn't receive any notifications
  11. Offline


    I would love this!!!
  12. Offline


    I've been working on a plugin called WebWidgets which will allow you to connect to your server through your serverIp:customPort/call?method=callingMethod&args=yourArgs (ex: localhost:25564/call?doChat&args=myName,myMessage)

    And then other devs are able to make addons for this but I might think about hardcoding this into it, if not I will surely create an addon for it.
  13. Offline


    Sounds good, would also hope to see Multi-Server support (a player can use the command on any server and still receive the reward)
  14. Offline


    I would need this plugin, too, it's a great idea!
  15. Offline


    Right, I'm not going to actually give out jars and such (due to other commitments), but I will be able to supply some code:
    Code generation: <?php
    /* Non-functional code snippet. May need modification for it to actually work */
    /* genCode.php -- Generates the alphanumeric code and stores it */
    /* Lol768 -- Gift code API for Bukkit item rewards */
    /* Released under GNU GPL v3 */
    //Grab the config:
    if (
    $cdbUser == null || $cdbPass == null || $cdbConnection == null || $dbName == null)
    die (
    "Check config.php exists");
    $characters 'abcdefghijklmnopqrstuvwxyz0123456789'//Lowercase letters and numbers (to avoid confusion)
    function genCode($length)
    $string '';
        for (
    $i 0$i $length$i++)
    $string .= $characters[rand(0strlen($characters) - 1)];
    //Main code:
    //Ensure a username has been supplied
    $username $_GET['user'];
    if (
    $username == null)
        die (
    "Invalid supplied username");
    //We've got a valid username, now it's time to connect to the DB
    if (!extension_loaded('pdo_mysql'))
    //We don't have PDO w/ MySQL available. Damn :\
    die("Sorry, I need PDO to handle database connections with MySQL");
    //Get a DB handle via a connection
    $dbh = new PDO($cdbConnection$cdbUser$cdbPass);
    catch (
    PDOException $exception)
    "I couldn't connect to the DB server. Error: " .  $exception->getMessage());
    //Check the main table exists
    if ($pdo->query("SELECT codes FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = '$dbName'")->fetch())
    die (
    "You must make a table called codes prior to attempting to use this tool");
    //TODO: Cooldown (could do this in plugin code though)
    //get a code
    $code genCode(6);
    // query -- $username doesn't need sanatising as this is a prepared query
    $sql "INSERT INTO codes (username,code,time) VALUES (:us,:co,:now)";
    $q $conn->prepare($sql);
    "Your code is $code. Visit us to recieve your item:\nhttp://tinyurl.com/4clpsbn");
    My plan was:
      UrlManager um = (UrlManager) getServer().getPluginManager().getPlugin("UrlManager");
    //no parameters

Share This Page