/** * User command for betting on the coin toss game in the casino * * @param bet int The amount of money to bet on the coin toss game * @return Array * * @note * If the player bets within ~1% of the maximum bet, they will receive a reward item */ public function bet() { $player = new Player(self_char_id()); $bet = intval(in('bet')); $negative = $bet < 0; set_setting('bet', max(0, $bet)); $pageParts = ['reminder-max-bet']; if ($negative) { $pageParts = ['result-cheat']; $player->vo->health = subtractHealth($player->id(), 99); } else { if ($bet > $player->vo->gold) { $pageParts = ['result-no-gold']; } else { if ($bet > 0 && $bet <= self::MAX_BET) { if (rand(0, 1) === 1) { $pageParts = ['result-win']; $player->vo->gold = add_gold($player->id(), $bet); if ($bet >= round(self::MAX_BET * 0.99)) { // within about 1% of the max bet & you win, you get a reward item. add_item($player->id(), self::REWARD, 1); } } else { $player->vo->gold = subtract_gold($player->id(), $bet); $pageParts = ['result-lose']; } } } } // End of not cheating check. return $this->render(['pageParts' => $pageParts, 'player' => $player, 'bet' => get_setting('bet')]); }
/** * Action to request the Dim Mak form AND execute the purchase * * @todo split form request (GET) and purchase (POST) into separate funcs * @return ViewSpec */ public function buyDimMak() { if (is_logged_in()) { $player = new Player(self_char_id()); $showMonks = false; $parts = []; RequestWrapper::init(); if (RequestWrapper::$request && RequestWrapper::$request->isMethod('POST')) { $error = $this->dimMakReqs($player, self::DIM_MAK_COST); if (!$error) { $player->changeTurns(-1 * self::DIM_MAK_COST); add_item($player->id(), 'dimmak', 1); $parts['pageParts'] = ['success-dim-mak']; $showMonks = true; } else { $parts['error'] = $error; } } else { $parts['pageParts'] = ['form-dim-mak']; $parts['dim_mak_cost'] = self::DIM_MAK_COST; } return $this->render($parts, $player, $showMonks); } else { return $this->accessDenied(); } }
/** * User command for betting on the coin toss game in the casino * * @param bet int The amount of money to bet on the coin toss game * @return Array * * @note * If the player bets within ~1% of the maximum bet, they will receive a * reward item */ public function bet() { $player = Player::find(self_char_id()); $bet = intval(in('bet')); $pageParts = ['reminder-max-bet']; if ($bet < 0) { $pageParts = ['result-cheat']; $player->harm(self::CHEAT_DMG); } else { if ($bet > $player->gold) { $pageParts = ['result-no-gold']; } else { if ($bet > 0 && $bet <= self::MAX_BET) { if (rand(0, 1) === 1) { $pageParts = ['result-win']; $player->set_gold($player->gold + $bet); if ($bet >= round(self::MAX_BET * 0.99)) { // within about 1% of the max bet & you win, you get a reward item. add_item($player->id(), self::REWARD, 1); } } else { $player->set_gold($player->gold - $bet); $pageParts = ['result-lose']; } } } } $player->save(); return $this->render(['pageParts' => $pageParts, 'player' => $player]); }
function add_to_basket($tab) { if (isset($_SESSION) && isset($_SESSION['logged_on_user'])) { $_SESSION['basket'][] = add_item($tab); // utiliser count pour le nombre d'article. } else { echo "<p>Vous devez etre loggé.</p>"; } }
function setUp() { $this->controller = new InventoryController(); $this->char = TestAccountCreateAndDestroy::char(); $request = new Request([], []); RequestWrapper::inject($request); SessionFactory::init(new MockArraySessionStorage()); $sess = SessionFactory::getSession(); $sess->set('player_id', $this->char->id()); add_item($this->char->id(), self::ITEM); }
/** * Wrapper and actualiser to add an item. Does not return. * * @param MEMBER The member performing the action * @param string The name of the item * @param integer The cost the item * @param BINARY Whether the item is finite * @param BINARY Whether the item may be used for bribes * @param BINARY Whether the item may be used to provide a health boost * @param URLPATH The picture of the item * @param integer The maximum number of these items a player may have * @param BINARY Whether the item may be replicated via a new item copy source * @param string Description for the item */ function add_item_wrap($member_id, $name, $cost, $not_infinite, $bribable, $healthy, $picture_url, $max_per_player, $replicateable, $description) { if ($healthy != 1) { $healthy = 0; } if ($bribable != 1) { $bribable = 0; } if ($not_infinite != 1) { $not_infinite = 0; } if (!($cost > 0)) { $cost = 0; } if (!($max_per_player > 0)) { $max_per_player = 0; } if ($replicateable != 1) { $replicateable = 0; } if ($name == '') { ocw_refresh_with_message(do_lang_tempcode('W_MISSING_NAME'), 'warn'); } // Get $realm,$x,$y from $member_id list($realm, $x, $y) = get_loc_details($member_id); if (!has_specific_permission($member_id, 'administer_ocworld') && $GLOBALS['SITE_DB']->query_value('w_realms', 'owner', array('id' => $realm)) != $member_id && $GLOBALS['SITE_DB']->query_value('w_realms', 'r_private', array('id' => $realm)) == 1) { ocw_refresh_with_message(do_lang_tempcode('W_NO_EDIT_ACCESS_PRIVATE_REALM'), 'warn'); } // Make sure the item does not already exist! (people aren't allowed to arbitarily duplicate items for security reasons) $r = $GLOBALS['SITE_DB']->query_value_null_ok('w_itemdef', 'bribable', array('name' => $name)); if (!is_null($r)) { ocw_refresh_with_message(do_lang_tempcode('W_DUPE_ITEM'), 'warn'); } // Make sure that they aren't in the brig and adding a bribable! if ($x == 0 && $y == 2 && $bribable == 1) { ocw_refresh_with_message(do_lang_tempcode('ACCESS_DENIED__I_ERROR', $GLOBALS['FORUM_DRIVER']->get_username(get_member())), 'warn'); } // Charge them if (!has_specific_permission($member_id, 'administer_ocworld')) { $price = get_price('mud_item'); if (available_points($member_id) < $price) { ocw_refresh_with_message(do_lang_tempcode('W_EXPENSIVE', escape_html($price)), 'warn'); } require_code('points2'); charge_member($member_id, $price, do_lang('W_MADE_OCWORLD', $name)); } add_item($name, $bribable, $healthy, $picture_url, $member_id, $max_per_player, $replicateable, $description); add_item_to_room($realm, $x, $y, $name, $not_infinite, $cost, $member_id); ocw_refresh_with_message(do_lang_tempcode('W_MADE_ITEM_AT', escape_html($name))); }
/** * Command for current user to purchase a quantity of a specific item * * @param quantity int The quantity of the item to purchase * @param item string The identity of the item to purchase * @return Array */ public function buy() { $in_quantity = in('quantity'); $in_item = in('item'); $gold = get_gold($this->sessionData['char_id']); $current_item_cost = 0; $no_funny_business = false; // Pull the item info from the database $item_costs = $this->itemForSaleCosts(); $item = getItemByID(item_id_from_display_name($in_item)); $quantity = whichever(positive_int($in_quantity), 1); $item_text = null; if ($item instanceof Item) { $item_text = $quantity > 1 ? $item->getPluralName() : $item->getName(); $purchaseOrder = new PurchaseOrder(); // Determine the quantity from input or as a fallback, default of 1. $purchaseOrder->quantity = $quantity; $purchaseOrder->item = $item; $potential_cost = isset($item_costs[$purchaseOrder->item->identity()]['item_cost']) ? $item_costs[$purchaseOrder->item->identity()]['item_cost'] : null; $current_item_cost = first_value($potential_cost, 0); $current_item_cost = $current_item_cost * $purchaseOrder->quantity; if (!$this->sessionData['char_id'] || !$purchaseOrder->item || $purchaseOrder->quantity < 1) { $no_funny_business = true; } else { if ($gold >= $current_item_cost) { // Has enough gold. try { add_item($this->sessionData['char_id'], $purchaseOrder->item->identity(), $purchaseOrder->quantity); subtract_gold($this->sessionData['char_id'], $current_item_cost); } catch (\Exception $e) { $invalid_item = $e->getMessage(); error_log('Invalid Item attempted :' . $invalid_item); $no_funny_business = true; } } } } else { $no_funny_business = true; } $parts = array('current_item_cost' => $current_item_cost, 'quantity' => $quantity, 'item_text' => $item_text, 'no_funny_business' => $no_funny_business, 'view_part' => 'buy'); return $this->render($parts); }
/** * Add item * * {@source} * @access public * @static * @since 1.8 * @version 1 * * Input array $items has following structure and default values : * <code> * array( array( * *'description' => *, * *'key_' => *, * *'hostid' => *, * 'delay' => 60, * 'history' => 7, * 'status' => ITEM_STATUS_ACTIVE, * 'type' => ITEM_TYPE_ZABBIX, * 'snmp_community' => '', * 'snmp_oid' => '', * 'value_type' => ITEM_VALUE_TYPE_STR, * 'data_type' => ITEM_DATA_TYPE_DECIMAL, * 'trapper_hosts' => 'localhost', * 'snmp_port' => 161, * 'units' => '', * 'multiplier' => 0, * 'delta' => 0, * 'snmpv3_securityname' => '', * 'snmpv3_securitylevel' => 0, * 'snmpv3_authpassphrase' => '', * 'snmpv3_privpassphrase' => '', * 'formula' => 0, * 'trends' => 365, * 'logtimefmt' => '', * 'valuemapid' => 0, * 'delay_flex' => '', * 'params' => '', * 'ipmi_sensor' => '', * 'applications' => array(), * 'templateid' => 0 * ), ...); * </code> * * @static * @param array $items multidimensional array with items data * @return array|boolean */ public static function add($items) { $itemids = array(); DBstart(false); $result = false; foreach ($items as $item) { $result = add_item($item); if (!$result) { break; } $itemids['result'] = $result; } $result = DBend($result); if ($result) { return $itemids; } else { self::$error = array('error' => ZBX_API_ERROR_INTERNAL, 'data' => 'Internal zabbix error'); return false; } }
if ($s = $i->prepare("UPDATE ITEMS SET ARCHIVED = 1 WHERE ID = ? AND OWNER = ?")) { foreach ($ids as $i) { $s->bind_param('is', $i, $_SESSION['user-id']); if (!$s->execute()) { $errors[] = $i->error; } } $s->close(); if (count($errors)) { error_log("Encountered errors while archiving items: " . print_r($errors, true)); } } else { error_log("There was an error while preparing the item archive statement: {$i->error}"); } json_error("There was actually no error..."); } $action = array_get($_POST, "a", "dump"); switch ($action) { case 'dump': echo get_items($i); break; case 'add': echo add_item($i, $_POST['title'], $_POST['parent']); break; case 'save': echo save_items($i, $_POST['items']); break; case 'archive': echo archive_items($i, $_POST['ids']); break; }
// Include cart functions require_once 'cart.php'; // Get the action to perform $action = filter_input(INPUT_POST, 'action'); if ($action === NULL) { $action = filter_input(INPUT_GET, 'action'); if ($action === NULL) { $action = 'show_add_item'; } } // Add or update cart as needed switch ($action) { case 'add': $product_key = filter_input(INPUT_POST, 'productkey'); $item_qty = filter_input(INPUT_POST, 'itemqty'); add_item($product_key, $item_qty); include 'cart_view.php'; break; case 'update': $new_qty_list = filter_input(INPUT_POST, 'newqty', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY); foreach ($new_qty_list as $key => $qty) { if ($_SESSION['cart12'][$key]['qty'] != $qty) { update_item($key, $qty); } } include 'cart_view.php'; break; case 'show_cart': include 'cart_view.php'; break; case 'show_add_item':
} } // modify item if (isset($_POST["mod"])) { if (mod_item($this_table, $_POST["id"], $_POST["mod"])) { header("Location:index.php?page=" . ADMIN_PAGE . "&id_modified=" . $_POST["id"] . "&msg=mod_OK"); } else { $warning = $lang["msg_mod_KO"]; } } // add new item if (isset($_POST["add"])) { // define next list order $_POST["add"]["list_order"] = get_next_order($this_table); $_POST["add"]["id_user"] = $_SESSION["admin_id"]; if (add_item($this_table, $_POST["add"], false)) { header("Location:index.php?page=" . ADMIN_PAGE . "&id_added=" . mysql_insert_id() . "&msg=add_OK"); } else { $warning = $lang["msg_add_KO"]; } } if (isset($_REQUEST["action"])) { $xtra_moo .= ' new FormCheck("item_form"); '; switch ($_REQUEST["action"]) { case "new": $page_title_add = ' - ' . $lang["title_add"]; $contents .= ' <form method="post" id="item_form"> <table>
// | This program is distributed in the hope that it will be useful, | // | but WITHOUT ANY WARRANTY; without even the implied warranty of | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | // | GNU General Public License for more details. | // | | // | You should have received a copy of the GNU General Public License | // | along with this program; if not, write to the Free Software Foundation, | // | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | // | | // +--------------------------------------------------------------------------+ require_once $_CONF['path_html'] . "/fckeditor/fckeditor.php"; if (isset($_POST['update_item'])) { $error = update_item(basename($_FILES['picture_small']['name']), basename($_FILES['picture_large']['name'])); } else { if (isset($_POST['add_item'])) { $error = add_item(basename($_FILES['picture_small']['name']), basename($_FILES['picture_large']['name'])); } else { if (isset($_POST['add_catagory'])) { $error = add_catagory(); } else { if (isset($_GET['delete_cat'])) { $error = delete_catagory(); } else { $error = ""; } } } } $T = new Template($_CONF['path'] . 'plugins/ecommerce/templates/admin'); $T->set_file('text', 'item.thtml'); //Catagories
// Include cart functions require_once 'cart.php'; // Get the action to perform if (isset($_POST['action'])) { $action = $_POST['action']; } else { if (isset($_GET['action'])) { $action = $_GET['action']; } else { $action = 'show_add_item'; } } // Add or update cart as needed switch ($action) { case 'add': add_item($_POST['productkey'], $_POST['itemqty']); include 'cart_view.php'; break; case 'update': $new_qty_list = $_POST['newqty']; foreach ($new_qty_list as $key => $qty) { if ($_SESSION['cart13'][$key]['qty'] != $qty) { update_item($key, $qty); } } include 'cart_view.php'; break; case 'show_cart': include 'cart_view.php'; break; case 'show_add_item':
* Created on Nov 8, 2005 * * To change the template for this generated file go to * Window - Preferences - PHPeclipse - PHP - Code Templates */ function add_item($catalog, $itemId, $desc, $price, $quantity, $warehouseId) { $item = $catalog->createDataObject('item'); $item->itemId = $itemId; $item->description = $desc; $item->price = $price; $item->quantity = $quantity; $item->warehouseId = $warehouseId; } $xmldas = SDO_DAS_XML::create('Catalog.xsd'); $catalog = $xmldas->createDataObject('catalogNS', 'CatalogType'); add_item($catalog, 1, 'A Partridge in a Pear Tree', 1.99, 0, 1); add_item($catalog, 2, 'Turtle Doves', 2.99, 0, 1); add_item($catalog, 3, 'French Hens', 3.99, 0, 1); add_item($catalog, 4, 'Calling Birds', 4.99, 0, 1); add_item($catalog, 5, 'Golden Rings', 5.99, 0, 1); add_item($catalog, 6, 'Geese a-laying', 6.99, 0, 1); add_item($catalog, 7, 'Swans a-swimming', 7.99, 0, 1); add_item($catalog, 8, 'Maids a-milking', 8.99, 0, 1); add_item($catalog, 9, 'Ladies dancing', 9.99, 0, 1); add_item($catalog, 10, 'Lords a-leaping', 10.99, 0, 1); add_item($catalog, 11, 'Pipers piping', 11.99, 0, 1); add_item($catalog, 12, 'Drummers drumming', 12.99, 0, 1); $doc = $xmldas->createDocument('catalogNS', 'catalog', $catalog); // echo htmlspecialchars($xmldas->saveString($doc)); $xmldas->saveFile($doc, 'Catalog.xml', 4);
/** * Add an item using the old display name */ private function addItem($who, $item, $quantity = 1) { $item_identity = $this->itemIdentityFromDisplayName($item); if ((int) $quantity > 0 && !empty($item) && $item_identity) { add_item(get_char_id($who), $item_identity, $quantity); } else { throw new \Exception('Improper deprecated item addition request made.'); } }
if (file_exists($filename)) { unlink($filename); } } if (!$new_item) { /*so its an existing one */ update_item($_POST['NewStockID'], $_POST['description'], $_POST['long_description'], $_POST['category_id'], $_POST['level_id'], $_POST['tax_type_id'], get_post('units'), get_post('mb_flag'), $_POST['sales_account'], $_POST['inventory_account'], $_POST['cogs_account'], $_POST['adjustment_account'], $_POST['assembly_account'], $_POST['dimension_id'], $_POST['dimension2_id'], check_value('no_sale'), check_value('editable')); update_record_status($_POST['NewStockID'], $_POST['inactive'], 'stock_master', 'stock_id'); update_record_status($_POST['NewStockID'], $_POST['inactive'], 'item_codes', 'item_code'); set_focus('stock_id'); $Ajax->activate('stock_id'); // in case of status change display_notification(_("Item has been updated.")); } else { //it is a NEW part add_item($_POST['NewStockID'], $_POST['description'], $_POST['long_description'], $_POST['level_id'], $_POST['category_id'], $_POST['tax_type_id'], $_POST['units'], $_POST['mb_flag'], $_POST['sales_account'], $_POST['inventory_account'], $_POST['cogs_account'], $_POST['adjustment_account'], $_POST['assembly_account'], $_POST['dimension_id'], $_POST['dimension2_id'], check_value('no_sale'), check_value('editable')); display_notification(_("A new item has been added.")); $_POST['stock_id'] = $_POST['NewStockID'] = $_POST['description'] = $_POST['long_description'] = ''; $_POST['no_sale'] = $_POST['editable'] = 0; set_focus('NewStockID'); } $Ajax->activate('_page_body'); } } if (get_post('clone')) { unset($_POST['stock_id']); $stock_id = ''; unset($_POST['inactive']); set_focus('NewStockID'); $Ajax->activate('_page_body'); }
function EndElement($parser, $name) { if (!$this->root) { return false; } global $USER_DETAILS; $data =& $this->data[$name]; switch ($name) { case XML_TAG_HOST: if ($data['skip'] || !isset($data['hostid']) || !$data['hostid']) { break; } // case if (!isset($data['port'])) { $data['port'] = 10050; } if (!isset($data['status'])) { $data['status'] = 0; } if (!isset($data['useip'])) { $data['useip'] = 0; } if (!isset($data['dns'])) { $data['dns'] = ''; } if (!isset($data['ip'])) { $data['ip'] = ''; } if (!isset($data['proxy'])) { $data['proxy'] = ''; } if (!zbx_empty($data['proxy'])) { $sql = 'SELECT hostid ' . ' FROM hosts ' . ' WHERE host=' . zbx_dbstr($data['proxy']) . ' AND status=' . HOST_STATUS_PROXY . ' AND ' . DBin_node('hostid', get_current_nodeid(false)); if ($host_data = DBfetch(DBselect($sql))) { $data['proxy'] = $host_data['hostid']; } else { $data['proxy'] = 0; } } else { $data['proxy'] = 0; } if (update_host($data['hostid'], $data['name'], $data['port'], $data['status'], $data['useip'], $data['dns'], $data['ip'], $data['proxy'], $data['templates'], 'no', '', 623, -1, 2, '', '', null, $data['groups'])) { info('Host [' . $data['name'] . '] updated'); } break; // case // based on mod by scricca // case // based on mod by scricca case XML_TAG_HOSTPROFILE: if (!isset($this->data[XML_TAG_HOST]['hostid']) || !$this->data[XML_TAG_HOST]['hostid']) { break; } //case if (!isset($data['devicetype'])) { $data['devicetype'] = ''; } if (!isset($data['name'])) { $data['name'] = ''; } if (!isset($data['os'])) { $data['os'] = ''; } if (!isset($data['serialno'])) { $data['serialno'] = ''; } if (!isset($data['tag'])) { $data['tag'] = ''; } if (!isset($data['macaddress'])) { $data['macaddress'] = ''; } if (!isset($data['hardware'])) { $data['hardware'] = ''; } if (!isset($data['software'])) { $data['software'] = ''; } if (!isset($data['contact'])) { $data['contact'] = ''; } if (!isset($data['location'])) { $data['location'] = ''; } if (!isset($data['notes'])) { $data['notes'] = ''; } delete_host_profile($this->data[XML_TAG_HOST]['hostid']); if (add_host_profile($this->data[XML_TAG_HOST]['hostid'], $data['devicetype'], $data['name'], $data['os'], $data['serialno'], $data['tag'], $data['macaddress'], $data['hardware'], $data['software'], $data['contact'], $data['location'], $data['notes'])) { info('Host Profile [' . $this->data[XML_TAG_HOST]['name'] . '] updated'); } break; // case //--- // Extended profiles // case //--- // Extended profiles case XML_TAG_HOSTPROFILE_EXT: if (!isset($this->data[XML_TAG_HOST]['hostid']) || !$this->data[XML_TAG_HOST]['hostid']) { break; } //case if (!isset($data['device_alias'])) { $data['device_alias'] = ''; } if (!isset($data['device_type'])) { $data['device_type'] = ''; } if (!isset($data['device_chassis'])) { $data['device_chassis'] = ''; } if (!isset($data['device_os'])) { $data['device_os'] = ''; } if (!isset($data['device_os_short'])) { $data['device_os_short'] = ''; } if (!isset($data['device_hw_arch'])) { $data['device_hw_arch'] = ''; } if (!isset($data['device_serial'])) { $data['device_serial'] = ''; } if (!isset($data['device_model'])) { $data['device_model'] = ''; } if (!isset($data['device_tag'])) { $data['device_tag'] = ''; } if (!isset($data['device_vendor'])) { $data['device_vendor'] = ''; } if (!isset($data['device_contract'])) { $data['device_contract'] = ''; } if (!isset($data['device_who'])) { $data['device_who'] = ''; } if (!isset($data['device_status'])) { $data['device_status'] = ''; } if (!isset($data['device_app_01'])) { $data['device_app_01'] = ''; } if (!isset($data['device_app_02'])) { $data['device_app_02'] = ''; } if (!isset($data['device_app_03'])) { $data['device_app_03'] = ''; } if (!isset($data['device_app_04'])) { $data['device_app_04'] = ''; } if (!isset($data['device_app_05'])) { $data['device_app_05'] = ''; } if (!isset($data['device_url_1'])) { $data['device_url_1'] = ''; } if (!isset($data['device_url_2'])) { $data['device_url_2'] = ''; } if (!isset($data['device_url_3'])) { $data['device_url_3'] = ''; } if (!isset($data['device_networks'])) { $data['device_networks'] = ''; } if (!isset($data['device_notes'])) { $data['device_notes'] = ''; } if (!isset($data['device_hardware'])) { $data['device_hardware'] = ''; } if (!isset($data['device_software'])) { $data['device_software'] = ''; } if (!isset($data['ip_subnet_mask'])) { $data['ip_subnet_mask'] = ''; } if (!isset($data['ip_router'])) { $data['ip_router'] = ''; } if (!isset($data['ip_macaddress'])) { $data['ip_macaddress'] = ''; } if (!isset($data['oob_ip'])) { $data['oob_ip'] = ''; } if (!isset($data['oob_subnet_mask'])) { $data['oob_subnet_mask'] = ''; } if (!isset($data['oob_router'])) { $data['oob_router'] = ''; } if (!isset($data['date_hw_buy'])) { $data['date_hw_buy'] = ''; } if (!isset($data['date_hw_install'])) { $data['date_hw_install'] = ''; } if (!isset($data['date_hw_expiry'])) { $data['date_hw_expiry'] = ''; } if (!isset($data['date_hw_decomm'])) { $data['date_hw_decomm'] = ''; } if (!isset($data['site_street_1'])) { $data['site_street_1'] = ''; } if (!isset($data['site_street_2'])) { $data['site_street_2'] = ''; } if (!isset($data['site_street_3'])) { $data['site_street_3'] = ''; } if (!isset($data['site_city'])) { $data['site_city'] = ''; } if (!isset($data['site_state'])) { $data['site_state'] = ''; } if (!isset($data['site_country'])) { $data['site_country'] = ''; } if (!isset($data['site_zip'])) { $data['site_zip'] = ''; } if (!isset($data['site_rack'])) { $data['site_rack'] = ''; } if (!isset($data['site_notes'])) { $data['site_notes'] = ''; } if (!isset($data['poc_1_name'])) { $data['poc_1_name'] = ''; } if (!isset($data['poc_1_email'])) { $data['poc_1_email'] = ''; } if (!isset($data['poc_1_phone_1'])) { $data['poc_1_phone_1'] = ''; } if (!isset($data['poc_1_phone_2'])) { $data['poc_1_phone_2'] = ''; } if (!isset($data['poc_1_cell'])) { $data['poc_1_cell'] = ''; } if (!isset($data['poc_1_screen'])) { $data['poc_1_screen'] = ''; } if (!isset($data['poc_1_notes'])) { $data['poc_1_notes'] = ''; } if (!isset($data['poc_2_name'])) { $data['poc_2_name'] = ''; } if (!isset($data['poc_2_email'])) { $data['poc_2_email'] = ''; } if (!isset($data['poc_2_phone_1'])) { $data['poc_2_phone_1'] = ''; } if (!isset($data['poc_2_phone_2'])) { $data['poc_2_phone_2'] = ''; } if (!isset($data['poc_2_cell'])) { $data['poc_2_cell'] = ''; } if (!isset($data['poc_2_screen'])) { $data['poc_2_screen'] = ''; } if (!isset($data['poc_2_notes'])) { $data['poc_2_notes'] = ''; } delete_host_profile_ext($this->data[XML_TAG_HOST]['hostid']); if (add_host_profile_ext($this->data[XML_TAG_HOST]['hostid'], $data)) { info('Host Extended Profile [' . $this->data[XML_TAG_HOST]['name'] . '] updated'); } break; // case //--- // case //--- case XML_TAG_GROUP: if (!isset($this->data[XML_TAG_HOST]['hostid']) || !$this->data[XML_TAG_HOST]['hostid']) { break; } //case $sql = 'SELECT groupid, name ' . ' FROM groups' . ' WHERE ' . DBin_node('groupid', get_current_nodeid(false)) . ' AND name=' . zbx_dbstr($this->element_data); if (!($group = DBfetch(DBselect($sql)))) { error('Missing group [' . $this->element_data . ']'); break; // case } if (!isset($this->available_groups[$group['groupid']])) { error('Group [' . $this->element_data . '] skipped - Access deny.'); break; // case } $this->data[XML_TAG_HOST]['groups'][$group['groupid']] = $group['groupid']; break; // case // case case XML_TAG_DEPENDENCY: if (!isset($data['triggerid_down']) || !$data['triggerid_down']) { break; } // case update_trigger($data['triggerid_down'], null, null, null, null, null, null, null, $data['triggerid_up'], null); break; // case // case case XML_TAG_DEPENDS: if (!isset($this->data[XML_TAG_DEPENDENCY]['triggerid_down']) || !$this->data[XML_TAG_DEPENDENCY]['triggerid_down']) { break; } //case if (!($trigger_up = get_trigger_by_description($this->element_data))) { break; } array_push($this->data[XML_TAG_DEPENDENCY]['triggerid_up'], $trigger_up['triggerid']); break; // case // case case XML_TAG_APPLICATION: if (!isset($this->data[XML_TAG_HOST]['hostid']) || !$this->data[XML_TAG_HOST]['hostid']) { break; } //case if (!isset($this->data[XML_TAG_ITEM])) { break; } //case $sql = 'SELECT applicationid ' . ' FROM applications' . ' WHERE ' . DBin_node('applicationid', get_current_nodeid(false)) . ' AND name=' . zbx_dbstr($this->element_data) . ' AND hostid=' . $this->data[XML_TAG_HOST]['hostid']; if (!($application = DBfetch(DBselect($sql)))) { $applicationid = add_application($this->element_data, $this->data[XML_TAG_HOST]['hostid']); } else { $applicationid = $application['applicationid']; } $this->data[XML_TAG_ITEM]['applications'][] = $applicationid; break; // case // case case XML_TAG_TEMPLATE: if (!isset($this->data[XML_TAG_HOST]['hostid']) || !$this->data[XML_TAG_HOST]['hostid']) { break; } //case $sql = 'SELECT DISTINCT host, hostid ' . ' FROM hosts' . ' WHERE ' . DBin_node('hostid') . ' AND host=' . zbx_dbstr($this->element_data) . ' AND status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ',' . HOST_STATUS_TEMPLATE . ')'; if (!($template = DBfetch(DBselect($sql)))) { error('Missing template [' . $this->element_data . ']'); break; // case } if (!isset($this->available_hosts[$template['hostid']])) { error('Template [' . $this->element_data . '] skipped - Access deny.'); break; // case } $this->data[XML_TAG_HOST]['templates'][$template["hostid"]] = $template['host']; break; // case // case case XML_TAG_ITEM: if (!isset($this->data[XML_TAG_HOST]['hostid']) || !$this->data[XML_TAG_HOST]['hostid']) { if (isset($this->data[XML_TAG_HOST]['skip']) && $this->data[XML_TAG_HOST]['skip']) { info('Item [' . $data['description'] . '] skipped - user rule for host'); break; // case } error('Item [' . $data['description'] . '] skipped - missing host'); break; // case } if (!isset($data['description'])) { $data['description'] = ''; } if (!isset($data['delay'])) { $data['delay'] = 30; } if (!isset($data['history'])) { $data['history'] = 90; } if (!isset($data['trends'])) { $data['trends'] = 365; } if (!isset($data['status'])) { $data['status'] = 0; } if (!isset($data['units'])) { $data['units'] = ''; } if (!isset($data['multiplier'])) { $data['multiplier'] = 0; } if (!isset($data['delta'])) { $data['delta'] = 0; } if (!isset($data['formula'])) { $data['formula'] = ''; } if (!isset($data['lastlogsize'])) { $data['lastlogsize'] = 0; } if (!isset($data['logtimefmt'])) { $data['logtimefmt'] = ''; } if (!isset($data['delay_flex'])) { $data['delay_flex'] = ''; } if (!isset($data['trapper_hosts'])) { $data['trapper_hosts'] = ''; } if (!isset($data['snmp_community'])) { $data['snmp_community'] = ''; } if (!isset($data['snmp_oid'])) { $data['snmp_oid'] = ''; } if (!isset($data['snmp_port'])) { $data['snmp_port'] = 161; } if (!isset($data['snmpv3_securityname'])) { $data['snmpv3_securityname'] = ''; } if (!isset($data['snmpv3_securitylevel'])) { $data['snmpv3_securitylevel'] = 0; } if (!isset($data['snmpv3_authpassphrase'])) { $data['snmpv3_authpassphrase'] = ''; } if (!isset($data['snmpv3_privpassphrase'])) { $data['snmpv3_privpassphrase'] = ''; } if (!isset($data['valuemap'])) { $data['valuemap'] = ''; } if (!isset($data['params'])) { $data['params'] = ''; } if (!isset($data['ipmi_sensor'])) { $data['ipmi_sensor'] = ''; } if (!isset($data['applications'])) { $data['applications'] = array(); } if (!empty($data['valuemap'])) { $sql = 'SELECT valuemapid ' . ' FROM valuemaps ' . ' WHERE ' . DBin_node('valuemapid', get_current_nodeid(false)) . ' AND name=' . zbx_dbstr($data['valuemap']); if ($valuemap = DBfetch(DBselect($sql))) { $data['valuemapid'] = $valuemap['valuemapid']; } else { $data['valuemapid'] = add_valuemap($data['valuemap'], array()); } } $sql = 'SELECT itemid,valuemapid,templateid ' . ' FROM items ' . ' WHERE key_=' . zbx_dbstr($data['key']) . ' AND hostid=' . $this->data[XML_TAG_HOST]['hostid'] . ' AND ' . DBin_node('itemid', get_current_nodeid(false)); if ($item = DBfetch(DBselect($sql))) { /* exist */ if ($this->item['exist'] == 1) { info('Item [' . $data['description'] . '] skipped - user rule'); break; } if (!isset($data['valuemapid'])) { $data['valuemapid'] = $item['valuemapid']; } $data['key_'] = $data['key']; $data['hostid'] = $this->data[XML_TAG_HOST]['hostid']; $data['applications'] = array_unique(array_merge($data['applications'], get_applications_by_itemid($item['itemid']))); $data['templateid'] = $item['templateid']; check_db_fields($item, $data); update_item($item['itemid'], $data); } else { /* missed */ if ($this->item['missed'] == 1) { info('Item [' . $data['description'] . '] skipped - user rule'); break; // case } if (!isset($data['valuemapid'])) { $data['valuemapid'] = 0; } $data['hostid'] = $this->data[XML_TAG_HOST]['hostid']; $data['key_'] = $data['key']; add_item($data); } break; // case // case case XML_TAG_TRIGGER: if (!isset($data['expression'])) { $data['expression'] = ''; } if (!isset($data['description'])) { $data['description'] = ''; } if (!isset($data['type'])) { $data['type'] = 0; } if (!isset($data['priority'])) { $data['priority'] = 0; } if (!isset($data['status'])) { $data['status'] = 0; } if (!isset($data['comments'])) { $data['comments'] = ''; } if (!isset($data['url'])) { $data['url'] = ''; } if (!isset($this->data[XML_TAG_HOST]['hostid']) || !$this->data[XML_TAG_HOST]['hostid']) { if (isset($this->data[XML_TAG_HOST]['skip']) && $this->data[XML_TAG_HOST]['skip']) { // remember skipped triggers for dependencies $this->data[XML_TAG_DEPENDENCIES]['skip'][] = $this->data[XML_TAG_HOST]['name'] . ':' . $data['description']; info('Trigger [' . $data['description'] . '] skipped - user rule for host'); break; // case } if (zbx_strstr($data['expression'], '{HOSTNAME}')) { // remember skipped triggers for dependencies $this->data[XML_TAG_DEPENDENCIES]['skip'][] = $this->data[XML_TAG_HOST]['name'] . ':' . $data['description']; error('Trigger [' . $data['description'] . '] skipped - missing host'); break; // case } } else { $data['expression'] = str_replace('{{HOSTNAME}:', '{' . $this->data[XML_TAG_HOST]['name'] . ':', $data['expression']); $result = DBselect('SELECT DISTINCT t.triggerid,t.templateid,t.expression ' . ' FROM triggers t,functions f,items i ' . ' WHERE t.triggerid=f.triggerid ' . ' AND f.itemid=i.itemid' . ' AND i.hostid=' . $this->data[XML_TAG_HOST]['hostid'] . ' AND t.description=' . zbx_dbstr($data['description'])); while ($trigger = DBfetch($result)) { if (explode_exp($trigger['expression'], 0) == $data['expression']) { break; // while } } if (!empty($trigger)) { /* exist */ if ($this->trigger['exist'] == 1) { /* skip */ // remember skipped triggers for dependencies $this->data[XML_TAG_DEPENDENCIES]['skip'][] = $this->data[XML_TAG_HOST]['name'] . ':' . $data['description']; info('Trigger [' . $data['description'] . '] skipped - user rule'); break; // case } update_trigger($trigger['triggerid'], $data['expression'], $data['description'], $data['type'], $data['priority'], $data['status'], $data['comments'], $data['url'], get_trigger_dependencies_by_triggerid($trigger['triggerid']), $trigger['templateid']); break; // case } else { /* missed */ // continue [add_trigger] } } if ($this->trigger['missed'] == 1) { // remember skipped triggers for dependencies $this->data[XML_TAG_DEPENDENCIES]['skip'][] = $this->data[XML_TAG_HOST]['name'] . ':' . $data['description']; info('Trigger [' . $data['description'] . '] skipped - user rule'); break; // case } add_trigger($data['expression'], $data['description'], $data['type'], $data['priority'], $data['status'], $data['comments'], $data['url']); break; // case // case case XML_TAG_GRAPH: if (isset($data['error'])) { error('Graph [' . $data['name'] . '] skipped - error occured'); break; // case } if (!isset($data['ymin_type'])) { $data['ymin_type'] = 0; } if (!isset($data['ymax_type'])) { $data['ymax_type'] = 0; } if (!isset($data['ymin_item_key'])) { $data['ymin_item_key'] = ''; } if (!isset($data['ymax_item_key'])) { $data['ymax_item_key'] = ''; } if (!isset($data['ymin_itemid'])) { $data['ymin_itemid'] = 0; } if (!isset($data['ymax_itemid'])) { $data['ymax_itemid'] = 0; } if (!isset($data['show_work_period'])) { $data['show_work_period'] = 1; } if (!isset($data['show_triggers'])) { $data['show_triggers'] = 1; } if (!isset($data['graphtype'])) { $data['graphtype'] = 0; } if (!isset($data['yaxismin'])) { $data['yaxismin'] = 0; } if (!isset($data['yaxismax'])) { $data['yaxismax'] = 0; } if (!isset($data['show_legend'])) { $data['show_legend'] = 0; } if (!isset($data['show_3d'])) { $data['show_3d'] = 0; } if (!isset($data['percent_left'])) { $data['percent_left'] = 0; } if (!isset($data['percent_right'])) { $data['percent_right'] = 0; } if (!isset($data['items'])) { $data['items'] = array(); } if (!empty($data['ymin_item_key'])) { $data['ymin_item_key'] = explode(':', $data['ymin_item_key']); if (count($data['ymin_item_key']) < 2) { $this->data[XML_TAG_GRAPH]['error'] = true; error('Incorrect y min item for graph [' . $data['name'] . ']'); break; // case } $data['host'] = array_shift($data['ymin_item_key']); $data['ymin_item_key'] = implode(':', $data['ymin_item_key']); if (!($item = get_item_by_key($data['ymin_item_key'], $data['host']))) { $this->data[XML_TAG_GRAPH]['error'] = true; error('Missed item [' . $data['ymin_item_key'] . '] for host [' . $data['host'] . ']'); break; // case } $data['ymin_itemid'] = $item['itemid']; } if (!empty($data['ymax_item_key'])) { $data['ymax_item_key'] = explode(':', $data['ymax_item_key']); if (count($data['ymax_item_key']) < 2) { $this->data[XML_TAG_GRAPH]['error'] = true; error('Incorrect y max item for graph [' . $data['name'] . ']'); break; // case } $data['host'] = array_shift($data['ymax_item_key']); $data['ymax_item_key'] = implode(':', $data['ymax_item_key']); if (!($item = get_item_by_key($data['ymax_item_key'], $data['host']))) { $this->data[XML_TAG_GRAPH]['error'] = true; error('Missed item [' . $data['ymax_item_key'] . '] for host [' . $data['host'] . ']'); break; // case } $data['ymax_itemid'] = $item['itemid']; } if (!isset($this->data[XML_TAG_HOST]['hostid']) || !$this->data[XML_TAG_HOST]['hostid']) { if (isset($this->data[XML_TAG_HOST]['skip']) && $this->data[XML_TAG_HOST]['skip']) { info('Graph [' . $data['name'] . '] skipped - user rule for host'); break; // case } foreach ($data['items'] as $id) { if (zbx_strstr($data['name'], '{HOSTNAME}')) { error('Graph [' . $data['name'] . '] skipped - missing host'); break; // case } } } else { if ($graph = DBfetch(DBselect('SELECT DISTINCT g.graphid, g.templateid' . ' FROM graphs g, graphs_items gi, items i' . ' WHERE g.graphid=gi.graphid ' . ' AND gi.itemid=i.itemid' . ' AND g.name=' . zbx_dbstr($data['name']) . ' AND i.hostid=' . $this->data[XML_TAG_HOST]['hostid']))) { /* exist */ if ($this->graph['exist'] == 1) { /* skip */ info('Graph [' . $data['name'] . '] skipped - user rule'); break; // case } $data['graphid'] = $graph['graphid']; update_graph_with_items($data['graphid'], $data['name'], $data['width'], $data['height'], $data['ymin_type'], $data['ymax_type'], $data['yaxismin'], $data['yaxismax'], $data['ymin_itemid'], $data['ymax_itemid'], $data['show_work_period'], $data['show_triggers'], $data['graphtype'], $data['show_legend'], $data['show_3d'], $data['percent_left'], $data['percent_right'], $data['items'], $graph['templateid']); } else { /* missed */ // continue [add_group] } } if (!isset($data['graphid'])) { if ($this->graph['missed'] == 1) { /* skip */ info('Graph [' . $data['name'] . '] skipped - user rule'); break; // case } $data['graphid'] = add_graph_with_items($data['name'], $data['width'], $data['height'], $data['ymin_type'], $data['ymax_type'], $data['yaxismin'], $data['yaxismax'], $data['ymin_itemid'], $data['ymax_itemid'], $data['show_work_period'], $data['show_triggers'], $data['graphtype'], $data['show_legend'], $data['show_3d'], $data['percent_left'], $data['percent_right'], $data['items']); } break; // case // case case XML_TAG_GRAPH_ELEMENT: if (!isset($this->data[XML_TAG_GRAPH])) { break; } // case $data['key'] = explode(':', $data['item']); if (count($data['key']) < 2) { $this->data[XML_TAG_GRAPH]['error'] = true; error('Incorrect element for graph [' . $data['name'] . ']'); break; // case } $data['host'] = array_shift($data['key']); $data['key'] = implode(':', $data['key']); if (isset($this->data[XML_TAG_HOST]['name'])) { $data['host'] = str_replace('{HOSTNAME}', $this->data[XML_TAG_HOST]['name'], $data['host']); } if (!isset($data['drawtype'])) { $data['drawtype'] = 0; } if (!isset($data['sortorder'])) { $data['sortorder'] = 0; } if (!isset($data['color'])) { $data['color'] = 'Dark Green'; } if (!isset($data['yaxisside'])) { $data['yaxisside'] = 1; } if (!isset($data['calc_fnc'])) { $data['calc_fnc'] = 2; } if (!isset($data['type'])) { $data['type'] = 0; } if (!isset($data['periods_cnt'])) { $data['periods_cnt'] = 5; } if (!($item = get_item_by_key($data['key'], $data['host']))) { $this->data[XML_TAG_GRAPH]['error'] = true; error('Missing item [' . $data['key'] . '] for host [' . $data['host'] . ']'); break; // case } $data['itemid'] = $item['itemid']; array_push($this->data[XML_TAG_GRAPH]['items'], $data); break; // case /*case XML_TAG_SCREEN: case XML_TAG_SCREEN_ELEMENT: break; // case*/ // case /*case XML_TAG_SCREEN: case XML_TAG_SCREEN_ELEMENT: break; // case*/ default: if (isset($this->sub_node) && isset($this->main_node)) { $main_node = array_pop($this->main_node); $this->data[$main_node][$this->sub_node] = $this->element_data; array_push($this->main_node, $main_node); } $this->sub_node = null; return; } unset($this->data[$name], $data); array_pop($this->main_node); }
// Include cart functions require_once 'cart.php'; // Get the action to perform $action = filter_input(INPUT_POST, 'action'); if ($action === NULL) { $action = filter_input(INPUT_GET, 'action'); if ($action === NULL) { $action = 'show_add_item'; } } // Add or update cart as needed switch ($action) { case 'add': $key = filter_input(INPUT_POST, 'productkey'); $quantity = filter_input(INPUT_POST, 'itemqty'); add_item($key, $quantity); include 'cart_view.php'; break; case 'update': $new_qty_list = filter_input(INPUT_POST, 'newqty', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY); foreach ($new_qty_list as $key => $qty) { if ($_SESSION['cart13'][$key]['qty'] != $qty) { update_item($key, $qty); } } include 'cart_view.php'; break; case 'show_cart': include 'cart_view.php'; break; case 'show_add_item':
if ($char_obj->strength() < $str_req) { $error = "You don't have enough strength to get a Dim Mak."; } return $error; } // Check that they can do one action or another. $max_level = maximum_level(); // For display in the template. $nextLevel = $userLevel + 1; $class_change_requirement_error = class_change_reqs($char, $class_change_cost); $dim_mak_requirement_error = dim_mak_reqs($char, $dim_mak_cost, $dim_mak_strength_requirement); // DIM MAK BUY if (!$dim_mak_requirement_error && $dimmak_sequence == 2) { // *** Start of Dim Mak Code, A dim mak didn't error and was requested. *** $char_turns = $char->changeTurns(-1 * $dim_mak_cost); add_item($char_id, 'dimmak', 1); } // *** End of Dim Mak Code. *** // Class Change Buy $class_change_error = null; if ($classChangeSequence == 2 && $current_class_untrusted == $userClass && $destination_class_identity) { // Class change requested, not a page refresh, and requested class is existant. if (!$class_change_requirement_error) { // Class change conditions are ok, so: // subtract the cost in turns // ...and change the class. $class_change_error = set_class($char_id, $destination_class_identity); if (!$class_change_error) { $char->changeTurns(-1 * $class_change_cost); } }
function db_save_httptest($httptestid, $hostid, $application, $name, $delay, $status, $agent, $macros, $steps) { $history = 30; // TODO !!! Allow user set this parametr $trends = 90; // TODO !!! Allow user set this parametr if (!eregi('^([0-9a-zA-Z\\_\\.[.-.]\\$ ]+)$', $name)) { error("Scenario name should contain '0-9a-zA-Z_.\$ '- characters only"); return false; } DBstart(); if ($applicationid = DBfetch(DBselect('select applicationid from applications ' . ' where name=' . zbx_dbstr($application) . ' and hostid=' . $hostid))) { $applicationid = $applicationid['applicationid']; } else { $applicationid = add_application($application, $hostid); if (!$applicationid) { error('Can\'t add new application. [' . $application . ']'); return false; } } if (isset($httptestid)) { $result = DBexecute('update httptest set ' . ' applicationid=' . $applicationid . ', name=' . zbx_dbstr($name) . ', delay=' . $delay . ',' . ' status=' . $status . ', agent=' . zbx_dbstr($agent) . ', macros=' . zbx_dbstr($macros) . ',' . ' error=' . zbx_dbstr('') . ', curstate=' . HTTPTEST_STATE_UNKNOWN . ' where httptestid=' . $httptestid); } else { $httptestid = get_dbid("httptest", "httptestid"); if (DBfetch(DBselect('select t.httptestid from httptest t, applications a where t.applicationid=a.applicationid ' . ' and a.hostid=' . $hostid . ' and t.name=' . zbx_dbstr($name)))) { error('Scenario with name [' . $name . '] already exist'); return false; } $result = DBexecute('insert into httptest' . ' (httptestid, applicationid, name, delay, status, agent, macros, curstate) ' . ' values (' . $httptestid . ',' . $applicationid . ',' . zbx_dbstr($name) . ',' . $delay . ',' . $status . ',' . zbx_dbstr($agent) . ',' . zbx_dbstr($macros) . ',' . HTTPTEST_STATE_UNKNOWN . ')'); $test_added = true; } if ($result) { $httpstepids = array(); foreach ($steps as $sid => $s) { if (!isset($s['name'])) { $s['name'] = ''; } if (!isset($s['timeout'])) { $s['timeout'] = 15; } if (!isset($s['url'])) { $s['url'] = ''; } if (!isset($s['posts'])) { $s['posts'] = ''; } if (!isset($s['required'])) { $s['required'] = ''; } if (!isset($s['status_codes'])) { $s['status_codes'] = ''; } $result = db_save_step($hostid, $applicationid, $httptestid, $name, $s['name'], $sid + 1, $s['timeout'], $s['url'], $s['posts'], $s['required'], $s['status_codes'], $delay, $history, $trends); if (!$result) { break; } $httpstepids[$result] = $result; } if ($result) { /* clean unneeded steps */ $db_steps = DBselect('select httpstepid from httpstep where httptestid=' . $httptestid); while ($step_data = DBfetch($db_steps)) { if (isset($httpstepids[$step_data['httpstepid']])) { continue; } delete_httpstep($step_data['httpstepid']); } } } if ($result) { $monitored_items = array(array('description' => 'Download speed for scenario \'$1\'', 'key_' => 'web.test.in[' . $name . ',,bps]', 'type' => ITEM_VALUE_TYPE_FLOAT, 'units' => 'bps', 'httptestitemtype' => HTTPSTEP_ITEM_TYPE_IN), array('description' => 'Failed step of scenario \'$1\'', 'key_' => 'web.test.fail[' . $name . ']', 'type' => ITEM_VALUE_TYPE_UINT64, 'units' => '', 'httptestitemtype' => HTTPSTEP_ITEM_TYPE_LASTSTEP)); foreach ($monitored_items as $item) { $item_data = DBfetch(DBselect('select i.itemid,i.history,i.trends,i.status,i.delta,i.valuemapid ' . ' from items i, httptestitem hi ' . ' where hi.httptestid=' . $httptestid . ' and hi.itemid=i.itemid ' . ' and hi.type=' . $item['httptestitemtype'])); if (!$item_data) { $item_data = DBfetch(DBselect('select i.itemid,i.history,i.trends,i.status,i.delta,i.valuemapid ' . ' from items i where i.key_=' . zbx_dbstr($item['key_']) . ' and i.hostid=' . $hostid)); } $item_args = array('description' => $item['description'], 'key_' => $item['key_'], 'hostid' => $hostid, 'delay' => $delay, 'type' => ITEM_TYPE_HTTPTEST, 'snmp_community' => '', 'snmp_oid' => '', 'value_type' => $item['type'], 'data_type' => ITEM_DATA_TYPE_DECIMAL, 'trapper_hosts' => 'localhost', 'snmp_port' => 161, 'units' => $item['units'], 'multiplier' => 0, 'snmpv3_securityname' => '', 'snmpv3_securitylevel' => 0, 'snmpv3_authpassphrase' => '', 'snmpv3_privpassphrase' => '', 'formula' => 0, 'logtimefmt' => '', 'delay_flex' => '', 'params' => '', 'ipmi_sensor' => '', 'applications' => array($applicationid)); if (!$item_data) { $item_args['history'] = $history; $item_args['status'] = ITEM_STATUS_ACTIVE; $item_args['delta'] = 0; $item_args['trends'] = $trends; $item_args['valuemapid'] = 0; if (!($itemid = add_item($item_args))) { $result = false; break; } } else { $itemid = $item_data['itemid']; $item_args['history'] = $item_data['history']; $item_args['status'] = $item_data['status']; $item_args['delta'] = $item_data['delta']; $item_args['trends'] = $item_data['trends']; $item_args['valuemapid'] = $item_data['valuemapid']; if (!update_item($itemid, $item_args)) { $result = false; break; } } $httptestitemid = get_dbid('httptestitem', 'httptestitemid'); DBexecute('delete from httptestitem where itemid=' . $itemid); if (!DBexecute('insert into httptestitem' . ' (httptestitemid, httptestid, itemid, type) ' . ' values (' . $httptestitemid . ',' . $httptestid . ',' . $itemid . ',' . $item['httptestitemtype'] . ')')) { $result = false; break; } } } if (!$result && isset($test_added)) { delete_httptest($httptestid); } else { $restult = $httptestid; } DBend($result); return $result; }
} $npc_template = 'npc.thief-group.tpl'; $combat_data = array('attack' => $group_attack, 'gold' => $group_gold, 'victory' => $victory); } else { // Normal attack on a single thief. $thief_attack = rand(0, 35); // *** Thief Damage *** if ($player->vo->health = $victory = subtractHealth($char_id, $thief_attack)) { $thief_gold = rand(0, 40); // *** Thief Gold *** if ($thief_attack > 30) { subtract_gold($char_id, $thief_gold); } else { if ($thief_attack < 30) { add_gold($char_id, $thief_gold); add_item($char_id, 'shuriken', $quantity = 1); } } } else { $thief_gold = 0; } $npc_template = 'npc.thief.tpl'; $combat_data = array('attack' => $thief_attack, 'gold' => $thief_gold, 'victory' => $victory); } } } } } } } // ************ End of specific npc logic *******************
function db_save_httptest($httptestid, $hostid, $application, $name, $authentication, $http_user, $http_password, $delay, $status, $agent, $macros, $steps) { $history = 30; // TODO !!! Allow user to set this parameter $trends = 90; // TODO !!! Allow user to set this parameter if (!preg_match('/^([' . ZBX_PREG_PRINT . '])+$/u', $name)) { error(S_ONLY_CHARACTERS_ARE_ALLOWED); return false; } DBstart(); try { $sql = 'SELECT t.httptestid' . ' FROM httptest t, applications a' . ' WHERE t.applicationid=a.applicationid' . ' AND a.hostid=' . $hostid . ' AND t.name=' . zbx_dbstr($name); $t = DBfetch(DBselect($sql)); if (isset($httptestid) && $t && $t['httptestid'] != $httptestid || $t && !isset($httptestid)) { throw new Exception(S_SCENARIO_WITH_NAME . ' [ ' . $name . ' ] ' . S_ALREADY_EXISTS_SMALL); } $sql = 'SELECT applicationid FROM applications WHERE name=' . zbx_dbstr($application) . ' AND hostid=' . $hostid; if ($applicationid = DBfetch(DBselect($sql))) { $applicationid = $applicationid['applicationid']; } else { $result = CApplication::create(array('name' => $application, 'hostid' => $hostid)); if (!$result) { throw new Exception(S_CANNOT_ADD_NEW_APPLICATION . ' [ ' . $application . ' ]'); } else { $applicationid = reset($result['applicationids']); } } if (isset($httptestid)) { $sql = 'UPDATE httptest SET ' . ' applicationid=' . $applicationid . ', ' . ' name=' . zbx_dbstr($name) . ', ' . ' authentication=' . $authentication . ', ' . ' http_user='******', ' . ' http_password='******', ' . ' delay=' . $delay . ', ' . ' status=' . $status . ', ' . ' agent=' . zbx_dbstr($agent) . ', ' . ' macros=' . zbx_dbstr($macros) . ', ' . ' error=' . zbx_dbstr('') . ', ' . ' curstate=' . HTTPTEST_STATE_UNKNOWN . ' WHERE httptestid=' . $httptestid; if (!DBexecute($sql)) { throw new Exception('DBerror'); } } else { $httptestid = get_dbid('httptest', 'httptestid'); $values = array('httptestid' => $httptestid, 'applicationid' => $applicationid, 'name' => zbx_dbstr($name), 'authentication' => $authentication, 'http_user' => zbx_dbstr($http_user), 'http_password' => zbx_dbstr($http_password), 'delay' => $delay, 'status' => $status, 'agent' => zbx_dbstr($agent), 'macros' => zbx_dbstr($macros), 'curstate' => HTTPTEST_STATE_UNKNOWN); $sql = 'INSERT INTO httptest (' . implode(', ', array_keys($values)) . ') VALUES (' . implode(', ', $values) . ')'; if (!DBexecute($sql)) { throw new Exception('DBerror'); } } $httpstepids = array(); foreach ($steps as $sid => $s) { if (!isset($s['name'])) { $s['name'] = ''; } if (!isset($s['timeout'])) { $s['timeout'] = 15; } if (!isset($s['url'])) { $s['url'] = ''; } if (!isset($s['posts'])) { $s['posts'] = ''; } if (!isset($s['required'])) { $s['required'] = ''; } if (!isset($s['status_codes'])) { $s['status_codes'] = ''; } $result = db_save_step($hostid, $applicationid, $httptestid, $name, $s['name'], $sid + 1, $s['timeout'], $s['url'], $s['posts'], $s['required'], $s['status_codes'], $delay, $history, $trends); if (!$result) { throw new Exception('Cannot create web step'); } $httpstepids[$result] = $result; } /* clean unneeded steps */ $sql = 'SELECT httpstepid FROM httpstep WHERE httptestid=' . $httptestid; $db_steps = DBselect($sql); while ($step_data = DBfetch($db_steps)) { if (!isset($httpstepids[$step_data['httpstepid']])) { delete_httpstep($step_data['httpstepid']); } } $monitored_items = array(array('description' => 'Download speed for scenario \'$1\'', 'key_' => 'web.test.in[' . $name . ',,bps]', 'type' => ITEM_VALUE_TYPE_FLOAT, 'units' => 'Bps', 'httptestitemtype' => HTTPSTEP_ITEM_TYPE_IN), array('description' => 'Failed step of scenario \'$1\'', 'key_' => 'web.test.fail[' . $name . ']', 'type' => ITEM_VALUE_TYPE_UINT64, 'units' => '', 'httptestitemtype' => HTTPSTEP_ITEM_TYPE_LASTSTEP)); foreach ($monitored_items as $item) { $item_data = DBfetch(DBselect('select i.itemid,i.history,i.trends,i.status,i.delta,i.valuemapid ' . ' from items i, httptestitem hi ' . ' where hi.httptestid=' . $httptestid . ' and hi.itemid=i.itemid ' . ' and hi.type=' . $item['httptestitemtype'])); if (!$item_data) { $item_data = DBfetch(DBselect('select i.itemid,i.history,i.trends,i.status,i.delta,i.valuemapid ' . ' from items i where i.key_=' . zbx_dbstr($item['key_']) . ' and i.hostid=' . $hostid)); } $item_args = array('description' => $item['description'], 'key_' => $item['key_'], 'hostid' => $hostid, 'delay' => $delay, 'type' => ITEM_TYPE_HTTPTEST, 'snmp_community' => '', 'snmp_oid' => '', 'value_type' => $item['type'], 'data_type' => ITEM_DATA_TYPE_DECIMAL, 'trapper_hosts' => 'localhost', 'snmp_port' => 161, 'units' => $item['units'], 'multiplier' => 0, 'snmpv3_securityname' => '', 'snmpv3_securitylevel' => 0, 'snmpv3_authpassphrase' => '', 'snmpv3_privpassphrase' => '', 'formula' => 0, 'logtimefmt' => '', 'delay_flex' => '', 'authtype' => 0, 'username' => '', 'password' => '', 'publickey' => '', 'privatekey' => '', 'params' => '', 'ipmi_sensor' => '', 'applications' => array($applicationid)); if (!$item_data) { $item_args['history'] = $history; $item_args['status'] = ITEM_STATUS_ACTIVE; $item_args['delta'] = 0; $item_args['trends'] = $trends; $item_args['valuemapid'] = 0; if (!($itemid = add_item($item_args))) { throw new Exception('Cannot add item'); } } else { $itemid = $item_data['itemid']; $item_args['history'] = $item_data['history']; $item_args['status'] = $item_data['status']; $item_args['delta'] = $item_data['delta']; $item_args['trends'] = $item_data['trends']; $item_args['valuemapid'] = $item_data['valuemapid']; if (!update_item($itemid, $item_args)) { throw new Exception('Cannot update item'); } } $httptestitemid = get_dbid('httptestitem', 'httptestitemid'); DBexecute('delete from httptestitem where itemid=' . $itemid); if (!DBexecute('insert into httptestitem (httptestitemid, httptestid, itemid, type) ' . ' values (' . $httptestitemid . ',' . $httptestid . ',' . $itemid . ',' . $item['httptestitemtype'] . ')')) { throw new Exception('DBerror'); } } return DBend(true); } catch (Exception $e) { error($e->getMessage()); return DBend(false); } }
$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); $generic_state_change = "__TARGET__ has been poisoned!";
$event_result = $conn->query(add_event($username, "added", $_POST['special_mailer_types'])); } elseif ($_POST['change_special_mailers'] == 'remove_special_mailer') { $remove_mailers_result = $conn->query(remove_item("special_mailers", "daily_lead_data")); $remove_mailers_code_result = $conn->query(remove_item($_POST['special_mailer_types'], "daily_special_mailers")); $event_result = $conn->query(add_event($username, "removed", $_POST['special_mailer_types'])); } } /* Logic for adding web apps */ if (isset($_POST['change_web_apps'])) { if ($_POST['change_web_apps'] == "add_web_app") { $add_web_apps_result = $conn->query(add_item("web_apps", "daily_lead_data")); $drop_web_result = $conn->query(drop_rank("web")); $event_result = $conn->query(add_event($username, "added", "web app")); } elseif ($_POST['change_web_apps'] == "remove_web_app") { $remove_web_apps_result = $conn->query(remove_item("web_apps", "daily_lead_data")); $raise_web_result = $conn->query(raise_rank("web_apps")); $event_result = $conn->query(add_event($username, "removed", "web apps")); } } /* Logic for adding abandoned web apps */ if (isset($_POST['change_abandoned_web_apps'])) { if ($_POST['change_abandoned_web_apps'] == 'add_abandoned_web_app') { $add_abandoned_web_result = $conn->query(add_item("abandoned_web_apps", "daily_lead_data")); $event_result = $conn->query(add_event($username, "added", "abandoned web apps")); } elseif ($_POST['change_abandoned_web_apps'] == 'remove_abandoned_web_app') { $remove_abandoned_web_result = $conn->query(remove_item("abandoned_web_apps", "daily_lead_data")); $event_result = $conn->query(add_event($username, "removed", "abandoned web apps")); } } unset($_POST); header('Location: index.php');
function copy_template_items($hostid, $templateid = null, $copy_mode = false) { if ($templateid == null) { $templateid = array_keys(get_templates_by_hostid($hostid)); } if (is_array($templateid)) { foreach ($templateid as $id) { copy_template_items($hostid, $id, $copy_mode); } // attention recursion return; } $db_tmp_items = get_items_by_hostid($templateid); while ($db_tmp_item = DBfetch($db_tmp_items)) { $db_tmp_item['hostid'] = $hostid; $db_tmp_item['applications'] = get_same_applications_for_host(get_applications_by_itemid($db_tmp_item['itemid']), $hostid); $db_tmp_item['templateid'] = $copy_mode ? 0 : $db_tmp_item['itemid']; add_item($db_tmp_item); } }
} elseif (strlen($_POST['NewStockID']) == 0) { $input_error = 1; display_error(tr('The item code cannot be empty')); set_focus('NewStockID'); } elseif (strstr($_POST['NewStockID'], " ") || strstr($_POST['NewStockID'], "'") || strstr($_POST['NewStockID'], "+") || strstr($_POST['NewStockID'], "\"") || strstr($_POST['NewStockID'], "&")) { $input_error = 1; display_error(tr('The item code cannot contain any of the following characters - & + OR a space OR quotes')); set_focus('NewStockID'); } if ($input_error != 1) { if (!isset($_POST['New'])) { /*so its an existing one */ update_item($_POST['NewStockID'], $_POST['description'], $_POST['long_description'], $_POST['category_id'], $_POST['tax_type_id'], $_POST['sales_account'], $_POST['inventory_account'], $_POST['cogs_account'], $_POST['adjustment_account'], $_POST['assembly_account'], $_POST['dimension_id'], $_POST['dimension2_id'], $_POST['selling'], $_POST['depending'], $_POST['barcode'], $_POST['weight'], $blob, $_POST['units']); } else { //it is a NEW part add_item($_POST['NewStockID'], $_POST['description'], $_POST['long_description'], $_POST['category_id'], $_POST['tax_type_id'], $_POST['units'], $_POST['mb_flag'], $_POST['sales_account'], $_POST['inventory_account'], $_POST['cogs_account'], $_POST['adjustment_account'], $_POST['assembly_account'], $_POST['dimension_id'], $_POST['dimension2_id'], $_POST['selling'], $_POST['depending'], $_POST['barcode'], $_POST['weight'], $blob); } meta_forward($_SERVER['PHP_SELF']); } } function can_delete($stock_id) { $sql = "SELECT COUNT(*) FROM stock_moves " . "WHERE stock_id='{$stock_id}'"; $result = db_query($sql, "could not query stock moves"); $myrow = db_fetch_row($result); if ($myrow[0] > 0) { display_error(tr('Cannot delete this item because there are stock ' . 'movements that refer to this item.')); return false; } $sql = "SELECT COUNT(*) FROM bom WHERE component='{$stock_id}'"; $result = db_query($sql, "could not query boms");
if (!isset($_GET['action'])) { index(); } else { switch ($_GET['action']) { case "view": views(); break; case "add_item": add_item(); break; case "add_credit": AddCreditDebit(); break; case "submit_item": submit_item(); add_item(); break; case "submit_tran": SubmitTran(); AddCreditDebit(); break; case "item": SelectItem(); break; case "add_repair": Repair(); break; case "submit_repair": SubmitRepair(); Repair(); break;
# # # # # # # # get settings require "../settings.php"; //require("core-settings.php"); require "../libs/ext.lib.php"; # decide what to do if (isset($_GET["cat"]) && isset($_GET["action"])) { switch ($_GET["action"]) { case "add": $OUTPUT = add_item($_GET); break; case "view": $OUTPUT = view_item($_GET); break; default: $OUTPUT = "Invalid use of module"; } } elseif (isset($_POST["key"])) { switch ($_POST["key"]) { case "add": $OUTPUT = write_add_item($_POST); break; default: $OUTPUT = "Invalid option selected."; }
public function add_ebay_item() { $requestType = $this->input->post('requestType'); $Currency = $this->input->post('Currency'); $ListingType = $this->input->post('ListingType'); $eBayID = $this->input->post('eBayID'); $Site = $this->input->post('Site'); $Title = $this->input->post('Title'); $description = $this->input->post('itemDescription'); $description = wrap_description($description); $CategoryId = $this->input->post('CategoryId'); $CustomerLabel = $this->input->post('CustomerLabel'); $Quantity = $this->input->post('Quantity'); $StartPrice = $this->input->post('StartPrice'); $ExternalGalleryImageFile = $this->input->post('ExternalGalleryImageFile'); $ListingDuration = $this->input->post('ListingDuration'); $Country = $this->input->post('Country'); $Location = $this->input->post('Location'); $PayPalEmailAddress = $this->input->post('PayPalEmailAddress'); $ShippingType = $this->input->post('ShippingType'); $ShippingService0 = $this->input->post('ShippingService0'); $free0 = $this->input->post('free0'); $ShippingServiceCost0 = $this->input->post('ShippingServiceCost0'); $ShippingServiceAdditionalCost0 = $this->input->post('ShippingServiceAdditionalCost0'); $ShippingSurcharge0 = $this->input->post('ShippingSurcharge0'); $DispatchTimeMax = $this->input->post('DispatchTimeMax'); $GetItFast = $this->input->post('GetItFast'); $iShippingService0 = $this->input->post('iShippingService0'); $ifree0 = $this->input->post('ifree0'); $iShippingServiceCost0 = $this->input->post('iShippingServiceCost0'); $iShippingServiceAdditionalCost0 = $this->input->post('iShippingServiceAdditionalCost0'); $ShippingService1 = $this->input->post('ShippingService1'); $ShippingServiceCost1 = $this->input->post('ShippingServiceCost1'); $ShippingServiceAdditionalCost1 = $this->input->post('ShippingServiceAdditionalCost1'); $ShippingSurcharge1 = $this->input->post('ShippingSurcharge1'); $ShippingService2 = $this->input->post('ShippingService2'); $ShippingServiceCost2 = $this->input->post('ShippingServiceCost2'); $ShippingServiceAdditionalCost2 = $this->input->post('ShippingServiceAdditionalCost2'); $ShippingSurcharge2 = $this->input->post('ShippingSurcharge2'); $iShippingService1 = $this->input->post('iShippingService1'); $iShippingServiceCost1 = $this->input->post('iShippingServiceCost1'); $iShippingServiceAdditionalCost1 = $this->input->post('iShippingServiceAdditionalCost1'); $iShippingService2 = $this->input->post('iShippingService2'); $iShippingServiceCost2 = $this->input->post('iShippingServiceCost2'); $iShippingServiceAdditionalCost2 = $this->input->post('iShippingServiceAdditionalCost2'); $ReturnPolicy = $this->input->post('ReturnPolicy'); $BestOfferEnabled = $this->input->post('BestOfferEnabled'); $iShipToLocation0 = $this->input->post('iShipToLocation0'); if (isset($iShipToLocation0[0])) { $iShipToLocation0 = $iShipToLocation0[0]; } $storeCategoryID = $this->input->post('StoreCategoryID'); $itemInfo = array('site' => $Site, 'currency' => $Currency, 'description' => $description, 'title' => $Title, 'startPrice' => $StartPrice, 'quantity' => $Quantity, 'pictureUrl' => $ExternalGalleryImageFile, 'categoryID' => $CategoryId, 'customerLabel' => $CustomerLabel, 'listType' => $ListingType, 'bestOfferEnabled' => false, 'listingDuration' => $ListingDuration, 'country' => $Country, 'location' => $Location, 'payPalEmailAddress' => $PayPalEmailAddress, 'shippingType' => $ShippingType, 'shippingService0' => $ShippingService0, 'shippingServiceCost0' => $ShippingServiceCost0, 'ishippingService0' => $iShippingService0, 'ishippingServiceCost0' => $iShippingServiceCost0, 'iShipToLocation0' => $iShipToLocation0, 'dispatchTimeMax' => $DispatchTimeMax, 'returnPolicy' => $ReturnPolicy); $this->ebay_config['siteToUseID'] = get_site_id($Site); if (!empty($storeCategoryID)) { $itemInfo['storeCategoryID'] = $storeCategoryID; } if ($free0 == 1) { $itemInfo['free0'] = true; } if (isset($ShippingServiceAdditionalCost0)) { $itemInfo['shippingServiceAdditionalCost0'] = $ShippingServiceAdditionalCost0; } if (isset($ShippingSurcharge0) && $ShippingSurcharge0 > 0) { $itemInfo['shippingSurcharge0'] = $ShippingSurcharge0; } if ($GetItFast == 1) { $itemInfo['getItFast'] = $GetItFast; } if ($ifree0 == 1) { $itemInfo['ifree0'] = true; } if (isset($iShippingServiceAdditionalCost0)) { $itemInfo['ishippingServiceAdditionalCost0'] = $iShippingServiceAdditionalCost0; } if ($ShippingService1 != 'NotSelected') { $itemInfo['shippingService1'] = $ShippingService1; $itemInfo['shippingServiceCost1'] = $ShippingServiceCost1; if (isset($ShippingServiceAdditionalCost1)) { $itemInfo['shippingServiceAdditionalCost1'] = $ShippingServiceAdditionalCost1; } if (isset($ShippingSurcharge1) && $ShippingSurcharge1 > 0) { $itemInfo['shippingSurcharge1'] = $ShippingSurcharge1; } } if ($ShippingService2 != 'NotSelected') { $itemInfo['shippingService2'] = $ShippingService2; $itemInfo['shippingServiceCost2'] = $ShippingServiceCost2; if (isset($ShippingServiceAdditionalCost2)) { $itemInfo['shippingServiceAdditionalCost2'] = $ShippingServiceAdditionalCost2; } if (isset($ShippingSurcharge2) && $ShippingSurcharge2 > 0) { $itemInfo['shippingSurcharge2'] = $ShippingSurcharge2; } } if ($iShippingService1 != 'InternationalNotSelected') { $itemInfo['ishippingService1'] = $iShippingService1; $itemInfo['ishippingServiceCost1'] = $this->input->post('iShippingServiceCost1'); if (isset($iShippingServiceAdditionalCost1)) { $itemInfo['ishippingServiceAdditionalCost1'] = $iShippingServiceAdditionalCost1; } $iShipToLocation1 = $this->input->post('iShipToLocation1'); if (isset($iShipToLocation1[0])) { $itemInfo['ishipToLocation1'] = $iShipToLocation1[0]; } } if ($iShippingService2 != 'InternationalNotSelected') { $itemInfo['ishippingService2'] = $iShippingService2; $itemInfo['ishippingServiceCost2'] = $iShippingServiceCost2; if (isset($iShippingServiceAdditionalCost2)) { $itemInfo['ishippingServiceAdditionalCost2'] = $iShippingServiceAdditionalCost2; } $iShipToLocation2 = $this->input->post('iShipToLocation2'); if (isset($iShipToLocation2[0])) { $itemInfo['ishipToLocation2'] = $iShipToLocation2[0]; } } if ($ReturnPolicy == 1) { $return_within = $this->input->post('return_within'); $return_refund_as = $this->input->post('return_refund_as'); $return_actor = $this->input->post('return_actor'); $return_details = $this->input->post('return_details'); $itemInfo['return_within'] = $return_within; $itemInfo['return_refund_as'] = $return_refund_as; $itemInfo['return_actor'] = $return_actor; if (!empty($return_details)) { $itemInfo['return_details'] = $return_details; } } $usescheduler = $this->input->post('usescheduler'); if ($usescheduler == 1) { $schedule_hour = $this->input->post('schedule_hour'); $schedule_minute = $this->input->post('schedule_minute'); $auctionDate = $this->input->post('auctionDate'); $schedule_date = date('d', strtotime($auctionDate)); $schedule_month = date('m', strtotime($auctionDate)); $schedule_year = date('Y', strtotime($auctionDate)); $itemInfo['schedule_time'] = get_gmt(array('year' => $schedule_year, 'month' => $schedule_month, 'date' => $schedule_date, 'hour' => $schedule_hour, 'minute' => $schedule_minute)); } $itemSpecificsJSON = $this->input->post('itemSpecifics'); $itemSpecifics = json_decode($itemSpecificsJSON, true); if (count($itemSpecifics)) { $itemInfo['itemSpecifics'] = $itemSpecifics; } if ($ListingType == 'FixedPriceItem') { if ($BestOfferEnabled) { $itemInfo['bestOfferEnabled'] = true; $MinimumBestOfferPrice = $this->input->post('MinimumBestOfferPrice'); if (isset($MinimumBestOfferPrice) && $MinimumBestOfferPrice > 0) { $itemInfo['minimumBestOfferPrice'] = $MinimumBestOfferPrice; } $BestOfferAutoAcceptPrice = $this->input->post('BestOfferAutoAcceptPrice'); if (isset($BestOfferAutoAcceptPrice) && $BestOfferAutoAcceptPrice > 0) { $itemInfo['bestOfferAutoAcceptPrice'] = $BestOfferAutoAcceptPrice; } } $this->ebay_config['callName'] = $requestType; $this->load->library('ebayapi/EbaySession', $this->ebay_config); if ($requestType == 'AddItem') { $requestType = $requestType . 'Request'; $xml = add_item($this->appToken, $itemInfo, $requestType); $resp = $this->xmlRequest($this->ebaysession, $xml); if ($resp->Ack != 'Failure') { echo 'Success'; } else { $err_num = count($resp->Errors); echo $resp->Errors[$err_num - 1]->LongMessage; } } else { if ($requestType == 'VerifyAddItem') { $requestType = $requestType . 'Request'; $xml = add_item($this->appToken, $itemInfo, $requestType); $resp = $this->xmlRequest($this->ebaysession, $xml); if ($resp->Ack == 'Success' || $resp->Ack == 'Warning') { $toReturn['Ack'] = 'Success'; $toReturn['Fees'] = countFees($resp); } else { $toReturn['Ack'] = 'Failure'; $err_num = count($resp->Errors); $toReturn['Message'] = sprintf('%s', $resp->Errors[$err_num - 1]->LongMessage); } echo json_encode($toReturn); } } } else { if ($ListingType == 'Chinese') { $ReservePrice = $this->input->post('ReservePrice'); if (isset($ReservePrice) && $ReservePrice > 0) { $itemInfo['reservePrice'] = $ReservePrice; } $BuyItNowPrice = $this->input->post('BuyItNowPrice'); if (isset($BuyItNowPrice) && $BuyItNowPrice > 0) { $itemInfo['buyItNowPrice'] = $BuyItNowPrice; } $this->ebay_config['callName'] = $requestType; $this->load->library('ebayapi/EbaySession', $this->ebay_config); if ($requestType == 'AddItem') { $requestType = $requestType . 'Request'; $xml = add_item($this->appToken, $itemInfo, $requestType); $resp = $this->xmlRequest($this->ebaysession, $xml); if ($resp->Ack != 'Failure') { echo 'Success'; } else { $err_num = count($resp->Errors); echo $resp->Errors[$err_num - 1]->LongMessage; } } else { if ($requestType == 'VerifyAddItem') { $requestType = $requestType . 'Request'; $xml = add_item($this->appToken, $itemInfo, $requestType); $resp = $this->xmlRequest($this->ebaysession, $xml); if ($resp->Ack == 'Success' || $resp->Ack == 'Warning') { $toReturn['Ack'] = 'Success'; $toReturn['Fees'] = countFees($resp); } else { $toReturn['Ack'] = 'Failure'; $err_num = count($resp->Errors); $toReturn['Message'] = sprintf('%s', $resp->Errors[$err_num - 1]->LongMessage); } echo json_encode($toReturn); } } } else { if ($ListingType == 'MultiSKU') { $variations = get_variations($_POST); if (count($variations) > 0) { $itemInfo['variations'] = $variations; } if ($requestType == 'AddItem') { $this->ebay_config['callName'] = 'AddFixedPriceItem'; $this->load->library('ebayapi/EbaySession', $this->ebay_config); $requestType = 'AddFixedPriceItemRequest'; $xml = add_multi_sku_item($this->appToken, $itemInfo, $requestType); $resp = $this->xmlRequest($this->ebaysession, $xml); if ($resp->Ack != 'Failure') { echo 'Success'; } else { $err_num = count($resp->Errors); echo $resp->Errors[$err_num - 1]->LongMessage; } } else { if ($requestType == 'VerifyAddItem') { $this->ebay_config['callName'] = 'VerifyAddFixedPriceItem'; $this->load->library('ebayapi/EbaySession', $this->ebay_config); $requestType = 'VerifyAddFixedPriceItemRequest'; $xml = add_multi_sku_item($this->appToken, $itemInfo, $requestType); $resp = $this->xmlRequest($this->ebaysession, $xml); if ($resp->Ack == 'Success' || $resp->Ack == 'Warning') { $toReturn['Ack'] = 'Success'; $toReturn['Fees'] = countFees($resp); } else { $toReturn['Ack'] = 'Failure'; $err_num = count($resp->Errors); $toReturn['Message'] = sprintf('%s', $resp->Errors[$err_num - 1]->LongMessage); } echo json_encode($toReturn); } } } } } }
/** * Add item * * @param array $items * @return array|boolean */ public static function create($items) { $items = zbx_toArray($items); $itemids = array(); try { self::BeginTransaction(__METHOD__); $dbHosts = CHost::get(array('output' => API_OUTPUT_SHORTEN, 'hostids' => zbx_objectValues($items, 'hostid'), 'templated_hosts' => true, 'editable' => true, 'preservekeys' => true)); foreach ($items as $inum => $item) { if (!isset($dbHosts[$item['hostid']])) { self::exception(ZBX_API_ERROR_PARAMETERS, S_NO_PERMISSIONS); } $result = add_item($item); if (!$result) { self::exception(ZBX_API_ERROR_PARAMETERS, 'Cannot create Item'); } $itemids[] = $result; } self::EndTransaction(true, __METHOD__); return array('itemids' => $itemids); } catch (APIException $e) { self::EndTransaction(false, __METHOD__); $error = $e->getErrors(); $error = reset($error); self::setError(__METHOD__, $e->getCode(), $error); return false; } }