Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of ssh://github.com/samholman/MC-Monitor
- Loading branch information
Showing
11 changed files
with
107 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
define('CONSOLE_REQUEST', true); | ||
require('public/index.php'); | ||
|
||
$application->bootstrap(); | ||
|
||
$server = new Application_Model_Map(); | ||
$server->regenerate(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -233,10 +233,3 @@ a:hover { | |
color: #009900; | ||
} | ||
|
||
.chat { | ||
width: 100%; | ||
} | ||
|
||
|
||
|
||
|