Forum Moderators: coopster
I have a portion of it running via cron to handle the automated checking for links, emailing webmasters when my link is removed etc.
Up until recently it worked perfectly on every site it is running on (about 10). Suddenly, I have started getting the error mention in the title of this thread. It basically says..
FATAL: emalloc(): Unable to allocate 268675669 bytes
With the number of bytes varying. I have no idea what is suddenly causing this.
Any ideas of places to look?
My sendmail function is fairly basic and looks like the following:
function sendmail($fromname,$fromemail,$toemail,$ccemail,$bccemails,$subject,$message)
{
if (is_array($bccemails))
{
$bccstring=join(",",$bccemails);
}
$headers = "From: \"".$fromname."\"<".$fromemail.">\n";
$headers .= "X-Sender: <".$fromemail.">\n";
$headers .= "X-Priority: 3\n";
$headers .= "Return-Path: ".$fromemail."\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/plain; charset=iso-8859-1\n";
if ($ccemail!="")
{
$headers .= "cc: ".$ccemail."\n"; // CC to
}
if ($bccemails!="")
{
$headers .= "bcc: ".$bccstring."\n";
}
//echo $headers;
//$message="<HTML><BODY>".$message."</BODY></HTML>";
mail("$toemail","$subject","$message","$headers","-f $fromemail");
}
Any ideas?
Also, which version of PHP is running on the problem server?
<edit>Can that ODBC/SQL idea, there are all kinds of hits on the bugs pages in past versions regarding all different functions, including mail(). Let's go with the second question though, which version of PHP and which OS?
Well, It is happening on a few different sites at two different hosting providers.
On one host it's 4.3.11 and the other host is 4.3.10
AGain, these were working perfectly up until about 5 days ago.
I also have a couple of other sites running this script at the same hosting provider with no errors at all.
The issue is this part was coded for me and while I have developed a pretty good understanding of PHP over the past year and a half, I'm not sure where the problem in this function is.
The function is basically designed to strip out any javascript on the page leaving only the html. The entire contents of the page is passed to this function in the $html string and the function returns the html without any javascript in it.
This is the function
function strip_tag_script($html) {
$pos1 = false;
$pos2 = false;
do {
if ($pos1!== false && $pos2!== false) {
$first = NULL;
$second = NULL;
if ($pos1 > 0)
$first = substr($html, 0, $pos1);
if ($pos2 < strlen($html) - 1)
$second = substr($html, $pos2);
$html = $first . $second;
}
preg_match("/<script[^>]*>/i", $html, $matches);
$str1 =& $matches[0];
preg_match("/<\/script>/i", $html, $matches);
$str2 =& $matches[0];
$pos1 = strpos($html, $str1);
$pos2 = strpos($html, $str2);
if ($pos2!== false)
$pos2 += strlen($str2);
} while ($pos1!== false && $pos2!== false);
return $html;
}
Whatever the issue, the program is not getting past this function.
ANY help would be appreciated.