]> git.mxchange.org Git - friendica.git/blobdiff - mod/dfrn_request.php
collapse posts by same author (but not you).
[friendica.git] / mod / dfrn_request.php
index 844fbbf6d01bc0e6318ed8c69c394ff66a1b184c..3cd8473cf314120f12f421dc2d874d0983fc2cd1 100644 (file)
@@ -123,9 +123,9 @@ function dfrn_request_post(&$a) {
                                                        notice( t('Warning: profile location has no profile photo.') . EOL );
                                                $invalid = validate_dfrn($parms);               
                                                if($invalid) {
-                                                       notice( $invalid . t(' required parameter') 
-                                                               . (($invalid == 1) ? t(" was ") : t("s were ") )
-                                                               . t("not found at the given location.") . EOL ) ;
+                                                       notice( sprintf( tt("%d required parameter was not found at the given location",
+                                                                                               "%d required parameters were not found at the given location",
+                                                                                               $invalid), $invalid) . EOL );
                                                        return;
                                                }
                                        }
@@ -238,13 +238,36 @@ function dfrn_request_post(&$a) {
                                intval($uid)
                        );
                        if(count($r) > $maxreq) {
-                               notice( $a->profile['name'] . t(' has received too many connection requests today.') . EOL);
+                               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);
                                return;
                        } 
                }
 
+               /**
+                *
+                * Cleanup old introductions that remain blocked. 
+                * Also remove the contact record, but only if there is no existing relationship
+                *
+                */
+
+               $r = q("SELECT `intro`.*, `intro`.`id` AS `iid`, `contact`.`id` AS `cid`, `contact`.`rel` 
+                       FROM `intro` LEFT JOIN `contact` on `intro`.`contact-id` = `contact`.`id`
+                       WHERE `intro`.`blocked` = 1 AND `contact`.`self` = 0 AND `intro`.`datetime` < UTC_TIMESTAMP() - INTERVAL 30 MINUTE ");
+               if(count($r)) {
+                       foreach($r as $rr) {
+                               if(! $rr['rel']) {
+                                       q("DELETE FROM `contact` WHERE `id` = %d LIMIT 1",
+                                               intval($rr['cid'])
+                                       );
+                               }
+                               q("DELETE FROM `intro` WHERE `id` = %d LIMIT 1",
+                                       intval($rr['iid'])
+                               );
+                       }
+               }
+
                $url = trim($_POST['dfrn_url']);
                if(! strlen($url)) {
                        notice( t("Invalid locator") . EOL );
@@ -283,7 +306,7 @@ function dfrn_request_post(&$a) {
                                        return;
                                }
                                elseif($ret[0]['rel'] == REL_BUD) {
-                                       notice( t('Apparently you are already friends with .') . $a->profile['name'] . EOL);
+                                       notice( sprintf( t('Apparently you are already friends with %s.'), $a->profile['name']) . EOL);
                                        return;
                                }
                                else {
@@ -331,9 +354,9 @@ function dfrn_request_post(&$a) {
                                                notice( t('Warning: profile location has no profile photo.') . EOL );
                                        $invalid = validate_dfrn($parms);               
                                        if($invalid) {
-                                               notice( $invalid . t(' required parameter') 
-                                                       . (($invalid == 1) ? t(" was ") : t("s were ") )
-                                                       . t("not found at the given location.") . EOL ) ;
+                                               notice( sprintf( tt("%d required parameter was not found at the given location",
+                                                                                       "%d required parameters were not found at the given location",
+                                                                                       $invalid), $invalid) . EOL );
        
                                                return;
                                        }
@@ -452,6 +475,12 @@ function dfrn_request_content(&$a) {
 
                if(! local_user()) {
                        notice( t("Please login to confirm introduction.") . EOL );
+
+                       /* setup the return URL to come back to this page if they use openid */
+
+                       $stripped = str_replace('q=','',$a->query_string);
+                       $_SESSION['return_url'] = trim($stripped,'/');
+
                        return login();
                }
 
@@ -511,7 +540,7 @@ function dfrn_request_content(&$a) {
                                                '$sitename' => $a->config['sitename']
                                        ));
                                        $res = mail($r[0]['email'], 
-                                               t("Introduction received at ") . $a->config['sitename'],
+                                           t("Introduction received at ") . $a->config['sitename'],
                                                $email,
                                                'From: ' . t('Administrator') . '@' . $_SERVER['SERVER_NAME'] );
                                        // This is a redundant notification - no point throwing errors if it fails.
@@ -561,8 +590,12 @@ function dfrn_request_content(&$a) {
                                $myaddr = $a->user['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3 );
                        }
                }
-               else { 
-                       $myaddr = ((x($_GET,'address')) ? urldecode($_GET['address']) : '');
+               elseif(x($_GET,'addr')) {
+                       $myaddr = hex2bin($_GET['addr']);
+               }
+               else {
+                       /* $_GET variables are already urldecoded */ 
+                       $myaddr = ((x($_GET,'address')) ? $_GET['address'] : '');
                }
 
                /**