X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Finvite.php;h=aea92a663a01f53d37e1b50b3747740d07f5aa8c;hb=2a5fb7b175f487b277254a76a484687f7e491e05;hp=2dbf93c590bd8e1480a18ee1485a852085a871d2;hpb=c3139fa0fd49b0b4de4568d46a6946c75ccb2a62;p=friendica.git diff --git a/mod/invite.php b/mod/invite.php index 2dbf93c590..aea92a663a 100644 --- a/mod/invite.php +++ b/mod/invite.php @@ -7,6 +7,8 @@ * */ +require_once('include/email.php'); + function invite_post(&$a) { if(! local_user()) { @@ -14,6 +16,18 @@ function invite_post(&$a) { return; } + check_form_security_token_redirectOnErr('/', 'send_invite'); + + $max_invites = intval(get_config('system','max_invites')); + if(! $max_invites) + $max_invites = 50; + + $current_invites = intval(get_pconfig(local_user(),'system','sent_invites')); + if($current_invites > $max_invites) { + notice( t('Total invitation limit exceeded.') . EOL); + return; + }; + $recips = ((x($_POST,'recipients')) ? explode("\n",$_POST['recipients']) : array()); $message = ((x($_POST,'message')) ? notags(trim($_POST['message'])) : ''); @@ -56,7 +70,7 @@ function invite_post(&$a) { else $nmessage = $message; - $res = mail($recip, sprintf( t('Please join us on Friendica'), $a->config['sitename']), + $res = mail($recip, email_header_encode( t('Please join us on Friendica'),'UTF-8'), $nmessage, "From: " . $a->user['email'] . "\n" . 'Content-type: text/plain; charset=UTF-8' . "\n" @@ -64,6 +78,12 @@ function invite_post(&$a) { if($res) { $total ++; + $current_invites ++; + set_pconfig(local_user(),'system','sent_invites',$current_invites); + if($current_invites > $max_invites) { + notice( t('Invitation limit exceeded. Please contact your site administrator.') . EOL); + return; + } } else { notice( sprintf( t('%s : Message delivery failed.'), $recip) . EOL); @@ -108,6 +128,7 @@ function invite_content(&$a) { } $o = replace_macros($tpl, array( + '$form_security_token' => get_form_security_token("send_invite"), '$invite' => t('Send invitations'), '$addr_text' => t('Enter email addresses, one per line:'), '$msg_text' => t('Your message:'),