X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fdfrn_poll.php;h=85829926e154c70270e4b603453fef743b6feedf;hb=0ec44f3e8a73229c3aadea86f61b5571a701c6b7;hp=7d5418c364533b4f27c073b9e3dfe0822453bca7;hpb=d53e53cceb2823cceec36f91f39f8b1e6459a648;p=friendica.git diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php index 7d5418c364..85829926e1 100644 --- a/mod/dfrn_poll.php +++ b/mod/dfrn_poll.php @@ -3,11 +3,12 @@ /** * @file mod/dfrn_poll.php */ + use Friendica\App; use Friendica\Core\Config; use Friendica\Core\L10n; use Friendica\Core\System; -use Friendica\Database\DBM; +use Friendica\Database\DBA; use Friendica\Module\Login; use Friendica\Protocol\DFRN; use Friendica\Protocol\OStatus; @@ -99,7 +100,7 @@ function dfrn_poll_init(App $a) dbesc($a->argv[1]) ); - if (DBM::is_result($r)) { + if (DBA::is_result($r)) { $s = Network::fetchUrl($r[0]['poll'] . '?dfrn_id=' . $my_id . '&type=profile-check'); logger("dfrn_poll: old profile returns " . $s, LOGGER_DATA); @@ -119,6 +120,7 @@ function dfrn_poll_init(App $a) $_SESSION['visitor_home'] = $r[0]['url']; $_SESSION['visitor_handle'] = $r[0]['addr']; $_SESSION['visitor_visiting'] = $r[0]['uid']; + $_SESSION['my_url'] = $r[0]['url']; if (!$quiet) { info(L10n::t('%1$s welcomes %2$s', $r[0]['username'], $r[0]['name']) . EOL); } @@ -140,11 +142,11 @@ function dfrn_poll_init(App $a) if ($type === 'profile-check' && $dfrn_version < 2.2) { if ((strlen($challenge)) && (strlen($sec))) { - q("DELETE FROM `profile_check` WHERE `expire` < " . intval(time())); + DBA::delete('profile_check', ["`expire` < ?", time()]); $r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1", dbesc($sec) ); - if (!DBM::is_result($r)) { + if (!DBA::is_result($r)) { System::xmlExit(3, 'No ticket'); // NOTREACHED } @@ -157,7 +159,7 @@ function dfrn_poll_init(App $a) $c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1", intval($r[0]['cid']) ); - if (!DBM::is_result($c)) { + if (!DBA::is_result($c)) { System::xmlExit(3, 'No profile'); } @@ -205,10 +207,10 @@ function dfrn_poll_init(App $a) break; } - q("DELETE FROM `profile_check` WHERE `expire` < " . intval(time())); + DBA::delete('profile_check', ["`expire` < ?", time()]); $r = q("SELECT * FROM `profile_check` WHERE `dfrn_id` = '%s' ORDER BY `expire` DESC", dbesc($dfrn_id)); - if (DBM::is_result($r)) { + if (DBA::is_result($r)) { System::xmlExit(1); return; // NOTREACHED } @@ -232,11 +234,11 @@ function dfrn_poll_post(App $a) if (strlen($challenge) && strlen($sec)) { logger('dfrn_poll: POST: profile-check'); - q("DELETE FROM `profile_check` WHERE `expire` < " . intval(time())); + DBA::delete('profile_check', ["`expire` < ?", time()]); $r = q("SELECT * FROM `profile_check` WHERE `sec` = '%s' ORDER BY `expire` DESC LIMIT 1", dbesc($sec) ); - if (!DBM::is_result($r)) { + if (!DBA::is_result($r)) { System::xmlExit(3, 'No ticket'); // NOTREACHED } @@ -249,7 +251,7 @@ function dfrn_poll_post(App $a) $c = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1", intval($r[0]['cid']) ); - if (!DBM::is_result($c)) { + if (!DBA::is_result($c)) { System::xmlExit(3, 'No profile'); } @@ -298,18 +300,14 @@ function dfrn_poll_post(App $a) dbesc($challenge) ); - if (!DBM::is_result($r)) { + if (!DBA::is_result($r)) { killme(); } $type = $r[0]['type']; $last_update = $r[0]['last_update']; - $r = q("DELETE FROM `challenge` WHERE `dfrn-id` = '%s' AND `challenge` = '%s'", - dbesc($dfrn_id), - dbesc($challenge) - ); - + DBA::delete('challenge', ['dfrn-id' => $dfrn_id, 'challenge' => $challenge]); $sql_extra = ''; switch ($direction) { @@ -331,7 +329,7 @@ function dfrn_poll_post(App $a) } $r = q("SELECT * FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 $sql_extra LIMIT 1"); - if (!DBM::is_result($r)) { + if (!DBA::is_result($r)) { killme(); } @@ -347,7 +345,7 @@ function dfrn_poll_post(App $a) $reputation = 0; $text = ''; - if (DBM::is_result($r)) { + if (DBA::is_result($r)) { $reputation = $r[0]['rating']; $text = $r[0]['reason']; @@ -414,7 +412,7 @@ function dfrn_poll_content(App $a) $status = 0; - $r = q("DELETE FROM `challenge` WHERE `expire` < " . intval(time())); + DBA::delete('challenge', ["`expire` < ?", time()]); if ($type !== 'profile') { $r = q("INSERT INTO `challenge` ( `challenge`, `dfrn-id`, `expire` , `type`, `last_update` ) @@ -459,7 +457,7 @@ function dfrn_poll_content(App $a) AND `user`.`nickname` = '%s' $sql_extra LIMIT 1", dbesc($nickname) ); - if (DBM::is_result($r)) { + if (DBA::is_result($r)) { $challenge = ''; $encrypted_id = ''; $id_str = $my_id . '.' . mt_rand(1000, 9999); @@ -500,7 +498,7 @@ function dfrn_poll_content(App $a) ]); } - $profile = ((DBM::is_result($r) && $r[0]['nickname']) ? $r[0]['nickname'] : $nickname); + $profile = ((DBA::is_result($r) && $r[0]['nickname']) ? $r[0]['nickname'] : $nickname); switch ($destination_url) { case 'profile': @@ -539,6 +537,7 @@ function dfrn_poll_content(App $a) $_SESSION['visitor_id'] = $r[0]['id']; $_SESSION['visitor_home'] = $r[0]['url']; $_SESSION['visitor_visiting'] = $r[0]['uid']; + $_SESSION['my_url'] = $r[0]['url']; if (!$quiet) { info(L10n::t('%1$s welcomes %2$s', $r[0]['username'], $r[0]['name']) . EOL); }