All pastes #414348 Raw Edit

Stuff

public php v1 · immutable
#414348 ·published 2007-03-29 00:03 UTC
rendered paste body
<?php chdir(dirname(__FILE__));//Written by GeorgeMoney//you need php 5//files: sites.txt is input, output.txt and stdout is output. Errors go to errors.txt//Now remember, it APPENDS to output.txt, //so if you want to erase the old contents you must physically clear the fileini_set('display_errors', 0);error_reporting(E_ALL);ini_set('error_log', 'errors.txt');$list = @file('sites.txt');echo "***Parsing list\n";$newlist = array();foreach($list as $key=>$val) {	$safe = true;	//primary parsing: removing blank lines and stripping comments	$val = trim($val);	$tmpval = explode('#', $val);	$val = trim($tmpval[0]);	if($val == "") { continue; }	//now parse for foo(bar|baz)	if(preg_match('/\([^)]+\)/', $val)) {		preg_match_all('/\(([^)]+)\)/', $val, $vlist);		$val = preg_replace('/\([^)]+\)/', '', $val);		foreach($vlist[1] as $vval) {			$xlist = explode("|", $vval);			foreach($xlist as $xval) {				$newlist[] = $val.trim($xval);			}		}		$safe = false;	}	if($safe) $newlist[] = $val;}$list = &$newlist;unset($newlist);foreach($list as $site) {	$ips = gethostbynamel($site);	if($ips === false) continue;	foreach($ips as $ip) {		file_put_contents('output.txt', "$site=$ip\n", FILE_APPEND);		echo "$site=$ip\n";	}}echo "***DONE\n";?>