Add first pass of handling for DB config.php files
This commit is contained in:
parent
023af3676b
commit
95a91d2a89
56 changed files with 66 additions and 534 deletions
|
|
@ -123,6 +123,7 @@ public class DynmapCore implements DynmapCommonAPI {
|
|||
private int perTickLimit = 50; // 50 ms
|
||||
private boolean dumpMissing = false;
|
||||
private static boolean migrate_chunks = false;
|
||||
public boolean isInternalWebServerDisabled = false;
|
||||
|
||||
private int config_hashcode; /* Used to signal need to reload web configuration (world changes, config update, etc) */
|
||||
private int fullrenderplayerlimit; /* Number of online players that will cause fullrender processing to pause */
|
||||
|
|
@ -530,6 +531,8 @@ public class DynmapCore implements DynmapCommonAPI {
|
|||
updateplayerlimit = configuration.getInteger("updateplayerlimit", 0);
|
||||
/* Load sort permission nodes */
|
||||
sortPermissionNodes = configuration.getStrings("player-sort-permission-nodes", null);
|
||||
// Check if we are disabling the internal web server (implies external)
|
||||
isInternalWebServerDisabled = configuration.getBoolean("disable-webserver", false);
|
||||
|
||||
perTickLimit = configuration.getInteger("per-tick-time-limit", 50);
|
||||
if (perTickLimit < 5) perTickLimit = 5;
|
||||
|
|
@ -594,7 +597,10 @@ public class DynmapCore implements DynmapCommonAPI {
|
|||
|
||||
loginRequired = configuration.getBoolean("login-required", false);
|
||||
|
||||
loadWebserver();
|
||||
// If not disabled, load and initialize the internal web server
|
||||
if (!isInternalWebServerDisabled) {
|
||||
loadWebserver();
|
||||
}
|
||||
|
||||
enabledTriggers.clear();
|
||||
List<String> triggers = configuration.getStrings("render-triggers", new ArrayList<String>());
|
||||
|
|
@ -616,26 +622,26 @@ public class DynmapCore implements DynmapCommonAPI {
|
|||
}
|
||||
Log.verboseinfo("Loaded " + componentManager.components.size() + " components.");
|
||||
|
||||
if (!configuration.getBoolean("disable-webserver", false)) {
|
||||
if (!isInternalWebServerDisabled) { // If internal not disabled, we should be using it and not external
|
||||
startWebserver();
|
||||
if(!componentManager.isLoaded(InternalClientUpdateComponent.class)) {
|
||||
if (!componentManager.isLoaded(InternalClientUpdateComponent.class)) {
|
||||
Log.warning("Using internal server, but " + InternalClientUpdateComponent.class.toString() + " is DISABLED!");
|
||||
webserverCompConfigWarn = true;
|
||||
}
|
||||
if(componentManager.isLoaded(JsonFileClientUpdateComponent.class)) {
|
||||
if (componentManager.isLoaded(JsonFileClientUpdateComponent.class)) {
|
||||
Log.warning("Using internal server, but " + JsonFileClientUpdateComponent.class.toString() + " is ENABLED!");
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(componentManager.isLoaded(InternalClientUpdateComponent.class)) {
|
||||
if (componentManager.isLoaded(InternalClientUpdateComponent.class)) {
|
||||
Log.warning("Using external server, but " + InternalClientUpdateComponent.class.toString() + " is ENABLED!");
|
||||
}
|
||||
if(!componentManager.isLoaded(JsonFileClientUpdateComponent.class)) {
|
||||
if (!componentManager.isLoaded(JsonFileClientUpdateComponent.class)) {
|
||||
Log.warning("Using external server, but " + JsonFileClientUpdateComponent.class.toString() + " is DISABLED!");
|
||||
webserverCompConfigWarn = true;
|
||||
}
|
||||
}
|
||||
if(webserverCompConfigWarn){
|
||||
if (webserverCompConfigWarn) {
|
||||
Log.warning("If the website is missing files or not loading/updating, this might be why.");
|
||||
Log.warning("For more info, read this: " + CompConfigWiki);
|
||||
webserverCompConfigWarn = false;
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ public abstract class MapStorage {
|
|||
*/
|
||||
public abstract String getMarkersURI(boolean login_enabled);
|
||||
/**
|
||||
* URI to use for loading tiles (for external web server)
|
||||
* URI to use for loading tiles (for external web server only)
|
||||
*
|
||||
* @param login_enabled - selects based on login security enabled
|
||||
* @return URI
|
||||
|
|
@ -210,14 +210,14 @@ public abstract class MapStorage {
|
|||
return login_enabled;
|
||||
}
|
||||
/**
|
||||
* Get sendmessage URI
|
||||
* Get sendmessage URI (for external web server only)
|
||||
* @return URI
|
||||
*/
|
||||
public String getSendMessageURI() {
|
||||
return "standalone/sendmessage.php";
|
||||
}
|
||||
/**
|
||||
* URI to use for loading configuration JSON files (for external web server)
|
||||
* URI to use for loading configuration JSON files (for external web server only)
|
||||
* @param login_enabled - selects based on login security enabled
|
||||
* @return URI
|
||||
*/
|
||||
|
|
@ -225,7 +225,7 @@ public abstract class MapStorage {
|
|||
return login_enabled?"standalone/configuration.php":"standalone/dynmap_config.json?_={timestamp}";
|
||||
}
|
||||
/**
|
||||
* URI to use for loading update JSON files (for external web server)
|
||||
* URI to use for loading update JSON files (for external web server only)
|
||||
* @param login_enabled - selects based on login security enabled
|
||||
* @return URI
|
||||
*/
|
||||
|
|
@ -445,9 +445,11 @@ public abstract class MapStorage {
|
|||
public boolean wrapStandalonePHP() {
|
||||
return true;
|
||||
}
|
||||
// For external web server only
|
||||
public String getStandaloneLoginURI() {
|
||||
return "standalone/login.php";
|
||||
}
|
||||
// For external web server only
|
||||
public String getStandaloneRegisterURI() {
|
||||
return "standalone/register.php";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -617,11 +617,13 @@ public class FileTreeMapStorage extends MapStorage {
|
|||
}
|
||||
|
||||
@Override
|
||||
// For external web server only
|
||||
public String getMarkersURI(boolean login_enabled) {
|
||||
return login_enabled?"standalone/markers.php?marker=":"tiles/";
|
||||
}
|
||||
|
||||
@Override
|
||||
// For external web server only
|
||||
public String getTilesURI(boolean login_enabled) {
|
||||
return login_enabled?"standalone/tiles.php?tile=":"tiles/";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -304,9 +304,14 @@ public class MariaDBMapStorage extends MapStorage {
|
|||
}
|
||||
|
||||
private boolean writeConfigPHP(DynmapCore core) {
|
||||
File cfgfile = new File(baseStandaloneDir, "MySQL_config.php");
|
||||
if (!core.isInternalWebServerDisabled) { // If using internal server
|
||||
cfgfile.delete(); // Zap file (in case we left junk from last time)
|
||||
return true;
|
||||
}
|
||||
FileWriter fw = null;
|
||||
try {
|
||||
fw = new FileWriter(new File(baseStandaloneDir, "MySQL_config.php"));
|
||||
fw = new FileWriter(cfgfile);
|
||||
fw.write("<?php\n$dbname = \'");
|
||||
fw.write(WebAuthManager.esc(database));
|
||||
fw.write("\';\n");
|
||||
|
|
@ -955,26 +960,31 @@ public class MariaDBMapStorage extends MapStorage {
|
|||
}
|
||||
|
||||
@Override
|
||||
// For external web server only
|
||||
public String getMarkersURI(boolean login_enabled) {
|
||||
return "standalone/MySQL_markers.php?marker=";
|
||||
}
|
||||
|
||||
@Override
|
||||
// For external web server only
|
||||
public String getTilesURI(boolean login_enabled) {
|
||||
return "standalone/MySQL_tiles.php?tile=";
|
||||
}
|
||||
|
||||
@Override
|
||||
// For external web server only
|
||||
public String getConfigurationJSONURI(boolean login_enabled) {
|
||||
return "standalone/MySQL_configuration.php"; // ?serverid={serverid}";
|
||||
}
|
||||
|
||||
@Override
|
||||
// For external web server only
|
||||
public String getUpdateJSONURI(boolean login_enabled) {
|
||||
return "standalone/MySQL_update.php?world={world}&ts={timestamp}"; // &serverid={serverid}";
|
||||
}
|
||||
|
||||
@Override
|
||||
// For external web server only
|
||||
public String getSendMessageURI() {
|
||||
return "standalone/MySQL_sendmessage.php";
|
||||
}
|
||||
|
|
@ -1066,16 +1076,17 @@ public class MariaDBMapStorage extends MapStorage {
|
|||
return false;
|
||||
}
|
||||
@Override
|
||||
// For external web server only
|
||||
public String getStandaloneLoginURI() {
|
||||
return "standalone/MySQL_login.php";
|
||||
}
|
||||
@Override
|
||||
// For external web server only
|
||||
public String getStandaloneRegisterURI() {
|
||||
return "standalone/MySQL_register.php";
|
||||
}
|
||||
@Override
|
||||
public void setLoginEnabled(DynmapCore core) {
|
||||
writeConfigPHP(core);
|
||||
writeConfigPHP(core);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -306,9 +306,14 @@ public class MySQLMapStorage extends MapStorage {
|
|||
}
|
||||
|
||||
private boolean writeConfigPHP(DynmapCore core) {
|
||||
File cfgfile = new File(baseStandaloneDir, "MySQL_config.php");
|
||||
if (!core.isInternalWebServerDisabled) { // If using internal server
|
||||
cfgfile.delete(); // Zap file (in case we left junk from last time)
|
||||
return true;
|
||||
}
|
||||
FileWriter fw = null;
|
||||
try {
|
||||
fw = new FileWriter(new File(baseStandaloneDir, "MySQL_config.php"));
|
||||
fw = new FileWriter(cfgfile);
|
||||
fw.write("<?php\n$dbname = \'");
|
||||
fw.write(WebAuthManager.esc(database));
|
||||
fw.write("\';\n");
|
||||
|
|
@ -956,26 +961,31 @@ public class MySQLMapStorage extends MapStorage {
|
|||
}
|
||||
|
||||
@Override
|
||||
// External web server only
|
||||
public String getMarkersURI(boolean login_enabled) {
|
||||
return "standalone/MySQL_markers.php?marker=";
|
||||
}
|
||||
|
||||
@Override
|
||||
// External web server only
|
||||
public String getTilesURI(boolean login_enabled) {
|
||||
return "standalone/MySQL_tiles.php?tile=";
|
||||
}
|
||||
|
||||
@Override
|
||||
// External web server only
|
||||
public String getConfigurationJSONURI(boolean login_enabled) {
|
||||
return "standalone/MySQL_configuration.php"; // ?serverid={serverid}";
|
||||
}
|
||||
|
||||
@Override
|
||||
// External web server only
|
||||
public String getUpdateJSONURI(boolean login_enabled) {
|
||||
return "standalone/MySQL_update.php?world={world}&ts={timestamp}"; // &serverid={serverid}";
|
||||
}
|
||||
|
||||
@Override
|
||||
// External web server only
|
||||
public String getSendMessageURI() {
|
||||
return "standalone/MySQL_sendmessage.php";
|
||||
}
|
||||
|
|
@ -1066,10 +1076,12 @@ public class MySQLMapStorage extends MapStorage {
|
|||
return false;
|
||||
}
|
||||
@Override
|
||||
// External web server only
|
||||
public String getStandaloneLoginURI() {
|
||||
return "standalone/MySQL_login.php";
|
||||
}
|
||||
@Override
|
||||
// External web server only
|
||||
public String getStandaloneRegisterURI() {
|
||||
return "standalone/MySQL_register.php";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -308,9 +308,14 @@ public class PostgreSQLMapStorage extends MapStorage {
|
|||
return writeConfigPHP(core);
|
||||
}
|
||||
private boolean writeConfigPHP(DynmapCore core) {
|
||||
File cfgfile = new File(baseStandaloneDir, "PostgreSQL_config.php");
|
||||
if (!core.isInternalWebServerDisabled) { // If using internal server
|
||||
cfgfile.delete(); // Zap file (in case we left junk from last time)
|
||||
return true;
|
||||
}
|
||||
FileWriter fw = null;
|
||||
try {
|
||||
fw = new FileWriter(new File(baseStandaloneDir, "PostgreSQL_config.php"));
|
||||
fw = new FileWriter(cfgfile);
|
||||
fw.write("<?php\n$dbname = \'");
|
||||
fw.write(WebAuthManager.esc(database));
|
||||
fw.write("\';\n");
|
||||
|
|
@ -957,26 +962,31 @@ public class PostgreSQLMapStorage extends MapStorage {
|
|||
}
|
||||
|
||||
@Override
|
||||
// External web server only
|
||||
public String getMarkersURI(boolean login_enabled) {
|
||||
return "standalone/PostgreSQL_markers.php?marker=";
|
||||
}
|
||||
|
||||
@Override
|
||||
// External web server only
|
||||
public String getTilesURI(boolean login_enabled) {
|
||||
return "standalone/PostgreSQL_tiles.php?tile=";
|
||||
}
|
||||
|
||||
@Override
|
||||
// External web server only
|
||||
public String getConfigurationJSONURI(boolean login_enabled) {
|
||||
return "standalone/PostgreSQL_configuration.php"; // ?serverid={serverid}";
|
||||
}
|
||||
|
||||
@Override
|
||||
// External web server only
|
||||
public String getUpdateJSONURI(boolean login_enabled) {
|
||||
return "standalone/PostgreSQL_update.php?world={world}&ts={timestamp}"; // &serverid={serverid}";
|
||||
}
|
||||
|
||||
@Override
|
||||
// External web server only
|
||||
public String getSendMessageURI() {
|
||||
return "standalone/PostgreSQL_sendmessage.php";
|
||||
}
|
||||
|
|
@ -1067,10 +1077,12 @@ public class PostgreSQLMapStorage extends MapStorage {
|
|||
return false;
|
||||
}
|
||||
@Override
|
||||
// External web server only
|
||||
public String getStandaloneLoginURI() {
|
||||
return "standalone/PostgreSQL_login.php";
|
||||
}
|
||||
@Override
|
||||
// External web server only
|
||||
public String getStandaloneRegisterURI() {
|
||||
return "standalone/PostgreSQL_register.php";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -915,11 +915,13 @@ public class SQLiteMapStorage extends MapStorage {
|
|||
}
|
||||
|
||||
@Override
|
||||
// External web server only
|
||||
public String getMarkersURI(boolean login_enabled) {
|
||||
return "standalone/SQLite_markers.php?marker=";
|
||||
}
|
||||
|
||||
@Override
|
||||
// External web server only
|
||||
public String getTilesURI(boolean login_enabled) {
|
||||
return "standalone/SQLite_tiles.php?tile=";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue