From c1a15befc55af63ab95318c160aa4e9c5bbf6517 Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 20 Sep 2016 22:18:35 +0200 Subject: [PATCH] Some improvements/fix: - fixed curly brace bug (introduced by myself) - make all SQL keywords upper-case, column and table names lower-case - used some more dbm::is_result Signed-off-by: Roland Haeder --- mod/dfrn_request.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index 4953a0c996..9b7dede2e2 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -269,7 +269,7 @@ function dfrn_request_post(&$a) { dbesc(datetime_convert('UTC','UTC','now - 24 hours')), intval($uid) ); - if(count($r) > $maxreq) { + if(dbm::is_result($r) && count($r) > $maxreq) { notice( sprintf( t('%s has received too many connection requests today.'), $a->profile['name']) . EOL); notice( t('Spam protection measures have been invoked.') . EOL); notice( t('Friends are advised to please try again in 24 hours.') . EOL); @@ -368,8 +368,7 @@ function dfrn_request_post(&$a) { $r = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", intval($uid) ); - if(! count($r)) { - + if(! dbm::is_result($r)) { notice( t('This account has not been configured for email. Request failed.') . EOL); return; } @@ -429,8 +428,8 @@ function dfrn_request_post(&$a) { $hash = random_string(); - $r = q("insert into intro ( uid, `contact-id`, knowyou, note, hash, datetime, blocked ) - values( %d , %d, %d, '%s', '%s', '%s', %d ) ", + $r = q("INSERT INTO intro ( uid, `contact-id`, knowyou, note, hash, datetime, blocked ) + VALUES( %d , %d, %d, '%s', '%s', '%s', %d ) ", intval($uid), intval($contact_id), ((x($_POST,'knowyou') && ($_POST['knowyou'] == 1)) ? 1 : 0), @@ -475,7 +474,7 @@ function dfrn_request_post(&$a) { dbesc($url) ); - if(count($ret)) { + if(dbm::is_result($ret)) { if(strlen($ret[0]['issued-id'])) { notice( t('You have already introduced yourself here.') . EOL ); return; @@ -572,7 +571,7 @@ function dfrn_request_post(&$a) { $parms['url'], $parms['issued-id'] ); - if(dbm::is_result($r)) + if(dbm::is_result($r)) { $contact_record = $r[0]; update_contact_avatar($photo, $uid, $contact_record["id"], true); } -- 2.39.5