Uniport WebServer
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
I have a working solution on Minecraft 1.12 using a self-made installer which automaticly decompiles your server and compiles it back. It might be version independant but I haven't tested so. The only error I am getting with this is that the Player[] Bukkit.getOnlinePlayers() method doesn't exist anymore.
If there is any interest in me publishing that installer, feel free to ask.
In reply to Wombosvideo:
But yes, I am interested :)
And yeah, they changed the Bukkit API... I hope I won't forget it when uploading versions for >1.7/≤1.7 :)
I love the plugin but are you gonna update this plugin for 1.10.2 and will it work with spigot?
I don't know about the updating yet, because I am not only working in the BukkitAPI in this project. I've to use native things which are ill documented and changed every version...
Each version released will work with Spigot :)
Just to be clear, this plugin will only currently work on 1.7 and 1.8 and will not work on 1.9 and 1.10 correct? or have you not tested to see if it will
@OilO
I don't know how well you are with php(my php arts are... ok...), but I found out (with the full crash report xD (maybe added in the next update for such problems)) that Quercus don't like the PDO part: There you'll find a tutorial about how to rewrite the index.php: http:www.caucho.com/resin-3.1/examples/quercus-pdo/index.xtp :)
If it is too complicated it may be easier to write your own plugin with the UniportWebserver component by me and some components by Chatlog. You can see their source code with JDGui or luyten
Maybe I'll add some kind of alternative PDO for compatibly problems with other plugins, but I'm not sure whether I'll do it (there are more interesting things ;))
Hi, so I'm trying to host this plugin using your webserver and it seems to work nicely except that the server gave me this error
I know the link of Quercus is the one I'm supposed to use but I'm not sure how to implement it, is there a more detailed tutorial or will you be kind enough to add it to an upcoming update?
@JordanDifferentCraft
For such file sizes you should use a FTP server with guranted fast access like Mega or Mediafire. Additionally a feature which saves the actual download data when the connection breakes is very useful. - so you could make it with php and Javascript code and download the bytes from the file "row by row" but that's lot of work which is allready done on other free service sites.
Actually there is the max file size of 256kB, so if you want to send the file with php/Quercus and Javascript you would have to create for your 70GB file about 70,000,000,000/256,000 = about 290,000 requests which are answered by php (sth like filedownloader.php?file=xyz.zip&part=15241) and then puzzled into your file by Javascript (loaded via XMLHttpRequests or anything similar)
Also I don't think Chrome/Firefox would like to handle 70GB in RAM, but Mega does it in some way, so it has to be possible...
When you use Mega or Mediafire just place the link (sth like <a src="http://abc.com/xyz.zip">Download here</a>) on your site
@mat41997
added it :) https://www.spigotmc.org/resources/uniport-webserver.16865/
It work, so awesome : P
and my sugestion you can add this plugin on this site? https://www.spigotmc.org/resources/ Thanks.
@JordanDifferentCraft
Hey JordanDifferentCraft, PHP is now supported by the newest file :D, but you may have to change some parts of your code if you allready have it, because it is a Quercus - PHPinterpreter, so there are no date() functions etc.. You will have to use the java classes instead; tutorial: http://quercus.caucho.com/quercus-3.1/doc/quercus.xtp
maybe I'll implement some of the most important functions in the next update :)
@Knucklesfan
no it should do it by itself... did you put the net folder into your bukkit.jar and the WebBukkit.jar into your plugins folder? (and the name of the folder you are looking for is not "WebBukkit/UniportWebserver", but "WebBukkit" or "UniportWebserver" (depends on which version you use); the right folder contains a 404.html after server start)
Ok, so I have a question, when the server starts up, it didnt create the WebBukkit/UniportWebServer folder. Do I need to create that?
@Knucklesfan
Your very welcome :)
Dude, your amazing. Just plain amazing! This is genious! free web hosting!
@JordanDifferentCraft
Thanks for your ideas :) - php is a bit of work so I'll look what's possible. The downloading feature is included in the newest file (from 06.01.16) - just add "?download" to your file link
@JordanDifferentCraft
Thanks you'r right.... uploaded the wrong file.. I am so sorry :(... Uploaded now the working file (a .zip including the webbukkit.jar and the net folder)
@JordanDifferentCraft
Did you put the net - folder into your bukkit/spigot.jar? You have to do so because the real bukkit doesn't support HTTP-Requests. (and I didn't test spigot but it should work)