]> git.mxchange.org Git - friendica.git/commitdiff
do a better job of comparing same URLs.
authorFriendika <info@friendika.com>
Thu, 20 Jan 2011 03:51:34 +0000 (19:51 -0800)
committerFriendika <info@friendika.com>
Thu, 20 Jan 2011 03:51:34 +0000 (19:51 -0800)
boot.php
mod/display.php
mod/network.php
mod/profile.php

index d458b8647c0d6a7e7f15169c653ce1314671c262..05b33abd6ef93d1d4d3f5cea4e5e0e5d8e806065 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -2191,3 +2191,22 @@ function get_birthdays() {
 
 }}
 
+/**
+ *
+ * Compare two URLs to see if they are the same, but ignore
+ * slight but hopefully insignificant differences such as if one 
+ * is https and the other isn't, or if one is www.something and 
+ * the other isn't - and also ignore case differences.
+ *
+ * Return true if the URLs match, otherwise false.
+ *
+ */
+
+if(! function_exists('link_compare')) {
+function link_compare($a,$b) {
+       $a1 = str_replace(array('https:','//www.'), array('http:','//'), $a);
+       $b1 = str_replace(array('https:','//www.'), array('http:','//'), $b);
+       if(strcasecmp($a1,$b1) === 0)
+               return true;
+       return false;
+}}
index 0e5768838f74c3f147e3ef4a30c68985ea245244..de11ec35d65f08836f23d4a5838507fdb604f4f5 100644 (file)
@@ -202,7 +202,7 @@ function display_content(&$a) {
                                        $template = $wallwall;
                                        $commentww = 'ww';
                                        // If it is our contact, use a friendly redirect link
-                                       if(($item['owner-link'] == $item['url']) && ($item['network'] === 'dfrn')) {
+                                       if((link_compare($item['owner-link'],$item['url'])) && ($item['network'] === 'dfrn')) {
                                                $owner_url = $redirect_url;
                                                $osparkle = ' sparkle';
                                        }
@@ -211,7 +211,7 @@ function display_content(&$a) {
                                }
                        }
 
-                       $diff_author = (($item['url'] !== $item['author-link']) ? true : false);
+                       $diff_author = ((link_compare($item['url'],$item['author-link'])) ? false : true);
 
                        $profile_name   = (((strlen($item['author-name']))   && $diff_author) ? $item['author-name']   : $item['name']);
                        $profile_avatar = (((strlen($item['author-avatar'])) && $diff_author) ? $item['author-avatar'] : $item['thumb']);
index d094febc67f0c85c454888faf34f97fbfa5e6948..aa42e2f529b97aee64d02eeb0525b2d27ae940c8 100644 (file)
@@ -303,7 +303,7 @@ function network_content(&$a, $update = 0) {
                                        $template = $wallwall;
                                        $commentww = 'ww';
                                        // If it is our contact, use a friendly redirect link
-                                       if(($item['owner-link'] == $item['url']
+                                       if((link_compare($item['owner-link'],$item['url'])
                                                && ($item['network'] === 'dfrn')) {
                                                $owner_url = $redirect_url;
                                                $osparkle = ' sparkle';
@@ -350,7 +350,7 @@ function network_content(&$a, $update = 0) {
 
                        // Post was remotely authored.
 
-                       $diff_author = (($item['url'] !== $item['author-link']) ? true : false);
+                       $diff_author = ((link_compare($item['url'],$item['author-link'])) ? false : true);
 
                        $profile_name   = (((strlen($item['author-name']))   && $diff_author) ? $item['author-name']   : $item['name']);
                        $profile_avatar = (((strlen($item['author-avatar'])) && $diff_author) ? $item['author-avatar'] : $thumb);
@@ -361,7 +361,7 @@ function network_content(&$a, $update = 0) {
                        // Can we use our special contact URL for this author? 
 
                        if(strlen($item['author-link'])) {
-                               if($item['author-link'] == $item['url'] && ($item['network'] === 'dfrn') && (! $item['self'])) {
+                               if((link_compare($item['author-link'],$item['url'])) && ($item['network'] === 'dfrn') && (! $item['self'])) {
                                        $profile_link = $redirect_url;
                                        $sparkle = ' sparkle';
                                }
index bcd2b64e36c5b1b44c6920caf82795fc1f83bbc4..9363793604f2f8a6ab9463ab6cc37eef9bceb2d1 100644 (file)
@@ -297,7 +297,7 @@ function profile_content(&$a, $update = 0) {
 
                        $profile_url = $item['url'];
 
-                       // This is my profile but I'm not the author of this post/comment. If it's somebody that's a fan or mutual friend,
+                       // This is my profile page but I'm not the author of this post/comment. If it's somebody that's a fan or mutual friend,
                        // I can go directly to their profile as an authenticated guest.
 
                        if(local_user() && ($item['contact-uid'] == $_SESSION['uid']) 
@@ -314,7 +314,7 @@ function profile_content(&$a, $update = 0) {
                        // local contact info at all. In this module you should never encounter a third-party author, but we still will do
                        // the right thing if you ever do. 
 
-                       $diff_author = (($item['url'] !== $item['author-link']) ? true : false);
+                       $diff_author = ((link_compare($item['url'],$item['author-link'])) ? false : true);
 
                        $profile_name   = (((strlen($item['author-name']))   && $diff_author) ? $item['author-name']   : $item['name']);
                        $profile_avatar = (((strlen($item['author-avatar'])) && $diff_author) ? $item['author-avatar'] : $item['thumb']);