1
votes

I have add some php code in my drupal site. When i tried to run it it showing a warning like

"Warning: Please contact support about failure in php_eval() (line 80 of /folderpath../modules/php/php.module)."

In line 80 of that php.module contains

ob_start();
print eval('?>' . $code);
$output = ob_get_contents();
ob_end_clean();

Actually it was a php code to send mail...

Anybody please help to find out this...

Thanks in advance

This was the code i have written for sending mail...

    $strTo = $_POST["txtTo"];
$strSubject = $_POST["txtSubject"];
$strMessage = nl2br($_POST["txtDescription"]);

//*** Uniqid Session ***//
$strSid = md5(uniqid(time()));

$strHeader = "";
$strHeader .= "From: ".$_POST["txtFormName"]."<".$_POST["txtFormEmail"].">\nReply-To: ".$_POST["txtFormEmail"]."";

$strHeader .= "MIME-Version: 1.0\n";
$strHeader .= "Content-Type: multipart/mixed; boundary=\"".$strSid."\"\n\n";
$strHeader .= "This is a multi-part message in MIME format.\n";

$strHeader .= "--".$strSid."\n";
$strHeader .= "Content-type: text/html; charset=utf-8\n";
$strHeader .= "Content-Transfer-Encoding: 7bit\n\n";
$strHeader .= $strMessage."\n\n";

//*** Attachment ***//
if($_FILES["fileAttach"]["name"] != "")
{
    $strFilesName = $_FILES["fileAttach"]["name"];
    $strContent = chunk_split(base64_encode(file_get_contents($_FILES["fileAttach"]["tmp_name"]))); 
    $strHeader .= "--".$strSid."\n";
    $strHeader .= "Content-Type: application/octet-stream; name=\"".$strFilesName."\"\n"; 
    $strHeader .= "Content-Transfer-Encoding: base64\n";
    $strHeader .= "Content-Disposition: attachment; filename=\"".$strFilesName."\"\n\n";
    $strHeader .= $strContent."\n\n";
}


$flgSend = @mail($strTo,$strSubject,null,$strHeader);  // @ = No Show Error //

if($flgSend)
{
    echo "Mail send completed.";
}
else
{
    echo "Cannot send mail.";
}
2
Can you echo $code and update question so we can see if there any error in evaluation script . I suspect it may have "?>" or something which may cause the error - Shridhar
@sridhar i have removed that ?> and placed...but still showing same error... - Ann
Does send mail script is standard php script or it is drupal module. If it is then check permission or try running code with admin user. I guess if you copy paste your $code script then I can check it at my end. - Shridhar
Or just check eval function with simple script. $code = "<? echo 'hello'; ?>" and pass it to drupal eval . If you get same error then drupal eval is not available . Possible Permission issue. - Shridhar
I have added the code . could you plz check it... - Ann

2 Answers

1
votes

It looks like your host doesn't allow execution of the eval() function, which is common as it can be used in various exploit scripts to hack a server. Chances are they won't allow you to use it either as it could compromise the whole server, you need to change hosts!

0
votes

Changing host won't solve the problem, my Ubuntu server allows the eval() function but I get the same error reported in the Apache log:

  1. This is the Apache error: PHP Parse error: syntax error, unexpected T_STRING in /home/websites/domainname/modules/php/php.module(80) : eval()'d code on line 3

2.The php.module is using the function "php_eval: You can view it here: http://api.drupal.org/api/drupal/modules%21php%21php.module/function/php_eval/7

Line 80 is this: print eval('?>' . $code);

If I remove the . $code then no error is reported so i don't think its the php tags. There is no fault on the website, just the error log is growing for each visitor.

  1. You can test if eval() function is allowed and running on your server with this code:

Further note that I am using the GoVideo Theme and the eval function script is displaying 3 x urls at the bottom of the front page. The 3 x URLs are pointing to Youtube, Flickr and facebook. You can view them here (stroll to the bottom). http://govideo.themesnap.net/

To make it clear; if I remove the $code variable then I loose the 3 x Urls on the front page.