'#c0c0c0','#e0cf35'=>'#b8b8b8'); $patched=0; $br="\n"; echo (empty($argc)?'
':''),'searching for SVG in ',$path,$br;
foreach (array('1f31','f09f8c9') as $base) { // handles both original and binary named files
for ($pass=0;$pass<2;$pass++) { // search uppercase and lowercase filenames
for ($i=1;$i<14;$i++) { // since not all systems support glob braces
$name=$base.dechex($i); $name=$pass?strtoupper($name):strtolower($name);
$file=$path.($name=$name.'.svg');
if (is_file($file) && is_writable($file)) {
if ($name!==basename(realpath($file))) { continue; } // case-insensitive systems
$data=file_get_contents($file);
$size=strlen($data);
$count=0;
foreach ($replace as $old=>$new) {
$data=str_replace('fill="'.$old.'"','fill="'.$new.'"',$data,$replaced);
$count+=$replaced;
}
if ($count) {
$count=file_put_contents($file,$data);
if ($count===false || $count!=$size) { echo 'Error writing: ',$name,$br; }
else { echo 'Successfully patched: ',$name,$br; $patched++; }
} else { echo 'Did not patch: ',$name,$br; }
}
}
}
} echo str_repeat('-', 50),$br,$patched,' total SVG files patched',$br;