-
[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_id` int(255) NOT NULL,
`furni_left` int(255) NOT NULL DEFAULT '100',
`furni_sold` int(255) NOT NULL DEFAULT '0',
`furni_price` int(255) NOT NULL DEFAULT '5000',
PRIMARY KEY (`furni_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `rev_ltd` VALUES ('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:
http://puu.sh/2pQSa
-
Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]
Thankyou so much what a great release xo
-
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...
-
Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]
Quote:
Originally Posted by
XiFy
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.
-
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
-
Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]
Awesome! I'm sure many people will appreciate this release. About time someone releases this :D
-
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.
-
Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]
This looks dope man! Realy Nice job!
-
Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]
Quote:
Originally Posted by
TardisHotel
Thankyou so much what a great release xo
Quote:
Originally Posted by
Incinigrate
Awesome! I'm sure many people will appreciate this release. About time someone releases this :D
Quote:
Originally Posted by
resize
This looks dope man! Realy Nice job!
Quote:
Originally Posted by
Marceline
Thanks for this.
I hope my laptop gets fixed :/.
Sent from my GT-S5670 using Tapatalk 2
Thank you for feedback!
-
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.
-
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.
-
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
-
Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]
Quote:
Originally Posted by
Thewicard
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
-
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?
-
Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]
Quote:
Originally Posted by
Dan822
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
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.
-
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
-
Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]
Quote:
Originally Posted by
billsonnn
(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:
Warning: mysql_result() expects parameter 1 to be resource, integer given in C:\xampp\htdocs\RevCMS\app\tpl\skins\Priv\buyltd.php on line 7
You don't have enough credits for that furniture
-
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. :thumbup:
-
Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]
Quote:
Originally Posted by
Riley H
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. :thumbup:
I don't see what damage it does? :P
-
Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]
anybody managed to get this fully working for habbo theme?
-
Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]
Quote:
Originally Posted by
Dan822
anybody managed to get this fully working for habbo theme?
Send me URL of a plain Habbo theme and I'll look into it.
-
[RevCMS] LIMITED furniture sales in CMS [Phoenix]
Quote:
Originally Posted by
Thewicard
(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:
Warning: mysql_result() expects parameter 1 to be resource, integer 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
-
Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]
Quote:
Originally Posted by
Thewicard
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 :)
-
Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]
Quote:
Originally Posted by
BuzzOfficial
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?
-
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?
Quote:
$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!
-
Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]
Once made the same for phoenixphp. Deleted it yesterday lol.
Maybe you should implent MUS so coins are immediatly taken when buying one. Now there is a chance people can get one for free.
-
Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]
Thanks, i can use this! :w00t:
-
Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]
The code dont work right on habbo theme it may not work right at all because if you put 2 limited rares one has 100 out and the other has 60 out it will make them both say 100 and after you buy one in the database it makes them both 100 but this is messing with the database and giving free rares. MUS should be added if you can do that real fast that would help with the free rares and the limit thing idk you should try to find that out. Also this is a awesome release for phoenix users really good!
-
Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]
Quote:
Originally Posted by
Nate Curry
The code dont work right on habbo theme it may not work right at all because if you put 2 limited rares one has 100 out and the other has 60 out it will make them both say 100 and after you buy one in the database it makes them both 100 but this is messing with the database and giving free rares. MUS should be added if you can do that real fast that would help with the free rares and the limit thing idk you should try to find that out. Also this is a awesome release for phoenix users really good!
It works like it should for Priv theme, not really sure what the issue is when converting to Habbo theme.
Will look closer into that.
-
Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]
okay ill tell you what errors i see so you can find out better thanks
-
Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]
Quote:
Originally Posted by
Nate Curry
okay ill tell you what errors i see so you can find out better thanks
One temporary soulution would be in Habbo theme to change name of all variables in the forth part,
ec in furni number 2 change all
$ltd_id = $2ltd_id
$ltd_name = $2ltd_name
$image_url = $2image_url
$selectfromltd = $2selectfromltd
ec ec
-
Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]
Very messy omg!
Please big hotels with 100+ online tell me if you use this plzplz!! :love:
-
Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]
Quote:
Originally Posted by
Nate Curry
The code dont work right on habbo theme it may not work right at all because if you put 2 limited rares one has 100 out and the other has 60 out it will make them both say 100 and after you buy one in the database it makes them both 100 but this is messing with the database and giving free rares. MUS should be added if you can do that real fast that would help with the free rares and the limit thing idk you should try to find that out. Also this is a awesome release for phoenix users really good!
Replace the code in the buyltd.php page with this :
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());
$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());
$getfurninum = mysql_fetch_array($selectfromfurninum);
$furnileft = $getfurninum['furni_left'];
$furnisold = $getfurninum['furni_sold'];
$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."' WHERE furni_id = '".$ltd_id."'") or die(mysql_error());
mysql_query("UPDATE rev_ltd SET furni_left='".$newfurnileft."' WHERE furni_id = '".$ltd_id."'") or die(mysql_error());
$highestid = mysql_query("SELECT * from items ORDER BY id DESC LIMIT 1") or die(mysql_error());
$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">
That will fix the problem.
-
Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix]
now a new problem really bad that you cant even use this it buys the item but makes phoenix have the duplication error so you gotta work on that the most.
-
Re: [RevCMS] LIMITED furniture sales in CMS [Phoenix] ~~~ ERROR
Hello, i followed corectly everything but, when i press "Buy" and after it goes to buyltd.php page, i get this ERROR (See Below). How can i fix it ?
ERROR:
Code:
Unknown column 'id' in 'order clause'