This is what the file(/etc/postfix/virtual) looks like:
Left side is address
Right side is user
addy1@bob.com usr0001
addy2@jogn.net usr003
bigwilly@none.net jogn
bob@one.com usr0001
john@code.au jogn
This is what the code looks like:
<code>
//vars
$users[]="";
static $add=0;
static $countA=0;
static $countB=0;
//Place file in array
$filearray=file("/etc/postfix/virtual");
while (list ($line_num, $line) = each($filearray))
{
//Is the line an address?
if(ereg("@", $line) && !ereg("#", $line))
{
//Split the address and user
//0 : addy //1 : user
$line=explode(" ", $line);
//Add user
if($line[1]!="")
{
$current=chop($line[1]);
$add=1;
++$countA;
$countB=0;
while(list($index, $value)=each($users))
{
++$countB;
$value=chop($value);
//print("<option>$countA:$countB-$current:$value");
if(strcmp($current, $value)==0)
$add=0;
}
if($add)
{
$users[]=$current;
print("<option>$current");
}
}
}
}
?>
</code>
This code is supposed to read in the lines and parse out the user. It's supposed to eliminate any redundancy at the same time.
I've spent many days trying to debug this and came to the conclusion that theres something in php that I'm missing. I could do this in a sec in C++, oh well.