Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Apache2 and new php build [solved..again]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
marky9074
Apprentice
Apprentice


Joined: 24 Sep 2004
Posts: 196
Location: UK

PostPosted: Mon Apr 03, 2006 8:59 am    Post subject: Apache2 and new php build [solved..again] Reply with quote

Hi guys,

I have just had to do an install from scratch after a botched world update....

Anyway, now we have the new php package I have had to add a few USE flags to get it going with phpmyadmin and phpBB, these being the 'pcre' and 'session' flags. Now, I did not do this with mod_php, so maybe this info will be of some use to people......

Now the only problem I have is that for some reason my php mail script is not doing anything in apache2. Before when I had problems with courier it would at least come back with an error saying the mail hadnt gone, but at the moment I get nothing, just the forms refreshed blank, and nothing whatsover in the logs.....

So I think it is a php build issue but I cannot be sure as I have a new apache2 and php installation so it could be either!

Can anyone shed some light on the problem?

Thanks,

Mark


Last edited by marky9074 on Thu Apr 06, 2006 7:58 am; edited 3 times in total
Back to top
View user's profile Send private message
marky9074
Apprentice
Apprentice


Joined: 24 Sep 2004
Posts: 196
Location: UK

PostPosted: Mon Apr 03, 2006 9:01 am    Post subject: Reply with quote

This is the script (I have changed the email addresses!)....


<?php
// -----------------------------------------------------------------------------------------
// Simple E-Mail Form
// Version 1.0
// By H G Laughland
//
// Web site: http://www.laughland.biz
//
// This script may be freely used and shared. The author
// is not responsible for any problems arising from its use.
//
//--------------------------------------------------------------------------------------------

//----- Set these to variables to your name & e-mail address ---------------------------------
$fname = "Web Site Response"; // Name to be shown in from details.
$toemail = "email@email.com"; // E-mail address to be shown in from details.

//-------------------------------------------------------------------------------------------

if(!isset($action)){

?>

<?php include("ssi1.htm");?>

</head>
<BODY leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" background="images/bgb.gif">

<?php include("ssi2.htm");?>

<span class="zagol">• <strong>Contact Us</strong></span><br>
<br> <div align="justify" class="content">Please feel free to fill
in the contact form below indicating the services you require, and
one of our independent advisors will get back to you as soon as
possible: </div>
<form name="form1" method="post" action="contact.php">
<input name="action" type="hidden" value="send">
<table width="461" border="0" cellspacing="0" cellpadding="2" class="content">
<tr>
<td width="182">Your Email Address:</td>
<td width="271"><input name="femail" type="text" size="30" class="content"></td>
</tr>
<tr>
<td>Services Required:</td>
<td><input name="subject" type="text" size="30" class="content"></td>
</tr>
<tr>
<td valign="top">Message:</td>
<td><textarea name="message" type="text" class="content" rows="5" cols="30"></textarea>
</td>
</tr>
<tr>
<td>Mail Format:</td>
<td>text&nbsp;<input name="rdType" type="radio" value="0" checked>&nbsp;&nbsp;html&nbsp;<input name="rdType" type="radio" value="1">
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td> <input name="cmdSend" type="submit" value="send"> &nbsp;
<input name="cmdReset" type="reset" value="reset"> </td>
</tr>
</table>
</form>
<br>

<?php include("ssi3.htm");?>

<?php
}else{
$from = $fname . "<$femail>";
$headers = "From: $from \r\n";
if($rdType == 1){
$headers .= "MIME-Version: 1.0\n" . "Content-type: text/html; charset=iso-8859-1";
$message = stripslashes($message);
}else{
$headers .= "MIME-Version: 1.0\n" . "Content-type: text/plain; charset=iso-8859-1";
}
$ok = @mail($toemail, $subject, $message, $headers);
if ($ok) {header("Location: success.shtml");
} else {
header("Location: failure.shtml");
}
exit;
}
?>

</BODY>
</HTML>


Last edited by marky9074 on Tue Apr 04, 2006 11:11 am; edited 3 times in total
Back to top
View user's profile Send private message
SoTired
Apprentice
Apprentice


Joined: 19 May 2004
Posts: 174

PostPosted: Mon Apr 03, 2006 6:18 pm    Post subject: Reply with quote

Do you have sendmail or ssmtp or something to get the mail off the system?

You may want to check sendmail_path in php.ini and make sure whatever it is calling is working correctly.
Back to top
View user's profile Send private message
marky9074
Apprentice
Apprentice


Joined: 24 Sep 2004
Posts: 196
Location: UK

PostPosted: Mon Apr 03, 2006 7:55 pm    Post subject: Reply with quote

Yeah, I had the default ssmtp which didnt work, then I emerged courier and that doesnt work either...will check the file and report back...
Back to top
View user's profile Send private message
marky9074
Apprentice
Apprentice


Joined: 24 Sep 2004
Posts: 196
Location: UK

PostPosted: Mon Apr 03, 2006 8:04 pm    Post subject: Reply with quote

It calls sendmail as default and sendmail is there (but not installed as a package, think this is just link to courier, though not a sym link...)
Back to top
View user's profile Send private message
SoTired
Apprentice
Apprentice


Joined: 19 May 2004
Posts: 174

PostPosted: Mon Apr 03, 2006 8:09 pm    Post subject: Reply with quote

Can't help you with courier, never used it. For ssmtp, if you want to give it another try, it really should work provided you've edited your /etc/ssmtp/ssmtp.conf file properly.
Back to top
View user's profile Send private message
marky9074
Apprentice
Apprentice


Joined: 24 Sep 2004
Posts: 196
Location: UK

PostPosted: Tue Apr 04, 2006 6:35 am    Post subject: Reply with quote

I dont 'actually' think it is a mail problem, I think it is a php problem. As if it was a mail problem and the mail 'failed' the php would take you to a failure page, it just isnt doing anything (apart from clearing the fields), which makes me think that it is a php problem...

Mark
Back to top
View user's profile Send private message
marky9074
Apprentice
Apprentice


Joined: 24 Sep 2004
Posts: 196
Location: UK

PostPosted: Tue Apr 04, 2006 9:15 am    Post subject: Reply with quote

OK, I have set up courier and can get mail out of the box, so I know it is not anything to do with the mail system....it is either apache2 or php...... :cry:

I have set up sqwebmail and that croaks when I log in with:

Internal error (module sqconfig.c, line 77) - contact system administrator

I think this has got something to do with it as well as this is on php...

Mark
Back to top
View user's profile Send private message
marky9074
Apprentice
Apprentice


Joined: 24 Sep 2004
Posts: 196
Location: UK

PostPosted: Tue Apr 04, 2006 11:06 am    Post subject: Reply with quote

Ok so I tested this simple code and it got sent....so my other php is not working properly (it did before)

<?php
mail("email@email.com", test, test);
?>


Last edited by marky9074 on Tue Apr 04, 2006 12:47 pm; edited 1 time in total
Back to top
View user's profile Send private message
marky9074
Apprentice
Apprentice


Joined: 24 Sep 2004
Posts: 196
Location: UK

PostPosted: Tue Apr 04, 2006 11:23 am    Post subject: Reply with quote

damn.....it is something to do with the php as I have just used 'FormToEmail' and it has sent OK. Can anyone see anything wrong with the code? The only thing I noticed was the @ in front of mail. I have been using this script for about four years, and now all of a sudden after a fresh install it doesnt work....
Back to top
View user's profile Send private message
stuherbert
Retired Dev
Retired Dev


Joined: 17 Aug 2003
Posts: 47
Location: Pontypridd, South Wales

PostPosted: Tue Apr 04, 2006 12:07 pm    Post subject: Reply with quote

Looks like your script is relying on register_globals being on ... and on Gentoo it's off by default.

Best regards,
Stu
_________________
--
stuart@gentoo.org
Gentoo Developer
Trustee, Gentoo Foundation
http://blog.stuartherbert.com
Back to top
View user's profile Send private message
marky9074
Apprentice
Apprentice


Joined: 24 Sep 2004
Posts: 196
Location: UK

PostPosted: Tue Apr 04, 2006 12:45 pm    Post subject: Reply with quote

Cheers Stu,

At least I hope this will help other people if they have had a radical upgrade, below is some text from the php site, definately sounds like the reason, but I have changed it over to 'Formtoemail' now...

As always, everyones help was much appreciated...

Mark
--------------------

Perhaps the most controversial change in PHP is when the default value for the PHP directive register_globals went from ON to OFF in PHP 4.2.0. Reliance on this directive was quite common and many people didn't even know it existed and assumed it's just how PHP works. This page will explain how one can write insecure code with this directive but keep in mind that the directive itself isn't insecure but rather it's the misuse of it.

http://uk.php.net/register_globals
Back to top
View user's profile Send private message
tomk
Bodhisattva
Bodhisattva


Joined: 23 Sep 2003
Posts: 7221
Location: Sat in front of my computer

PostPosted: Tue Apr 04, 2006 1:26 pm    Post subject: Reply with quote

It's important to note that there can be security implications when you have register_globals enabled so it's better to write code that doesn't rely on it being enabled. So in contact.php the variables $femail, $subject, $rdType and $message should be obtained from the $_POST array e.g. $_POST['femail']
_________________
Search | Read | Answer | Report | Strip
Back to top
View user's profile Send private message
marky9074
Apprentice
Apprentice


Joined: 24 Sep 2004
Posts: 196
Location: UK

PostPosted: Tue Apr 04, 2006 1:32 pm    Post subject: Reply with quote

Yeah, this is what I am using now, hopefully a bit better...

Mark

----

<?php

/*

Enter the email address below to send the form to:

*/

$my_email = "email@email.com";

/*

*/

// This line prevents values being entered in a URL

if ($_SERVER['REQUEST_METHOD'] != "POST"){exit;}

// Check for disallowed characters in the Name and Email fields.

$disallowed_services = array(':',';',"'",'"','=','(',')','{','}','@');

foreach($disallowed_services as $value)
{

if(stristr($_POST[Name],$value)){header("location: $_SERVER[HTTP_REFERER]");exit;}

}

$disallowed_email = array(':',';',"'",'"','=','(',')','{','}');

foreach($disallowed_email as $value)
{

if(stristr($_POST[Email],$value)){header("location: $_SERVER[HTTP_REFERER]");exit;}

}

$message = "";

// This line prevents a blank form being sent

while(list($key,$value) = each($_POST)){if(!(empty($value))){$set=1;}$message = $message . "$key: $value\n\n";} if($set!==1){header("location: $_SERVER[HTTP_REFERER]");exit;}

$message = stripslashes($message);

$subject = "email.com web site response";
$headers = "From: " . $_POST['Email'] . "\n" . "Return-Path: " . $_POST['Email'] . "\n" . "Reply-To: " . $_POST['Email'] . "\n";

mail($my_email,$subject,$message,$headers);

?>
Back to top
View user's profile Send private message
marky9074
Apprentice
Apprentice


Joined: 24 Sep 2004
Posts: 196
Location: UK

PostPosted: Tue Apr 04, 2006 1:55 pm    Post subject: Reply with quote

...damn finger trouble ignore this post

Last edited by marky9074 on Thu Apr 06, 2006 7:57 am; edited 1 time in total
Back to top
View user's profile Send private message
marky9074
Apprentice
Apprentice


Joined: 24 Sep 2004
Posts: 196
Location: UK

PostPosted: Tue Apr 04, 2006 3:06 pm    Post subject: Reply with quote

...damn finger trouble ignore this post

Last edited by marky9074 on Thu Apr 06, 2006 7:57 am; edited 1 time in total
Back to top
View user's profile Send private message
marky9074
Apprentice
Apprentice


Joined: 24 Sep 2004
Posts: 196
Location: UK

PostPosted: Tue Apr 04, 2006 4:51 pm    Post subject: Reply with quote

...damn finger trouble ignore this post
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum