]> git.mxchange.org Git - friendica.git/blobdiff - mod/dirfind.php
Docs: add a note on adding `use` on theme.php
[friendica.git] / mod / dirfind.php
index 52e7c2aa02b267225171f38e0405f7688490e098..14ceb6daee365077e1366060e10cd9c1c0f9102a 100644 (file)
@@ -114,28 +114,22 @@ function dirfind_content(App $a, $prefix = "") {
 
                        /// @TODO These 2 SELECTs are not checked on validity with DBM::is_result()
                        $count = q("SELECT count(*) AS `total` FROM `gcontact`
-                                       LEFT JOIN `contact` ON `contact`.`nurl` = `gcontact`.`nurl` AND `contact`.`uid` = 0
-                                       WHERE NOT `gcontact`.`hide` AND `gcontact`.`network` IN ('%s', '%s', '%s') AND
-                                               ((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR
-                                               (`gcontact`.`updated` >= `gcontact`.`last_failure`)) AND
-                                               (`gcontact`.`url` LIKE '%s' OR `gcontact`.`name` LIKE '%s' OR
-                                               `gcontact`.`location` LIKE '%s' OR `gcontact`.`addr` LIKE '%s' OR
-                                               `gcontact`.`about` LIKE '%s' OR `gcontact`.`keywords` LIKE '%s') $extra_sql",
+                                       WHERE NOT `hide` AND `network` IN ('%s', '%s', '%s') AND
+                                               ((`last_contact` >= `last_failure`) OR (`updated` >= `last_failure`)) AND
+                                               (`url` LIKE '%s' OR `name` LIKE '%s' OR `location` LIKE '%s' OR
+                                               `addr` LIKE '%s' OR `about` LIKE '%s' OR `keywords` LIKE '%s') $extra_sql",
                                        dbesc(NETWORK_DFRN), dbesc($ostatus), dbesc($diaspora),
                                        dbesc(escape_tags($search2)), dbesc(escape_tags($search2)), dbesc(escape_tags($search2)),
                                        dbesc(escape_tags($search2)), dbesc(escape_tags($search2)), dbesc(escape_tags($search2)));
 
-                       $results = q("SELECT `gcontact`.`nurl`
+                       $results = q("SELECT `nurl`
                                        FROM `gcontact`
-                                       LEFT JOIN `contact` ON `contact`.`nurl` = `gcontact`.`nurl` AND `contact`.`uid` = 0
-                                       WHERE NOT `gcontact`.`hide` AND `gcontact`.`network` IN ('%s', '%s', '%s') AND
-                                               ((`gcontact`.`last_contact` >= `gcontact`.`last_failure`) OR
-                                               (`gcontact`.`updated` >= `gcontact`.`last_failure`)) AND
-                                               (`gcontact`.`url` LIKE '%s' OR `gcontact`.`name` LIKE '%s' OR
-                                               `gcontact`.`location` LIKE '%s' OR `gcontact`.`addr` LIKE '%s' OR
-                                               `gcontact`.`about` LIKE '%s' OR `gcontact`.`keywords` LIKE '%s') $extra_sql
-                                               GROUP BY `gcontact`.`nurl`
-                                               ORDER BY `gcontact`.`updated` DESC LIMIT %d, %d",
+                                       WHERE NOT `hide` AND `network` IN ('%s', '%s', '%s') AND
+                                               ((`last_contact` >= `last_failure`) OR (`updated` >= `last_failure`)) AND
+                                               (`url` LIKE '%s' OR `name` LIKE '%s' OR `location` LIKE '%s' OR
+                                               `addr` LIKE '%s' OR `about` LIKE '%s' OR `keywords` LIKE '%s') $extra_sql
+                                               GROUP BY `nurl`
+                                               ORDER BY `updated` DESC LIMIT %d, %d",
                                        dbesc(NETWORK_DFRN), dbesc($ostatus), dbesc($diaspora),
                                        dbesc(escape_tags($search2)), dbesc(escape_tags($search2)), dbesc(escape_tags($search2)),
                                        dbesc(escape_tags($search2)), dbesc(escape_tags($search2)), dbesc(escape_tags($search2)),
@@ -149,10 +143,17 @@ function dirfind_content(App $a, $prefix = "") {
                                        continue;
                                }
 
+                               $urlparts = parse_url($result["nurl"]);
+
+                               // Ignore results that look strange.
+                               // For historic reasons the gcontact table does contain some garbage.
+                               if (!empty($urlparts['query']) || !empty($urlparts['fragment'])) {
+                                       continue;
+                               }
+
                                $result = Contact::getDetailsByURL($result["nurl"], local_user());
 
                                if ($result["name"] == "") {
-                                       $urlparts = parse_url($result["nurl"]);
                                        $result["name"] = end(explode("/", $urlparts["path"]));
                                }
 
@@ -222,7 +223,7 @@ function dirfind_content(App $a, $prefix = "") {
 
                                $entry = [
                                        'alt_text' => $alt_text,
-                                       'url' => Profile::zrl($jj->url),
+                                       'url' => Profile::magicLink($jj->url),
                                        'itemurl' => $itemurl,
                                        'name' => htmlentities($jj->name),
                                        'thumb' => proxy_url($jj->photo, false, PROXY_SIZE_THUMB),