X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Ffsuggest.php;h=58bb11670070bbf22ceeee11fa1ede56c97b766c;hb=41663c7592abe55a958632c3a48265e0a8544d2b;hp=efaf100efcaa1bf3b9535d4343bcfcf4265b8988;hpb=02cd652c130af27f3df8f4f9ef43d68eaa590d8c;p=friendica.git diff --git a/mod/fsuggest.php b/mod/fsuggest.php index efaf100efc..58bb116700 100644 --- a/mod/fsuggest.php +++ b/mod/fsuggest.php @@ -1,10 +1,18 @@ argv[1]); - $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", - intval($contact_id), - intval(local_user()) - ); - if (! dbm::is_result($r)) { - notice( t('Contact not found.') . EOL); + $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($_POST['note'])); + $note = Strings::escapeHtml(trim(defaults($_POST, 'note', ''))); - if($new_contact) { + if ($new_contact) { $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($new_contact), intval(local_user()) ); - if (dbm::is_result($r)) { - - $x = q("INSERT INTO `fsuggest` ( `uid`,`cid`,`name`,`url`,`request`,`photo`,`note`,`created`) + if (DBA::isResult($r)) { + 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), - dbesc($r[0]['name']), - dbesc($r[0]['url']), - dbesc($r[0]['request']), - dbesc($r[0]['photo']), - dbesc($hash), - dbesc(datetime_convert()) + DBA::escape($contact['name']), + DBA::escape($contact['url']), + DBA::escape($contact['request']), + DBA::escape($contact['photo']), + DBA::escape($hash), + DBA::escape(DateTimeFormat::utcNow()) ); $r = q("SELECT `id` FROM `fsuggest` WHERE `note` = '%s' AND `uid` = %d LIMIT 1", - dbesc($hash), + DBA::escape($hash), intval(local_user()) ); - if (dbm::is_result($r)) { - $fsuggest_id = $r[0]['id']; + if (DBA::isResult($r)) { + $fsuggest_id = $contact['id']; q("UPDATE `fsuggest` SET `note` = '%s' WHERE `id` = %d AND `uid` = %d", - dbesc($note), + DBA::escape($note), intval($fsuggest_id), intval(local_user()) ); - Worker::add(PRIORITY_HIGH, 'notifier', 'suggest', $fsuggest_id); + Worker::add(PRIORITY_HIGH, 'Notifier', 'suggest', $fsuggest_id); } - info( t('Friend suggestion sent.') . EOL); + info(L10n::t('Friend suggestion sent.') . EOL); } - } - - } - - -function fsuggest_content(App $a) { - - require_once('include/acl_selectors.php'); - +function fsuggest_content(App $a) +{ if (! local_user()) { - notice( t('Permission denied.') . EOL); + notice(L10n::t('Permission denied.') . EOL); return; } - if($a->argc != 2) + if ($a->argc != 2) { return; + } $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 (! dbm::is_result($r)) { - notice( t('Contact not found.') . EOL); + $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 = '