- // No entry found, so we need to check out the stats table as well... :)
- // We have to add that suff here, now we continue WITHOUT checking and check the text and subject against some filters
- $data['url'] = '';
- if (getConfig('allow_url_in_text') == 'Y') {
- // Test submitted text against some filters (length, URLs in text etc.)
- if ((isInStringIgnoreCase('https://', postRequestElement('text'))) || (isInStringIgnoreCase('http://', postRequestElement('text'))) || (isInStringIgnoreCase('www', postRequestElement('text')))) {
- // URL found
- $data['url'] = 'modules.php?module=login&what=order&code=' . getCode('URL_FOUND');
- } // END - if
-
- // Remove new-line and carriage-return characters
- $TEST = str_replace(array(PHP_EOL, chr(13)), array('', ''), postRequestElement('text'));
-
- // Text length within allowed length?
- if (strlen($TEST) > getConfig('max_tlength')) {
- // Text is too long!
- $data['url'] = 'modules.php?module=login&what=order&code=' . getCode('OVERLENGTH');
- } // END - if
- } // END - if
-
- // Shall I test the subject line against URLs?
- if (getConfig('allow_url_in_subject') == 'Y') {
- // Check the subject line for issues
- setPostRequestElement('subject', str_replace(chr(92), '[nl]', substr(postRequestElement('subject'), 0, 200)));
- if ((isInStringIgnoreCase('https://', postRequestElement('subject'))) || (isInStringIgnoreCase('http://', postRequestElement('subject'))) || (isInStringIgnoreCase('www', postRequestElement('subject')))) {
- // URL in subject found
- $data['url'] = 'modules.php?module=login&what=order&code=' . getCode('SUBJECT_URL');
- } // END - if
- } // END - if
-
- // And shall I check that his URL is not in the black list?
- if (isUrlBlacklisted(postRequestElement('url'))) {
- // Create redirect-URL
- $data['url'] = 'modules.php?module=login&what=order&code=' . getCode('BLIST_URL') . '&blist=' . $GLOBALS['blacklist_data'][postRequestElement('url')]['timestamp'];
- } // END - if
-
- // Enougth receivers entered?
- if ((postRequestElement('receiver') < getConfig('order_min')) && (!isAdmin())) {
- // Less than allowed receivers entered!
- $data['url'] = 'modules.php?module=login&what=order&code=' . getCode('MORE_RECEIVERS3');
- } // END - if
-
- // Validate URL
- if (!isUrlValid(postRequestElement('url'))) {
- // URL is invalid!
- $data['url'] = 'modules.php?module=login&what=order&code=' . getCode('INVALID_URL');
- } // END - if
-
- // Probe for HTML extension
- if (isExtensionActive('html_mail')) {
- // HTML or regular text mail?
- if (postRequestElement('html') == 'Y') {
- // Chek for valid HTML tags
- setPostRequestElement('text', checkHtmlTags(postRequestElement('text')));
-
- // Maybe invalid tags found?
- if (!isPostRequestElementSet('text')) $data['url'] = 'modules.php?module=login&what=order&code=' . getCode('INVALID_TAGS') . '&id=' . $data['id'];
- } else {
- // Remove any HTML code
- setPostRequestElement('text', str_replace(array('<', '>'), array('{OPEN_HTML}', '{CLOSE_HTML}'), postRequestElement('text')));
- }
- } // END - if
-
- // Is mail type set?
- if ((!isPostRequestElementSet('mail_type')) || (postRequestElement('mail_type') < 1)) {
- // Not correctly set
- $data['url'] = 'modules.php?module=login&what=order&code=' . getCode('NO_MAIL_TYPE');
+ // Prepare data for filter chain
+ $filterData = array(
+ 'url' => postRequestElement('url'),
+ 'text' => postRequestElement('text'),
+ 'subject' => postRequestElement('subject'),
+ 'receiver' => bigintval(postRequestElement('receiver')),
+ 'mail_type' => bigintval(postRequestElement('mail_type')),
+ 'html' => postRequestElement('html'),
+ 'id' => bigintval($data['id']),
+ 'redirect' => '',
+ );
+
+ // Run the filter chain
+ $filterData = runFilterChain('pre_mail_order', $filterData);
+
+ // Copy field redirect->url
+ $data['url'] = $filterData['redirect'];
+
+ // Is there an error?
+ if (empty($data['url'])) {
+ // Copy all filter data -> POST
+ foreach ($filterData as $key => $value) {
+ // Set it
+ setPostRequestElement($key, $value);
+ } // END - foreach