"); // Check for possible running rallyes $ADMIN = " AND d.is_active='Y'"; if (IS_ADMIN()) $ADMIN = ''; $result = SQL_QUERY("SELECT 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 FROM `{!_MYSQL_PREFIX!}_rallye_data` AS d INNER JOIN `{!_MYSQL_PREFIX!}_admins` AS a ON d.admin_id=a.id WHERE d.notified='Y'".$ADMIN." ORDER BY d.end_time ASC LIMIT 1", __FILE__, __LINE__); if (SQL_NUMROWS($result) == 1) { // Found some (normally one... $content = SQL_FETCHARRAY($result); $expired = false; if ($content['end_time'] < time()) { // Rallye is expired define('__RALLYE_EXTRAS', getMessage('RALLYE_HAS_EXPIRED')); $expired = true; } elseif (time() >= ($content['end_time'] - getConfig('one_day'))) { // Rallye will expire in less one day! define('__RALLYE_EXTRAS', getMessage('RALLYE_EXPIRE_ONE_DAY')); } else { define('__RALLYE_EXTRAS', "{--RALLYE_GET_REFLINK--}"); } // Set admin line (currently set to impressum, later to contact form) define('__RALLYE_ADMIN', "".$content['login'].""); // Set title define('__RALLYE_TITLE', COMPILE_CODE($content['title'])); // Handle description... if ((empty($content['descr'])) && (!empty($content['template']))) { // Use description from template define('__RALLYE_DESCR', LOAD_TEMPLATE('rallye_' . $content['template'], true)); } else { // Use description from database define('__RALLYE_DESCR', COMPILE_CODE($content['descr'])); } // Determine min_users/prices define('__RALLYE_MAX_USERS' , RALLYE_DETERMINE_MIN_USERS($content['min_users'])); define('__RALLYE_MAX_PRICES', RALLYE_DETERMINE_MIN_PRICES($content['min_prices'])); // Set start and end time define('__RALLYE_START', generateDateTime($content['start_time'], '1')); define('__RALLYE_END' , generateDateTime($content['end_time'] , '1')); if ($expired === true) { define('__RALLYE_PRICES', RALLYE_LIST_WINNERS($content['id'])); define('__RALLYE_TOP_USERS', "
{!__RALLYE_EXTRAS!}
"); define('__RALLYE_CAN_WIN_THIS', getMessage('RALLYE_OUR_WINNERS_ARE')); } else { define('__RALLYE_PRICES', RALLYE_ADD_PRICES($content['id'], 'html')); define('__RALLYE_TOP_USERS', RALLYE_ADD_TOPUSERS($content['id'], getUserId())); define('__RALLYE_CAN_WIN_THIS', getMessage('RALLYE_YOU_CAN_WIN')); } // And load final template LOAD_TEMPLATE('guest_rallye_show'); } else { // No rallye found so far LOAD_TEMPLATE('guest_no_rallyes'); } // Free result SQL_FREERESULT($result); // OUTPUT_HTML(''); // ?>