Skip to content

Commit 26d3475

Browse files
committed
Added new pages and features
* Added api2 * Fixed a bug in InstaPlugin * Added perm
1 parent e2ab12d commit 26d3475

File tree

5 files changed

+127
-3
lines changed

5 files changed

+127
-3
lines changed

.htaccess

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ RewriteRule ^pg/viewSrc\.php/(.*)$ /pg/viewSrc.php?path=$1
1212
RewriteRule ^pg/viewSrc/(.*)$ /pg/viewSrc.php?path=$1
1313
RewriteRule ^(pg/([^\.]+)(\.[a-z]+))/.*$ /$1
1414
RewriteRule ^pmb/dl/(.+).phar$ /pmb/dl.php?branch=$1
15+
RewriteRule ^api2/.+\.phar$ /api2/
1516
RewriteCond %{REQUEST_URI} !/robots\.txt$ [nocase]
1617
RewriteRule \.txt$ - [forbidden,last]
1718

api2/index.php

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
set_error_handler(function($n, $msg, $file, $line){
3+
header("Content-Type: text/plain");
4+
echo "Error: $msg at $file#$line";
5+
http_response_code(500);
6+
exit;
7+
});
8+
if(isset($_FILES["phar"])){
9+
$newApi = "2.0.0";
10+
if(isset($_REQUEST["api"])) $newApi = $_REQUEST["api"];
11+
$path = $_FILES["phar"]["tmp_name"];
12+
$extended = $path . ".phar";
13+
move_uploaded_File($path, $extended);
14+
$phar = new Phar($extended);
15+
$phar->startBuffering();
16+
if(!isset($phar["plugin.yml"])){
17+
header("Content-Type: text/plain");
18+
echo "plugin.yml missing";
19+
exit;
20+
}
21+
$contents = file_get_contents($phar["plugin.yml"]);
22+
$yaml = yaml_parse($contents);
23+
if(!is_array($yaml["api"])) $yaml["api"] = [$yaml["api"]];
24+
if(in_array($newApi, $yaml["api"])){
25+
header("Content-Type: text/plain");
26+
echo "API version $newApi is already declared.";
27+
exit;
28+
}
29+
$yaml["api"][] = "2.0.0";
30+
$contents = yaml_emit($yaml);
31+
$phar->addFromString("plugin.yml", $contents);
32+
$phar->stopBuffering();
33+
header("Content-Type: application/octet-stream");
34+
echo file_get_contents($extended);
35+
exit;
36+
}
37+
?>
38+
<html>
39+
<head>
40+
<title>Plugin API version bumper</title>
41+
</head>
42+
<body>
43+
<h1>API 2.0.0 injection</h1>
44+
<p>Before using this tool, please carefully read the following cautions:</p>
45+
<ul>
46+
<li>This tool only <em>forces</em> the plugin to say that it supports API 2.0.0 (PHP 7 update). It will not fix the actual incompatibility issues.</li>
47+
<li>If errors happen after using phars downloaded from this page, unintsall it immediately.</li>
48+
<li>Click <button onclick='document.getElementById("upload").disabled = false;'>this button</button> if you have read the above.</li>
49+
</ul>
50+
<hr>
51+
<form action="updated.phar" method="post" enctype="multipart/form-data">
52+
<input type="file" name="phar"><br>
53+
No, I don't want API <code>2.0.0</code>. I want something else: <input type="text" name="api" value="2.0.0"><br>
54+
<input type="submit" id="upload" value="Inject" disabled>
55+
</form>
56+
</body>
57+
</html>
58+

insta/new.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function onRun(\$ticks){
101101
$files["src--" . str_replace("\\", "--", $namespace) . "--$className.php"] = ["content" => $c];
102102
}
103103
if($config){
104-
$files["resources--config.yml"] = "---\n\n...\n";
104+
$files["resources--config.yml"] = ["content" => "---\n\n...\n"];
105105
}
106106

107107
foreach($skeletonNames as $className){
@@ -119,12 +119,14 @@ public function __construct(){
119119
$files["src--" . str_replace("\\", "--", $namespace) . "--$className.php"] = ["content" => $c];
120120
}
121121

122-
$data = json_decode(urlGet("https://api.github.com/gists", true, json_encode([
122+
$data = json_decode($jsonIn = urlGet("https://api.github.com/gists", true, $jsonOut = json_encode([
123123
"description" => "$name - Auto-generated gist plugin stub by pmt.mcpe.me InstaPlugin",
124124
"files" => $files,
125125
])));
126126
if(!isset($data->id)){
127-
echo json_encode($data, JSON_PRETTY_PRINT);
127+
header("Content-Type: text/plain");
128+
echo "Request:\r\n===$jsonOut\r\n";;
129+
echo "Response:\r\n===$jsonIn\r\n";;
128130
return;
129131
}
130132
header("Location: https://gist.github.com/" . $_SESSION["github_login"] . "/$data->id/edit");

perm/index.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
if(strpos(getallheaders()["Accept"], "json") !== false) echo json_encode(yaml_parse_file("perm.yml"), JSON_PRETTY_PRINT);
3+

perm/perm.json

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
[
2+
"pocketmine",
3+
"pocketmine.broadcast",
4+
"pocketmine.broadcast.admin",
5+
"pocketmine.broadcast.user",
6+
"pocketmine.command",
7+
"pocketmine.command.whitelist",
8+
"pocketmine.command.whitelist.add",
9+
"pocketmine.command.whitelist.remove",
10+
"pocketmine.command.whitelist.reload",
11+
"pocketmine.command.whitelist.enable",
12+
"pocketmine.command.whitelist.disable",
13+
"pocketmine.command.whitelist.list",
14+
"pocketmine.command.ban",
15+
"pocketmine.command.ban.player",
16+
"pocketmine.command.ban.ip",
17+
"pocketmine.command.unban",
18+
"pocketmine.command.unban.player",
19+
"pocketmine.command.unban.ip",
20+
"pocketmine.command.op",
21+
"pocketmine.command.op.give",
22+
"pocketmine.command.op.take",
23+
"pocketmine.command.save",
24+
"pocketmine.command.save.enable",
25+
"pocketmine.command.save.disable",
26+
"pocketmine.command.save.perform",
27+
"pocketmine.command.time",
28+
"pocketmine.command.time.add",
29+
"pocketmine.command.time.set",
30+
"pocketmine.command.time.start",
31+
"pocketmine.command.time.stop",
32+
"pocketmine.command.time.query",
33+
"pocketmine.command.kill",
34+
"pocketmine.command.kill.self",
35+
"pocketmine.command.kill.other",
36+
"pocketmine.command.me",
37+
"pocketmine.command.tell",
38+
"pocketmine.command.say",
39+
"pocketmine.command.give",
40+
"pocketmine.command.effect",
41+
"pocketmine.command.enchant",
42+
"pocketmine.command.particle",
43+
"pocketmine.command.teleport",
44+
"pocketmine.command.kick",
45+
"pocketmine.command.stop",
46+
"pocketmine.command.list",
47+
"pocketmine.command.help",
48+
"pocketmine.command.plugins",
49+
"pocketmine.command.reload",
50+
"pocketmine.command.version",
51+
"pocketmine.command.gamemode",
52+
"pocketmine.command.defaultgamemode",
53+
"pocketmine.command.seed",
54+
"pocketmine.command.status",
55+
"pocketmine.command.gc",
56+
"pocketmine.command.dumpmemory",
57+
"pocketmine.command.timings",
58+
"pocketmine.command.spawnpoint",
59+
"pocketmine.command.setworldspawn"
60+
]

0 commit comments

Comments
 (0)