#!/usr/bin/php . // Copyright © 2007-2014 Erwan Briand // // This program is free software: you can redistribute it and/or modify it // under the terms of the GNU Affero General Public License as published by // the Free Software Foundation, version 3 only. // // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public // License for more details. // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . /* Upgrade from 0.9 to 0.9.1 * * This script add new SQL configuration keys to the database and update the * SQL tables schema. * * Once this script is executed, you just have to create the new briefcase * folder in public/upload (as it stands in the INSTALL file). I put my trust * in you to replace old PHP files of your forge by the recent one. Oh, and you * have to update your inc/codingteam.cfg too (take a look at INSTALL). * * A real install/upgrade script would be cool, yeah. Stay tuned. */ // But where are we? $base = dirname(__FILE__); $whereis = '/scripts/miscellaneous'; $length = -mb_strlen($whereis); $basedir = mb_substr($base, 0, $length); define('CT_BASEDIR', $basedir); // Check if the configuration file exist if (!file_exists($basedir.'/inc/codingteam.cfg')) die ('There are no configuration file. CodingTeam cannot start.'); // Read the configuration and connect to the database layer $xml = simplexml_load_file($basedir.'/inc/codingteam.cfg'); $db_type = $xml->db->type; $db_hostname = $xml->db->hostname; $db_database = $xml->db->database; $db_username = $xml->db->username; $db_password = $xml->db->password; // Database connection require($basedir.'/inc/classes/db.php'); $ct_db = new Database($db_type, $db_hostname, $db_database, $db_username, $db_password); // New SQL configuration keys $config = array( array('global', 'show-exectime', 'false', 'true or false if you want to hide execution time.'), array('global', 'show-informationbox', 'true', 'true or false if you want to hide the search bar.'), array('global', 'force-login', 'false', 'true or false if you want to make your forge public.'), array('global', 'briefcase-max', '20', 'The maximum size (in Mo) allowed for each user\'s briefcase.'), array('projects', 'allow-private', 'false', 'true or false if you don\'t want private projects.') ); foreach ($config as $key) $ct_db->insert('config', array('group' => $key[0], 'field' => $key[1], 'value' => $key[2], 'text' => $key[3])); // Update table schemas $rules = array( 'ALTER TABLE `projects` ADD `is_private` tinyint(1) NOT NULL AFTER `is_valid`', 'ALTER TABLE `projects_bugs` CHANGE `authorid` `registered_id` INT(11) NOT NULL', 'ALTER TABLE `projects_bugs` ADD `unregistered_nick` tinytext collate utf8_bin NOT NULL AFTER `allow_nl2br`', 'ALTER TABLE `projects_bugs` ADD `author_ip` varchar(15) collate utf8_bin NOT NULL AFTER `registered_id`', 'ALTER TABLE `projects_bugs` ADD `milestone` varchar(15) collate utf8_bin NOT NULL AFTER `version`', 'ALTER TABLE `projects_bugs_answers` CHANGE `authorid` `registered_id` INT(11) NOT NULL', 'ALTER TABLE `projects_bugs_answers` ADD `unregistered_nick` tinytext collate utf8_bin NOT NULL AFTER `allow_nl2br`', 'ALTER TABLE `projects_bugs_answers` ADD `author_ip` varchar(15) collate utf8_bin NOT NULL AFTER `registered_id`', 'ALTER TABLE `projects_bugs_log` CHANGE `authorid` `registered_id` INT(11) NOT NULL', 'ALTER TABLE `projects_bugs_log` ADD `unregistered_nick` tinytext collate utf8_bin NOT NULL AFTER `projectid`', 'ALTER TABLE `projects_bugs_log` ADD `author_ip` varchar(15) collate utf8_bin NOT NULL AFTER `registered_id`', 'ALTER TABLE `projects_bugs_log` ADD `milestone` varchar(15) collate utf8_bin NOT NULL AFTER `version`', ); foreach ($rules as $rule) { $rs = $ct_db->dbclass->prepare($rule); $rs->execute(); } ?>