c2788fbc05386b6609277b1860f280ef2d0a5271
[mailer.git] / inc / modules / guest / what-rallyes.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    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  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
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 - 2009 by Roland Haeder                           *
21  * For more information visit: http://www.mxchange.org                  *
22  *                                                                      *
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.                                  *
27  *                                                                      *
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.                         *
32  *                                                                      *
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,               *
36  * MA  02110-1301  USA                                                  *
37  ************************************************************************/
38
39 // Some security stuff...
40 if (!defined('__SECURITY')) {
41         die();
42 } // END - if
43
44 // Add description as navigation point
45 addMenuDescription('guest', __FILE__);
46
47 if ((!isExtensionActive('rallye')) && (!isAdmin())) {
48         loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('rallye'));
49         return;
50 } // END - if
51
52 // Open div tag
53 outputHtml("<div align=\"center\">");
54
55 // Check for possible running rallyes
56 $ADMIN = " AND d.is_active='Y'";
57 if (isAdmin()) $ADMIN = '';
58
59 $result = SQL_QUERY("SELECT
60         d.id, d.admin_id, a.login, d.title, d.descr, d.template, d.start_time, d.end_time, d.min_users, d.min_prices
61 FROM
62         `{?_MYSQL_PREFIX?}_rallye_data` AS d
63 INNER JOIN
64         `{?_MYSQL_PREFIX?}_admins` AS a
65 ON
66         d.admin_id=a.id
67 WHERE
68         d.notified='Y'".$ADMIN."
69 ORDER BY
70         d.end_time
71 LIMIT 1", __FILE__, __LINE__);
72
73 if (SQL_NUMROWS($result) == 1) {
74         // Found some (normally one...
75         list($id, $adminId, $login, $title, $descr, $templ, $start, $end, $min_users, $min_prices) = SQL_FETCHROW($result);
76
77         $expired = false;
78         if ($end < time()) {
79                 // Rallye is expired
80                 $content['extras'] = getMessage('RALLYE_HAS_EXPIRED');
81                 $expired = true;
82         } elseif (time() >= ($end - getConfig('ONE_DAY'))) {
83                 // Rallye will expire in less one day!
84                 $content['extras'] = getMessage('RALLYE_EXPIRE_ONE_DAY');
85         } else {
86                 $content['extras'] = "<a href=\"{?URL?}/modules.php?module=index&amp;what=register\">{--RALLYE_REGISTER_NOW--}</a>";
87         }
88
89         // Set admin line (currently set to impressum, later to contact form)
90         // @TODO Reactivate this: $content['admin'] = "<a href=\"{?URL?}/modules.php?module=index&amp;what=impressum&amp;admin=".$adminId."\">".$login."</a>";
91
92         // Set title
93         $content['title'] = $title;
94
95         // Handle description...
96         if ((empty($descr)) && (!empty($templ))) {
97                 // Use description from template
98                 $content['descr'] = loadTemplate('rallye_' . $templ, true);
99         } else {
100                 // Use description from database
101                 $content['descr'] = $descr;
102         }
103
104         // Set start and end time
105         $content['start'] = generateDateTime($start, '1');
106         $content['end']   = generateDateTime($end  , '1');
107
108         // Determine min_users
109         $content['min_users'] = determineReferalRallyeMinimumUsers($min_users);
110
111         // Determine min prices (now in function)
112         $content['min_prices'] = determineReferalRallyeMinimumPrices();
113
114         if ($expired === true) {
115                 $content['prices']       = addReferalRallyeWinners($id);
116                 $content['top_users']    = "<div align=\"center\" class=\"big\">".$content['extras']."</div>";
117                 $content['can_win_this'] = getMessage('RALLYE_OUR_WINNERS_ARE');
118         } else {
119                 $content['prices']       = addReferalRallyePrices($id, 'html');
120                 $content['top_users']    = addReferalRallyeTopUsers($id, getUserId());
121                 $content['can_win_this'] = getMessage('RALLYE_YOU_CAN_WIN');
122         }
123
124         // And load final template
125         loadTemplate('guest_rallye_show', false, $content);
126 } else {
127         // No rallye found so far
128         loadTemplate('guest_no_rallyes');
129 }
130
131 // Close the div tag
132 outputHtml('</div>');
133
134 // [EOF]
135 ?>