From 07ac6ade39ea0eb73931c40f60c80e3d8f1e46df Mon Sep 17 00:00:00 2001 From: God Mod Date: Mon, 27 Apr 2015 16:54:18 +0200 Subject: [PATCH] Fixed Tera Status --- tera/status.class.php | 9 +++++---- tera/tera_html.class.php | 7 ++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/tera/status.class.php b/tera/status.class.php index 08d3458..f372d5a 100644 --- a/tera/status.class.php +++ b/tera/status.class.php @@ -47,7 +47,7 @@ public static function __shortcuts(){ protected $game_name = 'tera'; /* URL to load serverstatus from */ - private $status_url = 'http://tera-europe.com/server-status.html'; + private $status_url = 'http://en.tera.gameforge.com/community/serverstatus'; /* cache time in seconds default 30 minutes = 1800 seconds */ private $cachetime = 1800; @@ -120,11 +120,11 @@ protected function getOutput($servers){ // output status switch ($serverdata['status']){ - case 'online': + case 'status_green': $output .= '
Online
'; $isUnknown = false; break; - case 'offline': + case 'status_red': $output .= '
Offline
'; $isUnknown = false; break; @@ -247,8 +247,9 @@ private function loadServerStatus(){ // process the server lists $tera_servers = $server_list->getServers(); + if (is_array($tera_servers)){ - foreach ($tera_servers as $server){ + foreach ($tera_servers as $server){ $servers[$server->name] = array( 'status' => $server->status, 'population' => intval($server->population), diff --git a/tera/tera_html.class.php b/tera/tera_html.class.php index 4cf4a84..dd4d8e1 100644 --- a/tera/tera_html.class.php +++ b/tera/tera_html.class.php @@ -77,7 +77,8 @@ public function clear(){ */ private function process(){ // get the DOM list for the servers - $server_list = $this->dom->find("div[id=serverstatus]", 0); + $server_list = $this->dom->find("div[class=server_status_box]", 0); + if ($server_list) $this->tera_servers = new tera_html_serverlist($server_list); } @@ -161,8 +162,8 @@ public function __get($name){ case 'status': $node = $this->dom->find('td', 0); if (!$node) return 'unknown'; - $img_node = $node->find('img', 0); - return ($img_node ? $img_node->attr['alt'] : 'unknown'); + $span_node = $node->find('span', 0); + return ($node ? trim($span_node->class) : 'unknown'); case 'name': $node = $this->dom->find('td', 1); return ($node ? trim($node->text()) : 'Unknown');