Skip to content

Commit

Permalink
Merge branch 'master' of ssh://github.com/samholman/MC-Monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
sam committed Aug 6, 2011
2 parents da4d0ae + 3e5ae99 commit b3b7612
Show file tree
Hide file tree
Showing 11 changed files with 107 additions and 26 deletions.
10 changes: 10 additions & 0 deletions .zfproject.xml
Expand Up @@ -18,6 +18,9 @@
<controllerFile controllerName="Server">
<actionMethod actionName="index"/>
</controllerFile>
<controllerFile controllerName="Map">
<actionMethod actionName="index"/>
</controllerFile>
</controllersDirectory>
<formsDirectory>
<formFile formName="Login"/>
Expand All @@ -30,6 +33,7 @@
<modelFile modelName="PlayerData"/>
<modelFile modelName="PlayerList"/>
<modelFile modelName="Iterator"/>
<modelFile modelName="Map"/>
</modelsDirectory>
<modulesDirectory enabled="false"/>
<viewsDirectory>
Expand All @@ -46,6 +50,9 @@
<viewControllerScriptsDirectory forControllerName="Server">
<viewScriptFile forActionName="index"/>
</viewControllerScriptsDirectory>
<viewControllerScriptsDirectory forControllerName="Map">
<viewScriptFile forActionName="index"/>
</viewControllerScriptsDirectory>
</viewScriptsDirectory>
<viewHelpersDirectory/>
<viewFiltersDirectory enabled="false"/>
Expand Down Expand Up @@ -87,6 +94,9 @@
<testApplicationControllerFile forControllerName="Server">
<testApplicationActionMethod forActionName="index"/>
</testApplicationControllerFile>
<testApplicationControllerFile forControllerName="Map">
<testApplicationActionMethod forActionName="index"/>
</testApplicationControllerFile>
</testApplicationControllerDirectory>
</testApplicationDirectory>
<testLibraryDirectory/>
Expand Down
2 changes: 2 additions & 0 deletions application/configs/application.ini-dist
Expand Up @@ -11,6 +11,8 @@ resources.frontController.params.displayExceptions = 0
minecraft.serverPath = "/opt/local/minecraft_server.jar"
minecraft.worldPath = "/opt/local/minecraft"

c10t.path = "/home/tom/software/c10t/c10t"

[staging : production]

[testing : production]
Expand Down
4 changes: 2 additions & 2 deletions application/controllers/IndexController.php
Expand Up @@ -32,7 +32,7 @@ public function indexAction()
*/
public function dashboardAction()
{
$playerList = Application_Model_PlayerList::get();
$this->view->playerList = $playerList->getIterator();
$playerList = Application_Model_PlayerList::get();
$this->view->playerList = $playerList->getIterator();
}
}
20 changes: 20 additions & 0 deletions application/controllers/MapController.php
@@ -0,0 +1,20 @@
<?php

class MapController extends Zend_Controller_Action
{

public function init()
{
/* Initialize action controller here */
}

public function indexAction()
{
$map = new Application_Model_Map();
$map->outputMap();
exit;
}


}

55 changes: 55 additions & 0 deletions application/models/Map.php
@@ -0,0 +1,55 @@
<?php

class Application_Model_Map
{

private
$_generatorPath;

public function __construct()
{
$path = Zend_Registry::get('config')->get('c10t')->get('path');

if (!$path || !file_exists($path)) {
throw new Exception('No path to c10t defined in config: try adding \'c10t.path\'');
}

$this->_generatorPath = Zend_Registry::get('config')->get('c10t')->get('path');
}

/**
* Generate the map file and put it in the temp dir
*/
public function regenerate()
{
exec($this->_generatorPath . ' -w ' . Zend_Registry::get('config')->get('minecraft')->get('worldPath') . '/world -o ' . $this->getMapPath());
}

/**
* Outputs a png header followed by the contents of the map file
*
* @return void
*/
public function outputMap()
{
if (file_exists($this->getMapPath()))
{
header ('Content-Type: image/png');
readfile($this->getMapPath());
}
else {
throw new Exception('Map file not present');
}
}

/**
* Returns the path to the map file
*
* @return string
*/
private function getMapPath()
{
return realpath(APPLICATION_PATH . '/../tmp') . '/map.png';
}
}

4 changes: 1 addition & 3 deletions application/models/Player.php
Expand Up @@ -17,9 +17,7 @@ public function load($username)

if (file_exists($this->getDatFilePath()))
{
$data = $this->getPlayerData();

//$data = gzfile($this->getDatFilePath());
//$data = $this->getPlayerData();

return true;
}
Expand Down
4 changes: 4 additions & 0 deletions application/views/scripts/header.phtml
Expand Up @@ -12,6 +12,10 @@

<!-- Fonts -->
<link href='http://fonts.googleapis.com/css?family=VT323|Geo' rel='stylesheet' type='text/css'>

<!-- JS Libs -->
<script src="/js/libs/prototype.js" type="text/javascript"></script>
<script src="/javascripts/scriptaculous.js" type="text/javascript"></script>
</head>
<body id="body">
<div class="pageContainer">
Expand Down
14 changes: 0 additions & 14 deletions application/views/scripts/index/dashboard.phtml
Expand Up @@ -20,20 +20,6 @@
<?php
}
?>

<div class="player online">
<a class="name">Name <span class="status">(online)</span></a>
<div class="info"></div>
</div>

<div class="player">
<a class="name">Name <span class="status">(offline)</span></a>
<div class="info"></div>
</div>

</div>
<div class="chat">
<h2>Chat</h2>
</div>
</div>

Expand Down
4 changes: 4 additions & 0 deletions application/views/scripts/map/index.phtml
@@ -0,0 +1,4 @@
<br /><br />
<div id="view-content">
<p>View script for controller <b>Map</b> and script/action name <b>index</b></p>
</div>
9 changes: 9 additions & 0 deletions map.php
@@ -0,0 +1,9 @@
<?php

define('CONSOLE_REQUEST', true);
require('public/index.php');

$application->bootstrap();

$server = new Application_Model_Map();
$server->regenerate();
7 changes: 0 additions & 7 deletions public/css/default.css
Expand Up @@ -233,10 +233,3 @@ a:hover {
color: #009900;
}

.chat {
width: 100%;
}




0 comments on commit b3b7612

Please sign in to comment.