]> git.mxchange.org Git - friendica.git/commitdiff
Do a redirect when the post doesn't come from our system but we know where it comes...
authorMichael Vogel <icarus@dabo.de>
Thu, 30 Jun 2016 06:55:26 +0000 (08:55 +0200)
committerMichael Vogel <icarus@dabo.de>
Thu, 30 Jun 2016 06:55:26 +0000 (08:55 +0200)
mod/fetch.php
mod/p.php

index 70766e8e5e7c56b01caed6dd3b8ae0747e7dadff..f0838af507e0433115e4aa2112d19ad357df26fc 100644 (file)
@@ -20,6 +20,20 @@ function fetch_init($a){
                        FROM `item` WHERE `wall` AND NOT `private` AND `guid` = '%s' AND `network` IN ('%s', '%s') AND `id` = `parent` LIMIT 1",
                dbesc($guid), NETWORK_DFRN, NETWORK_DIASPORA);
        if (!$item) {
+               $r = q("SELECT `author-link`
+                       FROM `item` WHERE `uid` = 0 AND `guid` = '%s' AND `network` IN ('%s', '%s') AND `id` = `parent` LIMIT 1",
+                       dbesc($guid), NETWORK_DFRN, NETWORK_DIASPORA);
+               if ($r) {
+                       $parts = parse_url($r[0]["author-link"]);
+                       $host = $parts["scheme"]."://".$parts["host"];
+
+                       $location = $host."/fetch/".$a->argv[1]."/".$guid;
+
+                       header("HTTP/1.1 301 Moved Permanently");
+                       header("Location:".$location);
+                       killme();
+               }
+
                header($_SERVER["SERVER_PROTOCOL"].' 404 '.t('Not Found'));
                killme();
        }
index 80333ef21ee8f622243aac4d93aa0f8605bda4a8..df904372add3165ecc3315acd67927337378865a 100644 (file)
--- a/mod/p.php
+++ b/mod/p.php
@@ -24,6 +24,20 @@ function p_init($a){
                        FROM `item` WHERE `wall` AND NOT `private` AND `guid` = '%s' AND `network` IN ('%s', '%s') AND `id` = `parent` LIMIT 1",
                dbesc($guid), NETWORK_DFRN, NETWORK_DIASPORA);
        if (!$item) {
+               $r = q("SELECT `author-link`
+                       FROM `item` WHERE `uid` = 0 AND `guid` = '%s' AND `network` IN ('%s', '%s') AND `id` = `parent` LIMIT 1",
+                       dbesc($guid), NETWORK_DFRN, NETWORK_DIASPORA);
+               if ($r) {
+                       $parts = parse_url($r[0]["author-link"]);
+                       $host = $parts["scheme"]."://".$parts["host"];
+
+                       $location = $host."/p/".$guid.".xml";
+
+                       header("HTTP/1.1 301 Moved Permanently");
+                       header("Location:".$location);
+                       killme();
+               }
+
                header($_SERVER["SERVER_PROTOCOL"].' 404 '.t('Not Found'));
                killme();
        }