2 /************************************************************************
3 * MXChange v0.2.1 Start: 02/17/2005 *
4 * =============== Last change: 02/17/2005 *
6 * -------------------------------------------------------------------- *
7 * File : doubler_functions.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Functions for the guest's newsletter *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Funktionen fuer den Newsletter an die Gaeste *
12 * -------------------------------------------------------------------- *
14 * $Date:: 2009-03-06 20:24:32 +0100 (Fr, 06. Mär 2009) $ *
15 * $Tag:: 0.2.1-FINAL $ *
16 * $Author:: stelzi $ *
17 * Needs to be in all Files and every File needs "svn propset *
18 * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
19 * -------------------------------------------------------------------- *
20 * Copyright (c) 2003 - 2008 by Roland Haeder *
21 * For more information visit: http://www.mxchange.org *
23 * This program is free software; you can redistribute it and/or modify *
24 * it under the terms of the GNU General Public License as published by *
25 * the Free Software Foundation; either version 2 of the License, or *
26 * (at your option) any later version. *
28 * This program is distributed in the hope that it will be useful, *
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
31 * GNU General Public License for more details. *
33 * You should have received a copy of the GNU General Public License *
34 * along with this program; if not, write to the Free Software *
35 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
37 ************************************************************************/
39 // Some security stuff...
40 if (!defined('__SECURITY')) {
41 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
45 // Generates a HTML table based on given data
46 // @TODO Lame description
47 function DOUBLER_GENERATE_TABLE ($uid="0", $done='N', $ref='N', $sort="ASC") {
48 if (empty($cnt)) $cnt = 0;
49 $ADD = ""; $DT_MODE = 0;
51 // Load entries only from a single user
52 $ADD = " AND userid='".bigintval($uid)."'";
53 $MODE = "member"; $COLS = "4"; $DT_MODE = "2";
54 $NOT_FOUND = getMessage('DOUBLER_MEMBER_NO_ENTRIES_FOUND');
57 $MODE = "guest"; $COLS = "3"; $DT_MODE = "3";
58 $NOT_FOUND = getMessage('DOUBLER_GUEST_NO_ENTRIES_FOUND');
61 if (($done == "Y") && ($sort == "ASC")) {
62 // Already payed out points (latest payouts first)
63 $limit = getConfig('doubler_display_old');
64 } elseif ($sort == "ASC") {
65 // List entries which will receive their payout soon
66 $limit = getConfig('doubler_display_pay');
67 } elseif ($sort == "DESC") {
69 $limit = getConfig('doubler_display_new');
73 $result = SQL_QUERY("SELECT userid, refid, points, timemark
74 FROM `{!_MYSQL_PREFIX!}_doubler`
75 WHERE completed='".$done."' AND is_ref='".$ref."'".$ADD."
76 ORDER BY timemark ".$sort."
77 LIMIT ".$limit, __FUNCTION__, __LINE__);
79 if (SQL_NUMROWS($result) > 0) {
82 while ($content = SQL_FETCHARRAY($result)) {
83 // Rewrite userid/refid only if admin is in
85 // Set links to admin area
86 if ($content['userid'] > 0) { $content['userid'] = ADMIN_USER_PROFILE_LINK($content['userid']); } else { $content['userid'] = "---"; }
87 if ($content['refid'] > 0) { $content['refid'] = ADMIN_USER_PROFILE_LINK($content['refid']); } else { $content['refid'] = "---"; }
90 // Prepare data for the row template
92 'uid' => $content['userid'],
93 'rid' => $content['refid'],
94 'points' => TRANSLATE_COMMA($content['points']),
95 'stamp' => MAKE_DATETIME($content['timemark'], $DT_MODE),
99 // Load template and switch color
100 $OUT .= LOAD_TEMPLATE($MODE."_doubler_list_rows", true, $content);
105 SQL_FREERESULT($result);
109 <td colspan=\"".$COLS."\" align=\"center\" class=\"doubler_big_row bottom2\">
110 ".LOAD_TEMPLATE("admin_settings_saved", true, $NOT_FOUND)."
116 return LOAD_TEMPLATE($MODE."_doubler_list", true, $OUT);
120 function DOUBLER_GET_TOTAL_POINTS_LEFT() {
121 // Initialize variables
124 if (getConfig('doubler_own') == "Y") {
125 // Take points from doubler's own account
126 $points += getConfig('doubler_points') - getConfig('doubler_used');
129 if (getConfig('doubler_jackpot') == "Y") {
131 $result = SQL_QUERY("SELECT points FROM `{!_MYSQL_PREFIX!}_jackpot` WHERE ok='ok' LIMIT 1", __FUNCTION__, __LINE__);
132 list($jackpot) = SQL_FETCHROW($result);
133 SQL_FREERESULT($result);
135 if (!empty($jackpot)) $points += $jackpot;
138 if (getConfig('doubler_uid') > 0) {
140 $user = GET_TOTAL_DATA(getConfig('doubler_uid'), "user_points", "points");