X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Ffsuggest.php;h=58bb11670070bbf22ceeee11fa1ede56c97b766c;hb=41663c7592abe55a958632c3a48265e0a8544d2b;hp=35710bb338d0139717ed133228d3bcaf3bd53222;hpb=8821d33f73785884cfce83e7b23d3ef19cc1bc11;p=friendica.git diff --git a/mod/fsuggest.php b/mod/fsuggest.php index 35710bb338..58bb116700 100644 --- a/mod/fsuggest.php +++ b/mod/fsuggest.php @@ -9,6 +9,7 @@ use Friendica\Core\L10n; use Friendica\Core\Worker; use Friendica\Database\DBA; use Friendica\Util\DateTimeFormat; +use Friendica\Util\Strings; function fsuggest_post(App $a) { @@ -22,21 +23,17 @@ function fsuggest_post(App $a) $contact_id = intval($a->argv[1]); - $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", - intval($contact_id), - intval(local_user()) - ); - if (! DBA::isResult($r)) { + $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user()]); + if (! DBA::isResult($contact)) { notice(L10n::t('Contact not found.') . EOL); return; } - $contact = $r[0]; $new_contact = intval($_POST['suggest']); - $hash = random_string(); + $hash = Strings::getRandomHex(); - $note = escape_tags(trim(defaults($_POST, 'note', ''))); + $note = Strings::escapeHtml(trim(defaults($_POST, 'note', ''))); if ($new_contact) { $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", @@ -44,14 +41,14 @@ function fsuggest_post(App $a) intval(local_user()) ); if (DBA::isResult($r)) { - $x = q("INSERT INTO `fsuggest` ( `uid`,`cid`,`name`,`url`,`request`,`photo`,`note`,`created`) + q("INSERT INTO `fsuggest` ( `uid`,`cid`,`name`,`url`,`request`,`photo`,`note`,`created`) VALUES ( %d, %d, '%s','%s','%s','%s','%s','%s')", intval(local_user()), intval($contact_id), - DBA::escape($r[0]['name']), - DBA::escape($r[0]['url']), - DBA::escape($r[0]['request']), - DBA::escape($r[0]['photo']), + DBA::escape($contact['name']), + DBA::escape($contact['url']), + DBA::escape($contact['request']), + DBA::escape($contact['photo']), DBA::escape($hash), DBA::escape(DateTimeFormat::utcNow()) ); @@ -60,7 +57,7 @@ function fsuggest_post(App $a) intval(local_user()) ); if (DBA::isResult($r)) { - $fsuggest_id = $r[0]['id']; + $fsuggest_id = $contact['id']; q("UPDATE `fsuggest` SET `note` = '%s' WHERE `id` = %d AND `uid` = %d", DBA::escape($note), intval($fsuggest_id), @@ -87,16 +84,11 @@ function fsuggest_content(App $a) $contact_id = intval($a->argv[1]); - $r = q( - "SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", - intval($contact_id), - intval(local_user()) - ); - if (! DBA::isResult($r)) { + $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => local_user()]); + if (! DBA::isResult($contact)) { notice(L10n::t('Contact not found.') . EOL); return; } - $contact = $r[0]; $o = '