1
Items / Change Balances
« on: October 12, 2007, 09:45:06 am »
just an item to change the balances of Bank and Pocket either individually or together. saves going through mysql, which can be a little daunting for some.
save as ChangeBal.php and place inside your SMFShop's items folder and install as you would an ordinary item just making sure to set stock to zero so no one can purchase it. and then just give yourself the item through admin.
ChangeBal.php
save as ChangeBal.php and place inside your SMFShop's items folder and install as you would an ordinary item just making sure to set stock to zero so no one can purchase it. and then just give yourself the item through admin.
ChangeBal.php
Code: [Select]
<?php
if (!defined('SMF'))
die('Hacking attempt...');
class item_ChangeBal extends itemTemplate {
function getItemDetails() {
$this->authorName = 'inkstains';
$this->authorWeb = 'http://www.daniel15.com/forum/index.php';
$this->authorEmail = '';
$this->name = "Change Balance";
$this->desc = "Change the balances of Bank and Pocket";
$this->price = 10;
$this->require_input = true;
$this->can_use_item = true;
}
function getUseInput() {
global $context, $scripturl, $settings, $txt;
return '<br />Change Money Bank: <select name="resetB" size="1" id="resetB">
<option value="0">No</option>
<option value="1">Yes</option>
</select>
Change Money Bank Value: <input type="text" name="info1" value="40" /><br />
<br />Change Money Pocket: <select name="resetP" size="1" id="resetP">
<option value="0">No</option>
<option value="1">Yes</option>
</select>
Change Money Pocket Value: <input type="text" name="info2" value="40" /><br />
';
}
function onUse() {
global $db_prefix, $ID_MEMBER, $item_info;
if ($_POST['resetB'] && $_POST['resetP'] == 1)
{
db_query("UPDATE {$db_prefix}members
SET moneyBank = {$_POST['info1']}
", __FILE__, __LINE__);
db_query("UPDATE {$db_prefix}members
SET money = {$_POST['info2']}
", __FILE__, __LINE__);
return "Money Bank and Money Pocket has been set to {$_POST['info1']} and {$_POST['info2']} respectively";
die("dead");
}
elseif ($_POST['resetB'] == 1 && $_POST['resetP'] == 0)
{
db_query("UPDATE {$db_prefix}members
SET moneyBank = {$_POST['info1']}", __FILE__, __LINE__);
return "Money Bank has been reset {$_POST['info1']}";
die("dead");
}
elseif ($_POST['resetB'] == 0 && $_POST['resetP'] == 1)
{
db_query("UPDATE {$db_prefix}members
SET money = {$_POST['info2']}", __FILE__, __LINE__);
return "Money Pocket has been reset {$_POST['info2']}";
die("dead");
}
else
{
return "Please make sure you fill in all options";
}
}
}
?>