2 /************************************************************************
3 * MXChange v0.2.1 Start: 10/29/2003 *
4 * =============== Last change: 01/06/2006 *
6 * -------------------------------------------------------------------- *
8 * -------------------------------------------------------------------- *
9 * Short description : Submits your order to the administrators *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Sendet die Buchung an die Administratoren *
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...
36 if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
38 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
41 elseif ((!EXT_IS_ACTIVE("order")) && (!IS_ADMIN()))
43 ADD_FATAL(EXTENSION_PROBLEM_EXT_INACTIVE, "order");
46 elseif (!IS_LOGGED_IN())
48 // Sorry, no guest access!
49 $URL = URL."/modules.php?module=index";
51 elseif (empty($_GET['order']))
53 // You cannot call this module directly!
54 $URL = URL."/modules.php?module=login&what=order";
57 // When URL is empty nothing bad happend here
60 // Is the auto-send mechanism active or inactive?
61 if ($_CONFIG['autosend_active'] == 'Y')
63 // Auto-send is active
64 define('ADMIN_AUTOSEND', COMPILE_CODE(ADMIN_AUTOSEND_ACTIVE));
65 define('MEMBER_AUTOSEND', COMPILE_CODE(MEMBER_AUTOSEND_ACTIVE));
70 // Auto-send is inactive
71 define('ADMIN_AUTOSEND', COMPILE_CODE(ADMIN_AUTOSEND_INACTIVE));
72 define('MEMBER_AUTOSEND', COMPILE_CODE(MEMBER_AUTOSEND_INACTIVE));
76 // Update sending pool
77 $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_pool SET data_type='%s' WHERE id=%d AND sender=%d AND data_type='TEMP' LIMIT 1",
78 array($type, bigintval($_GET['order']), $GLOBALS['userid']), __FILE__, __LINE__);
80 // Finally is the entry valid?
81 if (SQL_AFFECTEDROWS($link) == 1)
83 // Update his login data
86 // Load personal data...
87 $result = SQL_QUERY_ESC("SELECT sex, surname, family, email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%d LIMIT 1",
88 array($GLOBALS['userid']), __FILE__, __LINE__);
89 list($sex, $sname, $fname, $email) = SQL_FETCHROW($result);
90 SQL_FREERESULT($result);
92 // Load mail again... 0 1 2 3 4 5 6 7
93 $result = SQL_QUERY_ESC("SELECT subject, text, receivers, payment_id, timestamp, url, cat_id, target_send FROM "._MYSQL_PREFIX."_pool WHERE id=%d AND sender=%d LIMIT 1",
94 array(bigintval($_GET['order']), $GLOBALS['userid']), __FILE__, __LINE__);
95 $DATA = SQL_FETCHROW($result);
96 SQL_FREERESULT($result);
97 if (empty($DATA[0])) $DATA[0] = DEFAULT_SUBJECT_LINE;
99 // Calculate used points
100 $USED = $DATA[7] * GET_PAY_POINTS($DATA[3]);
102 // Update used points
104 if ($_CONFIG['order_max'] == "ORDER") $ADD = ", mail_orders=mail_orders+1";
105 $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET used_points=used_points+%s".$ADD." WHERE userid=%d LIMIT 1",
106 array($USED, $GLOBALS['userid']), __FILE__, __LINE__);
108 // Update mediadata as well
109 if (GET_EXT_VERSION("mediadata") >= "0.0.4")
112 MEDIA_UPDATE_ENTRY(array("total_points"), "sub", $USED);
115 // Send an email to the user
116 $msg_mem = LOAD_EMAIL_TEMPLATE("order-member", "", $GLOBALS['userid']);
117 SEND_EMAIL($email, MEMBER_NEW_QUEUE, $msg_mem);
119 // Notify admins about this
120 if (GET_EXT_VERSION("admins") >= "0.4.1")
122 SEND_ADMIN_EMAILS_PRO(ADMIN_NEW_QUEUE, "order-admin", "", $GLOBALS['userid']);
126 $msg_admin = LOAD_EMAIL_TEMPLATE("order-admin", "", $GLOBALS['userid']);
127 SEND_ADMIN_EMAILS(ADMIN_NEW_QUEUE, $msg_admin);
130 // Output back bottom
131 LOAD_TEMPLATE("member_order-back", false);
135 // Matching line not found or already "placed" in send queue
136 $URL = URL."/modules.php?module=login";