| 1 |
sysadm |
1.1 |
<?
|
| 2 |
|
|
|
| 3 |
|
|
if (!isset($_SERVER["argc"]) || $_SERVER["argc"] != 2)
|
| 4 |
|
|
{
|
| 5 |
|
|
echo "Error usage\n";
|
| 6 |
|
|
exit(1);
|
| 7 |
|
|
}
|
| 8 |
|
|
|
| 9 |
|
|
$file = $_SERVER["argv"][1];
|
| 10 |
|
|
|
| 11 |
|
|
$skip_itemname_list = array("tbk", "ibk", "aqv", "cqv", "key", "isc", "tsc");
|
| 12 |
|
|
$skip_itemuid_list = array();
|
| 13 |
|
|
$skip_char_list = array();
|
| 14 |
|
|
|
| 15 |
|
|
$fp = fopen($file, "r")
|
| 16 |
|
|
or die("Open input file failed");
|
| 17 |
|
|
|
| 18 |
|
|
$last_name = "";
|
| 19 |
|
|
$last_uid = "";
|
| 20 |
|
|
$last_char = "";
|
| 21 |
|
|
|
| 22 |
|
|
$match = false;
|
| 23 |
|
|
|
| 24 |
|
|
while($line = fscanf($fp, "%s\t%s\t%s"))
|
| 25 |
|
|
{
|
| 26 |
|
|
list($item_name, $item_uid, $char) = $line;
|
| 27 |
|
|
|
| 28 |
|
|
if (in_array($item_name, $skip_itemname_list) || in_array($item_uid, $skip_itemuid_list) || in_array($char, $skip_char_list))
|
| 29 |
|
|
{
|
| 30 |
|
|
continue;
|
| 31 |
|
|
}
|
| 32 |
|
|
|
| 33 |
|
|
if (strcmp($item_name, $last_name) == 0 && strcmp($item_uid, $last_uid) == 0)
|
| 34 |
|
|
{
|
| 35 |
|
|
echo $last_name."\t".$last_uid."\t".$last_char."\n";
|
| 36 |
|
|
$last_char = $char;
|
| 37 |
|
|
$match = true;
|
| 38 |
|
|
}
|
| 39 |
|
|
else
|
| 40 |
|
|
{
|
| 41 |
|
|
if ($match)
|
| 42 |
|
|
{
|
| 43 |
|
|
echo $last_name."\t".$last_uid."\t".$last_char."\n\n";
|
| 44 |
|
|
$match = false;
|
| 45 |
|
|
}
|
| 46 |
|
|
$last_name = $item_name;
|
| 47 |
|
|
$last_uid = $item_uid;
|
| 48 |
|
|
$last_char = $char;
|
| 49 |
|
|
}
|
| 50 |
|
|
}
|
| 51 |
|
|
|
| 52 |
|
|
fclose($fp);
|
| 53 |
|
|
|