Example #1
0
	/**
	 * @param string $username
	 * @param int $char_guid
	 * @param int $itemid
	 * @param int $quantity
	 * @param int $titleid
	 * @param int $achievid
	 * @param int $new_level
	 * @return array
	 */
	public static function addcode($username, $char_guid = 0, $itemid = 0, $quantity = 1,  $titleid = 0, $achievid = 0, $new_level = 0) {
		$account_id = auth_account::get_id(mb_strtolower($username));
		$code = self::generate_code();

		// Check Data
		if(! $account_id)
			return array("fail" => 'Account konnte nicht gefunden werden', "result" => false);
		if(! $code)
			return array("fail" => 'Code konnte nicht generiert werden', "result" => false);

		// Add Code
		if(char_code::add($code, $account_id, $char_guid, $itemid, $new_level, $titleid, $achievid, $quantity) !== false)
			return array("key" => $code, "result" => true);
		// Default Value
		return array("fail" => 'Ein unbekannter Fehler ist aufgetreten...', "result" => false);
	}
Example #2
0
	/**
	 * @param mixed $prefix
	 */
	private static function setPrefix($prefix) {
		self::$prefix = $prefix;
	}
	/**
	 * @param int $code - code id
	 * @param int $newacc - new account id
	 * @param int $oldacc - old account id
	 * @return int|string
	 */
	protected static function tradecode($code, $newacc, $oldacc) {
		$char = char_code::getchar($code);

		if ($char != 0)
			return "Nur nicht Charakter gebundene Codes können getauscht werden.";
		if ($newacc == 0)
			return "Neue Account ID ist Ungültig";

		$sql = 'UPDATE ' . self::getFullTableName() . ' SET account_id = :new, trade_to_id = :new, trade_from_id = :old WHERE code = :code';

		return SQL::execute(self::getConnection(), $sql,
			array(
				"new" => $newacc,
				"old" => $oldacc,
				"code" => $code
			)
		);
	}