A lot fixes to templates and missing functions added, more rewrites
[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  *                                                                      *
14  * -------------------------------------------------------------------- *
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
16  * For more information visit: http://www.mxchange.org                  *
17  *                                                                      *
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.                                  *
22  *                                                                      *
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.                         *
27  *                                                                      *
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,               *
31  * MA  02110-1301  USA                                                  *
32  ************************************************************************/
33
34 // Some security stuff...
35 if (!defined('__SECURITY')) {
36         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
37         require($INC);
38 } elseif ((!EXT_IS_ACTIVE("rallye")) && (!IS_ADMIN())) {
39         addFatalMessage(__FILE__, __LINE__, getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), "rallye");
40         return;
41 }
42
43 // Add description as navigation point
44 ADD_DESCR("guest", __FILE__);
45
46 OUTPUT_HTML("<div align=\"center\">");
47
48 // Check for possible running rallyes
49 $ADMIN = " AND d.is_active='Y'";
50 if (IS_ADMIN()) $ADMIN = "";
51
52 $result = SQL_QUERY("SELECT DISTINCT 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
53 FROM `{!_MYSQL_PREFIX!}_rallye_data` AS d, `{!_MYSQL_PREFIX!}_admins` AS a
54 WHERE d.admin_id=a.id".$ADMIN." AND d.notified='Y'
55 ORDER BY d.end_time LIMIT 1", __FILE__, __LINE__);
56
57 if (SQL_NUMROWS($result) == 1)
58 {
59         // Found some (normally one...
60         list($id, $aid, $login, $title, $descr, $templ, $start, $end, $min_users, $min_prices) = SQL_FETCHROW($result);
61
62         $expired = false;
63         if ($end < time())
64         {
65                 // Rallye is expired
66                 define('__RALLYE_EXTRAS', RALLYE_HAS_EXPIRED);
67                 $expired = true;
68         }
69          elseif (time() >= ($end - getConfig('one_day')))
70         {
71                 // Rallye will expire in less one day!
72                 define('__RALLYE_EXTRAS', RALLYE_EXPIRE_ONE_DAY);
73         }
74          else
75         {
76                 define('__RALLYE_EXTRAS', "<a href=\"{!URL!}/modules.php?module=index&amp;what=register\">".RALLYE_REGISTER_NOW."</a>");
77         }
78         // Set admin line (currently set to impressum, later to contact form)
79         define('__RALLYE_ADMIN', "<a href=\"{!URL!}/modules.php?module=index&amp;what=impressum&amp;admin=".$aid."\">".$login."</a>");
80
81         // Set title
82         define('__RALLYE_TITLE', COMPILE_CODE($title));
83
84         // Handle description...
85         if ((empty($descr)) && (!empty($templ)))
86         {
87                 // Use description from template
88                 define('__RALLYE_DESCR', LOAD_TEMPLATE("rallye_".$templ, true));
89         }
90          else
91         {
92                 // Use description from database
93                 define('__RALLYE_DESCR', COMPILE_CODE($descr));
94         }
95
96         // Set start and end time
97         define('__RALLYE_START', MAKE_DATETIME($start, "1"));
98         define('__RALLYE_END'  , MAKE_DATETIME($end  , "1"));
99
100         if ($min_users == 0)
101         {
102                 // Rallye ends without user limitation
103                 define('__RALLYE_MAX_USERS', RALLYE_END_NO_USER_LIMITATION);
104         }
105          else
106         {
107                 // Rallye ends when X members are totally in your exchange
108                 define('__RALLYE_MAX_USERS', RALLYE_END_USERS_1." ".$min_users." ".RALLYE_END_USERS_2);
109         }
110         if ($min_prices == 0)
111         {
112                 // Rallye ends without user limitation
113                 define('__RALLYE_MIN_PRICES', RALLYE_END_NO_PRICE_LIMITATION);
114         }
115          else
116         {
117                 // Rallye ends when X members are totally in your exchange
118                 define('__RALLYE_MIN_PRICES', RALLYE_END_PRICES_1." ".$min_prices." ".RALLYE_END_PRICES_2);
119         }
120
121         if ($expired)
122         {
123                 define('__RALLYE_PRICES', RALLYE_LIST_WINNERS($id));
124                 define('__RALLYE_TOP_USERS', "<div align=\"center\" class=\"big\">".__RALLYE_EXTRAS."</div>");
125                 define('__RALLYE_CAN_WIN_THIS', RALLYE_OUR_WINNERS_ARE);
126         }
127          else
128         {
129                 define('__RALLYE_PRICES', RALLYE_ADD_PRICES($id, "html"));
130                 define('__RALLYE_TOP_USERS', RALLYE_ADD_TOPUSERS($id, $GLOBALS['userid']));
131                 define('__RALLYE_CAN_WIN_THIS', RALLYE_YOU_CAN_WIN);
132         }
133
134         // And load final template
135         LOAD_TEMPLATE("guest_rallye_show");
136 }
137  else
138 {
139         // No rallye found so far
140         LOAD_TEMPLATE("guest_no_rallyes");
141 }
142 //
143 OUTPUT_HTML("</div>");
144 //
145 ?>