diff --git a/api/get.php b/api/get.php deleted file mode 100644 index e69de29..0000000 diff --git a/api/register.php b/api/register.php index 5d94b84..2d0d266 100644 --- a/api/register.php +++ b/api/register.php @@ -1,85 +1,5 @@ get_server_urlsuserID'.$userID.''; - $optionen = stream_context_create(array('http' => array('timeout' => 1, 'method' => 'POST', 'header' => 'Content-Type: application/xml', 'content' => $xml))); - $result = file_get_contents($homeURL, false, $optionen); - - $servers = new SimpleXMLElement($result); - - foreach ($servers->params->param->value->struct[0] as $serverEntry) - { - if($serverEntry->name == 'SRV_AssetServerURI') - return $serverEntry->value->string->__toString(); - } - } - - function getAssetData($assetServer, $assetUUID) - { - global $DATA; - chdir("/var/www/html"); - - if(!is_file('./data/RegionImages/'.$assetUUID.'.png')) - { - $DATA['WGETCMD'] = '/usr/bin/wget '.$assetServer.'assets/'.$assetUUID.'/data -O /tmp/'.$assetUUID; - $DATA['MPEGCMD'] = '/usr/bin/ffmpeg -i /tmp/'.$assetUUID.' ./data/RegionImages/'.$assetUUID.'.png'; - - $DATA['WGET'] = shell_exec($DATA['WGETCMD']); - $DATA['FFMPEG'] = shell_exec($DATA['MPEGCMD']); - } - - return $assetUUID.'.png'; - } - - function getRegionStats($regionHostName) - { - $optionen = stream_context_create(array('http' => array('timeout' => 1))); - $result = file_get_contents("http://".$regionHostName."/jsonSimStats", false, $optionen); - - if($result != "") - { - return json_decode($result); - } - } - - if(isset($_SERVER['HTTP_X_SECONDLIFE_SHARD']) && isset($_SERVER['HTTP_X_SECONDLIFE_REGION'])) - { - $DATA = array(); - $DATA['RegionData'] = explode("(", $_SERVER['HTTP_X_SECONDLIFE_REGION']); - $DATA['RegionName'] = trim($DATA['RegionData'][0]); - $DATA['RegionID'] = md5($_SERVER['HTTP_X_SECONDLIFE_REGION'].$_REQUEST['grid']); - $DATA['Position'] = trim(str_replace(" ", "", str_replace(")", "", str_replace("(", "", $_SERVER['HTTP_X_SECONDLIFE_LOCAL_POSITION'])))); - $DATA['PositionData'] = explode(",", $DATA['Position']); - - $DATA['PositionData'][0] = explode(".", $DATA['PositionData'][0])[0]; - $DATA['PositionData'][1] = explode(".", $DATA['PositionData'][1])[0]; - $DATA['PositionData'][2] = explode(".", $DATA['PositionData'][2])[0]; - - - $DATA['GridHomeURI'] = $_REQUEST['GridHomeURI']; - $DATA['Link'] = "hop://".str_replace("http://", "", $DATA['GridHomeURI']).":".$DATA['RegionName']."/".$DATA['PositionData'][0]."/".$DATA['PositionData'][1]."/".$DATA['PositionData'][2]; - $DATA['AgentCount'] = $_REQUEST['AgentCount']; - $DATA['Beschreibung'] = file_get_contents("php://input"); - - $DATA['AssetServer'] = getServerURI($DATA['GridHomeURI'], $_SERVER['HTTP_X_SECONDLIFE_OWNER_KEY']); - $DATA['AssetPath'] = getAssetData($DATA['AssetServer'], $_REQUEST['RegionImageTexture']); - - $DATA['GridName'] = $_REQUEST['GridName']; - - if(!isset($DATA['RegionName']) || @$DATA['RegionName'] == "")die("ERROR: RegionName"); - if(!isset($DATA['Beschreibung']) || @$DATA['Beschreibung'] == "")die("ERROR: Beschreibung"); - if(!isset($DATA['GridHomeURI']) || @$DATA['GridHomeURI'] == "")die("ERROR: GridHomeURI"); - if(!isset($DATA['AgentCount']) || @$DATA['AgentCount'] == "")die("ERROR: AgentCount"); - if(!isset($DATA['GridName']) || @$DATA['GridName'] == "")die("ERROR: GridName"); - - $MYSQLDATA = array('RegionID' => $DATA['RegionID'], 'RegionName' => $DATA['RegionName'], 'RegionBeschreibung' => $DATA['Beschreibung'], 'RegionLink' => $DATA['Link'],'PositionX' => $DATA['PositionData'][0], 'PositionY' => $DATA['PositionData'][1], 'PositionZ' => $DATA['PositionData'][2], 'GridName' => $DATA['GridName'], 'ImageName' => $DATA['AssetPath'], 'LastSeen' => time(), 'OnlineUser' => $DATA['AgentCount']); - $statementSend = $RUNTIME['PDO']->prepare('REPLACE INTO Regions (RegionID, RegionName, RegionBeschreibung, RegionLink, PositionX, PositionY, PositionZ, GridName, ImageName, LastSeen, OnlineUser) VALUES (:RegionID, :RegionName, :RegionBeschreibung, :RegionLink, :PositionX, :PositionY, :PositionZ, :GridName, :ImageName, :LastSeen, :OnlineUser)'); - $statementSend->execute($MYSQLDATA); - - echo "OK"; - }else{ - die("ERROR: LSL"); - } - - //file_put_contents("debug-".time().".txt", print_r($GLOBALS, true)); + $data = json_decode(file_get_contents('php://input'), true); + + file_put_contents("debug_".time().".txt", print_r($data, true)); ?> diff --git a/classen/RegionManager.php b/classen/RegionManager.php index 6f25a2a..261dd80 100644 --- a/classen/RegionManager.php +++ b/classen/RegionManager.php @@ -38,10 +38,7 @@ { global $RUNTIME; - $removeRegionStatement = $RUNTIME['PDO']->prepare("DELETE FROM regions WHERE RegionUUID = ?"); - $removeRegionStatement->execute(array($uuid)); - - $removeRegionStatement = $RUNTIME['PDO']->prepare("DELETE FROM onlinetimes WHERE RegionUUID = ?"); + $removeRegionStatement = $RUNTIME['PDO']->prepare("DELETE regions, onlinetimes FROM regions INNER JOIN onlinetimes ON regions.RegionUUID = onlinetimes.RegionUUID WHERE regions.RegionUUID = ?"); $removeRegionStatement->execute(array($uuid)); } } diff --git a/classen/utils.php b/classen/utils.php index b2cdc78..930224f 100644 --- a/classen/utils.php +++ b/classen/utils.php @@ -86,10 +86,10 @@ function getAssetImage($assetServer, $assetUUID) global $DATA; chdir("/var/www/html"); - if(!is_file('./data/RegionImages/'.$assetUUID.'.png')) + if(!is_file('./data/RegionImages/'.$assetUUID.'.jpg')) { $DATA['WGETCMD'] = '/usr/bin/wget '.$assetServer.'assets/'.$assetUUID.'/data -O /tmp/'.$assetUUID; - $DATA['MPEGCMD'] = '/usr/bin/ffmpeg -i /tmp/'.$assetUUID.' ./data/RegionImages/'.$assetUUID.'.png'; + $DATA['MPEGCMD'] = '/usr/bin/ffmpeg -i /tmp/'.$assetUUID.' ./data/RegionImages/'.$assetUUID.'.jpg'; $DATA['WGET'] = shell_exec($DATA['WGETCMD']); $DATA['FFMPEG'] = shell_exec($DATA['MPEGCMD']); @@ -116,25 +116,25 @@ function getTopRegionHTML($row) if(!isset($row['Image'])) return; - if(!file_exists("./data/RegionImages/".$row['Image'])) - $row['Image'] = "notFound.jpg"; + if(!file_exists("./data/RegionImages/".$row['Image'].".jpg")) + $row['Image'] = "notFound"; if(!isset($row['Description'])) $row['Description'] = "(Es wurde noch keine Beschreibung hinterlegt.)"; return ''; + Region Image '.substr($row['Name'], 0, 50).''; } function getRegionHTML($row) { - if(!file_exists("./data/RegionImages/".$row['Image'])) - $row['Image'] = "notFound.jpg"; + if(!file_exists("./data/RegionImages/".$row['Image']."jpg")) + $row['Image'] = "notFound"; if(!isset($row['Description'])) $row['Description'] = "(Es wurde noch keine Beschreibung hinterlegt.)"; - return '
Region Image '.substr($row['Name'], 0, 50).' + return '
Region Image '.substr($row['Name'], 0, 50).'

'.substr($row['Name'], 0, 50).'

Online: '.$row['OnlineCount'].'

'.substr($row['Description'], 0, 300).'

'; } ?> \ No newline at end of file diff --git a/cron/03-download_images.php b/cron/03-download_images.php deleted file mode 100644 index 5c3c24d..0000000 --- a/cron/03-download_images.php +++ /dev/null @@ -1,16 +0,0 @@ -prepare("SELECT regions.RegionName AS Name, regions.RegionUUID AS UUID, regions.RegionImage AS Image, regions.RegionOwner AS OwnerID, users.UserName AS OwnerName, onlinetimes.RegionLastSeen AS LastSeen, onlinetimes.RegionOnlineUser AS OnlineCount, regions.RegionVersion AS RegionVersion, regions.RegionHostname AS Hostname, regions.RegionPort AS Port FROM regions INNER JOIN onlinetimes ON regions.RegionUUID = onlinetimes.RegionUUID INNER JOIN users ON regions.RegionOwner = users.UserUUID WHERE onlinetimes.RegionLastSeen < ? ORDER BY LastSeen ASC"); - $topRegionStatement->execute(array(time() - 600)); - - while($row = $topRegionStatement->fetch()) - { - if(ping($row['Hostname'], $row['Port'])) - { - RegionManager::setOnlineTime($row['UUID']); - continue; - } - - RegionManager::removeRegion($row['UUID']); - } - -?> \ No newline at end of file diff --git a/cron/03-regionImageDownload.php b/cron/03-regionImageDownload.php new file mode 100644 index 0000000..07b756a --- /dev/null +++ b/cron/03-regionImageDownload.php @@ -0,0 +1,20 @@ +prepare("SELECT * FROM queue WHERE QueueType = 'regionImageDownload'"); + $QueueStatement->execute(array()); + + while($row = $QueueStatement->fetch()) + { + $queueData = json_decode($row['QueueData']); + + if(!is_file('./data/RegionImages/'.$queueData->TargetAssetUUID.'.jpg')) + { + $rawImage = getDataFromHTTP($queueData->URL, ""); + + file_put_contents("./data/RegionImages/".$queueData->TargetAssetUUID.".jpg", $rawImage); + } + + $removeQueueStatement = $RUNTIME['PDO']->prepare("DELETE FROM queue WHERE QueueID = ?"); + $removeQueueStatement->execute(array($row['QueueID'])); + } + +?> \ No newline at end of file diff --git a/data/RegionImages/4376f83d-79be-4e23-acc7-165beb8dc8d8.jpg b/data/RegionImages/4376f83d-79be-4e23-acc7-165beb8dc8d8.jpg new file mode 100644 index 0000000..8ba6bf7 Binary files /dev/null and b/data/RegionImages/4376f83d-79be-4e23-acc7-165beb8dc8d8.jpg differ diff --git a/pages/start.php b/pages/start.php index e75a379..c5d62de 100644 --- a/pages/start.php +++ b/pages/start.php @@ -4,7 +4,7 @@ $HTML->importHTML("style/default/start.html"); $RegionManager = new RegionManager(0, 28); - + $HTML->ReplaceLayoutInhalt("%%TopRegion%%", getTopRegionHTML($RegionManager->getNextRegion())); while($region = $RegionManager->getNextRegion()) @@ -12,7 +12,6 @@ $HTML->ReplaceLayoutInhalt("%%RegionList%%", @$RUNTIME['RegionList']); - $HTML->build(); echo $HTML->ausgabe(); ?> \ No newline at end of file