#!/usr/bin/php $key, "field" => $field ); } $c=fopen($csv,"r"); $header=fgetcsv($c,false,$delim); $data=""; while ($row=fgetcsv($c,false,$delim)) { if (count($row)==1 && trim($row[0])=="") continue; $p=get_replacements($header,$row); $hostr=preg_replace($p["patterns"],$p["replacements"],$host); foreach ($items as $item) { $data.=sprintf("%s %s %s\n", $hostr, preg_replace($p["patterns"],$p["replacements"],$item["key"]), addcslashes(preg_replace($p["patterns"],$p["replacements"],$item["field"]),"\0..\40\"") ); } } fclose($c); if ($mode=="send") { $h = popen(getenv("ZAF_BIN")." send", "w"); fputs($h,$data); fclose($h); exit; } if ($mode=="stdout") { echo $data; exit; } fprintf(STDERR,"Bad mode $mode\n!"); exit(1);