]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/member/what-order.php
Fixes + asserts
[mailer.git] / inc / modules / member / what-order.php
index 0b187f963e98131437599cd73bccad56ac6daf9c..cc8fdf421685eb1132743a28a07e7510ad3403a1 100644 (file)
@@ -94,79 +94,31 @@ LIMIT 1",
        sqlFreeResult($result);
 
        if ($data['data_type'] == 'TEMP') {
-               /*
-                * 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 (!isAllowUrlInTextEnabled()) {
-                       // 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) > getMaxTextLength()) {
-                               // 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 (!isAllowUrlInSubjectEnabled()) {
-                       // 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 ((isExtensionActive('blacklist')) && (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') < getOrderMin()) && (!isAdmin())) {
-                       // Less than allowed receivers entered!
-                       $data['url'] = 'modules.php?module=login&amp;what=order&amp;code=' . getCode('MORE_RECEIVERS3');
-               } // END - if
-
-               // Validate URL
-               if (!isUrlValid(postRequestElement('url'))) {
-                       // URL is invalid!
-                       $data['url'] = 'modules.php?module=login&amp;what=order&amp;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
-                               $checked = checkHtmlTags(postRequestElement('text')));
-
-                               // Maybe invalid tags found?
-                               if (empty($checked)) {
-                                       // Invalid HTML tags found
-                                       $data['url'] = 'modules.php?module=login&amp;what=order&amp;code=' . getCode('INVALID_TAGS') . '&amp;id=' . $data['id'];
-                               } // END - if
-                       } 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&amp;what=order&amp;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
                } // END - if
        } elseif (!isAdmin()) {
                // He has already sent a mail within a specific time
@@ -234,7 +186,7 @@ LIMIT 1",
                        sqlFreeResult($result);
 
                        // Implode array into string for the sending pool
-                       $receiver = implode($TEST, ';');
+                       $receivers = implode($TEST, ';');
 
                        // Count array for maximum sent
                        $content['target_send'] = count($TEST);
@@ -242,7 +194,7 @@ LIMIT 1",
                        // Update receiver list
                        sqlQueryEscaped("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `receive_mails`=`receive_mails`-1 WHERE `userid` IN (%s) LIMIT %s",
                                array(
-                                       convertReceivers($receiver),
+                                       convertReceivers($receivers),
                                        bigintval($content['target_send'])
                                ), __FILE__, __LINE__);
 
@@ -268,7 +220,7 @@ LIMIT 1",
                                                'sender'      => getMemberId(),
                                                'subject'     => postRequestElement('subject'),
                                                'text'        => postRequestElement('text'),
-                                               'receivers'   => $receiver
+                                               'receivers'   => $receivers,
                                                'payment_id'  => bigintval(postRequestElement('mail_type')),
                                                'data_type'   => 'TEMP',
                                                'timestamp'   => 'UNIX_TIMESTAMP()',
@@ -291,7 +243,7 @@ LIMIT 1",
                                        $data = array(
                                                'subject'     => postRequestElement('subject'),
                                                'text'        => postRequestElement('text'),
-                                               'receivers'   => $receiver
+                                               'receivers'   => $receivers,
                                                'payment_id'  => bigintval(postRequestElement('mail_type')),
                                                'timestamp'   => 'UNIX_TIMESTAMP()',
                                                'url'         => postRequestElement('url'),
@@ -311,7 +263,7 @@ LIMIT 1",
                                }
 
                                // Make sure only valid id numbers can pass
-                               assert(isValidId($data['id']));
+                               assert(isValidId($data['id']), 'data[id]=' . $data['id'] . ' is not a valid id number.');
 
                                // Id is received so we can redirect the user, used points will be added when he send's out the mail
                                $data['url'] = 'modules.php?module=frametester&amp;order=' . bigintval($data['id']);
@@ -604,7 +556,7 @@ LIMIT 1",
                        }
                } else {
                        // No points left
-                       displayMessage('<span class="bad">{--MEMBER_ORDER_NO_POINTS--}</span>');
+                       displayMessage('<span class="notice">{--MEMBER_ORDER_NO_POINTS--}</span>');
                }
        } else {
                // No cateogries are defined yet