logo
Main

Forums

Downloads

Unreal-Netiquette

Donate for Oldunreal:
Donate

borderline

Links to our wiki:
Wiki

Walkthrough

Links

Tutorials

Unreal Reference

Usermaps

borderline

Contact us:
Submit News
Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Idea: Web admin API (Read 993 times)
ArtifexEt
New Member
*
Offline


Oldunreal member

Posts: 4
Location: Gdańsk
Joined: May 26th, 2014
Gender: Male
Idea: Web admin API
Mar 5th, 2018 at 9:07pm
Print Post  
I do not know if this is the best place to ask for a change current web admin page.
I realize that this is not the most important thing that can be improved. Probably not many people use this. But my solution could solve the problem of management via a web server and make it more convenient.
Please let me know if instead of patch mod will be better.

Story:

Currently web admin allows for basic management. It is based on generating html files using the game engine. This method of generation does not allow creating a complicated user interfaces. In theory, you can attach additional scripts to the html with the help of some external http server but this is just an apparent solution.

Proposition:

Create new api web server. The game engine would interpret and generate only data in the json format. Communication would be done using the rest api.

Advantages:
- Easy to implement on game engine side
- It allows you to increase game control
- Serialization of objects allows you to support every mod and state in game
- Well implemented can be universal (Unreal, UT etc)
- Everyone will be able to control the server using api
- it will be possible to create an application / management page for more than one game server at a time
- it will be possible to collect much more accurate server statistics, eg average health of players in a given stage, etc.
- it will be possible provide information about the number of players or server status on websites
- Anyone will be able to create a web admin page without having to modify the game

Why better patch than mod:
- You can share selected core elements of game as "modifiable"
- serialization should probably be done natively for optimization

What can I do:

- Create detailed documentation how api should look like.
- Create client application that use this api.
- Write high-level server architecture, to to speed up patch implementation
- Support the whole process

What I can not do:
- Write the unreal script code/c++, because I do not know it well enough
  
Back to top
IP Logged
 
Pitbull™
Forum Administrator
*****
Offline



Posts: 1058
Location: Between Venus & Mars
Joined: Oct 4th, 2002
Gender: Male
Re: Idea: Web admin API
Reply #1 - Mar 5th, 2018 at 10:54pm
Print Post  
I've always liked web admin as you can easily manage your server from any where. Your idea of an external server though. That kinda draws a red flag for me. I am by no means well versed in programming and I have basic knowledge of html etc. Would an external server allow for abuse? One thing I do think would be cool though would be a mobile version of web admin.
  

LOADING HATERS..████████████] 99% Complete.

It was only a difference of opinion, but really...I mean good manners
don't cost nothing do they, eh?
Back to top
IP Logged
 
ArtifexEt
New Member
*
Offline


Oldunreal member

Posts: 4
Location: Gdańsk
Joined: May 26th, 2014
Gender: Male
Re: Idea: Web admin API
Reply #2 - Mar 6th, 2018 at 1:51am
Print Post  
The threats will be at the same level as currently. The truth is that my idea is not very complicated. Because it is not much different from what we have today. We change html to json. The difference is only in server response format.

It would be possible to create a mobile application. I would stay with the control using the browser. However, everyone could create mobile admin app.

Of course, there are even better ways to create a web admin. For example, websockets But they seem to me much more invasive and not implemented correctly would affect the performance of the game itself.
  
Back to top
IP Logged
 
Pitbull™
Forum Administrator
*****
Offline



Posts: 1058
Location: Between Venus & Mars
Joined: Oct 4th, 2002
Gender: Male
Re: Idea: Web admin API
Reply #3 - Mar 6th, 2018 at 4:17am
Print Post  
For mobile wouldn't a mobile format work just as easily? I'd imagine most would rather have that instead. I hate installing tons of apps on my phone.
  

LOADING HATERS..████████████] 99% Complete.

It was only a difference of opinion, but really...I mean good manners
don't cost nothing do they, eh?
Back to top
IP Logged
 
Smirftsch
Forum Administrator
*****
Offline



Posts: 7763
Location: at home
Joined: Apr 30th, 1998
Gender: Male
Re: Idea: Web admin API
Reply #4 - Mar 6th, 2018 at 7:04am
Print Post  
in general any improvement is welcome and the idea to have a web admin suitable for mobile is also quite cool.
Somehow I find it a bit funny that our old game seems to get technology even modern games don't have Cheesy

I do not know much about json and what it can do other than that it exists. Therefor I can't overview right now how much effort this will take and since my time is usually very limited I can't say yet if such a project is feasible in any way.
Either way, I think there is interest and we should dig a bit deeper how many people want to contribute here and if we can realize it.
  

Sometimes you have to lose a fight to win the war.
Back to top
WWWICQ  
IP Logged
 
Feralidragon
Full Member
***
Offline



Posts: 207
Location: Lisbon - Portugal
Joined: Jul 24th, 2008
Gender: Male
Re: Idea: Web admin API
Reply #5 - Mar 6th, 2018 at 11:30am
Print Post  
For the record, I am currently working towards something similar, technology-wise.

I am creating a new PHP framework, which I am already starting to use at work, and which I also intend to use to build a fairly complete platform for both Unreal and UT99, and one of the last steps is for me to develop a JSON parser in UnrealScript, along with a few other things, which I have first to experiment with, such as a REST framework for UnrealScript as well (given that as it is, at least in UT99, I will have to rebuild the entire thing, which luckily can be done so with UnrealScript only), to retrieve data and render a view in-game.

What I mean to do sits mostly on the opposite side of what you want to do, as you want a web interface to interact with Unreal, while I want an Unreal interface to interact with web in the end (although I also want a web towards Unreal, but mostly in the sense of browsing a site, hit play and open Unreal from the client perspective), but the technologies are the same: JSON, REST, web interface, etc.
So I can already say that most if not all of this can be achieved through UnrealScript alone.



As for JSON itself, the biggest challenge is not to parse it (that's the easy part, the format is very simple), but rather what to translate it into in terms of Unreal data structures, given that going from weak typed to strong typed is always a challenge, while from strong typed to weak typed is very easy.
At least my own idea in how to do it is to use objects to represent it: a main JSON object while then is extended to represent other objects and arrays, and even scalar values such as numbers, strings, booleans, etc.

Although having objects where each JSON property directly translates to each Unreal object property is also possible, although yeah, it would be much easier to do it natively, but I don't think it's strictly required.



As for the entire REST communication... I am not sure how the current web admin works in terms of authentication (it's perhaps basic HTTP authentication?), but it could be a good moment to consider other stronger options to ensure that the API is more secure.
This could be done through HMAC, which involves hashing, generally using the SHA family of hashes (preferably SHA-256 nowadays), since it's a way to sign every request with a key and even check if the data has been tampered with during transmission, and that key doesn't have be sent ever, unlike normal credentials like user and password.

HMAC may also be processed with UnrealScript alone, and I am not sure if Unreal has already any hashing functions implemented (UT99 at least does not), but I already implemented the most used hashing functions several years ago using UnrealScript as well (MD5, SHA-1, SHA-224, SHA-256, SHA-384 and SHA-512), so in case someone already proceeds to develop something in this direction, I can provide the code I already did (it's old code though, but it should work well and be fairly fast).



Having all that said, given that I am now almost entirely focused in the PHP part (the web part), and will be so for several months at least, I won't be touching UnrealScript itself anytime soon to actually create this stuff, but if in the meanwhile someone advances with this, I may at least provide support either with the little code I already have or giving feedback in general in terms of the REST/HTTP/JSON implementation, if needed at all of course. Smiley
  
Back to top
IP Logged
 
ArtifexEt
New Member
*
Offline


Oldunreal member

Posts: 4
Location: Gdańsk
Joined: May 26th, 2014
Gender: Male
Re: Idea: Web admin API
Reply #6 - Mar 6th, 2018 at 4:41pm
Print Post  
What is json?

Quote:
json is an open-standard file format that uses human-readable text to transmit data objects consisting of attribute–value pairs and array data types (or any other serializable value). It is a very common data format used for asynchronous browser–server communication, including as a replacement for XML in some AJAX-style systems

So it is practically a properly formatted text file - like html, that is intended for data transfer, not for presentation. What format should have these files and what url should be used tp download them describes the REST.

Quote:
REpresentational State Transfer (REST), or RESTful, web services provide interoperability between computer systems on the Internet. REST-compliant web services allow the requesting systems to access and manipulate textual representations of web resources by using a uniform and predefined set of stateless operations. Other kinds of web services, such as WSDL and SOAP, expose their own arbitrary sets of operations

Rest provides rules how to download, create and modify resources. It does not exclude use of a different data format, eg, instead of json, you can send xml.

So why patch? As Feralidragon said. The entire plan requires serialization of uscript objects to the selected format and deserialization. The next step is to write (in uscript?)  web admin so that you can ask about specific objects. Eg:

url get: /game/level/players/ returns all players data in json format

And set selected object properties:

url post: /game/level/ {"levelUrl": "NaliLord"} which may cause navigation

Writing a mobile application that uses this API It's the simplest (for me) part. And I could do it by the way.

Because I work as frontend developer I did not consider communication using php treating it as another layer, especially with the main goal was to manage the server. But I could prepare examples of using this api in php, java or other languages.
  
Back to top
IP Logged
 
[]KAOS[]Casey
Developer Team
Betatester
Offline


nedm

Posts: 3135
Joined: Aug 7th, 2011
Gender: Male
Re: Idea: Web admin API
Reply #7 - Mar 6th, 2018 at 5:22pm
Print Post  
Feralidragon wrote on Mar 6th, 2018 at 11:30am:
but rather what to translate it into in terms of Unreal data structures, given that going from weak typed to strong typed is always a challenge, while from strong typed to weak typed is very easy.
At least my own idea in how to do it is to use objects to represent it: a main JSON object while then is extended to represent other objects and arrays, and even scalar values such as numbers, strings, booleans, etc.


SetPropertyText and GetPropertyText will do lots of things here for you. Watch out for arrays though...
  
Back to top
 
IP Logged
 
Feralidragon
Full Member
***
Offline



Posts: 207
Location: Lisbon - Portugal
Joined: Jul 24th, 2008
Gender: Male
Re: Idea: Web admin API
Reply #8 - Mar 7th, 2018 at 11:20am
Print Post  
Yes, I know about those. Smiley
They're very useful to change scalar properties, but once you try to change arrays or structs, and even class references (if I recall correctly), that's where they fail.

Although I probably won't use them at all, unless it's to do some kind of conversion that can only be achieved with those (such as string to name), although only as a polyfill in UT99, given that I believe in Unreal there's already a function for this?

Instead, what I am planning to do is to create actual objects (as in, extending Object rather than Actor), and each object representing a possible value or a set of values (arrays and objects).
Essentially, following the same kind of structure that weak typed languages use internally.

By doing it like that, I don't need to use those methods at all, and objects are the closest thing I can get to clean classes with no extras.
  
Back to top
IP Logged
 
Skupie
New Member
*
Offline


Oldunreal member

Posts: 1
Joined: Mar 7th, 2018
Re: Idea: Web admin API
Reply #9 - Mar 7th, 2018 at 3:38pm
Print Post  
Good idea
  
Back to top
 
IP Logged
 
ArtifexEt
New Member
*
Offline


Oldunreal member

Posts: 4
Location: Gdańsk
Joined: May 26th, 2014
Gender: Male
Re: Idea: Web admin API
Reply #10 - May 4th, 2018 at 8:54am
Print Post  
I know that some time has passed since the start of the topic. I still watching it.

Maybe it would help if I prepare some demo. I would like to see the admin panel made with the standards of google material.

I can do the web app. And if you like it, we can think how to connect it with this api.
  
Back to top
IP Logged
 
syn
New Member
*
Offline


Oldunreal member

Posts: 1
Joined: Sep 16th, 2018
Re: Idea: Web admin API
Reply #11 - Sep 16th, 2018 at 10:09am
Print Post  
I've rewritten the web UI's HTML to be a little more modern.
Your SHOULD be able to just replace (make a backup of course).
It isn't pretty, but it is functional.

Feel free to modify and do whatever you would like.

I plan to make further changes in the future, but would prefer not to have to maintain this code for the community.

With minimal effort, the (fairly responsive) css could be modified to be a little more mobile friendly.

https://pastebin.com/3hRARL6G



Code
Select All
// Feel free to edit this file, expand it or w/e.
// Just make sure you dont mess up ur own administration interface.
// Functions/Keywords:
// /Cdate = Current date
// /Ctime = Current time
// /MapT = Current map title
// /MapF = Current map filename
// /WebVer = Current webadmin version
// /n = New line (Note that next Web line automatly includes new line code)
// %frd: <Redirect name>% = Forward code to some other int file or keep in this file but different part
// WARNING!!!! Redirecting from part A to part B, then in part B to part A will always crash (runaway loop)!
// %Content: <Webpage content classname>% = Add HTML codes from a UScript class
// Line type: "Alive/" will keep the connection refreshing page every 5 seconds.

// Web site content
[index]
WebContentLen=3
web0=%frd:PageHeader%
web1=%frd:Menu%
web2=%frd:Welcome%
web3=%frd:PageEnding%

// The CSS
[CSS]
WebContentLen=0
web0=		<style>body,ul{margin:0;padding:0}body{width:100%}body,li a,li span{text-align:center}body{color:#222;background:#ebe8e4}form h3{display:inline-flex;width:7em}form select{vertical-align:middle;width:30em}table,td,th{border:0}li a{display:block;color:#fff;text-decoration:none;padding:14px 16px}li span{display:block;color:#ccc;text-decoration:none;padding:14px 16px}li.dropdown{display:inline-block}li:last-child{border-right:0}li{float:left;border-right:1px solid #bbb}table{margin:1em auto}th{color:#fff;line-height:1.2;font-size:16px;font-weight:unset;padding:0 5px;background:#444}tr:nth-child(even){background:#eee}ul{overflow:hidden;background:#333}.dropdown-content a{color:#000;text-decoration:none;display:block;text-align:left;font-weight:600;padding:12px 16px}.dropdown-content{display:none;position:absolute;min-width:160px;box-shadow:0 8px 16px 0 rgba(0,0,0,.2);z-index:1;background:#f9f9f9}.dropdown:hover .dropbtn,li a:hover{background:green}.dropdown:hover .dropdown-content{display:block}#console{width:50%;text-align:left;height:40em;color:green;font-family:Consolas,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New,monospace;margin:0 auto;padding:.25em .5em;background:#000}#nav,tr{background:#fff}#nav,ul{list-style-type:none}#nav{border:1px solid #dedede;width:90%;margin:1px auto}#playerlist table{padding-left:65px}</style>

// The script to refresh the console and post.
[console_script]
WebContentLen=23
web0=		<script>
web1=			setInterval(refresh_console(), 5000); // 5000 = 5 Seconds
web2=			function refresh_console() {
web3=				"use strict";
web4=				var xmlhttp;
web5=				if (window.XMLHttpRequest) {
web6=					xmlhttp = new XMLHttpRequest();
web7=				}
web8=				xmlhttp.onreadystatechange = function () {
web9=					if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
web10=						document.getElementById("console").innerHTML = xmlhttp.responseText;
web11=					}
web12=				};
web13=				xmlhttp.open("GET", "/console_get", true);
web14=				xmlhttp.send();
web15=			}
web16=			function submit_console() {
web17=				var formData = document.getElementById("cmdline").name + "=" + document.getElementById("cmdline").value + "&edit=Enter"; console.log(formData);
web18=				var xmlhttp = new XMLHttpRequest();
web19=				xmlhttp.open("post", "ServerConsolePost?UWebAdmin.WebChatWindow");
web20=				xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
web21=				xmlhttp.send(formData);
web22=			}
web23=		</script>

[console_get]
WebContentLen=0
web0=%Content:UWebAdmin.WebChatWindow%

// The Menu
[Menu]
WebContentLen=19
web0=		<div id=nav>
web1=			<ul>
web2=				<li><a href="/index">Index</a></li>
web3=				<li><a href="/MapChange">Change map</a></li>
web4=				<li><a href="/BanListPage">Ban list</a></li>
web5=				<li><a href="/ServerConsole">Console</a></li>
web6=				<li style="float:right"><a href="/Logout">Logout</a></li>
web7=					<li style="float:right"><span>User: %Content:UWebAdmin.GetClientUser%</span></li>
web8=					<li style="float:right"><span>ver /WebVer</span></li>
web9=				<li class="dropdown">
web10=					<a href="javascript:void(0)" class="dropbtn">Configuration</a>
web11=					<div class="dropdown-content">
web12=						<a href="/GameDefaults">Game</a>
web13=						<a href="/ServerInfo">Server Info</a>
web14=						<a href="/MapLinksPage">Maplists</a>
web15=						<a href="/ModLinksPage">Mods</a>
web16=					</div>
web17=				</li>
web18=			</ul>
web19=		</div>

[Welcome]
WebContentLen=4
web0=		<h1>Current map: /MapF "/MapT"</h1>
web1=		<form id="playerlist" method="post" action="Index?UWebAdmin.PlayersListDebug">
web2=				%Content:UWebAdmin.PlayersListDebug%
web3=		</form>
web4=		<span>Your IP: %Content:UWebAdmin.GetClientIP% has been logged on server.</span>

[ServerInfo]
WebContentLen=5
web0=%frd:PageHeader%
web1=%frd:Menu%
web2=<h1>Server Configuration</h1>
web3=%Content:UWebAdmin.RepPageConfig%
web4=%Content:UWebAdmin.WebChatWindow%
web5=%frd:PageEnding%

// Server console page
[ServerConsole]
WebContentLen=9
web0=%frd:PageHeader%
web1=%frd:Menu%
web2=			<h1>Console</h1>
web3=			<h3>Playing on /MapF: /MapT</h3>
web4=			<div id="console">
web5=%Content:UWebAdmin.WebChatWindow%
web6=			</div>
web7=%frd:ServerConsoleLine%
web8=%frd:console_script%
web9=%frd:PageEnding%

// Server console input line
[ServerConsoleLine]
WebContentLen=5
web0=		<form action="ServerConsoleLine?UWebAdmin.WebChatWindow" method="post" id="ServerConsoleLine">
web1=			Console Command:
web2=			<input id="cmdline" type="text" name="Cmd" size="56" value="Say " maxlength="80">
web4=			<input class="button" type="submit" onclick="submit_console(); return false;">
web5=		</form>

// Restart map
[MapRestartPage]
WebContentLen=3
web0=%frd:PageHeader%
web1=		<h2>Restarting map, please wait.</h2>%Content:UWebAdmin.RestartMapCode%
web2=		<h3>Please click <a href="/Index">here</a> once its done.</h3>
web3=%frd:PageEnding%

// Switch map
[MapSwitchingPage]
WebContentLen=3
web0=%frd:PageHeader%w
web1=		<h2>Server is now switching the map, please wait...</h2>
web2=		<script>setTimeout(function(){window.location.href="/Index"},1500);</script>
web3=%frd:PageEnding%

// Banlist page
[BanListPage]
WebContentLen=6
web0=%frd:PageHeader%
web1=%frd:Menu%
web2=			<h1>Banlist</h1>
web3=		<form method="post" action="BanListPage?UWebAdmin.BanListGen">
web4=%Content:UWebAdmin.BanListGen%
web5=		</form>
web6=%frd:PageEnding%

// User logging out
[Logout]
WebContentLen=2
web0=%frd:PageHeader%
web1=		<h2>You have successfully logged out from webadministration page.</h2>%Content:UWebAdmin.UserLogout%
web2=%frd:PageEnding%

// Basic game configures (server packages/server actors/admin/game passwords).
[GameDefaults]
WebContentLen=8
web0=%frd:PageHeader%
web1=%frd:Menu%
web2=		<h1>Game Configuration</h1>
web3=		<form method="post" action="GameDefaults?UWebAdmin.GameConfigPage">
web4=%Content:UWebAdmin.GameConfigPage%
web5=		</form>
web6=		<form method="post" action="GameDefaults?UWebAdmin.NetConfigPage">
web7=%Content:UWebAdmin.NetConfigPage%
web8=		</form>
web9=%frd:PageEnding%

// Maplist Links page
[MapLinksPage]
WebContentLen=6
web0=%frd:PageHeader%
web1=%frd:Menu%
web2=		<h1>Maplist configuration</h1>
web3=		<form method="post" action="MapLinksPage?UWebAdmin.MapListLinkPage">
web4=%Content:UWebAdmin.MapListLinkPage%
web5=		</form>
web6=%frd:PageEnding%

// Mod Link page
[ModLinksPage]
WebContentLen=4
web0=%frd:PageHeader%
web1=%frd:Menu%
web2=		<h1>Custom mod configuration</h1>
web3=%Content:UWebAdmin.ModLinkPage%
web4=%frd:PageEnding%

// Mod based game configures (works using special hacks).
[ModConfigPage]
WebContentLen=3
web0=%frd:PageHeader%
web1=%frd:Menu%
web2=%MODBASED%
web3=%frd:PageEnding%

// Maplist game configures (also works using special hacks).
[MapLConfigPage]
WebContentLen=3
web0=%frd:PageHeader%
web1=%frd:Menu%
web2=%Content:UWebAdmin.MapListPage%
web3=%frd:PageEnding%

// Map switch page.
[MapChange]
WebContentLen=4
web0=%frd:PageHeader%
web1=%frd:Menu%
web2=			<h1>Change Map</h1>
web3=			<h2>*<a href="/MapRestartPage">Restart Current Map</a></h2>
web4=			<form method="post" action="MapSwitchingPage?UWebAdmin.MapSwitchPage">/n%Content:UWebAdmin.MapSwitchPage%</form>
web5=%frd:PageEnding%

// Global stuff
[PageHeader]
WebContentLen=8
web0=<!DOCTYPE HTML>
web1=<html lang="en">
web2=	<head>
web3=		<meta charset="utf-8">
web4=		<meta name="description" content="Server WebAdministration code /WebVer">
web5=		<title>Unreal Gold Server Administration</title>
web6=%frd:CSS%
web7=	</head>
web8=	<body>

// The "ending" part of this page.
[PageEnding]
webContentLen=1
web0=	</body>
web1=</html>
 





  
Back to top
 
IP Logged
 
Smirftsch
Forum Administrator
*****
Offline



Posts: 7763
Location: at home
Joined: Apr 30th, 1998
Gender: Male
Re: Idea: Web admin API
Reply #12 - Oct 15th, 2018 at 12:06pm
Print Post  
oh cool, need to test this. Maybe this could be even used for 227j, if you are ok with that Smiley

and sorry, have been very RL busy in the last weeks.

We have a css file btw, it's in the WebServer folder, so perhaps you want to use this instead of embedding.

  

Sometimes you have to lose a fight to win the war.
Back to top
WWWICQ  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint
Bookmarks: del.icio.us Digg Facebook Google Google+ Linked in reddit StumbleUpon Twitter Yahoo