]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #5905 from nupplaphil/move_global_functions
authorHypolite Petovan <hypolite@mrpetovan.com>
Sat, 13 Oct 2018 23:46:57 +0000 (19:46 -0400)
committerGitHub <noreply@github.com>
Sat, 13 Oct 2018 23:46:57 +0000 (19:46 -0400)
Move global functions

mod/acctlink.php [deleted file]
src/Module/Acctlink.php [new file with mode: 0644]
src/Util/JsonLD.php

diff --git a/mod/acctlink.php b/mod/acctlink.php
deleted file mode 100644 (file)
index fb8cfd4..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-<?php
-
-use Friendica\App;
-use Friendica\Network\Probe;
-
-function acctlink_init()
-{
-       if (x($_GET, 'addr')) {
-               $addr = trim($_GET['addr']);
-               $res = Probe::uri($addr);
-               if ($res['url']) {
-                       goaway($res['url']);
-                       killme();
-               }
-       }
-}
diff --git a/src/Module/Acctlink.php b/src/Module/Acctlink.php
new file mode 100644 (file)
index 0000000..f149052
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+
+namespace Friendica\Module;
+
+use Friendica\BaseModule;
+use Friendica\Network\Probe;
+
+/**
+ * Redirects to another URL based on the parameter 'addr'
+ */
+class Acctlink extends BaseModule
+{
+       public static function content()
+       {
+               $addr = defaults($_REQUEST, 'addr', false);
+
+               if ($addr) {
+                       $url = defaults(Probe::uri($addr), 'url', false);
+
+                       if ($url) {
+                               goaway($url);
+                               exit();
+                       }
+               }
+       }
+}
index cf23276d7529a8c8e3be0f98162e72bcde9d3733..5380c3c542734bb613aa4238fc960d8a755ceb4a 100644 (file)
@@ -92,7 +92,14 @@ class JsonLD
 
                $jsonobj = json_decode(json_encode($json, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
 
-               $compacted = jsonld_compact($jsonobj, $context);
+
+               try {
+                       $compacted = jsonld_compact($jsonobj, $context);
+               }
+               catch (Exception $e) {
+                       $compacted = false;
+                       logger('compacting error:' . print_r($e, true), LOGGER_DEBUG);
+               }
 
                return json_decode(json_encode($compacted, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE), true);
        }