2 /************************************************************************
3 * MXChange v0.2.1 Start: 06/29/2004 *
4 * ================ Last change: 08/22/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-rallyes.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Ref rallyes *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Ref-Rallyes *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
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 *
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. *
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. *
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, *
37 ************************************************************************/
39 // Some security stuff...
40 if (!defined('__SECURITY')) {
41 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
43 } elseif (!IS_MEMBER()) {
44 redirectToUrl('modules.php?module=index');
45 } elseif ((!EXT_IS_ACTIVE('rallye')) && (!IS_ADMIN())) {
46 addFatalMessage(__FILE__, __LINE__, generateExtensionInactiveNotInstalledMessage('rallye'));
50 // Add description as navigation point
51 ADD_DESCR('member', __FILE__);
53 OUTPUT_HTML("<div align=\"center\">");
55 // Check for possible running rallyes
56 $ADMIN = " AND d.is_active='Y'";
57 if (IS_ADMIN()) $ADMIN = '';
58 $result = SQL_QUERY("SELECT
59 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 `{!_MYSQL_PREFIX!}_rallye_data` AS d
63 `{!_MYSQL_PREFIX!}_admins` AS a
67 d.notified='Y'".$ADMIN."
70 LIMIT 1", __FILE__, __LINE__);
72 if (SQL_NUMROWS($result) == 1) {
73 // Found some (normally one...
74 $content = SQL_FETCHARRAY($result);
77 if ($content['end_time'] < time()) {
79 define('__RALLYE_EXTRAS', getMessage('RALLYE_HAS_EXPIRED'));
81 } elseif (time() >= ($content['end_time'] - getConfig('one_day'))) {
82 // Rallye will expire in less one day!
83 define('__RALLYE_EXTRAS', getMessage('RALLYE_EXPIRE_ONE_DAY'));
85 define('__RALLYE_EXTRAS', "<a href=\"{?URL?}/modules.php?module=login&what=reflinks\">{--RALLYE_GET_REFLINK--}</a>");
88 // Set admin line (currently set to impressum, later to contact form)
89 define('__RALLYE_ADMIN', "<a href=\"{?URL?}/modules.php?module=index&what=impressum&admin=".$content['admin_id']."\">".$content['login']."</a>");
92 define('__RALLYE_TITLE', COMPILE_CODE($content['title']));
94 // Handle description...
95 if ((empty($content['descr'])) && (!empty($content['template']))) {
96 // Use description from template
97 define('__RALLYE_DESCR', LOAD_TEMPLATE('rallye_' . $content['template'], true));
99 // Use description from database
100 define('__RALLYE_DESCR', COMPILE_CODE($content['descr']));
103 // Determine min_users/prices
104 define('__RALLYE_MAX_USERS' , RALLYE_DETERMINE_MIN_USERS($content['min_users']));
105 define('__RALLYE_MAX_PRICES', RALLYE_DETERMINE_MIN_PRICES($content['min_prices']));
107 // Set start and end time
108 define('__RALLYE_START', generateDateTime($content['start_time'], '1'));
109 define('__RALLYE_END' , generateDateTime($content['end_time'] , '1'));
111 if ($expired === true) {
112 define('__RALLYE_PRICES', RALLYE_LIST_WINNERS($content['id']));
113 define('__RALLYE_TOP_USERS', "<div align=\"center\" class=\"big\">{!__RALLYE_EXTRAS!}</div>");
114 define('__RALLYE_CAN_WIN_THIS', getMessage('RALLYE_OUR_WINNERS_ARE'));
116 define('__RALLYE_PRICES', RALLYE_ADD_PRICES($content['id'], 'html'));
117 define('__RALLYE_TOP_USERS', RALLYE_ADD_TOPUSERS($content['id'], getUserId()));
118 define('__RALLYE_CAN_WIN_THIS', getMessage('RALLYE_YOU_CAN_WIN'));
121 // And load final template
122 LOAD_TEMPLATE('guest_rallye_show');
124 // No rallye found so far
125 LOAD_TEMPLATE('guest_no_rallyes');
129 SQL_FREERESULT($result);
132 OUTPUT_HTML('</div>');