[RevCMS] LIMITED furniture sales in CMS [Phoenix]

Page 1 of 2 12 LastLast
Results 1 to 25 of 35
  1. #1
    Member Thewicard is offline
    MemberRank
    Nov 2011 Join Date
    NorwayLocation
    92Posts

    big grin [RevCMS] LIMITED furniture sales in CMS [Phoenix]

    So, I used a few hours figuring this out xP
    Hope you enjoy. Sorry about insanely long code.
    Price is now configured in DB.

    This code isn't done YET,
    stay tuned for updates.

    What does this code do?
    It allows you to sell furniture in limited quantities.
    Is it secure?
    It has double money-in-pocket check (1 in whatever page it's placed in AND 1 when delivering furniture)
    It has double furniture-not-sold-out check (1 in whatever page it's placed in AND 1 when delivering furniture)
    Will not work to refresh page to get another furniture unless there are still available AND you have money for it.
    Added POST Filter (Now only allow numeric posts) //Thanks to Leenster for telling me it was needed.

    First: Run this queue
    PHP Code:
    DROP TABLE IF EXISTS `rev_ltd`;
    CREATE TABLE `rev_ltd` (
     `
    furni_idint(255NOT NULL,
     `
    furni_leftint(255NOT NULL DEFAULT '100',
     `
    furni_soldint(255NOT NULL DEFAULT '0',
     `
    furni_priceint(255NOT NULL DEFAULT '5000',
     
    PRIMARY KEY (`furni_id`)
    ENGINE=MyISAM DEFAULT CHARSET=latin1;
    INSERT INTO `rev_ltdVALUES ('227''15''0''5000'); 
    Second: Create a file in app/tpl/skins/YOURSKIN/ named buyltd.php
    Place this content in the file and save:
    PHP Code:
    <?php
    $ltd_id 
    preg_replace('/[^0-9]/'''$_POST["ltd_id"]);
    $user_id $_SESSION['user']['id'];
    $selectfromusers mysql_query("SELECT * FROM users WHERE id = '".$user_id."'") or die(mysql_error());
    while (
    $getmoney mysql_fetch_array($selectfromusers))
    $money_current $getmoney['credits'];
    $selectfromfurninum mysql_query("SELECT * FROM rev_ltd WHERE furni_id = '".$ltd_id."'") or die(mysql_error());
    while (
    $getfurninum mysql_fetch_array($selectfromfurninum))
    $furnileft $getfurninum['furni_left'] and
    $furnisold $getfurninum['furni_sold'] and
    $ltd_price $getfurninum['furni_price'];
    if(
    $furnileft '0')
    {
    if(
    $money_current $ltd_price)
    {
    echo 
    "You don't have enough money for this item";
    }
    else
    {
    $newmoney $money_current $ltd_price;
    mysql_query("UPDATE users SET credits='".$newmoney."' WHERE id='".$user_id."'") or die(mysql_error());
    $newfurnileft $furnileft '1';
    $newfurnisold $furnisold '1';
    mysql_query("UPDATE rev_ltd SET furni_sold='".$newfurnisold."'") or die(mysql_error());
    mysql_query("UPDATE rev_ltd SET furni_left='".$newfurnileft."'") or die(mysql_error());
    $highestid mysql_query("SELECT * from items ORDER BY id DESC LIMIT 1") or die(mysql_error());
    while (
    $checknewid2 mysql_fetch_array($highestid))
    $newid2 $checknewid2['id'];
    $newid $newid2 '1';
    mysql_query("INSERT INTO items (id, user_id, room_id, base_item, extra_data, x, y, z, rot, wall_pos) VALUES ('".$newid."','".$user_id."',0,'".$ltd_id."',0,0,0,0,0,0)") or die(mysql_error());
    echo 
    "Item bough successfully!";
    }
    }
    else
    {
    echo 
    "All of furniture is already sold, sorry";
    }
    ?>
    <meta http-equiv="refresh" content="1; URL=me">
    Third:
    Goto whatever page you want this in, add this at the top:
    PHP Code:
    <?php
    $user_id 
    $_SESSION['user']['id'];
    $selectfromusers mysql_query("SELECT * FROM users WHERE id = '".$user_id."'") or die(mysql_error());
    while (
    $getmoney mysql_fetch_array($selectfromusers))
    $money_current $getmoney['credits'];
    ?>
    Forth:
    Add this wherever you want the output, this is made for Priv theme.
    PHP Code:
    <?php
    //Furniconfiguration
    $ltd_id "227"//furni_id in the database
    $ltd_name "Dragonegg"//The name of your furni
    $image_url "http://habboxwiki.com/wiki/images/1/12/Black_Dino_Egg.png"//Image URL (optional)


    //Collects data from database
    $selectfromltd mysql_query("SELECT * FROM rev_ltd WHERE furni_id = '".$ltd_id."'") or die(mysql_error());
    while (
    $getltd mysql_fetch_array($selectfromltd))
    $getltd_num $getltd['furni_left'] and
    $getltd_sold $getltd['furni_sold'] and
    $ltd_price $getltd['furni_price'];
    $getltd_total $getltd_sold $getltd_num;
    $money_lack $ltd_price $money_current?>

    <!-- The part that you can see, may need to be changed to fit other theme (currently for Priv theme)   -->
    <div class="left page round"><ul> <?php
    if($getltd_num == '0') {
    $money_lack $ltd_price $money_current;
    echo 
    "This item is no longer available, sorry.";?>
    <br><br><br><h3><?php echo "$ltd_name"?></h3><img src="<?php echo "$image_url?>" style="float: right">
    <br>Sold out.<br><br>
    <?php }
    else
    {
    if(
    $money_current $ltd_price)
    {
    echo 
    "You need $money_lack more credits in order to buy this item.";?>
    <br><br><br><h3><?php echo "$ltd_name"?></h3><img src="<?php echo "$image_url?>" style="float: right">
    <br>Out of credits.<br><br>
    <?php
    } else{ ?>
    <img src="<?php echo "$image_url?>" style="float: right">
    <font size="2" color="white"> <h3>Buy</h3>
    <p>Buy your <?php echo "$ltd_name"?> for just <?php echo "$ltd_price"?> credits.<br>
    </font><font size="2" color="purple">
    Only <?php echo "$getltd_num"?> of <?php echo "$getltd_total"?> left!</p></font>
    <form action="buyltd" method="post">
    <input type="hidden" name="ltd_id" value="<?php echo "$ltd_id"?>">
    <input type="submit" type="submit" name="help" value="Buy" class="button round"> </form></b> <?php }}?>
    </div></ul><br><br><br><br><br><br><br><br><br>
    And here comes one made for the Habbo theme (NEW)
    PHP Code:
    <?php
    //Furniconfiguration
    $ltd_id "227"//furni_id in the database
    $ltd_name "Dragonegg"//The name of your furni
    $image_url "http://habboxwiki.com/wiki/images/1/12/Black_Dino_Egg.png"//Image URL (optional)


    //Collects data from database
    $selectfromltd mysql_query("SELECT * FROM rev_ltd WHERE furni_id = '".$ltd_id."'") or die(mysql_error());
    while (
    $getltd mysql_fetch_array($selectfromltd))
    $getltd_num $getltd['furni_left'] and
    $getltd_sold $getltd['furni_sold'] and
    $ltd_price $getltd['furni_price'];
    $getltd_total $getltd_sold $getltd_num;
    $money_lack $ltd_price $money_current?>

    <!-- The part that you can see, may need to be changed to fit other theme (currently for Priv theme)   -->
    <div class="habblet-container ">
    <div class="cbb clearfix"><ul> <?php
    if($getltd_num == '0') {
    $money_lack $ltd_price $money_current;
    echo 
    "This item is no longer available, sorry.";?>
    <br><br><br><h3 class="title"><?php echo "$ltd_name"?></h3><img src="<?php echo "$image_url?>" style="float: right">
    <br>Sold out.<br><br>
    <?php }
    else
    {
    if(
    $money_current $ltd_price)
    {
    echo 
    "You need $money_lack more credits in order to buy this item.";?>
    <br><br><br><h3><?php echo "$ltd_name"?></h3><img src="<?php echo "$image_url?>" style="float: right">
    <br>Out of credits.<br><br>
    <?php
    } else{ ?>
    <font size="2.5" color="gray"><b>Buy</b></font><br><br><font size="2" color="gray">
    <img src="<?php echo "$image_url?>" style="float: right">Buy your <?php echo "$ltd_name"?> for just <?php echo "$ltd_price"?> credits.<br>
    </font><font size="2" color="purple">
    <br><br>Only <?php echo "$getltd_num"?> of <?php echo "$getltd_total"?> left!<br><br><br></font>
    <form action="buyltd" method="post">
    <input type="hidden" name="ltd_id" value="<?php echo "$ltd_id"?>">
    <input type="submit" type="submit" name="help" value="Buy" class="button round"> </form></b> <?php }}?>
    </div></div></ul>
    Each time you want to add a new furniture, you have to duplicate this code, edit in database table rev_ltd (insert record for each furniture you want to add), furni_id should be the same as 'id' of the furniture is in table 'furniture'.

    Images:
    Last edited by Thewicard; 30-03-13 at 05:44 PM.


  2. #2
    Sorcerer Supreme TardisHotel is offline
    Member +Rank
    Mar 2013 Join Date
    404Posts

    Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]

    Thankyou so much what a great release xo

  3. #3
    Grand Master KyleeIsProzZ is offline
    Grand MasterRank
    Oct 2012 Join Date
    C:Location
    548Posts

    happy Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]

    Hey,

    Going to Re Code this for UberCMS 2.0,
    hope you don't mind. I'll give you credits...

  4. #4
    Member Thewicard is offline
    MemberRank
    Nov 2011 Join Date
    NorwayLocation
    92Posts

    Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]

    Quote Originally Posted by XiFy View Post
    Hey,

    Going, to code this for UberCMS 2.0, hope you don't mind.
    I'll give you credits...
    Go on :-)
    I hope you create with as good security.

  5. #5
    Elite Member Marceline is offline
    Member +Rank
    Oct 2012 Join Date
    Guess.Location
    228Posts

    Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]

    Thanks for this.
    I hope my laptop gets fixed :/.

    Sent from my GT-S5670 using Tapatalk 2

  6. #6
    Sorcerer Supreme Incinigrate is offline
    Member +Rank
    May 2012 Join Date
    314Posts

    Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]

    Awesome! I'm sure many people will appreciate this release. About time someone releases this :D

  7. #7
    Member Thewicard is offline
    MemberRank
    Nov 2011 Join Date
    NorwayLocation
    92Posts

    Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]

    POST data now filtered,
    Price is now set in DB.

    UPDATE: TOTALY NEEDED third step that got removed by accident, added again.

  8. #8
    Sorcerer Supreme resize is offline
    Member +Rank
    Dec 2011 Join Date
    286Posts

    Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]

    This looks dope man! Realy Nice job!

  9. #9
    Member Thewicard is offline
    MemberRank
    Nov 2011 Join Date
    NorwayLocation
    92Posts

    Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]

    Quote Originally Posted by TardisHotel View Post
    Thankyou so much what a great release xo
    Quote Originally Posted by Incinigrate View Post
    Awesome! I'm sure many people will appreciate this release. About time someone releases this :D
    Quote Originally Posted by resize View Post
    This looks dope man! Realy Nice job!
    Quote Originally Posted by Marceline View Post
    Thanks for this.
    I hope my laptop gets fixed :/.

    Sent from my GT-S5670 using Tapatalk 2

    Thank you for feedback!

  10. #10
    Check http://arcturus.pw The General is offline
    DeveloperRank
    Aug 2011 Join Date
    7,613Posts

    Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]

    Why you declare so many new variables you can simple use $furnileft = $furnileft -1
    It makes the code easier to understand for others.

    Still good release.

  11. #11
    Elite Member BuzzOfficial is offline
    Member +Rank
    Aug 2011 Join Date
    104Posts

    Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]

    Apologies if I'm wrong, but this won't work with Phoenix as Phoenix requires MUS to insert items into the database. If you manually insert items via SQL, Phoenix will not not know the ID has been filled, and will override it :) I only know this as I had the same problem and spoke to Aaron about it.

  12. #12
    Member Thewicard is offline
    MemberRank
    Nov 2011 Join Date
    NorwayLocation
    92Posts

    Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]

    I don't think that's the case with bots, furniture ec since they don't overwrite any information.
    I had a bot creator in a earlier hotel of mine, created in PHP no MUS. Phoenix 3.11.0

  13. #13
    Elite Member BuzzOfficial is offline
    Member +Rank
    Aug 2011 Join Date
    104Posts

    Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]

    Quote Originally Posted by Thewicard View Post
    I don't think that's the case with bots, furniture ec since they don't overwrite any information.
    I had a bot creator in a earlier hotel of mine, created in PHP no MUS. Phoenix 3.11.0
    Bot's are fine because they aren't inserted by the emulator, however items are, and the emulator will not take notice of anything that is inserted via the CMS in the items table and will simply overwrite it. You can ask Aaron's opinion on this if you want to :) I only became aware of the problem when my users complained that the items they'd purchased had dissapeared

  14. #14
    Member Dan822 is offline
    MemberRank
    Jan 2013 Join Date
    BirminghamLocation
    92Posts

    Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]

    one problem, the design isn't the same on my cms, it's just a blank button.

    Dosen't this require CSS?

  15. #15
    Member Thewicard is offline
    MemberRank
    Nov 2011 Join Date
    NorwayLocation
    92Posts

    Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]

    Quote Originally Posted by Dan822 View Post
    one problem, the design isn't the same on my cms, it's just a blank button.

    Dosen't this require CSS?
    I belive it will work for you to change
    <div class="left page round"> and
    class="button round">
    to something that fits your theme.

    Quote Originally Posted by BuzzOfficial View Post
    Bot's are fine because they aren't inserted by the emulator, however items are, and the emulator will not take notice of anything that is inserted via the CMS in the items table and will simply overwrite it. You can ask Aaron's opinion on this if you want to :) I only became aware of the problem when my users complained that the items they'd purchased had dissapeared
    I tested it out with phoenix, furni appeared after reload (Like it should)
    I tried shutdowning and various other things, but it seems to work like it should.
    This is no issue.

  16. #16
    Elite Member billsonnn is offline
    Member +Rank
    Jan 2013 Join Date
    157Posts

    Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]

    Your code isn't as secure as you say it is... I rewrote the second part. I haven't tested it yet but it's a lot better.

    [PHP] <?php $ltd_id = (isset($_POST['ltd_id']) && $_POST['ltd_id'] != NULL && is_nu - Pastebin.com
    Last edited by billsonnn; 29-03-13 at 07:13 PM.

  17. #17
    Member Thewicard is offline
    MemberRank
    Nov 2011 Join Date
    NorwayLocation
    92Posts

    Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]

    Quote Originally Posted by billsonnn View Post
    Your code isn't as secure as you say it is... I rewrote the second part. I haven't tested it yet but it's a lot better.

    [PHP] <?php $ltd_id = (isset($_POST['ltd_id']) && $_POST['ltd_id'] != NULL && is_nu - Pastebin.com
    (1)
    POST on second part is already filtered.
    $ltd_id = preg_replace('/[^0-9]/', '', $_POST["ltd_id"]);

    (2)
    The "auto increment" doesn't always work as great.

    (3)
    You forgot to redirect back to /me (or whatever page that is prefered)

    (4)
    Your code doesn't work.
    PHP Code:
    Warningmysql_result() expects parameter 1 to be resourceinteger given in C:\xampp\htdocs\RevCMS\app\tpl\skins\Priv\buyltd.php on line 7
    You don
    't have enough credits for that furniture 
    Last edited by Thewicard; 29-03-13 at 07:49 PM.

  18. #18
    Elite Member Riley H is offline
    Member +Rank
    Mar 2010 Join Date
    United StatesLocation
    203Posts

    Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]

    Changing all of the text when the user doesn't have enough credits is kind of unnecessary imo, you could just display a prompt saying "Insufficient Funds" when the user tries to purchase it. Otherwise this is a pretty cool release.

  19. #19
    Member Thewicard is offline
    MemberRank
    Nov 2011 Join Date
    NorwayLocation
    92Posts

    Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]

    Quote Originally Posted by Riley H View Post
    Changing all of the text when the user doesn't have enough credits is kind of unnecessary imo, you could just display a prompt saying "Insufficient Funds" when the user tries to purchase it. Otherwise this is a pretty cool release.
    I don't see what damage it does? :P

  20. #20
    Member Dan822 is offline
    MemberRank
    Jan 2013 Join Date
    BirminghamLocation
    92Posts

    Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]

    anybody managed to get this fully working for habbo theme?

  21. #21
    Member Thewicard is offline
    MemberRank
    Nov 2011 Join Date
    NorwayLocation
    92Posts

    Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]

    Quote Originally Posted by Dan822 View Post
    anybody managed to get this fully working for habbo theme?
    Send me URL of a plain Habbo theme and I'll look into it.
    Last edited by Thewicard; 29-03-13 at 09:53 PM.

  22. #22
    Elite Member billsonnn is offline
    Member +Rank
    Jan 2013 Join Date
    157Posts

    [RevCMS] LIMITED furniture sales in CMS [Phoenix]

    Quote Originally Posted by Thewicard View Post
    (1)
    POST on second part is already filtered.
    $ltd_id = preg_replace('/[^0-9]/', '', $_POST["ltd_id"]);

    (2)
    The "auto increment" doesn't always work as great.

    (3)
    You forgot to redirect back to /me (or whatever page that is prefered)

    (4)
    Your code doesn't work.
    PHP Code:
    Warningmysql_result() expects parameter 1 to be resourceinteger given in C:\xampp\htdocs\RevCMS\app\tpl\skins\Priv\buyltd.php on line 7
    You don
    't have enough credits for that furniture 
    I said I hadn't tested it yet. Your code is messy and could use some improvement. I was simply trying to help.


    Sent from my iPhone using Tapatalk 2

  23. #23
    Elite Member BuzzOfficial is offline
    Member +Rank
    Aug 2011 Join Date
    104Posts

    Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]

    Quote Originally Posted by Thewicard View Post
    I tested it out with phoenix, furni appeared after reload (Like it should)
    I tried shutdowning and various other things, but it seems to work like it should.
    This is no issue.
    It works at first, but wait and see after using it for a period of time people will start complaining of their furni dissapear. Aaron himself has confirmed that the Emulator will simply overwrite what is inserted by the CMS in the "items" table. I'm just trying to help out, you should try using MUS commands :)

  24. #24
    Member Thewicard is offline
    MemberRank
    Nov 2011 Join Date
    NorwayLocation
    92Posts

    Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]

    Quote Originally Posted by BuzzOfficial View Post
    It works at first, but wait and see after using it for a period of time people will start complaining of their furni dissapear. Aaron himself has confirmed that the Emulator will simply overwrite what is inserted by the CMS in the "items" table. I'm just trying to help out, you should try using MUS commands :)
    Not possible to open gifts sent in MUS?

  25. #25
    Developer Eronisch is offline
    Grand MasterRank
    Jul 2009 Join Date
    The NetherlandsLocation
    1,328Posts

    Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]

    Thank you very much.

    I'm just wondering why you are making a string out of this?

    $newfurnileft = $furnileft - '1';
    $newfurnisold = $furnisold + '1';
    mysql_query("UPDATE rev_ltd SET furni_sold='".$newfurnisold."'") or die(mysql_error());
    mysql_query("UPDATE rev_ltd SET furni_left='".$newfurnileft."'") or die(mysql_error());
    Instead of a preg_match you can also do is_digit, not sure what the function was called, it's been a long time since i worked with php!



Page 1 of 2 12 LastLast

Advertisement