3 * Automatic database updates
5 * @author Roland Haeder <webmaster@ship-simu.org>
7 * @copyright Copyright (c) 2009, 2010 Cracker Tracker Team
8 * @license GNU GPL 3.0 or any newer version
9 * @link http://www.ship-simu.org
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
26 function crackerTrackerInitUpdates () {
28 $GLOBALS['ctracker_updates'] = array(
31 'CREATE TABLE IF NOT EXISTS `ctracker_ticket` (
32 `ctracker_ticket` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
33 `ctracker_ticket_remote_addr` varchar(15) NOT NULL,
34 `ctracker_ticket_user_agent` tinytext NOT NULL,
35 `ctracker_ticket_name` varchar(255) NOT NULL,
36 `ctracker_ticket_email` varchar(255) NOT NULL,
37 `ctracker_ticket_comment` tinytext NOT NULL,
38 PRIMARY KEY ( `ctracker_ticket` ),
39 UNIQUE KEY (`ctracker_ticket_remote_addr`)
41 'CREATE TABLE IF NOT EXISTS `ctracker_ticket_data` (
42 `ctracker_ticket_data_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
43 `ctracker_ticket_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
44 `ctracker_data_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
45 PRIMARY KEY ( `ctracker_ticket_data_id` ),
46 UNIQUE KEY `ctracker_ticket_data` ( `ctracker_ticket_id`,`ctracker_data_id` ),
47 INDEX ( `ctracker_data_id` ),
48 FOREIGN KEY ( `ctracker_ticket_id` ) REFERENCES `' . $GLOBALS['ctracker_dbname'] . '`.`ctracker_ticket` (
51 FOREIGN KEY ( `ctracker_data_id` ) REFERENCES `' . $GLOBALS['ctracker_dbname'] . '`.`ctracker_data` (
59 // Runs the given updates at number X
60 function runCrackerTrackerUpdates ($update) {
61 // We assume it is set
62 foreach ($GLOBALS['ctracker_updates'][$update] as $sql) {
63 // Run the SQL command
64 runCrackerTrackerSql($sql, __FUNCTION__, __LINE__);