protected static function getItemLangData(&$data) { // multi-language if (is_array($data)) { $lang = SettingsClass::getString('Language'); if (isset($data[$lang])) { return $data[$lang]; } else { if (isset($data['en'])) { return $data['en']; } else { return reset($data); } } } return $data; }
function __construct() { global $config; session_init(); $loginUrl = './?page=login'; if (empty($config['session name'])) { $config['session name'] = 'WebAuctionPlus User'; } // check logged in if (isset($_SESSION[$config['session name']])) { $this->doValidate($_SESSION[$config['session name']]); } // not logged in (and is required) if (SettingsClass::getBoolean('Require Login')) { if (!$this->isOk() && $config['page'] != 'login') { ForwardTo($loginUrl, 0); exit; } } }
function FormatPrice($price) { global $config; return SettingsClass::getString('Currency Prefix') . number_format((double) $price, 2) . SettingsClass::getString('Currency Postfix'); }
$output .= ' </div> '; break; case 'basic': $output .= ' </td></tr> <tr><td style="height: 1px;"> '; } $output .= ' <div id="footer" class="clear" style="text-align:center; padding:10px"> <!-- Paste advert code here --> <!-- ====================== --> <p style="margin-bottom: 10px; font-size: large; color: #FFFFFF;"> ' . '<a href="http://dev.bukkit.org/server-mods/webauctionplus/" ' . 'target="_blank" style="color: #FFFFFF;"><u>WebAuctionPlus</u> ' . SettingsClass::getString('Version') . '</a> <br />' . '<span style="font-size: medium;"> Based on the original WebAuction </span></p> <p style="margin-bottom: 10px; font-size: smaller; color: #FFFFFF;">' . '<b> Rendered page in ' . GetRenderTime() . ' Seconds with ' . (int) @$num_queries . ' Queries </b></p> <p style="font-size: smaller; color: #FFFFFF;">' . ' </div> '; switch ($html->getPageFrame()) { case 'basic': $output .= ' </td></tr> </table> '; } $output .= ' </body> </html> ';
public static function BuyFixed($auctionId, $qty) { global $config, $user; // validate args $auctionId = (int) $auctionId; $qty = (int) $qty; if ($auctionId < 1) { $_SESSION['error'][] = 'Invalid auction id!'; return FALSE; } if ($qty < 1) { $_SESSION['error'][] = 'Invalid qty!'; return FALSE; } // has canBuy permissions if (!$user->hasPerms('canBuy')) { $_SESSION['error'][] = 'You don\'t have permission to buy.'; return FALSE; } // query auction $auction = QueryAuctions::QuerySingle($auctionId); if (!$auction) { $_SESSION['error'][] = 'Auction not found!'; return FALSE; } $Item = $auction->getItemCopy(); // // is item allowed // if (!itemAllowed($item->name, $item->damage)){ // $_SESSION['error'][] = $item->fullname.' is not allowed to be sold.'; // header("Location: ../myauctions.php"); // } // buying validation if ($auction->getSellerId() == $user->getId()) { $_SESSION['error'][] = 'Can\'t buy from yourself!'; return FALSE; } if ($qty > $Item->getItemQty()) { $_SESSION['error'][] = 'Not that many for sale!'; return FALSE; } $maxSellPrice = SettingsClass::getDouble('Max Sell Price'); $sellPrice = $auction->getPrice(); $priceTotal = $sellPrice * (double) $qty; if ($maxSellPrice > 0.0 && $sellPrice > $maxSellPrice) { $_SESSION['error'][] = 'Over max sell price of ' . SettingsClass::getBoolean('Currency Prefix') . $maxSellPrice . SettingsClass::getBoolean('Currency Prefix') . ' !'; return FALSE; } if ($priceTotal > $user->getMoney()) { $_SESSION['error'][] = 'You don\'t have enough money!'; return FALSE; } // make payment from buyer to seller UserClass::MakePayment($user->getName(), $user->getUUID(), $auction->getSeller(), $auction->getSellerUUID(), $priceTotal, 'Bought auction ' . (int) $auction->getTableRowId() . ' ' . $Item->getItemTitle() . ' x' . (int) $Item->getItemQty()); // remove auction if (!self::RemoveAuction($auctionId, $qty < $Item->getItemQty() ? $qty : -1)) { echo '<p style="color: red;">Error removing/updating auction!</p>'; exit; } // add to inventory $Item->setItemQty($qty); $tableRowId = ItemFuncs::AddCreateItem($user->getId(), $Item); if (!$tableRowId) { echo '<p style="color: red;">Error adding item to your inventory!</p>'; exit; } // add sale log LogSales::addLog(LogSales::LOG_SALE, LogSales::SALE_BUYNOW, $auction->getSellerId(), $user->getId(), $Item, $sellPrice, FALSE, '', TRUE); return TRUE; }
public static function getItemBlacklist() { if (self::$itemBlacklist !== NULL) { return self::$itemBlacklist; } $str = self::getString('Item Blacklist'); if (empty($str)) { self::$itemBlacklist = array(); return self::$itemBlacklist; } $list = array(); $parts = explode(',', $str); foreach ($parts as $part) { $part = trim($part); if (empty($part)) { continue; } $stack = self::getItemBlacklist_Type($part); if ($stack == NULL) { continue; } $list[] = $stack; } self::$itemBlacklist = $list; return self::$itemBlacklist; }
SettingsClass::setDefault('Item Packs', '', FALSE); SettingsClass::setDefault('Max Sell Price', 10000.0, TRUE); //SettingsClass::setDefault('Max Selling Per Player', 20 , TRUE ); $config['language'] = SettingsClass::getString('Language'); $config['theme'] = SettingsClass::getString('Website Theme'); // check website version if (SettingsClass::getString('Version') != CURRENT_VERSION) { echo '<center><h2>Please update the RhythmMarket website to match the plugin version you\'re running.</h2>' . '<b>Plugin is running: ' . SettingsClass::getString('Version') . '</b><br />' . '<b>Website is running: ' . CURRENT_VERSION . '</b></center>'; exit; } // jquery ui path $lpaths['static jquery'] = $lpaths['static'] . 'jquery/' . SanFilename(SettingsClass::getString('jQuery UI Pack')) . '/'; $wpaths['static jquery'] = $wpaths['static'] . 'jquery/' . SanFilename(SettingsClass::getString('jQuery UI Pack')) . '/'; // load item packs require $lpaths['item packs'] . 'default/item.defines.php'; foreach (explode(',', SettingsClass::getString('Item Packs')) as $v) { $t = trim($v); if (empty($v)) { continue; } require $lpaths['item packs'] . SanFilename($v) . '/item.defines.php'; } // load template engine require $lpaths['classes'] . 'html.class.php'; $page_outputs = array(); $config['html'] = new RenderHtml($page_outputs, $tags); // load user manager include $lpaths['classes'] . 'user.class.php'; $config['user'] = new UserClass(); if ($config['user'] === NULL) { echo '<p>Failed to load user manager!</p>';
function RenderPage_sell() { global $config, $html, $user; $config['title'] = 'Sell Items'; $id = getVar('id', 'int'); // load page html $outputs = RenderHTML::LoadHTML('pages/sell.php'); if (!is_array($outputs)) { echo 'Failed to load html!'; exit; } // load javascript $html->addToHeader($outputs['header']); // query item $Item = QueryItems::QuerySingle($user->getId(), $id); if (!$Item) { return '<h2 style="text-align: center;">The item you\'re trying to sell couldn\'t be found!</h2>'; } // check item blacklist ItemFuncs::checkItemBlacklist($Item); $qty = getVar('qty'); $priceFixed = getVar('priceFixed', 'double'); $priceStart = getVar('priceStart', 'double'); $priceBuy = getVar('priceBuy', 'double'); $priceSell = getVar('priceSell', 'double'); if (empty($qty)) { $qty = $Item->getItemQty(); } if ($priceFixed < 0.0) { $priceFixed = 0.0; } if ($priceStart < 0.0) { $priceStart = 0.0; } if ($priceBuy < 0.0) { $priceBuy = 0.0; } if ($priceSell < 0.0) { $priceSell = 0.0; } $messages = ''; $tags = array('messages' => &$messages, 'item id' => (int) $id, 'item display' => $Item->getDisplay(), 'have qty' => (int) $Item->getItemQty(), 'qty' => (int) $qty, 'price fixed' => (double) $priceFixed, 'price start' => (double) $priceStart, 'price buy' => (double) $priceBuy, 'price sell' => (double) $priceSell, 'currency prefix' => SettingsClass::getString('Currency Prefix'), 'currency postfix' => SettingsClass::getString('Currency Postfix')); unset($Item); // input errors if (isset($_SESSION['error'])) { if (is_array($_SESSION['error'])) { foreach ($_SESSION['error'] as $msg) { $messages .= str_replace('{message}', $msg, $outputs['error']); } } else { $messages .= str_replace('{message}', $_SESSION['error'], $outputs['error']); } unset($_SESSION['error']); } if (!$user->hasPerms('canSell')) { $messages .= str_replace('{message}', 'You don\'t have permission to sell.', $outputs['error']); } RenderHTML::RenderTags($outputs['body'], $tags); unset($tags); return $outputs['body']; }
public static function isEnabled() { return SettingsClass::getBoolean('CSRF Protection'); }
public static function SellShop($shopId, $qty) { global $config, $user; // has canSell permissions if (!$user->hasPerms('canSell')) { $_SESSION['error'][] = 'You don\'t have permission to sell.'; return FALSE; } // sanitize args $shopId = (int) $shopId; $qty = (int) $qty; if ($shopId < 1) { $_SESSION['error'][] = 'Invalid server shop id!'; return FALSE; } if ($qty < 1) { $_SESSION['error'][] = 'Invalid qty!'; return FALSE; } // query shop $shop = QueryAuctions::QuerySingleShop($shopId); if (!$shop) { $_SESSION['error'][] = 'Shop not found!'; return FALSE; } $shopItem = $shop->getItem(); if (!$shopItem) { $_SESSION['error'][] = 'Failed to get item info for server shop!'; return FALSE; } // query player items $Items = QueryItems::QueryInventory($user->getId(), $shopItem); if (!$Items) { $_SESSION['error'][] = 'Failed to get item from inventory!'; return FALSE; } // shop price $shopPrice = $shop->getPriceSell(); if ($shopPrice <= 0.0) { $_SESSION['error'][] = 'Cannot sell to this shop!'; return FALSE; } // sell multiple stacks $hasFound = FALSE; $soldCount = 0; while (TRUE) { $Item = $Items->getNext(); // no more stacks found if (!$Item) { break; } // remove empty stack if ($Item->getItemQty() <= 0) { ItemFuncs::RemoveItem($Item->getTableRowId(), -1); continue; } // sold enough if ($soldCount >= $qty) { break; } $hasFound = TRUE; // sell partial stack if ($qty - $soldCount < $Item->getItemQty()) { $sellQty = $qty - $soldCount; $soldCount += $sellQty; if (!ItemFuncs::RemoveItem($Item->getTableRowId(), $sellQty)) { $_SESSION['error'][] = 'Failed to remove sold item!'; return FALSE; } // sell full stack } else { $soldCount += $Item->getItemQty(); if (!ItemFuncs::RemoveItem($Item->getTableRowId(), -1)) { $_SESSION['error'][] = 'Failed to remove sold item!'; return FALSE; } } } // no items sold if (!$hasFound || $soldCount <= 0) { $_SESSION['error'][] = 'You don\'t have any of this item!'; return FALSE; } // price for sold items $priceTotal = $shopPrice * (double) $soldCount; // success $_SESSION['success'][] = 'Sold ' . $soldCount . ' items for ' . SettingsClass::getString('Currency Prefix') . $priceTotal . SettingsClass::getString('Currency Postfix'); // make payment to seller UserClass::PaymentQuery($user->getName(), $user->getUUID(), $priceTotal); // sold less than requested if ($qty > $soldCount) { $_SESSION['error'][] = 'You don\'t have that many!'; } // add sale log $Item->setItemQty($soldCount); LogSales::addLog(LogSales::LOG_SALE, LogSales::SALE_SERVER, NULL, $user->getId(), $Item, $priceTotal, FALSE, '', FALSE); return TRUE; }
$output .= ' </div> '; break; case 'basic': $output .= ' </td></tr> <tr><td style="height: 1px;"> '; } $output .= ' <div id="footer" class="clear" style="text-align:center; padding:10px"> <!-- Paste advert code here --> <!-- ====================== --> <p style="margin-bottom: 10px; font-size: large; color: #FFFFFF;"> ' . '<a href="http://website.rhythmpvp.com" ' . 'target="_blank" style="color: #FFFFFF;"><u>RhythmMarket</u> ' . SettingsClass::getString('Version') . '</a> By pablo67340 & lorenzop <br />' . '<b> Rendered page in ' . GetRenderTime() . ' Seconds with ' . (int) @$num_queries . ' Queries </b></p> <p style="font-size: smaller; color: #FFFFFF;">' . ' </div> '; switch ($html->getPageFrame()) { case 'basic': $output .= ' </td></tr> </table> '; } $output .= ' </body> </html> '; return $output;
public static function checkItemBlacklist($item) { if ($item == NULL) { return; } $blacklist = SettingsClass::getItemBlacklist(); $id = $item->getItemId(); $damage = $item->getItemDamage(); foreach ($blacklist as $listed) { if ($listed->id == $id) { if ($listed->damage == -1 || $listed->damage == $damage) { echo '<br /><center><font size="+2" color="red">Sorry, you cannot sell this type of item.</font></center><br />'; exit; } } } }
function RenderPage_sell() { global $config, $html, $user, $settings; $output = ''; $id = getVar('id', 'int'); $qty = getVar('qty'); $priceEach = getVar('price', 'double'); // query item $Item = QueryItems::QuerySingle($user->getName(), $id); if (!$Item) { return '<h2 style="text-align: center;">The item you\'re trying to sell couldn\'t be found!</h2>'; } //echo '<pre>';print_r($Item);exit(); if (empty($qty)) { $qty = $Item->getItemQty(); } if ($priceEach == 0.0) { $priceEach = ''; $priceTotal = ''; } else { $priceTotal = (double) $priceEach * (double) $qty; } $html->addToHeader(' <script type="text/javascript" language="javascript"> function updateTotal(thisfield,otherfieldid){ otherfield = document.getElementById(otherfieldid); document.getElementById("pricetotal").innerHTML = (thisfield.value * otherfield.value).toFixed(2); // $("pricetotal").update( thisfield.value * otherfield.value ); } </script> '); //if(isset($_SESSION['error'])) { // $output.='<p style="color:red">'.$_SESSION['error'].'</p>'; // unset($_SESSION['error']); //} //if(isset($_SESSION['success'])) { // $output.='<p style="color: green;">'.$_SESSION['success'].'</p>'; // unset($_SESSION['success']); //} $output .= ' <!-- mainTable example --> <form action="./" method="post"> {token form} <input type="hidden" name="page" value="' . $config['page'] . '" /> <input type="hidden" name="action" value="newauction" /> <input type="hidden" name="lastpage" value="' . getLastPage() . '" /> <input type="hidden" name="id" value="' . getVar('id', 'int') . '" /> <table border="0" cellpadding="0" cellspacing="0" id="createauctionTable"> '; // input errors if (!isset($config['error'])) { if (!$user->hasPerms('canSell')) { $config['error'] = 'You don\'t have permission to sell.'; } } if (isset($config['error'])) { $output .= '<tr><td align="center" style="padding-top: 20px; color: red; font-size: larger;">' . $config['error'] . '</td></tr>'; } // add enchantments to this link! // '<a href="./?page=graph&name='.((int)$Item->getItemId()).'&damage='.$Item->getItemDamage().'">'.' . $output .= ' <tr><td align="center"><h2>Create a New Auction</h2></td></tr> <tr><td align="center"><div class="input" style="width: 150px; padding-top: 15px; padding-bottom: 15px; text-align: center;">' . $Item->getDisplay() . '</div></td></tr> <tr><td height="20"></td></tr> <tr><td align="center"><b>You have <font size="+2">' . (int) $Item->getItemQty() . '</font> items</b></td></tr> <tr><td><table border="0" cellpadding="0" cellspacing="10" align="center"> <tr> <td align="right"><b>Quantity:</b></td> <td><div style="position: absolute; margin-top: 10px; margin-left: 8px; font-size: larger; font-weight: bold;">x</div>' . '<input type="text" name="qty" value="' . (int) $qty . '" id="qty" class="input" style="width: 160px; text-align: center;" ' . 'onkeypress="return numbersonly(this, event);" onkeyup="updateTotal(this,\'price\');" /></td> </tr> <tr> <td align="right"><b>Price Each:</b></td> <td><div style="position: absolute; margin-top: 8px; margin-left: 8px; font-size: larger; font-weight: bold;">' . SettingsClass::getString('Currency Prefix') . '</div>' . '<input type="text" name="price" value="' . $priceEach . '" id="price" class="input" style="width: 160px; text-align: center;" ' . 'onkeypress="return numbersonly(this, event);" onkeyup="updateTotal(this,\'qty\');" />' . '<b> ' . SettingsClass::getString('Currency Postfix') . '</b></td> </tr> <tr> <td align="right"><b>Price Total:</b></td> <td><div style="position: absolute; margin-top: 8px; margin-left: 8px; font-size: larger; font-weight: bold;">' . SettingsClass::getString('Currency Prefix') . '</div>' . '<div id="pricetotal" class="input" style="float: left; width: 160px; text-align: center; font-size: larger; font-weight: bold;"> </div>' . '<div style="margin-top: 8px;"><b> ' . SettingsClass::getString('Currency Postfix') . '</b></div></td> </tr> </table></td></tr> <tr><td height="20"></td></tr> '; // custom descriptions if (SettingsClass::getString('Custom Descriptions')) { $output .= ' <tr><td colspan="2" align="center"> <b>Description:</b> (optional)</td></tr> <tr><td height="10"></td></tr> <tr><td colspan="2" align="center"><textarea name="desc" class="input" style="width: 80%; height: 55px;" readonly>Coming soon!</textarea></td></tr> <tr><td height="30"></td></tr> '; } $output .= ' <tr><td colspan="2" align="center"><input type="submit" value="Create Auction" class="input" /></td></tr> <tr><td height="30"></td></tr> </table> </form> '; unset($Item); return $output; }