2 /************************************************************************
3 * MXChange v0.2.1 Start: 01/28/2004 *
4 * ================ Last change: 12/13/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-list_links.php *
8 * -------------------------------------------------------------------- *
9 * Short description : List unconfirmed mails of a member *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Unbestaetigte Mails eines Mitgliedes auflisten *
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 ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN())) {
36 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
38 } elseif (!EXT_IS_ACTIVE("mailid")) {
39 ADD_FATAL(sprintf(EXTENSION_PROBLEM_NOT_INSTALLED, "mailid"));
43 // Add description as navigation point
44 ADD_DESCR("admin", basename(__FILE__));
46 if (empty($_GET['del'])) $_GET['del'] = "";
48 if (!empty($_GET['u_id'])) {
49 // Check if the user already exists
50 $result = SQL_QUERY_ESC("SELECT surname, family, email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%d LIMIT 1",
51 array(bigintval($_GET['u_id'])), __FILE__, __LINE__);
54 if (SQL_NUMROWS($result) == 1) {
55 // Loads surname, family's name and the email address
56 list($sname, $fname, $email) = SQL_FETCHROW($result);
57 SQL_FREERESULT($result);
59 // Grab user's all unconfirmed mails
60 if (EXT_IS_ACTIVE("bonus")) {
62 $result = SQL_QUERY_ESC("SELECT stats_id, bonus_id, link_type FROM "._MYSQL_PREFIX."_user_links WHERE userid=%d ORDER BY id",
63 array(bigintval($_GET['u_id'])), __FILE__, __LINE__);
65 // Load stats ID (2nd will be ignored later! But it is needed for the same fetchrow command)
66 $result = SQL_QUERY_ESC("SELECT stats_id, stats_id, link_type FROM "._MYSQL_PREFIX."_user_links WHERE userid=%d ORDER BY id",
67 array(bigintval($_GET['u_id'])), __FILE__, __LINE__);
70 // Get number of rows from the query
71 $nums = SQL_NUMROWS($result);
74 // Some unconfirmed mails left
75 if ($_GET['del'] == "all") {
76 // Delete all unconfirmed mails by this user
77 $result_del = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_links WHERE userid=%d LIMIT %s",
78 array(bigintval($_GET['u_id']), $nums), __FILE__, __LINE__);
80 // Prepare mail and send it away
81 $msg = LOAD_EMAIL_TEMPLATE("admin-del_links", $nums, bigintval($_GET['u_id']));
82 SEND_EMAIL($email, ADMIN_DEL_LINK_SUBJ, $msg);
85 LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_LINKS_DELETED);
87 // List all unconfirmed mails
89 while (list($id, $id2, $type) = SQL_FETCHROW($result)) {
90 // Load data from stats table...
95 $result_data = SQL_QUERY_ESC("SELECT subject, timestamp_ordered, cat_id FROM "._MYSQL_PREFIX."_user_stats WHERE id=%d LIMIT 1",
96 array(bigintval($id)), __FILE__, __LINE__);
97 $TYPE = "mailid"; $DATA = $id; $PROBLEM = NORMAL_MAIL_PROBLEM;
98 $LINK = "<A href=\"".URL."/mailid.php?uid=".$_GET['u_id']."&mailid=".$id."\" target=\"_blank\">".$id."</A>";
102 $result_data = SQL_QUERY_ESC("SELECT subject, timestamp, cat_id FROM "._MYSQL_PREFIX."_bonus WHERE id=%d LIMIT 1",
103 array(bigintval($id2)), __FILE__, __LINE__);
104 $TYPE = "bonusid"; $DATA = $id2; $PROBLEM = BONUS_MAIL_PROBLEM;
105 $LINK = "<A href=\"".URL."/mailid.php?uid=".$_GET['u_id']."&bonusid=".$id2."\" target=\"_blank\">".$id2."</A>";
109 if (SQL_NUMROWS($result_data) == 1) {
111 list($subject, $timestamp, $cat) = SQL_FETCHROW($result_data);
112 SQL_FREERESULT($result_data);
113 if (empty($subject)) $subject = DEFAULT_SUBJECT_LINE;
115 // Prepare data for the row template
120 'stamp' => MAKE_DATETIME($timestamp, "0"),
121 'cat' => GET_CATEGORY($cat),
125 $OUT .= LOAD_TEMPLATE("admin_list_links_row", true, $content);
127 // Load template for error
128 $OUT .= LOAD_TEMPLATE("admin_list_links_problem",
131 'problem' => $PROBLEM,
140 SQL_FREERESULT($result);
142 // Remember list in constant for the template
143 define('__SNAME_VALUE', $sname);
144 define('__FNAME_VALUE', $fname);
145 define('__EMAIL_VALUE', "<A href=\"".CREATE_EMAIL_LINK($email, "user_data")."\">".$email."</A>");
146 define('__EMAIL_LIST' , $OUT);
147 define('__NUMS_VALUE' , $nums);
148 define('__UID_VALUE' , $_GET['u_id']);
150 // Load final template
151 LOAD_TEMPLATE("admin_list_links");
154 // No mails left to confirm
155 LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_MEMBER_LINKS_1.$_GET['u_id'].ADMIN_MEMBER_LINKS_2);
159 LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_MEMBER_404_1.$_GET['u_id'].ADMIN_MEMBER_404_2);
162 // Output selection form with all confirmed user accounts listed
163 ADD_MEMBER_SELECTION_BOX();