2 /************************************************************************
3 * MXChange v0.2.1 Start: 11/23/2003 *
4 * =============== Last change: 09/23/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-sub_points.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Add manually points to a user *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Manuell einem Mitglied Punkte gutschreiben *
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()))
37 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
40 // Add description as navigation point
41 ADD_DESCR("admin", basename(__FILE__));
44 if (!isset($_GET['u_id'])) $_GET['u_id'] = "";
46 OPEN_TABLE("100%", "admin_content admin_content_align", "");
47 if ($_GET['u_id'] == "all")
49 // Add points to all accounts
50 define('__POINTS_VALUE', $_POST['points']);
51 if ((isset($_POST['ok'])) && ($_POST['points'] > 0))
53 $result_main = SQL_QUERY("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE status='CONFIRMED' ORDER BY userid", __FILE__, __LINE__);
54 while (list($uid) = SQL_FETCHROW($result_main))
56 // User ID found in URL so we use this give him some credits
57 $result = SQL_QUERY_ESC("SELECT surname, family, email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s AND status='CONFIRMED' LIMIT 1",
58 array(bigintval($uid)), __FILE__, __LINE__);
59 if (SQL_NUMROWS($result) == 1)
61 // Selected user does exist
62 list($sname, $fname, $email) = SQL_FETCHROW($result);
63 SQL_FREERESULT($result);
65 if ((isset($_POST['ok'])) && (!empty($_POST['points'])))
67 // Ok, add points to used points and send an email to him...
68 SUB_POINTS($uid, $_POST['points']);
70 // Load message and send it away
71 $msg = LOAD_EMAIL_TEMPLATE("sub-points", $_POST['reason'], $uid);
72 SEND_EMAIL($email, ADMIN_SUB_SUBJ, $msg);
77 SQL_FREERESULT($result_main);
80 LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_ALL_POINTS_SUBTRACTED);
84 // Display form add points
85 LOAD_TEMPLATE("admin_sub_points_all");
88 elseif (!empty($_GET['u_id']))
90 // User ID found in URL so we use this give him some credits
91 $result = SQL_QUERY_ESC("SELECT surname, family, email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s AND status='CONFIRMED' LIMIT 1",
92 array(bigintval($_GET['u_id'])),__FILE__, __LINE__);
93 if (SQL_NUMROWS($result) == 1)
95 // Selected user does exist
96 list($sname, $fname, $email) = SQL_FETCHROW($result);
97 SQL_FREERESULT($result);
99 if ((isset($_POST['ok'])) && (!empty($_POST['points'])))
101 // Ok, add to used points and send an email to him...
102 SUB_POINTS(bigintval($_GET['u_id']), $_POST['points']);
104 // Remember points in template
105 define('__POINTS_VALUE', bigintval($_POST['points']));
107 // Load email and send it away
108 $msg = LOAD_EMAIL_TEMPLATE("sub-points", $_POST['reason'], $_GET['u_id']);
109 SEND_EMAIL($email, ADMIN_SUB_SUBJ, $msg);
112 LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_POINTS_SUBTRACTED);
116 // Opps, missing form here
117 define('__USER_VALUE', "<A href=\"".CREATE_EMAIL_LINK($email, "user_data")."\">".$sname." ".$fname."</A>");
118 define('__UID_VALUE', $_GET['u_id']);
119 LOAD_TEMPLATE("admin_sub_points");
125 OUTPUT_HTML("<STRONG class=\"admin_failed\">".ADMIN_MEMBER_404_1.$_GET['u_id'].ADMIN_MEMBER_404_2."</STRONG>");
130 // Output selection form with all confirmed user accounts listed
131 ADD_MEMBER_SELECTION_BOX(true);