Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 1
CRAP
n/a
0 / 0
MediaWiki\SecureLinkFixer\main
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3 * Copyright (C) 2018-2019 Kunal Mehta <legoktm@debian.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
17 */
18
19namespace MediaWiki\SecureLinkFixer;
20
21$IP = getenv( 'MW_INSTALL_PATH' );
22if ( $IP === false ) {
23    $IP = __DIR__ . '/../../..';
24}
25
26require_once "$IP/includes/libs/StaticArrayWriter.php";
27require_once __DIR__ . '/../includes/ListFetcher.php';
28
29/**
30 * Downloads Mozilla's HSTS preload list and builds it into a PHP file.
31 *
32 * We explicitly don't use Maintenance here so that this script
33 * can be run without needing all of MediaWiki to be installed.
34 */
35function main() {
36    $lf = new ListFetcher( static function ( $text ) {
37        echo $text;
38    } );
39    [ $rev, $date ] = $lf->getLatestInfo();
40    $code = $lf->fetchList( $rev, $date );
41    file_put_contents( __DIR__ . '/../domains.php', $code );
42    echo "Updated domains.php\n";
43}
44
45main();