]> git.mxchange.org Git - friendica.git/blobdiff - mod/salmon.php
Renamed functions
[friendica.git] / mod / salmon.php
index 22da151cf8e1c93f44d3478fee2c1b0e23c6e129..bd4b3773cb7a4de2a81d1618115f9f885d177226 100644 (file)
@@ -4,8 +4,9 @@
  */
 use Friendica\App;
 use Friendica\Core\PConfig;
+use Friendica\Core\Protocol;
 use Friendica\Core\System;
-use Friendica\Database\DBM;
+use Friendica\Database\DBA;
 use Friendica\Model\Contact;
 use Friendica\Protocol\OStatus;
 use Friendica\Protocol\Salmon;
@@ -25,9 +26,9 @@ function salmon_post(App $a, $xml = '') {
        $mentions   = (($a->argc > 2 && $a->argv[2] === 'mention') ? true : false);
 
        $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `account_expired` = 0 AND `account_removed` = 0 LIMIT 1",
-               dbesc($nick)
+               DBA::escape($nick)
        );
-       if (! DBM::is_result($r)) {
+       if (! DBA::isResult($r)) {
                System::httpExit(500);
        }
 
@@ -40,14 +41,14 @@ function salmon_post(App $a, $xml = '') {
        $base = null;
 
        // figure out where in the DOM tree our data is hiding
-       if($dom->provenance->data)
+       if (!empty($dom->provenance->data))
                $base = $dom->provenance;
-       elseif($dom->env->data)
+       elseif (!empty($dom->env->data))
                $base = $dom->env;
-       elseif($dom->data)
+       elseif (!empty($dom->data))
                $base = $dom;
 
-       if(! $base) {
+       if (empty($base)) {
                logger('unable to locate salmon data in xml ');
                System::httpExit(400);
        }
@@ -145,23 +146,26 @@ function salmon_post(App $a, $xml = '') {
        $r = q("SELECT * FROM `contact` WHERE `network` IN ('%s', '%s')
                                                AND (`nurl` = '%s' OR `alias` = '%s' OR `alias` = '%s')
                                                AND `uid` = %d LIMIT 1",
-               dbesc(NETWORK_OSTATUS),
-               dbesc(NETWORK_DFRN),
-               dbesc(normalise_link($author_link)),
-               dbesc($author_link),
-               dbesc(normalise_link($author_link)),
+               DBA::escape(Protocol::OSTATUS),
+               DBA::escape(Protocol::DFRN),
+               DBA::escape(normalise_link($author_link)),
+               DBA::escape($author_link),
+               DBA::escape(normalise_link($author_link)),
                intval($importer['uid'])
        );
-       if (! DBM::is_result($r)) {
+
+       if (!DBA::isResult($r)) {
                logger('Author ' . $author_link . ' unknown to user ' . $importer['uid'] . '.');
-               if(PConfig::get($importer['uid'],'system','ostatus_autofriend')) {
+
+               if (PConfig::get($importer['uid'], 'system', 'ostatus_autofriend')) {
                        $result = Contact::createFromProbe($importer['uid'], $author_link);
-                       if($result['success']) {
+
+                       if ($result['success']) {
                                $r = q("SELECT * FROM `contact` WHERE `network` = '%s' AND ( `url` = '%s' OR `alias` = '%s')
                                        AND `uid` = %d LIMIT 1",
-                                       dbesc(NETWORK_OSTATUS),
-                                       dbesc($author_link),
-                                       dbesc($author_link),
+                                       DBA::escape(Protocol::OSTATUS),
+                                       DBA::escape($author_link),
+                                       DBA::escape($author_link),
                                        intval($importer['uid'])
                                );
                        }
@@ -171,8 +175,8 @@ function salmon_post(App $a, $xml = '') {
        // Have we ignored the person?
        // If so we can not accept this post.
 
-       //if((DBM::is_result($r)) && (($r[0]['readonly']) || ($r[0]['rel'] == CONTACT_IS_FOLLOWER) || ($r[0]['blocked']))) {
-       if (DBM::is_result($r) && $r[0]['blocked']) {
+       //if((DBA::isResult($r)) && (($r[0]['readonly']) || ($r[0]['rel'] == Contact::FOLLOWER) || ($r[0]['blocked']))) {
+       if (DBA::isResult($r) && $r[0]['blocked']) {
                logger('Ignoring this author.');
                System::httpExit(202);
                // NOTREACHED
@@ -181,7 +185,7 @@ function salmon_post(App $a, $xml = '') {
        // Placeholder for hub discovery.
        $hub = '';
 
-       $contact_rec = ((DBM::is_result($r)) ? $r[0] : null);
+       $contact_rec = ((DBA::isResult($r)) ? $r[0] : null);
 
        OStatus::import($data, $importer, $contact_rec, $hub);