1
0
KF2-Dev-Scripts/IpDrv/Classes/HelloWeb.uc
2020-12-13 18:01:13 +03:00

74 lines
2.2 KiB
Ucode

/*=============================================================================
HelloWeb.uc - example web server
Copyright 1998-2013 Epic Games, Inc. All Rights Reserved.
=============================================================================*/
class HelloWeb extends WebApplication;
/* Usage:
This is a sample web application, to demonstrate how to program for the web server.
[IpDrv.WebServer]
Applications[0]="IpDrv.HelloWeb"
ApplicationPaths[0]="/hello"
bEnabled=True
http://server.ip.address/hello
*/
function Init()
{
`log("HelloWeb INIT");
}
event Query(WebRequest Request, WebResponse Response)
{
local int i;
`log("Query received"@Request@Response);
if(Request.Username != "test" || Request.Password != "test")
{
Response.FailAuthentication("HelloWeb");
return;
}
switch(Request.URI)
{
case "/form.html":
Response.SendText("<form method=post action=submit.html>");
Response.SendText("<input type=edit name=TestEdit>");
Response.SendText("<p><select multiple name=selecter>");
Response.SendText("<option value=\"one\">Number One");
Response.SendText("<option value=\"two\">Number Two");
Response.SendText("<option value=\"three\">Number Three");
Response.SendText("<option value=\"four\">Number Four");
Response.SendText("</select><p>");
Response.SendText("<input type=submit name=Submit value=Submit>");
Response.SendText("</form>");
break;
case "/submit.html":
Response.SendText("Thanks for submitting the form.<br>");
Response.SendText("TestEdit was \""$Request.GetVariable("TestEdit")$"\"<p>");
Response.SendText("You selected these items:<br>");
for(i=Request.GetVariableCount("selecter")-1;i>=0;i--)
Response.SendText("\""$Request.GetVariableNumber("selecter", i)$"\"<br>");
break;
case "/include.html":
Response.Subst("variable1", "This is variable 1");
Response.Subst("variable2", "This is variable 2");
Response.Subst("variable3", "This is variable 3");
Response.IncludeUHTM("testinclude.html");
break;
default:
Response.SendText("Hello web! The current level is "$WorldInfo.Title);
Response.SendText("<br>Click <a href=\"form.html\">this link</a> to go to a test form");
break;
}
}
defaultproperties
{
}