REST half-implemented

ogs-cs@86
gareth 2007-02-25 06:26:37 +00:00
parent f1db84e57c
commit 8bb7f6a48e
5 changed files with 63 additions and 18 deletions

View File

@ -2,8 +2,8 @@
// this file tells all the OGS services where to find the MySQL database // this file tells all the OGS services where to find the MySQL database
// if multiple OGS services are running on one machine, it is assumed that they all use the same MySQL server/database // if multiple OGS services are running on one machine, it is assumed that they all use the same MySQL server/database
$dbhost="localhost"; $dbhost="autopia.garethnelson.com";
$dbuser="opengridservice"; $dbuser="opengridservice";
$dbname="OGS"; $dbname="OGS";
$dbpasswd=""; $dbpasswd="supersecret";
?> ?>

View File

@ -23,6 +23,14 @@ function format_lluuid($uuid)
return strtolower(substr($uuid,0,8)."-".substr($uuid,8,4)."-".substr($uuid,12,4)."-".substr($uuid,16,4)."-".substr($uuid,20)); return strtolower(substr($uuid,0,8)."-".substr($uuid,8,4)."-".substr($uuid,12,4)."-".substr($uuid,16,4)."-".substr($uuid,20));
} }
function output_xml_block($blockname, $data) {
echo("<$blockname>\n");
foreach($data as $name => $value) {
echo(" <$name>$value</$name>\n");
}
echo("</$blockname>\n");
}
function rand_uuid() function rand_uuid()
{ {
return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',

View File

@ -2,13 +2,13 @@
// All the grid server specific stuff lives here // All the grid server specific stuff lives here
// What we send to authenticate to the user/login server // What we send to authenticate to the user/login server
$userserver_sendkey="YO LOGIN, I'm ThE ReAL thInG and CaSE SeNSiTIVe TOO! Random stuff is good in our keys - 2432324343ifvo3o332i32o32i32o"; $userserver_sendkey="1234";
// What we expect to get back from the user/login server // What we expect to get back from the user/login server
$userserver_recvkey="HEY GRID SERVER, I AM THE DAMN LOGIN SERVER, THIS IS MY KEY! ooh, randomness 32432gfrgergregrgrt34to44i433igfh44t09i094r09"; $userserver_recvkey="1234";
$sim_recvkey = "we are not linden labs1234dyson"; $sim_recvkey = "1234";
$sim_sendkey = "you are ogs4325678"; $sim_sendkey = "1234";
$grid_home = "/ogs/gridserver/"; $grid_home = "/ogs/gridserver/";
?> ?>

View File

@ -1,8 +1,14 @@
<? <?
// This file parses URLs of the format:
// usersessions/key/userid/data
// where key is the key to authenticate with the grid, userid is the user's LLUUID and data is the data about the user's session being requested
// if the data requested is left out, an XML response will be sent
error_reporting(E_ALL); // Remember kids, PHP errors kill XML-RPC responses and REST too! will the slaughter ever end? error_reporting(E_ALL); // Remember kids, PHP errors kill XML-RPC responses and REST too! will the slaughter ever end?
include("../gridserver_config.inc.php"); include("../gridserver_config.inc.php");
include("../../common/database.inc.php"); include("../../common/database.inc.php");
include("../../common/util.inc.php");
// Parse out the parameters from the URL // Parse out the parameters from the URL
$params = str_replace($grid_home,'', $_SERVER['REQUEST_URI']); $params = str_replace($grid_home,'', $_SERVER['REQUEST_URI']);
@ -11,17 +17,47 @@ $params = split('/',$params);
// Die if the key doesn't match // Die if the key doesn't match
if($params[1]!=$sim_recvkey) { if($params[1]!=$sim_recvkey) {
// die(); die();
} }
print_r($params); // if only 4 params, assume we are sending an XML response
// Send requested data if(count($params)==3) {
switch($params[0]) { $link = mysql_connect($dbhost,$dbuser,$dbpasswd)
case 'getasset': OR die("Unable to connect to database");
if($params[3]=="data") {
Header("Content-Length: ". (string)filesize($asset_repos . "/" . $params[2] . "/data")); mysql_select_db($dbname)
readfile($asset_repos . "/" . $params[2] . "/data"); or die("Unable to select database");
$agent_id = strtolower($params[2]);
$query = "SELECT * FROM sessions WHERE agent_id='$agent_id' AND session_active=1";
$result = mysql_query($query);
if(mysql_num_rows($result)>0) {
$info=mysql_fetch_assoc($result);
$circuit_code = $info['circuit_code'];
$secure_session_id=$info['secure_session_id'];
$session_id=$info['session_id'];
$query = "SELECT * FROM local_user_profiles WHERE userprofile_LLUUID='$agent_id'";
$result=mysql_query($query);
$userinfo=mysql_fetch_assoc($result);
$firstname=$userinfo['profile_firstname'];
$lastname=$userinfo['profile_lastname'];
$agent_id=$userinfo['userprofile_LLUUID'];
output_xml_block("usersession",Array(
'authkey' => $sim_sendkey,
'circuit_code' => $circuit_code,
'agent_id' => $agent_id,
'session_id' => $session_id,
'secure_session_id' => $secure_session_id,
'firstname' => $firstname,
'lastname' => $lastname
));
} }
break;
} }
?> ?>

View File

@ -2,9 +2,10 @@
// All the user/login server specific stuff lives here // All the user/login server specific stuff lives here
// What we send to authenticate to the grid server // What we send to authenticate to the grid server
$gridserver_sendkey="HEY GRID SERVER, I AM THE DAMN LOGIN SERVER, THIS IS MY KEY! ooh, randomness 32432gfrgergregrgrt34to44i433igfh44t09i094r09"; $gridserver_sendkey="1234";
// What we expect to get back from the grid server // What we expect to get back from the grid server
$gridserver_recvkey="YO LOGIN, I'm ThE ReAL thInG and CaSE SeNSiTIVe TOO! Random stuff is good in our keys - 2432324343ifvo3o332i32o32i32o"; $gridserver_recvkey="1234";
$gridserver_url="http://www.osgrid.org/ogs/gridserver/index.php";
?> ?>