]> git.mxchange.org Git - friendica.git/blobdiff - mod/noscrape.php
Adjusted implementation to a better one (thanks to Michael Vogel)
[friendica.git] / mod / noscrape.php
index d17937ff5d39fb7b9cee7b37333902ef7a4e6bcf..a948bee4f38807530c25610bd007843899f0ce09 100644 (file)
@@ -5,8 +5,8 @@
 
 use Friendica\App;
 use Friendica\Core\System;
-use Friendica\Database\dba;
-use Friendica\Database\DBM;
+use Friendica\Database\DBA;
+use Friendica\Model\Contact;
 use Friendica\Model\Profile;
 
 function noscrape_init(App $a)
@@ -31,7 +31,7 @@ function noscrape_init(App $a)
                'guid'     => $a->profile['guid'],
                'key'      => $a->profile['pubkey'],
                'homepage' => System::baseUrl()."/profile/{$which}",
-               'comm'     => ($a->profile['account-type'] == ACCOUNT_TYPE_COMMUNITY),
+               'comm'     => ($a->profile['account-type'] == Contact::ACCOUNT_TYPE_COMMUNITY),
        ];
 
        if (!$a->profile['net-publish'] || $a->profile['hidewall']) {
@@ -45,7 +45,7 @@ function noscrape_init(App $a)
        $keywords = str_replace(['#',',',' ',',,'], ['',' ',',',','], $keywords);
        $keywords = explode(',', $keywords);
 
-       $contactPhoto = dba::selectFirst('contact', ['photo'], ['self' => true, 'uid' => $a->profile['uid']]);
+       $contactPhoto = DBA::selectFirst('contact', ['photo'], ['self' => true, 'uid' => $a->profile['uid']]);
 
        $json_info['fn'] = $a->profile['name'];
        $json_info['photo'] = $contactPhoto["photo"];
@@ -55,18 +55,18 @@ function noscrape_init(App $a)
                /// @todo What should this value tell us?
                $r = q("SELECT `gcontact`.`updated` FROM `contact` INNER JOIN `gcontact` WHERE `gcontact`.`nurl` = `contact`.`nurl` AND `self` AND `uid` = %d LIMIT 1",
                        intval($a->profile['uid']));
-               if (DBM::is_result($r)) {
+               if (DBA::isResult($r)) {
                        $json_info["updated"] =  date("c", strtotime($r[0]['updated']));
                }
 
                $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0 AND `hidden` = 0 AND `archive` = 0
                                AND `network` IN ('%s', '%s', '%s', '')",
                        intval($a->profile['uid']),
-                       dbesc(NETWORK_DFRN),
-                       dbesc(NETWORK_DIASPORA),
-                       dbesc(NETWORK_OSTATUS)
+                       DBA::escape(NETWORK_DFRN),
+                       DBA::escape(NETWORK_DIASPORA),
+                       DBA::escape(NETWORK_OSTATUS)
                );
-               if (DBM::is_result($r)) {
+               if (DBA::isResult($r)) {
                        $json_info["contacts"] = intval($r[0]['total']);
                }
        }
@@ -74,14 +74,14 @@ function noscrape_init(App $a)
        // We display the last activity (post or login), reduced to year and week number
        $last_active = 0;
        $condition = ['uid' => $a->profile['uid'], 'self' => true];
-       $contact = dba::selectFirst('contact', ['last-item'], $condition);
-       if (DBM::is_result($contact)) {
+       $contact = DBA::selectFirst('contact', ['last-item'], $condition);
+       if (DBA::isResult($contact)) {
                $last_active = strtotime($contact['last-item']);
        }
 
        $condition = ['uid' => $a->profile['uid']];
-       $user = dba::selectFirst('user', ['login_date'], $condition);
-       if (DBM::is_result($user)) {
+       $user = DBA::selectFirst('user', ['login_date'], $condition);
+       if (DBA::isResult($user)) {
                if ($last_active < strtotime($user['login_date'])) {
                        $last_active = strtotime($user['login_date']);
                }