11<?php
2- // $Id: bot.inc.php,v 1.0 2022/03/04 00:00 :00 Pitqn Exp $
2+ // $Id: bot.inc.php,v 1.3 2022/03/06 13:59 :00 Pitqn Exp $
33
44/**
55* @link https://pkom.ml/?プラグイン/bot.inc.php
2323// パーミッションはplugin_bot_define_permissions関数を参照してください
2424plugin_bot_define_permissions ();
2525define ('PLUGIN_BOT_PERMISSIONS ' , array (
26- "DEFAULT " => BOT_PERMISSION_NONE ,
27- "MDhEOTQ2MjE4NjJDRjAwRjdGNzhCNDlEQTgxN0RBMzk " => BOT_PERMISSION_PAGE_READ | BOT_PERMISSION_PAGE_LIST ,
26+ "DEFAULT " => BOT_PERMISSION_DEFAULT ,
27+ "MDhEOTQ2MjE4NjJDRjAwRjdGNzhCNDlEQTgxN0RBMzk " => BOT_PERMISSION_DEFAULT | BOT_PERMISSION_PAGE_EDIT ,
2828));
2929
3030
@@ -89,9 +89,15 @@ function __construct($token) {
8989
9090 function proc () {
9191 global $ vars ;
92- if (isset ($ vars [ ' method ' ]))
93- $ _METHOD = strtoupper ($ vars [ ' method ' ]);
92+ if (isset ($ _SERVER [ ' REQUEST_METHOD ' ]))
93+ $ _METHOD = strtoupper ($ _SERVER [ ' REQUEST_METHOD ' ]);
9494
95+ if ($ _METHOD == "PUT " || $ _METHOD == "DELETE " ) {
96+ $ param = array ();
97+ parse_str (file_get_contents ('php://input ' ), $ param );
98+ $ vars = array_merge ($ vars , $ param );
99+ }
100+
95101 if ($ _GET ['api ' ] == "permission " ) {
96102 PluginBot::sendJson (array (
97103 "permission " => PLUGIN_BOT_PERMISSIONS [$ this ->token ],
@@ -198,13 +204,13 @@ function proc() {
198204
199205 if (!exist_plugin ($ name ))
200206 PluginBot::showError ("the plugin do not exist " , 500 , "NOT_EXIST_PLUGIN " );
201- if ($ vars ['type ' ] == "action " ) {
207+ if ($ vars ['plugin_type ' ] == "action " ) {
202208 if (exist_plugin_action ($ name )) {
203209 do_plugin_action ($ name );
204210 PluginBot::showError ("executed action function " , 201 , "PLUGIN_EXECUTED " );
205211 }
206212 }
207- if ($ vars ['type ' ] == "convert " ) {
213+ if ($ vars ['plugin_type ' ] == "convert " ) {
208214 if (exist_plugin_convert ($ name )) {
209215 if (isset ($ args ))
210216 do_plugin_convert ($ name , $ args );
@@ -214,7 +220,7 @@ function proc() {
214220 PluginBot::showError ("executed convert function " , 201 , "PLUGIN_EXECUTED " );
215221 }
216222 }
217- if ($ vars ['type ' ] == "inline " ) {
223+ if ($ vars ['plugin_type ' ] == "inline " ) {
218224 if (exist_plugin_inline ($ name )) {
219225 if (isset ($ args ))
220226 do_plugin_inline ($ name , $ args );
@@ -232,8 +238,10 @@ function proc() {
232238 if (BOT_PERMISSION_PLUGIN_LIST & ~PLUGIN_BOT_PERMISSIONS [$ this ->token ]) {
233239 PluginBot::showError ("bot has not permission 'BOT_PERMISSION_PLUGIN_LIST' " , 403 , "HAS_NOT_ " . "BOT_PERMISSION_PLUGIN_LIST " );
234240 }
235-
236- $ pluginlist = glob (PLUGIN_DIR . '*.inc.php ' );
241+
242+ $ pluginlist = array_map (function ($ filename ) {
243+ return substr ($ filename , 0 , -8 ); // inc.phpを取り除く
244+ }, array_map ('basename ' , glob (PLUGIN_DIR . '*.inc.php ' )));
237245 PluginBot::sendJson ($ pluginlist );
238246 }
239247
@@ -544,5 +552,9 @@ function plugin_bot_define_permissions() {
544552
545553 // すべてのパーミッション
546554 define ("BOT_PERMISSION_ALL " , BOT_PERMISSION_INFO | BOT_PERMISSION_PAGE_ALL | BOT_PERMISSION_PLUGIN_ALL | BOT_PERMISSION_ATTACH_ALL | BOT_PERMISSION_BACKUP_ALL | BOT_PERMISSION_DIFF_ALL | BOT_PERMISSION_TOTAL_ALL );
547-
555+
556+ // デフォルト用のパーミッション (書き込みと実行と検索以外はすべて)
557+ define ('BOT_PERMISSION_DEFAULT ' ,BOT_PERMISSION_INFO | BOT_PERMISSION_INFO | BOT_PERMISSION_PAGE_READ | BOT_PERMISSION_PAGE_LIST | BOT_PERMISSION_PAGE_CHECK
558+ | BOT_PERMISSION_PLUGIN_LIST | BOT_PERMISSION_PLUGIN_CHECK | BOT_PERMISSION_BACKUP_READ | BOT_PERMISSION_DIFF_READ
559+ | BOT_PERMISSION_TOTAL_ALL );
548560}
0 commit comments