Does your hoster only gave you one port and you want to have a website trought? So here it is: a server mod that makes your bukkit server to both: Web and MC-Server :D
Uniport Webserver = HTML Webserver on same port as server :D
Configuration
- Use own plugin OR
- logMissingPages: true/false - Should the plugin log missing files? (by user request)
Specials since "little Download Update"
- If you want to the user to download the file use the suffix "?download" for your file name (e.g. <a src="/index.png?download">Download</a>)
PHP-Data since "PHP Update"
- $_REQUEST: array of http headers (e.g. Host, Accept-Language or User-Agent)
- $_GET = $_POST: request parameters (e.g. ?v=Video123)
Commands
NONE
Permissions
NONE
How to install?
- Make sure you have CraftBukkit 1.7.x or 1.8.x and paste the folders from the zip into your bukkit.jar (main directory, a JAR = a renamed ZIP, use e.g. 7zip or WinRar to open and copy and paste)
- Then paste the WebBukkit.jar or UniportWebserver(maybe lite).jar into your plugins folder.
- Start your server.
- Add your website sites into the "UniportWebserver"-folder :D
How to handle the HTTPRequestEvent (for pros)?
@EventHandler public void onHTTPRequest(HTTPRequestEvent event){ // Request example: "GET /Minecraft HTTP/1.1 ..." String req = event.getRequest().split(" ")[1]; if(req.equals("/")){ req="/index.html"; } File f = new File(getDataFolder()+req); if(f.isDirectory()){ f = new File(f, "index.html"); } if(f.exists() && !f.isDirectory()){ try { event.setImage(IOUtils.toByteArray(new FileInputStream(f))); if(!f.getName().endsWith(".html")){ event.setContentType("*/*"); } } catch (IOException e) { e.printStackTrace(); } } }
Is there more data from the HTTP/1.1 Request?
Yes there is in the getRequest()-String, But there might be a wrong ip and port in the request file...
The PHP-Interpreter don't knows date() etc...?
Yes, you should use the Quercus/Java expressions for that (see http://quercus.caucho.com/quercus-3.1/doc/quercus.xtp)
Templates...
best try to avoid them since they don't know about the 256kB limit. You should be able to create a website on your own with some tutorials from youtube, e.g. https://www.youtube.com/watch?v=3JluqTojuME
Bugs
Max file size 1.7.2
When the file is to big (>256kB - that's a lot for a text file as html, css or javascript) you will get a crash report (it seems big files need to long so the packet handlers notice that and fire an exception) in 1.7.2, in 1.8.x the download will stop without
To fix this for your website just split big files and load the parts. If you have a big background image you should upload it elsewhere - then it'll work (http://www.fotos-hochladen.net/ is free, for .zips or .jars or anything similar use Mega or Mediafire)
This plugin uses Metrics since "PHP Update"/"lite Update"
What is sent? http://mcstats.org/plugin/UniportWebserver + number of files downloaded