2 /************************************************************************
3 * MXChange v0.2.1 Start: 02/12/2004 *
4 * ================ Last change: 02/27/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-del_email.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Delete a bonus or normal mail *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Bonus- / Normal-Mail loeschen *
12 * -------------------------------------------------------------------- *
14 * Module by Robert Niedziela, Megacomputing *
15 * web : http://mc-p.mcserver.de *
17 * -------------------------------------------------------------------- *
18 * Copyright (c) 2003 - 2008 by Roland Haeder *
19 * For more information visit: http://www.mxchange.org *
21 * This program is free software; you can redistribute it and/or modify *
22 * it under the terms of the GNU General Public License as published by *
23 * the Free Software Foundation; either version 2 of the License, or *
24 * (at your option) any later version. *
26 * This program is distributed in the hope that it will be useful, *
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
29 * GNU General Public License for more details. *
31 * You should have received a copy of the GNU General Public License *
32 * along with this program; if not, write to the Free Software *
33 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
35 ************************************************************************/
37 // Some security stuff...
38 if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN()))
40 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
44 // Add description as navigation point
45 ADD_DESCR("admin", basename(__FILE__));
46 OPEN_TABLE("100%", "admin_content admin_content_align", "");
47 if (!empty($_GET['mid']))
50 $result = SQL_QUERY_ESC("SELECT id, sender, subject, url, timestamp FROM "._MYSQL_PREFIX."_pool WHERE id=%d LIMIT 1",
51 array(bigintval($_GET['mid'])), __FILE__, __LINE__);
52 list ($id, $sender, $subject, $url, $timestamp,) = SQL_FETCHROW($result);
53 SQL_FREERESULT($result);
55 // Delete mail only once
58 // Prepare data for the template
60 define('__SENDER' , ADMIN_USER_PROFILE_LINK($sender));
61 define('__SUBJECT', $subject);
62 define('__URL' , DEREFERER($url));
63 define('__ORDERED', MAKE_DATETIME($timestamp, "0"));
66 LOAD_TEMPLATE("admin_del_email_normal");
68 // Transfer data to data array
69 $DATA = array($url, $subject);
71 // Load email template and send the email away
72 $msg_user = LOAD_EMAIL_TEMPLATE("order-deleted", "", $sender);
73 SEND_EMAIL($sender, MEMBER_ORDER_DELETED, $msg_user);
75 // Delete mail from queue
76 $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_pool WHERE id=%d LIMIT 1",
77 array(bigintval($_GET['mid'])), __FILE__, __LINE__);
79 // Fetch right stats_id from pool
80 $result = SQL_QUERY_ESC("SELECT s.id FROM "._MYSQL_PREFIX."_user_stats AS s
81 LEFT JOIN "._MYSQL_PREFIX."_pool AS p
82 ON s.pool_id=%d LIMIT 1",
83 array(bigintval($_GET['mid'])), __FILE__, __LINE__);
84 if (SQL_NUMROWS($result) == 1)
87 list($stats_id) = SQL_FETCHROW($result);
88 SQL_FREERESULT($result);
90 // Remove links from DB
91 $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_links WHERE stats_id=%d",
92 array(bigintval($stats_id)), __FILE__, __LINE__);
94 // Output link for manually removing stats entry
95 LOAD_TEMPLATE("admin_settings_saved", false, "<A href=\"".URL."/modules.php?module=admin&what=del_email&pid=".$_GET['mid']."\">".ADMIN_REMOVE_STATS_ENTRY."</A>");
100 // Mail already deleted!
101 LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_NORMAL_MAIL_ALREADY_DELETED);
104 elseif (!empty($_GET['pid']))
106 // Remove stats entries
107 $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_stats WHERE pool_id=%d LIMIT 1",
108 array(bigintval($_GET['pid'])), __FILE__, __LINE__);
109 LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_USER_STATS_REMOVED);
111 elseif ((!empty($_GET['bid'])) && (EXT_IS_ACTIVE("bonus")))
113 // Load data from bonus mail
114 $result = SQL_QUERY_ESC("SELECT id, subject, url, timestamp FROM "._MYSQL_PREFIX."_bonus WHERE id=%d",
115 array(bigintval($_GET['bid'])), __FILE__, __LINE__);
116 list ($id, $subject, $url, $timestamp) = SQL_FETCHROW($result);
117 SQL_FREERESULT($result);
119 // Delete mail only once
122 // Delete bonus mail entirely from database
123 $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_bonus WHERE id=%d LIMIT 1",
124 array(bigintval($_GET['bid'])), __FILE__, __LINE__);
125 $result = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_links WHERE bonus_id=%d",
126 array(bigintval($_GET['bid'])), __FILE__, __LINE__);
128 // Prepare data for the template
129 define('__ID' , $id);
130 define('__SUBJECT', $subject);
131 define('__URL' , DEREFERER($url));
132 define('__ORDERED', MAKE_DATETIME($timestamp, "0"));
135 LOAD_TEMPLATE("admin_del_email_bonus");
139 // Mail already deleted!
140 LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_BONUS_MAIL_ALREADY_DELETED);
145 // No mail orders fond
146 LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_WRONG_CALL);