2 /************************************************************************
3 * MXChange v0.2.1 Start: 06/29/2004 *
4 * ================ Last change: 08/22/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-add_rallye.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Add new rallye *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Neue Ref-Rallye einfuegen *
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 ((!defined('__SECURITY')) || (!IS_ADMIN())) {
36 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
40 // Add description as navigation point
41 ADD_DESCR("admin", basename(__FILE__));
43 if (isset($_POST['ok']))
45 // Generate timestamps
46 $START = mktime($_POST['start_hour'], $_POST['start_min'], $_POST['start_sec'], $_POST['start_month'], $_POST['start_day'], $_POST['start_year']);
47 $END = mktime($_POST['end_hour'] , $_POST['end_min'] , $_POST['end_sec'] , $_POST['end_month'] , $_POST['end_day'] , $_POST['end_year'] );
49 // Is there already a rallye running?
50 $result = SQL_QUERY_ESC("SELECT id, admin_id FROM "._MYSQL_PREFIX."_rallye_data WHERE (start_time <= %s AND end_time >= %s) OR (start_time >= %s AND start_time <= %s) LIMIT 1",
51 array($START, $START, $START, $END), __FILE__, __LINE__);
53 if (SQL_NUMROWS($result) == 0)
55 // Ok, start and end time did not overlap
56 $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_rallye_data (admin_id, title, descr, template, start_time, end_time, auto_add_new_user, is_active, send_notify)
57 VALUES ('%s','%s','%s','%s','%s','%s','%s','%s','%s')",
59 GET_ADMIN_ID(get_session('admin_login')),
68 ), __FILE__, __LINE__);
71 $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_rallye_data WHERE start_time='%s' AND end_time='%s' AND title='%s' LIMIT 1",
72 array($START, $END, $_POST['title']), __FILE__, __LINE__);
73 list($id) = SQL_FETCHROW($result);
74 SQL_FREERESULT($result);
78 // Reload to prices...
79 LOAD_URL("modules.php?module=admin&what=config_rallye_prices&rallye=".$id);
83 // Problem detected...
84 LOAD_TEMPLATE("admin_settings_saved", false, RALLYE_PROBLEM_CREATE);
90 SQL_FREERESULT($result);
92 // Overlapping detected
93 LOAD_TEMPLATE("admin_settings_saved", false, RALLYE_OVERLAP_TIMES);
97 // Prepare some constants for the template
98 define('_AUTO_ADD_OPTIONS', ADD_OPTION_LINES("/ARRAY/", array('Y','N'), array(YES, NO )));
99 define('_ACTIVE_OPTIONS' , ADD_OPTION_LINES("/ARRAY/", array('N','Y'), array(NO , YES)));
100 define('_NOTIFY_OPTIONS' , ADD_OPTION_LINES("/ARRAY/", array('Y','N'), array(YES, NO )));
103 define('_START_SEC' , ADD_SELECTION("sec" , "0" , "start"));
104 define('_START_MIN' , ADD_SELECTION("min" , "0" , "start"));
105 define('_START_HOUR' , ADD_SELECTION("hour" , date("G", time()), "start"));
106 define('_START_DAY' , ADD_SELECTION("day" , date("d", time()), "start"));
107 define('_START_MONTH', ADD_SELECTION("month", date("m", time()), "start"));
108 define('_START_YEAR' , ADD_SELECTION("year" , date('Y', time()), "start"));
110 // Calcualte ending date
111 $D = date("d", time() + ($_CONFIG['one_day'] * 7));
112 $M = date("m", time() + ($_CONFIG['one_day'] * 7));
113 $Y = date('Y', time() + ($_CONFIG['one_day'] * 7));
116 define('_END_SEC' , ADD_SELECTION("sec" , "0" , "end"));
117 define('_END_MIN' , ADD_SELECTION("min" , "0" , "end"));
118 define('_END_HOUR' , ADD_SELECTION("hour" , date("G", time()), "end"));
119 define('_END_DAY' , ADD_SELECTION("day" , $D , "end"));
120 define('_END_MONTH', ADD_SELECTION("month", $M , "end"));
121 define('_END_YEAR' , ADD_SELECTION("year" , $Y , "end"));
123 // Transfer (maybe found) templates into constant for the template
124 define('_TEMPLATES', RALLYE_TEMPLATE_SELECTION());
127 LOAD_TEMPLATE("admin_add_rallye");