Example #1
0
/**
 * Receive a account_info request from map-serv
 * @author : [Dekamaster/Nightroad]
 * @param fd : map-serv link
 */
void mapif_parse_accinfo(int fd) {
	int u_fd = RFIFOL(fd,2), u_aid = RFIFOL(fd,6), u_group = RFIFOL(fd,10);
	char type= RFIFOB(fd,14);
	char query[NAME_LENGTH], query_esq[NAME_LENGTH*2+1];
	uint32 account_id = 0;
	char *data;

	safestrncpy(query, RFIFOCP(fd,15), NAME_LENGTH);
	Sql_EscapeString(sql_handle, query_esq, query);

	account_id = atoi(query);

	if (account_id < START_ACCOUNT_NUM) {	// is string
		if ( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id`,`name`,`class`,`base_level`,`job_level`,`online` FROM `%s` WHERE `name` LIKE '%s' LIMIT 10", schema_config.char_db, query_esq)
				|| Sql_NumRows(sql_handle) == 0 ) {
			if( Sql_NumRows(sql_handle) == 0 ) {
				inter_to_fd(fd, u_fd, u_aid, (char *)msg_txt(212) ,query);
			} else {
				Sql_ShowDebug(sql_handle);
				inter_to_fd(fd, u_fd, u_aid, (char *)msg_txt(213));
			}
			Sql_FreeResult(sql_handle);
			return;
		} else {
			if( Sql_NumRows(sql_handle) == 1 ) {//we found a perfect match
				Sql_NextRow(sql_handle);
				Sql_GetData(sql_handle, 0, &data, NULL); account_id = atoi(data);
				Sql_FreeResult(sql_handle);
			} else {// more than one, listing... [Dekamaster/Nightroad]
				inter_to_fd(fd, u_fd, u_aid, (char *)msg_txt(214),(int)Sql_NumRows(sql_handle));
				while ( SQL_SUCCESS == Sql_NextRow(sql_handle) ) {
					int class_;
					short base_level, job_level, online;
					char name[NAME_LENGTH];

					Sql_GetData(sql_handle, 0, &data, NULL); account_id = atoi(data);
					Sql_GetData(sql_handle, 1, &data, NULL); safestrncpy(name, data, sizeof(name));
					Sql_GetData(sql_handle, 2, &data, NULL); class_ = atoi(data);
					Sql_GetData(sql_handle, 3, &data, NULL); base_level = atoi(data);
					Sql_GetData(sql_handle, 4, &data, NULL); job_level = atoi(data);
					Sql_GetData(sql_handle, 5, &data, NULL); online = atoi(data);

					inter_to_fd(fd, u_fd, u_aid, (char *)msg_txt(215), account_id, name, job_name(class_), base_level, job_level, online?"Online":"Offline");
				}
				Sql_FreeResult(sql_handle);
				return;
			}
		}
	}

	/* it will only get here if we have a single match then ask login-server to fetch the `login` record */
	if (!account_id || chlogif_req_accinfo(fd, u_fd, u_aid, u_group, account_id, type) != 1) {
		inter_to_fd(fd, u_fd, u_aid, (char *)msg_txt(213));
	}
	return;
}
Example #2
0
/**
 * Show account info from login-server to user
 */
void mapif_accinfo_ack(bool success, int map_fd, int u_fd, int u_aid, int account_id, int8 type,
	int group_id, int logincount, int state, const char *email, const char *last_ip, const char *lastlogin,
	const char *birthdate, const char *user_pass, const char *pincode, const char *userid)
{
	
	if (map_fd <= 0 || !session_isActive(map_fd))
		return; // check if we have a valid fd

	if (!success) {
		inter_to_fd(map_fd, u_fd, u_aid, (char *)msg_txt(216), account_id);
		return;
	}

	if (type == 1) { //type 1 we don't want all the info [lighta] @CHECKME
		mapif_acc_info_ack(map_fd, u_fd, account_id, userid);
		return;
	}

	inter_to_fd(map_fd, u_fd, u_aid, (char *)msg_txt(217), account_id);
	inter_to_fd(map_fd, u_fd, u_aid, (char *)msg_txt(218), userid, group_id, state);
	inter_to_fd(map_fd, u_fd, u_aid, (char *)msg_txt(219), user_pass[0] != '\0' ? user_pass : msg_txt(220), pincode[0] != '\0' ? msg_txt(220) : pincode);
	inter_to_fd(map_fd, u_fd, u_aid, (char *)msg_txt(221), email, birthdate);
	inter_to_fd(map_fd, u_fd, u_aid, (char *)msg_txt(222), last_ip, geoip_getcountry(str2ip(last_ip)));
	inter_to_fd(map_fd, u_fd, u_aid, (char *)msg_txt(223), logincount, lastlogin);
	inter_to_fd(map_fd, u_fd, u_aid, (char *)msg_txt(224));

	if ( SQL_ERROR == Sql_Query(sql_handle, "SELECT `char_id`, `name`, `char_num`, `class`, `base_level`, `job_level`, `online` FROM `%s` WHERE `account_id` = '%d' ORDER BY `char_num` LIMIT %d", schema_config.char_db, account_id, MAX_CHARS)
		|| Sql_NumRows(sql_handle) == 0 )
	{
		if( Sql_NumRows(sql_handle) == 0 )
			inter_to_fd(map_fd, u_fd, u_aid, (char *)msg_txt(226));
		else {
			inter_to_fd(map_fd, u_fd, u_aid, (char *)msg_txt(213));
			Sql_ShowDebug(sql_handle);
		}
	} else {
		while ( SQL_SUCCESS == Sql_NextRow(sql_handle) ) {
			uint32 char_id, class_;
			short char_num, base_level, job_level, online;
			char name[NAME_LENGTH];
			char *data;

			Sql_GetData(sql_handle, 0, &data, NULL); char_id = atoi(data);
			Sql_GetData(sql_handle, 1, &data, NULL); safestrncpy(name, data, sizeof(name));
			Sql_GetData(sql_handle, 2, &data, NULL); char_num = atoi(data);
			Sql_GetData(sql_handle, 3, &data, NULL); class_ = atoi(data);
			Sql_GetData(sql_handle, 4, &data, NULL); base_level = atoi(data);
			Sql_GetData(sql_handle, 5, &data, NULL); job_level = atoi(data);
			Sql_GetData(sql_handle, 6, &data, NULL); online = atoi(data);

			inter_to_fd(map_fd, u_fd, u_aid, (char *)msg_txt(225), char_num, char_id, name, job_name(class_), base_level, job_level, online?"Online":"Offline");
		}
	}
	Sql_FreeResult(sql_handle);
}
Example #3
0
/* [Dekamaster/Nightroad] */
void mapif_parse_accinfo(int fd) {
	int u_fd = RFIFOL(fd,2), aid = RFIFOL(fd,6), castergroup = RFIFOL(fd,10);
	char query[NAME_LENGTH], query_esq[NAME_LENGTH*2+1];
	int account_id;
	char *data;

	safestrncpy(query, (char*) RFIFOP(fd,14), NAME_LENGTH);

	SQL->EscapeString(sql_handle, query_esq, query);

	account_id = atoi(query);

	if (account_id < START_ACCOUNT_NUM) {	// is string
		if ( SQL_ERROR == SQL->Query(sql_handle, "SELECT `account_id`,`name`,`class`,`base_level`,`job_level`,`online` FROM `%s` WHERE `name` LIKE '%s' LIMIT 10", char_db, query_esq)
				|| SQL->NumRows(sql_handle) == 0 ) {
			if( SQL->NumRows(sql_handle) == 0 ) {
				inter_msg_to_fd(fd, u_fd, aid, "No matches were found for your criteria, '%s'",query);
			} else {
				Sql_ShowDebug(sql_handle);
				inter_msg_to_fd(fd, u_fd, aid, "An error occured, bother your admin about it.");
			}
			SQL->FreeResult(sql_handle);
			return;
		} else {
			if( SQL->NumRows(sql_handle) == 1 ) {//we found a perfect match
				SQL->NextRow(sql_handle);
				SQL->GetData(sql_handle, 0, &data, NULL); account_id = atoi(data);
				SQL->FreeResult(sql_handle);
			} else {// more than one, listing... [Dekamaster/Nightroad]
				inter_msg_to_fd(fd, u_fd, aid, "Your query returned the following %d results, please be more specific...",(int)SQL->NumRows(sql_handle));
				while ( SQL_SUCCESS == SQL->NextRow(sql_handle) ) {
					int class_;
					short base_level, job_level, online;
					char name[NAME_LENGTH];

					SQL->GetData(sql_handle, 0, &data, NULL); account_id = atoi(data);
					SQL->GetData(sql_handle, 1, &data, NULL); safestrncpy(name, data, sizeof(name));
					SQL->GetData(sql_handle, 2, &data, NULL); class_ = atoi(data);
					SQL->GetData(sql_handle, 3, &data, NULL); base_level = atoi(data);
					SQL->GetData(sql_handle, 4, &data, NULL); job_level = atoi(data);
					SQL->GetData(sql_handle, 5, &data, NULL); online = atoi(data);

					inter_msg_to_fd(fd, u_fd, aid, "[AID: %d] %s | %s | Level: %d/%d | %s", account_id, name, job_name(class_), base_level, job_level, online?"Online":"Offline");
				}
				SQL->FreeResult(sql_handle);
				return;
			}
		}
	}

	/* it will only get here if we have a single match */
	if( account_id ) {
		char userid[NAME_LENGTH], user_pass[NAME_LENGTH], email[40], last_ip[20], lastlogin[30], pin_code[5], birthdate[11];
		short level = -1;
		int logincount = 0,state = 0;
		// FIXME: No, this doesn't really look right.  We can't, and shouldn't, access the login table from the char server.
		if ( SQL_ERROR == SQL->Query(sql_handle, "SELECT `userid`, `user_pass`, `email`, `last_ip`, `group_id`, `lastlogin`, `logincount`, `state`,`pincode`,`birthdate` FROM `login` WHERE `account_id` = '%d' LIMIT 1", account_id)
			|| SQL->NumRows(sql_handle) == 0 ) {
			if( SQL->NumRows(sql_handle) == 0 ) {
				inter_msg_to_fd(fd, u_fd, aid,  "No account with ID '%d' was found.", account_id );
			} else {
				inter_msg_to_fd(fd, u_fd, aid, "An error occured, bother your admin about it.");
				Sql_ShowDebug(sql_handle);
			}
		} else {
			SQL->NextRow(sql_handle);
			SQL->GetData(sql_handle, 0, &data, NULL); safestrncpy(userid, data, sizeof(userid));
			SQL->GetData(sql_handle, 1, &data, NULL); safestrncpy(user_pass, data, sizeof(user_pass));
			SQL->GetData(sql_handle, 2, &data, NULL); safestrncpy(email, data, sizeof(email));
			SQL->GetData(sql_handle, 3, &data, NULL); safestrncpy(last_ip, data, sizeof(last_ip));
			SQL->GetData(sql_handle, 4, &data, NULL); level = atoi(data);
			SQL->GetData(sql_handle, 5, &data, NULL); safestrncpy(lastlogin, data, sizeof(lastlogin));
			SQL->GetData(sql_handle, 6, &data, NULL); logincount = atoi(data);
			SQL->GetData(sql_handle, 7, &data, NULL); state = atoi(data);
			SQL->GetData(sql_handle, 8, &data, NULL); safestrncpy(pin_code, data, sizeof(pin_code));
			SQL->GetData(sql_handle, 9, &data, NULL); safestrncpy(birthdate, data, sizeof(birthdate));
		}

		SQL->FreeResult(sql_handle);

		if (level == -1)
			return;

		inter_msg_to_fd(fd, u_fd, aid, "-- Account %d --", account_id );
		inter_msg_to_fd(fd, u_fd, aid, "User: %s | GM Group: %d | State: %d", userid, level, state );

		if (level < castergroup) { /* only show pass if your gm level is greater than the one you're searching for */
			if( strlen(pin_code) )
				inter_msg_to_fd(fd, u_fd, aid, "Password: %s (PIN:%s)", user_pass, pin_code );
			else
				inter_msg_to_fd(fd, u_fd, aid, "Password: %s", user_pass );
		}

		inter_msg_to_fd(fd, u_fd, aid, "Account e-mail: %s | Birthdate: %s", email, birthdate);
		inter_msg_to_fd(fd, u_fd, aid, "Last IP: %s (%s)", last_ip, geoip_getcountry(str2ip(last_ip)) );
		inter_msg_to_fd(fd, u_fd, aid, "This user has logged %d times, the last time were at %s", logincount, lastlogin );
		inter_msg_to_fd(fd, u_fd, aid, "-- Character Details --" );


		if ( SQL_ERROR == SQL->Query(sql_handle, "SELECT `char_id`, `name`, `char_num`, `class`, `base_level`, `job_level`, `online` FROM `%s` WHERE `account_id` = '%d' ORDER BY `char_num` LIMIT %d", char_db, account_id, MAX_CHARS)
				|| SQL->NumRows(sql_handle) == 0 ) {

				if( SQL->NumRows(sql_handle) == 0 )
					inter_msg_to_fd(fd, u_fd, aid,"This account doesn't have characters.");
				else {
					inter_msg_to_fd(fd, u_fd, aid,"An error occured, bother your admin about it.");
					Sql_ShowDebug(sql_handle);
				}

		} else {
			while ( SQL_SUCCESS == SQL->NextRow(sql_handle) ) {
				int char_id, class_;
				short char_num, base_level, job_level, online;
				char name[NAME_LENGTH];

				SQL->GetData(sql_handle, 0, &data, NULL); char_id = atoi(data);
				SQL->GetData(sql_handle, 1, &data, NULL); safestrncpy(name, data, sizeof(name));
				SQL->GetData(sql_handle, 2, &data, NULL); char_num = atoi(data);
				SQL->GetData(sql_handle, 3, &data, NULL); class_ = atoi(data);
				SQL->GetData(sql_handle, 4, &data, NULL); base_level = atoi(data);
				SQL->GetData(sql_handle, 5, &data, NULL); job_level = atoi(data);
				SQL->GetData(sql_handle, 6, &data, NULL); online = atoi(data);

				inter_msg_to_fd(fd, u_fd, aid, "[Slot/CID: %d/%d] %s | %s | Level: %d/%d | %s", char_num, char_id, name, job_name(class_), base_level, job_level, online?"On":"Off");
			}
		}
		SQL->FreeResult(sql_handle);
	}

	return;
}
Example #4
0
void mapif_parse_accinfo2(bool success, int map_fd, int u_fd, int u_aid, int account_id, const char *userid, const char *user_pass, const char *email, const char *last_ip, const char *lastlogin, const char *pin_code, const char *birthdate, int group_id, int logincount, int state) {
	if (map_fd <= 0 || !session_isActive(map_fd))
		return; // check if we have a valid fd

	if(!success) {
		inter_msg_to_fd(map_fd, u_fd, u_aid, "No account with ID '%d' was found.", account_id);
		return;
	}

		inter_msg_to_fd(map_fd, u_fd, u_aid, read_message("Source.char.inter_parse_accinfo_s7"), account_id);
		inter_msg_to_fd(map_fd, u_fd, u_aid, read_message("Source.char.inter_parse_accinfo_s8"), userid, group_id, state);

		if(user_pass && *user_pass != '\0') { /* password is only received if your gm level is greater than the one you're searching for */
			if(pin_code && *pin_code != '\0')
				inter_msg_to_fd(map_fd, u_fd, u_aid, read_message("Source.char.inter_parse_accinfo_s17"), user_pass, pin_code);
			else
				inter_msg_to_fd(map_fd, u_fd, u_aid, read_message("Source.char.inter_parse_accinfo_s9"), user_pass);
			}

		inter_msg_to_fd(map_fd, u_fd, u_aid, read_message("Source.char.inter_parse_accinfo_s10"), email, birthdate);
		inter_msg_to_fd(map_fd, u_fd, u_aid, read_message("Source.char.inter_parse_accinfo_s11"), last_ip, geoip_getcountry(str2ip(last_ip)));
		inter_msg_to_fd(map_fd, u_fd, u_aid, read_message("Source.char.inter_parse_accinfo_s12"), logincount, lastlogin);
		inter_msg_to_fd(map_fd, u_fd, u_aid, read_message("Source.char.inter_parse_accinfo_s13"));


		if(SQL_ERROR == Sql_Query(sql_handle, "SELECT `char_id`, `name`, `char_num`, `class`, `base_level`, `job_level`, `online` "
	                                              "FROM `%s` WHERE `account_id` = '%d' ORDER BY `char_num` LIMIT %d", char_db, account_id, MAX_CHARS)
			|| Sql_NumRows(sql_handle) == 0) {

			if(Sql_NumRows(sql_handle) == 0) {
				inter_msg_to_fd(map_fd, u_fd, u_aid, read_message("Source.char.inter_parse_accinfo_s14"));
			} else {
				inter_msg_to_fd(map_fd, u_fd, u_aid, read_message("Source.char.inter_parse_accinfo_s15"));
				Sql_ShowDebug(sql_handle);
			}
		} else {
			while(SQL_SUCCESS == Sql_NextRow(sql_handle)) {
				char *data;
				int char_id, class_;
				short char_num, base_level, job_level, online;
				char name[NAME_LENGTH];

				Sql_GetData(sql_handle, 0, &data, NULL); char_id = atoi(data);
				Sql_GetData(sql_handle, 1, &data, NULL); safestrncpy(name, data, sizeof(name));
				Sql_GetData(sql_handle, 2, &data, NULL); char_num = atoi(data);
				Sql_GetData(sql_handle, 3, &data, NULL); class_ = atoi(data);
				Sql_GetData(sql_handle, 4, &data, NULL); base_level = atoi(data);
				Sql_GetData(sql_handle, 5, &data, NULL); job_level = atoi(data);
				Sql_GetData(sql_handle, 6, &data, NULL); online = atoi(data);

				inter_msg_to_fd(map_fd, u_fd, u_aid, read_message("Source.char.inter_parse_accinfo_s16"), char_num, char_id, name, job_name(class_), base_level, job_level, online?"On":"Off");
			}
		}
		Sql_FreeResult(sql_handle);

	return;
}
Example #5
0
/* [Dekamaster/Nightroad] */
void mapif_parse_accinfo(int fd)
{
	int u_fd = RFIFOL(fd,2), aid = RFIFOL(fd,6), castergroup = RFIFOL(fd,10);
	char query[NAME_LENGTH], query_esq[NAME_LENGTH*2+1];
	int account_id;
	char *data;

	safestrncpy(query, (char *) RFIFOP(fd,14), NAME_LENGTH);

	Sql_EscapeString(sql_handle, query_esq, query);

	account_id = atoi(query);

	if(account_id < START_ACCOUNT_NUM) {    // is string
		if(SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id`,`name`,`class`,`base_level`,`job_level`,`online` FROM `%s` WHERE `name` LIKE '%s' LIMIT 10", char_db, query_esq)
			|| Sql_NumRows(sql_handle) == 0) {
			if(Sql_NumRows(sql_handle) == 0) {
				inter_msg_to_fd(fd, u_fd, aid, read_message("Source.char.inter_parse_accinfo_s1"), query);
			} else {
				Sql_ShowDebug(sql_handle);
				inter_msg_to_fd(fd, u_fd, aid, read_message("Source.char.inter_parse_accinfo_s2"));
			}
			Sql_FreeResult(sql_handle);
			return;
		} else {
			if(Sql_NumRows(sql_handle) == 1) {  //we found a perfect match
				Sql_NextRow(sql_handle);
				Sql_GetData(sql_handle, 0, &data, NULL); account_id = atoi(data);
				Sql_FreeResult(sql_handle);
			} else {// more than one, listing... [Dekamaster/Nightroad]
				inter_msg_to_fd(fd, u_fd, aid, read_message("Source.char.inter_parse_accinfo_s3"), (int)Sql_NumRows(sql_handle));
				while (SQL_SUCCESS == Sql_NextRow(sql_handle)) {
					int class_;
					short base_level, job_level, online;
					char name[NAME_LENGTH];

					Sql_GetData(sql_handle, 0, &data, NULL); account_id = atoi(data);
					Sql_GetData(sql_handle, 1, &data, NULL); safestrncpy(name, data, sizeof(name));
					Sql_GetData(sql_handle, 2, &data, NULL); class_ = atoi(data);
					Sql_GetData(sql_handle, 3, &data, NULL); base_level = atoi(data);
					Sql_GetData(sql_handle, 4, &data, NULL); job_level = atoi(data);
					Sql_GetData(sql_handle, 5, &data, NULL); online = atoi(data);

					inter_msg_to_fd(fd, u_fd, aid, read_message("Source.char.inter_parse_accinfo_s4"), account_id, name, job_name(class_), base_level, job_level, online?"Online":"Offline");
				}
				Sql_FreeResult(sql_handle);
				return;
			}
		}
	}

	/* it will only get here if we have a single match */
	/* and we will send packet with account id to login server asking for account info */
	if(account_id) {
		mapif_on_parse_accinfo(account_id, u_fd, aid, castergroup, fd);
	}

	return;
}
Example #6
0
/* [Dekamaster/Nightroad] */
void mapif_parse_accinfo (int fd)
{
	int u_fd = RFIFOL (fd, 2), aid = RFIFOL (fd, 6), castergroup = RFIFOL (fd, 10);
	char query[NAME_LENGTH], query_esq[NAME_LENGTH * 2 + 1];
	int account_id;
	char *data;
	safestrncpy (query, (char *) RFIFOP (fd, 14), NAME_LENGTH);
	Sql_EscapeString (sql_handle, query_esq, query);
	account_id = atoi (query);

	if (account_id < START_ACCOUNT_NUM) {	// is string
		if (SQL_ERROR == Sql_Query (sql_handle, "SELECT `account_id`,`name`,`class`,`base_level`,`job_level`,`online` FROM `char` WHERE `name` LIKE '%s' LIMIT 10", query_esq)
				|| Sql_NumRows (sql_handle) == 0) {
			if (Sql_NumRows (sql_handle) == 0) {
				inter_to_fd (fd, u_fd, aid, "Não foram encontrados resultados para seu critério, '%s'", query);
			} else {
				Sql_ShowDebug (sql_handle);
				inter_to_fd (fd, u_fd, aid, "Um erro ocorreu, incomode seu administrador sobre isso.");
			}

			Sql_FreeResult (sql_handle);
			return;
		} else {
			if (Sql_NumRows (sql_handle) == 1) {//we found a perfect match
				Sql_NextRow (sql_handle);
				Sql_GetData (sql_handle, 0, &data, NULL); account_id = atoi (data);
				Sql_FreeResult (sql_handle);
			} else {// more than one, listing... [Dekamaster/Nightroad]
				inter_to_fd (fd, u_fd, aid, "Sua requisição retornou %d resultados, seja mais específico...", (int) Sql_NumRows (sql_handle));

				while (SQL_SUCCESS == Sql_NextRow (sql_handle)) {
					int class_;
					short base_level, job_level, online;
					char name[NAME_LENGTH];
					Sql_GetData (sql_handle, 0, &data, NULL); account_id = atoi (data);
					Sql_GetData (sql_handle, 1, &data, NULL); safestrncpy (name, data, sizeof (name));
					Sql_GetData (sql_handle, 2, &data, NULL); class_ = atoi (data);
					Sql_GetData (sql_handle, 3, &data, NULL); base_level = atoi (data);
					Sql_GetData (sql_handle, 4, &data, NULL); job_level = atoi (data);
					Sql_GetData (sql_handle, 5, &data, NULL); online = atoi (data);
					inter_to_fd (fd, u_fd, aid, "[AID: %d] %s | %s | Nível: %d/%d | %s", account_id, name, job_name (class_), base_level, job_level, online ? "Online" : "Offline");
				}

				Sql_FreeResult (sql_handle);
				return;
			}
		}
	}

	/* it will only get here if we have a single match */
	if (account_id) {
		char userid[NAME_LENGTH], user_pass[NAME_LENGTH], email[40], last_ip[20], lastlogin[30];
		short level = -1;
		int logincount = 0, state = 0;

		if (SQL_ERROR == Sql_Query (sql_handle, "SELECT `userid`, `user_pass`, `email`, `last_ip`, `group_id`, `lastlogin`, `logincount`, `state` FROM `login` WHERE `account_id` = '%d' LIMIT 1", account_id)
				|| Sql_NumRows (sql_handle) == 0) {
			if (Sql_NumRows (sql_handle) == 0) {
				inter_to_fd (fd, u_fd, aid,  "Nenhuma conta de ID '%d' foi encontrada.", account_id);
			} else {
				inter_to_fd (fd, u_fd, aid, "Um erro ocorreu, incomode seu administrador sobre isso.");
				Sql_ShowDebug (sql_handle);
			}
		} else {
			Sql_NextRow (sql_handle);
			Sql_GetData (sql_handle, 0, &data, NULL); safestrncpy (userid, data, sizeof (userid));
			Sql_GetData (sql_handle, 1, &data, NULL); safestrncpy (user_pass, data, sizeof (user_pass));
			Sql_GetData (sql_handle, 2, &data, NULL); safestrncpy (email, data, sizeof (email));
			Sql_GetData (sql_handle, 3, &data, NULL); safestrncpy (last_ip, data, sizeof (last_ip));
			Sql_GetData (sql_handle, 4, &data, NULL); level = atoi (data);
			Sql_GetData (sql_handle, 5, &data, NULL); safestrncpy (lastlogin, data, sizeof (lastlogin));
			Sql_GetData (sql_handle, 6, &data, NULL); logincount = atoi (data);
			Sql_GetData (sql_handle, 7, &data, NULL); state = atoi (data);
		}

		Sql_FreeResult (sql_handle);

		if (level == -1)
			return;

		inter_to_fd (fd, u_fd, aid, "-- Conta %d --", account_id);
		inter_to_fd (fd, u_fd, aid, "Usuário: %s | Grupo de GM: %d | Estado: %d", userid, level, state);

		if (level < castergroup) /* only show pass if your gm level is greater than the one you're searching for */
			inter_to_fd (fd, u_fd, aid, "Senha: %s", user_pass);

		inter_to_fd (fd, u_fd, aid, "Conta de email: %s", email);
		inter_to_fd (fd, u_fd, aid, "Último IP: %s (%s)", last_ip, geoip_getcountry (str2ip (last_ip)));
		inter_to_fd (fd, u_fd, aid, "Este usuário logou %d vezes, a última vez foi em %s", logincount, lastlogin);
		inter_to_fd (fd, u_fd, aid, "-- Detalhes do personagem --");

		if (SQL_ERROR == Sql_Query (sql_handle, "SELECT `char_id`, `name`, `char_num`, `class`, `base_level`, `job_level`, `online` FROM `char` WHERE `account_id` = '%d' ORDER BY `char_num` LIMIT %d", account_id, MAX_CHARS)
				|| Sql_NumRows (sql_handle) == 0) {
			if (Sql_NumRows (sql_handle) == 0)
				inter_to_fd (fd, u_fd, aid, "Esta conta não tem personagens.");
			else {
				inter_to_fd (fd, u_fd, aid, "Um erro ocorreu, fale com seu administrador sobre isso.");
				Sql_ShowDebug (sql_handle);
			}
		} else {
			while (SQL_SUCCESS == Sql_NextRow (sql_handle)) {
				int char_id, class_;
				short char_num, base_level, job_level, online;
				char name[NAME_LENGTH];
				Sql_GetData (sql_handle, 0, &data, NULL); char_id = atoi (data);
				Sql_GetData (sql_handle, 1, &data, NULL); safestrncpy (name, data, sizeof (name));
				Sql_GetData (sql_handle, 2, &data, NULL); char_num = atoi (data);
				Sql_GetData (sql_handle, 3, &data, NULL); class_ = atoi (data);
				Sql_GetData (sql_handle, 4, &data, NULL); base_level = atoi (data);
				Sql_GetData (sql_handle, 5, &data, NULL); job_level = atoi (data);
				Sql_GetData (sql_handle, 6, &data, NULL); online = atoi (data);
				inter_to_fd (fd, u_fd, aid, "[Slot/CID: %d/%d] %s | %s | Nível: %d/%d | %s", char_num, char_id, name, job_name (class_), base_level, job_level, online ? "On" : "Off");
			}
		}

		Sql_FreeResult (sql_handle);
	}

	return;
}
Example #7
0
void mapif_parse_accinfo2(bool success, int map_fd, int u_fd, int u_aid, int account_id, const char *userid, const char *user_pass, const char *email, const char *last_ip, const char *lastlogin, const char *pin_code, const char *birthdate, int group_id, int logincount, int state) {
	if (map_fd <= 0 || !session_isActive(map_fd))
		return; // check if we have a valid fd

	if (!success) {
		inter_msg_to_fd(map_fd, u_fd, u_aid, "Nenhuma conta com ID '%d' foi encontrada.", account_id);
		return;
	}

	inter_msg_to_fd(map_fd, u_fd, u_aid, "-- Conta %d --", account_id);
	inter_msg_to_fd(map_fd, u_fd, u_aid, "Usuário: %s | Nível de Conta: %d | Estado: %d", userid, group_id, state);

	if (user_pass && *user_pass != '\0') { /* password is only received if your gm level is greater than the one you're searching for */
		if (pin_code && *pin_code != '\0')
			inter_msg_to_fd(map_fd, u_fd, u_aid, "Senha: %s (PIN:%s)", user_pass, pin_code);
		else
			inter_msg_to_fd(map_fd, u_fd, u_aid, "Senha: %s", user_pass );
	}

	inter_msg_to_fd(map_fd, u_fd, u_aid, "E-mail da conta: %s | Data de Aniversário: %s", email, birthdate);
	inter_msg_to_fd(map_fd, u_fd, u_aid, "Último IP: %s (%s)", last_ip, geoip_getcountry(str2ip(last_ip)));
	inter_msg_to_fd(map_fd, u_fd, u_aid, "Este usuário já logou %d vezes. Última vez em:  %s", logincount, lastlogin);
	inter_msg_to_fd(map_fd, u_fd, u_aid, "-- Detalhes do Personagem --");

	if ( SQL_ERROR == SQL->Query(sql_handle, "SELECT `char_id`, `name`, `char_num`, `class`, `base_level`, `job_level`, `online` "
	                                         "FROM `%s` WHERE `account_id` = '%d' ORDER BY `char_num` LIMIT %d", char_db, account_id, MAX_CHARS)
	  || SQL->NumRows(sql_handle) == 0 ) {
		if (SQL->NumRows(sql_handle) == 0) {
			inter_msg_to_fd(map_fd, u_fd, u_aid, "Esta conta não possui personagens.");
		} else {
			inter_msg_to_fd(map_fd, u_fd, u_aid, "Falha na pesquisa de dados.");
			Sql_ShowDebug(sql_handle);
		}
	} else {
		while ( SQL_SUCCESS == SQL->NextRow(sql_handle) ) {
			char *data;
			int char_id, class_;
			short char_num, base_level, job_level, online;
			char name[NAME_LENGTH];

			SQL->GetData(sql_handle, 0, &data, NULL); char_id = atoi(data);
			SQL->GetData(sql_handle, 1, &data, NULL); safestrncpy(name, data, sizeof(name));
			SQL->GetData(sql_handle, 2, &data, NULL); char_num = atoi(data);
			SQL->GetData(sql_handle, 3, &data, NULL); class_ = atoi(data);
			SQL->GetData(sql_handle, 4, &data, NULL); base_level = atoi(data);
			SQL->GetData(sql_handle, 5, &data, NULL); job_level = atoi(data);
			SQL->GetData(sql_handle, 6, &data, NULL); online = atoi(data);

			inter_msg_to_fd(map_fd, u_fd, u_aid, "[Slot/CID: %d/%d] %s | %s | Nível: %d/%d | %s", char_num, char_id, name, job_name(class_), base_level, job_level, online?"On":"Off");
		}
	}
	SQL->FreeResult(sql_handle);

	return;
}
Example #8
0
/* [Dekamaster/Nightroad] */
void mapif_parse_accinfo(int fd) {
	int u_fd = RFIFOL(fd,2), aid = RFIFOL(fd,6), castergroup = RFIFOL(fd,10);
	char query[NAME_LENGTH], query_esq[NAME_LENGTH*2+1];
	int account_id;
	char *data;

	safestrncpy(query, (char*) RFIFOP(fd,14), NAME_LENGTH);

	SQL->EscapeString(sql_handle, query_esq, query);

	account_id = atoi(query);

	if (account_id < START_ACCOUNT_NUM) {	// is string
		if ( SQL_ERROR == SQL->Query(sql_handle, "SELECT `account_id`,`name`,`class`,`base_level`,`job_level`,`online` FROM `%s` WHERE `name` LIKE '%s' LIMIT 10", char_db, query_esq)
				|| SQL->NumRows(sql_handle) == 0 ) {
			if( SQL->NumRows(sql_handle) == 0 ) {
				inter_msg_to_fd(fd, u_fd, aid, "Nenhum dado foi retornado com base nos parâmetros da pesquisa: '%s'",query);
			} else {
				Sql_ShowDebug(sql_handle);
				inter_msg_to_fd(fd, u_fd, aid, "Falha na pesquisa de dados.");
			}
			SQL->FreeResult(sql_handle);
			return;
		} else {
			if( SQL->NumRows(sql_handle) == 1 ) {//we found a perfect match
				SQL->NextRow(sql_handle);
				SQL->GetData(sql_handle, 0, &data, NULL); account_id = atoi(data);
				SQL->FreeResult(sql_handle);
			} else {// more than one, listing... [Dekamaster/Nightroad]
				inter_msg_to_fd(fd, u_fd, aid, "Sua pesquisa retornou %d resultados. Por favor, seja mais especifico...",(int)SQL->NumRows(sql_handle));
				while ( SQL_SUCCESS == SQL->NextRow(sql_handle) ) {
					int class_;
					short base_level, job_level, online;
					char name[NAME_LENGTH];

					SQL->GetData(sql_handle, 0, &data, NULL); account_id = atoi(data);
					SQL->GetData(sql_handle, 1, &data, NULL); safestrncpy(name, data, sizeof(name));
					SQL->GetData(sql_handle, 2, &data, NULL); class_ = atoi(data);
					SQL->GetData(sql_handle, 3, &data, NULL); base_level = atoi(data);
					SQL->GetData(sql_handle, 4, &data, NULL); job_level = atoi(data);
					SQL->GetData(sql_handle, 5, &data, NULL); online = atoi(data);

					inter_msg_to_fd(fd, u_fd, aid, "[AID: %d] %s | %s | Nível: %d/%d | %s", account_id, name, job_name(class_), base_level, job_level, online?"Online":"Offline");
				}
				SQL->FreeResult(sql_handle);
				return;
			}
		}
	}

	/* it will only get here if we have a single match */
	/* and we will send packet with account id to login server asking for account info */
	if( account_id ) {
		mapif_on_parse_accinfo(account_id, u_fd, aid, castergroup, fd);
	}

	return;
}
Example #9
0
void mapif_parse_accinfo2(bool success, int map_fd, int u_fd, int u_aid, int account_id, const char *userid, const char *user_pass, const char *email, const char *last_ip, const char *lastlogin, const char *pin_code, const char *birthdate, int group_id, int logincount, int state) {
	if (map_fd <= 0 || !session_isActive(map_fd))
		return; // check if we have a valid fd

	if (!success) {
		inter_msg_to_fd(map_fd, u_fd, u_aid, "No account with ID '%d' was found.", account_id);
		return;
	}

	inter_msg_to_fd(map_fd, u_fd, u_aid, "-- Account %d --", account_id);
	inter_msg_to_fd(map_fd, u_fd, u_aid, "User: %s | GM Group: %d | State: %d", userid, group_id, state);

	if (user_pass && *user_pass != '\0') { /* password is only received if your gm level is greater than the one you're searching for */
		if (pin_code && *pin_code != '\0')
			inter_msg_to_fd(map_fd, u_fd, u_aid, "Password: %s (PIN:%s)", user_pass, pin_code);
		else
			inter_msg_to_fd(map_fd, u_fd, u_aid, "Password: %s", user_pass );
	}

	inter_msg_to_fd(map_fd, u_fd, u_aid, "Account e-mail: %s | Birthdate: %s", email, birthdate);
	inter_msg_to_fd(map_fd, u_fd, u_aid, "Last IP: %s (%s)", last_ip, geoip_getcountry(str2ip(last_ip)));
	inter_msg_to_fd(map_fd, u_fd, u_aid, "This user has logged %d times, the last time were at %s", logincount, lastlogin);
	inter_msg_to_fd(map_fd, u_fd, u_aid, "-- Character Details --");

	if ( SQL_ERROR == SQL->Query(sql_handle, "SELECT `char_id`, `name`, `char_num`, `class`, `base_level`, `job_level`, `online` "
	                                         "FROM `%s` WHERE `account_id` = '%d' ORDER BY `char_num` LIMIT %d", char_db, account_id, MAX_CHARS)
	  || SQL->NumRows(sql_handle) == 0 ) {
		if (SQL->NumRows(sql_handle) == 0) {
			inter_msg_to_fd(map_fd, u_fd, u_aid, "This account doesn't have characters.");
		} else {
			inter_msg_to_fd(map_fd, u_fd, u_aid, "An error occurred, bother your admin about it.");
			Sql_ShowDebug(sql_handle);
		}
	} else {
		while ( SQL_SUCCESS == SQL->NextRow(sql_handle) ) {
			char *data;
			int char_id, class_;
			short char_num, base_level, job_level, online;
			char name[NAME_LENGTH];

			SQL->GetData(sql_handle, 0, &data, NULL); char_id = atoi(data);
			SQL->GetData(sql_handle, 1, &data, NULL); safestrncpy(name, data, sizeof(name));
			SQL->GetData(sql_handle, 2, &data, NULL); char_num = atoi(data);
			SQL->GetData(sql_handle, 3, &data, NULL); class_ = atoi(data);
			SQL->GetData(sql_handle, 4, &data, NULL); base_level = atoi(data);
			SQL->GetData(sql_handle, 5, &data, NULL); job_level = atoi(data);
			SQL->GetData(sql_handle, 6, &data, NULL); online = atoi(data);

			inter_msg_to_fd(map_fd, u_fd, u_aid, "[Slot/CID: %d/%d] %s | %s | Level: %d/%d | %s", char_num, char_id, name, job_name(class_), base_level, job_level, online?"On":"Off");
		}
	}
	SQL->FreeResult(sql_handle);

	return;
}