+
Unallowed domain
+
This IP does not have any domain on this machine. Please refer to your server administartor if you think it's an error.
+
+
+
+A;
}
\ No newline at end of file
diff --git a/src/Ad5001/Online/Main.php b/src/Ad5001/Online/Main.php
index bf5c1ff..70c74d6 100644
--- a/src/Ad5001/Online/Main.php
+++ b/src/Ad5001/Online/Main.php
@@ -12,34 +12,51 @@ use pocketmine\Player;
class Main extends PluginBase{
public function onEnable(){
$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"));
-}
-if(!file_exists($this->getDataFolder() . "403.html")) {
- file_put_contents($this->getDataFolder() . "403.html", $this->getResource("403.html"));
+foreach($this->getConfig()->get("Domains") as $d) {
+ @mkdir($this->getDataFolder() . $d);
+ if(!file_exists($this->getDataFolder() . $d . "/index.html") and !file_exists($this->getDataFolder() . $d . "/index.php")) {
+ file_put_contents($this->getDataFolder() .$d. "/index.html", $this->getResource("index.html"));
+ }
+ if(!file_exists($this->getDataFolder() .$d. "/404.html")) {
+ file_put_contents($this->getDataFolder() . $d . "/404.html", $this->getResource("404.html"));
+ }
+ if(!file_exists($this->getDataFolder() . $d . "/403.html")) {
+ file_put_contents($this->getDataFolder() .$d . "/403.html", $this->getResource("403.html"));
+ }
}
+
+register_shutdown_function("Ad5001\\Online\\Main::shutdown");
+
set_time_limit(0);
$this->port = $this->getConfig()->get("port");
+if(!UPnP::PortForward($this->port)) {// Beta for Windows
+ $this->getLogger()->info("Not able to port forward!");
+}
+
$this->getServer()->getScheduler()->scheduleAsyncTask(new execTask($this->getServer()->getFilePath()));
-// UPnP::PortForward($port); \\\\ Beta for Windows
+}
+
+public static function shutdown() {
+ echo "Shutdowned !";
}
public function onDisable() {
if($this->getConfig()->get("KillOnShutdown") !== "false") {
+ $this->getLogger()->info("Shutdowning.....");
switch(true) {
case stristr(PHP_OS, "WIN"):
- exec('FOR /F "tokens=4 delims= " %P IN (\'netstat -a -n -o ^| findstr :'. $this->port .'\') DO @ECHO TaskKill.exe /PID %P');
+ shell_exec('FOR /F "tokens=5" %P IN (\'netstat -a -n -o ^| findstr 0.0.0.0:'. $this->port .'\') DO TaskKill.exe /F /PID %P');
+ $this->getLogger()->info("Shutdowned on Windows !");
break;
case stristr(PHP_OS, "DAR") or stristr(PHP_OS, "LINUX"):
shell_exec("kill -kill `lsof -t -i tcp:$this->port`");
+ $this->getLogger()->info("Shutdowned on Linux or MAC !");
break;
}
}
diff --git a/src/Ad5001/Online/OnlineTask.php b/src/Ad5001/Online/OnlineTask.php
deleted file mode 100644
index 928dc19..0000000
--- a/src/Ad5001/Online/OnlineTask.php
+++ /dev/null
@@ -1,98 +0,0 @@
-sock = $sock;
- $this->datapath = $datapath;
- $this->isRunning = true;
- $this->cfg = new Config($datapath . "config.yml", Config::YAML);
- }
- public function close() {
- $this->isRunning = false;
- }
- public function onRun() {
- $sock = $this->sock;
- $client = socket_accept($sock);
- $input = socket_read($client, 1024);
- $incoming = explode("\r\n", $input);
- $fetchArray = explode(" ", $incoming[0]);
- if($fetchArray[1] == "/"){
- $file = $this->cfg->get("index");
- $fetchArray[1] = $this->cfg->get("index");
- } else {
- $filearray = [];
- $filearray = explode("/", $fetchArray[1]);
- $file = $fetchArray[1];
- }
- $output = "";
- $Header = "HTTP/1.1 200 OK \r\n" .
- "Date: Fri, 31 Dec 1999 23:59:59 GMT \r\n" .
- "Content-Type: text/html \r\n\r\n";
- $file = ltrim($file, '/');
- if(strpos($file, "?")) {
- $exe = explode("?", $file);
- $file = $exe[0];
- $exe = explode("&", $exe[1]);
- }
-
- if(file_exists($this->datapath . $file)) {
- if(pathinfo($this->datapath . $file)['extension'] === "php") {
- if(isset($exe[0])) {
- $GET = [];
- foreach($exe as $exes) {
- $ex = explode("=", $exes);
- array_push($GET, "\"{$ex[0]}\" => \"{$ex[1]}\"");
- }
- $current = '' . file_get_contents($this->datapath . $file);
- $current = str_ireplace('$_GET', '$GET', $current);
- file_put_contents($this->datapath . "current.php", $current);
- $file = "current.php";
- }
- ob_start();
- include $this->datapath . $file ;
- $Content = ob_get_contents();
- ob_end_clean();
- } else {
- $Content = file_get_contents($this->datapath . $file);
- }
- $Header = "HTTP/1.1 200 OK \r\n" .
-"Date: Fri, 31 Dec 1999 23:59:59 GMT \r\n" .
-"Content-Type: text/html \r\n\r\n";
- } else {
- $Header = "HTTP/1.1 404 NOT FOUND \r\n" .
-"Date: Fri, 31 Dec 1999 23:59:59 GMT \r\n" .
-"Content-Type: text/html \r\n\r\n";
- $Content = file_get_contents($this->datapath . $this->cfg->get("404"));
- }
- foreach($this->cfg->get("denied-pages") as $dp) {
- if($dp === $file) {
- $Header = "HTTP/1.1 403 FORBIDDEN \r\n" .
-"Date: Fri, 31 Dec 1999 23:59:59 GMT \r\n" .
-"Content-Type: text/html \r\n\r\n";
- $Content = file_get_contents($this->datapath . $this->cfg->get("403"));
- }
- }
- $output = $Header . $Content;
- socket_write($client,$output,strlen($output));
- }
- }
\ No newline at end of file
diff --git a/src/Ad5001/Online/isOnlineTask.php b/src/Ad5001/Online/isOnlineTask.php
deleted file mode 100644
index e7e1acd..0000000
--- a/src/Ad5001/Online/isOnlineTask.php
+++ /dev/null
@@ -1,31 +0,0 @@
-pl = $plugin;
- $this->sock = $sock;
- $this->datapath = $datapath;
- $this->isRunning = true;
- }
- public function close() {
- $this->isRunning = false;
- }
- public function onRun($tick) {
- if($this->isRunning) {
- socket_listen($this->sock);
- $this->pl->getServer()->getScheduler()->scheduleAsyncTask(new OnlineTask($this->pl, $this->sock, $this->datapath));
- }
- }
- }
\ No newline at end of file