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
|
|
|
|
|
2019-12-16 23:17:47 +08:00
|
|
|
|
define('ROOT_DIR', __DIR__ . '/');
|
2018-10-04 21:34:10 +08:00
|
|
|
|
set_time_limit(600);
|
2019-12-14 16:23:37 +08:00
|
|
|
|
error_reporting(0);
|
2019-10-19 19:39:59 +08:00
|
|
|
|
|
2017-12-31 20:18:41 +08:00
|
|
|
|
if(PHP_SAPI != 'cli'){
|
|
|
|
|
die('nothing.');
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-16 23:17:47 +08:00
|
|
|
|
require ROOT_DIR . 'lib/writerFormat.class.php';
|
|
|
|
|
require ROOT_DIR . 'lib/addressMaker.class.php';
|
2019-12-17 20:01:16 +08:00
|
|
|
|
$arr_blacklist = require ROOT_DIR . 'lib/black_domain_list.php';
|
|
|
|
|
$arr_whitelist = require ROOT_DIR . 'lib/white_domain_list.php';
|
2017-12-31 20:18:41 +08:00
|
|
|
|
|
2019-12-16 23:17:47 +08:00
|
|
|
|
$arr_result = array();
|
2019-12-16 22:17:17 +08:00
|
|
|
|
$easylist = file_get_contents('./origin-files/base-src-easylist.txt');
|
|
|
|
|
$arr_result = array_merge_recursive($arr_result, addressMaker::get_domain_from_easylist($easylist));
|
2018-10-04 21:34:10 +08:00
|
|
|
|
|
2019-12-16 22:17:17 +08:00
|
|
|
|
$hosts = file_get_contents('./origin-files/base-src-hosts.txt');
|
|
|
|
|
$arr_result = array_merge_recursive($arr_result, addressMaker::get_domain_list($hosts));
|
2018-10-08 10:59:06 +08:00
|
|
|
|
|
2019-12-17 20:01:16 +08:00
|
|
|
|
$arr_result = array_merge_recursive($arr_result, $arr_blacklist);
|
|
|
|
|
|
2019-12-17 21:20:41 +08:00
|
|
|
|
$reflect = new ReflectionClass('writerFormat');
|
|
|
|
|
|
|
|
|
|
$formatterList = $reflect->getConstants();
|
|
|
|
|
$arr_output = array();
|
|
|
|
|
|
|
|
|
|
foreach ($formatterList as $name => $formatObj){
|
|
|
|
|
$arr_output[] = '['. $name . ']' . addressMaker::write_to_conf($arr_result, $formatObj);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo implode('---', $arr_output);
|
2019-12-14 10:45:22 +08:00
|
|
|
|
|
|
|
|
|
|