createSpamCheckTable();if (isset($_POST['DMDtask']) && is_array($_POST['DMDtask'])) :
// IE has a stupid bug: http://www.peterbe.com/plog/button-tag-in-IE.
// Here we work around it 🙁
$_POST['DMDtask'] = key($_POST['DMDtask']);
elseif (empty($_POST['DMDtask'])) :
$_POST['DMDtask'] = '';
endif;$errors = [];
$response = '';
$DMDgid = isset($_settings['group_id']) ? $_settings['group_id']['value'] : GroupId::SUBSCRIBERS;if ($_SERVER['REQUEST_METHOD'] === 'GET' && isset($_params['e']) && $_params['e'] === 'confirm') :
$_POST['DMDtask'] = 'confirm';
endif;switch ($_POST['DMDtask']) :
case 'subscribe':
unset($_POST['id'], $_POST['create_date']);
if (isset($_POST['submitCheck']) &&
!empty($_POST['submitCheck'])
) :
$errors[] = "You don't seem to be human!";
endif;$checkErrors = DMD::checkRecipient(
$_POST,
'insert',
$DMDcid,
$pluginLang,
RecipientChecker::CHECK_REQUIRED_FORM_FIELDS
);
$errors = array_merge($errors, $translateValidationErrors->getTranslatedErrors($checkErrors));// Make sure forward_id and from_name settings are present:
$sql = sprintf(
'SELECT /* dmdelivery_gui plugins-v2/subscribe.php */ SQL_NO_CACHE forward_id,
from_name
FROM mailing
WHERE id = %d',
$_settings['confirm_mailing_id']['value']
);$row = [];
$cur = $db->Query($sql)
or trigger_error("Query $sql failed: " . $db->Error(), E_USER_ERROR);if (! $db->EndOfResult($cur)) {
$db->FetchResultAssoc($cur, $row, 0);
}
$db->FreeResult($cur);if (!$row['forward_id'] || !$row['from_name']) {
$errors[] = sprintf(
'This plugin is not configured properly. The owner of this form should fix this.
The sender address and/or from name are missing for plugin mailing %s.', $pName ); }// Make sure no spamming is going on: $nrSpamCheckRecords = $spamCheck->nrOfRecordsInLast12Hours(new CampaignId($DMDcid), $pName, PH::getRemoteAddr());if ($nrSpamCheckRecords >= 50) { $errors[] = DMD::pluginWord( 1048 /* In order to prevent abuse of this subscribe procedure, you have to wait a few hours before you can subscribe again. */ ); }if (empty($errors)) : // // Valid data entered, try to add recipient: //// Add recipient to DB, not to group, no overwrite: $recipient = DMD::addRecipient( $DMDcid, null, $_POST, $pName, null, $DMDmid, $pluginLang, RecipientStorer::OVERWRITE_NONE, false ); $DMDrid = $recipient['DMDrid']; if ($recipient['isDuplicate'] && array_key_exists(GroupId::SPAMCOMPLAINT, DMD::getRecipientGroups($DMDcid, $DMDrid)) ) : // If recipient filed a spam complaint in the past, he cannot re-subscribe! $errors[] = DMD::pluginWord(1049 /* Spam-complainers cannot re-subscribe */); else : // Create new MIDRID, as it is used in pluginVars function: $params = ['c' => $DMDcid, 'r' => $DMDrid]; if ($DMDmid) : $params['m'] = $DMDmid; endif; $MIDRID = DMD::DMurlencode($params);if (DMD::recipientAcceptsMail($DMDcid, $DMDrid)) : // Edit data hyperlink: $response = sprintf( '
';
print '';
elseif (!empty($response)) :
print $response;
else :
?>The sender address and/or from name are missing for plugin mailing %s.', $pName ); }// Make sure no spamming is going on: $nrSpamCheckRecords = $spamCheck->nrOfRecordsInLast12Hours(new CampaignId($DMDcid), $pName, PH::getRemoteAddr());if ($nrSpamCheckRecords >= 50) { $errors[] = DMD::pluginWord( 1048 /* In order to prevent abuse of this subscribe procedure, you have to wait a few hours before you can subscribe again. */ ); }if (empty($errors)) : // // Valid data entered, try to add recipient: //// Add recipient to DB, not to group, no overwrite: $recipient = DMD::addRecipient( $DMDcid, null, $_POST, $pName, null, $DMDmid, $pluginLang, RecipientStorer::OVERWRITE_NONE, false ); $DMDrid = $recipient['DMDrid']; if ($recipient['isDuplicate'] && array_key_exists(GroupId::SPAMCOMPLAINT, DMD::getRecipientGroups($DMDcid, $DMDrid)) ) : // If recipient filed a spam complaint in the past, he cannot re-subscribe! $errors[] = DMD::pluginWord(1049 /* Spam-complainers cannot re-subscribe */); else : // Create new MIDRID, as it is used in pluginVars function: $params = ['c' => $DMDcid, 'r' => $DMDrid]; if ($DMDmid) : $params['m'] = $DMDmid; endif; $MIDRID = DMD::DMurlencode($params);if (DMD::recipientAcceptsMail($DMDcid, $DMDrid)) : // Edit data hyperlink: $response = sprintf( '
%s
', DMD::pluginWord( 1052 /* You're a member already. Click to update your personal info */, '/x/plugin/' . htmlspecialchars(DMD::pluginVars('edit_data_request', $pluginLang, false)) ) ); else : // Make recipient a member of the Subscribers group: DMD::addRecipientToGroups($DMDcid, $DMDrid, GroupId::SUBSCRIBERS);if ($recipient['isDuplicate']) : // Update recipient data now (overwrite): $recipient = DMD::addRecipient( $DMDcid, null, $_POST, $pName, $DMDrid, $DMDmid, $pluginLang, RecipientStorer::OVERWRITE_REPLACE_ALL, false ); else : DMD::logRcptAction($DMDcid, $DMDrid, 20, 'gid:' . GroupId::SUBSCRIBERS . " Plugin: {$pName}"); endif;DMD::addToEventBus(new ContactOptIned($DMDcid, $DMDrid, new \DateTime()));$DMDmid = $_settings['welcome_mailing_id']['value']; if ($DMDmid == -1) { list($DMDmid, $DMDsid) = DMD::getLastSentMailing($DMDcid, $pluginLang); } if ($DMDmid) { DMD::sendPluginMailing($DMDcid, $DMDmid, $DMDrid, $pName, $error); }$response = sprintf( '%s
';
$response .= '' . DMD::pluginWord(1056 /* Your subscription has been confirmed */) . '';
$response .= sprintf(
'
%s',
DMD::pluginWord(
1057 /* If info is incorrect, click link to change it */,
'/x/plugin/' . htmlspecialchars(DMD::pluginVars('edit_data', $pluginLang, false))
)
);
$response .= '
'; $response .= '' . DMD::pluginWord(1056 /* Your subscription has been confirmed */) . ''; $response .= '
'; endif;break; endswitch;?>= DMD::pluginWord(1050) /* Fill out the form below to subscribe to our mailing */ ?>
= DMD::pluginWord(1006) /* red fields are required */ ?>
= DMD::getRecipientForm( getTableInfoSelection(DMD::getTableInfo($rcptTable, $pluginLang, true)), $pluginLang, 'insert', isset($fieldRowLayout) ? $fieldRowLayout : 'fieldset', $_GET ); ?>
Please don't insert text in the box below!