Moving forward !

Fixing some issues in the config + processing PHP
This commit is contained in:
Ad5001 2016-05-30 19:06:31 +02:00
parent a6a8881d1c
commit 4d0aa7ef1e
7 changed files with 304 additions and 17 deletions

View File

@ -11,4 +11,7 @@ index: index.html
# Here you can config pages that user will not be able to see !
denied-pages:
- /config..yml/
- config.yml
# Here you can configure the refresh in tick (20 tick = 1s)
TimePerConnection: 20

2
hey.php Normal file
View File

@ -0,0 +1,2 @@
<html>
<head><title><?php echo "hey"; ?></title></head>

3
im.php Normal file
View File

@ -0,0 +1,3 @@
<?php
header("Location: https://forums.imagicalmine.net/members/ad5001.233/");
?>

235
index.html Normal file
View File

@ -0,0 +1,235 @@
<!DOCTYPE html>
<!--
Transit by TEMPLATED
templated.co @templatedco
Released for free under the Creative Commons Attribution 3.0 license (templated.co/license)
-->
<html lang="en">
<head>
<meta charset="UTF-8">
<title>BoxOfDevs</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<!--[if lte IE 8]><script src="js/html5shiv.js"></script><![endif]-->
<link rel="stylesheet" href="http://mc-pe.ga/css/skel.css" />
<link rel="stylesheet" href="http://mc-pe.ga/css/style.css" />
<link rel="stylesheet" href="http://mc-pe.ga/css/style-xlarge.css" />
</head>
<body class="landing">
<!-- Header -->
<header id="header">
<h1><a href="index.html"><img src="images/BODLogo.png" height="15" width="15" /> BoxOfDevs Team</a></h1>
<nav id="nav">
<ul>
<li><a href="http://software.boxofdevs.ml">Software</a></li>
<li><a href="http://forums.boxofdevs.ml">Forums</a></li>
<li><a href="http://licenses.boxofdevs.ml">Licenses</a></li>
<li><a href="http://wiki.boxofdevs.ml">Wiki</a></li>
<li><a href="services.html">Services</a></li>
<li><a href="apply.html">Apply</a></li>
<li><a href="contact.html" class="button special">Contact Us</a></li>
</ul>
</nav>
</header>
<!-- Banner -->
<section id="banner">
<h2>BoxOfDevs</h2>
<p>The development team that makes softwares happends</p>
<ul class="actions">
<li>
<a href="services.html" class="button big">Our services</a>
</li>
<li>
<a href="http://software.boxofdevs.ml" class="button big">Our softwares</a>
</li>
</ul>
</section>
<!-- One -->
<section id="one" class="wrapper style1 special">
<div class="container">
<header class="major">
<h2>Consectetur adipisicing elit</h2>
<p>Lorem ipsum dolor sit amet, delectus consequatur, similique quia!</p>
</header>
<div class="row 150%">
<div class="4u 12u$(medium)">
<section class="box">
<i class="icon big rounded color1 fa-cloud"></i>
<h3>Lorem ipsum dolor</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Enim quam consectetur quibusdam magni minus aut modi aliquid.</p>
</section>
</div>
<div class="4u 12u$(medium)">
<section class="box">
<i class="icon big rounded color9 fa-desktop"></i>
<h3>Consectetur adipisicing</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Laudantium ullam consequatur repellat debitis maxime.</p>
</section>
</div>
<div class="4u$ 12u$(medium)">
<section class="box">
<i class="icon big rounded color6 fa-rocket"></i>
<h3>Adipisicing elit totam</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Atque eaque eveniet, nesciunt molestias. Ipsam, voluptate vero.</p>
</section>
</div>
</div>
</div>
</section>
<!-- Two -->
<section id="two" class="wrapper style2 special">
<div class="container">
<header class="major">
<h2>Lorem ipsum dolor sit</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Distinctio, autem.</p>
</header>
<section class="profiles">
<div class="row">
<section class="3u 6u(medium) 12u$(xsmall) profile">
<img src="images/profile_placeholder.gif" alt="" />
<h4>Lorem ipsum</h4>
<p>Lorem ipsum dolor</p>
</section>
<section class="3u 6u$(medium) 12u$(xsmall) profile">
<img src="images/profile_placeholder.gif" alt="" />
<h4>Voluptatem dolores</h4>
<p>Ullam nihil repudi</p>
</section>
<section class="3u 6u(medium) 12u$(xsmall) profile">
<img src="images/profile_placeholder.gif" alt="" />
<h4>Doloremque quo</h4>
<p>Harum corrupti quia</p>
</section>
<section class="3u$ 6u$(medium) 12u$(xsmall) profile">
<img src="images/profile_placeholder.gif" alt="" />
<h4>Voluptatem dicta</h4>
<p>Et natus sapiente</p>
</section>
</div>
</section>
<footer>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quibusdam dolore illum, temporibus veritatis eligendi, aliquam, dolor enim itaque veniam aut eaque sequi qui quia vitae pariatur repudiandae ab dignissimos ex!</p>
<ul class="actions">
<li>
<a href="#" class="button big">Lorem ipsum dolor sit</a>
</li>
</ul>
</footer>
</div>
</section>
<!-- Three -->
<section id="three" class="wrapper style3 special">
<div class="container">
<header class="major">
<h2>Consectetur adipisicing elit</h2>
<p>Lorem ipsum dolor sit amet. Delectus consequatur, similique quia!</p>
</header>
</div>
<div class="container 50%">
<form action="mail.php" method="POST">
<div class="row uniform">
<div class="6u 12u$(small)">
<input name="name" id="name" value="" placeholder="Name" type="text">
</div>
<div class="6u$ 12u$(small)">
<input name="email" id="email" value="" placeholder="Email" type="email">
</div>
<div class="12u$">
<input name="subject" id="subject" value="" placeholder="Subject" type="text">
</div>
<div class="12u$">
<textarea name="message" id="message" placeholder="Message" rows="6"></textarea>
</div>
<div class="12u$">
<ul class="actions">
<li><input value="Submit" class="special big" type="submit"><input type="reset" class="special" value="Clear"></li>
</ul>
</div>
</div>
</form>
</div>
</section>
<!-- Footer -->
<footer id="footer">
<div class="container">
<section class="links">
<div class="row">
<section class="3u 6u(medium) 12u$(small)">
<h3>Lorem ipsum dolor</h3>
<ul class="unstyled">
<li><a href="#">Lorem ipsum dolor sit</a></li>
<li><a href="#">Nesciunt itaque, alias possimus</a></li>
<li><a href="#">Optio rerum beatae autem</a></li>
<li><a href="#">Nostrum nemo dolorum facilis</a></li>
<li><a href="#">Quo fugit dolor totam</a></li>
</ul>
</section>
<section class="3u 6u$(medium) 12u$(small)">
<h3>Culpa quia, nesciunt</h3>
<ul class="unstyled">
<li><a href="#">Lorem ipsum dolor sit</a></li>
<li><a href="#">Reiciendis dicta laboriosam enim</a></li>
<li><a href="#">Corporis, non aut rerum</a></li>
<li><a href="#">Laboriosam nulla voluptas, harum</a></li>
<li><a href="#">Facere eligendi, inventore dolor</a></li>
</ul>
</section>
<section class="3u 6u(medium) 12u$(small)">
<h3>Neque, dolore, facere</h3>
<ul class="unstyled">
<li><a href="#">Lorem ipsum dolor sit</a></li>
<li><a href="#">Distinctio, inventore quidem nesciunt</a></li>
<li><a href="#">Explicabo inventore itaque autem</a></li>
<li><a href="#">Aperiam harum, sint quibusdam</a></li>
<li><a href="#">Labore excepturi assumenda</a></li>
</ul>
</section>
<section class="3u$ 6u$(medium) 12u$(small)">
<h3>Illum, tempori, saepe</h3>
<ul class="unstyled">
<li><a href="#">Lorem ipsum dolor sit</a></li>
<li><a href="#">Recusandae, culpa necessita nam</a></li>
<li><a href="#">Cupiditate, debitis adipisci blandi</a></li>
<li><a href="#">Tempore nam, enim quia</a></li>
<li><a href="#">Explicabo molestiae dolor labore</a></li>
</ul>
</section>
</div>
</section>
<div class="row">
<div class="8u 12u$(medium)">
<ul class="copyright">
<li>&copy; Untitled. All rights reserved.</li>
<li>Design: <a href="http://templated.co">TEMPLATED</a></li>
<li>Images: <a href="http://unsplash.com">Unsplash</a></li>
</ul>
</div>
<div class="4u$ 12u$(medium)">
<ul class="icons">
<li>
<a class="icon rounded fa-facebook"><span class="label">Facebook</span></a>
</li>
<li>
<a class="icon rounded fa-twitter"><span class="label">Twitter</span></a>
</li>
<li>
<a class="icon rounded fa-google-plus"><span class="label">Google+</span></a>
</li>
<li>
<a class="icon rounded fa-linkedin"><span class="label">LinkedIn</span></a>
</li>
</ul>
</div>
</div>
</div>
</footer>
</body>
</html>

View File

@ -13,7 +13,6 @@ use pocketmine\Server;
class Main extends PluginBase{
public function onDisable() {
$this->socket->close();
socket_shutdown($this->sock, 2);
}
public function onEnable(){
// $this->getServer()->getPluginManager()->registerEvents($this, $this);
@ -35,8 +34,8 @@ $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->socket = new OnlineTask($this, $sock, $this->getDataFolder());
$this->getServer()->getScheduler()->scheduleAsyncTask($this->socket);
$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){

View File

@ -25,17 +25,18 @@ use pocketmine\math\Vector3;
$this->isRunning = true;
$this->cfg = new Config($datapath . "config.yml", Config::YAML);
}
public function close() {
$this->isRunning = false;
}
public function onRun() {
$sock = $this->sock;
socket_listen($sock);
while ($this->isRunning) {
$client = socket_accept($sock);
$input = socket_read($client, 1024);
$incoming = explode("\r\n", $input);
$fetchArray = explode(" ", $incoming[0]);
if($fetchArray[1] == "/"){
$file = "index.html";
$fetchArray[1] = "index.html";
$file = $this->cfg->get("index");
$fetchArray[1] = $this->cfg->get("index");
} else {
$filearray = [];
$filearray = explode("/", $fetchArray[1]);
@ -46,20 +47,33 @@ use pocketmine\math\Vector3;
"Date: Fri, 31 Dec 1999 23:59:59 GMT \r\n" .
"Content-Type: text/html \r\n\r\n";
$file = ltrim($file, '/');
echo $fetchArray[1];
if(file_exists($this->datapath . $file)) {
$Content = file_get_contents($this->datapath . $file);
if(pathinfo($this->datapath . $file)['extension'] === "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 {
$Content = file_get_contents($this->datapath . "404.html");
$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"));
}
if(in_array($file, $this->cfg->get("denied-pages"))) {
$Content = file_get_contents($this->datapath . "403.html");
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));
}
}
public function close() {
$this->isRunning = false;
}
}

View File

@ -0,0 +1,31 @@
<?php
namespace Ad5001\Online;
use pocketmine\Server;
use pocketmine\scheduler\PluginTask;
use pocketmine\scheduler\Task;
use pocketmine\plugin\Plugin;
use pocketmine\scheduler\ServerScheduler;
use Ad5001\Online\OnlineTask;
class isOnlineTask extends PluginTask{
private $plugin;
private $sock;
public function __construct(Plugin $plugin, $sock, $datapath){
parent::__construct($plugin);
$this->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));
}
}
}