<?php
     $gridInfo      = getGridInfo($_POST['region_grid_home_url']);
     $serviceURLS   = getUserServiceURL($_POST['region_grid_home_url'], $_POST['object_owner']);
     $userInfo      = getUserInfo(@$serviceURLS['SRV_HomeURI'], $_POST['object_owner']);
     $regionInfo    = getRegionInfo($serviceURLS['SRV_HomeURI'], $_POST['region_name']);
     $regionData    = getRegionData($serviceURLS['SRV_HomeURI'], $regionInfo['uuid']);

     if(!isset($gridInfo) || count($gridInfo) == 0)
          die("getGridInfo request error");

     if(!isset($serviceURLS) || count($serviceURLS) == 0)
          die("serviceURLS request error");

     if(!isset($regionInfo['result']) || $regionInfo['result'] == "false")
          die("regionInfo request error");

     if(!isset($regionData['result']) || $regionData['result'] == "false")
          die("regionData request error");

     if(!isset($userInfo['result']) || $userInfo['result'] == "false")
          die("userInfo request error");

     //Add Grid
     $GridData      = new OSGrid(@$gridInfo['gridname'], @$serviceURLS['SRV_HomeURI'], @$serviceURLS['SRV_AssetServerURI'], @$serviceURLS['SRV_IMServerURI']); 

     if(!isset($GridData))
          die("Unknown Error: Grid data not in db.");

     //Add Region
     $RegionData    =   $GridData->addRegion(@$regionData['region_name'], @$regionInfo['uuid'], @$_POST['object_owner'], @$_POST['region_image_asset'], @$regionData['hostname'], @$regionData['http_port']);

     //Add User
     $UserData      =   $GridData->addUser(@$_POST['object_owner'], $userInfo['user_firstname']." ".$userInfo['user_lastname'], "");
?>