Hi there,
Ok - This is the error I get,
Warning: 2 is not a valid File-Handle resource in
/usr/local/apache/htdocs/mm_edit.php on line 359
But this is the code... I marked line 359 where it attempts to call fputs
for the first time. I can't seem to understand how this is failing. I really
think it is not the code. I am really stumped.
function write()
{
global $db;
global $domain;
//Notice that I exit if it can't open the file... That is not the
//the problem
if(!$domainfile=fopen("/tmp/$domain", "w"))
{
die("Failed to open domain file");
}
echo("<P>DEBUG /tmp/$domain -- $domainfile<BR>");
$result = $db->Execute("SELECT * FROM addresses WHERE
domain='$domain'");
if ($result === false)
{
die("SQL Failed");
}
while(!$result->EOF)
{
list($dom,$ext)=split("\.",$domain);
$virt_address=$result->fields[1];
$dest=$result->fields[2];
$default=$result->fields[3];
echo("<P>DEBUG $virt_address $dest $default<BR>");
list($virt_user,$virt_domain)=split("\@", $virt_address);
list($remote_user,$remote_domain)=split("\@", $dest);
//If the destination is a remote address and this is a NOT a
default
if($remote_domain && !($default))
{
//this is line 359 - the first call to fputs
fputs($domainfile, "$virt_address");
echo("$virt_address");
fputs($domainfile, ": $virt_user$dom$ext\n");
echo(": $virt_user$dom$ext<BR>");
if(!$courierfile=fopen("/tmp/.courier-$virt_user$dom$ext", "w"))
{
echo "Could not open file....";
}
fputs($courierfile, "$dest\n");
fclose($courierfile);
//If the destination is a local address and this is
NOT a default
}
elseif(!($remote_domain) && !($default))
{
fputs($domainfile, "$virt_address");
fputs($domainfile, ": $remote_user\n");
}
//If it's a default we don't care where it is going, just
write a .courier-domext-default with the address
//And stick line in the the domain file that looks like this
"@dom.com: domcom-default"
elseif($default)
{
fputs($domainfile, "$virt_address");
fputs($domainfile, ": $dom$ext-default\n");
if(!$courierfile=fopen("/tmp/.courier-$dom$ext-default", "w"))
{
echo "Could not open file....";
}
fputs($courierfile, "$dest\n");
fclose($courierfile);
}
$result->MoveNext();
system("mv /tmp/.changes /tmp/$domain");
#system("/usr/local/sbin/changewriter $domain &>
/tmp/cw_error");
fclose($domainfile);
}
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php