alert($email);”;
$email_len = strlen($email);
if($email_len < 8 || strpos($email, ‘@’)==false)
die(‘Error: the email address is invalid.’);
$file = file_get_contents(‘c:\example\mailing list.txt’);
if(!$file)
die(‘Error: failed to load mailing list.’);
$file_length = strlen($file);
$found = false;
$i = 0;
while(true) {
$j = stripos($file, $email, $i);
if($j===false)
break;
$ch = $file[$j – 1];
if($ch==”\r” || $ch==”\n” || $ch=='<‘ || $ch==’ ‘ || $ch=='”‘ || $j==0) {
$ch = $file[$j + $email_len];
if($ch==”\r” || $ch==”\n” || $ch==’>’ || $ch==’ ‘ || $ch=='”‘) {
// $k is the end of the line
$k = $j + $email_len;
while($k < $file_length) {
$ch = $file[$k];
if($ch==”\r” || $ch==”\n”)
break;
$k += 1;
}
$ch = $file[$k];
if($ch==”\r” || $ch==”\n”) {
$k += 1;
$ch = $file[$k];
if($ch==”\r” || $ch==”\n”)
$k += 1;
}
// move $j to the beginning of the line
while($j > 0) {
$ch = $file[$j – 1];
if($ch==”\r” || $ch==”\n”)
break;
$j -= 1;
}
$file = substr_replace($file, “”, $j, $k – $j);
$found = true;
$i = $j;
continue;
}
}
$i = $j + $email_len;
}
if(!$found)
echo ‘Your email address was not found in the mailing list.’;
else {
file_put_contents(‘c:\example\mailing list.txt’, $file);
echo ‘You have been removed from the mailing list.’;
}
?>