added loadfile again, and pushed unpushed changes
This commit is contained in:
parent
27aac6842e
commit
8b54c9f5ea
@ -8,7 +8,53 @@ namespace ManiaControl;
|
|||||||
* @author steeffeen & kremsy
|
* @author steeffeen & kremsy
|
||||||
*/
|
*/
|
||||||
abstract class FileUtil {
|
abstract class FileUtil {
|
||||||
|
/**
|
||||||
|
* Load a remote file
|
||||||
|
*
|
||||||
|
* @param string $url
|
||||||
|
* @return string || null
|
||||||
|
*/
|
||||||
|
public static function loadFile($url) {
|
||||||
|
if (!$url) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
$urlData = parse_url($url);
|
||||||
|
$port = (isset($urlData['port']) ? $urlData['port'] : 80);
|
||||||
|
|
||||||
|
$fsock = fsockopen($urlData['host'], $port);
|
||||||
|
stream_set_timeout($fsock, 3);
|
||||||
|
|
||||||
|
$query = 'GET ' . $urlData['path'] . ' HTTP/1.0' . PHP_EOL;
|
||||||
|
$query .= 'Host: ' . $urlData['host'] . PHP_EOL;
|
||||||
|
$query .= 'Content-Type: UTF-8' . PHP_EOL;
|
||||||
|
$query .= 'User-Agent: ManiaControl v' . ManiaControl::VERSION . PHP_EOL;
|
||||||
|
$query .= PHP_EOL;
|
||||||
|
|
||||||
|
fwrite($fsock, $query);
|
||||||
|
|
||||||
|
$buffer = '';
|
||||||
|
$info = array('timed_out' => false);
|
||||||
|
while (!feof($fsock) && !$info['timed_out']) {
|
||||||
|
$buffer .= fread($fsock, 1024);
|
||||||
|
$info = stream_get_meta_data($fsock);
|
||||||
|
}
|
||||||
|
fclose($fsock);
|
||||||
|
|
||||||
|
if ($info['timed_out'] || !$buffer) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (substr($buffer, 9, 3) != "200") {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = explode("\r\n\r\n", $buffer, 2);
|
||||||
|
|
||||||
|
if (count($result) < 2) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result[1];
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Load config xml-file
|
* Load config xml-file
|
||||||
*
|
*
|
||||||
|
@ -294,6 +294,9 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO pages
|
||||||
|
|
||||||
|
|
||||||
//render and display xml
|
//render and display xml
|
||||||
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player);
|
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player);
|
||||||
}
|
}
|
||||||
@ -328,7 +331,6 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$this->maniaControl->manialinkManager->labelLine($frame,$array);
|
$this->maniaControl->manialinkManager->labelLine($frame,$array);
|
||||||
//TODO detailed mx info page with link to mxo
|
//TODO detailed mx info page with link to mxo
|
||||||
//TODO action detailed map info
|
//TODO action detailed map info
|
||||||
//TODO later add buttons for jukebox, admin control buttons (remove map, change to map)
|
|
||||||
//TODO side switch
|
//TODO side switch
|
||||||
|
|
||||||
|
|
||||||
@ -341,6 +343,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function closeWidget(array $callback, Player $player) {
|
public function closeWidget(array $callback, Player $player) {
|
||||||
|
//TODO update player things
|
||||||
$this->maniaControl->manialinkManager->closeWidget($player);
|
$this->maniaControl->manialinkManager->closeWidget($player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ class Player {
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
// TODO: check for bot players
|
// TODO: check for bot players
|
||||||
public function isFakePlayer() {
|
public function isFakePlayer() { //TODO Bot have also positive pids, so this is useless, just stringmatch *fake
|
||||||
return ($this->pid <= 0);
|
return ($this->pid <= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ class Player {
|
|||||||
if (isset($pathParts[3])) {
|
if (isset($pathParts[3])) {
|
||||||
return $pathParts[3];
|
return $pathParts[3];
|
||||||
}
|
}
|
||||||
return "";
|
return $this->getCountry();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -159,6 +159,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$countryQuad->setX($x + 88);
|
$countryQuad->setX($x + 88);
|
||||||
$countryQuad->setSize(4,4);
|
$countryQuad->setSize(4,4);
|
||||||
$countryQuad->setZ(-0.1);
|
$countryQuad->setZ(-0.1);
|
||||||
|
//TODO mousover show locations in descript bar
|
||||||
|
|
||||||
|
|
||||||
//Level Quad
|
//Level Quad
|
||||||
$rightQuad = new Quad_BgRaceScore2();
|
$rightQuad = new Quad_BgRaceScore2();
|
||||||
@ -205,6 +207,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_Buddy);
|
$playerQuad->setSubStyle($playerQuad::SUBSTYLE_Buddy);
|
||||||
$playerQuad->setSize(3.8,3.8);
|
$playerQuad->setSize(3.8,3.8);
|
||||||
//$playerQuad->setAction(self::ACTION_FORCE_BLUE . "." .$listPlayer->login);
|
//$playerQuad->setAction(self::ACTION_FORCE_BLUE . "." .$listPlayer->login);
|
||||||
|
//TODO special player thing
|
||||||
|
|
||||||
|
|
||||||
$redQuad = new Quad_Emblems();
|
$redQuad = new Quad_Emblems();
|
||||||
$playerFrame->add($redQuad);
|
$playerFrame->add($redQuad);
|
||||||
|
@ -119,14 +119,21 @@ class PlayerManager implements CallbackListener {
|
|||||||
$this->maniaControl->client->query('GetDetailedPlayerInfo', $login);
|
$this->maniaControl->client->query('GetDetailedPlayerInfo', $login);
|
||||||
$playerInfo = $this->maniaControl->client->getResponse();
|
$playerInfo = $this->maniaControl->client->getResponse();
|
||||||
$player = new Player($playerInfo);
|
$player = new Player($playerInfo);
|
||||||
|
|
||||||
|
var_dump($player);
|
||||||
|
//if($player->isFakePlayer())
|
||||||
|
//return;
|
||||||
|
|
||||||
$this->addPlayer($player);
|
$this->addPlayer($player);
|
||||||
|
|
||||||
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES)) {
|
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES)) {
|
||||||
$string = array(0 => 'New Player', 1 => '$0f0Operator', 2 => '$0f0Admin', 3 => '$0f0MasterAdmin', 4 => '$0f0MasterAdmin');
|
$string = array(0 => '$0f0Player', 1 => '$0f0Moderator', 2 => '$0f0Admin', 3 => '$0f0MasterAdmin', 4 => '$0f0MasterAdmin');
|
||||||
$nickname = Formatter::stripCodes($player->nickname); // TODO: strip codes without colour codes like in serverviewer
|
//$nickname = Formatter::stripCodes($player->nickname); // TODO: strip codes without colour codes like in serverviewer
|
||||||
|
|
||||||
|
//TODO standart notification colour from settings or something
|
||||||
|
|
||||||
$this->maniaControl->chat->sendChat(
|
$this->maniaControl->chat->sendChat(
|
||||||
'$ff0' . $string[$player->authLevel] . ': $fff' . $nickname . '$z $ff0Nation:$fff ' . $player->getCountry() .
|
'$s$0f0' . $string[$player->authLevel] . ' $fff' . $player->nickname . '$z$s$0f0 Nation:$fff ' . $player->getCountry() . ' $z$s$0f0joined');
|
||||||
' $ff0Ladder: $fff' . $player->ladderRank);
|
|
||||||
$this->maniaControl->chat->sendInformation('This server uses ManiaControl v' . ManiaControl::VERSION,$player->login);
|
$this->maniaControl->chat->sendInformation('This server uses ManiaControl v' . ManiaControl::VERSION,$player->login);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,14 +150,19 @@ class PlayerManager implements CallbackListener {
|
|||||||
*/
|
*/
|
||||||
public function playerDisconnect(array $callback) {
|
public function playerDisconnect(array $callback) {
|
||||||
$login = $callback[1][0];
|
$login = $callback[1][0];
|
||||||
//TODO check for fakeplayers
|
|
||||||
$player = $this->removePlayer($login);
|
$player = $this->removePlayer($login);
|
||||||
|
|
||||||
|
//if($player->isFakePlayer())
|
||||||
|
//return;
|
||||||
|
|
||||||
$played = Formatter::formatTimeH(time() - $player->joinTime);
|
$played = Formatter::formatTimeH(time() - $player->joinTime);
|
||||||
$this->maniaControl->log("Player left: " . $player->login . " / " . $player->nickname . " Playtime: " . $played);
|
$this->maniaControl->log("Player left: " . $player->login . " / " . $player->nickname . " Playtime: " . $played);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES)) {
|
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES)) {
|
||||||
$this->maniaControl->chat->sendChat('$<' . $player->nickname . '$> $ff0has left the game. Played:$fff ' . $played);
|
//$this->maniaControl->chat->sendChat('$<' . $player->nickname . '$> $ff0left the game. Played:$fff ' . $played);
|
||||||
|
$this->maniaControl->chat->sendChat('$<' . $player->nickname . '$> $s$0f0has left the game');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user