bool CClient::OnRxAxis( const byte * pData, size_t iLen ) { ADDTOCALLSTACK("CClient::OnRxAxis"); if ( !iLen || ( GetConnectType() != CONNECT_AXIS )) return false; while ( iLen -- ) { int iRet = OnConsoleKey( m_Targ_Text, *pData++, GetAccount() != NULL ); if ( ! iRet ) return false; if ( iRet == 2 ) { if ( GetAccount() == NULL ) { if ( !m_zLogin[0] ) { if ( (uint)(m_Targ_Text.GetLength()) <= (CountOf(m_zLogin) - 1) ) strcpy(m_zLogin, m_Targ_Text); m_Targ_Text.Empty(); } else { CSString sMsg; CAccountRef pAccount = g_Accounts.Account_Find(m_zLogin); if (( pAccount == NULL ) || ( pAccount->GetPrivLevel() < PLEVEL_Counsel )) { SysMessagef("\"MSG:%s\"", g_Cfg.GetDefaultMsg(DEFMSG_AXIS_NOT_PRIV)); m_Targ_Text.Empty(); return false; } if ( LogIn(m_zLogin, m_Targ_Text, sMsg ) == PacketLoginError::Success ) { m_Targ_Text.Empty(); if ( GetPrivLevel() < PLEVEL_Counsel ) { SysMessagef("\"MSG:%s\"", g_Cfg.GetDefaultMsg(DEFMSG_AXIS_NOT_PRIV)); return false; } if (GetPeer().IsValidAddr()) { CScriptTriggerArgs Args; Args.m_VarsLocal.SetStrNew("Account",GetName()); Args.m_VarsLocal.SetStrNew("IP",GetPeer().GetAddrStr()); TRIGRET_TYPE tRet = TRIGRET_RET_DEFAULT; r_Call("f_axis_preload", this, &Args, NULL, &tRet); if ( tRet == TRIGRET_RET_FALSE ) return false; if ( tRet == TRIGRET_RET_TRUE ) { SysMessagef("\"MSG:%s\"", g_Cfg.GetDefaultMsg(DEFMSG_AXIS_DENIED)); return false; } time_t dateChange; dword dwSize; if ( ! CSFileList::ReadFileInfo( "Axis.db", dateChange, dwSize )) { SysMessagef("\"MSG:%s\"", g_Cfg.GetDefaultMsg(DEFMSG_AXIS_INFO_ERROR)); return false; } CSFile FileRead; if ( ! FileRead.Open( "Axis.db", OF_READ|OF_BINARY )) { SysMessagef("\"MSG:%s\"", g_Cfg.GetDefaultMsg(DEFMSG_AXIS_FILE_ERROR)); return false; } tchar szTmp[8*1024]; PacketWeb packet; for (;;) { size_t iLength = FileRead.Read( szTmp, sizeof( szTmp ) ); if ( iLength <= 0 ) break; packet.setData((byte*)szTmp, iLength); packet.send(this); dwSize -= (dword)iLength; if ( dwSize <= 0 ) break; } return true; } return false; } else if ( ! sMsg.IsEmpty()) { SysMessagef("\"MSG:%s\"", (lpctstr)sMsg); return false; } m_Targ_Text.Empty(); } return true; } } } return true; }
bool CClient::OnRxConsole( const byte * pData, size_t iLen ) { ADDTOCALLSTACK("CClient::OnRxConsole"); // A special console version of the client. (Not game protocol) if ( !iLen || ( GetConnectType() != CONNECT_TELNET )) return false; if ( IsSetEF( EF_AllowTelnetPacketFilter ) ) { bool fFiltered = xPacketFilter(pData, iLen); if ( fFiltered ) return fFiltered; } while ( iLen -- ) { int iRet = OnConsoleKey( m_Targ_Text, *pData++, GetAccount() != NULL ); if ( ! iRet ) return false; if ( iRet == 2 ) { if ( GetAccount() == NULL ) { if ( !m_zLogin[0] ) { if ( (uint)(m_Targ_Text.GetLength()) > (CountOf(m_zLogin) - 1) ) { SysMessage("Login:\n"); } else { strcpy(m_zLogin, m_Targ_Text); SysMessage("Password:\n"); } m_Targ_Text.Empty(); } else { CSString sMsg; CAccountRef pAccount = g_Accounts.Account_Find(m_zLogin); if (( pAccount == NULL ) || ( pAccount->GetPrivLevel() < PLEVEL_Admin )) { SysMessagef("%s\n", g_Cfg.GetDefaultMsg(DEFMSG_CONSOLE_NOT_PRIV)); m_Targ_Text.Empty(); return false; } if ( LogIn(m_zLogin, m_Targ_Text, sMsg ) == PacketLoginError::Success ) { m_Targ_Text.Empty(); return OnRxConsoleLoginComplete(); } else if ( ! sMsg.IsEmpty()) { SysMessage( sMsg ); return false; } m_Targ_Text.Empty(); } return true; } else { iRet = g_Serv.OnConsoleCmd( m_Targ_Text, this ); if (g_Cfg.m_fTelnetLog && GetPrivLevel() >= g_Cfg.m_iCommandLog) g_Log.Event(LOGM_GM_CMDS, "%x:'%s' commands '%s'=%d\n", GetSocketID(), GetName(), static_cast<lpctstr>(m_Targ_Text), iRet); } } } return true; }