summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2019-08-15 20:23:45 +0300
committerAndrew Dolgov <[email protected]>2019-08-15 20:23:45 +0300
commit10c63ed58240c3e652b931be9a880026c465bb50 (patch)
tree1004ccd27896ecd4602b16dc1deeaec2e1a4705d
parente46ed1ff975aec5b6f2bc7b17abe9d3b5d243028 (diff)
pluginhost: add helper methods to get private/public pluginmethod endpoint URLs
-rwxr-xr-xclasses/pluginhost.php30
-rw-r--r--plugins/af_proxy_http/init.php3
2 files changed, 31 insertions, 2 deletions
diff --git a/classes/pluginhost.php b/classes/pluginhost.php
index 4d5b3252c..4cc85f044 100755
--- a/classes/pluginhost.php
+++ b/classes/pluginhost.php
@@ -491,4 +491,34 @@ class PluginHost {
function get_owner_uid() {
return $this->owner_uid;
}
+
+ // handled by classes/pluginhandler.php, requires valid session
+ function get_method_url($sender, $method, $params) {
+ return get_self_url_prefix() . "/backend.php?" .
+ http_build_query(
+ array_merge(
+ [
+ "op" => "pluginhandler",
+ "plugin" => strtolower(get_class($sender)),
+ "pmethod" => $method
+ ],
+ $params));
+ }
+
+ // WARNING: endpoint in public.php, exposed to unauthenticated users
+ function get_public_method_url($sender, $method, $params) {
+ if ($sender->is_public_method($method)) {
+ return get_self_url_prefix() . "/public.php?" .
+ http_build_query(
+ array_merge(
+ [
+ "op" => "pluginhandler",
+ "plugin" => strtolower(get_class($sender)),
+ "pmethod" => $method
+ ],
+ $params));
+ } else {
+ user_error("get_public_method_url: requested method '$method' of '" . get_class($sender) . "' is private.");
+ }
+ }
}
diff --git a/plugins/af_proxy_http/init.php b/plugins/af_proxy_http/init.php
index 421e04d1f..80100160d 100644
--- a/plugins/af_proxy_http/init.php
+++ b/plugins/af_proxy_http/init.php
@@ -141,8 +141,7 @@ class Af_Proxy_Http extends Plugin {
}
}
- return get_self_url_prefix() . "/public.php?op=pluginhandler&plugin=af_proxy_http&pmethod=imgproxy&url=" .
- urlencode($url);
+ return $this->host->get_public_method_url($this, "imgproxy", ["url" => $url]);
}
}
}