diff --git a/fetch_hosts.php b/fetch_hosts.php index 93f4330..56eba61 100644 --- a/fetch_hosts.php +++ b/fetch_hosts.php @@ -40,14 +40,6 @@ "objects.githubusercontent.com" ]; -function hosts_write($filename, $content) -{ - $fs = fopen($filename, 'w+'); - fwrite($fs, $content); - fflush($fs); - fclose($fs); -} - $github_hosts = []; $hosts_content = "# fetch-github-host begin\n"; foreach ($github_urls as $url) { @@ -60,8 +52,8 @@ function hosts_write($filename, $content) $template = file_get_contents('index-template.php'); file_put_contents('index.php', str_replace('', $utc_date, $template)); -hosts_write('hosts.txt', $hosts_content); -hosts_write('hosts.json', json_encode($github_hosts)); +file_put_contents('hosts.txt', $hosts_content); +file_put_contents('hosts.json', json_encode($github_hosts)); echo "fetch success! ($utc_date)";