Updated copyright year.
[mailer.git] / inc / modules / guest / what-rallyes.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 06/29/2004 *
4  * ===================                          Last change: 08/22/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-rallyes.php                                 *
8  * -------------------------------------------------------------------- *
9  * Short description : Ref rallyes                                      *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Ref-Rallyes                                      *
12  * -------------------------------------------------------------------- *
13  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
14  * Copyright (c) 2009 - 2016 by Mailer Developer Team                   *
15  * For more information visit: http://mxchange.org                      *
16  *                                                                      *
17  * This program is free software; you can redistribute it and/or modify *
18  * it under the terms of the GNU General Public License as published by *
19  * the Free Software Foundation; either version 2 of the License, or    *
20  * (at your option) any later version.                                  *
21  *                                                                      *
22  * This program is distributed in the hope that it will be useful,      *
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
25  * GNU General Public License for more details.                         *
26  *                                                                      *
27  * You should have received a copy of the GNU General Public License    *
28  * along with this program; if not, write to the Free Software          *
29  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
30  * MA  02110-1301  USA                                                  *
31  ************************************************************************/
32
33 // Some security stuff...
34 if (!defined('__SECURITY')) {
35         exit();
36 } // END - if
37
38 // Add description as navigation point
39 addYouAreHereLink('guest', __FILE__);
40
41 if ((!isExtensionActive('rallye')) && (!isAdmin())) {
42         displayMessage('{%pipe,generateExtensionInactiveNotInstalledMessage=rallye%}');
43         return;
44 } // END - if
45
46 // Open div tag
47 outputHtml('<div align="center">');
48
49 // Check for possible running rallyes
50 $ADD = " AND `d`.`is_active`='Y'";
51 if (isAdmin()) $ADD = '';
52
53 $result = sqlQuery("SELECT
54         `d`.`id`,
55         `d`.`admin_id`,
56         `a`.`login`,
57         `d`.`title`,
58         `d`.`descr`,
59         `d`.`template`,
60         `d`.`start_time`,
61         `d`.`end_time`,
62         `d`.`min_users`,
63         `d`.`min_prices`
64 FROM
65         `{?_MYSQL_PREFIX?}_rallye_data` AS `d`
66 INNER JOIN
67         `{?_MYSQL_PREFIX?}_admins` AS `a`
68 ON
69         `d`.`admin_id`=`a`.`id`
70 WHERE
71         `d`.`notified`='Y'
72         " . $ADD . "
73 ORDER BY
74         `d`.`end_time` ASC
75 LIMIT 1", __FILE__, __LINE__);
76
77 if (sqlNumRows($result) == 1) {
78         // Found some (normally one...
79         $content = sqlFetchArray($result);
80
81         $expired = FALSE;
82         if (($content['end_time'] < time()) && (getTotalConfirmedUser() >= $content['min_users']) && (getTotalRallyeWinners($content['id']) >= $content['min_prices'])) {
83                 // Rallye is expired
84                 $content['extras'] = '{--RALLYE_HAS_EXPIRED--}';
85                 $expired = TRUE;
86         } elseif (time() >= ($content['end_time'] - getOneDay())) {
87                 // Rallye will expire in less one day!
88                 $content['extras'] = '{--RALLYE_EXPIRE_ONE_DAY--}';
89         } else {
90                 $content['extras'] = '<a href="{%url=modules.php?module=index&amp;what=register%}">{--RALLYE_REGISTER_NOW--}</a>';
91         }
92
93         // Set admin line (currently set to impressum, later to contact form)
94         // @TODO Reactivate this: $content['admin'] = '<a href="{%url=modules.php?module=index&amp;what=impressum&amp;id=' . $content['admin_id'] . '%}">' . $content['login'] . '</a>';
95
96         // Handle description...
97         if ((empty($content['descr'])) && (!empty($content['template']))) {
98                 // Use description from template
99                 $content['descr'] = '{%template,LoadTemplate=rallye_' . $content['template'] . '%}';
100         } // END - if
101
102         // Set start and end time
103         $content['start_time'] = generateDateTime($content['start_time'], 1);
104         $content['end_time']   = generateDateTime($content['end_time']  , 1);
105
106         if ($expired === TRUE) {
107                 $content['prices']       = addReferralRallyeWinners('guest', $content['id']);
108                 $content['top_users']    = '<div align="center" class="big">' . $content['extras'] . '</div>';
109                 $content['can_win_this'] = '{--RALLYE_OUR_WINNERS_ARE--}';
110         } else {
111                 $content['prices']       = addReferralRallyePrices($content['id'], 'html');
112                 $content['top_users']    = addReferralRallyeTopUsers('guest', $content['id'], getMemberId());
113                 $content['can_win_this'] = '{--RALLYE_YOU_CAN_WIN--}';
114         }
115
116         // And load final template
117         loadTemplate('guest_show_rallye', FALSE, $content);
118 } else {
119         // No rallye found so far
120         loadTemplate('guest_rallye_404');
121 }
122
123 // Close the div tag
124 outputHtml('</div>');
125
126 // [EOF]
127 ?>