diff --git a/403.html b/403.html
new file mode 100644
index 0000000..87140c9
--- /dev/null
+++ b/403.html
@@ -0,0 +1,5 @@
+
+
+403 FORBIDDEN
+
+Error. You don't have the peremission to view this page or to perform this action !
\ No newline at end of file
diff --git a/404.html b/404.html
new file mode 100644
index 0000000..8778804
--- /dev/null
+++ b/404.html
@@ -0,0 +1,5 @@
+
+
+404 NOT FOUND
+
+Error. File not found !
\ No newline at end of file
diff --git a/config.yml b/config.yml
index 6c78ef3..f16b143 100644
--- a/config.yml
+++ b/config.yml
@@ -2,7 +2,7 @@
#This define the port that your website that will run.
#****NOTE THAT YOU WILL NEED TO RE-PORTFOREWARD WITH THE NEW PORT****
-port: 8080
+port: 80
# Here you can choose the pages !
index: index.html
@@ -11,7 +11,4 @@ index: index.html
# Here you can config pages that user will not be able to see !
denied-pages:
- - config.yml
-
- # Here you can configure the refresh in tick (20 tick = 1s)
-TimePerConnection: 20
\ No newline at end of file
+ - /config.yml
\ No newline at end of file
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..6a7d8ff
--- /dev/null
+++ b/index.html
@@ -0,0 +1,8 @@
+
+
+Welcome to your new website !
+
+
+Welcome to your new website ! You can edit it in your new folder !
+
+
\ No newline at end of file
diff --git a/plugin.yml b/plugin.yml
index f10c4dd..5300bb3 100644
--- a/plugin.yml
+++ b/plugin.yml
@@ -1,7 +1,7 @@
---
name: Online
author: Ad5001
-version: 1.1
+version: 1.4
api: [2.0.0]
main: Ad5001\Online\Main
commands: []
diff --git a/resources/config.yml b/resources/config.yml
index aefe907..76180ef 100644
--- a/resources/config.yml
+++ b/resources/config.yml
@@ -2,7 +2,7 @@
#This define the port that your website that will run.
#****NOTE THAT YOU WILL NEED TO RE-PORTFOREWARD WITH THE NEW PORT****
-port: 8080
+port: 80
# Here you can choose the pages !
index: index.html
@@ -11,4 +11,5 @@ index: index.html
# Here you can config pages that user will not be able to see !
denied-pages:
- - /config..yml
\ No newline at end of file
+ - /config.yml
+ - /router.php
\ No newline at end of file
diff --git a/resources/handler.php b/resources/handler.php
new file mode 100644
index 0000000..cd71567
--- /dev/null
+++ b/resources/handler.php
@@ -0,0 +1,16 @@
+socket->close();
- }
public function onEnable(){
-// $this->getServer()->getPluginManager()->registerEvents($this, $this);
$this->saveDefaultConfig();
if(!file_exists($this->getDataFolder() . "index.html")) {
file_put_contents($this->getDataFolder() . "index.html", $this->getResource("index.html"));
}
+if(!stream_resolve_include_path("router.php")) {
+ file_put_contents($this->getDataFolder() . "router.php", $this->getResource("handler.php"));
+}
if(!file_exists($this->getDataFolder() . "404.html")) {
file_put_contents($this->getDataFolder() . "404.html", $this->getResource("404.html"));
}
@@ -31,17 +29,32 @@ set_time_limit(0);
$address = '0.0.0.0';
$port = $this->getConfig()->get("port");
-$sock = socket_create(AF_INET, SOCK_STREAM, 0) or die("Could not create socket\n");
-$result = socket_bind($sock, $address, $port) or die('Could not bind to address');
-$this->getLogger()->info("Website open in port §a" . $port);
+$this->getServer()->getScheduler()->scheduleAsyncTask(new execTask($this->getServer()->getFilePath()));
+// UPnP::PortForward($port); \\\\ Beta for Windows
+}
+}
-$this->socket = new isOnlineTask($this, $sock, $this->getDataFolder());
-$this->getServer()->getScheduler()->scheduleRepeatingTask($this->socket, $this->getConfig()->get("TimePerConnection"));
-$this->sock = $sock;
-}
- public function onCommand(CommandSender $issuer, Command $cmd, $label, array $params){
-switch($cmd->getName()){
-}
-return false;
- }
+class execTask extends \pocketmine\scheduler\AsyncTask {
+
+ public function __construct(string $path) {
+ $this->path = $path;
+ }
+
+ public function onRun() {
+ $address = '0.0.0.0';
+ $port = yaml_parse(file_get_contents("plugins\\Online\\config.yml"))["port"];
+ // shell_exec("cd plugins/Online");
+ switch(true) {
+ case stristr(PHP_OS, "WIN"):
+ echo '"%CD%\\bin\\php\\php.exe -t %CD%\\plugins\\Online -n -d include_path=\'%CD%\\plugins\\Online\\\' -S ' . $address . ":" . $port . ' -f %CD%\\plugins\\Online\\router.php"';
+ shell_exec('start "Online Listener" cmd /c "%CD%\\bin\\php\\php.exe -t %CD%\\plugins\\Online -n -d include_path=\'%CD%\\plugins\\Online\\\' -d extension=\'%CD%\\bin\\php\\ext\\php_yaml.dll\' -S ' . $address . ":" . $port . ' router.php"');
+ break;
+ case stristr(PHP_OS, "DAR"):
+ shell_exec('open -a Terminal "' . $this->path . "bin\\php\\php.exe -t " . $this->path . "plugins\\Online -n -d include_path=\'" . $this->path . "plugins\\Online\\\' -d extension=\'" . $this->path . "bin\\php\\ext\\php_yaml.dll\' -S ' . $address . ":" . $port . ' router.php");
+ break;
+ case stristr(PHP_OS, "LINUX"):
+ shell_exec('gnome-terminal -e "' . $this->path . "bin\\php\\php.exe -t " . $this->path . "plugins\\Online -n -d include_path=\'" . $this->path . "plugins\\Online\\\' -d extension=\'" . $this->path . "bin\\php\\ext\\php_yaml.dll\' -S ' . $address . ":" . $port . ' router.php");
+ break;
+ }
+ }
}
\ No newline at end of file