poikilos
9 years ago
committed by
Jacob Gustafson
8 changed files with 185 additions and 32 deletions
@ -0,0 +1,111 @@ |
|||||
|
<?php |
||||
|
include_once('browser.php'); |
||||
|
foreach($_REQUEST as $key => $value) { |
||||
|
//in case auto_globals is not enabled |
||||
|
$GLOBALS[$key]=$value; |
||||
|
} |
||||
|
date_default_timezone_set('EST'); //required by PHP >=5.1.0 |
||||
|
|
||||
|
$chunkymapdata_path = "chunkymapdata"; |
||||
|
$showplayers=true; |
||||
|
|
||||
|
function get_dict_from_conf($path, $assignment_operator) { |
||||
|
$handle = fopen($path, "r"); |
||||
|
$result = null; |
||||
|
if ($handle) { |
||||
|
while (($line = fgets($handle)) !== false) { |
||||
|
$line_strip = trim($line); |
||||
|
if (strlen($line_strip)>0) { |
||||
|
if (substr($line_strip)!="#") { |
||||
|
$ao_index = strpos($line_strip, $assignment_operator); |
||||
|
if ($ao_index>0 and $ao_index<(strlen($line_strip)-1)) { //skip blank variable OR value |
||||
|
$found_name = substr($line_strip, 0, $ao_index); |
||||
|
$found_value_index = $ao_index + 1; |
||||
|
$found_value = substr($line_strip, $found_value_index, strlen($line_strip)-$found_value_index); |
||||
|
if ($result===null) { |
||||
|
$result = array(); |
||||
|
} |
||||
|
$result[$found_name]=$found_value; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
fclose($handle); |
||||
|
} else { |
||||
|
echo "<span style=\"color:read\">Failed to read $path</span> (run chunkymap-cronjob script as root first, otherwise see README.md in minetest-chunkymap to ensure installation is correct).<br/>"; |
||||
|
} |
||||
|
return $result; |
||||
|
}//end get_dict_from_conf |
||||
|
|
||||
|
$map_dict = get_dict_from_conf($chunkymapdata_path."/generated.yml"; |
||||
|
|
||||
|
//startsWith and endsWith are from: |
||||
|
//Salmon A. stackoverflow. <http://stackoverflow.com/questions/834303/startswith-and-endswith-functions-in-php>. 5 Feb 2016. 19 Feb, 2016. |
||||
|
function startsWith($haystack, $needle) { |
||||
|
// search backwards starting from haystack length characters from the end |
||||
|
return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== false; |
||||
|
} |
||||
|
function endsWith($haystack, $needle) { |
||||
|
// search forward starting from end minus needle length characters |
||||
|
return $needle === "" || (($temp = strlen($haystack) - strlen($needle)) >= 0 && strpos($haystack, $needle, $temp) !== false); |
||||
|
} |
||||
|
|
||||
|
function echo_chunkymap_table($center_x, $center_z, $zoom_min_1_max_100) { |
||||
|
global $chunkymapdata_path; |
||||
|
global $map_dict; |
||||
|
if ($zoom_min_1_max_100<1) $zoom_min_1_max_100 = 1; |
||||
|
if ($zoom_min_1_max_100>100) $zoom_min_1_max_100 = 100; |
||||
|
$zoom_divisor = int(100/$zoom_min_1_max_100); |
||||
|
$chunk_assoc = array(); |
||||
|
$chunk_count = 0; |
||||
|
$x_opener="chunk_x"; |
||||
|
$z_opener="z"; |
||||
|
$dot_and_ext = ".png"; |
||||
|
$x = $map_dict["chunkx_min"]; |
||||
|
$z = $map_dict["chunkz_min"]; |
||||
|
$x_count = $map_dict["chunkx_max"] - $map_dict["chunkx_min"] |
||||
|
$z_count = $map_dict["chunkz_max"] - $map_dict["chunkz_min"] |
||||
|
echo "<table border=\"0\">"; |
||||
|
while ($z <= $map_dict["chunkz_max"]) { |
||||
|
echo " <tr>"; |
||||
|
while ($x <= $map_dict["chunkx_max"]) { |
||||
|
echo " <td>"; |
||||
|
$chunk_luid = "x".$x."z".$z; |
||||
|
$chunk_img_name = $x_opener.$x.$z_opener.$z."$dot_and_ext"; |
||||
|
$chunk_img_path = $chunkymapdata_path.'/'.$chunk_img_name; |
||||
|
if (is_file($chunk_img_path)) { |
||||
|
echo "<img src=\"$chunk_img_path\"/ style=\"width:$zoom_min_1_max_100%\">"; |
||||
|
} |
||||
|
echo " <br/>".$x.",0,".$z |
||||
|
echo " </td>"; |
||||
|
$x++; |
||||
|
} |
||||
|
echo " </tr>"; |
||||
|
$z++; |
||||
|
} |
||||
|
echo "</table>"; |
||||
|
//NOTE: no need to detect range since using $map_dict |
||||
|
/* |
||||
|
$x_max = 0; |
||||
|
$x_min = 0; |
||||
|
$z_min = 0; |
||||
|
$z_max = 0; |
||||
|
if ($handle = opendir($chunkymapdata_path)) { |
||||
|
while (false !== ($file = readdir($handle))) { |
||||
|
if (substr($file, 0, 1) != ".") { |
||||
|
$file_lower = strtolower($file); |
||||
|
if (endsWith($file_lower, $dot_and_ext) and startsWith($file_lower, $x_opener)) { |
||||
|
$z_opener_index = strpos($file_lower, $z_opener, strlen($x_opener)); |
||||
|
if ($z_opener_index !== false) { |
||||
|
$x_len = $z_opener_index - strlen($x_opener); |
||||
|
$z_len = strlen($file_lower) - strlen($x_opener) - $x_len - strlen($z_opener) - $dot_and_ext; |
||||
|
$x = substr($file_lower, strlen($x_opener), $x_len); |
||||
|
$z = substr($file_lower, $z_opener_index + strlen($z_opener), $z_len); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
*/ |
||||
|
} |
||||
|
?> |
@ -0,0 +1,11 @@ |
|||||
|
<html> |
||||
|
<title>Chunkymap Example Page</title> |
||||
|
<body> |
||||
|
Live Map: |
||||
|
<?php |
||||
|
include_once('chunkymap.php'); |
||||
|
echo_chunkymap_table(0,0,25); |
||||
|
?> |
||||
|
<center><small>Powered by <a href="https://github.com/expertmm/minetest-chunkymap">Chunkymap</a></small></center> |
||||
|
</body> |
||||
|
</html> |
@ -1,10 +1,4 @@ |
|||||
#!/bin/sh |
#!/bin/sh |
||||
cd ~/minetest-stuff |
CHUNKYMAP_INSTALLER_DIR=~/minetest-stuff/minetest-chunkymap |
||||
rm master.zip |
./update-chunkymap-installer-only.sh |
||||
wget https://github.com/expertmm/minetest-chunkymap/archive/master.zip |
sh $CHUNKYMAP_INSTALLER_DIR/install-chunkymap-on-ubuntu.sh |
||||
mv master.zip minetest-chunkymap.zip |
|
||||
unzip minetest-chunkymap.zip |
|
||||
mv minetest-chunkymap-master minetest-chunkymap |
|
||||
cd minetest-chunkymap |
|
||||
chmod +x install-chunkymap-on-ubuntu.sh |
|
||||
./install-chunkymap-on-ubuntu.sh |
|
@ -0,0 +1,13 @@ |
|||||
|
#!/bin/sh |
||||
|
CHUNKYMAP_INSTALLER_DIR=~/minetest-stuff/minetest-chunkymap |
||||
|
|
||||
|
cd ~/minetest-stuff |
||||
|
rm master.zip |
||||
|
wget https://github.com/expertmm/minetest-chunkymap/archive/master.zip |
||||
|
mv master.zip minetest-chunkymap.zip |
||||
|
unzip minetest-chunkymap.zip |
||||
|
#mv minetest-chunkymap-master minetest-chunkymap |
||||
|
mv minetest-chunkymap-master "$CHUNKYMAP_INSTALLER_DIR" |
||||
|
#cd minetest-chunkymap |
||||
|
chmod +x "$CHUNKYMAP_INSTALLER_DIR/install-chunkymap-on-ubuntu.sh" |
||||
|
chmod +x "$CHUNKYMAP_INSTALLER_DIR/update-chunkymap-on-ubuntu-from-web.sh" |
@ -0,0 +1,18 @@ |
|||||
|
#!/bin/sh |
||||
|
CHUNKYMAP_INSTALLER_DIR=~/minetest-stuff/minetest-chunkymap |
||||
|
./update-chunkymap-installer-only.sh |
||||
|
#./install-chunkymap-on-ubuntu.sh |
||||
|
|
||||
|
|
||||
|
cp -f "$CHUNKYMAP_INSTALLER_DIR/minetestmapper-numpy.py" "$HOME/minetest/util/minetestmapper-numpy.py" |
||||
|
mkdir "$CHUNKYMAP_DEST" |
||||
|
cp -f "$CHUNKYMAP_INSTALLER_DIR/chunkymap-regen.py" "$CHUNKYMAP_DEST/" |
||||
|
#chmod +x "$CHUNKYMAP_DEST/chunkymap-regen.py" |
||||
|
cp -f "$CHUNKYMAP_INSTALLER_DIR/chunkymap-regen.sh" "$CHUNKYMAP_DEST/" |
||||
|
chmod +x "$CHUNKYMAP_DEST/chunkymap-regen.sh" |
||||
|
cp -f "$CHUNKYMAP_INSTALLER_DIR/chunkymap-cronjob" "$CHUNKYMAP_DEST/" |
||||
|
chmod +x "$CHUNKYMAP_DEST/chunkymap-cronjob" |
||||
|
cp -f "$CHUNKYMAP_INSTALLER_DIR/set-minutely-crontab-job.sh" "$CHUNKYMAP_DEST/" |
||||
|
chmod +x "$CHUNKYMAP_DEST/set-minutely-crontab-job.sh" |
||||
|
|
||||
|
python replace-with-current-user.py |
Loading…
Reference in new issue