1443c8fc640dc0c3e2fe6262ad42e2de272ed27f
[mailer.git] / 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  * $Revision:: 856                                                    $ *
14  * $Date:: 2009-03-06 20:24:32 +0100 (Fr, 06. Mär 2009)              $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author:: stelzi                                                   $ *
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 - 2008 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         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
42         require($INC);
43 } elseif (!IS_MEMBER()) {
44         LOAD_URL("modules.php?module=index");
45 } elseif ((!EXT_IS_ACTIVE("rallye")) && (!IS_ADMIN())) {
46         addFatalMessage(__FILE__, __LINE__, getMessage('EXTENSION_PROBLEM_EXT_INACTIVE'), "rallye");
47         return;
48 }
49
50 // Add description as navigation point
51 ADD_DESCR("member", __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         // Found some (normally one...
65         list($id, $aid, $login, $title, $descr, $templ, $start, $end, $min_users, $min_prices) = SQL_FETCHROW($result);
66         SQL_FREERESULT($result);
67
68         $expired = false;
69         if ($end < time()) {
70                 // Rallye is expired
71                 define('__RALLYE_EXTRAS', getMessage('RALLYE_HAS_EXPIRED'));
72                 $expired = true;
73         } elseif (time() >= ($end - getConfig('one_day'))) {
74                 // Rallye will expire in less one day!
75                 define('__RALLYE_EXTRAS', getMessage('RALLYE_EXPIRE_ONE_DAY'));
76         } else {
77                 define('__RALLYE_EXTRAS', "<a href=\"{!URL!}/modules.php?module=login&amp;what=reflinks\">{--RALLYE_GET_REFLINK--}</a>");
78         }
79
80         // Set admin line (currently set to impressum, later to contact form)
81         define('__RALLYE_ADMIN', "<a href=\"{!URL!}/modules.php?module=index&amp;what=impressum&amp;admin=".$aid."\">".$login."</a>");
82
83         // Set title
84         define('__RALLYE_TITLE', COMPILE_CODE($title));
85
86         // Handle description...
87         if ((empty($descr)) && (!empty($templ))) {
88                 // Use description from template
89                 define('__RALLYE_DESCR', LOAD_TEMPLATE("rallye_".$templ, true));
90         } else {
91                 // Use description from database
92                 define('__RALLYE_DESCR', COMPILE_CODE($descr));
93         }
94
95         // Determine min_users/prices
96         define('__RALLYE_MAX_USERS' ,  RALLYE_DETERMINE_MIN_USERS($min_users));
97         define('__RALLYE_MAX_PRICES',  RALLYE_DETERMINE_MIN_PRICES($min_prices));
98
99         // Set start and end time
100         define('__RALLYE_START', MAKE_DATETIME($start, "1"));
101         define('__RALLYE_END'  , MAKE_DATETIME($end  , "1"));
102
103         if ($expired === true) {
104                 define('__RALLYE_PRICES', RALLYE_LIST_WINNERS($id));
105                 define('__RALLYE_TOP_USERS', "<div align=\"center\" class=\"big\">{!__RALLYE_EXTRAS!}</div>");
106                 define('__RALLYE_CAN_WIN_THIS', getMessage('RALLYE_OUR_WINNERS_ARE'));
107         } else {
108                 define('__RALLYE_PRICES', RALLYE_ADD_PRICES($id, "html"));
109                 define('__RALLYE_TOP_USERS', RALLYE_ADD_TOPUSERS($id, $GLOBALS['userid']));
110                 define('__RALLYE_CAN_WIN_THIS', getMessage('RALLYE_YOU_CAN_WIN'));
111         }
112
113         // And load final template
114         LOAD_TEMPLATE("guest_rallye_show");
115 } else {
116         // No rallye found so far
117         LOAD_TEMPLATE("guest_no_rallyes");
118 }
119
120 //
121 OUTPUT_HTML("</div>");
122
123 //
124 ?>