<?php require_once 'config.php'; $cartEntityId = $_GET['entity_id']; /** * @param $cartEntityId * @return bool * */ function removeItem($cartEntityId) { global $DB; try { $stmt = $DB->prepare("DELETE FROM cart WHERE entity_id = :cartEntityId "); $stmt->bindParam(':cartEntityId', $cartEntityId); return $stmt->execute(); } catch (Exception $e) { } } $removeStatus = removeItem($cartEntityId); if ($removeStatus) { header("location:cart_page.php"); exit; }
require_once 'mycart.php'; require_once 'footer.php'; } break; case "compatibleJSON": $id = isset($_GET['id']) != null ? $_GET['id'] : ""; getBrandCompatibleMakes($id); break; case "updateQTY": if (isset($_POST['cpID']) != null && isset($_POST['Qty']) != null) { echo updateQTY($_POST['cpID'], $_POST['Qty']); } break; case "removeItem": if (isset($_POST['cpID']) != null) { echo removeItem($_POST['cpID']); } break; case "logout": session_destroy(); header('Location: index.php?action=home'); break; case "myaccount": if (isLoggedin()) { $pageTitle = "AlgimStore - My Account"; require_once 'header.php'; require_once 'myaccount.php'; require_once 'footer.php'; } else { header('Location: index.php?action=login'); }
} else { $turn_cost = 0; $generic_state_change = "__TARGET__ is already {$state}."; } } else { if ($command == 'Kampo') { $covert = true; // *** Get Special Items From Inventory *** $user_id = self_char_id(); $root_item_type = 7; $itemCount = query_item('SELECT sum(amount) AS c FROM inventory WHERE owner = :owner AND item_type = :type GROUP BY item_type', array(':owner' => $user_id, ':type' => $root_item_type)); $turn_cost = min($itemCount, $starting_turns - 1, 2); // Costs 1 or two depending on the number of items. if ($turn_cost && $itemCount > 0) { // *** If special item count > 0 *** removeItem($user_id, 'ginsengroot', $itemCount); add_item($user_id, 'tigersalve', $itemCount); $generic_skill_result_message = 'With intense focus you grind the ' . $itemCount . ' roots into potent formulas.'; } else { // *** no special items, give error message *** $turn_cost = 0; $generic_skill_result_message = 'You do not have the necessary ginsengroots or energy to create any Kampo formulas.'; } } else { if ($command == 'Poison Touch') { $covert = true; $target->addStatus(POISON); $target->addStatus(WEAKENED); // Weakness kills strength. $target_damage = rand($poisonMinimum, $poisonMaximum); $victim_alive = $target->subtractHealth($target_damage);
{ return $this->productName; } public function getPrice() { return $this->price; } } $products = array(1 => new Product(1, "SuperWidget", 19.99), 2 => new Product(2, "MegaWidget", 29.99), 3 => new Product(3, "WonderWidget", 39.99)); if (!isset($_SESSION["cart"])) { $_SESSION["cart"] = array(); } if (isset($_GET["action"]) and $_GET["action"] == "addItem") { addItem(); } elseif (isset($_GET["action"]) and $_GET["action"] == "removeItem") { removeItem(); } else { displayCart(); } function addItem() { global $products; if (isset($_GET["productId"]) and $_GET["productId"] >= 1 and $_GET["productId"] <= 3) { $productId = (int) $_GET["productId"]; if (!isset($_SESSION["cart"][$productId])) { $_SESSION["cart"][$productId] = $products[$productId]; } } session_write_close(); header("Location: shopping_cart.php"); }
function craftItem($PID, $BID, $BID2) { $conn = conDB(); $IID = getIID($PID, $BID); $IID2 = getIID($PID, $BID2); $newIID = checkRecipe($IID, $IID2); if ($newIID != 0) { $R1 = removeItem($PID, $IID, 1); $sql = "SELECT * FROM craftrecipe WHERE (ItemID1='{$IID}' AND ItemID2='{$IID2}') OR (ItemID2='{$IID}' AND ItemID1='{$IID2}')"; $result = mysqli_query($conn, $sql); $row = $result->fetch_assoc(); $min = $row["Min"]; $max = $row["Max"]; $DIFF = $row["Difficulty"]; $LVL = $row["LVL"]; $SKID = $row["SkillID"]; if ($R1 == 0) { $R2 = removeItem($PID, $IID2, 1); if ($R2 == 0) { $skill = performAct($PID, $SKID, $DIFF, $LVL); if ($skill == true) { if ($min != $max) { $QUANT = rand($min, $max); } else { $QUANT = $max; } AddtoLog($PID, "You successfully Crafted an Item!", 0, 1); grantItem($PID, $newIID, $QUANT); } AddtoLog($PID, "You were unable to Craft the item.", 0, 0); } } } }
$array[] = $item; } } else { printf("no results!"); } mysqli_free_result($result); return $array; } $con = mysqli_connect("dbhost.cs.man.ac.uk", "mbbx9mg3", "Fincherz+2013") or die("Error " . mysqli_error($link)); mysqli_select_db($con, "mbbx9mg3"); if (isset($_POST["submit_button"])) { $itemsList = $_POST['items']; $message = ""; foreach ($_POST['items'] as $check) { $newItemID = getItemID($check, $con); removeItem($newItemID, $con); } $message = "Removed Successfully!"; } // isInserted $array = selectItems($con); mysqli_close($con); ?> <!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Properties. To change this template file, choose Tools | Templates and open the template in the editor. --> <html> <head>
public function testIndexDoesNotErrorWithoutItem() { removeItem($this->char->id(), self::ITEM); $result = $this->controller->index(); $this->assertNotEmpty($result); }
/** * Use an item on a target * @note /use/ is aliased to useItem externally because use is a php reserved keyword */ public function useItem($give = false, $self_use = false) { // Formats are: // http://nw.local/item/self_use/amanita/ // http://nw.local/item/use/shuriken/10/ // http://nw.local/item/give/shuriken/10/ // http://nw.local/item/use/shuriken/156001/ $slugs = $this->parse_slugs($give, $self_use); // Pull the parsed slugs $link_back = $slugs['link_back']; $selfTarget = $slugs['selfTarget']; $item_in = $slugs['item_in']; // Item identifier, either it's id or internal name $in_target = $slugs['in_target']; $give = $slugs['give']; $target = $in_target; if (positive_int($in_target)) { $target_id = positive_int($target); } else { $target_id = get_char_id($target); } $give = in_array($give, array('on', 'Give')); $player = new Player(self_char_id()); $victim_alive = true; $using_item = true; $item_used = true; $stealthLost = false; $error = false; $suicide = false; $kill = false; $repeat = false; $ending_turns = null; $turns_change = null; $turns_to_take = null; $gold_mod = NULL; $result = NULL; $targetResult = NULL; // result message to send to target of item use $targetName = ''; $targetHealth = ''; $bountyMessage = ''; $resultMessage = ''; $alternateResultMessage = ''; if ($item_in == (int) $item_in && is_numeric($item_in)) { // Can be cast to an id. $item = $item_obj = getItemByID($item_in); } elseif (is_string($item_in)) { $item = $item_obj = $this->getItemByIdentity($item_in); } else { $item = null; } if (!is_object($item)) { return new RedirectResponse(WEB_ROOT . 'inventory?error=noitem'); } else { $item_count = $this->itemCount($player->id(), $item); // Check whether use on self is occurring. $self_use = $selfTarget || $target_id === $player->id(); if ($self_use) { $target = $player->name(); $targetObj = $player; } else { if ($target_id) { $targetObj = new Player($target_id); $target = $targetObj->name(); } } $starting_turns = $player->turns; $username_turns = $starting_turns; $username_level = $player->level; if ($targetObj instanceof Player && $targetObj->id()) { $targets_turns = $targetObj->turns; $targets_level = $targetObj->level; $target_hp = $targetObj->health; } else { $targets_turns = $targets_level = $target_hp = null; } $max_power_increase = 10; $level_difference = $targets_level - $username_level; $level_check = $username_level - $targets_level; $near_level_power_increase = $this->nearLevelPowerIncrease($level_difference, $max_power_increase); // Sets the page to link back to. if ($target_id && ($link_back == "" || $link_back == 'player') && $target_id != $player->id()) { $return_to = 'player'; } else { $return_to = 'inventory'; } // Exceptions to the rules, using effects. if ($item->hasEffect('wound')) { // Minor damage by default items. $item->setTargetDamage(rand(1, $item->getMaxDamage())); // DEFAULT, overwritable. // e.g. Shuriken slices, for some reason. if ($item->hasEffect('slice')) { // Minor slicing damage. $item->setTargetDamage(rand(1, max(9, $player->getStrength() - 4)) + $near_level_power_increase); } // Piercing weapon, and actually does any static damage. if ($item->hasEffect('pierce')) { // Minor static piercing damage, e.g. 1-50 plus the near level power increase. $item->setTargetDamage(rand(1, $item->getMaxDamage()) + $near_level_power_increase); } // Increased damage from damaging effects, minimum of 20. if ($item->hasEffect('fire')) { // Major fire damage $item->setTargetDamage(rand(20, $player->getStrength() + 20) + $near_level_power_increase); } } // end of wounds section. // Exclusive speed/slow turn changes. if ($item->hasEffect('slow')) { $item->setTurnChange(-1 * $this->caltropTurnLoss($targets_turns, $near_level_power_increase)); } else { if ($item->hasEffect('speed')) { $item->setTurnChange($item->getMaxTurnChange()); } } $turn_change = $item_obj->getTurnChange(); $itemName = $item->getName(); $itemType = $item->getType(); $article = self::getIndefiniteArticle($item_obj->getName()); if ($give) { $turn_cost = 1; $using_item = false; } else { $turn_cost = $item->getTurnCost(); } // Attack Legal section $attacker = $player->name(); $params = ['required_turns' => $turn_cost, 'ignores_stealth' => $item_obj->ignoresStealth(), 'self_use' => $item->isSelfUsable()]; assert(!!$selfTarget || $attacker != $target); $AttackLegal = new AttackLegal($player, $targetObj, $params); $attack_allowed = $AttackLegal->check(); $attack_error = $AttackLegal->getError(); // *** Any ERRORS prevent attacks happen here *** if (!$attack_allowed) { //Checks for error conditions before starting. $error = 1; } else { if (is_string($item) || $target == "") { $error = 2; } else { if ($item_count < 1) { $error = 3; } else { /**** MAIN SUCCESSFUL USE ****/ if ($give) { $this->giveItem($player->name(), $target, $item->getName()); $alternateResultMessage = "__TARGET__ will receive your {$item->getName()}."; } else { if (!$item->isOtherUsable()) { // If it doesn't do damage or have an effect, don't use up the item. $resultMessage = $result = 'This item is not usable on __TARGET__, so it remains unused.'; $item_used = false; $using_item = false; } else { if ($item->hasEffect('stealth')) { $targetObj->addStatus(STEALTH); $alternateResultMessage = "__TARGET__ is now stealthed."; $targetResult = ' be shrouded in smoke.'; } if ($item->hasEffect('vigor')) { if ($targetObj->hasStatus(STR_UP1)) { $result = "__TARGET__'s body cannot become more vigorous!"; $item_used = false; $using_item = false; } else { $targetObj->addStatus(STR_UP1); $result = "__TARGET__'s muscles experience a strange tingling."; } } if ($item->hasEffect('strength')) { if ($targetObj->hasStatus(STR_UP2)) { $result = "__TARGET__'s body cannot become any stronger!"; $item_used = false; $using_item = false; } else { $targetObj->addStatus(STR_UP2); $result = "__TARGET__ feels a surge of power!"; } } // Slow and speed effects are exclusive. if ($item->hasEffect('slow')) { $turns_change = $item->getTurnChange(); if ($targetObj->hasStatus(SLOW)) { // If the effect is already in play, it will have a decreased effect. $turns_change = ceil($turns_change * 0.3); $alternateResultMessage = "__TARGET__ is already moving slowly."; } else { if ($targetObj->hasStatus(FAST)) { $targetObj->subtractStatus(FAST); $alternateResultMessage = "__TARGET__ is no longer moving quickly."; } else { $targetObj->addStatus(SLOW); $alternateResultMessage = "__TARGET__ begins to move slowly..."; } } if ($turns_change == 0) { $alternateResultMessage .= " You fail to take any turns from __TARGET__."; } $targetResult = " lose " . abs($turns_change) . " turns."; $targetObj->subtractTurns($turns_change); } else { if ($item->hasEffect('speed')) { // Note that speed and slow effects are exclusive. $turns_change = $item->getTurnChange(); if ($targetObj->hasStatus(FAST)) { // If the effect is already in play, it will have a decreased effect. $turns_change = ceil($turns_change * 0.5); $alternateResultMessage = "__TARGET__ is already moving quickly."; } else { if ($targetObj->hasStatus(SLOW)) { $targetObj->subtractStatus(SLOW); $alternateResultMessage = "__TARGET__ is no longer moving slowly."; } else { $targetObj->addStatus(FAST); $alternateResultMessage = "__TARGET__ begins to move quickly!"; } } // Actual turn gain is 1 less because 1 is used each time you use an item. $targetResult = " gain {$turns_change} turns."; $targetObj->changeTurns($turns_change); // Still adding some turns. } } if ($item->getTargetDamage() > 0) { // *** HP Altering *** $alternateResultMessage .= " __TARGET__ takes " . $item->getTargetDamage() . " damage."; if ($self_use) { $result .= "You take " . $item->getTargetDamage() . " damage!"; } else { if (strlen($targetResult) > 0) { $targetResult .= " You also"; // Join multiple targetResult messages. } $targetResult .= " take " . $item->getTargetDamage() . " damage!"; } $victim_alive = $targetObj->subtractHealth($item->getTargetDamage()); // This is the other location that $victim_alive is set, to determine whether the death proceedings should occur. } if ($item->hasEffect('death')) { $targetObj->death(); $resultMessage = "The life force drains from __TARGET__ and they drop dead before your eyes!"; $victim_alive = false; $targetResult = " be drained of your life-force and die!"; $gold_mod = 0.25; //The Dim Mak takes away 25% of a targets' gold. } if ($turns_change !== null) { // Even if $turns_change is set to zero, let them know that. if ($turns_change > 0) { $resultMessage .= "__TARGET__ has gained back {$turns_change} turns!"; } else { if ($turns_change === 0) { $resultMessage .= "__TARGET__ did not lose any turns!"; } else { $resultMessage .= "__TARGET__ has lost " . abs($turns_change) . " turns!"; } if ($targetObj->turns <= 0) { // Message when a target has no more turns to remove. $resultMessage .= " __TARGET__ no longer has any turns."; } } } if (empty($resultMessage) && !empty($result)) { $resultMessage = $result; } if (!$victim_alive) { // Target was killed by the item. if (!$self_use) { // *** SUCCESSFUL KILL, not self-use of an item *** $attacker_id = $player->hasStatus(STEALTH) ? "A Stealthed Ninja" : $player->name(); if (!$gold_mod) { $gold_mod = 0.15; } $initial_gold = $targetObj->gold(); $loot = floor($gold_mod * $initial_gold); $targetObj->set_gold($initial_gold - $loot); $player->set_gold($player->gold() + $loot); $player->save(); $targetObj->save(); $player->addKills(1); $kill = true; $bountyMessage = Combat::runBountyExchange($player->name(), $target); //Rewards or increases bounty. } else { $loot = 0; $suicide = true; } // Send mails if the target was killed. $this->sendKillMails($player->name(), $target, $attacker_id, $article, $item->getName(), $loot); } else { // They weren't killed. $attacker_id = $player->name(); } if (!$self_use && $item_used) { if (!$targetResult) { error_log('Debug: Issue 226 - An attack was made using ' . $item->getName() . ', but no targetResult message was set.'); } // Notify targets when they get an item used on them. $message_to_target = "{$attacker_id} has used {$article} {$item->getName()} on you"; if ($targetResult) { $message_to_target .= " and caused you to {$targetResult}"; } else { $message_to_target .= '.'; } send_event($player->id(), $target_id, str_replace(' ', ' ', $message_to_target)); } // Unstealth if (!$item->isCovert() && !$item->hasEffect('stealth') && $player->hasStatus(STEALTH)) { //non-covert acts $player->subtractStatus(STEALTH); $stealthLost = true; } else { $stealthLost = false; } } } $targetName = $targetObj->uname; $targetHealth = $targetObj->health; $turns_to_take = 1; if ($item_used) { // *** remove Item *** removeItem($player->id(), $item->getName(), 1); // *** Decreases the item amount by 1. } if ($victim_alive && $using_item) { $repeat = true; } } } } // *** Take away at least one turn even on attacks that fail to prevent page reload spamming *** if ($turns_to_take < 1) { $turns_to_take = 1; } $ending_turns = $player->subtractTurns($turns_to_take); assert($item->hasEffect('speed') || $ending_turns < $starting_turns || $starting_turns == 0); return ['template' => 'inventory_mod.tpl', 'title' => 'Use Item', 'parts' => get_defined_vars(), 'options' => ['body_classes' => 'inventory-use', 'quickstat' => 'player']]; } // Item was not valid object }
if (!$item->isCovert() && !$item->hasEffect('stealth') && $player->hasStatus(STEALTH)) { //non-covert acts $player->subtractStatus(STEALTH); $stealthLost = true; } else { $stealthLost = false; } } } $targetName = $targetObj->vo->uname; $targetHealth = $targetObj->vo->health; $targetHealthPercent = $targetObj->health_percent(); $turns_to_take = 1; if ($item_used) { // *** remove Item *** removeItem($user_id, $item->getName(), 1); // *** Decreases the item amount by 1. } if ($victim_alive && $using_item) { $repeat = true; } } } } // *** Take away at least one turn even on attacks that fail to prevent page reload spamming *** if ($turns_to_take < 1) { $turns_to_take = 1; } $ending_turns = subtractTurns($user_id, $turns_to_take); assert($item->hasEffect('speed') || $ending_turns < $starting_turns || $starting_turns == 0); display_page('inventory_mod.tpl', 'Item Usage', get_defined_vars(), array('quickstat' => 'player'));
$sql_select = "SELECT plPlayerID, plFirstName, plSurname, plEmail, plEmailPaymentReceived "; $sql_select .= "FROM {$db_prefix}players INNER JOIN {$db_prefix}bookings on bkPlayerID = plPlayerID WHERE bkID = " . $iBookingID; //Run UPDATE query to set paid date ba_db_query($link, $sql_update); //Run SELECT query and send e-mail $result = ba_db_query($link, $sql_select); $row = ba_db_fetch_assoc($result); $sBody = "Your payment for the upcoming event has been received and you have been marked as paid.\n"; $sBody .= "You are now fully booked.\n\nThank you.\n\n"; $sBody .= "Player ID: " . PID_PREFIX . sprintf('%03s', $row['plPlayerID']) . "\n"; $sBody .= "OOC Name: " . $row['plFirstName'] . " " . $row['plSurname']; if ($row['plEmailPaymentReceived']) { mail($row['plEmail'], SYSTEM_NAME . ' - marked paid', $sBody, "From:" . SYSTEM_NAME . " <" . EVENT_CONTACT_MAIL . ">"); } //Remove any meal ticket items from this booking removeItem($iBookingID, 'meal'); //Update meal ticket field if ($meal != 0) { //Set up UPDATE query $sql = "UPDATE {$db_prefix}bookings SET bkMealTicket = 1 WHERE bkID = " . $iBookingID; //Run UPDATE query to set meal ticket ba_db_query($link, $sql); addItem($iBookingID, 'meal'); } } //Update pay on gate field if ($gate != 0) { $sql = "UPDATE {$db_prefix}bookings SET bkDatePaymentConfirmed = '" . date('Y-m-d') . "', bkPayOnGate = 1, bkAmountPaid = {$amountpaid}, bkAmountExpected = {$amountexpected} " . "WHERE bkID = " . $iBookingID; } else { $sql = "UPDATE {$db_prefix}bookings SET bkPayOnGate = 0 WHERE bkID = " . $iBookingID; }
echo PHP_EOL . "... {$trackableIndex} trackable(s) have been added." . PHP_EOL; } break; case "removeItem": echo "Removing item..." . PHP_EOL; $email = getEMail(); $password = getPassword(); $dbName = getDbName(); $filename = getItemFileName(); $msg = validateItemExtension($filename, true); if (isset($msg)) { echo $msg; break; } replaceWhitespaces($filename); $response = removeItem($email, $password, $dbName, $filename); if (isOK($response)) { printResult($response, " ---- DELETING ITEM FAILED ---- ", PHP_EOL . " Item {$filename} has been deleted." . PHP_EOL . PHP_EOL . " ---- DELETING ITEM SUCCESSFULLY COMPLETED ---- "); } else { echo $response->getMessage(); } break; case "deleteTrackingData": echo "Deleting trackable..." . PHP_EOL; $email = getEMail(); $password = getPassword(); $dbName = getDbName(); $filename = getItemFileName("trackable"); $msg = validateItemExtension($filename, true); if (isset($msg)) { echo $msg;
<?php require 'fragments/head.php'; ?> <body> <?php require 'fragments/header.php'; if (isset($_POST['update'])) { if (isset($_POST['qty']) && $_POST['qty'] != "" && is_numeric($_POST['qty'])) { updateCart($_POST['product_id'], $_POST['qty']); } } if (isset($_POST['delete'])) { removeItem($_POST['product_id']); } ?> <nav> <ul> <li><a href="index.php">Home</a></li> <li><a href="movies.php">Movies</a></li> <li><a href="booking.php">Booking</a></li> <li><a href="contact-us.php">Contact Us</a></li> </ul> </nav> <div class="content-full-height"> <div class="container-main"> <h2> Cart</h2>
ba_db_query($link, $sql_clearbunks); foreach ($_POST as $key => $value) { if (substr($key, 0, 8) == "hBooking") { $bunk = (int) $_POST["chkPl{$value}"]; if ($bunk > 0) { $bunk = 1; } else { $bunk = 0; } $iBookingID = (int) $value; if ($bunk) { $sql_update = "UPDATE {$db_prefix}bookings SET bkBunkAllocated = 1, bkBunkRequested = 1 WHERE bkID = " . $iBookingID; //echo $sql_update."<br />"; ba_db_query($link, $sql_update); } removeItem($iBookingID, 'bunk'); if ($bunk > 0) { addItem($iBookingID, 'bunk'); } } } } //Get list of players that have paid and requested bunks $sql = "SELECT plPlayerID, " . "plFirstName, " . "plSurname, " . "bkBookAs, " . "bkBunkRequested, " . "bkBunkAllocated, " . "AES_DECRYPT(pleMedicalInfo, '{$key}') AS dMedicalInfo, " . "chName, " . "bkDateOOCConfirmed, " . "bkDateICConfirmed, " . "bkDatePaymentConfirmed, " . "bkID " . "FROM {$db_prefix}players, {$db_prefix}characters, {$db_prefix}bookings " . "WHERE plPlayerID = chPlayerID AND chPlayerID = bkPlayerID AND " . "bkDatePaymentConfirmed <> '0000-00-00' AND bkDatePaymentConfirmed <> '' and bkEventID = {$eventid}"; $result = ba_db_query($link, $sql); ?> <script src="../inc/sorttable.js" type="text/javascript"></script> <h1><?php echo TITLE; ?>