]> git.mxchange.org Git - mailer.git/blob - 0.2.1/inc/modules/admin/what-list_links.php
a72ee9b5b358705f2f1263c12ba491f180f52e1b
[mailer.git] / 0.2.1 / inc / modules / admin / what-list_links.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 01/28/2004 *
4  * ================                             Last change: 12/13/2004 *
5  *                                                                      *
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  * -------------------------------------------------------------------- *
13  *                                                                      *
14  * -------------------------------------------------------------------- *
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
16  * For more information visit: http://www.mxchange.org                  *
17  *                                                                      *
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.                                  *
22  *                                                                      *
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.                         *
27  *                                                                      *
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,               *
31  * MA  02110-1301  USA                                                  *
32  ************************************************************************/
33
34 // Some security stuff...
35 if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN()))
36 {
37         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
38         require($INC);
39 }
40
41 // Add description as navigation point
42 ADD_DESCR("admin", basename(__FILE__));
43
44 if (empty($_GET['del'])) $_GET['del'] = "";
45
46 OPEN_TABLE("100%", "admin_content admin_content_align", "");
47 if (!empty($_GET['u_id']))
48 {
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__);
52         if (SQL_NUMROWS($result) == 1)
53         {
54                 // Loads surname, family's name and the email address
55                 list($sname, $fname, $email) = SQL_FETCHROW($result);
56                 SQL_FREERESULT($result);
57
58                 // Grab user's all unconfirmed mails
59                 if (EXT_IS_ACTIVE("bonus"))
60                 {
61                         // Load bonus ID
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__);
64                 }
65                  else
66                 {
67                         // Load stats ID (2nd will be ignored later! But it is needed for the same fetchrow command)
68                         $result = SQL_QUERY_ESC("SELECT stats_id, stats_id, link_type FROM "._MYSQL_PREFIX."_user_links WHERE userid=%d ORDER BY id",
69                          array(bigintval($_GET['u_id'])), __FILE__, __LINE__);
70                 }
71
72                 $nums = bigintval(SQL_NUMROWS($result));
73                 if ($nums > 0)
74                 {
75                         // Some unconfirmed mails left
76                         if ($_GET['del'] == "all")
77                         {
78                                 // Delete all unconfirmed mails by this user
79                                 $result_del = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_links WHERE userid=%d LIMIT %s",
80                                  array(bigintval($_GET['u_id']), $nums), __FILE__, __LINE__);
81
82                                 // Prepare mail and send it away
83                                 $msg = LOAD_EMAIL_TEMPLATE("admin-del_links", $nums, bigintval($_GET['u_id']));
84                                 SEND_EMAIL($email, ADMIN_DEL_LINK_SUBJ, $msg);
85
86                                 // Display message
87                                 LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_LINKS_DELETED);
88                         }
89                          else
90                         {
91                                 // List all unconfirmed mails
92                                 $SW = 2; $OUT = "";
93                                 while (list($id, $id2, $type) = SQL_FETCHROW($result))
94                                 {
95                                         // Load data from stats table...
96                                         $cat = "";
97                                         switch ($type)
98                                         {
99                                         case "NORMAL":
100                                                 $result_data = SQL_QUERY_ESC("SELECT subject, timestamp_ordered, cat_id FROM "._MYSQL_PREFIX."_user_stats WHERE id=%d LIMIT 1",
101                                                  array(bigintval($id)), __FILE__, __LINE__);
102                                                 $TYPE = "mailid"; $DATA = $id; $PROBLEM = NORMAL_MAIL_PROBLEM;
103                                                 $LINK = "<A href=\"".URL."/mailid.php?uid=".$_GET['u_id']."&amp;mailid=".$id."\" target=\"_blank\">".$id."</A>";
104                                                 break;
105
106                                         case "BONUS":
107                                                 $result_data = SQL_QUERY_ESC("SELECT subject, timestamp, cat_id FROM "._MYSQL_PREFIX."_bonus WHERE id=%d LIMIT 1",
108                                                  array(bigintval($id2)), __FILE__, __LINE__);
109                                                 $TYPE = "bonusid"; $DATA = $id2; $PROBLEM = BONUS_MAIL_PROBLEM;
110                                                 $LINK = "<A href=\"".URL."/mailid.php?uid=".$_GET['u_id']."&amp;bonusid=".$id2."\" target=\"_blank\">".$id2."</A>";
111                                                 break;
112                                         }
113
114                                         if (SQL_NUMROWS($result_data) == 1)
115                                         {
116                                                 // Mail was found!
117                                                 list($subject, $timestamp, $cat) = SQL_FETCHROW($result_data);
118                                                 SQL_FREERESULT($result_data);
119                                                 if (empty($subject)) $subject = DEFAULT_SUBJECT_LINE;
120
121                                                 // Prepare data for the row template
122                                                 $content = array(
123                                                         'sw'    => $SW,
124                                                         'link'  => $LINK,
125                                                         'subj'  => $subject,
126                                                         'stamp' => MAKE_DATETIME($timestamp, "0"),
127                                                         'cat'   => GET_CATEGORY($cat),
128                                                 );
129
130                                                 // Load row template
131                                                 $OUT .= LOAD_TEMPLATE("admin_list_links_row", true, $content);
132                                         }
133                                          else
134                                         {
135                                                 $OUT .= "<TR>
136   <TD align=\"center\" class=\"switch_sw".$SW." bottom2\" colspan=\"4\">
137     <STRONG class=\"member_failed large\">".$PROBLEM.":</STRONG> ".$DATA."
138   </TD>
139 </TR>\n";
140                                         }
141                                         $SW = 3 - $SW;
142                                 }
143
144                                 // Free memory
145                                 SQL_FREERESULT($result);
146
147                                 // Remember list in constant for the template
148                                 define('__SNAME_VALUE', $sname);
149                                 define('__FNAME_VALUE', $fname);
150                                 define('__EMAIL_VALUE', "<A href=\"".CREATE_EMAIL_LINK($email, "user_data")."\">".$email."</A>");
151                                 define('__EMAIL_LIST' , $OUT);
152                                 define('__NUMS_VALUE' , $nums);
153                                 define('__UID_VALUE'  , $_GET['u_id']);
154
155                                 // Load final template
156                                 LOAD_TEMPLATE("admin_list_links");
157                         }
158                 }
159                  else
160                 {
161                         // No mails left to confirm
162                         LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_MEMBER_LINKS_1.$_GET['u_id'].ADMIN_MEMBER_LINKS_2);
163                 }
164         }
165          else
166         {
167                 // User not found
168                 LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_MEMBER_404_1.$_GET['u_id'].ADMIN_MEMBER_404_2);
169         }
170 }
171  else
172 {
173         // Output selection form with all confirmed user accounts listed
174         ADD_MEMBER_SELECTION_BOX();
175 }
176 CLOSE_TABLE();
177
178 //
179 ?>