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 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * Needs to be in all Files and every File needs "svn propset *
18 * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
19 * -------------------------------------------------------------------- *
20 * Copyright (c) 2003 - 2008 by Roland Haeder *
21 * For more information visit: http://www.mxchange.org *
23 * This program is free software; you can redistribute it and/or modify *
24 * it under the terms of the GNU General Public License as published by *
25 * the Free Software Foundation; either version 2 of the License, or *
26 * (at your option) any later version. *
28 * This program is distributed in the hope that it will be useful, *
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
31 * GNU General Public License for more details. *
33 * You should have received a copy of the GNU General Public License *
34 * along with this program; if not, write to the Free Software *
35 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
37 ************************************************************************/
39 // Some security stuff...
40 if (!defined('__SECURITY')) {
41 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
43 } elseif (!IS_MEMBER()) {
44 LOAD_URL('modules.php?module=index');
45 } elseif ((!EXT_IS_ACTIVE('order')) && (!IS_ADMIN())) {
46 addFatalMessage(__FILE__, __LINE__, getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), 'order');
50 // Add description as navigation point
51 ADD_DESCR('member', __FILE__);
54 $whereStatement = " WHERE `visible`='Y'";
56 // Set undefined array elements
57 if (!REQUEST_ISSET_GET('msg')) REQUEST_SET_GET('msg' , '');
58 if (!REQUEST_ISSET_POST('zip')) REQUEST_SET_POST('zip' , '');
59 if (!REQUEST_ISSET_POST('html')) REQUEST_SET_POST('html' , '');
60 if (!REQUEST_ISSET_POST('receiver')) REQUEST_SET_POST('receiver', '');
61 if (IS_ADMIN()) $whereStatement = '';
63 // Minimum mails / order
64 define('__MIN_VALUE', getConfig('order_min'));
66 // Count unconfirmed mails
67 $links = GET_TOTAL_DATA(getUserId(), "user_links", "id", 'userid', true);
69 // Does the user has more than 0 mails per day set?
71 if (GET_EXT_VERSION('holiday') >= '0.1.3') {
72 // Fetch also holiday activation data
73 $HOLIDAY = "holiday_active";
76 $result_mmails = SQL_QUERY_ESC("SELECT userid, receive_mails, mail_orders, ".$HOLIDAY."
77 FROM `{!_MYSQL_PREFIX!}_user_data`
78 WHERE userid=%s AND max_mails > 0 LIMIT 1",
79 array(getUserId()), __FILE__, __LINE__);
81 $mmails = SQL_NUMROWS($result_mmails);
82 list($DMY, $MAXI, $ORDERS, $HOLIDAY) = SQL_FETCHROW($result_mmails);
83 SQL_FREERESULT($result_mmails);
84 if ($HOLIDAY == $DMY) $HOLIDAY='N';
86 $ALLOWED = $MAXI - $ORDERS;
87 if (getConfig('order_max_full') == 'MAX') $ALLOWED = $MAXI;
89 // Now check his points amount
90 $total = GET_TOTAL_DATA(getUserId(), "user_points", "points") - GET_TOTAL_DATA(getUserId(), "user_data", "used_points");;
92 if (($HOLIDAY == 'Y') && (GET_EXT_VERSION('holiday') >= '0.1.3')) {
94 LOAD_TEMPLATE('admin_settings_saved', false, getMessage('HOLIDAY_ORDER_NOT_POSSIBLE'));
95 } elseif ((REQUEST_ISSET_POST(('frametester'))) && ($ALLOWED > 0) && (REQUEST_POST('receiver') > 0)) {
96 // Continue with the frametester, we first need to store the data temporary in the pool
98 // First we would like to store the data and get it's pool position back...
99 $result = SQL_QUERY_ESC("SELECT id, data_type
100 FROM `{!_MYSQL_PREFIX!}_pool`
101 WHERE sender=%s AND url='%s' AND timestamp > (UNIX_TIMESTAMP() - %s) LIMIT 1",
102 array(getUserId(), REQUEST_POST('url'), getConfig('url_tlock')), __FILE__, __LINE__);
104 $type = "TEMP"; $id = 0;
105 if (SQL_NUMROWS($result) == 1) {
106 // Load id and mail type
107 list($id, $type) = SQL_FETCHROW($result);
111 SQL_FREERESULT($result);
113 if ($type == "TEMP") {
114 // No entry found, so we need to check out the stats table as well... :)
115 // We have to add that suff here, now we continue WITHOUT checking and check the text and subject against some filters
117 if (getConfig('test_text') == 'Y') {
118 // Test submitted text against some filters (length, URLs in text etc.)
119 if ((strpos(strtolower(REQUEST_POST('text')), "https://") > -1) || (strpos(strtolower(REQUEST_POST('text')), "http://") > -1) || (strpos(strtolower(REQUEST_POST('text')), "www") > -1)) {
121 $URL = 'modules.php?module=login&what=order&msg=' . getCode('URL_FOUND');
124 // Remove new-line and carriage-return characters
125 $TEST = str_replace("\n", '', str_replace("\r", '', REQUEST_POST('text')));
127 // Text length within allowed length?
128 if (strlen($TEST) > getConfig('max_tlength')) {
130 $URL = 'modules.php?module=login&what=order&msg=' . getCode('OVERLENGTH');
134 // Shall I test the subject line against URLs?
135 if (getConfig('test_subj') == 'Y') {
136 // Check the subject line for issues
137 REQUEST_SET_POST('subject', str_replace("\\", "[nl]", substr(REQUEST_POST('subject'), 0, 200)));
138 if ((strpos(strtolower(REQUEST_POST('subject')), "http://") > -1) || (strpos(strtolower(REQUEST_POST('subject')), "www") > -1)) {
139 // URL in subject found
140 $URL = 'modules.php?module=login&what=order&msg=' . getCode('SUBJ_URL');
144 // And shall I check that his URL is not in the black list?
145 if (getConfig('url_blacklist') == 'Y') {
146 // Ok, I do that for you know...
147 $result = SQL_QUERY_ESC("SELECT UNIX_TIMESTAMP(`timestamp`) AS tstamp FROM `{!_MYSQL_PREFIX!}_url_blacklist` WHERE `url`='%s' LIMIT 1",
148 array(REQUEST_POST('url')), __FILE__, __LINE__);
150 if (SQL_NUMROWS($result) == 1) {
151 // Jupp, we got one listed
152 list($blist) = SQL_FETCHROW($result);
154 // Create redirect-URL
155 $URL = 'modules.php?module=login&what=order&msg=' . getCode('BLIST_URL')."&blist=".$blist;
159 SQL_FREERESULT($result);
162 // Enougth receivers entered?
163 if ((REQUEST_POST('receiver') < getConfig('order_min')) && (!IS_ADMIN())) {
164 // Less than allowed receivers entered!
165 $URL = 'modules.php?module=login&what=order&msg=' . getCode('MORE_RECEIVERS3');
169 if (!VALIDATE_URL(REQUEST_POST('url'))) {
171 $URL = 'modules.php?module=login&what=order&msg=' . getCode('INVALID_URL');
174 // Probe for HTML extension
175 if (EXT_IS_ACTIVE('html_mail')) {
176 // HTML or regular text mail?
177 if (REQUEST_POST('html') == 'Y') {
178 // Chek for valid HTML tags
179 REQUEST_SET_POST('text', HTML_CHECK_TAGS(REQUEST_POST('text')));
181 // Maybe invalid tags found?
182 if (!REQUEST_ISSET_POST(('text'))) $URL = 'modules.php?module=login&what=order&msg=' . getCode('INVALID_TAGS')."&id=".$id;
184 // Remove any HTML code
185 REQUEST_SET_POST('text', str_replace("<", "{OPEN_HTML}", str_replace(">", "{CLOSE_HTML}", REQUEST_POST('text'))));
188 } elseif (!IS_ADMIN()) {
189 // He has already sent a mail within a specific time
190 $URL = 'modules.php?module=login&what=order&msg=' . getCode('URL_TLOCK')."&id=".$id;
195 // Check if category and number of receivers is okay
197 if ((getConfig('order_multi_page') == 'Y') && (REQUEST_ISSET_POST('zip'))) {
198 // Choose recipients by ZIP code
199 $add = " AND d.zip LIKE '".bigintval(REQUEST_POST('zip'))."{PER}'";
203 $result = SQL_QUERY_ESC("SELECT DISTINCT c.userid FROM `{!_MYSQL_PREFIX!}_user_cats` AS c
204 LEFT JOIN `{!_MYSQL_PREFIX!}_user_data` AS d
206 WHERE c.cat_id=%s AND c.userid != '%s' AND d.`status`='CONFIRMED' AND d.receive_mails > 0".$add."
209 bigintval(REQUEST_POST('cat')),
211 getConfig('order_select'),
212 getConfig('order_mode'),
213 ), __FILE__, __LINE__);
215 // Do we enougth receivers left?
216 if (SQL_NUMROWS($result) >= REQUEST_POST('receiver')) {
217 // Check for holiday extensions
219 if (GET_EXT_VERSION('holiday') >= '0.1.3') {
220 // Include checking for users in holiday
224 // Load receivers from database
225 $TEST = array(); $cnt = 0;
226 while ($content = SQL_FETCHARRAY($result)) {
228 // Check for his holiday status
229 $result_holiday = SQL_QUERY_ESC("SELECT id FROM `{!_MYSQL_PREFIX!}_user_holidays`
230 WHERE userid=%s AND holiday_start < UNIX_TIMESTAMP() AND holiday_end > UNIX_TIMESTAMP() LIMIT 1",
231 array(bigintval($content['userid'])), __FILE__, __LINE__);
232 if (SQL_NUMROWS($result_holiday) == 1) $content['userid'] = 0; // Exclude user who are in holiday
235 SQL_FREERESULT($result_holiday);
238 if ($content['userid'] > 0) {
240 $TEST[] = $content['userid'];
246 SQL_FREERESULT($result);
248 // Implode array into string for the sending pool
249 $RECEIVER = implode($TEST, ';');
251 // Count array for maximum sent
252 $MAX_SEND = count($TEST);
254 // Update receiver list
255 SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET receive_mails=receive_mails-1 WHERE userid IN (%s) LIMIT %s",
256 array(str_replace(';', ", ", $RECEIVER), $MAX_SEND), __FILE__, __LINE__);
258 // Is calculated max receivers larger than wanted receivers then reset it
259 if ($MAX_SEND > REQUEST_POST('receiver')) $MAX_SEND = REQUEST_POST('receiver');
261 // Calculate used points
262 $USED = $MAX_SEND * GET_PAY_POINTS(bigintval(REQUEST_POST('type')));
264 // Fix empty zip code
265 if (!REQUEST_ISSET_POST('zip')) REQUEST_SET_POST('zip', "0");
267 // Check if he has enougth points for this order and selected more than 0 receivers
268 if (($USED > 0) && ($USED <= $total) && ($MAX_SEND > 0)) {
269 // Gettings points is okay, so we can add $USED later from
271 if (($id == "0") || ($type != "TEMP")) {
274 if (EXT_IS_ACTIVE('html_mail')) {
275 // HTML extension is active
276 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)
277 VALUES ('%s','%s','%s','%s','%s','TEMP','%s','%s','%s','%s','%s','%s')",
280 REQUEST_POST('subject'),
281 REQUEST_POST('text'),
283 bigintval(REQUEST_POST('type')),
286 bigintval(REQUEST_POST('cat')),
288 bigintval(REQUEST_POST('zip')),
290 ), __FILE__, __LINE__);
292 // No HTML extension is active
293 SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_pool` (sender, subject, text, receivers, payment_id, data_type, timestamp, url, cat_id, target_send, zip)
294 VALUES ('%s','%s','%s','%s','%s','TEMP','%s','%s','%s','%s','%s')",
297 REQUEST_POST('subject'),
298 REQUEST_POST('text'),
300 bigintval(REQUEST_POST('type')),
303 bigintval(REQUEST_POST('cat')),
305 bigintval(REQUEST_POST('zip')),
306 ), __FILE__, __LINE__);
309 // Change current order
310 if (EXT_IS_ACTIVE('html_mail')) {
311 // HTML extension is active
312 SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_pool` SET
317 timestamp=UNIX_TIMESTAMP(),
323 WHERE id=%s LIMIT 1",
325 REQUEST_POST('subject'),
326 REQUEST_POST('text'),
328 bigintval(REQUEST_POST('type')),
330 bigintval(REQUEST_POST('cat')),
332 bigintval(REQUEST_POST('zip')),
333 REQUEST_POST('html'),
335 ), __FILE__, __LINE__);
337 // No HTML extension is active
338 SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_pool` SET
343 timestamp=UNIX_TIMESTAMP(),
348 WHERE id=%s LIMIT 1",
350 REQUEST_POST('subject'),
351 REQUEST_POST('text'),
353 bigintval(REQUEST_POST('type')),
355 bigintval(REQUEST_POST('cat')),
357 bigintval(REQUEST_POST('zip')),
359 ), __FILE__, __LINE__);
363 // Do we need to get the ID number?
365 // Order is placed as temporary. We need to get it's id for the frametester
366 $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",
369 REQUEST_POST('subject'),
370 bigintval(REQUEST_POST('type')),
372 ), __FILE__, __LINE__);
374 list($id) = SQL_FETCHROW($result);
375 SQL_FREERESULT($result);
378 // ID is received so we can redirect the user, used points will be added when he send's out the mail
379 $URL = "modules.php?module=frametester&order=".$id."";
380 } elseif ($MAX_SEND == 0) {
381 // Not enougth receivers found which can receive mails
382 $URL = 'modules.php?module=login&what=order&msg=' . getCode('MORE_RECEIVERS2');
384 // No enougth points left!
385 $URL = 'modules.php?module=login&what=order&msg=' . getCode('MORE_POINTS');
388 // Ordered more mails than he can send in this category
389 $URL = 'modules.php?module=login&what=order&msg=' . getCode('NO_RECS_LEFT');
392 } elseif (REQUEST_POST('receiver') == "0") {
393 // Not enougth receivers selected
394 $URL = 'modules.php?module=login&what=order&msg=' . getCode('MORE_RECEIVERS1');
395 } elseif (($ALLOWED == 0) && (getConfig('order_max_full') == 'ORDER')) {
396 // No more mail orders allowed
397 LOAD_TEMPLATE('admin_settings_saved', false, getMessage('MEMBER_ORDER_ALLOWED_EXHAUSTED'));
398 } elseif (($links < getConfig('unconfirmed')) && ($mmails == "1")) {
399 // Display order form
400 $result_cats = SQL_QUERY("SELECT id, cat FROM `{!_MYSQL_PREFIX!}_cats`".$whereStatement." ORDER BY `sort`", __FILE__, __LINE__);
401 if (SQL_NUMROWS($result_cats) > 0) {
403 // Initialize array...
410 // Enable HTML checking
411 $HTML = ''; $HOLIDAY = false; $HOL_STRING = '';
412 if ((EXT_IS_ACTIVE('html_mail')) && (REQUEST_POST('html') == 'Y')) $HTML = " AND html='Y'";
413 if (GET_EXT_VERSION('holiday') >= '0.1.3') {
414 // Extension's version is fine
415 $HOLIDAY = true; $HOL_STRING = " AND holiday_active='N'";
418 // ... and begin loading stuff
419 while ($content = SQL_FETCHARRAY($result_cats)) {
420 $CATS['id'][] = bigintval($content['id']);
421 $CATS['name'][] = $content['cat'];
423 // Select users in current category
424 $result_uids = SQL_QUERY_ESC("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_cats` WHERE cat_id=%s AND userid != '%s' ORDER BY userid",
425 array(bigintval($content['id']), getUserId()), __FILE__, __LINE__);
428 while (list($ucat) = SQL_FETCHROW($result_uids)) {
429 // Check for holiday system
432 // Check user's holiday status
433 $result_holiday = SQL_QUERY_ESC("SELECT DISTINCT d.userid FROM `{!_MYSQL_PREFIX!}_user_data` AS d
434 LEFT JOIN `{!_MYSQL_PREFIX!}_user_holidays` AS h
436 WHERE d.userid=%s AND d.receive_mails > 0 AND d.`status`='CONFIRMED' AND d.holiday_active='Y'
437 AND h.holiday_start < UNIX_TIMESTAMP() AND h.holiday_end > UNIX_TIMESTAMP()
438 LIMIT 1", array(bigintval($ucat)), __FILE__, __LINE__);
439 if (SQL_NUMROWS($result_holiday) == 1) {
440 // Holiday is active!
445 SQL_FREERESULT($result_holiday);
449 // Check if the user want's to receive mails?
450 $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",
451 array(bigintval($ucat)), __FILE__, __LINE__);
453 if ((SQL_NUMROWS($result_ver) == 1) && (REQUEST_ISSET_POST('zip')) && (getConfig('order_multi_page') == 'Y')) {
454 list($zip) = SQL_FETCHROW($result_ver);
455 SQL_FREERESULT($result_ver);
456 if (substr($zip, 0, strlen(REQUEST_POST('zip'))) == REQUEST_POST('zip')) {
457 // Ok, ZIP part is found
462 $uid_cnt += SQL_NUMROWS($result_ver);
468 SQL_FREERESULT($result_uids);
469 $CATS['uids'][] = $uid_cnt;
473 SQL_FREERESULT($result_cats);
475 // Now we need to load the mail types...
476 $result = SQL_QUERY("SELECT id, price, payment, mail_title FROM `{!_MYSQL_PREFIX!}_payments` ORDER BY payment", __FILE__, __LINE__);
479 if (SQL_NUMROWS($result) > 0) {
480 // Check for message ID in URL
482 switch (REQUEST_GET('msg'))
484 case getCode('URL_TLOCK'):
485 $result = SQL_QUERY_ESC("SELECT timestamp FROM `{!_MYSQL_PREFIX!}_pool` WHERE id=%s LIMIT 1",
486 array(bigintval(REQUEST_GET('id'))), __FILE__, __LINE__);
488 // Load timestamp from last order
489 list($LORDER) = SQL_FETCHROW($result);
490 $LORDER = MAKE_DATETIME($LORDER, "1");
493 SQL_FREERESULT($result);
495 // Calculate hours...
496 $STD = round(getConfig('url_tlock') / 60 / 60);
499 $MIN = round((getConfig('url_tlock') - $STD * 60 * 60) / 60);
502 $SEC = getConfig('url_tlock') - $STD * 60 * 60 - $MIN * 60;
504 // Finally contruct the message
505 // @TODO Rewrite this old lost code to a template
506 $message = "{--MEMBER_URL_TIME_LOCK--}<br />{--CONFIG_URL_TLOCK--} ".$STD."
507 {--_HOURS--}, ".$MIN." {--_MINUTES--} {--_AND--} ".$SEC." {--_SECONDS--}<br />
508 {--MEMBER_LAST_TLOCK--}: ".$LORDER;
511 case getCode('OVERLENGTH'):
512 $message = getMessage('MEMBER_TEXT_OVERLENGTH');
515 case getCode('URL_FOUND'):
516 $message = getMessage('MEMBER_TEXT_CONTAINS_URL');
519 case getCode('SUBJ_URL'):
520 $message = getMessage('MEMBER_SUBJ_CONTAINS_URL');
523 case getCode('BLIST_URL'):
524 $message = "{--MEMBER_URL_BLACK_LISTED--}<br />\n{--MEMBER_BLIST_TIME--}: ".MAKE_DATETIME(REQUEST_GET('blist'), "0");
527 case getCode('NO_RECS_LEFT'):
528 $message = getMessage('MEMBER_SELECTED_MORE_RECS');
531 case getCode('INVALID_TAGS'):
532 $message = getMessage('MEMBER_HTML_INVALID_TAGS');
535 case getCode('MORE_POINTS'):
536 $message = getMessage('MEMBER_MORE_POINTS_NEEDED');
539 case getCode('MORE_RECEIVERS1'):
540 $message = getMessage('MEMBER_ENTER_MORE_RECEIVERS');
543 case getCode('MORE_RECEIVERS2'):
544 $message = getMessage('MEMBER_NO_MORE_RECEIVERS_FOUND');
547 case getCode('MORE_RECEIVERS3'):
548 $message = sprintf(getMessage('MEMBER_ENTER_MORE_MIN_RECEIVERS'), getConfig('order_min'));
551 case getCode('INVALID_URL'):
552 $message = getMessage('MEMBER_ENTER_INVALID_URL');
555 case "": // When no error code is included in the URL we do not need to output an error message as well...
559 DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown error code %s detected.", REQUEST_GET('msg')));
560 $message = sprintf(getMessage('UNKNOWN_CODE'), REQUEST_GET('msg'));
564 if (!empty($message)) {
565 // We got system message so we drop it out to the user
566 LOAD_TEMPLATE('admin_settings_saved', false, $message);
569 // Load all email types...
570 while ($typeS[] = SQL_FETCHROW($result)) {
571 // Nothing to do here... ;-)
575 SQL_FREERESULT($result);
577 // Output user's points
578 $total = TRANSLATE_COMMA($total);
580 // Check how many mail orders he has placed today and how many he's allowed to send
581 switch (getConfig('order_max_full'))
583 case 'MAX': // He is allowed to send as much as possible
584 define('ORDER_MAX_VALUE', getMessage('ORDER_ALLOWED_MAX'));
587 case 'ORDER': // He is allowed to send as much as he setup the receiving value
588 define('ORDER_MAX_VALUE', sprintf(getMessage('ORDER_ALLOWED_RECEIVE'), $ALLOWED, $MAXI));
591 default: // Unknown/invalid
592 DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown order_mas_full config detected.", getConfig('order_max_full')));
593 define('ORDER_MAX_VALUE', getMessage('ORDER_ALLOWED_UNKNOWN'));
597 // Load final template
598 LOAD_TEMPLATE("member_order_points", false, $total);
601 $OLD_ORDER = false; $subject = ''; $text = ''; $target = '';
603 // Check if we already have an order placed and make it editable
604 $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",
605 array(getUserId()), __FILE__, __LINE__);
607 if (SQL_NUMROWS($result) == 1) {
609 list($subject, $text, $payment, $tstamp, $url, $target, $content['cat'], $zip) = SQL_FETCHROW($result);
611 // Fix max receivers when it is too much
612 if ((isset($CATS['uids'][$content['cat']])) && ($target > $CATS['uids'][$content['cat']])) $target = $CATS['uids'][$content['cat']];
614 // Old order is grabbed
617 // Default output for that your members don't forget it...
622 SQL_FREERESULT($result);
624 // 01 2 21 12 2 23 443 3 3210
625 if ((REQUEST_ISSET_POST(('data'))) || ((getConfig('order_multi_page') != 'Y') && ((!IS_ADMIN()) && (!EXT_IS_ACTIVE('html_mail'))))) {
626 // Pre-output categories
628 foreach ($CATS['id'] as $key => $value) {
629 $CAT .= " <option value=\"".$value."\"";
630 if (($OLD_ORDER) && ($content['cat'] == $value)) $CAT .= ' selected="selected"';
631 $CAT .= ">".$CATS['name'][$key]." (".$CATS['uids'][$key]." {--USER_IN_CAT--})</option>\n";
636 foreach ($typeS as $key => $value) {
637 $P = TRANSLATE_COMMA($typeS[$key][1]);
638 if (is_array($value)) {
639 // Output option line
640 $type .= " <option value=\"".$typeS[$key][0]."\"";
641 if (($OLD_ORDER) && ($payment == $typeS[$key][0])) $type .= ' selected="selected"';
642 $type .= ">".$P." {--PER_MAIL--} - ".$typeS[$key][3]." - ".round($typeS[$key][2])." {--PAYMENT--}</option>\n";
646 // Put all in constants for the template
647 define('CATEGORY_SELECTION', $CAT);
648 define('TYPE_SELECTION', $type);
649 define('TARGET', $target);
650 define('SUBJECT', $subject);
651 define('TEXT', COMPILE_CODE($text));
652 define('T_URL', $url);
654 if (REQUEST_ISSET_POST('zip')) {
655 // Output entered ZIP code
656 define('ZIP_OUTPUT', LOAD_TEMPLATE("member_order-zip2", true, REQUEST_POST('zip')));
658 define('ZIP_OUTPUT', "<tr><td colspan=\"5\" height=\"5\" class=\"seperator\"> </td></tr>");
662 if ((EXT_IS_ACTIVE('html_mail')) && (REQUEST_POST('html') == 'Y')) {
663 // Extension is active so output valid HTML tags
664 define('MEMBER_HTML_EXTENSION', LOAD_TEMPLATE("member_order-html_ext", true, HTML_ADD_VALID_TAGS()));
666 // Extension not active and/or class not uploaded
667 define('MEMBER_HTML_EXTENSION', "<tr><td colspan=\"5\"><input type=\"hidden\" name=\"html\" value=\"N\"> /</td></tr>");
670 // Output form for page 2
671 LOAD_TEMPLATE("member_order_page2");
673 // Remember maybe entered ZIP code in constant
675 if (EXT_IS_ACTIVE('html_mail')) {
676 // Add some content when html extension is active
677 if ((getConfig('order_multi_page') == 'Y') || (IS_ADMIN())) $add = "<tr><td colspan=\"2\" class=\"seperator bottom2\" height=\"5\"> </td></tr>\n";
678 define('MEMBER_HTML_EXTENSION', LOAD_TEMPLATE("member_order-html_intro", true));
680 // No HTML extension installed
681 define('MEMBER_HTML_EXTENSION', "<tr><td colspan=\"2\"><input type=\"hidden\" name=\"html\" value=\"N\" /></td></tr>");
684 // Do we want ZIP code or not?
685 if ((getConfig('order_multi_page') == 'Y') || (IS_ADMIN())) {
687 if (REQUEST_POST('zip') > 0) {
689 'zip' => bigintval(REQUEST_POST('zip')),
698 define('MEMBER_ZIP_CONTENT', LOAD_TEMPLATE("member_order-zip1", true, $content));
701 define('MEMBER_ZIP_CONTENT', '');
704 // Output form for page 1 (ZIP code or HTML)
705 LOAD_TEMPLATE("member_order_page1");
708 // No mail types defined
709 LOAD_TEMPLATE('admin_settings_saved', false, "<span class=\"member_failed\">{--MEMBER_NO_PAYMENTS--}</span>");
713 LOAD_TEMPLATE('admin_settings_saved', false, "<span class=\"member_failed\">{--MEMBER_NO_POINTS--}</span>");
716 // No cateogries are defined yet
717 LOAD_TEMPLATE('admin_settings_saved', false, "<span class=\"member_failed\">{--MEMBER_NO_CATS--}</span>");
719 } elseif ($mmails == "0") {
720 // Please set more than 0 mails per day
721 LOAD_TEMPLATE('admin_settings_saved', false, getMessage('MEMBER_HAS_ZERO_MMAILS'));
723 // Please confirm some mails first
724 LOAD_TEMPLATE('admin_settings_saved', false, sprintf(getMessage('MEMBER_LINKS_LEFT'), $links, getConfig('unconfirmed')));
728 // Redirect to requested URL