You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
anti-AD/make-addr.php

46 lines
1.2 KiB
PHP

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?php
/**
* 根据下载的原始文件生成dnsmasq的屏蔽广告用途的配置
*
* @file make-addr.php
* @author gently
* @date 2017.12.31
*
*
*/
define('ROOT_DIR', __DIR__ . '/');
set_time_limit(600);
error_reporting(0);
if(PHP_SAPI != 'cli'){
die('nothing.');
}
$arr_blacklist = require ROOT_DIR . 'lib/black_domain_list.php';
$arr_whitelist = require ROOT_DIR . 'lib/white_domain_list.php';
require ROOT_DIR . 'lib/writerFormat.class.php';
require ROOT_DIR . 'lib/addressMaker.class.php';
$arr_result = array();
$easylist = file_get_contents('./origin-files/base-src-easylist.txt');
$arr_result = array_merge_recursive($arr_result, addressMaker::get_domain_from_easylist($easylist));
$hosts = file_get_contents('./origin-files/base-src-hosts.txt');
$arr_result = array_merge_recursive($arr_result, addressMaker::get_domain_list($hosts));
$arr_result = array_merge_recursive($arr_result, $arr_blacklist);
$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);