#!/usr/bin/php
<?
// cheap script with no sanity checks or security. careful!

// $argv[1] what we are looking for
// $argv[2] set to -y to actually delete

$path = `pwd`;
$path = rtrim($path);
$path .= "/out/target";

$files = `find '$path' | grep '$argv[1]'`;
$files = split("\n",$files);

foreach ($files as $file) {
	echo $file."\n";
	if (@$argv[2] == "-y") {
		if (is_file($file)) {
			@unlink($file);
		}
		if (is_dir($file)) {
			@rmdir($file);
		}
	}
}


echo "** WARNING! **\n";
echo "This script is meant for testing only. NIGHTLY builds should always be CLEAN.\n";
if (@$argv[2] == "-y") {
	echo "Deleted files.\n";
} else {
	echo "Read only, files not deleted.\n";
}
