Skip to content

Commit

Permalink
Added dynmap.dat file creation when it doesn't exist.
Browse files Browse the repository at this point in the history
  • Loading branch information
LinhyCZ committed Oct 28, 2015
1 parent 5d7780f commit e9c0708
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions dynmap-core.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php
//error_reporting(0);
error_reporting(0);
include "dynmap-config.php";
header('Content-Type: text/html; charset=utf-8');

//Definice složek
$cachefolder = $_SERVER["DOCUMENT_ROOT"] . "/.cache";
$mapsfolder = $_SERVER["DOCUMENT_ROOT"] . "/.maps";
$cachefolder = getcwd() . "/.cache";
$mapsfolder = getcwd() . "/.maps";

//Vytvoření složek, pokud neexistují
if (!file_exists($cachefolder)) {
Expand All @@ -20,6 +20,16 @@
umask($old_umask);
}

if (!file_exists("cursor.png")) {
file_put_contents("cursor.png", file_get_contents("https://cdn.rawgit.com/LinhyCZ/DynmapFiles/master/cursor.png"));
}

if (!file_exists($cachefolder . "/dynmap.dat")) {
$file = $cachefolder . "/dynmap.dat";
$file = fopen($file, "w+");
fclose($file);
}

//Zpracování serverového požadavku
if ($_GET["user"] == "server") {
//Kontrola privatekey
Expand All @@ -40,13 +50,14 @@
//Kontrola stažených souborů map
//Čtení dat od serveru
$maps = urldecode($_GET["maps"]);
$maps = explode(" ", $maps);
$maps = explode(";", $maps);

$downloadedMaps = scandir($mapsfolder);

//Vypíše stažené mapy do array;
foreach ($downloadedMaps as $downloadedMap) {
if($downloadedMap != "." && $downloadedMap != "..") {
//echo $downloadedMap;
$substrMaps[] = substr($downloadedMap, 0, -4);
}
}
Expand All @@ -73,6 +84,7 @@
print_r($_FILES);
}
} else {
echo $_FILES['file']['error'];
echo "Error.UploadFailed";
}
} else {
Expand Down

0 comments on commit e9c0708

Please sign in to comment.