13bfb94b0SGreg Roach<?php 23bfb94b0SGreg Roach/** 33bfb94b0SGreg Roach * webtrees: online genealogy 4*6bdf7674SGreg Roach * Copyright (C) 2017 webtrees development team 53bfb94b0SGreg Roach * This program is free software: you can redistribute it and/or modify 63bfb94b0SGreg Roach * it under the terms of the GNU General Public License as published by 73bfb94b0SGreg Roach * the Free Software Foundation, either version 3 of the License, or 83bfb94b0SGreg Roach * (at your option) any later version. 93bfb94b0SGreg Roach * This program is distributed in the hope that it will be useful, 103bfb94b0SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 113bfb94b0SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 123bfb94b0SGreg Roach * GNU General Public License for more details. 133bfb94b0SGreg Roach * You should have received a copy of the GNU General Public License 143bfb94b0SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 153bfb94b0SGreg Roach */ 1676692c8bSGreg Roachnamespace Fisharebest\Webtrees\Schema; 1776692c8bSGreg Roach 183bfb94b0SGreg Roachuse Fisharebest\Webtrees\Database; 193bfb94b0SGreg Roach 203bfb94b0SGreg Roach/** 2176692c8bSGreg Roach * Upgrade the database schema from version 17 to version 18. 223bfb94b0SGreg Roach */ 233bfb94b0SGreg Roachclass Migration17 implements MigrationInterface { 2476692c8bSGreg Roach /** 2576692c8bSGreg Roach * Upgrade to to the next version 2676692c8bSGreg Roach */ 273bfb94b0SGreg Roach public function upgrade() { 283bfb94b0SGreg Roach // Add table to control site access 293bfb94b0SGreg Roach Database::exec( 303bfb94b0SGreg Roach "CREATE TABLE IF NOT EXISTS `##site_access_rule` (" . 313bfb94b0SGreg Roach " site_access_rule_id INTEGER NOT NULL AUTO_INCREMENT," . 323bfb94b0SGreg Roach " ip_address_start INTEGER UNSIGNED NOT NULL DEFAULT 0," . 333bfb94b0SGreg Roach " ip_address_end INTEGER UNSIGNED NOT NULL DEFAULT 4294967295," . 343bfb94b0SGreg Roach " user_agent_pattern VARCHAR(255) NOT NULL," . 353bfb94b0SGreg Roach " rule ENUM('allow', 'deny', 'robot', 'unknown') NOT NULL DEFAULT 'unknown'," . 363bfb94b0SGreg Roach " comment VARCHAR(255) NOT NULL," . 373bfb94b0SGreg Roach " updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP," . 383bfb94b0SGreg Roach " PRIMARY KEY (site_access_rule_id)" . 393bfb94b0SGreg Roach ") ENGINE=InnoDB COLLATE=utf8_unicode_ci" 403bfb94b0SGreg Roach ); 413bfb94b0SGreg Roach 423bfb94b0SGreg Roach Database::exec( 433bfb94b0SGreg Roach "INSERT IGNORE INTO `##site_access_rule` (user_agent_pattern, rule, comment) VALUES" . 443bfb94b0SGreg Roach " ('Mozilla/5.0 (%) Gecko/% %/%', 'allow', 'Gecko-based browsers')," . 453bfb94b0SGreg Roach " ('Mozilla/5.0 (%) AppleWebKit/% (KHTML, like Gecko)%', 'allow', 'WebKit-based browsers')," . 463bfb94b0SGreg Roach " ('Opera/% (%) Presto/% Version/%', 'allow', 'Presto-based browsers')," . 473bfb94b0SGreg Roach " ('Mozilla/% (compatible; MSIE %', 'allow', 'Trident-based browsers')," . 483bfb94b0SGreg Roach " ('Mozilla/5.0 (compatible; Konqueror/%', 'allow', 'Konqueror browser')" 493bfb94b0SGreg Roach ); 503bfb94b0SGreg Roach } 513bfb94b0SGreg Roach} 52