public function login_action() { if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (empty($_POST['email']) || empty($_POST['password']) || !account::log_in($_POST['email'], $_POST['password'])) { return api::result(false); } return api::result(true); } return api::result(false); }
public function formatted_action($key) { if (empty($key)) { return api::result(false, array('message' => 'No_key_provided')); } $kb = knowledge_base_article::load_one($key, 'key'); if (!$kb) { return api::result(false, array('message' => 'Article_not_found')); } return api::result(true, array('formatted' => addslashes($kb->formatted()))); }
public function inventory_action($type) { $type = page::arg('type', $type, 'character'); $charId = page::arg('character_id'); $charName = page::arg('name'); $itemType = page::arg('item_type', null, 'all'); $char = null; if ($charId) { $char = character::load_one($charId); } else { if ($charName) { $char = character::load_one($charName, 'name'); } else { if (!character::selected()) { return api::result(false, array('message' => 'No_character_selected')); } else { $char = character::current(); } } } if (!$type) { $type = 'character'; } $types = array('character' => inventory::TYPE_CHARACTER, 'vault' => inventory::TYPE_VAULT); $itemTypes = array('all' => null, 'usable' => item::TYPE_USABLE, 'enchantable' => item::TYPE_ENCHANTABLE, 'destroyable' => item::TYPE_DESTROYABLE, 'loot' => item::TYPE_LOOT, 'equippable' => item::TYPE_EQUIPPABLE, 'material' => item::TYPE_MATERIAL); if (!isset($types[$type])) { $itemType = (int) $type; } if (!array_key_exists($itemType, $itemTypes)) { return api::result(false, array('message' => 'Invalid_item_type')); } return api::result(true, array($char->inventory($types[$type])->items($itemTypes[$itemType], true))); }
public function result($type, $args = array(), $status = true) { return api::result($status, array($status ? 'type' : 'message' => $type, 'args' => $args)); }