static function checkReceiver( $receiver ) { eZTipafriendRequest::cleanup(); $ini = eZINI::instance(); $timeFrame = 1; if ( $ini->hasVariable( 'TipAFriend', 'TimeFrame' ) ) $timeFrame = $ini->variable( 'TipAFriend', 'TimeFrame' ); $time = time() - $timeFrame * 3600; $requestsPerTimeframe = 1; if ( $ini->hasVariable( 'TipAFriend', 'MaxRequestsPerTimeframe' ) ) $requestsPerTimeframe = $ini->variable( 'TipAFriend', 'MaxRequestsPerTimeframe' ); $db = eZDB::instance(); $receiver = $db->escapeString( $receiver ); $countResult = $db->arrayQuery( "SELECT count(*) as count FROM eztipafriend_request WHERE email_receiver = '$receiver' AND created > $time " ); $count = 0; if ( isset( $countResult[0]['count'] ) ) $count = $countResult[0]['count']; if ( $count >= $requestsPerTimeframe ) return false; return true; }
$mailtpl->setVariable('node_id', $NodeID); $mailtpl->setVariable('node', $node); $mailtpl->setVariable('your_name', $yourName); $mailtpl->setVariable('your_email', $yourEmail); $mailtpl->setVariable('receivers_name', $receiversName); $mailtpl->setVariable('receivers_email', $receiversEmail); $mailtpl->setVariable('comment', $comment); $mailtext = $mailtpl->fetch('design:content/tipafriendmail.tpl'); if ($mailtpl->hasVariable('content_type')) { $mail->setContentType($mailtpl->variable('content_type')); } $mail->setBody($mailtext); // mail was sent ok if (eZMailTransport::send($mail)) { $tpl->setVariable('action', 'confirm'); $request = eZTipafriendRequest::create($receiversEmail); $request->store(); // Increase tipafriend count for this node $counter = eZTipafriendCounter::create($NodeID); $counter->store(); // Prevent user from sending tipafriend mail to same user on same node again for the rest of session $sessionSentTipList = $NodeID . '|' . $receiversEmail; if ($http->hasSessionVariable('ezpContentTipafriendList')) { $sessionSentTipList = $http->sessionVariable('ezpContentTipafriendList') . ',' . $sessionSentTipList; } $http->setSessionVariable('ezpContentTipafriendList', $sessionSentTipList); } else { $tpl->setVariable('action', 'error'); } if ($http->hasPostVariable('RedirectBack') && $http->postVariable('RedirectBack') == 1) { $Module->redirectTo($node->attribute('url_alias'));