(no commit message)
[mailer.git] / 0.2.1 / inc / modules / member / 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 (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
36 {
37         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
38         require($INC);
39 }
40  elseif (!IS_LOGGED_IN())
41 {
42         LOAD_URL(URL."/modules.php?module=index");
43 }
44  elseif ((!EXT_IS_ACTIVE("rallye")) && (!IS_ADMIN()))
45 {
46         ADD_FATAL(EXTENSION_PROBLEM_EXT_INACTIVE, "rallye");
47         return;
48 }
49
50 // Add description as navigation point
51 ADD_DESCR("member", basename(__FILE__));
52
53 OUTPUT_HTML ("<DIV align=\"center\">");
54
55 // Check for possible running rallyes
56 $ADMIN = " AND d.is_active='Y'";
57 if (IS_ADMIN()) $ADMIN = "";
58 $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
59  FROM "._MYSQL_PREFIX."_rallye_data AS d, "._MYSQL_PREFIX."_admins AS a
60  WHERE d.admin_id=a.id".$ADMIN." AND d.notified='Y'
61  ORDER BY d.end_time LIMIT 1", __FILE__, __LINE__);
62
63 if (SQL_NUMROWS($result) == 1)
64 {
65         // Found some (normally one...
66         list($id, $aid, $login, $title, $descr, $templ, $start, $end, $min_users, $min_prices) = SQL_FETCHROW($result);
67         SQL_FREERESULT($result);
68
69         $expired = false;
70         if ($end < time())
71         {
72                 // Rallye is expired
73                 define('__RALLYE_EXTRAS', RALLYE_HAS_EXPIRED);
74                 $expired = true;
75         }
76          elseif (time() >= ($end - ONE_DAY))
77         {
78                 // Rallye will expire in less one day!
79                 define('__RALLYE_EXTRAS', RALLYE_EXPIRE_ONE_DAY);
80         }
81          else
82         {
83                 define('__RALLYE_EXTRAS', "<A href=\"".URL."/modules.php?module=login&amp;what=reflinks\">".RALLYE_GET_REFLINK."</A>");
84         }
85         // Set admin line (currently set to impressum, later to contact form)
86         define('__RALLYE_ADMIN', "<A href=\"".URL."/modules.php?module=index&amp;what=impressum&amp;admin=".$aid."\">".$login."</A>");
87
88         // Set title
89         define('__RALLYE_TITLE', COMPILE_CODE($title));
90
91         // Handle description...
92         if ((empty($descr)) && (!empty($templ)))
93         {
94                 // Use description from template
95                 define('__RALLYE_DESCR', LOAD_TEMPLATE("rallye_".$templ, true));
96         }
97          else
98         {
99                 // Use description from database
100                 define('__RALLYE_DESCR', COMPILE_CODE($descr));
101         }
102
103         if ($min_users == 0)
104         {
105                 // Rallye ends without user limitation
106                 define('__RALLYE_MAX_USERS', RALLYE_END_NO_USER_LIMITATION);
107         }
108          else
109         {
110                 // Rallye ends when X members are totally in your exchange
111                 define('__RALLYE_MAX_USERS', RALLYE_END_USERS_1." ".$min_users." ".RALLYE_END_USERS_2);
112         }
113         if ($min_prices == 0)
114         {
115                 // Rallye ends without user limitation
116                 define('__RALLYE_MIN_PRICES', RALLYE_END_NO_PRICE_LIMITATION);
117         }
118          else
119         {
120                 // Rallye ends when X members are totally in your exchange
121                 define('__RALLYE_MIN_PRICES', RALLYE_END_PRICES_1." ".$min_prices." ".RALLYE_END_PRICES_2);
122         }
123
124         // Set start and end time
125         define('__RALLYE_START', MAKE_DATETIME($start, "1"));
126         define('__RALLYE_END'  , MAKE_DATETIME($end  , "1"));
127
128         if ($expired)
129         {
130                 define('__RALLYE_PRICES', RALLYE_LIST_WINNERS($id));
131                 define('__RALLYE_TOP_USERS', "<DIV align=\"center\" class=\"big\">".__RALLYE_EXTRAS."</DIV>");
132                 define('__RALLYE_CAN_WIN_THIS', RALLYE_OUR_WINNERS_ARE);
133         }
134          else
135         {
136                 define('__RALLYE_PRICES', RALLYE_ADD_PRICES($id, "html"));
137                 define('__RALLYE_TOP_USERS', RALLYE_ADD_TOPUSERS($id, $GLOBALS['userid']));
138                 define('__RALLYE_CAN_WIN_THIS', RALLYE_YOU_CAN_WIN);
139         }
140
141         // And load final template
142         LOAD_TEMPLATE("guest_rallye_show");
143 }
144  else
145 {
146         // No rallye found so far
147         LOAD_TEMPLATE("guest_no_rallyes");
148 }
149 //
150 OUTPUT_HTML ("</DIV>");
151 //
152 ?>