xref: /webtrees/app/Schema/Migration17.php (revision 3bfb94b0b402ff08e5888afb946384316f6d3e60)
1*3bfb94b0SGreg Roach<?php
2*3bfb94b0SGreg Roachnamespace Fisharebest\Webtrees\Schema;
3*3bfb94b0SGreg Roach
4*3bfb94b0SGreg Roach/**
5*3bfb94b0SGreg Roach * webtrees: online genealogy
6*3bfb94b0SGreg Roach * Copyright (C) 2015 webtrees development team
7*3bfb94b0SGreg Roach * This program is free software: you can redistribute it and/or modify
8*3bfb94b0SGreg Roach * it under the terms of the GNU General Public License as published by
9*3bfb94b0SGreg Roach * the Free Software Foundation, either version 3 of the License, or
10*3bfb94b0SGreg Roach * (at your option) any later version.
11*3bfb94b0SGreg Roach * This program is distributed in the hope that it will be useful,
12*3bfb94b0SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
13*3bfb94b0SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14*3bfb94b0SGreg Roach * GNU General Public License for more details.
15*3bfb94b0SGreg Roach * You should have received a copy of the GNU General Public License
16*3bfb94b0SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
17*3bfb94b0SGreg Roach */
18*3bfb94b0SGreg Roachuse Fisharebest\Webtrees\Database;
19*3bfb94b0SGreg Roach
20*3bfb94b0SGreg Roach/**
21*3bfb94b0SGreg Roach * Class Migration17 - upgrade the database schema from version 17 to version 18.
22*3bfb94b0SGreg Roach */
23*3bfb94b0SGreg Roachclass Migration17 implements MigrationInterface {
24*3bfb94b0SGreg Roach	/** {@inheritDoc} */
25*3bfb94b0SGreg Roach	public function upgrade() {
26*3bfb94b0SGreg Roach		// Add table to control site access
27*3bfb94b0SGreg Roach		Database::exec(
28*3bfb94b0SGreg Roach			"CREATE TABLE IF NOT EXISTS `##site_access_rule` (" .
29*3bfb94b0SGreg Roach			" site_access_rule_id INTEGER          NOT NULL AUTO_INCREMENT," .
30*3bfb94b0SGreg Roach			" ip_address_start     INTEGER UNSIGNED NOT NULL DEFAULT 0," .
31*3bfb94b0SGreg Roach			" ip_address_end       INTEGER UNSIGNED NOT NULL DEFAULT 4294967295," .
32*3bfb94b0SGreg Roach			" user_agent_pattern   VARCHAR(255)     NOT NULL," .
33*3bfb94b0SGreg Roach			" rule                 ENUM('allow', 'deny', 'robot', 'unknown') NOT NULL DEFAULT 'unknown'," .
34*3bfb94b0SGreg Roach			" comment              VARCHAR(255)     NOT NULL," .
35*3bfb94b0SGreg Roach			" updated              TIMESTAMP        NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP," .
36*3bfb94b0SGreg Roach			" PRIMARY KEY     (site_access_rule_id)" .
37*3bfb94b0SGreg Roach			") ENGINE=InnoDB COLLATE=utf8_unicode_ci"
38*3bfb94b0SGreg Roach		);
39*3bfb94b0SGreg Roach
40*3bfb94b0SGreg Roach		Database::exec(
41*3bfb94b0SGreg Roach			"INSERT IGNORE INTO `##site_access_rule` (user_agent_pattern, rule, comment) VALUES" .
42*3bfb94b0SGreg Roach			" ('Mozilla/5.0 (%) Gecko/% %/%', 'allow', 'Gecko-based browsers')," .
43*3bfb94b0SGreg Roach			" ('Mozilla/5.0 (%) AppleWebKit/% (KHTML, like Gecko)%', 'allow', 'WebKit-based browsers')," .
44*3bfb94b0SGreg Roach			" ('Opera/% (%) Presto/% Version/%', 'allow', 'Presto-based browsers')," .
45*3bfb94b0SGreg Roach			" ('Mozilla/% (compatible; MSIE %', 'allow', 'Trident-based browsers')," .
46*3bfb94b0SGreg Roach			" ('Mozilla/5.0 (compatible; Konqueror/%', 'allow', 'Konqueror browser')"
47*3bfb94b0SGreg Roach		);
48*3bfb94b0SGreg Roach	}
49*3bfb94b0SGreg Roach}
50