Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |
00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 00030 00031 00032 00033 00034 00035 00036 00037 00038 00039 00040 00041 00042 00043 00044 00045 00046 00047 00048 00049 00050 00051 00052 00053 00054 00055 00056 00057 00058 00059 00060 00061 00062 00063 00064 00065 00066 00067 00068 00069 00070 00071 00072 00073 00074 00075 00076 00077 00078 00079 00080 00081 00082 00083 00084 00085 00086 00087 00088 00089 00090 00091 00092 00093 00094 00095 00096 00097 00098 00099 00100 00101 00102 00103 00104 00105 00106 00107 00108 00109 00110 00111 00112 00113 00114 00115 00116 00117 00118 00119 00120 00121 00122 00123 00124 00125 00126 00127 00128 00129 00130 00131 00132 00133 00134 00135 00136 00137 00138 00139 00140 00141 00142 00143 00144 00145 00146 00147 00148 00149 00150 00151 00152 00153 00154 00155 00156 00157 00158 00159 00160 00161 00162 00163 00164 00165 00166 00167 00168 00169 00170 00171 00172 00173 00174 00175 00176 00177 00178 00179 00180 00181 00182 00183 00184 00185 00186 00187 00188 00189 00190 00191 00192 00193 00194 00195 00196 00197 00198 00199 00200 00201 00202 00203 00204 00205 00206 00207 00208 00209 00210 00211 00212 00213 00214 00215 00216 00217 00218 00219 00220 00221 00222 00223 00224 00225 00226 00227 00228 00229 00230 00231 00232 00233 00234 00235 00236 00237 00238 00239 00240 00241 00242 00243 00244 00245 00246 00247 00248 00249 00250 00251 00252 00253 00254 00255 00256 00257 00258 00259 00260 00261 00262 00263 00264 00265 00266 00267 00268 00269 00270 00271 00272 00273 00274 00275 00276 00277 00278 00279 00280 00281 00282 00283 00284 00285 00286 00287 00288 00289 00290 00291 00292 00293 00294 00295 00296 00297 00298 00299 00300 00301 00302 00303 00304 00305 00306 00307 00308 00309 00310 00311 00312 00313 00314 00315 00316 00317 00318 00319 00320 00321 00322 00323 00324 00325 00326 00327 00328 00329 00330 00331 00332 00333 00334 00335 00336 00337 00338 00339 00340 00341 00342 00343 00344 00345 00346 00347 00348 00349 00350 00351 00352 00353 00354 00355 00356 00357 00358 00359 00360 00361 00362 00363 00364 00365 00366 00367 00368 00369 00370 00371 00372 00373 00374 00375 00376 00377 00378 00379 00380 00381 00382 00383 00384 00385 00386 00387 00388 00389 00390 00391 00392 00393 00394 00395 00396 00397 00398 00399 00400 00401 00402 00403 00404 00405 00406 00407 00408 00409 00410 00411 00412 00413 00414 00415 00416 00417 00418 00419 00420 00421 00422 00423 00424 00425 00426 00427 00428 00429 00430 00431 00432 00433 00434 00435 00436 00437 00438 00439 00440 00441 00442 00443 00444 00445 00446 00447 00448 00449 00450 00451 00452 00453 00454 00455 00456 00457 00458 00459 00460 00461 00462 00463 00464 00465 00466 00467 00468 00469 00470 00471 00472 00473 00474 00475 00476 00477 00478 00479 00480 00481 00482 00483 00484 00485 00486 00487 00488 00489 00490 00491 00492 00493 00494 00495 00496 00497 00498 00499 00500 00501 00502 00503 00504 00505 00506 00507 00508 00509 00510 00511 00512 00513 00514 00515 00516 00517 00518 00519 00520 00521 00522 00523 00524 00525 00526 00527 00528 00529 00530 00531 00532 00533 00534 00535 00536 00537 00538 00539 00540 00541 00542 00543 00544 00545 00546 00547 00548 00549 00550 00551 00552 00553 00554 00555 00556 00557 00558 00559 00560 00561 00562 00563 00564 00565 00566 00567 00568 00569 00570 00571 00572 00573 00574 00575 00576 00577 00578 00579 00580 00581 00582 00583 00584 00585 00586 00587 00588 00589 00590 00591 00592 00593 00594 00595 00596 00597 00598 00599 00600 00601 00602 00603 00604 00605 00606 00607 00608 00609 00610 00611 00612 00613 00614 00615 00616 00617 00618 00619 00620 00621 00622 00623 00624 00625 00626 00627 00628 00629 00630 00631 00632 00633 00634 00635 00636 00637 00638 00639 00640 00641 00642 00643 00644 00645 00646 00647 00648 00649 00650 00651 00652 00653 00654 00655 00656 00657 00658 00659 00660 00661 00662 00663 00664 00665 00666 00667 00668 00669 00670 00671 00672 00673 00674 00675 00676 00677 00678 00679 00680 00681 00682 00683 00684 00685 00686 00687 00688 00689 00690 00691 00692 00693 00694 00695 00696 00697 00698 00699 00700 00701 00702 00703 00704 00705 00706 00707 00708 00709 00710 00711 00712 00713 00714 00715 00716 00717 00718 00719 00720 00721 00722 00723 00724 00725 00726 00727 00728 00729 00730 00731 00732 00733 00734 00735 00736 00737 00738 00739 00740 00741 00742 00743 00744 00745 00746 00747 00748 00749 00750 00751 00752 00753 00754 00755 00756 00757 00758 00759 00760 00761 00762 00763 00764 00765 00766 00767 00768 00769 00770 00771 00772 00773 00774 00775 00776 00777 00778 00779 00780 00781 00782 00783 00784 00785 00786 00787 00788 00789 00790 00791 00792 00793 00794 00795 00796 00797 00798 00799 00800 00801 00802 00803 00804 00805 00806 00807 00808 00809 00810 00811 00812 00813 00814 00815 00816 00817 00818 00819 00820 00821 00822 00823 00824 00825 00826 00827 00828 00829 00830 00831 00832 00833 00834 00835 00836 00837 00838 00839 00840 00841 00842 00843 00844 00845 00846 00847 00848 00849 00850 00851 00852 00853 00854 00855 00856 00857 00858 00859 00860 00861 00862 00863 00864 00865 00866 00867 00868 00869 00870 00871 00872 00873 00874 00875 00876 00877 00878 00879 00880 00881 00882 00883 00884 00885 00886 00887 00888 00889 00890 00891 00892 00893 00894 00895 00896 00897 00898 00899 00900 00901 00902 00903 00904 00905 00906 00907 00908 00909 00910 00911 00912 00913 00914 00915 00916 00917 00918 00919 00920 00921 00922 00923 00924 00925 00926 00927 00928 00929 00930 00931 00932 00933 00934 00935 00936 00937 00938 00939 00940 00941 00942 00943 00944 00945 00946 00947 00948 00949 00950 00951 00952 00953 00954 00955 00956 00957 00958 00959 00960 00961 00962 00963 00964 00965 00966 00967 00968 00969 00970 00971 00972 00973 00974 00975 00976 00977 00978 00979 00980 00981 00982 00983 00984 00985 00986 00987 00988 00989 00990 00991 00992 00993 00994 00995 00996 00997 00998 00999 01000 01001 01002 01003 01004 01005 01006 01007 01008 01009 01010 01011 01012 01013 01014 01015 01016 01017 01018 01019 01020 01021 01022 01023 01024 01025 01026 01027 01028 01029 01030 01031 01032 01033 01034 01035 01036 01037 01038 01039 01040 01041 01042 01043 01044 01045 01046 01047 01048 01049 01050 01051 01052 01053 01054 01055 01056 01057 01058 01059 01060 01061 01062 01063 01064 01065 01066 01067 01068 01069 01070 01071 01072 01073 01074 01075 01076 01077 01078 01079 01080 01081 01082 01083 01084 01085 01086 01087 01088 01089 01090 01091 01092 01093 01094 01095 01096 01097 01098 01099 01100 01101 01102 01103 01104 01105 01106 01107 01108 01109 01110 01111 01112 01113 01114 01115 01116 01117 01118 01119 01120 01121 01122 01123 01124 01125 01126 01127 01128 01129 01130 01131 01132 01133 01134 01135 01136 01137 01138 01139 01140 01141 01142 01143 01144 01145 01146 01147 01148 01149 01150 01151 01152 01153 01154 01155 01156 01157 01158 01159 01160 01161 01162 01163 01164 01165 01166 01167 01168 01169 01170 01171 01172 01173 01174 01175 01176 01177 01178 01179 01180 01181 01182 01183 01184 01185 01186 01187 01188 01189 01190 01191 01192 01193 01194 01195 01196 01197 01198 01199 01200 01201 01202 01203 01204 01205 01206 01207 01208 01209 01210 01211 01212 01213 01214 01215 01216 01217 01218 01219 01220 01221 01222 01223 01224 01225 01226 01227 01228 01229 01230 01231 01232 01233 01234 01235 01236 01237 01238 01239 01240 01241 01242 01243 01244 01245 01246 01247 01248 01249 01250 01251 01252 01253 01254 01255 01256 01257 01258 01259 01260 01261 01262 01263 01264 01265 01266 01267 01268 01269 01270 01271 01272 01273 01274 01275 01276 01277 01278 01279 01280 01281 01282 01283 01284 01285 01286 01287 01288 01289 01290 01291 01292 01293 01294 01295 01296 01297 01298 01299 01300 01301 01302 01303 01304 01305 01306 01307 01308 01309 01310 01311 01312 01313 01314 01315 01316 01317 01318 01319 01320 01321 01322 01323 01324 01325 01326 01327 01328 01329 01330 01331 01332 01333 01334 01335 01336 01337 01338 01339 01340 01341 01342 01343 01344 01345 01346 01347 01348 01349 01350 01351 01352 01353 01354 01355 01356 01357 01358 01359 01360 01361 01362 01363 01364 |
//============================================================================== // Web Application to handle remote administration of server // // Revised by Micheal Comeau // Revised by Ron Prestenback // © 1998-2004, Epic Games, Inc. All Rights Reserved //============================================================================== class UTServerAdmin extends WebApplication config; // TODO: // Do something with colspan.inc var config string ActiveSkin; // Each query handler represents a section in webadmin var() config array<string> QueryHandlerClasses; var array<xWebQueryHandler> QueryHandlers; // Global Objects var() array<class<WebSkin> > WebSkins; // array of webadmin skins var() class<UTServerAdminSpectator> SpectatorType; var() class<WebSkin> DefaultWebSkinClass; var WebSkin CurrentSkin;// Currently loaded webadmin skin var UTServerAdminSpectator Spectator; // Used to get console messages var xAdminUser CurAdmin; // Currently logged admin (not thread safe) var PlayInfo GamePI; // Contains all confiurable variables var WebResponse Resp; // Non-thread safe reference to a WebResponse object // Lists var array<CacheManager.GameRecord> AllGames; var array<CacheManager.MapRecord> AllMaps; var array<CacheManager.MutatorRecord> AllMutators; // All mutators as determined by .int entries var StringArray AGameType; // All available Game Types var StringArray AExcMutators; // All available Mutators (Excluded) var StringArray AIncMutators; // All Mutators currently in play var StringArray Skins; // All Webadmin custom skins // Characters which aren't rendered correctly in HTML struct HtmlChar { var string Plain; var string Coded; }; var array<HtmlChar> SpecialChars; var config string DefaultBG; // Non-highlighted items var config string HighlightedBG; // Active links // Pages var config string RootFrame; // This is the master frame divided in 2: Top = Header, bottom = frame page var config string HeaderPage; // This is the header menu var config string MessagePage; // Name of the file containing the message template var config string FramedMessagePage; // Name of file containing message template for sub-frames var config string RestartPage; // This is the page that users will be transferred to when restarting the server var string htm; var config string AdminRealm; // Used by browsers to cache login information // HTML variables used for skins var string SkinPath; // Path to use for .htm and .inc content var string SiteCSSFile; // CSS file to use var string SiteBG; // Background color for this skin var string StatusOKColor; // Color of status ok messages var string StatusErrorColor; // Color of status error messages // Table cells var config string CellLeft; // Table cell, left justified var config string CellCenter; // Table cell, center justified var config string CellRight; // Table cell, right justified var config string CellColSpan; // Spanned table cell var config string NowrapLeft; // Nowrap table cell, left justified var config string NowrapCenter; // Nowrap table cell, center justified var config string NowrapRight; // Nowrap table cell, right justified var config string RowLeft; // Table row, left justified var config string RowCenter; // Table row, center justified // Form objects var config string CheckboxInclude; var config string TextboxInclude; var config string SubmitButtonInclude; var config string RadioButtonInclude; var config string SelectInclude; var config string ResetButtonInclude; var config string HiddenInclude; var config string SkinSelectInclude; // Global localization var localized string Accept; var localized string Deny; var localized string Update; var localized string Custom; var localized string Error; var localized string NoneText; var localized string SwitchText; var localized string DeleteText; var localized string NewText; var localized string Edit; var localized string WaitTitle; var localized string MapChanging; var localized string MapChangingTo; var localized string AccessDeniedText; var localized string ErrorAuthenticating; var localized string NoPrivs; var localized string LoadingGames, LoadingMaps, Initialized; var bool bDebug; // ===================================================================================================================== // ===================================================================================================================== // Initialization // ===================================================================================================================== // ===================================================================================================================== event Init() { Super.Init(); if (SpectatorType != None) Spectator = Level.Spawn(SpectatorType); else Spectator = Level.Spawn(class'UTServerAdminSpectator'); if (Spectator != None) Spectator.Server = self; // won't change as long as the server is up and the map hasnt changed LoadMaps(); LoadGameTypes(); LoadMutators(); LoadQueryHandlers(); ReplaceText( Initialized, "%class%", string(Class) ); ReplaceText( Initialized, "%port%", string(WebServer.ListenPort) ); Log(Initialized,'WebAdmin'); } function LoadMaps() { log(LoadingMaps,'WebAdmin'); class'CacheManager'.static.GetMaplist(AllMaps); } function LoadGameTypes() { local int i; Log(LoadingGames,'WebAdmin'); // reinitialize list if needed AGameType = New(None) class'SortedStringArray'; class'CacheManager'.static.GetGameTypeList(AllGames); for (i = 0; i < AllGames.Length; i++) AGameType.Add( AllGames[i].ClassName, AllGames[i].GameName ); } function LoadMutators() { local Mutator M; local int i, id; AExcMutators = New(None) class'StringArray'; AIncMutators = New(None) class'SortedStringArray'; if ( Level.IsDemoBuild() ) return; // Load All mutators class'CacheManager'.static.GetMutatorList(AllMutators); for (i = 0; i<AllMutators.Length; i++) AExcMutators.Add(string(i), AllMutators[i].ClassName); // Check Current Mutators for (M = Level.Game.BaseMutator; M != None; M = M.NextMutator) { if (M.bUserAdded) { id = AExcMutators.FindTagId(String(M.Class)); if (id >= 0) AIncMutators.Add(AExcMutators.GetItem(id), AllMutators[id].FriendlyName); else log("Unknown Mutator in use: "@M.Class,'WebAdmin'); } } } function LoadQueryHandlers() { local int i, j; local xWebQueryHandler QH; local class<xWebQueryHandler> QHC; LoadSkins(); for (i=0; i<QueryHandlerClasses.Length; i++) { QHC = class<xWebQueryHandler>(DynamicLoadObject(QueryHandlerClasses[i],class'Class')); // skip invalid classes if (QHC != None) { // Make sure we dont have duplicate instance of the same class for (j=0;j<QueryHandlers.Length; j++) { if (QueryHandlers[j].Class == QHC) { QHC = None; break; } } if (QHC != None) { QH = new(self) QHC; if (QH != None) { if (QH.Init()) { QueryHandlers.Length = QueryHandlers.Length+1; QueryHandlers[QueryHandlers.Length - 1] = QH; } else Log("WebQueryHandler:"@QHC@"could not be initialized",'WebAdmin'); } } } else { log("Invalid QueryHandlerClass:"$QueryHandlerClasses[i]$". Removing invalid entry.",'WebAdmin'); QueryHandlerClasses.Remove(i,1); SaveConfig(); } } } function string SetGamePI(optional string GameType) { local class<Info> TmpClass; local array<class<Info> > InfoClasses; local int i; if (GameType == "") { InfoClasses[0] = Level.Game.Class; GameType = string(Level.Game.Class); } else { TmpClass = class<Info>(DynamicLoadObject(GameType, class'Class')); if (TmpClass == None) { Log("Error loading gametype"@GameType,'WebAdmin'); return ""; } InfoClasses[0] = TmpClass; } if (GamePI == None) GamePI = new(None) class'PlayInfo'; if (Level.Game.AccessControl != None) InfoClasses[1] = Level.Game.AccessControl.Class; while (i < AIncMutators.Count()) { TmpClass = class<Info>(DynamicLoadObject(AllMutators[int(AIncMutators.GetItem(i++))].ClassName, class'Class')); if (TmpClass != None) InfoClasses[InfoClasses.Length] = TmpClass; } GamePI.Init( InfoClasses ); return GameType; } // ===================================================================================================================== // ===================================================================================================================== // List Initialization & Generation // ===================================================================================================================== // ===================================================================================================================== // Returns a list of all maps for this gametype function StringArray ReloadExcludeMaps(String GameType) { local int i, GameIndex; local string MapPrefix; local StringArray AMaps; local array<CacheManager.MapRecord> MapRecords; if ( GameType == "" ) GameType = string(Level.Game.Class); GameIndex = GetGameCacheIndex(GameType); if ( GameIndex == -1 ) { Warn("Could not load gametype"@GameType@"for maplist."); return AMaps; } AMaps = New(None) class'SortedStringArray'; MapPrefix = AllGames[GameIndex].MapPrefix; class'CacheManager'.static.GetMapList(MapRecords, MapPrefix); for ( i = 0; i < MapRecords.Length; i++ ) if ( ValidMap(MapRecords[i].MapName) ) { if ( bDebug ) log("Adding entry to exclude maplist Item '"$i$"' Tag '"$MapRecords[i].MapName$"'"); AMaps.Add(MapRecords[i].MapName, MapRecords[i].MapName, True); } return AMaps; } // Returns a list of active maps for this gametype function StringArray ReloadIncludeMaps(StringArray ExMaps, int GameIndex, int MapListIndex) { local int i, id; local string MapName; local array<string> Maps; local StringArray Arr; Arr = new(None) class'StringArray'; Maps = Level.Game.MaplistHandler.GetMapList(GameIndex, MapListIndex); for ( i = 0; i < Maps.Length; i++ ) { MapName = class'MaplistRecord'.static.GetBaseMapName(Maps[i]); Arr.Add( MapName $ Maps[i], MapName, True ); if ( bDebug ) log("Adding map entry to include list Item '"$MapName $ Maps[i]$"' Tag '"$MapName$"'"); // Always add the maps that are in the existing maplist, even if they aren't valid maps id = ExMaps.FindTagId(MapName); if ( id != -1 ) ExMaps.Remove(id); } return Arr; } // Only 'Mutators' has value when function is called function CreateFullMutatorList(out StringArray Mutators, out StringArray GroupsOnly) { local StringArray Grouped; local int i,j,z; local string GrpName; local string thisgroup, nextgroup; // This class provides a specialized sorting function // since mutators may be grouped - mutators in the same groups // are not allowed to be selected together Grouped = new(None) class'SortedStringArray'; // Create array sorted on GroupName...this allows to flag // the mutator for a different .inc file (radio instead of checkbox) for (i = 0; i < Mutators.Count(); i++) { j = int(Mutators.GetItem(i)); // If the mutator author forgot to configure a group name for the mutator, // generate a groupname "Z" + number, so that every mutator without group name // has its own group, and isn't grouped together if (AllMutators[j].GroupName == "") GrpName = "Z" $ string (z++); else GrpName = AllMutators[j].GroupName; Grouped.Add(string(j),GrpName $ "." $ AllMutators[j].FriendlyName $ AllMutators[j].ClassName); } // Move all grouped mutators to GroupsOnly StringArray for sorting by friendly name for (i = 0; i < Grouped.Count(); i++) { thisgroup = AllMutators[int(Grouped.GetItem(i))].GroupName; nextgroup = ""; if (thisgroup == "") continue; if (i+1 < Grouped.Count()) nextgroup = AllMutators[int(Grouped.GetItem(i+1))].GroupName; if (thisgroup ~= nextgroup) { j=i; while(nextgroup ~= thisgroup && j < Grouped.Count()) { GroupsOnly.MoveFromId(Grouped, Grouped.FindItemId(Grouped.GetItem(j))); thisgroup = nextgroup; if (j+1 == Grouped.Count()) nextgroup=""; else nextgroup = AllMutators[int(Grouped.GetItem(j+1))].GroupName; } if (j < Grouped.Count()) GroupsOnly.MoveFromId(Grouped,Grouped.FindItemId(Grouped.GetItem(j))); i=-1; } } // Move all non-grouped mutators back to Mutators StringArray // for re-sorting by Friendly Name Mutators.Reset(); for (i=0;i<Grouped.Count();i++) { j=int(Grouped.GetItem(i)); Mutators.Add(string(j),AllMutators[j].FriendlyName); } Grouped.Reset(); } // ===================================================================================================================== // ===================================================================================================================== // Server Management & Control // ===================================================================================================================== // ===================================================================================================================== function LoadSkins() { local int i; local string S; local class<WebSkin> SkinClass; Skins = new(None) class'StringArray'; S = Level.GetNextInt("XWebAdmin.WebSkin", i++); while (S != "") { SkinClass = class<WebSkin>(DynamicLoadObject(S, class'Class')); if (SkinClass != None) { Skins.Add(Level.GetItemName(string(SkinClass)), SkinClass.default.DisplayName); WebSkins[WebSkins.Length] = SkinClass; } S = Level.GetNextInt("XWebAdmin.WebSkin", i++); } ApplySkinSettings(); } function ApplySkinSettings() { local int i; if (Skins == None) return; if (CurrentSkin != None && Level.GetItemName(string(CurrentSkin.Class)) ~= ActiveSkin) return; i = Skins.FindItemId(ActiveSkin); if (i < 0) CurrentSkin = new(None) class'XWebAdmin.UT2K3Skin'; else CurrentSkin = new(None) WebSkins[i]; if (CurrentSkin != None) CurrentSkin.Init(Self); } function ServerChangeMap(WebRequest Request, WebResponse Response, string MapName, string GameType) { local int i; local bool bConflict; local string Conflicts, Str, ShortName, Muts; if (Level.NextURL != "") { ShowMessage(Response, WaitTitle, MapChanging); } if (Request.GetVariable("Save", "") != "") { // All we need to do is override settings as required for (i = 0; i<GamePI.Settings.Length; i++) { ShortName = Level.GetItemName(GamePI.Settings[i].SettingName); if (Request.GetVariable(GamePI.Settings[i].SettingName, "") != "") Level.UpdateURL(ShortName, GamePI.Settings[i].Value, false); } } else { bConflict = false; Conflicts = ""; // Make sure we have a GamePI with the right GameType selected GameType = SetGamePI(GameType); // Check each parameter and see if it conflicts with the settings on the command line for (i = 0; i<GamePI.Settings.Length; i++) { // Hack to get around "AdminName bug" if (HasURLOption(GamePI.Settings[i].SettingName, Str) && !(GamePI.Settings[i].Value ~= Str) && GamePI.Settings[i].SettingName != "GameReplicationInfo.AdminName") { // We have a conflicting setting, prepare a table row for it. Response.Subst("SettingName", GamePI.Settings[i].SettingName); Response.Subst("SettingText", GamePI.Settings[i].DisplayName); Response.Subst("DefVal", GamePI.Settings[i].Value); Response.Subst("URLVal", Str); Response.Subst("MapName", MapName); Response.Subst("GameType", GameType); Conflicts = Conflicts $ WebInclude(RestartPage$"_row");//skinme bConflict = true; } } if (bConflict) { // Conflicts exist .. show the RestartPage Response.Subst("Conflicts", Conflicts); Response.Subst("PostAction", RestartPage); Response.Subst("Section", "Restart Conflicts"); Response.Subst("SubmitValue", Accept); ShowPage(Response, RestartPage); return; } } Muts = UsedMutators(); if (Muts != "") Muts = "?Mutator=" $ Muts; Level.ServerTravel(MapName$"?Game="$GameType$Muts, false); ShowMessage(Response, WaitTitle, MapChanging); } // Save custom maplist function UpdateCustomMapList(int GameIndex, int Index, string NewName) { if ( !(Level.Game.MaplistHandler.GetMapListTitle(GameIndex, Index) == NewName) ) Index = Level.Game.MaplistHandler.RenameList(GameIndex, Index, NewName); if ( Level.Game.MaplistHandler.GetActiveList(GameIndex) == Index ) Level.Game.MaplistHandler.ApplyMaplist(GameIndex, Index); else Level.Game.MaplistHandler.SaveMapList(GameIndex, Index); } // Called at end of game function CleanupApp() { local int i; if (Spectator != None) Spectator = None; for (i = 0; i < QueryHandlers.Length; i++) QueryHandlers[i].Cleanup(); // In case a query is hung if (Resp != None) CleanupQuery(); Super.CleanupApp(); // Always call Super.CleanupApp(); } // ===================================================================================================================== // ===================================================================================================================== // Webpage Query Response Handling // ===================================================================================================================== // ===================================================================================================================== function bool PreQuery(WebRequest Request, WebResponse Response) { local bool bResult; local int i; if (Level == None || Level.Game == None || Level.Game.AccessControl == None) { ShowMessage(Response, Error, ErrorAuthenticating); return false; } // Prevent admin credentials from being stored across threads // Also ensure that hanging connections are closed before beginning another Query() if (Resp != None) CleanupQuery(); if (Spectator == None) { if (SpectatorType != None) Spectator = Level.Spawn(SpectatorType); else Spectator = Level.Spawn(class'UTServerAdminSpectator'); if (Spectator != None) Spectator.Server = self; } if (Spectator == None) { ShowMessage(Response, Error, ErrorAuthenticating); return false; } // Check authentication: if (!Level.Game.AccessControl.AdminLogin(Spectator, Request.Username, Request.Password)) { Response.FailAuthentication(AdminRealm); return false; } CurAdmin = Level.Game.AccessControl.GetLoggedAdmin(Spectator); if (CurAdmin == None) { ShowMessage(Response, Error, ErrorAuthenticating); Level.Game.AccessControl.AdminLogout(Spectator); return false; } Resp = Response; bResult = True; for (i=0; i<QueryHandlers.Length; i++) { if (!QueryHandlers[i].PreQuery(Request, Response)) bResult = False; } return bResult; } event Query(WebRequest Request, WebResponse Response) { local int i; Response.Subst("BugAddress", "webadminbugs"$Level.EngineVersion$"@epicgames.com"); Response.Subst("CSS", SiteCSSFile); Response.Subst("BODYBG", SiteBG); // Match query function. checks URI and calls appropriate input/output function if (CurrentSkin != None && CurrentSkin.SpecialQuery.Length > 0) { for (i = 0; i < CurrentSkin.SpecialQuery.Length; i++) { if (CurrentSkin.SpecialQuery[i] ~= Mid(Request.URI,1)) { if (CurrentSkin.HandleSpecialQuery(Request, Response)) return; break; } } } // Check whether we're supposed to handle this query switch (Mid(Request.URI, 1)) { case "": case RootFrame: QueryRootFrame(Request, Response); return; case HeaderPage: QueryHeaderPage(Request, Response); return; case RestartPage: if (!MapIsChanging()) QuerySubmitRestartPage(Request, Response); return; case SiteCSSFile: Response.SendCachedFile( Path $ SkinPath $ "/" $ Mid(Request.URI, 1), "text/css"); return; } // If not, allow each query handler a chance to process this query. Show error message if no query handlers // were able to handle the query for (i=0; i<QueryHandlers.Length; i++) if (QueryHandlers[i].Query(Request, Response)) return; ShowMessage(Response, Error, "Page not found!"); return; } event PostQuery(WebRequest Request, WebResponse Response) { local int i; for (i=0; i<QueryHandlers.Length; i++) if (!QueryHandlers[i].PostQuery(Request, Response)) Response.Connection.bDelayCleanup = True; if (Response.Connection.IsHanging()) return; CleanupQuery(); } function CleanupQuery() { if (Resp != None && Resp.Connection.IsHanging()) Resp.Connection.Timer(); Resp = None; CurAdmin = None; Level.Game.AccessControl.AdminLogout(Spectator); } // Generates the HTML for the main root frame function QueryRootFrame(WebRequest Request, WebResponse Response) { local String GroupPage; if (QueryHandlers.Length > 0) GroupPage = QueryHandlers[0].DefaultPage; if (Request.GetVariable("ChangeSkin") != "") { ActiveSkin = Request.GetVariable("WebSkin", ActiveSkin); ApplySkinSettings(); SaveConfig(); } GroupPage = Request.GetVariable("Group", GroupPage); Response.Subst("HeaderURI", HeaderPage$"?Group="$GroupPage); Response.Subst("BottomURI", GroupPage); Response.Subst("ServerName", class'GameReplicationInfo'.default.ServerName); ShowFrame(Response, RootFrame); } // Generates the HTML for the top frame, which displays the available areas of webadmin and webadmin skin selector function QueryHeaderPage(WebRequest Request, WebResponse Response) { local int i; local string menu, GroupPage, Dis, CurPageTitle; Response.Subst("AdminName", CurAdmin.UserName); Response.Subst("HeaderColSpan", "2"); if (QueryHandlers.Length > 0) { GroupPage = Request.GetVariable("Group", QueryHandlers[0].DefaultPage); // We build a multi-column table for each QueryHandler menu = ""; CurPageTitle = ""; for (i=0; i<QueryHandlers.Length; i++) { if (QueryHandlers[i].DefaultPage == GroupPage) CurPageTitle = QueryHandlers[i].Title; Dis = ""; if (QueryHandlers[i].NeededPrivs != "" && !CanPerform(QueryHandlers[i].NeededPrivs)) Dis = "d"; Response.Subst("MenuLink", RootFrame$"?Group="$QueryHandlers[i].DefaultPage); Response.Subst("MenuTitle", QueryHandlers[i].Title); menu = menu$WebInclude(HeaderPage$"_item"$Dis);//skinme } Response.Subst("Location", CurPageTitle); Response.Subst("HeaderMenu", menu); } if ( CanPerform("Xs") ) { Response.Subst("HeaderColSpan", "3"); Response.Subst("SkinSelect", Select("WebSkin", GenerateSkinSelect())); Response.Subst("WebSkinSelect", WebInclude(SkinSelectInclude)); } // Set URIs ShowPage(Response, HeaderPage); } function QueryRestartPage(WebRequest Request, WebResponse Response) { if ( CanPerform("Mr|Mt|Mm|Ms|Mu|Ml") ) ServerChangeMap(Request, Response, Level.GetURLMap(), String(Level.Game.Class)); } function QuerySubmitRestartPage(WebRequest Request, WebResponse Response) { if ( CanPerform("Mr|Mt|Mm|Ms|Mu|Ml") ) ServerChangeMap(Request, Response, Request.GetVariable("MapName"), Request.GetVariable("GameType")); } // Generates HTML indicating that the admin doesn't have the priviledges required to view this page function AccessDenied(WebResponse Response) { ShowMessage(Response, AccessDeniedText, NoPrivs); } // ===================================================================================================================== // ===================================================================================================================== // HTML Generators for combo lists // ===================================================================================================================== // ===================================================================================================================== // HTML for gametype combo options function string GenerateGameTypeOptions(String CurrentGameType) { local int i; local string SelectedStr, OptionStr; for (i=0; i < AGameType.Count(); i++) { if (CurrentGameType ~= AGameType.GetItem(i)) SelectedStr = " selected"; else SelectedStr = ""; OptionStr = OptionStr$"<option value=\""$AGameType.GetItem(i)$"\""$SelectedStr$">"$AGameType.GetTag(i)$"</option>"; } return OptionStr; } // HTML for active mutator selection list function string GenerateMutatorOptions(String SelectedMutators) { local int i, j; local string SelectedStr, OptionStr; local array<string> MutatorList; local StringArray SortedMutatorList; local bool bNoMutators; Split( SelectedMutators, ",", MutatorList); SortedMutatorList = new(None) class'SortedStringArray'; for(i=0; i < AllMutators.Length; i++) SortedMutatorList.Add(AllMutators[i].ClassName,AllMutators[i].FriendlyName); // Search mutator list for NONE, if found then no other mutators can be selected. SelectedStr = ""; for( j=0; j < MutatorList.Length; j++) { if( MutatorList[j] ~= "NONE" ) { SelectedStr = " selected"; bNoMutators = true; break; } } // add None options - for unloading all mutators OptionStr = "<option value=\"NONE\"" $ SelectedStr $ ">" $ NoneText $ "</option>"; for(i=0; i < SortedMutatorList.Count(); i++) { SelectedStr = ""; if( !bNoMutators ) // dont select other mutators if none selected { for( j=0; j < MutatorList.Length; j++) { if( MutatorList[j] ~= SortedMutatorList.GetItem(i) ) { SelectedStr = " selected"; break; } } } OptionStr $= "<option value=\"" $ SortedMutatorList.GetItem(i) $ "\"" $ SelectedStr $ ">" $ SortedMutatorList.GetTag(i) $ "</option>"; } SortedMutatorList.Reset(); return OptionStr; } // HTML for maplist selection options function string GenerateMapListOptions(string GameType, int Active) { local int i, idx; local array<string> Ar; local string Result, selected; idx = Level.Game.MaplistHandler.GetGameIndex(GameType); Ar = Level.Game.MaplistHandler.GetMapListNames(idx); for (i = 0; i < Ar.Length; i++) { selected =Eval(i == Active, " selected", ""); Result $= "<option value=\"" $ string(i) $ "\"" $ selected $ ">" $ Ar[i] $ "</option>"; } return Result; } // HTML for the dual map selection lists function string GenerateMapListSelect(StringArray MapList, StringArray MovedMaps) { local int i; local String ResponseStr, SelectedStr; if (MapList.Count() == 0) return "<option value=\"\">***"@NoneText@"***</option>"; for (i = 0; i<MapList.Count(); i++) { if ( ValidMap(MapList.GetTag(i))) { SelectedStr = ""; if (MovedMaps != None && MovedMaps.FindTagId(MapList.GetTag(i)) >= 0) SelectedStr = " selected"; ResponseStr = ResponseStr$"<option value=\""$MapList.GetItem(i)$"\""$SelectedStr$">"$MapList.GetTag(i)$"</option>"; } } return ResponseStr; } // HTML for webadmin skin options function string GenerateSkinSelect() { local string S, selectedstring; local int i; if (Skins.Count() == 0) return "<option value=\"\">***"@NoneText@"***</option>"; for (i = 0; i < Skins.Count(); i++) { SelectedString = Eval(CurrentSkin != None && Level.GetItemName(string(CurrentSkin.Class)) ~= Skins.GetItem(i), " selected", ""); S = S $ "<option value=\""$Skins.GetItem(i)$"\""$SelectedString$">"$Skins.GetTag(i)$"</option>"; } return S; } // ===================================================================================================================== // ===================================================================================================================== // HTML helpers // ===================================================================================================================== // ===================================================================================================================== // Replaces special characters in a regular string with HTML static function string HtmlEncode(string src) { local int i; for (i = 0; i < default.SpecialChars.Length; i++) src = Repl(src, default.SpecialChars[i].Plain, default.SpecialChars[i].Coded); return src; } // Replaces HTML special characters with regular text static function string HtmlDecode(string src) { local int i; for (i = 0; i < default.SpecialChars.Length; i++) src = Repl(src, default.SpecialChars[i].Coded, default.SpecialChars[i].Plain); return src; } // Make the specified string's length equal to MaxWidth by adding PadString to the beginning of the string function string PadLeft( string Text, int MaxWidth, optional string PadString) { local String OutStr; if (PadString == "") PadString = " "; for (OutStr = Text; Len(OutStr) < MaxWidth; OutStr = PadString $ OutStr); return Right(OutStr, MaxWidth); // in case PadStr is more than one character } // Make the specified string's length equal to MaxWidth by adding PadString to the end of the string function string PadRight(string Text, int MaxWidth, optional string PadString) { local string OutStr; if (PadString == "") PadString = " "; for (OutStr = Text; Len(OutStr) < MaxWidth; OutStr $= PadString); return Left(OutStr, MaxWidth); } // Adds the HTML necessary for showing the current map's name function MapTitle(WebResponse Response) { local string str, smap; str = Level.Game.GameReplicationInfo.GameName$" in "; if (Level.Title ~= "untitled") { smap = Level.GetURLMap(); if (Right(smap, 4) ~= ".ut2") str $= Left(smap, Len(smap) - 4); else str $= smap; } else str $= Level.Title; Response.Subst("SubTitle", str); } function bool MapIsChanging() { if (Level.NextURL != "") { ShowMessage(Resp, WaitTitle, MapChanging); return true; } return false; } // Converts the specified text into a hyperlink function string HyperLink(string url, string text, bool bEnabled, optional string target) { local string hlink; if (bEnabled) { hlink = "<a href='"$url$"'"; if (target != "") hlink = hlink@"target='"$target$"'"; hlink = hlink$">"$text$"</a>"; return hlink; } return text; } // Loads an .inc file into the current WebResponse object function string WebInclude(string file) { local string S; if (CurrentSkin != None) { S = CurrentSkin.HandleWebInclude(Resp, file); if (S != "") return S; } return Resp.LoadParsedUHTM(Path $ SkinPath $ "/" $ file $ ".inc"); } function bool ShowFrame(WebResponse Response, string Page) { if (CurrentSkin != None && CurrentSkin.HandleHTM(Response, Page)) return true; Response.IncludeUHTM( Path $ SkinPath $ "/" $ Page $ htm); return true; } function bool ShowPage(WebResponse Response, string Page) { if (CurrentSkin != None && CurrentSkin.HandleHTM(Response, Page)) { Response.ClearSubst(); return true; } Response.IncludeUHTM( Path $ SkinPath $ "/" $ Page $ htm); Response.ClearSubst(); return true; } function StatusError(WebResponse Response, string Message) { if (Left(Message,1) == "@") Message = Mid(Message,1); Response.Subst("Status", "<font color='"$StatusErrorColor$"'>"$Message$"</font><br>"); } function StatusOk(WebResponse Response, string Message) { Response.Subst("Status", "<font color='"$StatusOKColor$"'>"$Message$"</font>"); } function bool StatusReport(WebResponse Response, string ErrorMessage, string SuccessMessage) { if (ErrorMessage == "") StatusOk(Response, SuccessMessage); else StatusError(Response, ErrorMessage); return ErrorMessage==""; } function ShowMessage(WebResponse Response, string Title, string Message) { if (CurrentSkin != None && CurrentSkin.HandleMessagePage(Response, Title, Message)) return; Response.Subst("Section", Title); Response.Subst("Message", Message); Response.IncludeUHTM(Path $ SkinPath $ "/" $ MessagePage $ htm); } // Framed message page (eliminates double headers) function ShowFramedMessage(WebResponse Response, string Message, bool bIsErrorMsg) { if (CurrentSkin != None && CurrentSkin.HandleFrameMessage(Response, Message, bIsErrorMsg)) return; if (bIsErrorMsg) StatusError(Response,Message); else Response.Subst("Message", Message); Response.IncludeUHTM(Path $ SkinPath $ "/" $ FramedMessagePage $ htm); } // ===================================================================================================================== // ===================================================================================================================== // Form control HTML helpers // ===================================================================================================================== // ===================================================================================================================== // Creates a checkbox, optionally greying it out (disabled) function string Checkbox(string tag, bool bChecked, optional bool bDisabled) { Resp.Subst("CheckName", tag); Resp.Subst("Checked", Eval(bChecked, " checked", "")); Resp.Subst("Disabled", Eval(bDisabled, " disabled", "")); return WebInclude(CheckboxInclude); } function string Hidden(string Tag, string Value) { Resp.Subst("HiddenName", Tag); Resp.Subst("HiddenValue", Value); return WebInclude(HiddenInclude); } // Creates a submit button function string SubmitButton(string SubmitButtonName, string SubmitButtonValue) { Resp.Subst("SubmitName", SubmitButtonName); Resp.Subst("SubmitValue", SubmitButtonValue); return WebInclude(SubmitButtonInclude); } function string ResetButton(string ResetButtonName, string ResetButtonValue) { Resp.Subst("ResetName", ResetButtonName); Resp.Subst("ResetValue", ResetButtonValue); return WebInclude(ResetButtonInclude); } // Creates a textbox, optionally providing a default value function string TextBox(string TextName, coerce string Size, coerce string MaxLength, optional string DefaultValue) { Resp.Subst("TextName", TextName); if (int(Size) > 0) Resp.Subst("TextSize", "size=\""$Size$"\""); else Resp.Subst("TextSize", ""); if (int(MaxLength) > 0) Resp.Subst("TextLength", "maxlength=\""$MaxLength$"\""); else Resp.Subst("TextLength", ""); Resp.Subst("TextValue", DefaultValue); return WebInclude(TextboxInclude); } function string RadioButton(string Group, string Value, bool bSelected) { Resp.Subst("RadioGroup", Group); Resp.Subst("RadioValue", Value); Resp.Subst("Selected", Eval(bSelected, " checked", "")); return WebInclude(RadioButtonInclude); } function string Select(string SelectName, string SelectOptions) { Resp.Subst("SelectName", SelectName); Resp.Subst("ListOptions", SelectOptions); return WebInclude(SelectInclude); } // ===================================================================================================================== // ===================================================================================================================== // Accessor / Utility Functions // ===================================================================================================================== // ===================================================================================================================== function int GetGameCacheIndex( string GameClass ) { local int i; for ( i = 0; i < AllGames.Length; i++ ) if ( AllGames[i].ClassName ~= GameClass ) return i; return -1; } // Returns whether this map is a valid map function bool ValidMap(string MapURL) { local int i; local string MapName; if ( Left(Caps(MapName),4) ~= "TUT-" ) return false; MapName = class'MaplistRecord'.static.GetBaseMapName(MapURL); for ( i = 0; i < AllMaps.Length; i++ ) { if ( AllMaps[i].MapName ~= MapName ) return true; } return false; } function FormatMapName(out string FullName, out string ShortName) { local string ext; ext = ".ut2"; if (FullName == "" && ShortName == "") return; if (FullName != "" && ShortName == "") { if (Right(FullName, 4) ~= ext) ShortName = Left(FullName, Len(FullName) - 4); else { ShortName = FullName; FullName = FullName $ ext; } } else if (FullName == "" && ShortName != "") { if (Right(ShortName,4) ~= ext) { FullName = ShortName; ShortName = Left(ShortName, Len(ShortName) - 4); } else FullName = ShortName $ ext; } else { if (!(Right(FullName,4) ~= ext)) FullName = FullName $ ext; ShortName = Left(FullName, Len(FullName) - 4); } } function String UsedMutators() { local int i; local String OutStr; while (i < AIncMutators.Count()) { if (OutStr != "") OutStr $= ","; OutStr $= AllMutators[int(AIncMutators.GetItem(i++))].ClassName; } return OutStr; } function bool HasURLOption(string ParamName, out string Value) { local string Param; local int i; Param = ParamName; while (true) { i = Instr(Param, "."); if (i < 0) break; Param = Mid(Param, i+1); } Value = Level.GetUrlOption(Param); return Value != ""; } function string NextPriv(out string PrivString) { local int pos; local string Priv; pos = Instr(PrivString, "|"); if (pos < 0) pos = Len(PrivString); EatStr(Priv, PrivString, Pos); if (PrivString != "") // Remove leading pipe char PrivString = Mid(PrivString, 1); return Priv; } function bool CanPerform(string privs) { local string priv; priv = NextPriv(privs); while (priv != "") { if (Level.Game.AccessControl.AllowPriv(priv) && CurAdmin.HasPrivilege(priv)) return true; priv = NextPriv(privs); } return false; } defaultproperties { QueryHandlerClasses(0)="XWebAdmin.xWebQueryCurrent" QueryHandlerClasses(1)="XWebAdmin.xWebQueryDefaults" QueryHandlerClasses(2)="XWebAdmin.xWebQueryAdmins" SpectatorType=Class'XWebAdmin.UTServerAdminSpectator' DefaultWebSkinClass=Class'XWebAdmin.UT2K3Skin' SpecialChars(0)=(Plain="&",Coded="&") SpecialChars(1)=(Plain=""",Coded=""") SpecialChars(2)=(Plain=" ",Coded=" ") SpecialChars(3)=(Plain="<",Coded="<") SpecialChars(4)=(Plain=">",Coded=">") SpecialChars(5)=(Plain="©",Coded="©") SpecialChars(6)=(Plain="™",Coded="™") SpecialChars(7)=(Plain="®",Coded="®") DefaultBG="#aaaaaa" HighlightedBG="#3a7c8c" RootFrame="rootframe" HeaderPage="mainmenu" MessagePage="message" FramedMessagePage="frame_message" RestartPage="server_restart" htm=".htm" AdminRealm="UT Remote Admin Server" SiteCSSFile="ut2003.css" SiteBG="#243954" StatusOKColor="#33cc66" StatusErrorColor="Yellow" CellLeft="cell_left" CellCenter="cell_center" CellRight="cell_right" CellColSpan="cell_colspan" NowrapLeft="cell_left_nowrap" NowrapCenter="cell_center_nowrap" NowrapRight="cell_right_nowrap" RowLeft="row_left" RowCenter="row_center" CheckboxInclude="checkbox" TextboxInclude="textbox" SubmitButtonInclude="submit_button" RadioButtonInclude="radio_button" SelectInclude="select" ResetButtonInclude="reset_button" HiddenInclude="hidden" SkinSelectInclude="mainmenu_items" Accept="Accept" Deny="Deny" Update="Update" Custom="Custom" Error="Error" NoneText="None" SwitchText="Switch" DeleteText="Delete" NewText="New" Edit="Edit" WaitTitle="Please Wait" MapChanging="The server is now switching maps. Please allow 10 - 15 seconds while the server changes maps." MapChangingTo="The server is now switching to map '%MapName%'. Please allow 10-15 seconds while the server changes maps." AccessDeniedText="Access Denied" ErrorAuthenticating="Exception Occurred During Authentication!" NoPrivs="Your privileges are not sufficient to view this page." LoadingGames="Loading Game Types" LoadingMaps="Loading Available Maps" Initialized="%class% Initialized on port %port%" } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |