diff --git a/mod/contacts.php b/mod/contacts.php index 54e9b5b644..c26a1b57b6 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -1,7 +1,9 @@ page['aside'] = ''; } + $contact_id = null; $contact = null; if ((($a->argc == 2) && intval($a->argv[1])) || (($a->argc == 3) && intval($a->argv[1]) && ($a->argv[2] == "posts"))) { $contact_id = intval($a->argv[1]); @@ -164,11 +167,7 @@ function contacts_post(App $a) return; } - $orig_record = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", - intval($contact_id), - intval(local_user()) - ); - if (!DBM::is_result($orig_record)) { + if (!DBM::exists('contact', ['id' => $contact_id, 'uid' => local_user()])) { notice(t('Could not access contact record.') . EOL); goaway('contacts'); return; // NOTREACHED @@ -178,11 +177,7 @@ function contacts_post(App $a) $profile_id = intval($_POST['profile-assign']); if ($profile_id) { - $r = q("SELECT `id` FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1", - intval($profile_id), - intval(local_user()) - ); - if (!DBM::is_result($r)) { + if (!DBM::exists('profile', ['id' => $profile_id, 'uid' => local_user()])) { notice(t('Could not locate selected profile.') . EOL); return; } @@ -229,6 +224,7 @@ function contacts_post(App $a) return; } + /* contact actions */ function _contact_update($contact_id) @@ -764,7 +760,6 @@ function contacts_content(App $a) $total = 0; $searching = false; $search_hdr = null; - $search_txt = ''; if ($search) { $searching = true; $search_hdr = $search; diff --git a/mod/credits.php b/mod/credits.php index e0e834388f..a501dee1f0 100644 --- a/mod/credits.php +++ b/mod/credits.php @@ -5,19 +5,17 @@ * (only contributors to the git repositories for friendica core and the * addons repository will be listed though ATM) */ - use Friendica\App; -function credits_content(App $a) { +function credits_content() +{ /* fill the page with credits */ - $f = fopen('util/credits.txt', 'r'); - $names = fread($f, filesize('util/credits.txt')); - $arr = explode("\n", htmlspecialchars($names)); - fclose($f); + $credits_string = file_get_contents('util/credits.txt'); + $names = explode("\n", htmlspecialchars($credits_string)); $tpl = get_markup_template('credits.tpl'); - return replace_macros($tpl, array( + return replace_macros($tpl, [ '$title' => t('Credits'), '$thanks' => t('Friendica is a community project, that would not be possible without the help of many people. Here is a list of those who have contributed to the code or the translation of Friendica. Thank you all!'), - '$names' => $arr, - )); + '$names' => $names, + ]); } diff --git a/mod/crepair.php b/mod/crepair.php index 12bfc302f7..94d161dc54 100644 --- a/mod/crepair.php +++ b/mod/crepair.php @@ -16,26 +16,17 @@ function crepair_init(App $a) return; } - $contact_id = 0; - + $contact = null; if (($a->argc == 2) && intval($a->argv[1])) { - $contact_id = intval($a->argv[1]); - $r = q("SELECT * FROM `contact` WHERE `uid` = %d and `id` = %d LIMIT 1", - intval(local_user()), - intval($contact_id) - ); - if (!DBM::is_result($r)) { - $contact_id = 0; - } + $contact = dba::selectFirst('contact', [], ['uid' => local_user(), 'id' => $a->argv[1]]); } if (!x($a->page, 'aside')) { $a->page['aside'] = ''; } - if ($contact_id) { - $a->data['contact'] = $r[0]; - $contact = $r[0]; + if (DBM::is_result($contact)) { + $a->data['contact'] = $contact; profile_load($a, "", 0, Contact::getDetailsByURL($contact["url"])); } } @@ -48,19 +39,15 @@ function crepair_post(App $a) $cid = (($a->argc > 1) ? intval($a->argv[1]) : 0); + $contact = null; if ($cid) { - $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", - intval($cid), - intval(local_user()) - ); + $contact = dba::selectFirst('contact', [], ['id' => $cid, 'uid' => local_user()]); } - if (!DBM::is_result($r)) { + if (!DBM::is_result($contact)) { return; } - $contact = $r[0]; - $name = defaults($_POST, 'name' , $contact['name']); $nick = defaults($_POST, 'nick' , ''); $url = defaults($_POST, 'url' , ''); @@ -113,20 +100,16 @@ function crepair_content(App $a) $cid = (($a->argc > 1) ? intval($a->argv[1]) : 0); + $contact = null; if ($cid) { - $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", - intval($cid), - intval(local_user()) - ); + $contact = dba::selectFirst('contact', [], ['id' => $cid, 'uid' => local_user()]); } - if (!DBM::is_result($r)) { + if (!DBM::is_result($contact)) { notice(t('Contact not found.') . EOL); return; } - $contact = $r[0]; - $warning = t('WARNING: This is highly advanced and if you enter incorrect information your communications with this contact may stop working.'); $info = t('Please use your browser \'Back\' button now if you are uncertain what to do on this page.');