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 * -------------------------------------------------------------------- *
14 * -------------------------------------------------------------------- *
15 * Copyright (c) 2003 - 2008 by Roland Haeder *
16 * For more information visit: http://www.mxchange.org *
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. *
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. *
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, *
32 ************************************************************************/
34 // Some security stuff...
35 if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
37 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
40 elseif ((!EXT_IS_ACTIVE("rallye")) && (!IS_ADMIN()))
42 ADD_FATAL(EXTENSION_PROBLEM_EXT_INACTIVE, "rallye");
46 // Add description as navigation point
47 ADD_DESCR("guest", basename(__FILE__));
49 OUTPUT_HTML("<DIV align=\"center\">");
51 // Check for possible running rallyes
52 $ADMIN = " AND d.is_active='Y'";
53 if (IS_ADMIN()) $ADMIN = "";
55 $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
56 FROM "._MYSQL_PREFIX."_rallye_data AS d, "._MYSQL_PREFIX."_admins AS a
57 WHERE d.admin_id=a.id".$ADMIN." AND d.notified='Y'
58 ORDER BY d.end_time LIMIT 1", __FILE__, __LINE__);
60 if (SQL_NUMROWS($result) == 1)
62 // Found some (normally one...
63 list($id, $aid, $login, $title, $descr, $templ, $start, $end, $min_users, $min_prices) = SQL_FETCHROW($result);
69 define('__RALLYE_EXTRAS', RALLYE_HAS_EXPIRED);
72 elseif (time() >= ($end - ONE_DAY))
74 // Rallye will expire in less one day!
75 define('__RALLYE_EXTRAS', RALLYE_EXPIRE_ONE_DAY);
79 define('__RALLYE_EXTRAS', "<A href=\"".URL."/modules.php?module=index&what=register\">".RALLYE_REGISTER_NOW."</A>");
81 // Set admin line (currently set to impressum, later to contact form)
82 define('__RALLYE_ADMIN', "<A href=\"".URL."/modules.php?module=index&what=impressum&admin=".$aid."\">".$login."</A>");
85 define('__RALLYE_TITLE', COMPILE_CODE($title));
87 // Handle description...
88 if ((empty($descr)) && (!empty($templ)))
90 // Use description from template
91 define('__RALLYE_DESCR', LOAD_TEMPLATE("rallye_".$templ, true));
95 // Use description from database
96 define('__RALLYE_DESCR', COMPILE_CODE($descr));
99 // Set start and end time
100 define('__RALLYE_START', MAKE_DATETIME($start, "1"));
101 define('__RALLYE_END' , MAKE_DATETIME($end , "1"));
105 // Rallye ends without user limitation
106 define('__RALLYE_MAX_USERS', RALLYE_END_NO_USER_LIMITATION);
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);
113 if ($min_prices == 0)
115 // Rallye ends without user limitation
116 define('__RALLYE_MIN_PRICES', RALLYE_END_NO_PRICE_LIMITATION);
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);
126 define('__RALLYE_PRICES', RALLYE_LIST_WINNERS($id));
127 define('__RALLYE_TOP_USERS', "<DIV align=\"center\" class=\"big\">".__RALLYE_EXTRAS."</DIV>");
128 define('__RALLYE_CAN_WIN_THIS', RALLYE_OUR_WINNERS_ARE);
132 define('__RALLYE_PRICES', RALLYE_ADD_PRICES($id, "html"));
133 define('__RALLYE_TOP_USERS', RALLYE_ADD_TOPUSERS($id, $GLOBALS['userid']));
134 define('__RALLYE_CAN_WIN_THIS', RALLYE_YOU_CAN_WIN);
137 // And load final template
138 LOAD_TEMPLATE("guest_rallye_show");
142 // No rallye found so far
143 LOAD_TEMPLATE("guest_no_rallyes");
146 OUTPUT_HTML("</DIV>");