2 /************************************************************************
3 * MXChange v0.2.1 Start: 10/19/2003 *
4 * =============== Last change: 08/26/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-order.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Order mails here *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Hier koennen Ihre Mitglieder Mails buchen *
12 * -------------------------------------------------------------------- *
14 * -------------------------------------------------------------------- *
15 * Copyright (c) 2003 - 2008 by Roland Haeder *
16 * For more information visit: http://www.mxchange.org *
18 * This program is free software; you can redistribute it and/or modify *
19 * it under the terms of the GNU General Public License as published by *
20 * the Free Software Foundation; either version 2 of the License, or *
21 * (at your option) any later version. *
23 * This program is distributed in the hope that it will be useful, *
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
26 * GNU General Public License for more details. *
28 * You should have received a copy of the GNU General Public License *
29 * along with this program; if not, write to the Free Software *
30 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
32 ************************************************************************/
34 // Some security stuff...
35 if (!defined('__SECURITY')) {
36 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
38 } elseif (!IS_MEMBER()) {
39 LOAD_URL("modules.php?module=index");
40 } elseif ((!EXT_IS_ACTIVE("order")) && (!IS_ADMIN())) {
41 addFatalMessage(getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), "order");
45 // Add description as navigation point
46 ADD_DESCR("member", __FILE__);
49 $whereStatement = " WHERE `visible`='Y'";
51 // Set undefined array elements
52 if (!REQUEST_ISSET_GET(('msg'))) REQUEST_SET_GET('msg' , "");
53 if (!REQUEST_ISSET_POST(('zip'))) REQUEST_SET_POST('zip' , "");
54 if (!REQUEST_ISSET_POST(('html'))) REQUEST_SET_POST('html' , "");
55 if (!REQUEST_ISSET_POST(('receiver'))) REQUEST_SET_POST('receiver', "");
56 if (IS_ADMIN()) $whereStatement = "";
58 // Minimum mails / order
59 define('__MIN_VALUE', getConfig('order_min'));
61 // Count unconfirmed mails
62 $links = GET_TOTAL_DATA($GLOBALS['userid'], "user_links", "id", "userid", true);
64 // Does the user has more than 0 mails per day set?
66 if (GET_EXT_VERSION("holiday") >= "0.1.3") {
67 // Fetch also holiday activation data
68 $HOLIDAY = "holiday_active";
71 $result_mmails = SQL_QUERY_ESC("SELECT userid, receive_mails, mail_orders, ".$HOLIDAY."
72 FROM `{!_MYSQL_PREFIX!}_user_data`
73 WHERE userid=%s AND max_mails > 0 LIMIT 1",
74 array($GLOBALS['userid']), __FILE__, __LINE__);
76 $mmails = SQL_NUMROWS($result_mmails);
77 list($DMY, $MAXI, $ORDERS, $HOLIDAY) = SQL_FETCHROW($result_mmails);
78 SQL_FREERESULT($result_mmails);
79 if ($HOLIDAY == $DMY) $HOLIDAY='N';
81 $ALLOWED = $MAXI - $ORDERS;
82 if (getConfig('order_max_full') == "MAX") $ALLOWED = $MAXI;
84 // Now check his points amount
85 $TOTAL = GET_TOTAL_DATA($GLOBALS['userid'], "user_points", "points") - GET_TOTAL_DATA($GLOBALS['userid'], "user_data", "used_points");;
87 if (($HOLIDAY == "Y") && (GET_EXT_VERSION("holiday") >= "0.1.3")) {
89 LOAD_TEMPLATE("admin_settings_saved", false, HOLIDAY_ORDER_NOT_POSSIBLE);
90 } elseif ((REQUEST_ISSET_POST(('frametester'))) && ($ALLOWED > 0) && (REQUEST_POST('receiver') > 0)) {
91 // Continue with the frametester, we first need to store the data temporary in the pool
93 // First we would like to store the data and get it's pool position back...
94 $result = SQL_QUERY_ESC("SELECT id, data_type
95 FROM `{!_MYSQL_PREFIX!}_pool`
96 WHERE sender=%s AND url='%s' AND timestamp > (UNIX_TIMESTAMP() - %s) LIMIT 1",
97 array($GLOBALS['userid'], REQUEST_POST('url'), getConfig('url_tlock')), __FILE__, __LINE__);
99 $type = "TEMP"; $id = 0;
100 if (SQL_NUMROWS($result) == 1) {
101 // Load id and mail type
102 list($id, $type) = SQL_FETCHROW($result);
106 SQL_FREERESULT($result);
108 if ($type == "TEMP") {
109 // No entry found, so we need to check out the stats table as well... :)
110 // We have to add that suff here, now we continue WITHOUT checking and check the text and subject against some filters
112 if (getConfig('test_text') == "Y") {
113 // Test submitted text against some filters (length, URLs in text etc.)
114 if ((strpos(strtolower(REQUEST_POST('text')), "https://") > -1) || (strpos(strtolower(REQUEST_POST('text')), "http://") > -1) || (strpos(strtolower(REQUEST_POST('text')), "www") > -1)) {
116 $URL = "modules.php?module=login&what=order&msg=".constant('CODE_URL_FOUND');
119 // Remove new-line and carriage-return characters
120 $TEST = str_replace("\n", "", str_replace("\r", "", REQUEST_POST('text')));
122 // Text length within allowed length?
123 if (strlen($TEST) > getConfig('max_tlength')) {
125 $URL = "modules.php?module=login&what=order&msg=".constant('CODE_OVERLENGTH');
129 // Shall I test the subject line against URLs?
130 if (getConfig('test_subj') == "Y") {
131 // Check the subject line for issues
132 REQUEST_SET_POST('subject', str_replace("\\", "[nl]", substr(REQUEST_POST('subject'), 0, 200)));
133 if ((strpos(strtolower(REQUEST_POST('subject')), "http://") > -1) || (strpos(strtolower(REQUEST_POST('subject')), "www") > -1)) {
134 // URL in subject found
135 $URL = "modules.php?module=login&what=order&msg=".constant('CODE_SUBJ_URL');
139 // And shall I check that his URL is not in the black list?
140 if (getConfig('url_blacklist') == "Y") {
141 // Ok, I do that for you know...
142 $result = SQL_QUERY_ESC("SELECT UNIX_TIMESTAMP(`timestamp`) AS tstamp FROM `{!_MYSQL_PREFIX!}_url_blacklist` WHERE `url`='%s' LIMIT 1",
143 array(REQUEST_POST('url')), __FILE__, __LINE__);
145 if (SQL_NUMROWS($result) == 1) {
146 // Jupp, we got one listed
147 list($blist) = SQL_FETCHROW($result);
149 // Create redirect-URL
150 $URL = "modules.php?module=login&what=order&msg=".constant('CODE_BLIST_URL')."&blist=".$blist;
154 SQL_FREERESULT($result);
157 // Enougth receivers entered?
158 if ((REQUEST_POST('receiver') < getConfig('order_min')) && (!IS_ADMIN())) {
159 // Less than allowed receivers entered!
160 $URL = "modules.php?module=login&what=order&msg=".constant('CODE_MORE_RECEIVERS3');
164 if (!VALIDATE_URL(REQUEST_POST('url'))) {
166 $URL = "modules.php?module=login&what=order&msg=".constant('CODE_INVALID_URL');
169 // Probe for HTML extension
170 if (EXT_IS_ACTIVE("html_mail")) {
171 // HTML or regular text mail?
172 if (REQUEST_POST('html') == "Y") {
173 // Chek for valid HTML tags
174 REQUEST_SET_POST('text', HTML_CHECK_TAGS(REQUEST_POST('text')));
176 // Maybe invalid tags found?
177 if (!REQUEST_ISSET_POST(('text'))) $URL = "modules.php?module=login&what=order&msg=".constant('CODE_INVALID_TAGS')."&id=".$id;
179 // Remove any HTML code
180 REQUEST_SET_POST('text', str_replace("<", "{OPEN_HTML}", str_replace(">", "{CLOSE_HTML}", REQUEST_POST('text'))));
183 } elseif (!IS_ADMIN()) {
184 // He has already sent a mail within a specific time
185 $URL = "modules.php?module=login&what=order&msg=".constant('CODE_URL_TLOCK')."&id=".$id;
190 // Check if category and number of receivers is okay
192 if ((getConfig('order_multi_page') == "Y") && (REQUEST_ISSET_POST(('zip')))) {
193 // Choose recipients by ZIP code
194 $ADD = " AND d.zip LIKE '".bigintval(REQUEST_POST('zip'))."{PER}'";
198 $result = SQL_QUERY_ESC("SELECT DISTINCT c.userid FROM `{!_MYSQL_PREFIX!}_user_cats` AS c
199 LEFT JOIN `{!_MYSQL_PREFIX!}_user_data` AS d
201 WHERE c.cat_id=%s AND c.userid != '%s' AND d.`status`='CONFIRMED' AND d.receive_mails > 0".$ADD."
204 bigintval(REQUEST_POST('cat')),
206 getConfig('order_select'),
207 getConfig('order_mode'),
208 ), __FILE__, __LINE__);
210 // Do we enougth receivers left?
211 if (SQL_NUMROWS($result) >= REQUEST_POST('receiver')) {
212 // Check for holiday extensions
214 if (GET_EXT_VERSION("holiday") >= "0.1.3") {
215 // Include checking for users in holiday
219 // Load receivers from database
220 $TEST = array(); $cnt = 0;
221 while (list($REC) = SQL_FETCHROW($result)) {
223 // Check for his holiday status
224 $result_holiday = SQL_QUERY_ESC("SELECT id FROM `{!_MYSQL_PREFIX!}_user_holidays`
225 WHERE userid=%s AND holiday_start < UNIX_TIMESTAMP() AND holiday_end > UNIX_TIMESTAMP() LIMIT 1",
226 array(bigintval($REC)), __FILE__, __LINE__);
227 if (SQL_NUMROWS($result_holiday) == 1) $REC = 0; // Exclude user who are in holiday
230 SQL_FREERESULT($result_holiday);
241 SQL_FREERESULT($result);
243 // Implode array into string for the sending pool
244 $RECEIVER = implode($TEST, ";");
246 // Count array for maximum sent
247 $MAX_SEND = count($TEST);
249 // Update receiver list
250 SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET receive_mails=receive_mails-1 WHERE userid IN (%s) LIMIT %s",
251 array(str_replace(";", ", ", $RECEIVER), $MAX_SEND), __FILE__, __LINE__);
253 // Is calculated max receivers larger than wanted receivers then reset it
254 if ($MAX_SEND > REQUEST_POST('receiver')) $MAX_SEND = REQUEST_POST('receiver');
256 // Calculate used points
257 $USED = $MAX_SEND * GET_PAY_POINTS(bigintval(REQUEST_POST('type')));
259 // Fix empty zip code
260 if (!REQUEST_ISSET_POST(('zip'))) REQUEST_SET_POST('zip', "0");
262 // Check if he has enougth points for this order and selected more than 0 receivers
263 if (($USED > 0) && ($USED <= $TOTAL) && ($MAX_SEND > 0)) {
264 // Gettings points is okay, so we can add $USED later from
266 if (($id == "0") || ($type != "TEMP")) {
269 if (EXT_IS_ACTIVE("html_mail")) {
270 // HTML extension is active
271 SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_pool` (sender, subject, text, receivers, payment_id, data_type, timestamp, url, cat_id, target_send, zip, html_msg)
272 VALUES ('%s','%s','%s','%s','%s','TEMP','%s','%s','%s','%s','%s','%s')",
275 REQUEST_POST('subject'),
276 REQUEST_POST('text'),
278 bigintval(REQUEST_POST('type')),
281 bigintval(REQUEST_POST('cat')),
283 bigintval(REQUEST_POST('zip')),
285 ), __FILE__, __LINE__);
287 // No HTML extension is active
288 SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_pool` (sender, subject, text, receivers, payment_id, data_type, timestamp, url, cat_id, target_send, zip)
289 VALUES ('%s','%s','%s','%s','%s','TEMP','%s','%s','%s','%s','%s')",
292 REQUEST_POST('subject'),
293 REQUEST_POST('text'),
295 bigintval(REQUEST_POST('type')),
298 bigintval(REQUEST_POST('cat')),
300 bigintval(REQUEST_POST('zip')),
301 ), __FILE__, __LINE__);
304 // Change current order
305 if (EXT_IS_ACTIVE("html_mail")) {
306 // HTML extension is active
307 SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_pool` SET
312 timestamp=UNIX_TIMESTAMP(),
318 WHERE id=%s LIMIT 1",
320 REQUEST_POST('subject'),
321 REQUEST_POST('text'),
323 bigintval(REQUEST_POST('type')),
325 bigintval(REQUEST_POST('cat')),
327 bigintval(REQUEST_POST('zip')),
328 REQUEST_POST('html'),
330 ), __FILE__, __LINE__);
332 // No HTML extension is active
333 SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_pool` SET
338 timestamp=UNIX_TIMESTAMP(),
343 WHERE id=%s LIMIT 1",
345 REQUEST_POST('subject'),
346 REQUEST_POST('text'),
348 bigintval(REQUEST_POST('type')),
350 bigintval(REQUEST_POST('cat')),
352 bigintval(REQUEST_POST('zip')),
354 ), __FILE__, __LINE__);
358 // Do we need to get the ID number?
360 // Order is placed as temporary. We need to get it's id for the frametester
361 $result = SQL_QUERY_ESC("SELECT id FROM `{!_MYSQL_PREFIX!}_pool` WHERE sender=%s AND subject='%s' AND payment_id=%s AND data_type='TEMP' AND timestamp=%s LIMIT 1",
364 REQUEST_POST('subject'),
365 bigintval(REQUEST_POST('type')),
367 ), __FILE__, __LINE__);
369 list($id) = SQL_FETCHROW($result);
370 SQL_FREERESULT($result);
373 // ID is received so we can redirect the user, used points will be added when he send's out the mail
374 $URL = "modules.php?module=frametester&order=".$id."";
375 } elseif ($MAX_SEND == 0) {
376 // Not enougth receivers found which can receive mails
377 $URL = "modules.php?module=login&what=order&msg=".constant('CODE_MORE_RECEIVERS2');
379 // No enougth points left!
380 $URL = "modules.php?module=login&what=order&msg=".constant('CODE_MORE_POINTS');
383 // Ordered more mails than he can send in this category
384 $URL = "modules.php?module=login&what=order&msg=".constant('CODE_NO_RECS_LEFT');
387 } elseif (REQUEST_POST('receiver') == "0") {
388 // Not enougth receivers selected
389 $URL = "modules.php?module=login&what=order&msg=".constant('CODE_MORE_RECEIVERS1');
390 } elseif (($ALLOWED == 0) && (getConfig('order_max_full') == "ORDER")) {
391 // No more mail orders allowed
392 LOAD_TEMPLATE("admin_settings_saved", false, getMessage('MEMBER_ORDER_ALLOWED_EXHAUSTED'));
393 } elseif (($links < getConfig('unconfirmed')) && ($mmails == "1")) {
394 // Display order form
395 $result_cats = SQL_QUERY("SELECT id, cat FROM `{!_MYSQL_PREFIX!}_cats`".$whereStatement." ORDER BY `sort`", __FILE__, __LINE__);
396 if (SQL_NUMROWS($result_cats) > 0) {
398 // Initialize array...
405 // Enable HTML checking
406 $HTML = ""; $HOLIDAY = false; $HOL_STRING = "";
407 if ((EXT_IS_ACTIVE("html_mail")) && (REQUEST_POST('html') == "Y")) $HTML = " AND html='Y'";
408 if (GET_EXT_VERSION("holiday") >= "0.1.3") {
409 // Extension's version is fine
410 $HOLIDAY = true; $HOL_STRING = " AND holiday_active='N'";
413 // ... and begin loading stuff
414 while (list($id, $cat) = SQL_FETCHROW($result_cats)) {
415 $CATS['id'][] = bigintval($id);
416 $CATS['name'][] = $cat;
418 // Select users in current category
419 $result_uids = SQL_QUERY_ESC("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_cats` WHERE cat_id=%s AND userid != '%s' ORDER BY userid",
420 array(bigintval($id), $GLOBALS['userid']), __FILE__, __LINE__);
423 while (list($ucat) = SQL_FETCHROW($result_uids)) {
424 // Check for holiday system
427 // Check user's holiday status
428 $result_holiday = SQL_QUERY_ESC("SELECT DISTINCT d.userid FROM `{!_MYSQL_PREFIX!}_user_data` AS d
429 LEFT JOIN `{!_MYSQL_PREFIX!}_user_holidays` AS h
431 WHERE d.userid=%s AND d.receive_mails > 0 AND d.`status`='CONFIRMED' AND d.holiday_active='Y'
432 AND h.holiday_start < UNIX_TIMESTAMP() AND h.holiday_end > UNIX_TIMESTAMP()
433 LIMIT 1", array(bigintval($ucat)), __FILE__, __LINE__);
434 if (SQL_NUMROWS($result_holiday) == 1) {
435 // Holiday is active!
440 SQL_FREERESULT($result_holiday);
444 // Check if the user want's to receive mails?
445 $result_ver = SQL_QUERY_ESC("SELECT zip FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s".$HTML." AND receive_mails > 0 AND `status`='CONFIRMED' LIMIT 1",
446 array(bigintval($ucat)), __FILE__, __LINE__);
448 if ((SQL_NUMROWS($result_ver) == 1) && (REQUEST_ISSET_POST(('zip'))) && (getConfig('order_multi_page') == "Y")) {
449 list($zip) = SQL_FETCHROW($result_ver);
450 SQL_FREERESULT($result_ver);
451 if (substr($zip, 0, strlen(REQUEST_POST('zip'))) == REQUEST_POST('zip')) {
452 // Ok, ZIP part is found
457 $uid_cnt += SQL_NUMROWS($result_ver);
463 SQL_FREERESULT($result_uids);
464 $CATS['uids'][] = $uid_cnt;
468 SQL_FREERESULT($result_cats);
470 // Now we need to load the mail types...
471 $result = SQL_QUERY("SELECT id, price, payment, mail_title FROM `{!_MYSQL_PREFIX!}_payments` ORDER BY payment", __FILE__, __LINE__);
474 if (SQL_NUMROWS($result) > 0) {
475 // Check for message ID in URL
477 switch (REQUEST_GET('msg'))
479 case constant('CODE_URL_TLOCK'):
480 $result = SQL_QUERY_ESC("SELECT timestamp FROM `{!_MYSQL_PREFIX!}_pool` WHERE id=%s LIMIT 1",
481 array(bigintval(REQUEST_GET('id'))), __FILE__, __LINE__);
483 // Load timestamp from last order
484 list($LORDER) = SQL_FETCHROW($result);
485 $LORDER = MAKE_DATETIME($LORDER, "1");
488 SQL_FREERESULT($result);
490 // Calculate hours...
491 $STD = round(getConfig('url_tlock') / 60 / 60);
494 $MIN = round((getConfig('url_tlock') - $STD * 60 * 60) / 60);
497 $SEC = getConfig('url_tlock') - $STD * 60 * 60 - $MIN * 60;
499 // Finally contruct the message
500 // @TODO Rewrite this old lost code to a template
501 $MSG = "{--MEMBER_URL_TIME_LOCK--}<br />{--CONFIG_URL_TLOCK--} ".$STD."
502 {--_HOURS--}, ".$MIN." {--_MINUTES--} {--_AND--} ".$SEC." {--_SECONDS--}<br />
503 {--MEMBER_LAST_TLOCK--}: ".$LORDER;
506 case constant('CODE_OVERLENGTH'):
507 $MSG = getMessage('MEMBER_TEXT_OVERLENGTH');
510 case constant('CODE_URL_FOUND'):
511 $MSG = getMessage('MEMBER_TEXT_CONTAINS_URL');
514 case constant('CODE_SUBJ_URL'):
515 $MSG = getMessage('MEMBER_SUBJ_CONTAINS_URL');
518 case constant('CODE_BLIST_URL'):
519 $MSG = "{--MEMBER_URL_BLACK_LISTED--}<br />\n{--MEMBER_BLIST_TIME--}: ".MAKE_DATETIME(REQUEST_GET('blist'), "0");
522 case constant('CODE_NO_RECS_LEFT'):
523 $MSG = getMessage('MEMBER_SELECTED_MORE_RECS');
526 case constant('CODE_INVALID_TAGS'):
527 $MSG = getMessage('MEMBER_HTML_INVALID_TAGS');
530 case constant('CODE_MORE_POINTS'):
531 $MSG = getMessage('MEMBER_MORE_POINTS_NEEDED');
534 case constant('CODE_MORE_RECEIVERS1'):
535 $MSG = getMessage('MEMBER_ENTER_MORE_RECEIVERS');
538 case constant('CODE_MORE_RECEIVERS2'):
539 $MSG = getMessage('MEMBER_NO_MORE_RECEIVERS_FOUND');
542 case constant('CODE_MORE_RECEIVERS3'):
543 $MSG = sprintf(getMessage('MEMBER_ENTER_MORE_MIN_RECEIVERS'), getConfig('order_min'));
546 case constant('CODE_INVALID_URL'):
547 $MSG = getMessage('MEMBER_ENTER_INVALID_URL');
550 case "": // When no error code is included in the URL we do not need to output an error message as well...
554 DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown error code %s detected.", REQUEST_GET('msg')));
555 $MSG = sprintf(getMessage('UNKNOWN_CODE'), REQUEST_GET('msg'));
560 // We got system message so we drop it out to the user
561 LOAD_TEMPLATE("admin_settings_saved", false, $MSG);
564 // Load all email types...
565 while ($typeS[] = SQL_FETCHROW($result)) {
566 // Nothing to do here... ;-)
570 SQL_FREERESULT($result);
572 // Output user's points
573 $TOTAL = TRANSLATE_COMMA($TOTAL);
575 // Check how many mail orders he has placed today and how many he's allowed to send
576 switch (getConfig('order_max_full'))
578 case "MAX": // He is allowed to send as much as possible
579 define('ORDER_MAX_VALUE', getMessage('ORDER_ALLOWED_MAX'));
582 case "ORDER": // He is allowed to send as much as he setup the receiving value
583 define('ORDER_MAX_VALUE', sprintf(getMessage('ORDER_ALLOWED_RECEIVE'), $ALLOWED, $MAXI));
586 default: // Unknown/invalid
587 DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown order_mas_full config detected.", getConfig('order_max_full')));
588 define('ORDER_MAX_VALUE', getMessage('ORDER_ALLOWED_UNKNOWN'));
592 // Load final template
593 LOAD_TEMPLATE("member_order_points", false, $TOTAL);
596 $OLD_ORDER = false; $subject = ""; $text = ""; $target = "";
598 // Check if we already have an order placed and make it editable
599 $result = SQL_QUERY_ESC("SELECT subject, text, payment_id, timestamp, url, target_send, cat_id, zip FROM `{!_MYSQL_PREFIX!}_pool` WHERE sender=%s AND data_type='TEMP' LIMIT 1",
600 array($GLOBALS['userid']), __FILE__, __LINE__);
602 if (SQL_NUMROWS($result) == 1) {
604 list($subject, $text, $payment, $tstamp, $url, $target, $cat, $zip) = SQL_FETCHROW($result);
606 // Fix max receivers when it is too much
607 if ((isset($CATS['uids'][$cat])) && ($target > $CATS['uids'][$cat])) $target = $CATS['uids'][$cat];
609 // Old order is grabbed
612 // Default output for that your members don't forget it...
617 SQL_FREERESULT($result);
619 // 01 2 21 12 2 23 443 3 3210
620 if ((REQUEST_ISSET_POST(('data'))) || ((getConfig('order_multi_page') != "Y") && ((!IS_ADMIN()) && (!EXT_IS_ACTIVE("html_mail"))))) {
621 // Pre-output categories
623 foreach ($CATS['id'] as $key => $value) {
624 $CAT .= " <option value=\"".$value."\"";
625 if (($OLD_ORDER) && ($cat == $value)) $CAT .= " selected=\"selected\"";
626 $CAT .= ">".$CATS['name'][$key]." (".$CATS['uids'][$key]." {--USER_IN_CAT--})</option>\n";
631 foreach ($typeS as $key => $value) {
632 $P = TRANSLATE_COMMA($typeS[$key][1]);
633 if (is_array($value)) {
634 // Output option line
635 $type .= " <option value=\"".$typeS[$key][0]."\"";
636 if (($OLD_ORDER) && ($payment == $typeS[$key][0])) $type .= " selected=\"selected\"";
637 $type .= ">".$P." {--PER_MAIL--} - ".$typeS[$key][3]." - ".round($typeS[$key][2])." {--PAYMENT--}</option>\n";
641 // Put all in constants for the template
642 define('CATEGORY_SELECTION', $CAT);
643 define('TYPE_SELECTION', $type);
644 define('TARGET', $target);
645 define('SUBJECT', $subject);
646 define('TEXT', COMPILE_CODE($text));
647 define('T_URL', $url);
649 if (REQUEST_ISSET_POST(('zip'))) {
650 // Output entered ZIP code
651 define('ZIP_OUTPUT', LOAD_TEMPLATE("member_order-zip2", true, REQUEST_POST('zip')));
653 define('ZIP_OUTPUT', "<tr><td colspan=\"5\" height=\"5\" class=\"seperator\"> </td></tr>");
657 if ((EXT_IS_ACTIVE("html_mail")) && (REQUEST_POST('html') == "Y")) {
658 // Extension is active so output valid HTML tags
659 define('MEMBER_HTML_EXTENSION', LOAD_TEMPLATE("member_order-html_ext", true, HTML_ADD_VALID_TAGS()));
661 // Extension not active and/or class not uploaded
662 define('MEMBER_HTML_EXTENSION', "<tr><td colspan=\"5\"><input type=\"hidden\" name=\"html\" value=\"N\"> /</td></tr>");
665 // Output form for page 2
666 LOAD_TEMPLATE("member_order_page2");
668 // Remember maybe entered ZIP code in constant
670 if (EXT_IS_ACTIVE("html_mail")) {
671 // Add some content when html extension is active
672 if ((getConfig('order_multi_page') == "Y") || (IS_ADMIN())) $ADD = "<tr><td colspan=\"2\" class=\"seperator bottom2\" height=\"5\"> </td></tr>\n";
673 define('MEMBER_HTML_EXTENSION', LOAD_TEMPLATE("member_order-html_intro", true));
675 // No HTML extension installed
676 define('MEMBER_HTML_EXTENSION', "<tr><td colspan=\"2\"><input type=\"hidden\" name=\"html\" value=\"N\" /></td></tr>");
679 // Do we want ZIP code or not?
680 if ((getConfig('order_multi_page') == "Y") || (IS_ADMIN())) {
682 if (REQUEST_POST('zip') > 0) {
684 'zip' => bigintval(REQUEST_POST('zip')),
693 define('MEMBER_ZIP_CONTENT', LOAD_TEMPLATE("member_order-zip1", true, $content));
696 define('MEMBER_ZIP_CONTENT', "");
699 // Output form for page 1 (ZIP code or HTML)
700 LOAD_TEMPLATE("member_order_page1");
703 // No mail types defined
704 LOAD_TEMPLATE("admin_settings_saved", false, "<span class=\"member_failed\">{--MEMBER_NO_PAYMENTS--}</span>");
708 LOAD_TEMPLATE("admin_settings_saved", false, "<span class=\"member_failed\">{--MEMBER_NO_POINTS--}</span>");
711 // No cateogries are defined yet
712 LOAD_TEMPLATE("admin_settings_saved", false, "<span class=\"member_failed\">{--MEMBER_NO_CATS--}</span>");
714 } elseif ($mmails == "0") {
715 // Please set more than 0 mails per day
716 LOAD_TEMPLATE("admin_settings_saved", false, getMessage('MEMBER_HAS_ZERO_MMAILS'));
718 // Please confirm some mails first
719 LOAD_TEMPLATE("admin_settings_saved", false, sprintf(getMessage('MEMBER_LINKS_LEFT'), $links, getConfig('unconfirmed')));
723 // Redirect to requested URL