All pastes #424545 Raw Edit

Untitled

public text v1 · immutable
·published 2007-04-04 21:14 UTC
rendered paste body
<?echo '<?xml version="1.0" encoding="utf8"?>';?>

<?
function parseIndexTag($patern, $filename, $fct) {
	$f = get_file_utf8($filename);
	
	if (trim($f[0]) <> $patern) return "invalid patern";
	
	$f[0] = "";
	
	while(list($key, $line) = each($f)) {
		$line = trim($line);
		if (substr($line, 0, 1) == "[") {
			$file = trim(substr($line, 1, -1));
			if (isset($tag))
				$fct($file, $tag);
			$item = $file;
			$tag = array();
		}	
		else if (ereg("^#", $line))
			echo "\n".$line;
			
		else if ($line <> '') {
			list($field, $value) = explode("=", $line);
			$field = trim($field);
			$value = trim($value);
			$tag[$field] = $value;
		}

	}
}
?>

<index name="Swac_Index_Tags">


$url = 'http://packs.shtooka.net/fra-balm-voc/flac/index.tags.txt';


function echoTag($key, $tag) {
	echo "\n<item name=\"$key\">";
	while (list($field, $value) = each($tag))
		echo "\n  <field name=\"$field\">$value</field>";
	echo "\n</item>\n\n";
}


parseIndexTag("\\Swac_Index_Tags", $url, "echoTag");

?>

</index>