[WEB/ADMN/ECON] WebShop v0.3 - Let your users buy blocks from your website [1060]

Discussion in 'Inactive/Unsupported Plugins' started by Jonchun, Aug 20, 2011.

  1. Offline

    Jonchun

    WebShop - Let your users buy blocks from your website!:
    Version: v0.3

    This makes use of the awesome InventorySQL plugin so check it out!(This is REQUIRED) So far, I have it set up so that I can buy items, money will be subtracted from my database, and the item will be given in game. This is the first release so expect bugs and glitches. It comes with a very very simple admin panel for granting credits.

    Demo: Click Here (v.03) [ign: test password: password] If you actually try buying the item, it won't work because it's linked to a database WITHOUT an actual InventorySQL installation. It's not a real minecraft database. It's just a test database. It WILL throw an SQL error except this will NOT happen if you set up your databases correctly.
    Live Demo: Jagcraft.tk (is still running v0.1) I develop this script separately from my own server store.


    Features:
    • Allows users to buy blocks from your website
    • Uses MySQL
    • Configurable. Will support any economy plugin that uses MySQL
    • Users must be logged in. (This WebShop doesn't provide registration.)
    • Supports custom password encryption
    • Supports xAuth! (just set $xAuth = true)
    Download

    Instructions: - Edit config.php to your liking.
    - Upload all the contents to your website server.
    - The "index.php" is "shop.php." I'll fix this up later in future releases.
    - Config file:
    PHP:
    <?php
    /////////////////// MySQL Information ////////////////////
    $host "localhost"//MySQL Host
    $user "root"// MySQL Username
    $pass ""// MySQL Password
    $database ""// Database name
    $adminpassword "jagcraft.tk"//Administration Password
    //////////////////////////////////////////////////////////

    //////////////////// User Database ////////////////////////
    $tablename "accounts"// Table name (the one that stores user account information)
    $username "username"// Name of username column
    $password "password"// Name of password column
    $moneyname "money"// Name of money/currency column
    $xAuth false// Are you using xAuth?
    ///////////////////////////////////////////////////////////


    //////////////// InventorySQL Database ////////////////////
    $InventorySQL "InventorySQL"//Your InventorySQL Table
    $viewlimit 15//How many items per page
    $bankname "JagBank"//Name of "Bank"
    ///////////////////////////////////////////////////////////

    //////////////// Miscellaneous Settings ////////////////////
    $currencyname "JagBucks"//Currency name (what you want to call your currency)

    function encryptPass ($raw)
    {
    $hash sha1($raw); // Password encryption function. Edit if you need encryption different from default.
    return $hash;
    }

    ///////////////////////////////////////////////////////////

    ////////////////////// Price List ////////////////////////
    // Format: [blockId],[damageValue],[blockName],[pricePerBlock]/n
    //////////////////////////////////////////////////////////
    $stock "1,0,Stone,3/n
    2,0,Grass,5/n
    3,0,Dirt,2/n
    4,0,Cobblestone,3/n
    5,0,Wooden Plank,3/n
    6,0,Sapling,12/n
    7,0,Bedrock,0/n
    8,0,Water,0/n
    9,0,Stationary Water,0/n
    10,0,Lava,0/n
    11,0,Stationary Lava,0/n
    12,0,Sand,8/n
    13,0,Gravel,3/n
    14,0,Gold Ore,50/n
    15,0,Iron Ore,25/n
    16,0,Coal Ore,15/n
    17,0,Wood,8/n
    18,0,Leaves,3/n
    19,0,Sponge,300/n
    20,0,Glass,10/n
    21,0,Lapis Lazuli Ore,75/n
    22,0,Lapis Lazuli Block,500/n
    23,0,Dispenser,0/n
    24,0,Sandstone,10/n
    25,0,Note Block,100/n
    26,0,Bed,25/n
    27,0,Powered Rail,45/n
    28,0,Detector Rail,45/n
    29,0,Sticky Piston,80/n
    30,0,Cobweb,0/n
    31,0,Tall Grass,0/n
    32,0,Dead Shrubs,0/n
    33,0,Piston,50/n
    34,0,Piston Extension,0/n
    35,0,White Wool,5/n
    35,1,Orange Wool,10/n
    35,2,Magenta Wool,10/n
    35,3,Light Blue Wool,10/n
    35,4,Yellow Wool,10/n
    35,5,Light Green Wool,10/n
    35,6,Pink Wool,10/n
    35,7,Gray Wool,10/n
    35,8,Light Gray Wool,10/n
    35,9,Cyan Wool,10/n
    35,10,Purple Wool,10/n
    35,11,Blue Wool,10/n
    35,12,Brown Wool,10/n
    35,13,Dark Green Wool,10/n
    35,14,Red Wool,10/n
    35,15,Black Wool,10/n
    36,0,Block Moved By Piston,0/n
    37,0,Dandelion,1/n
    38,0,Rose,1/n
    39,0,Brown Mushroom,1/n
    40,0,Red Mushroom,1/n
    41,0,Gold Block,425/n
    42,0,Iron Block,200/n
    43,0,Double Slabs,0/n
    44,0,Slabs,5/n
    45,0,Brick Block,20/n
    46,0,TNT,0/n
    47,0,Bookshelf,25/n
    48,0,Moss Stone,35/n
    49,0,Obsidian,50/n
    50,0,Torch,5/n
    51,0,Fire,0/n
    52,0,Mob Spawner,1500/n
    53,0,Wooden Stairs,15/n
    54,0,Chest,10/n
    55,0,Redstone Wire,25/n
    56,0,Diamond Ore,75/n
    57,0,Diamond Block,600/n
    58,0,Crafting Table,10/n
    59,0,Seeds,5/n
    60,0,Farmland,15/n
    61,0,Furnace,10/n
    62,0,Burning Furnace,25/n
    63,0,Sign Post,15/n
    64,0,Wooden Door,10/n
    59,0,Seeds,5/n
    60,0,Farmland,15/n
    61,0,Furnace,10/n
    62,0,Burning,25/n
    63,0,Sign Post,15/n
    64,0,Wooden Door,10/n
    65,0,Ladders,20/n
    66,0,Rails,35/n
    67,0,Cobblestone Stair,15/n
    68,0,Wall Sign,15/n
    69,0,Lever,20/n
    70,0,Stone Preasure Plate,25/n
    71,0,Iron Door,150/n
    72,0,Wooden Preasure Plate,25/n
    73,0,Redstone Ore,75/n
    74,0,Glowing Redstone Ore,85/n
    75,0,Redstone Torch (Off State),30/n
    76,0,Redstone Torch (On State),30/n
    77,0,Stone Button,15/n
    78,0,Snow,65/n
    79,0,Ice,75/n
    80,0,Snow Block,70/n
    81,0,Cactus,10/n
    82,0,Clay Block,20/n
    83,0,Sugar Cane,20/n
    84,0,Jukebox,200/n
    85,0,Fence,15/n
    86,0,Pumkin,30/n
    87,0,Netherrack,25/n
    88,0,Soul Sand,25/n
    89,0,Glowstone Block,150/n
    90,0,Portal,0/n
    91,0,Jack-O-Lantern,35/n
    92,0,Cake Block,60/n
    93,0,Redstone Repeater (Off State),65/n
    94,0,Redstone Repeater (On State),65/n
    95,0,Locked Chest,0/n
    96,0,Trapdoor,15/n
    256,0,Iron Shovel,75/n
    257,0,Iron Pickaxe,75/n
    258,0,Iron Axe,75/n
    259,0,Flint and Steel,50/n
    260,0,Red Aplle,20/n
    261,0,Bow,40/n
    262,0,Arrow,5/n
    263,0,Coal,15/n
    264,0,Diamond,75/n
    265,0,Iron Ingot,50/n
    266,0,Gold Ignot,65/n
    267,0,Iron Sword,75/n
    268,0,Wooden Sword,10/n
    269,0,Wooden Shovel,10/n
    270,0,Wooden Pickaxe,10/n
    271,0,Wooden Axe,10/n
    272,0,Stone Sword,25/n
    273,0,Stone Shovel,25/n
    274,0,Stone Pickaxe,25/n
    275,0,Stone Axe,25/n
    276,0,Diamond Sword,120/n
    277,0,Diamond Shovel,120/n
    278,0,Diamond Pickaxe,120/n
    279,0,Diamond Axe,120/n
    280,0,Stick,2/n
    281,0,Bowl,10/n
    282,0,Mushroom Soup,35/n
    283,0,Gold Sword,100/n
    284,0,Gold Shovel,100/n
    285,0,Gold Pickaxe,100/n
    286,0,Gold Axe,100/n
    287,0,String,40/n
    288,0,Feather,10/n
    289,0,Gunpowder,0/n
    290,0,Wooden Hoe,10/n
    291,0,Stone Hoe,25/n
    292,0,Iron Hoe,75/n
    293,0,Diamond Hoe,120/n
    294,0,Gold Hoe,100/n
    295,0,Seeds,5/n
    296,0,Wheat,15/n
    297,0,Bread,30/n
    298,0,Leather Cap,10/n
    299,0,Leather Tunic,10/n
    300,0,Leather Pants,10/n
    301,0,Leather Boots,10/n
    302,0,Chain Helmet,25/n
    303,0,Chain Chestplate,25/n
    304,0,Chain Leggings,25/n
    305,0,Chain Boots,25/n
    306,0,Iron Helmet,75/n
    307,0,Iron Chestplate,75/n
    308,0,Iron Leggings,75/n
    309,0,Iron Boots,75/n
    310,0,Diamond Helmet,120/n
    311,0,Diamond Chestplate,120/n
    312,0,Diamond Leggings,120/n
    313,0,Diamond Boots,120/n
    314,0,Gold Helmet,100/n
    315,0,Gold Chestplate,100/n
    316,0,Gold Leggings,100/n
    317,0,Gold Boots,100/n
    318,0,Flint,15/n
    319,0,Raw Porkchop,8/n
    320,0,Cooked Porkchop,10/n
    321,0,Paintings,12/n
    322,0,Golden Apple,130/n
    323,0,Sign,15/n
    324,0,Wooden door,10/n
    325,0,Bucket,10/n
    326,0,Water bucket,15/n
    327,0,Lava bucket,20/n
    328,0,Minecart,25/n
    329,0,Saddle,650/n
    330,0,Iron door,100/n
    331,0,Redstone,15/n
    332,0,Snowball,5/n
    333,0,Boat,15/n
    334,0,Leather,2/n
    335,0,Milk,25/n
    336,0,Clay Brick,20/n
    337,0,Clay,5/n
    338,0,Sugar Cane,20/n
    339,0,Paper,15/n
    340,0,Book,25/n
    341,0,Slimeball,100/n
    342,0,Minecart with Chest,45/n
    343,0,Minecart with Furnace,45/n
    344,0,Egg,10/n
    345,0,Compass,100/n
    346,0,Fishing Rod,45/n
    347,0,Clock,100/n
    348,0,Glowstone Dust,25/n
    349,0,Raw Fish,8/n
    350,0,Cooked Fish,10/n
    351,0,Dye,10/n
    352,0,Bone,15/n
    353,0,Sugar,12/n
    354,0,Cake,45/n
    355,0,Bed,15/n
    356,0,Redstone Reapter,25/n
    357,0,Cookie,30/n
    358,0,Map,100/n
    359,0,Shears,35/n
    2256,0,Gold Music Disc,1000/n
    2257,0,Green Music Disc,1000/n
    "
    ;

    $render "0,1,2,3,4,5,7,8,9,10,11,12,13,14,15,16,17,18,18d1,18d2,19,20,21,22,23,24,25,26,29,30,33,35,35d1,35d2,35d3,35d4,35d5,35d6,35d7,35d8,35d9,35d10,35d11,35d12,35d13,35d14,35d15,41,42,43,44,44d1,44d2,44d3,45,46,47,48,49,51,52,53,54,55,56,57,58,60,61,62,67,70,72,73,74,77,78,79,80,81,82,84,85,86,87,88,89,90,91,92,95,96";
    ///////////////////////////////////////////////////////////




    // Open SQL connection (Don't edit this!)
    mysql_connect($host,$user,$pass) OR die("Can't establish a connection with the MySQL server!");
    mysql_select_db($database) OR die("The Database could not be selected!");

    //xAuth checkPassword function
    function checkPassword($realPass$checkPass) {
        
    $saltPos strlen($checkPass);
        
    $salt substr($realPass$saltPos12);
        
    $hash1 hash('whirlpool'$salt $checkPass);
        
    $hash2 substr($hash10$saltPos). $salt substr($hash1$saltPos);
        return 
    $hash2;
    }

    ?>
    Make sure you edit the config file completely!

    Notes:
    You may not receive your items instantly if you don't have InventorySQL configured correctly.
    Make sure that you have the check-interval set to a low number like 5.
    Code:
    check-interval: 5

    - Support development of this script!
    [​IMG]

    Changelog:
    Version 0.3
    • Added easy user support for xAuth
    Version 0.2
    • Added custom password encryption support
    • Reformatted config.php to make it easier to read
    • Fixed minor grammatical errors
    • Moved Shop List to config.php
    • Added javascript price updating
    • Added Welcome message
    • Added Logout link
    • Removed searchshop.php (included on accident)
    Show Spoiler

    Version 0.1
    • Initial Release
     
    Reklats, PlanetPros and GmK like this.
  2. Offline

    DemonCraft

    Looks good, I always like things that use MySQL for Website connection with the server, but sadly I'm not going to use this Plugin as I see using ChestShop better standards for my economy.
     
  3. Offline

    Sh00ck

    Whats that with Registration ?

    It looks really nice but how i do that :confused:?
     
  4. Offline

    zebras

    I could help you setting it up, but only if you tell me more about your machine.
     
  5. Offline

    Sh00ck

    What did you mean with MACHINE ;D?
     
  6. Offline

    GmK

    Great stuff!

    Now I only need to figure out how to add a registration and user database and these things ;)
     
  7. Offline

    zebras

    I mean, where are you holding Craftbukkit server and etc..
     
  8. Offline

    Jonchun

    This supports ANy database with the column "money" in it. You can configure everything to meet your needs. This works great with a plugin like xAuth.

    ChestShop is nice but this allows for users to buy rare block ONlINE. On top of this, the system can easily be tweaked to give more. It can be combined with chestshop so you can control your economy. Set a global price and users who want to sell something Must sell below the global price.

    @mods, I'm really sorry about the double posting. I'm on an iPhone and it lags really bady if I try to edit an old post

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 18, 2016
  9. Offline

    Sh00ck

    Ger? zebras is German XD ?
     
  10. Offline

    zebras

    No, I'm not a german.
     
  11. Offline

    Sh00ck

    k!

    The Server is running on another PC!
    Hoster : a Friend (Root Server..)

    Need more?
     
  12. Offline

    zebras

    so, server is running on personal computer (or on dedicated/VPS server?), which OS it using? Is there PHP5; MySQL; Apache are installed?
     
  13. Offline

    Jonchun

    All you need is a pre-existing plugin (e.g. xAuth)
     
  14. Offline

    Sh00ck

  15. Offline

    Jonchun

    Password has md5 encryption. You will need to change the hash stuff in the vlogin.php manually for now. Now, once you set up your Password plugin, all you need to do is go into phpmyadmin and add a column called "money" or "gold" or something. Then, everything should work perfectly.
     
  16. If I modify my config.php and vlogin.php like that :

    config.php: (open)
    $host = "localhost"; //MySQL Host
    $user = "user"; // MySQL Username
    $pass = "pass"; // MySQL Password
    $database = "db"; // Database name
    $adminpassword = "adminpass"; //Adminsistration Password
    $hash = "md5"

    $tablename = "mybb_users"; // Account table name
    $username = "username"; // name of username column
    $password = "password"; // name of password column
    $moneyname = "mDreams"; // name of money column
    $InventorySQL = "InventorySQL"; //name of inventory table
    $currencyname = "mDreams"; //Currency name (also name of money column)

    $viewlimit = 15; //How many items per page
    $bankname = "Banque"; //Name of "Bank"


    vlogin.php (open)
    <?php
    error_reporting(0);
    require_once("config.php");
    if(!isset($_SESSION))
    {
    session_start();
    }

    @$ign = trim(@$_POST['ign']);
    @$password2 = trim(@$_POST['password']);

    $password2 = $hash($password2);
    $sqlquery = mysql_query("SELECT * FROM $tablename WHERE $username = '$ign' AND $password = '$password2'");

    if (mysql_num_rows($sqlquery) > 0) {
    session_regenerate_id();
    $sqldata = mysql_fetch_assoc($sqlquery);
    $_SESSION['ign'] = $sqldata['ign'];
    $_SESSION['LOGGEDIN'] = true;
    session_write_close();
    header("Location: shop.php");
    exit();
    } else {
    echo '<br><br><font size="6" color = "red"><strong>
    Connection &eacute;chou&eacute;e.</font><br><br><font size="3"></strong>
    Le mot de passe fourni n\'est pas li&eacute; au pseudo. Merci de recommencer.<br><br><br>
    Pseudo Minecraft: <br>
    <form action="vlogin.php" method="POST">
    <input name="ign" type="text" id="ign" /><br>Mot de Passe:<br>
    <input name="password" type="password" id="password" /><br><br>
    <input name="Login" type="submit" id="Login" value="Se connecter" /></font></form><br><br><br><br><br><br><br><br><br><br><br><br>';

    }

    ?>


    Do you think it will works ?

    I tried, but it won't works for me ...
     
  17. Offline

    zebras

    What exactly doesn't work? and I don't think, that vlogin.php needed to change.
     
  18. Rerouting-link from vlogin to shop.php...
     
  19. Offline

    zebras

    when you go to .../shop.php and if you not logged in, you will get a window automatically to login. Could you capture a foto when you just enter shop.php?
     
  20. For sure :

    [​IMG]

    Now, the vlogin can't read my md5 encrytion ...
     
  21. Offline

    zebras

    what authentication plugin you using in your game, is it configurated to mysql and what encryption is set of "auth" plugin?
     
  22. I use AuthDB to link Minecraft and MyBB.

    Do you think there is a link between WebShop and AuthDB ?
     
  23. Offline

    zebras

    go to your MySQL where mybb_users is located and tell me, how columns (username) and (password) named in there. (Because I don't use this plugin, I don't know, how they are named).
     
  24. They are named username and password., and I add the "money" column. Add money from ./admin/index.php works perfectly.
     
  25. Offline

    zebras

    From AuthDB topic:
    which encryption method is set in your config of AuthDB?
     
  26. Normaly, it's MD5 encryption.
     
  27. Offline

    Jonchun

    Currently this webshop only supports SHA1. When I have time (I have to finish a school coding project first) I'll be releasing this to be MUCH easier for the end user. You can easily modify vlogin.php if you're not using SHA1 encryption.
     
  28. Yes, but if I change "sha1($password2)" per "md5($password2)", everything need to work perfectly, no ?
     
  29. Offline

    Jonchun

    ahh yea. It should in theory work perfectly... Does your Auth plugin use a salt by any chance?
     
  30. Not at this time. It's one of the upcoming function.
     

Share This Page