Skip to content

Commit 2495b27

Browse files
committed
Initial commit
0 parents  commit 2495b27

File tree

107 files changed

+3965
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+3965
-0
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*.phar
2+
/data/data.json
3+
gc_last
4+
.idea
5+
!favicon.ico
6+
/pg_/

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "pg"]
2+
path = pg
3+
url = https://github.com/PEMapModder/plugingen-source

.htaccess

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Options +FollowSymLinks
2+
AddType application/octet-stream .phar
3+
Options -Indexes
4+
ErrorDocument 404 /err_pages/404.php
5+
ErrorDocument 403 /err_pages/403.php
6+
RewriteEngine On
7+
RewriteRule ^pm(/.*)?$ pocketmine.php
8+
RewriteRule ^err_pages/?$ err_pages/403.php
9+
RewriteRule ^(data/phars/([^\.]+)(\.[a-z]+))/.*$ /$1
10+
RewriteRule ^(index.php)?$ /pocketmine.php
11+
RewriteRule ^pg/viewSrc\.php/(.*)$ /pg/viewSrc.php?path=$1
12+
RewriteRule ^pg/viewSrc/(.*)$ /pg/viewSrc.php?path=$1
13+
RewriteRule ^(pg/([^\.]+)(\.[a-z]+))/.*$ /$1
14+

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# web-server-source
2+
pemapmodder.zapto.org source (partial)
3+
4+
## Requirements
5+
* PHP 5.6 (yes, and the default PHP 5 installation on Ubuntu is PHP 5.5)
6+
* PHP YAML extension
7+
* PHP cURL extension
8+
* probably other things that I forgot
9+
10+
## Installation
11+
Clone this repo at the **document root** of your website. It is because some hyperlinks explicitly indicate as `/file.php`. Assuming `/var/www/html` in this page.
12+
13+
Please allow read/write access to the parent directory of the document root of the website, i.e. `/var/www`. I do that with `chmod -R www-data:www-data /var/www`.
14+
15+
A GitHub service client\_id + client\_secret is required to be set up at /var/www/cid.txt and /var/www/secret.txt
16+

TuneArgs.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
class TuneArgs{
4+
public $topNamespaceBackslash;
5+
public $obfuscate;
6+
public function isFilled(){
7+
return $this->topNamespaceBackslash or $this->obfuscate;
8+
}
9+
}

_pg_old/addCommand.php

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
include_once "pgFx.php";
3+
if(!isInitialized()){
4+
header("Location: pg.php");
5+
return;
6+
}
7+
if(!isset($_GET["name"], $_GET["desc"], $_GET["usage"])){
8+
$_GET["name"] = "";
9+
$_GET["desc"] = "";
10+
$_GET["usage"] = "";
11+
}
12+
?>
13+
<html>
14+
<head>
15+
<title>Add command | Plugin Generator</title>
16+
<script>
17+
var usageChanged = <?php echo ($_GET["usage"] === "") ? "false":"true"; ?>;
18+
function onUsageChange(){
19+
usageChanged = true;
20+
}
21+
function onNameChange(){
22+
if(!usageChanged){
23+
var name = document.getElementById("input_name").value;
24+
var usage = document.getElementById("input_usage");
25+
usage.value = "/" + name;
26+
}
27+
}
28+
</script>
29+
</head>
30+
<body>
31+
<h1>Add command</h1>
32+
<hr>
33+
<?php
34+
if(isset($_GET["notice"])){
35+
echo "<font color='#D02020'>";
36+
echo $_GET["notice"];
37+
echo "</font>";
38+
echo "<hr>";
39+
}
40+
?>
41+
<form action="addCommandCallback.php" method="post">
42+
<table>
43+
<tr>
44+
<td>Name</td>
45+
<td>
46+
<input type="text" name="name" value="" id="input_name" onchange="onNameChange();">
47+
</td>
48+
<td>
49+
<em>Notes: The command name <strong>must not</strong> contain spaces or colons.</em>
50+
</td>
51+
</tr>
52+
<tr>
53+
<td>Description</td>
54+
<td>
55+
<input type="text" name="desc">
56+
</td>
57+
</tr>
58+
<tr>
59+
<td>Usage message</td>
60+
<td>
61+
<input type="text" name="usage" id="input_usage" onchange="onUsageChange();">
62+
</td>
63+
</tr>
64+
<tr>
65+
<td><input type="submit" value="Add"></td>
66+
</tr>
67+
</table>
68+
</form>
69+
</body>
70+
</html>

_pg_old/addCommandCallback.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
use pg\classes\Command;
3+
include_once "pgFx.php";
4+
if(!isInitialized()){
5+
header("Location: pg.php");
6+
return;
7+
}
8+
if(!isset($_POST["name"], $_POST["desc"], $_POST["usage"])){
9+
header("Location: addCommand.php");
10+
return;
11+
}
12+
if(!Command::isValidName($name = trim($_POST["name"]))){
13+
header("Location: addCommand.php?notice=" . urlencode("Command names must not include spaces or colons!"));
14+
return;
15+
}
16+
$cmd = new Command(getPlugin(), $name, $_POST["desc"], $_POST["usage"]);
17+
getPlugin()->cmds[$name] = $cmd;
18+
header("Location: editCommand.php?name=" . urlencode($cmd->name));

_pg_old/addOperation.php

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
include_once "pgFx.php";
3+
if(!isInitialized()){
4+
header("Location: pg.php");
5+
return;
6+
}
7+
if(!isset($_GET["name"], $_GET["class"])){
8+
header("Location: main.php");
9+
return;
10+
}
11+
$plugin = getPlugin();
12+
$name = $_GET["name"];
13+
$class = $_GET["class"];
14+
$escapedName = var_export($name, true);
15+
if($class === "cmd"){
16+
if(!isset($plugin->cmds[$name])){
17+
echo <<<EOP
18+
<html>
19+
<head>
20+
<title>Error | Add Operation | Edit Command | Plugin Generator</title>
21+
</head>
22+
<body>
23+
<script>
24+
alert("Unknown command: " + $escapedName);
25+
location = "main.php";
26+
</script>
27+
</body>
28+
</html>
29+
EOP;
30+
return;
31+
}
32+
}
33+
elseif($class === "event"){
34+
// TODO
35+
}
36+
else{
37+
$escapedClass = var_export($class, true);
38+
echo <<<EOP
39+
<html>
40+
<head>
41+
<title>Error | Add Operation | Edit Command | Plugin Generator</title>
42+
</head>
43+
<body>
44+
<script>
45+
alert("Unknown class: " + $escapedClass);
46+
location = "main.php";
47+
</script>
48+
</body>
49+
</html>
50+
EOP;
51+
return;
52+
}
53+
$name = htmlspecialchars($name);
54+
?>
55+
<html>
56+
<head>
57+
<title>Add Operation | Edit Command | Plugin Generator</title>
58+
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
59+
<script src="js/addOperation.js"></script>
60+
</head>
61+
<body>
62+
<h1>Add Operation</h1>
63+
<form name="result" action="addOpCallback.php" method="get">
64+
<input type="hidden" name="class" value="<?php echo $_GET["class"]; ?>">
65+
<input type="hidden" name="name" value="<?php echo $_GET["name"]; ?>">
66+
<p>1. Choose what type of operation to add.</p>
67+
<select name="type">
68+
<option value="sendMsg">Send a message to a player or the command sender</option>
69+
<option value="broadcast">Broadcast a message</option>
70+
</select>
71+
<br>
72+
<input type="submit" value="Add">
73+
</form>
74+
</body>
75+
</html>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
define("NO_PAGE_GEN_FOOTER", true);
3+
include_once "../pgFx.php";
4+
5+
$data = [
6+
"status" => "OK",
7+
"evalCode" => "alert('Failure: Unknown reason');"
8+
];
9+
10+
if(!isInitialized()){
11+
$data["status"] = "pluginNotInitialized";
12+
goto hell;
13+
}
14+
15+
if(!isset($_POST["oldName"], $_POST["newName"])){
16+
$data["status"] = "insufficientPostFields";
17+
goto hell;
18+
}
19+
20+
$plugin = getPlugin();
21+
if(!isset($plugin->cmds[$oldName = $_POST["oldName"]])){
22+
$data["status"] = "cmdNotFound";
23+
goto hell;
24+
}
25+
26+
$newName = $_POST["newName"];
27+
$cmd = $plugin->cmds[$oldName];
28+
29+
if(isset($plugin->cmds[$newName])){
30+
$data["evalCode"] = "alert('The command /$newName already exists!');";
31+
goto hell;
32+
}
33+
34+
$cmd->name = $newName;
35+
unset($plugin->cmds[$oldName]);
36+
$plugin->cmds[$newName] = $cmd;
37+
$data["evalCode"] = "alert('Done! The command name has been changed from /$oldName to /$newName.');
38+
location.replace('editCommand.php?name=" . urlencode($newName) . "');";
39+
40+
hell:
41+
echo json_encode($data);
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
define("NO_PAGE_GEN_FOOTER", true);
3+
include_once "../pgFx.php";
4+
5+
$data = [
6+
"status" => "OK",
7+
"evalCode" => "alert('Failure: Unknown reason');"
8+
];
9+
10+
if(!isInitialized()){
11+
$data["status"] = "pluginNotInitialized";
12+
goto hell;
13+
}
14+
15+
if(!isset($_POST["cmd"], $_POST["name"], $_POST["value"])){
16+
$data["status"] = "insufficientPostFields";
17+
goto hell;
18+
}
19+
20+
$property = $_POST["name"];
21+
$value = $_POST["value"];
22+
if(!in_array($property, ["desc", "usage"])){
23+
$data["status"] = "unknownProperty";
24+
goto hell;
25+
}
26+
27+
$plugin = getPlugin();
28+
if(!isset($plugin->cmds[$cmdName = $_POST["cmd"]])){
29+
$data["status"] = "cmdNotFound";
30+
goto hell;
31+
}
32+
33+
$cmd = $plugin->cmds[$cmdName];
34+
$cmd->$property = $value;
35+
36+
$htmlDesc = var_export($value, true);
37+
$data["evalCode"] = "document.getElementById('property_$property').textContent = $htmlDesc;";
38+
39+
hell:
40+
echo json_encode($data);

0 commit comments

Comments
 (0)