예제 #1
0
void ItemAwardManager::Load(SQLMsg* pMsg)
{
	MYSQL_RES * pRes = pMsg->Get()->pSQLResult;

	for (uint i = 0; i < pMsg->Get()->uiNumRows; ++i)
	{
		MYSQL_ROW row = mysql_fetch_row(pRes);
		int col = 0;

		DWORD dwID = 0;
		str_to_number(dwID, row[col++]);

		if (m_map_award.find(dwID) != m_map_award.end())
			continue;

		TItemAward * kData = new TItemAward;
		memset(kData, 0, sizeof(TItemAward));

		kData->dwID	= dwID;
		trim_and_lower(row[col++], kData->szLogin, sizeof(kData->szLogin));
		str_to_number(kData->dwVnum, row[col++]);
		str_to_number(kData->dwCount, row[col++]);
		str_to_number(kData->dwSocket0, row[col++]);
		str_to_number(kData->dwSocket1, row[col++]);
		str_to_number(kData->dwSocket2, row[col++]);
		str_to_number(kData->bMall, row[col++]);

		if (row[col])
		{
			enhance_strlcpymt(kData->szWhy, row[col], sizeof(kData->szWhy));
			//°ФАУ БЯїЎ whyДЭ·лїЎ єЇµїАМ »э±вёй				
			char* whyStr = kData->szWhy;	//why ДЭ·л АР±в
			char cmdStr[100] = "";	//whyДЭ·лїЎј­ АРАє °ЄА» АУЅГ №®АЪї­їЎ є№»зЗШµТ
			strcpy(cmdStr,whyStr);	//ён·Йѕо ѕтґВ °ъБ¤їЎј­ ЕдЕ«ѕІёй їшє»µµ ЕдЕ«И­ µЗ±в ¶§№®
			char command[20] = "";
			strcpy(command,CClientManager::instance().GetCommand(cmdStr));	// command ѕт±в
			//sys_err("%d,  %s",pItemAward->dwID,command);
			if( !(strcmp(command,"GIFT") ))	// command °Ў GIFTАМёй
			{
				TPacketItemAwardInfromer giftData;
				strcpy(giftData.login, kData->szLogin);	//·О±ЧАО ѕЖАМµр є№»з
				strcpy(giftData.command, command);					//ён·Йѕо є№»з
				giftData.vnum = kData->dwVnum;				//ѕЖАМЕЫ vnumµµ є№»з
				CClientManager::instance().ForwardPacket(HEADER_DG_ITEMAWARD_INFORMER,&giftData,sizeof(TPacketItemAwardInfromer));
			}
		}

		m_map_award.insert(std::make_pair(dwID, kData));

		printf("ITEM_AWARD load id %u bMall %d \n", kData->dwID, kData->bMall);
		sys_log(0, "ITEM_AWARD: load id %lu login %s vnum %lu count %u socket %lu", kData->dwID, kData->szLogin, kData->dwVnum, kData->dwCount, kData->dwSocket0);
		ItemAwardSet& kSet = m_map_kSetAwardByLogin[kData->szLogin];
		kSet.insert(kData);

		if (dwID > g_dwLastCachedItemAwardID)
			g_dwLastCachedItemAwardID = dwID;
	}
}
예제 #2
0
void CInputAuth::LoginOpenID(LPDESC d, const char * c_pData)
{
#ifdef ENABLE_LIMIT_TIME
#endif
    //OpenID test code.
    TPacketCGLogin5 *tempInfo1 = (TPacketCGLogin5 *)c_pData;

    //일본 웹 서버에 인증키 확인 요청을 보낸다.
    char* authKey = tempInfo1->authKey;
    char returnID[LOGIN_MAX_LEN + 1] = {0};

    int test_url_get_protocol = auth_OpenID(authKey, inet_ntoa(d->GetAddr().sin_addr), returnID);

    //인증 실패. 에러 처리
    if (0!=test_url_get_protocol)
    {
        LoginFailure(d, "OpenID Fail");
        return;
    }

    TPacketCGLogin3 tempInfo2;
    strncpy(tempInfo2.login, returnID, LOGIN_MAX_LEN);
    strncpy(tempInfo2.passwd, "0000", PASSWD_MAX_LEN);
    for(int i=0; i<4; i++)
        tempInfo2.adwClientKey[i] = tempInfo1->adwClientKey[i];
    TPacketCGLogin3 * pinfo = &tempInfo2;

    if (!g_bAuthServer)
    {
        sys_err ("CInputAuth class is not for game server. IP %s might be a hacker.",
                 inet_ntoa(d->GetAddr().sin_addr));
        d->DelayedDisconnect(5);
        return;
    }

    // string 무결성을 위해 복사
    char login[LOGIN_MAX_LEN + 1];
    trim_and_lower(pinfo->login, login, sizeof(login));

    char passwd[PASSWD_MAX_LEN + 1];
    strlcpy(passwd, pinfo->passwd, sizeof(passwd));

    sys_log(0, "InputAuth::Login : %s(%d) desc %p",
            login, strlen(login), get_pointer(d));

    // check login string
    if (false == FN_IS_VALID_LOGIN_STRING(login))
    {
        sys_log(0, "InputAuth::Login : IS_NOT_VALID_LOGIN_STRING(%s) desc %p",
                login, get_pointer(d));
        LoginFailure(d, "NOID");
        return;
    }

    if (g_bNoMoreClient)
    {
        TPacketGCLoginFailure failurePacket;

        failurePacket.header = HEADER_GC_LOGIN_FAILURE;
        strlcpy(failurePacket.szStatus, "SHUTDOWN", sizeof(failurePacket.szStatus));

        d->Packet(&failurePacket, sizeof(failurePacket));
        return;
    }

    if (DESC_MANAGER::instance().FindByLoginName(login))
    {
        LoginFailure(d, "ALREADY");
        return;
    }

    DWORD dwKey = DESC_MANAGER::instance().CreateLoginKey(d);
    DWORD dwPanamaKey = dwKey ^ pinfo->adwClientKey[0] ^ pinfo->adwClientKey[1] ^ pinfo->adwClientKey[2] ^ pinfo->adwClientKey[3];
    d->SetPanamaKey(dwPanamaKey);

    sys_log(0, "InputAuth::Login : key %u:0x%x login %s", dwKey, dwPanamaKey, login);

    // BRAZIL_AUTH
    if (LC_IsBrazil() && !test_server)
    {
        int result = auth_brazil(login, passwd);

        switch (result)
        {
        case AUTH_BRAZIL_SERVER_ERR:
        case AUTH_BRAZIL_NOID:
            LoginFailure(d, "NOID");
            return;
        case AUTH_BRAZIL_WRONGPWD:
            LoginFailure(d, "WRONGPWD");
            return;
        case AUTH_BRAZIL_FLASHUSER:
            LoginFailure(d, "FLASH");
            return;
        }
    }

    TPacketCGLogin3 * p = M2_NEW TPacketCGLogin3;
    thecore_memcpy(p, pinfo, sizeof(TPacketCGLogin3));

    char szPasswd[PASSWD_MAX_LEN * 2 + 1];
    DBManager::instance().EscapeString(szPasswd, sizeof(szPasswd), passwd, strlen(passwd));

    char szLogin[LOGIN_MAX_LEN * 2 + 1];
    DBManager::instance().EscapeString(szLogin, sizeof(szLogin), login, strlen(login));

    // CHANNEL_SERVICE_LOGIN
    if (Login_IsInChannelService(szLogin))
    {
        sys_log(0, "ChannelServiceLogin [%s]", szLogin);

        DBManager::instance().ReturnQuery(QID_AUTH_LOGIN_OPENID, dwKey, p,
                                          "SELECT '%s',password,securitycode,social_id,id,status,availDt - NOW() > 0,"
                                          "UNIX_TIMESTAMP(silver_expire),"
                                          "UNIX_TIMESTAMP(gold_expire),"
                                          "UNIX_TIMESTAMP(safebox_expire),"
                                          "UNIX_TIMESTAMP(autoloot_expire),"
                                          "UNIX_TIMESTAMP(fish_mind_expire),"
                                          "UNIX_TIMESTAMP(marriage_fast_expire),"
                                          "UNIX_TIMESTAMP(money_drop_rate_expire),"
                                          "UNIX_TIMESTAMP(create_time)"
                                          " FROM account WHERE login='******'",

                                          szPasswd, szLogin);
    }
    // END_OF_CHANNEL_SERVICE_LOGIN
    else
    {
        DBManager::instance().ReturnQuery(QID_AUTH_LOGIN_OPENID, dwKey, p,
                                          "SELECT PASSWORD('%s'),password,securitycode,social_id,id,status,availDt - NOW() > 0,"
                                          "UNIX_TIMESTAMP(silver_expire),"
                                          "UNIX_TIMESTAMP(gold_expire),"
                                          "UNIX_TIMESTAMP(safebox_expire),"
                                          "UNIX_TIMESTAMP(autoloot_expire),"
                                          "UNIX_TIMESTAMP(fish_mind_expire),"
                                          "UNIX_TIMESTAMP(marriage_fast_expire),"
                                          "UNIX_TIMESTAMP(money_drop_rate_expire),"
                                          "UNIX_TIMESTAMP(create_time)"
                                          " FROM account WHERE login='******'",
                                          szPasswd, szLogin);
    }
}