anti-AD/make-addr.php

52 lines
1.5 KiB
PHP
Raw Normal View History

2017-12-31 20:18:41 +08:00
<?php
2019-12-14 10:45:22 +08:00
/**
* 根据下载的原始文件生成dnsmasq的屏蔽广告用途的配置
*
* @file make-addr.php
* @author gently
* @date 2017.12.31
*
*
*/
2017-12-31 20:18:41 +08:00
2018-10-04 21:34:10 +08:00
set_time_limit(600);
2017-12-31 20:18:41 +08:00
2019-12-14 16:23:37 +08:00
error_reporting(0);
2017-12-31 20:18:41 +08:00
if(PHP_SAPI != 'cli'){
die('nothing.');
}
2019-12-14 10:45:22 +08:00
require('./lib/addressMaker.class.php');
2019-12-14 19:15:13 +08:00
$arr_blacklist = require('./lib/black_domain_list.php');
$arr_whitelist = require('./lib/white_domain_list.php');
2017-12-31 20:18:41 +08:00
$arr_result = array();
2019-12-14 10:45:22 +08:00
$easylist1 = file_get_contents('./origin-files/easylistchina+easylist.txt');
$arr_result = array_merge_recursive($arr_result, addressMaker::get_domain_from_easylist($easylist1));
2018-10-04 21:34:10 +08:00
2019-12-14 10:45:22 +08:00
$easylist2 = file_get_contents('./origin-files/cjx-annoyance.txt');
$arr_result = array_merge_recursive($arr_result, addressMaker::get_domain_from_easylist($easylist2));
2018-10-04 21:34:10 +08:00
2019-12-14 10:45:22 +08:00
$easylist3 = file_get_contents('./origin-files/fanboy-annoyance.txt');
$arr_result = array_merge_recursive($arr_result, addressMaker::get_domain_from_easylist($easylist3));
2019-11-01 00:48:07 +08:00
2019-12-14 10:45:22 +08:00
$host1 = file_get_contents('./origin-files/hosts1');
$arr_result = array_merge_recursive($arr_result, addressMaker::get_domain_list($host1));
2017-12-31 20:18:41 +08:00
2019-12-14 10:45:22 +08:00
$host2 = file_get_contents('./origin-files/hosts2');
$arr_result = array_merge_recursive($arr_result, addressMaker::get_domain_list($host2));
2017-12-31 20:18:41 +08:00
2019-12-14 10:45:22 +08:00
$host3 = file_get_contents('./origin-files/hosts3');
$arr_result = array_merge_recursive($arr_result, addressMaker::get_domain_list($host3));
2019-11-01 01:21:54 +08:00
$arr_result = array_merge_recursive($arr_result, $arr_blacklist);
2018-10-08 10:59:06 +08:00
echo 'Written file size:';
2019-12-14 10:45:22 +08:00
echo addressMaker::write_to_conf($arr_result, './adblock-for-dnsmasq.conf', 'q-filter.conf');