]> git.wh0rd.org - tt-rss.git/blobdiff - classes/handler/public.php
remove local file extensions and generalize some method names for cached media
[tt-rss.git] / classes / handler / public.php
index c7c86d4638bde8cab6c8e03852de9d717af4d41c..a6bc3ff6ff3efae9f4f7bb093df47c1771655a1e 100644 (file)
@@ -1046,9 +1046,12 @@ class Handler_Public extends Handler {
                <?php
        }
 
-       function cached_image() {
+       function cached_url() {
                @$hash = basename($_GET['hash']);
 
+               // we don't need an extension to find the file, hash is a complete URL
+               $hash = preg_replace("/\.[^\.]*$/", "", $hash);
+
                if ($hash) {
 
                        $filename = CACHE_DIR . '/images/' . $hash;
@@ -1086,5 +1089,37 @@ class Handler_Public extends Handler {
 
                return "tag:" . parse_url(get_self_url_prefix(), PHP_URL_HOST) . ",$timestamp:/$id";
        }
+
+       // this should be used very carefully because this endpoint is exposed to unauthenticated users
+       // plugin data is not loaded because there's no user context and owner_uid/session may or may not be available
+       // in general, don't do anything user-related in here and do not modify $_SESSION
+       public function pluginhandler() {
+               $host = new PluginHost();
+
+               $plugin = basename($_REQUEST["plugin"]);
+               $method = $_REQUEST["pmethod"];
+
+               $host->load($plugin, PluginHost::KIND_USER, 0);
+               $host->load_data();
+
+               $pclass = $host->get_plugin($plugin);
+
+               if ($pclass) {
+                       if (method_exists($pclass, $method)) {
+                               if ($pclass->is_public_method($method)) {
+                                       $pclass->$method();
+                               } else {
+                                       header("Content-Type: text/json");
+                                       print error_json(6);
+                               }
+                       } else {
+                               header("Content-Type: text/json");
+                               print error_json(13);
+                       }
+               } else {
+                       header("Content-Type: text/json");
+                       print error_json(14);
+               }
+       }
 }
-?>
+?>
\ No newline at end of file