Compare commits

...

25 commits
1.0 ... master

Author SHA1 Message Date
Ad5001 3d300bf5a2 My bad 2017-01-19 18:41:49 +01:00
Ad5001 fb3a2dfb82 Adding icon 2017-01-19 18:39:30 +01:00
Ad5001 ee20f04e2a README + fixs 2016-12-28 20:38:35 +01:00
Ad5001 31e25d3635 It was buggy. 2016-12-28 18:53:27 +01:00
Ad5001 c797ce9fdf Merge branch 'master' of https://github.com/Ad5001/Online 2016-12-28 18:35:08 +01:00
Ad5001 51ceb0ecc9 Fixing URI on handlers
having the URI with the args of get request
2016-12-28 18:34:58 +01:00
poggit-bot d15c4a1e9c Create .poggit.yml
Poggit-CI is enabled for this repo by @Ad5001
Visit the Poggit-CI page for this repo at https://poggit.pmmp.io/ci/Ad5001/Online
2016-12-28 18:33:27 +01:00
Ad5001 520f4f8115 1.6 IS WORKING? WANNA TRY IT OUT? 2016-12-27 15:19:49 +01:00
Ad5001 a5835e3b4b Fixing meging problems 2016-12-27 12:06:27 +01:00
Ad5001 1ccc14d389 1.6 starting 2016-12-27 12:04:35 +01:00
Ad5001 456a0bfef8 Fixing a bug ! 2016-10-08 16:35:02 +03:00
Ad5001 c5c8e3c1eb 1.5 README DOC 2016-08-26 19:24:46 +03:00
Ad5001 36c899f133
1.5, 2nd & last commit ! 2016-08-26 18:29:32 +03:00
Ad5001 bec496715e
1.5 ? :D 2016-08-26 17:40:14 +03:00
Ad5001 69528b9752 1.4 release :D 2016-07-30 19:12:56 +03:00
Ad5001 335007df2b 1.4 starting...
Just have to add an handler.
2016-07-30 17:09:31 +03:00
Ad5001 1db1810c7d 1.1 RELEASE 2016-05-31 19:56:40 +02:00
Ad5001 26a0822850 Fixing a bug 2016-05-31 19:43:30 +02:00
Ad5001 03643fb4af FINALLY ADDING $_GET METHOD 2016-05-31 18:47:08 +02:00
Ad5001 b64dd24aa1 Delete hey.php 2016-05-30 19:54:31 +02:00
Ad5001 2e8fc105fd Delete im.php 2016-05-30 19:54:20 +02:00
Ad5001 869c8fbb9f Delete index.html 2016-05-30 19:53:50 +02:00
Ad5001 4d0aa7ef1e Moving forward !
Fixing some issues in the config + processing PHP
2016-05-30 19:06:31 +02:00
Ad5001 a6a8881d1c Changing to lastest news ! 2016-05-30 11:58:44 +02:00
Ad5001 83061751f3 Adding forbidden 2016-05-30 08:11:06 +02:00
14 changed files with 709 additions and 283 deletions

6
.gitignore vendored
View file

@ -45,3 +45,9 @@ $RECYCLE.BIN/
Network Trash Folder
Temporary Items
.apdisk
# Github files, Junk files
.github
.router.php
.config.yml

8
.poggit.yml Normal file
View file

@ -0,0 +1,8 @@
--- # Poggit-CI Manifest. Open the CI at https://poggit.pmmp.io/ci/Ad5001/Online
branches:
- master
projects:
Online:
icon: "Online-Eclipse-Modified.png"
path: ""
...

7
.vscode/tasks.json vendored Normal file
View file

@ -0,0 +1,7 @@
{
"version": "0.1.0",
"command": "start",
"isShellCommand": true,
"args": ["cmd", "/C", "C:\\Program Files\\Git\\commit-signed.cmd"],
"showOutput": "always"
}

View file

@ -1,5 +0,0 @@
<html>
<head>
<title>404 NOT FOUND</title>
</head>
<body>Error. File not found !</body>

255
LICENSE
View file

@ -1,201 +1,104 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
1. Definitions.
Section 1 Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.
BY-NC-SA Compatible License means a license listed at creativecommons.org/compatiblelicenses, approved by Creative Commons as essentially the equivalent of this Public License.
Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
Effective Technological Measures means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
Exceptions and Limitations means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
License Elements means the license attributes listed in the name of a Creative Commons Public License. The License Elements of this Public License are Attribution, NonCommercial, and ShareAlike.
Licensed Material means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
Licensed Rights means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
Licensor means the individual(s) or entity(ies) granting rights under this Public License.
NonCommercial means not primarily intended for or directed towards commercial advantage or monetary compensation. For purposes of this Public License, the exchange of the Licensed Material for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is NonCommercial provided there is no payment of monetary compensation in connection with the exchange.
Share means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
Sui Generis Database Rights means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
You means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
Section 2 Scope.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
License grant.
Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
reproduce and Share the Licensed Material, in whole or in part, for NonCommercial purposes only; and
produce, reproduce, and Share Adapted Material for NonCommercial purposes only.
Exceptions and Limitations. For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
Term. The term of this Public License is specified in Section 6(a).
Media and formats; technical modifications allowed. The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
Downstream recipients.
Offer from the Licensor Licensed Material. Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
Additional offer from the Licensor Adapted Material. Every recipient of Adapted Material from You automatically receives an offer from the Licensor to exercise the Licensed Rights in the Adapted Material under the conditions of the Adapters License You apply.
No downstream restrictions. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
No endorsement. Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
Other rights.
Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
Patent and trademark rights are not licensed under this Public License.
To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties, including when the Licensed Material is used other than for NonCommercial purposes.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
Section 3 License Conditions.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
Your exercise of the Licensed Rights is expressly made subject to the following conditions.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
Attribution.
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
If You Share the Licensed Material (including in modified form), You must:
retain the following if it is supplied by the Licensor with the Licensed Material:
identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
a copyright notice;
a notice that refers to this Public License;
a notice that refers to the disclaimer of warranties;
a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
ShareAlike.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply.
The Adapters License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-NC-SA Compatible License.
You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material.
You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply.
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
Section 4 Sui Generis Database Rights.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database for NonCommercial purposes only;
if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material, including for purposes of Section 3(b); and
You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
Section 5 Disclaimer of Warranties and Limitation of Liability.
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.
To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
Section 6 Term and Termination.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
upon express reinstatement by the Licensor.
For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
Section 7 Other Terms and Conditions.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
Section 8 Interpretation.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2016 Ad5001
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.

BIN
Online-Eclipse-Modified.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

198
README.md
View file

@ -1,25 +1,199 @@
#Online
_______
Make a website for your ImagicalMine server fully free !
Create multiple website for your PocketMine server fully free !
This plugin is under the [Apache License v2.0](/LICENSE)
This plugin is under the [BoxOfDevs LICENSE v1.0](blob/master/LICENSE)
### How to use?
By default , the plugin generates a index.html (change it !) and a 404.html .
### Create your first website
<!--
By default , the plugin generates a index.html (change it !), a 404.html and a 403.html .
Use the plugin folder as website root folder.
To to your website, type localhost:8080 .
In the config, you can change: index page, 404 page, 403 page, the website port, and thz forbidden acess page.
-->
#### WHEN UPDATING TO 1.5, REMEMBER TO DELETE YOUR CONFIG! A NEW ONE WILL BE GENERATED WITH NEW VALUES !
To create a website, go to the config.yml -> plugins/Online/config.yml
Then add a new website in the "Domains" array (by default, there is localhost) with your website name so it looks like this (for this whole example, we will use example.com but local servers are already here by default. It's if you want to add a new one):
To make everyone able to see your website, you need to port forward your website (if you have port forwared your server, you will also need to do this) .
```yaml
Domains:
- localhost
- example.com
```
There are tons of tutorials on how to portforward something (use google !) but there are some specific config to do.
Restart your server and a new folder in the Online folder will be generated! It will be your new website path.
By default, there will be an index.html, a 404.html and a 403.html.
You can modify them, add more files, ect....
If you're using an external domain, portforward your machine (later on the lesson) , then go to your registar CPanel and go to records -> add new record and then put it to CName to your portforwarded machine. All of this isn't required localy.
After have done this, connect yourself to the website by your browser: http://example.com:Your port (by default 80).
To make everyone able to see your website, you need to port forward your website (if you have port forwared your server, you will also need to do this) . Note that the port forward should be automatized on windows devices using UPnP.
There are tons of tutorials on how to portforward something (google it !) but there are some specific config to do.
And there you go ! You've created your first website with online ! Good job !
Config of the port foreward:
Name: HTTP
Start port: 8080
End port: 8080
Protocol: TPC
Start port: Your port (by default 80)
End port: Your port (by default 80)
Protocol: TPC
Start your server and profit of your website !
Start your server and profit of your new website !
(I know that @Falk created a plugin called Volt that does same but this plugin works in a completly different way (that make a lot less laggy and a lot less heavier in space !) and it's fully coded by myself in PHP7)
### Add a parked domain
You've created a website but you want to broadcast it on multiple websites? No problem ! Look at the tutorial below and see how to do this !
1. You need first to have done [you're first website](#Create-your-first-website)
2. Go to your config (still the same and add a new element: `parked domain: current domain` (there is by default 0.0.0.0 and 127.0.0.1 that points to localhost) So it looks like this (for this example, example.net is the parked domain and example.com is the existing one):
```yaml
Parked domains:
0.0.0.0: localhost
127.0.0.1: localhost
example.net: example.com
```
3. Then, go to your parked domain registar CPanel and add a new CName record pointing to the machine IP.
4. There you go, you created a parked domain !
### Tips & tricks:
You might have seen that the tutorials above haven't covered the whole configs and stuff !
Here are some tips & tricks that what are they here for !
1. <u>Changing port</u>: Yes, it's not always easy to use port 80 ! It's often binded... CHange the value of "port" in the config and set it to your new port and it will work fine !
2. <u>Errors and index</u>: Change index, 404 and 403 to customize even more you're website ! Change them to customisze even more your website ! 404 is when a page is not found, 403 is when the user is not allowed to view this page. You can change them to make it even more customisable !
3. <u>Denied pages</u>: Sometimes, you don't want the user to see some pages so add them to the denied page array to block them from being viewed ! Example:
```yaml
denied-pages:
- website/path/to/file
```
4. <u>Set the server still open even if the server's stop</u>: Set the KillOnShutdown to false. What does that mean? Simply that the websites and domains will still remain even if the server is offline. BUT remember that those issues can happend: Server got stuck on disable: Problem at starting. Unable to stop it on hoster. So DON'T MODIFY IT IF YOU'RE NOT USING A VPS OR LOCALLY. Command to stop it :
Windows:
```batch
FOR /F "tokens=5" %P IN (\'netstat -a -n -o ^| findstr 0.0.0.0:<PORT>') DO TaskKill.exe /F /PID %P
```
MACOSX and LINUX:
```bash
kill -kill `lsof -t -i tcp:<port`
```
### API
With 1.6, API has been introduced with many ways to customize and filter requests to your website and interaction with your server.
##### Pocketmine, players, plugins, and levels variables with infos
First feature of the API is to get default infos about pocketmine or any plugin, players, or levels.
This allow recognition from the webserver of the server.
- Pocketmine infos are located at $_POCKETMINE["info"]
- Players infos are located at $_PLAYERS["name of the player"]["info"]
- Levels infos are located at $_LEVELS["name of the level"]["info"];
- Plugins infos are located at $_PLUGINS["name of the plugin"]["info"]
That being said, take a look at saved variables:
####### Pocketmine:
- software_name: Name of the software used as pocketmine (such as PocketMine-MP, Genisys, ...)
- software_codename: Codename of the software used as pocketmine (such as Unleached for PocketMine-MP ...)
- software_version: Version of the software used as pocketmine (such as 1.5, 1.6, ...)
- mcpe_version: MCPE version of the software.
- API: Plugins API version.
- software datapath: Root path of the server
- software_pluginpath: Plugins path of the server
- max_players: Maximum number of players in the server.
- port: Port listened by pocketmine.
- view_distance: View distance of the players on the server.
- ip: IP of the server. Might be usable.
- server_unique&#95;id: Returns the unique id of the server.
- auto_save: Boolean if the server has enabled autosaved
- default_gamemode: Default gamemode of the server.
- force_gamemode: Boolean if the server has enabled force gamemode.
- difficulty: Diffiulty of the server
- spawn_radius: Radius of the spawn protection.
- allow_flight: Boolean if the server enabled flight for players in every gamamode
- ultra_hardcore: Boolean if the server is in ultra hardcore, (banned if dead, no regeneration with food)
- motd: MOTD of the server.
- tps: Ticks Per Second of the server.
- lang_name: The name of the lang of the server.
- lang_code: The 3 char code letters of a language.
####### Plugins:
- name: Name of the plugin
- is_enabled: Is the plugin enabled
- data_folder: Path to plugin data folder
- apis: Compatible APIs of the plugin
- authors: Authors of the plugin
- prefix: Logger prefix of the plugin (mostly "[name of the plugin]")
- commands: Commands registered by the plugin
- dependencies: Plugin dependencies
- description: Description of the plugin
- load_before: When should the plugin loa (STARTUP or POSTLOAD)
- main: Main class of the plugin
- order: Order of the plugin
- soft_depend: Pocketmine dependency of the plugin
- version: Version of the plugin
- website: Website of the plugin.
####### Players:
- client_secret: Secret id of the client.
- banned: Is the player banned (should not be true, but we never know).
- whitelisted: Is the player whitelisted
- first_played: Date of the first play of the the player
- last_played: Date of the last play of the the player
- played_before: Has player played before
- allow_flight: Is the player allowed to fly
- flying: Is the player flying
- auto_jump: Has the player enabled auto jump
- op: Is the player OP
- connected: Is the player connected (Well he should x)).
- display_name: The displayed name of the player
- ip: Player's ip
- port: Port of the listening player's IP.
- is_sleeping: Is the player sleeping
- ticks_in&#95;air: Ticks in air of the player
- gamemode: Gamemode of the player
- name: Name of the player
- loader_id: Id of the loader of the player.
####### Levels:
- tick_rate: Tick rate of the level
- id: Id of the level
- auto_save: Has the level auto save
- players: Players in the level with their info.
- time: Time in the level
- name: Name of the levels
- folder_name: Folder name of the player
- seed: Seed of the player
##### Passing and getting "arguments" to the thread.
Second API features are variables that you can pass to the webserver. Variables will be passed as $_PLUGINS["name"]["id of the variable"].
To pass an argument, add this line to your code.
```php
$this->getServer()->getPluginManager()->getPlugin("Online")->setArgument($this, "id of the var", $varToPass);
```
You can see them by adding this line.
```php
$args = $this->getServer()->getPluginManager()->getPlugin("Online")->getArguments($this);
```
This gives you the ability to show custom things related to the server on the files.
Please note that all variables passed (default & customs) are refreshed every 10 seconfs.
##### Custom handlers.
This is the most powerfull way to customize your webserver.
Custom handlers are PHP files that are executed each time a request to the server is done.
To add a custom handler, create a new PHP file into your plugin src and add this line of code to your main file:
```php
$this->getServer()->getPluginManager()->getPlugin("Online")->addHandler(&#95;&#95;DIR&#95;&#95; . "/handler.php");
```
You can also see all the handlers by doing:
```php
$handlers = $this->getServer()->getPluginManager()->getPlugin("Online")->getHandlers();
```
=======
That's it so I hoope you will enjoy my plugin !
(I know that @Falk created a plugin called Volt that does same but this plugin works in a completly different way (that make a lot less laggy and a lot less heavier in space !) and it's fully coded by myself in PHP7)

25
config.yml Normal file
View file

@ -0,0 +1,25 @@
# Welcome to Online config !
#This define the port that your website that will run.
#****NOTE THAT YOU WILL NEED TO RE-PORTFOREWARD WITH THE NEW PORT****
port: 80
# Here you can choose the pages !
index: index.html
404: 404.html
403: 403.html
# Here you can config pages that user will not be able to see !
denied-pages: []
# Your domains (one per time). To redirect a domain here, put one per line then go to your registar CPanel and add a CName record that redirects to it !
Domains: ["localhost"]
#Parked domains: Domains that redirects to one of your domains. Same setup as shown above.
Parked domains:
127.0.0.1: localhost
# Here you can choose if the server automaticly disable itself on server stop.
# DO NOT DISABLE THIS OPTION WHEN YOU'RE USING AN HOSTER ! OR YOU WON'T BE ABLE TO STOP IT !
KillOnShutdown: true

View file

@ -1,9 +1,11 @@
---
name: Online
author: Ad5001
version: 1.0
api: [2.0.0]
version: 1.6
api: [2.0.0, 3.0.0, 3.0.0-ALPHA1, 3.0.0-ALPHA2, 3.0.0-ALPHA3,]
description: "You're own website, on PocketMine.'"
main: Ad5001\Online\Main
load: STARTUP
commands: []
permissions: []
...

5
resources/403.html Normal file
View file

@ -0,0 +1,5 @@
<html>
<head>
<title>403 FORBIDDEN</title>
</head>
<body>Error. You don't have the peremission to view this page or to perform this action !</body>

27
resources/config.yml Normal file
View file

@ -0,0 +1,27 @@
# Welcome to Online config !
#This define the port that your website that will run.
#****NOTE THAT YOU WILL NEED TO RE-PORTFOREWARD WITH THE NEW PORT****
port: 80
# Here you can choose the pages !
index: index.html
404: 404.html
403: 403.html
# Here you can config pages that user will not be able to see !
denied-pages: []
# Your domains (one per time). To redirect a domain here, put one per line then go to your registar CPanel and add a CName record that redirects to it !
Domains:
- localhost
#Parked domains: Domains that redirects to one of your domains. Same setup as shown above.
Parked domains:
127.0.0.1: localhost
0.0.0.0: localhost
# Here you can choose if the server automaticly disable itself on server stop.
# DO NOT DISABLE THIS OPTION WHEN YOU'RE USING AN HOSTER ! OR YOU WON'T BE ABLE TO STOP IT !
KillOnShutdown: true

96
resources/handler.php Normal file
View file

@ -0,0 +1,96 @@
<?php
/*
Copyright (C) Ad5001 2016 All rights reserved.
@link http://ad5001.ga
Do not attemped to modify this file if you're not sure on how it works.
This file process 404, 403 requests, custom index and some other stuff.
*/
// Definitions
$cfg = yaml_parse(file_get_contents(__DIR__ . "/../config.yml"));
$args = json_decode(file_get_contents(__DIR__ . "/args"), true);
$_POCKETMINE = $args["POCKETMINE"];
$_PLUGINS = $args["PLUGINS"];
$_PLAYERS = $args["PLAYERS"];
$_LEVELS = $args["LEVELS"];
// Removing GET from the request
$uri = $_SERVER["REQUEST_URI"];
if(strpos($uri, "?") !== false) {
$uri = explode("?", $uri)[0];
}
$_SERVER["REQUEST_URI"] = $uri;
// Calling handlers.
foreach($args["HANDLERS"] as $handler) {
if((include $handler) == false) {
return true;
}
}
// Domains parsing
$host = $_SERVER["HTTP_HOST"];
if(isset($cfg["Parked domains"][$host])) {
$host = $cfg["Parked domains"][$host];
}
if(in_array($host, $cfg["Domains"])) {
$_SERVER["REQUEST_URI"] = $host . $_SERVER["REQUEST_URI"];
} else {
unallowedDomain();
return true;
}
// Getting the file & output it if possible.
if(!file_exists(__DIR__ . "/../$host" . $uri)) {
include __DIR__ . "/../$host" . "/" . $cfg[404];
} elseif(in_array($uri, $cfg["denied-pages"])) {
include __DIR__ . "/../$host" . "/" . $cfg[403];
} elseif(is_dir(__DIR__ . "/../" .$uri)) {
if(file_exists(__DIR__ . "/../$host" . $uri . "index.html")) {
include __DIR__ . "/../$host" . $uri . "index.html";
} elseif(file_exists(__DIR__ . "/../$host" . $uri . "index.php")) {
include __DIR__ . "/../$host" . $uri . "index.php";
} elseif(file_exists(__DIR__ . "/../$host" . $uri . $cfg["index"])) {
include __DIR__ . "/../$host" . $uri . $cfg["index"];
}
} else {
include __DIR__ . "/" . $host . $uri;
}
function unallowedDomain() {
echo <<<A
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Roboto+Condensed:300" rel="stylesheet">
<style>
body {
padding: 60px;
}
div.container {
padding: 40px;
border: 3px solid lightgray;
border-radius: 8px;
background: linear-gradient(45deg, gray, grey);
height: 70%;
}
h1, h2, h3, p {
font-family: 'Roboto Condensed', sans-serif;
}
</style>
<link rel="icon" src="http://serveur.cf/Online/icon.ico" href="http://serveur.cf/Online/icon.ico" />
</head>
<body>
<div class="container">
<h1><img src="http://serveur.cf/Online/icon.png" style="width: 30px; height: 30px;"></img>Unallowed domain</h1><hr>
<p>This IP does not have any domain on this machine. Please refer to your server administartor if you think it's an error.</p>
<h2 style="float: right;">Online 1.6 - Eclipse edition</a></h2>
</body>
</style>
A;
}

View file

@ -1,44 +1,281 @@
<?php
namespace Ad5001\Online ;
namespace Ad5001\Online;
use pocketmine\command\CommandSender;
use pocketmine\command\Command;
use pocketmine\event\Listener;
use pocketmine\plugin\PluginBase;
use pocketmine\network\upnp\UPnP;
use pocketmine\Server;
use pocketmine\Player;
use Ad5001\Online\OnlineTask;
use pocketmine\Player;
class Main extends PluginBase{
public function onDisable() {
$this->socket->close();
socket_shutdown($this->sock, 2);
protected $handlers;
protected $arguments;
public function onEnable(){
$this->saveDefaultConfig();
$this->handlers = [];
$this->arguments = [];
$this->getServer()->getScheduler()->scheduleRepeatingTask($task = new ArgFillTask($this), 20*10);
@mkdir($this->getDataFolder() . "tmp");
$task->onRun(0);
if(!file_exists($this->getDataFolder() . "tmp/router.php")) {
file_put_contents($this->getDataFolder() . "tmp/router.php", $this->getResource("handler.php"));
}
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"));
}
}
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()));
}
public function onDisable() {
if($this->getConfig()->get("KillOnShutdown") !== "false") {
$this->getLogger()->info("Shutdowning.....");
switch(true) {
case stristr(PHP_OS, "WIN"):
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;
}
}
}
/*
Adds a PHP handler
@param $path string
@return bool
*/
public function addHandler(string $path) : bool {
if(file_exists($path)) {
$this->handlers[$path] = $path;
return true;
}
return false;
}
/*
Return an array with all handlers
@return array
*/
public function getHandlers() : array {
return $this->handlers;
}
/*
Sets a plugin argument
@param $plugin \pocketmine\plugin\Plugin
@param $id string
@param $value mixed
@return bool
*/
public function setArgument(\pocketmine\plugin\Plugin $plugin, string $id, $value) : bool {
if(!isset($this->arguments[$plugin->getName()])) $this->arguments[$plugin->getName()] = [];
$this->arguments[$plugin->getName()][$id] = $value;
return true;
}
/*
Gets a plugin arguments
@param $plugin \pocketmine\plugin\Plugin
@return array
*/
public function getArguments(\pocketmine\plugin\Plugin $plugin) : array {
return isset($this->arguments[$plugin->getName()]) ? $this->arguments[$plugin->getName()] : [];
}
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(!file_exists($this->getDataFolder() . "404.html")) {
file_put_contents($this->getDataFolder() . "404.html", $this->getResource("404.html"));
}
set_time_limit(0);
$address = '0.0.0.0';
$port = 8080;
$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->sock = $sock;
}
public function onCommand(CommandSender $issuer, Command $cmd, $label, array $params){
switch($cmd->getName()){
/**
* Setting rguments for the pocketine infos
*/
class ArgFillTask extends \pocketmine\scheduler\PluginTask {
/*
Constructs the class
@param $main Main
*/
public function __construct(Main $main) {
parent::__construct($main);
$this->main = $main;
$this->server = $main->getServer();
}
/*
Called when the task runs
@param $tick mixed
*/
public function onRun($tick) {
$server = $this->server;
$pmargs = [];
$pluginsargs = [];
$players = [];
$levels = [];
// Filling the arguments
// 1. Pocketmine
$pmargs["software_name"] = $server->getName();
$pmargs["software_codename"] = $server->getCodename();
$pmargs["software_version"] = $server->getPocketmineVersion();
$pmargs["mcpe_version"] = $server->getVersion();
$pmargs["API"] = $server->getApiVersion();
$pmargs["software_datapath"] = $server->getDataPath();
$pmargs["software_pluginpath"] = $server->getPluginPath();
$pmargs["max_players"] = $server->getMaxPlayers();
$pmargs["port"] = $server->getPort();
$pmargs["view_distance"] = $server->getViewDistance();
$pmargs["ip"] = $server->getIp();
$pmargs["server_unique_id"] = $server->getServerUniqueId();
$pmargs["auto_save"] = $server->getAutoSave();
$pmargs["default_gamemode"] = $server->getGamemode();
$pmargs["force_gamemode"] = $server->getForceGamemode();
$pmargs["difficulty"] = $server->getDifficulty();
$pmargs["spawn_radius"] = $server->getSpawnRadius();
$pmargs["allow_flight"] = $server->getAllowFlight();
$pmargs["ultra_hardcore"] = $server->isHardcore();
$pmargs["motd"] = $server->getMotd();
$pmargs["tps"] = $server->getTicksPerSecond();
$pmargs["lang_name"] = $server->getLanguage()->getName();
$pmargs["lang_code"] = $server->getLanguage()->getLang();
// 2. Plugins
foreach($server->getPluginManager()->getPlugins() as $plugin) {
$pl = [];
$pl["name"] = $plugin->getName();
$pl["is_enabled"] = $plugin->isEnabled();
$pl["data_folder"] = $plugin->getDataFolder();
$pl["apis"] = $plugin->getDescription()->getCompatibleApis();
$pl["authors"] = $plugin->getDescription()->getAuthors();
$pl["prefix"] = $plugin->getDescription()->getPrefix();
$pl["commands"] = $plugin->getDescription()->getCommands();
$pl["dependencies"] = $plugin->getDescription()->getDepend();
$pl["description"] = $plugin->getDescription()->getDescription();
$pl["load_before"] = $plugin->getDescription()->getLoadBefore();
$pl["main"] = $plugin->getDescription()->getMain();
$pl["order"] = $plugin->getDescription()->getOrder();
$pl["soft_depend"] = $plugin->getDescription()->getSoftDepend();
$pl["version"] = $plugin->getDescription()->getVersion();
$pl["website"] = $plugin->getDescription()->getWebsite();
foreach($this->main->getArguments($plugin) as $name => $arg) {
if(!isset($pl[$name])) {
$pl[$name] = $arg;
}
}
$pluginsargs[$plugin->getName()] = $pl;
}
// 3. Players
foreach ($server->getOnlinePlayers() as $player) {
$pl = [];
$pl["client_secret"] = $player->getClientSecret();
$pl["banned"] = $player->isBanned(); // I don't know if tis could be to false but we never know xD
$pl["whitelisted"] = $player->isWhitelisted();
$pl["first_played"] = $player->getFirstPlayed();
$pl["last_played"] = $player->getLastPlayed();
$pl["played_before"] = $player->hasPlayedBefore();
$pl["allow_flight"] = $player->getAllowFlight();
$pl["flying"] = $player->isFlying();
$pl["auto_jump"] = $player->hasAutoJump();
$pl["op"] = $player->isOp();
$pl["connected"] = $player->isConnected();
$pl["display_name"] = $player->getDisplayName();
$pl["ip"] = $player->getAddress();
$pl["port"] = $player->getPort();
$pl["is_sleeping"] = $player->isSleeping();
$pl["ticks_in_air"] = $player->getInAirTicks();
$pl["gamemode"] = $player->getGamemode();
$pl["name"] = $player->getName();
$pl["loader_id"] = $player->getLoaderId();
$players[$player->getName()] = $pl;
}
// 4.Levels
foreach ($server->getLevels() as $level) {
$lvl = [];
$lvl["tick_rate"] = $level->getTickRate();
$lvl["id"] = $level->getId();
$lvl["auto_save"] = $level->getAutoSave();
$lvl["players"] = [];
foreach ($level->getPlayers() as $pl) {
$lvl["players"][$pl->getName()] = $players[$pl->getName()];
}
$lvl["time"] = $level->getTime();
$lvl["name"] = $level->getName();
$lvl["folder_name"] = $level->getFolderName();
$lvl["seed"] = $level->getSeed();
$levels[$lvl["name"]] = $lvl;
}
file_put_contents($this->main->getDataFolder() . "tmp/args", json_encode(["POCKETMINE" => $pmargs, "PLUGINS" => $pluginsargs, "PLAYERS" => $players, "LEVELS" => $levels, "HANDLERS" => $this->main->getHandlers()]));
}
}
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"];
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 /MIN 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 . ' tmp/router.php"');
break;
case stristr(PHP_OS, "DAR"):
shell_exec('open -a Terminal php -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 . ' tmp/router.php"');
break;
case stristr(PHP_OS, "LINUX"):
shell_exec('gnome-terminal -e php -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 . ' tmp/router.php"');
break;
}
}
}

View file

@ -1,59 +0,0 @@
<?php
namespace Ad5001\Online;
use pocketmine\Server;
use pocketmine\scheduler\AsyncTask;
use pocketmine\scheduler\Task;
use pocketmine\scheduler\ServerScheduler;
use pocketmine\event\Listener;
use pocketmine\plugin\Plugin;
use pocketmine\level\Level;
use pocketmine\block\Block;
use pocketmine\Player;
use pocketmine\item\Item;
use pocketmine\utils\TextFormat as C;
use pocketmine\IPlayer;
use pocketmine\math\Vector3;
class OnlineTask extends AsyncTask{
private $plugin;
private $sock;
public function __construct(Plugin $plugin, $sock, $datapath){
$this->sock = $sock;
$this->datapath = $datapath;
$this->isRunning = true;
}
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";
} 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(file_exists($this->datapath . $file)) {
$Content = file_get_contents($this->datapath . $file);
} else {
$Content = file_get_contents($this->datapath . "404.html");
}
$output = $Header . $Content;
socket_write($client,$output,strlen($output));
}
}
public function close() {
$this->isRunning = false;
}
}