]> git.mxchange.org Git - friendica.git/blobdiff - mod/dirfind.php
Adjusted implementation to a better one (thanks to Michael Vogel)
[friendica.git] / mod / dirfind.php
index dc86f03a68f4c9cee27bd6e6f5d61efd92ae5dc8..2d728f8e730f0bb4e309d783c8899ae8588260fc 100644 (file)
@@ -2,6 +2,7 @@
 /**
  * @file mod/dirfind.php
  */
+
 use Friendica\App;
 use Friendica\Content\ContactSelector;
 use Friendica\Content\Widget;
@@ -9,12 +10,13 @@ use Friendica\Core\Config;
 use Friendica\Core\L10n;
 use Friendica\Core\System;
 use Friendica\Core\Worker;
+use Friendica\Database\DBA;
 use Friendica\Model\Contact;
 use Friendica\Model\GContact;
 use Friendica\Network\Probe;
 use Friendica\Protocol\PortableContact;
 use Friendica\Util\Network;
-use Friendica\Database\DBM;
+use Friendica\Util\Proxy as ProxyUtils;
 
 require_once 'mod/contacts.php';
 
@@ -43,6 +45,8 @@ function dirfind_content(App $a, $prefix = "") {
 
        $search = $prefix.notags(trim($_REQUEST['search']));
 
+       $header = '';
+
        if (strpos($search,'@') === 0) {
                $search = substr($search,1);
                $header = L10n::t('People Search - %s', $search);
@@ -111,15 +115,15 @@ function dirfind_content(App $a, $prefix = "") {
 
                        $search2 = "%".$search."%";
 
-                       /// @TODO These 2 SELECTs are not checked on validity with DBM::is_result()
+                       /// @TODO These 2 SELECTs are not checked on validity with DBA::isResult()
                        $count = q("SELECT count(*) AS `total` FROM `gcontact`
                                        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)));
+                                       DBA::escape(NETWORK_DFRN), DBA::escape($ostatus), DBA::escape($diaspora),
+                                       DBA::escape(escape_tags($search2)), DBA::escape(escape_tags($search2)), DBA::escape(escape_tags($search2)),
+                                       DBA::escape(escape_tags($search2)), DBA::escape(escape_tags($search2)), DBA::escape(escape_tags($search2)));
 
                        $results = q("SELECT `nurl`
                                        FROM `gcontact`
@@ -129,9 +133,9 @@ function dirfind_content(App $a, $prefix = "") {
                                                `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)),
+                                       DBA::escape(NETWORK_DFRN), DBA::escape($ostatus), DBA::escape($diaspora),
+                                       DBA::escape(escape_tags($search2)), DBA::escape(escape_tags($search2)), DBA::escape(escape_tags($search2)),
+                                       DBA::escape(escape_tags($search2)), DBA::escape(escape_tags($search2)), DBA::escape(escape_tags($search2)),
                                        intval($startrec), intval($perpage));
                        $j = new stdClass();
                        $j->total = $count[0]["total"];
@@ -185,7 +189,7 @@ function dirfind_content(App $a, $prefix = "") {
                        $a->set_pager_itemspage($j->items_page);
                }
 
-               if (count($j->results)) {
+               if (!empty($j->results)) {
 
                        $id = 0;
 
@@ -201,8 +205,8 @@ function dirfind_content(App $a, $prefix = "") {
                                if ($jj->cid > 0) {
                                        $connlnk = "";
                                        $conntxt = "";
-                                       $contact = dba::selectFirst('contact', [], ['id' => $jj->cid]);
-                                       if (DBM::is_result($contact)) {
+                                       $contact = DBA::selectFirst('contact', [], ['id' => $jj->cid]);
+                                       if (DBA::isResult($contact)) {
                                                $photo_menu = Contact::photoMenu($contact);
                                                $details = _contact_detail_for_template($contact);
                                                $alt_text = $details['alt_text'];
@@ -210,7 +214,7 @@ function dirfind_content(App $a, $prefix = "") {
                                                $photo_menu = [];
                                        }
                                } else {
-                                       $connlnk = System::baseUrl().'/follow/?url='.(($jj->connect) ? $jj->connect : $jj->url);
+                                       $connlnk = System::baseUrl().'/follow/?url='.(!empty($jj->connect) ? $jj->connect : $jj->url);
                                        $conntxt = L10n::t('Connect');
                                        $photo_menu = [
                                                'profile' => [L10n::t("View Profile"), Contact::magicLink($jj->url)],
@@ -225,7 +229,7 @@ function dirfind_content(App $a, $prefix = "") {
                                        'url' => Contact::magicLink($jj->url),
                                        'itemurl' => $itemurl,
                                        'name' => htmlentities($jj->name),
-                                       'thumb' => proxy_url($jj->photo, false, PROXY_SIZE_THUMB),
+                                       'thumb' => ProxyUtils::proxifyUrl($jj->photo, false, ProxyUtils::SIZE_THUMB),
                                        'img_hover' => $jj->tags,
                                        'conntxt' => $conntxt,
                                        'connlnk' => $connlnk,