TDP4 Admin Login Test
Snippet of Source Code
package com.darkness.tdp4.components.ui { import flash.display.Sprite; import com.darkness.tdp4.components.ui.admin.view.AdminDiscountPanelUI; import com.darkness.tdp4.components.ui.admin.view.AdminAuthFormUI; import com.darkness.tdp4.components.ui.admin.view.AdminUserListUI; import com.darkness.tdp4.components.ui.admin.view.AdminRequestPanelUI; import com.darkness.tdp4.components.ui.admin.view.AdminActionsPanelUI; import com.darkness.tdp4.components.ui.admin.view.AdminBalanceHistoryListUI; import com.darkness.tdp4.components.ui.view.main.otherUserData.OtherUserDataUI; import com.darkness.tdp4.components.ui.admin.view.AdminNewsPaneUI; import com.darkness.tdp4.components.ui.admin.delegate.HTTPServer; import com.darkness.tdp4.api.ui.IProfileSkinManagerUI; import com.darkness.loader.Loader; import com.darkness.tdp4.vo.ClientDataVo; import com.darkness.tdp4.vo.UserDataVo; import com.darkness.tdp4.components.ui.admin.event.HTTPEvent; import com.darkness.tdp4.components.ui.admin.vo.ServerAdminDataVo; import com.darkness.view.alert.Alert; import com.darkness.tdp4.components.ui.admin.delegate.HTTPActions; import com.darkness.tdp4.components.ui.admin.vo.UserDataVo; import com.darkness.tdp4.components.ui.admin.vo.BalanceHistoryDataVo; import com.darkness.tdp4.vo.ServerUIDataVo; import com.darkness.view.alert.PenderObj; import com.darkness.tdp4.components.ui.admin.event.AdminEvent; import flash.events.Event; import flash.display.StageScaleMode; import flash.display.StageAlign; import movie.MovieUtils; import flash.display.DisplayObject; import com.darkness.tdp4.vo.SkillsVo; import flash.events.IOErrorEvent; import flash.system.LoaderContext; import flash.system.ApplicationDomain; public class AdminEngine extends Sprite { public function AdminEngine() { super(); addEventListener(Event.ADDED_TO_STAGE,this.added); addEventListener(Event.REMOVED_FROM_STAGE,this.removed); } private var border:Border; private var discountPanelUI:AdminDiscountPanelUI; private var authUI:AdminAuthFormUI; private var userListUI:AdminUserListUI; private var reqPanelUI:AdminRequestPanelUI; private var actionsPanelUI:AdminActionsPanelUI; private var balanceListUI:AdminBalanceHistoryListUI; private var userInfoUI:OtherUserDataUI; private var newsPaneUI:AdminNewsPaneUI; private var httpServer:HTTPServer; private var allUI:Array; private var profileSkinManager:IProfileSkinManagerUI; private var skinLoader:Loader; private var clientData:ClientDataVo; private var userData:com.darkness.tdp4.vo.UserDataVo; private function gotAdminData(param1:HTTPEvent) : void { var _loc2_:ServerAdminDataVo = null; var _loc3_:String = null; Alert.clearTooltipObject(); _loc2_ = param1.data as ServerAdminDataVo; switch(_loc2_.action) { case HTTPActions.SET_UPDATE_STEAM: if(_loc2_.result == "OK") { Alert.show("OK",true); } else { Alert.show("Error",true); } break; case HTTPActions.GET_CLAN_INFO: _loc3_ = "CLAN ID: " + _loc2_.response.clan.id + "\nCLAN OFFICIAL: " + _loc2_.response.clan.official + "\nCLAN NAME: " + _loc2_.response.clan.name + "\nCLAN SHORT NAME: " + _loc2_.response.clan.shortName + "\nCLAN LEADER: " + _loc2_.response.clan.createdUserId + "\nCLAN OFFICER 1: " + _loc2_.response.clan.moderator1 + "\nCLAN OFFICER 2: " + _loc2_.response.clan.moderator2 + "\nCLAN MEMBERS COUNT: " + _loc2_.response.clan.membersCount; if(_loc2_.result == "OK") { Alert.show1Button(_loc3_,"OK",null,true,false,false); } else { Alert.show1Button("Something went wrong"); } break; case HTTPActions.SET_CLAN_OFFICIAL: if(_loc2_.result == "OK") { Alert.show1Button("Clan official status set/unset"); } else { Alert.show1Button("Something went wrong"); } break; case HTTPActions.GIVE_CLAN_REWARD: if(_loc2_.result == "OK") { Alert.show1Button("Reward given to " + _loc2_.count + " users"); } else { Alert.show1Button("Something went wrong"); } break; case HTTPActions.FIND_ONLINE: this.handleFindUserOnline(_loc2_); break; case HTTPActions.SEND_MESSAGE: this.handeSendMessageToTheUser(_loc2_); break; case HTTPActions.SEND_NEWS: this.handleSendNews(_loc2_); break; case HTTPActions.CHANGE_NICK: this.handleChangeNick(_loc2_); break; case HTTPActions.UNMUTE: this.handleUnmuteUser(_loc2_); break; case HTTPActions.MUTE: this.handleMuteUser(_loc2_); break; case HTTPActions.SEND_REMOVE_WEAPONS_FROM_SHOP: this.handleRemoveFromShop(_loc2_); break; case HTTPActions.SEND_DISCOUNT_DATA: this.handleDiscountResponse(_loc2_); break; case HTTPActions.LOGIN: this.handleLogin(_loc2_); break; case HTTPActions.GET_USER_LIST_BY_ID: this.handleGetUserListById(_loc2_); break; case HTTPActions.GET_USER_LIST_BY_NICK: this.handleGetUserListByNick(_loc2_); break; case HTTPActions.GET_USER_BALANCE: this.handleGetUserBalance(_loc2_); break; case HTTPActions.BAN: this.handleBan(_loc2_); break; case HTTPActions.UNBAN: this.handleUnBan(_loc2_); break; case HTTPActions.KICK: this.handleKick(_loc2_); break; case HTTPActions.ADD_CASH: this.handleAddCash(_loc2_); break; case HTTPActions.ADD_COINS: this.handleAddCoins(_loc2_); break; case HTTPActions.GET_USER_INFO: this.handleGetUserInfo(_loc2_); break; case HTTPActions.RESET_CLAN: this.handleClanReset(_loc2_); break; } } private function handleFindUserOnline(param1:ServerAdminDataVo) : void { if(param1.result == "OK" && !(param1.onlineZone == null)) { trace(param1.onlineZoneRoomName); Alert.show1Button("User was last seen on server: " + param1.onlineZone + " in \'" + param1.onlineZoneRoomName + "\'"); } else { Alert.show1Button("User seems to be offline..."); } } private function handeSendMessageToTheUser(param1:ServerAdminDataVo) : void { if(param1.result == "OK") { Alert.show1Button("Message to the user has been set..."); } else { Alert.show1Button("Error occured... try again"); } } private function handleSendNews(param1:ServerAdminDataVo) : void { if(param1.result == "OK") { Alert.show1Button("News have been set..."); } else { Alert.show1Button("Error occured... try again"); } } private function handleChangeNick(param1:ServerAdminDataVo) : void { if(param1.result == "OK") { Alert.show1Button("Nick has been changed..."); } else { Alert.show1Button("Error occured... try again"); } } private function handleUnmuteUser(param1:ServerAdminDataVo) : void { if(param1.result == "OK") { param1.userId = this.actionsPanelUI.userId; param1.muted = false; this.userListUI.unmuteUser(param1); } else { Alert.show1Button("Error occured... try again"); } } private function handleMuteUser(param1:ServerAdminDataVo) : void { if(param1.result == "OK") { param1.userId = this.actionsPanelUI.userId; param1.muted = true; this.userListUI.muteUser(param1); } else { Alert.show1Button("Error occured... try again"); } } private function handleRemoveFromShop(param1:ServerAdminDataVo) : void { if(param1.result == "OK") { Alert.show1Button("Weapon status in shop changed!"); } else { Alert.show1Button("Something went wrong, try again!"); } } private function handleDiscountResponse(param1:ServerAdminDataVo) : void { if(param1.result == "OK") { Alert.show1Button("Discount set"); } else { Alert.show1Button("Something went wrong, ask Max"); } } private function handleClanReset(param1:ServerAdminDataVo) : void { if(param1.result == "OK") { Alert.show1Button("Clan has been reseted!"); } else { Alert.show1Button("Something went wrong, try again!"); } } private function handleLogin(param1:ServerAdminDataVo) : void { if(param1.result == "OK") { this.clientData = new ClientDataVo(); this.clientData.adminsRole = param1.getAdminsRole(param1.adminsRole); this.removeAuthUI(); this.createCommonUI(); } else { Alert.show1Button("Invalid credentials!"); } } private function handleGetUserListById(param1:ServerAdminDataVo) : void { if(param1.result == "OK") { this.userListUI.userList = param1.users; } else { Alert.show1Button("Error occured... try again"); } } private function handleGetUserListByNick(param1:ServerAdminDataVo) : void { if(param1.result == "OK") { this.userListUI.userList = param1.users; } else { Alert.show1Button("Error occured... try again"); } } private function handleGetUserBalance(param1:ServerAdminDataVo) : void { var _loc2_:* = 0; var _loc3_:* = 0; var _loc4_:* = 0; var _loc5_:BalanceHistoryDataVo = null; if(param1.result == "OK") { this.balanceListUI.showSlotMachineBalance = this.reqPanelUI.showSlotCBox.selected; this.balanceListUI.balanceHistory = param1.balance; for each(_loc5_ in param1.balance) { if(!(_loc5_.type == 3) && !(_loc5_.type == 4) && !(_loc5_.type == 6) && !(_loc5_.type == 18) && !(_loc5_.type == 19) && !(_loc5_.type == 21) && !(_loc5_.type == 22)) { if(_loc5_.cash > 0) { _loc2_ = _loc2_ + _loc5_.cash; } if(_loc5_.coins > 0) { _loc3_ = _loc3_ + _loc5_.coins; } _loc4_++; } } this.reqPanelUI.donatedCash.text = _loc2_.toString(); this.reqPanelUI.donatedCoins.text = _loc3_.toString(); this.reqPanelUI.donatedCount.text = _loc4_.toString(); } else { Alert.show1Button("Error occured... try again"); } } private function handleBan(param1:ServerAdminDataVo) : void { if(param1.result == "OK") { param1.userId = this.actionsPanelUI.userId; param1.days = this.actionsPanelUI.banDays; param1.reason = this.actionsPanelUI.banReason; param1.banned = true; this.userListUI.banUser(param1); } else { Alert.show1Button("Error occured... try again"); } } private function handleUnBan(param1:ServerAdminDataVo) : void { if(param1.result == "OK") { param1.userId = this.actionsPanelUI.userId; param1.days = 0; param1.reason = ""; param1.banned = false; this.userListUI.unBanUser(param1); } else { Alert.show1Button("Error occured... try again"); } } private function handleKick(param1:ServerAdminDataVo) : void { if(param1.result != "OK") { Alert.show1Button("Error occured... try again"); } } private function handleAddCash(param1:ServerAdminDataVo) : void { var _loc2_:ServerUIDataVo = null; var _loc3_:* = false; var _loc4_:ServerAdminDataVo = null; if(param1.result == "OK") { _loc2_ = this.userInfoUI.data; _loc2_.cash = _loc2_.cash + this.actionsPanelUI.cash; this.createUserInfoUI(_loc2_); _loc3_ = this.reqPanelUI.showBalanceCBox.selected; if(_loc3_) { if(this.clientData.adminsRole == ServerAdminDataVo.ADMIN || this.clientData.adminsRole == ServerAdminDataVo.SUPER_MOD) { _loc4_ = new ServerAdminDataVo(); _loc4_.action = HTTPActions.GET_USER_BALANCE; _loc4_.userId = this.actionsPanelUI.userId; this.httpServer.sendAdminAction(_loc4_); Alert.showTooltipObject(new PenderObj()); } } } else { Alert.show1Button("Error occured... try again"); } } private function handleAddCoins(param1:ServerAdminDataVo) : void { var _loc2_:ServerUIDataVo = null; var _loc3_:* = false; var _loc4_:ServerAdminDataVo = null; if(param1.result == "OK") { _loc2_ = this.userInfoUI.data; _loc2_.coins = _loc2_.coins + this.actionsPanelUI.coins; this.createUserInfoUI(_loc2_); _loc3_ = this.reqPanelUI.showBalanceCBox.selected; if(_loc3_) { if(this.clientData.adminsRole == ServerAdminDataVo.ADMIN || this.clientData.adminsRole == ServerAdminDataVo.SUPER_MOD) { _loc4_ = new ServerAdminDataVo(); _loc4_.action = HTTPActions.GET_USER_BALANCE; _loc4_.userId = this.actionsPanelUI.userId; this.httpServer.sendAdminAction(_loc4_); Alert.showTooltipObject(new PenderObj()); } } } else { Alert.show1Button("Error occured... try again"); } } private function handleGetUserInfo(param1:ServerAdminDataVo) : void { var _loc2_:* = false; var _loc3_:ServerAdminDataVo = null; if(param1.result == "OK") { if(this.discountPanelUI) { if(this.discountPanelUI.parent) { this.discountPanelUI.parent.removeChild(this.discountPanelUI); } } this.createUserInfoUI(this.convertToUIData(param1)); this.actionsPanelUI.userId = param1.userId; this.reqPanelUI.lastBanReasonTf.text = "-"; if(param1.reason) { this.reqPanelUI.lastBanReasonTf.text = param1.reason; } this.reqPanelUI.adminsId.text = "-"; this.reqPanelUI.lastBanTime.text = "-"; if(param1.banList) { this.reqPanelUI.setbanHistoryList(param1.banList); } if(param1.adminId > 0) { this.reqPanelUI.adminsId.text = param1.adminId.toString(); this.reqPanelUI.lastBanTime.text = param1.banDate; } this.reqPanelUI.donatedCount.text = param1.donateCount.toString(); this.reqPanelUI.donatedCash.text = param1.donateCash.toString(); this.reqPanelUI.donatedCoins.text = param1.donateCoins.toString(); _loc2_ = this.reqPanelUI.showBalanceCBox.selected; if(_loc2_) { if(this.clientData.adminsRole == ServerAdminDataVo.ADMIN || this.clientData.adminsRole == ServerAdminDataVo.SUPER_MOD) { _loc3_ = new ServerAdminDataVo(); _loc3_.action = HTTPActions.GET_USER_BALANCE; _loc3_.userId = param1.userId; this.httpServer.sendAdminAction(_loc3_); Alert.showTooltipObject(new PenderObj()); } } } else { Alert.show1Button("Error occured... try again"); } } private function sendAdminRequest(param1:AdminEvent) : void { Alert.showTooltipObject(new PenderObj()); this.httpServer.sendAdminAction(param1.data); } private function added(param1:Event) : void { removeEventListener(Event.ADDED_TO_STAGE,this.added); stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; Alert.init(this); this.init(); } private function removed(param1:Event) : void { removeEventListener(Event.REMOVED_FROM_STAGE,this.removed); this.removeAuthUI(); this.removeCommonUI(); this.allUI = null; this.border = null; this.unLoadSkinLib(); MovieUtils.clearDisplay(this); } private function init() : void { this.httpServer = new HTTPServer(loaderInfo.parameters["url"]); this.httpServer.addEventListener(HTTPEvent.GOT_ADMIN_DATA,this.gotAdminData); this.httpServer.addEventListener(HTTPEvent.IO_ERROR,this.onOiError); this.loadSkinLib(); } private function onOiError(param1:HTTPEvent) : void { Alert.clearTooltipObject(); Alert.show1Button("An error occured on the server! Maybe current clan has been deleted! Anyway, ask Max"); } private function createUserInfoUI(param1:ServerUIDataVo) : void { this.removeUserInfoUI(); this.actionsPanelUI.visible = true; this.userInfoUI = new OtherUserDataUI(this.clientData,this.userData,this.profileSkinManager,param1,false,false,false,false,false,true); addChild(this.userInfoUI); addChild(this.border); } private function removeUserInfoUI() : void { if(this.userInfoUI) { if(this.userInfoUI.parent) { this.userInfoUI.parent.removeChild(this.userInfoUI); } this.userInfoUI = null; } } private function createAuthUI() : void { this.authUI = new AdminAuthFormUI(); this.authUI.addEventListener(AdminEvent.SEND_ADMIN_REQUEST,this.sendAdminRequest); addChild(this.authUI); } private function removeAuthUI() : void { if(this.authUI) { this.clientData.modsLogin = this.authUI.login; this.authUI.removeEventListener(AdminEvent.SEND_ADMIN_REQUEST,this.sendAdminRequest); if(this.authUI.parent) { this.authUI.parent.removeChild(this.authUI); } this.authUI = null; } } private function createCommonUI() : void { var _loc1_:DisplayObject = null; this.userListUI = new AdminUserListUI(); this.reqPanelUI = new AdminRequestPanelUI(loaderInfo.parameters["url"],this.clientData.adminsRole); this.actionsPanelUI = new AdminActionsPanelUI(this.clientData.adminsRole,this.clientData.modsLogin); this.balanceListUI = new AdminBalanceHistoryListUI(); this.allUI = [this.reqPanelUI,this.userListUI,this.actionsPanelUI,this.balanceListUI]; for each(_loc1_ in this.allUI) { _loc1_.addEventListener(AdminEvent.SEND_ADMIN_REQUEST,this.sendAdminRequest); addChild(_loc1_); } if(this.clientData.adminsRole == ServerAdminDataVo.MOD || this.clientData.adminsRole == ServerAdminDataVo.CURATOR) { this.balanceListUI.pane.visible = false; } this.reqPanelUI.addEventListener("open_news_pane",this.openNewsPane); this.actionsPanelUI.hideFast(); this.border = new Border(); addChild(this.border); } private function openNewsPane(param1:Event) : void { if(!this.newsPaneUI) { this.newsPaneUI = new AdminNewsPaneUI(); this.newsPaneUI.addEventListener("close_news_panel",this.closeNewsPane); this.newsPaneUI.addEventListener(AdminEvent.SEND_ADMIN_REQUEST,this.sendAdminRequest); addChild(this.newsPaneUI); } } private function closeNewsPane(param1:Event) : void { if(this.newsPaneUI) { this.newsPaneUI.removeEventListener("close_news_panel",this.closeNewsPane); this.newsPaneUI.removeEventListener(AdminEvent.SEND_ADMIN_REQUEST,this.sendAdminRequest); removeChild(this.newsPaneUI); this.newsPaneUI = null; } } private function removeCommonUI() : void { var _loc1_:DisplayObject = null; for each(_loc1_ in this.allUI) { if(_loc1_) { _loc1_.removeEventListener(AdminEvent.SEND_ADMIN_REQUEST,this.sendAdminRequest); if(_loc1_.parent) { _loc1_.parent.removeChild(_loc1_); } } } this.discountPanelUI.removeEventListener(AdminEvent.SEND_ADMIN_REQUEST,this.sendAdminRequest); this.reqPanelUI.removeEventListener("open_news_pane",this.openNewsPane); if(this.newsPaneUI) { this.newsPaneUI.removeEventListener("close_news_panel",this.closeNewsPane); this.newsPaneUI.removeEventListener(AdminEvent.SEND_ADMIN_REQUEST,this.sendAdminRequest); this.newsPaneUI = null; } this.discountPanelUI = null; this.userListUI = null; this.reqPanelUI = null; this.actionsPanelUI = null; this.balanceListUI = null; this.userInfoUI = null; } private function convertToUIData(param1:ServerAdminDataVo) : ServerUIDataVo { var _loc2_:ServerUIDataVo = new ServerUIDataVo(); _loc2_.clanId = param1.clanId; _loc2_.shortClanName = param1.shortClanName; _loc2_.userId = param1.userId; _loc2_.nickname = param1.fullNickname; _loc2_.birth = param1.birth; _loc2_.country = param1.country; _loc2_.about = param1.about; _loc2_.skin = param1.skin; _loc2_.color = param1.color; _loc2_.race = param1.race; _loc2_.userRating = param1.userRating; _loc2_.userLevel = param1.userLevel; _loc2_.maxHealth = param1.maxHealth; _loc2_.nextLevelRating = param1.nextLevelRating; _loc2_.cash = param1.cash; _loc2_.coins = param1.coins; _loc2_.globalRating = param1.globalRating; _loc2_.gameDeaths = param1.gameDeaths; _loc2_.gameFlagScore = param1.gameFlagScore; _loc2_.gameFrags = param1.gameFrags; _loc2_.gameTeamScore = param1.gameTeamScore; _loc2_.gameWinner = param1.gameWinner; _loc2_.gameSurvivor = param1.gameSurvivor; _loc2_.skills = param1.skills; _loc2_.artifactObjects = param1.artifactObjects; _loc2_.weaponObjects = param1.weaponObjects; _loc2_.medalObjects = param1.medalObjects; _loc2_.itemObjects = param1.itemObjects; _loc2_.skillPoints = param1.skillPoints; return _loc2_; } private function unLoadSkinLib() : void { if(this.profileSkinManager) { this.profileSkinManager.dispose(); this.profileSkinManager = null; } if(this.skinLoader) { this.skinLoader.unloadAndStop(); this.skinLoader.destroy(); this.skinLoader = null; } } private function loadSkinLib() : void { this.skinLoader = new Loader(); this.skinLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,this.skinLoaded); this.skinLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,this.skinIOError); this.skinLoader.load([loaderInfo.parameters["libURL"]],"/ProfileSkinManagerUI.swf",new LoaderContext(false,ApplicationDomain.currentDomain)); } private function skinLoaded(param1:Event) : void { this.skinLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE,this.skinLoaded); this.skinLoader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR,this.skinIOError); this.profileSkinManager = this.skinLoader.content as IProfileSkinManagerUI; this.createAuthUI(); } private function skinIOError(param1:IOErrorEvent) : void { this.skinLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE,this.skinLoaded); this.skinLoader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR,this.skinIOError); Alert.show1Button("Cannot load skin library! Please download ProfileSkinManagerUI and place in this folder."); } } }