2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 06/29/2004 *
4 * =================== Last change: 08/22/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-rallyes.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Ref rallyes *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Ref-Rallyes *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * -------------------------------------------------------------------- *
18 * Copyright (c) 2003 - 2009 by Roland Haeder *
19 * Copyright (c) 2009 - 2012 by Mailer Developer Team *
20 * For more information visit: http://mxchange.org *
22 * This program is free software; you can redistribute it and/or modify *
23 * it under the terms of the GNU General Public License as published by *
24 * the Free Software Foundation; either version 2 of the License, or *
25 * (at your option) any later version. *
27 * This program is distributed in the hope that it will be useful, *
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
30 * GNU General Public License for more details. *
32 * You should have received a copy of the GNU General Public License *
33 * along with this program; if not, write to the Free Software *
34 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
36 ************************************************************************/
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
41 } elseif (!isMember()) {
42 redirectToIndexMemberOnlyModule();
45 // Add description as navigation point
46 addYouAreHereLink('member', __FILE__);
48 if ((!isExtensionActive('rallye')) && (!isAdmin())) {
49 displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=rallye%}');
53 // Check for possible running rallyes
54 $ADD = " AND d.`is_active`='Y'";
55 if (isAdmin()) $ADD = '';
57 $result = SQL_QUERY("SELECT
69 `{?_MYSQL_PREFIX?}_rallye_data` AS d
71 `{?_MYSQL_PREFIX?}_admins` AS a
79 LIMIT 1", __FILE__, __LINE__);
81 if (SQL_NUMROWS($result) == 1) {
82 // Found some (normally one...
83 $content = SQL_FETCHARRAY($result);
86 if (($content['end_time'] < time()) && (getTotalConfirmedUser() >= $content['min_users']) && (getTotalRallyeWinners($content['id']) >= $content['min_prices'])) {
88 $content['extras'] = '{--RALLYE_HAS_EXPIRED--}';
90 } elseif (time() >= ($content['end_time'] - getOneDay())) {
91 // Rallye will expire in less one day!
92 $content['extras'] = '{--RALLYE_EXPIRE_ONE_DAY--}';
94 // Link to referral links page
95 $content['extras'] = '<a href="{%url=modules.php?module=login&what=reflinks%}">{--RALLYE_GET_REFERRAL_LINK--}</a>';
98 // Set admin line (currently set to impressum, later to contact form)
99 // @TODO Reactivate this: $content['admin'] = '<a href="{%url=modules.php?module=index&what=impressum&id=' . $content['admin_id'] . '%}">' . $content['login'] . '</a>';
101 // Handle description...
102 if ((empty($content['descr'])) && (!empty($content['template']))) {
103 // Use description from template
104 $content['descr'] = loadTemplate('rallye_' . $content['template'], TRUE);
107 // Determine min_users/prices
108 $content['min_users'] = determineReferralRallyeMinimumUsers($content['min_users']);
109 $content['min_prices'] = determineReferralRallyeMinimumPrices($content['min_prices']);
111 // Set start and end time
112 $content['start_time'] = generateDateTime($content['start_time'], 1);
113 $content['end_time'] = generateDateTime($content['end_time'] , 1);
115 if ($expired === TRUE) {
116 $content['prices'] = addReferralRallyeWinners('member', $content['id']);
117 $content['top_users'] = '<div align="center" class="big">' . $content['extras'] . '</div>';
118 $content['can_win_this'] = '{--RALLYE_OUR_WINNERS_ARE--}';
120 $content['prices'] = addReferralRallyePrices($content['id'], 'html');
121 $content['top_users'] = addReferralRallyeTopUsers('member', $content['id'], getMemberId());
122 $content['can_win_this'] = '{--RALLYE_YOU_CAN_WIN--}';
125 // And load final template
126 loadTemplate('member_show_rallye', FALSE, $content);
128 // No rallye found so far
129 loadTemplate('member_rallye_404');
133 SQL_FREERESULT($result);