Jump to content


Photo

DataRun - Online Statistics


  • Please log in to reply
5 replies to this topic

#1 xiongmao

xiongmao
  • Members
  • 175 posts
  • Location:Paris

Posted 05 May 2008 - 10:28 PM

Hi all,
I've worked on the OnlineStatistics (Further informations) this evening and manage to send post request to Ash's server.
Ash is the person in charge of creating DataRun Website, he provided us a test page to send post and get request at the following address: http://kyuu.co.uk/datarun.php

If you enter the following url for example http://kyuu.co.uk/da...hp?game=dataRun
the web browser will displayed
post vars

get vars
"game" = dataRun

The Objective was to send this kind of request using TcpLink UnrealScript class and here is the code which do that:

Use Class
var DataRun_TcpLink wConn;
wConn = spawn(class'DataRun_TcpLink');
wConn.sendPlayerStat("1664", "BeerLand", "124", "51");

TCPLink Class
class DataRun_TcpLink extends TcpLink
	 config(DataRun);

var config String ipWebSite, urlWebSite, pathFile;
var config int portNumber;

var IpAddr ipA;

function PostBeginPlay()
{

   super.PostBeginPlay();

   StringToIpAddr(ipWebSite, ipA);
   ipA.Port = portNumber;

   BindPort();

   // receive events rather than get data manually
   ReceiveMode = EReceiveMode.RMODE_Event;

   //method receiveText call
   LinkMode = ELinkMode.MODE_Text;
}

/*
 Send a Post Request as follow

  POST /datarun.php HTTP/1.0
  From: xiongmao@datarun.com
  User-Agent: HTTPTool/1.0
  Content-Type: application/x-www-form-urlencoded
  Content-Length: 27
  [Blank Line]
  userid=xiongmao&password=guessme
*/
function sendPlayerStat(String playerID, String level, String totalTime, String energy)
{
  local String httpRequest, request;

  request = getRequest(playerID, level, totalTime, energy);
  httpRequest = getStandardHeader();
  httpRequest $= getContentLength(request);
  httpRequest $= Chr(13)$Chr(10); // add the blank line
  httpRequest $= request;

  if(!IsConnected())
	Open(ipA);

  SendText(httpRequest);
}

function String getStandardHeader()
{
  local String header;

  //set the path of the file which will receive the post request
  header =  "POST /"$pathFile$" HTTP/1.0"$Chr(13)$Chr(10);

  //set the sender (optional)
  header $= "From: xiongmao@datarun.com"$Chr(13)$Chr(10);

  //set user agent
  header $= "User-Agent: HTTPTool/1.0"$Chr(13)$Chr(10);

  //set encode type
  header $= "Content-Type: application/x-www-form-urlencoded"$Chr(13)$Chr(10);

  return header;
}

function String getContentLength(String request)
{
  local String cLength;
  cLength = "Content-Length: "$len(request)$Chr(13)$Chr(10);
  return cLength;
}

function String getRequest(String playerID, String level, String totalTime, String energy)
{
  local String request;
  request = "playerID="$playerID$"&level="$level$"&totalTime="$totalTime$"&energy="$energy;
  return request;
}

event ReceivedText( string Text )
{
   LogInternal("text: "$Text);
}

defaultproperties
{
  pathFile =  "datarun.php"
  ipWebSite =  "82.17.97.168"
  urlWebSite = "http://kyuu.co.uk"
  portNumber = 80
}

and you will see a great trace in your logfile:

HTTP/1.1 200 OK
Date: Mon, 05 May 2008 22:11:59 GMT
Server: Apache
X-Powered-By: PHP/5.2.6RC1-pl1-gentoo
Content-Length: 493
Connection: close
Content-Type: text/html

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
	<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
	<title>kyuu</title>
  </head>
<body>
<h1>post vars</h1>
<ul>
<li>"playerID" = 1664</li><li>"level" = BeerLand</li><li>"totalTime" = 124</li><li>"energy" = 51</li></ul>
<h1>get vars</h1>
</body>
</html>

I can't figure out how to find gameSpyId if anyone has a clue ? if not players will have to create a kind of account on the website.
I don't know if it's necessary to take care of receive message (maybe the first line to see if the request has succeeded)

Comment? questions?

#2 ambershee

ambershee

    Nimbusfish Rawks

  • Hosted
  • 3,114 posts
  • Location:Derby, UK
  • Projects:Mutator Week & Unreal 3 Projects
  •  Mad Mod Boffin

Posted 05 May 2008 - 10:49 PM

Great work. I'm not sure if it's possible to get the gamespy ID - I'll look into it. However, it should be possible to send the player name. All player names in UT3 are unique, as far as I'm aware, because that's tied to the account.

#3 yuumei

yuumei
  • Project Team
  • 10 posts
  • Location:Derby,UK
  • Projects:DataRun

Posted 08 May 2008 - 06:44 PM

Awesome work! I'll create the db to hold this info and the php files behind it.
Just for confirmation, my ip address is dynamic so we'll have to put this thing on another when it goes live and change the url and ip accordingly.
So are we ok using php and postgresql/mysql on whatever server we will be using?

If the user name is tied to their account then we can use that to identify people. Although this brings up my point about not ever being able to stop anyone impersonating another user. They could just spoof a post request. At least I can't think of any way of doing it ^^
chown -R us ./base
^^*

#4 xiongmao

xiongmao
  • Members
  • 175 posts
  • Location:Paris

Posted 08 May 2008 - 09:20 PM

Ip and url are configurable fields so there's no problem. Do you intend to use DNS or something like that or do we have a fix IP at last ? (For now, I don't know how to resolve IP from url don't even know if it's possible).
Database type is your choice as we only send post request :p
For the last point, I have some doubts about using PlayerName. Some people can play DataRun without been registered(offline) and send record with a username which could potentially match an other username. Creating account on the website would be the safest way but too much bother for player. Luke may find how to get GameSpyID.
We should also prevent direct request, here is the current post request sent:
POST /datarun.php HTTP/1.0
  From: xiongmao@datarun.com
  User-Agent: HTTPTool/1.0
  Content-Type: application/x-www-form-urlencoded
  Content-Length: 27
  [Blank Line]
  userid=xiongmao&password=guessme
We could specify "From" section or another by a specific value telling your PHPFile that the request is coming from datarun game and not from a browser for example.
I don't know much about Web Hack so if you have some ideas ?

#5 yuumei

yuumei
  • Project Team
  • 10 posts
  • Location:Derby,UK
  • Projects:DataRun

Posted 09 May 2008 - 08:33 AM

Do you intend to use DNS or something like that or do we have a fix IP at last ?

Well, that's up to whoever decides what server the website will finally be on :3

Database type is your choice as we only send post request

Again, this depends if the server has the db.

Creating account on the website would be the safest way but too much bother for player. Luke may find how to get GameSpyID.

Creating an account on the server would things a little more complicated because you would have to send the username and password with the stats to the website.
I did a quick search for gamespy api's and it seems you can do things with them, but you have to be a developer D:

We could specify "From" section or another by a specific value telling your PHPFile that the request is coming from datarun game and not from a browser for example.

Nah - anything you can send in that post request, you can send without being in the game. All we can do is obfuscate posting the data.
chown -R us ./base
^^*

#6 ambershee

ambershee

    Nimbusfish Rawks

  • Hosted
  • 3,114 posts
  • Location:Derby, UK
  • Projects:Mutator Week & Unreal 3 Projects
  •  Mad Mod Boffin

Posted 12 May 2008 - 10:44 AM

Awesome work! I'll create the db to hold this info and the php files behind it.
Just for confirmation, my ip address is dynamic so we'll have to put this thing on another when it goes live and change the url and ip accordingly.
So are we ok using php and postgresql/mysql on whatever server we will be using?


We'll be using the current Shee Labs site. We can do PHP and MySQL for sure, and it has a fixed IP (75.126.231.34).


If the user name is tied to their account then we can use that to identify people. Although this brings up my point about not ever being able to stop anyone impersonating another user. They could just spoof a post request. At least I can't think of any way of doing it ^^


We should be able to get hold of quite a bit of player data, looking at things. We could potentially make it very difficult to spoof a request by using a various sets of gamespy related data (which cannot be faked by the player in the game), as well as using some obfuscation to encrypt. I think we can get a lot of this information. OnlineSystemGameSpy has a single non-native file that contains a lot of data. The trouble is working out how to access it. I cannot find where the object itself is created, but I believe it's done natively very early in the game initialisation, meaning we may have some difficulty. UTEngine.ini allows us to create a different default online subsystem. It stands to reason we could possible extend the current one and add a couple of functions. This also might not be possible.

We have good access to login and OnlinePlayerInterfaces in the engine script classes too. I'll keep rummaging. We don't actually use GameSpy at work, so I have only very partial complete code to look at, so I'm not better off than most modders..




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users