Permalink
Browse files

Merge branch 'master' of ssh://github.com/samholman/MC-Monitor

  • Loading branch information...
2 parents da4d0ae + 3e5ae99 commit b3b7612269ad2177a1f64bb9516c077d9d91b0bf @samholman committed Aug 6, 2011
View
@@ -18,6 +18,9 @@
<controllerFile controllerName="Server">
<actionMethod actionName="index"/>
</controllerFile>
+ <controllerFile controllerName="Map">
+ <actionMethod actionName="index"/>
+ </controllerFile>
</controllersDirectory>
<formsDirectory>
<formFile formName="Login"/>
@@ -30,6 +33,7 @@
<modelFile modelName="PlayerData"/>
<modelFile modelName="PlayerList"/>
<modelFile modelName="Iterator"/>
+ <modelFile modelName="Map"/>
</modelsDirectory>
<modulesDirectory enabled="false"/>
<viewsDirectory>
@@ -46,6 +50,9 @@
<viewControllerScriptsDirectory forControllerName="Server">
<viewScriptFile forActionName="index"/>
</viewControllerScriptsDirectory>
+ <viewControllerScriptsDirectory forControllerName="Map">
+ <viewScriptFile forActionName="index"/>
+ </viewControllerScriptsDirectory>
</viewScriptsDirectory>
<viewHelpersDirectory/>
<viewFiltersDirectory enabled="false"/>
@@ -87,6 +94,9 @@
<testApplicationControllerFile forControllerName="Server">
<testApplicationActionMethod forActionName="index"/>
</testApplicationControllerFile>
+ <testApplicationControllerFile forControllerName="Map">
+ <testApplicationActionMethod forActionName="index"/>
+ </testApplicationControllerFile>
</testApplicationControllerDirectory>
</testApplicationDirectory>
<testLibraryDirectory/>
@@ -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]
@@ -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();
}
}
@@ -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;
+ }
+
+
+}
+
View
@@ -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';
+ }
+}
+
@@ -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;
}
@@ -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">
@@ -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>
@@ -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>
View
@@ -0,0 +1,9 @@
+<?php
+
+define('CONSOLE_REQUEST', true);
+require('public/index.php');
+
+$application->bootstrap();
+
+$server = new Application_Model_Map();
+$server->regenerate();
View
@@ -233,10 +233,3 @@ a:hover {
color: #009900;
}
-.chat {
- width: 100%;
-}
-
-
-
-

0 comments on commit b3b7612

Please sign in to comment.