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