php-general Digest 9 Jun 2007 13:31:23 -0000 Issue 4838
Topics (messages 256425 through 256437):
Intercepting fopen, mysql_connect, and similar functions for migration
256425 by: Kelly Jones
PHP Form isnt emailing me
256426 by: Austin C
256427 by: itoctopus
256435 by: Daniel Brown
Sending mail on OS X
256428 by: Christian Cantrell
256429 by: Stut
256430 by: Jim Lucas
Re: Determing Content-type from request header when Apache installed as CGI
256431 by: Tijnema
Re: Double checking - I should turn off "magic quotes"
256432 by: Dave M G
Re: high-bit characters
256433 by: WeberSites LTD
256436 by: Abdullah Ramazanoglu
Re: filesize() and mime_content_type()
256434 by: Daniel Brown
[RFC] HTTP timezone
256437 by: Stefanos Harhalakis
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
I'm migrating a website from one server to another, and my file paths
and dbs have changed.
For example /a/b/c/foo.txt on the old machine is at /x/y/z/foo.txt on
the new machine. The MySQL db "foo" on the old machine is "bar" on the
new machine.
Can I intercept fopen() and mysql_connect() so that when PHP does
fopen("/a/b/c/foo.txt"), I magically (using Zend functions or method
overloading or anything else) convert it at runtime to
fopen("/x/y/z/foo.txt").
Same thing so that mysql_connect("foo") becomes mysql_connect("bar").
The code is badly written: doing a search/replace in the code wouldn't
really work. I really want to "hook" fopen()/mysql_connect() and
similar commands so I can tweak their args before they actually
execute. Is there any hope?
Sort of like an LD_PRELOAD for PHP?
--
We're just a Bunch Of Regular Guys, a collective group that's trying
to understand and assimilate technology. We feel that resistance to
new ideas and technology is unwise and ultimately futile.
--- End Message ---
--- Begin Message ---
Hello, I just finished making a PHP contact form for my webite, and I can
run through the whole thing, and get no errors, but it doesnt email me the
form contents.
*Here is th actual form page:*
<?php include("../header.php"); ?>
<td bgcolor="#BFC4CB"><b><font color="#333333">Contact
Me</font></b></td>
</tr>
</table>
</td>
</tr>
<tr>
<td bgcolor="#BFC4CB">
<p>
<font color="#333333">
Please use this form to contact me:
<p>
<br><center><form action="processcontactform.php" method="post">
Name: <input type="text" name="name" size="20">
<br>Email Address/Method of Contact: <input type="text" name="contact"
size="30">
<br>Reason for Contact: <select name="reasonforcontact">
<option value="question">Question</option>
<option value="suggestion">Suggestion</option>
<option value="gcomment">General Comment</option>
<option value="fanmail">Fan Mail</option>
<option value="other">Other</option>
</select>
<br>Message: <br><textarea name="message1" rows="10" cols="30"></textarea>
<br><input type="submit" value="send">
</form></center>
<?php include("../footer.php"); ?>
*Here is the form page processor:*
<?php include("../header.php"); ?>
<td bgcolor="#BFC4CB">
<b>
<font color="#333333">Processing your information . . .</font></b></td>
</tr>
</table>
</td>
</tr>
<tr>
<td bgcolor="#BFC4CB">
<p>
<font color="#333333">
<?php
$name = $_POST['name'];
$email = $_POST['contact'];
$reason = $_POST['reasonforcontact'];
$message = $_POST['message1'];
$to = "[EMAIL PROTECTED]";
$subject = "Contact Form Submitted at GWD-Dev";
$body = "Hello Austin,
".$name." has sent in a contact form at GWD-Dev. The reason he/she
contacted you was for ".$reason.". Here is the message they submitted with
their form:
".$message."
The contact field of the form contained the following information:
".$email."
Please remember to get back to them ASAP!!";
$headers = "From: ".$name." <".$email.">\n";
echo "Collecting information . . . . . . . . . . DONE!<p>";
$mail_sent = @mail($to, $subject, $body, $headers);
echo $mail_sent ? "<br>Sending contact form to webmaster . . . . . . . .
DONE!<p>" : "<script>alert('The mail did not go through')</script>";
echo "<br>. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . .<p>";
echo "<br>Thank you for contacting us, please expect a reply in anywhere
from 1 to 24 hours. Make sure that our email address, [EMAIL PROTECTED]&
[EMAIL PROTECTED], are not sent to your spam folder.";
include("../footer.php"); ?>
--
Thanks, the webmaster of Galacticneo
--- End Message ---
--- Begin Message ---
Remove the @ next to the mail function, probably there's a warning
somewhere. Additionally, are you sure that your mail server is actually
working?
--
itoctopus - http://www.itoctopus.com
""Austin C"" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hello, I just finished making a PHP contact form for my webite, and I can
> run through the whole thing, and get no errors, but it doesnt email me the
> form contents.
>
> *Here is th actual form page:*
> <?php include("../header.php"); ?>
> <td bgcolor="#BFC4CB"><b><font color="#333333">Contact
> Me</font></b></td>
> </tr>
> </table>
> </td>
> </tr>
> <tr>
> <td bgcolor="#BFC4CB">
> <p>
> <font color="#333333">
> Please use this form to contact me:
> <p>
> <br><center><form action="processcontactform.php" method="post">
> Name: <input type="text" name="name" size="20">
> <br>Email Address/Method of Contact: <input type="text" name="contact"
> size="30">
> <br>Reason for Contact: <select name="reasonforcontact">
> <option value="question">Question</option>
> <option value="suggestion">Suggestion</option>
> <option value="gcomment">General Comment</option>
> <option value="fanmail">Fan Mail</option>
> <option value="other">Other</option>
> </select>
> <br>Message: <br><textarea name="message1" rows="10" cols="30"></textarea>
> <br><input type="submit" value="send">
> </form></center>
> <?php include("../footer.php"); ?>
>
> *Here is the form page processor:*
> <?php include("../header.php"); ?>
> <td bgcolor="#BFC4CB">
> <b>
> <font color="#333333">Processing your information . . .</font></b></td>
> </tr>
> </table>
> </td>
> </tr>
> <tr>
> <td bgcolor="#BFC4CB">
> <p>
> <font color="#333333">
> <?php
> $name = $_POST['name'];
> $email = $_POST['contact'];
> $reason = $_POST['reasonforcontact'];
> $message = $_POST['message1'];
>
> $to = "[EMAIL PROTECTED]";
>
> $subject = "Contact Form Submitted at GWD-Dev";
>
> $body = "Hello Austin,
>
> ".$name." has sent in a contact form at GWD-Dev. The reason he/she
> contacted you was for ".$reason.". Here is the message they submitted with
> their form:
>
>
>
> ".$message."
>
> The contact field of the form contained the following information:
> ".$email."
> Please remember to get back to them ASAP!!";
>
> $headers = "From: ".$name." <".$email.">\n";
>
>
>
> echo "Collecting information . . . . . . . . . . DONE!<p>";
>
> $mail_sent = @mail($to, $subject, $body, $headers);
>
> echo $mail_sent ? "<br>Sending contact form to webmaster . . . . . . . .
> DONE!<p>" : "<script>alert('The mail did not go through')</script>";
>
>
> echo "<br>. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
> .
> . . . .<p>";
>
> echo "<br>Thank you for contacting us, please expect a reply in anywhere
> from 1 to 24 hours. Make sure that our email address,
> [EMAIL PROTECTED]&
> [EMAIL PROTECTED], are not sent to your spam folder.";
>
>
> include("../footer.php"); ?>
>
> --
> Thanks, the webmaster of Galacticneo
>
--- End Message ---
--- Begin Message ---
On 6/8/07, itoctopus <[EMAIL PROTECTED]> wrote:
Remove the @ next to the mail function, probably there's a warning
somewhere. Additionally, are you sure that your mail server is actually
working?
--
itoctopus - http://www.itoctopus.com
""Austin C"" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hello, I just finished making a PHP contact form for my webite, and I can
> run through the whole thing, and get no errors, but it doesnt email me the
> form contents.
>
> *Here is th actual form page:*
> <?php include("../header.php"); ?>
> <td bgcolor="#BFC4CB"><b><font color="#333333">Contact
> Me</font></b></td>
> </tr>
> </table>
> </td>
> </tr>
> <tr>
> <td bgcolor="#BFC4CB">
> <p>
> <font color="#333333">
> Please use this form to contact me:
> <p>
> <br><center><form action="processcontactform.php" method="post">
> Name: <input type="text" name="name" size="20">
> <br>Email Address/Method of Contact: <input type="text" name="contact"
> size="30">
> <br>Reason for Contact: <select name="reasonforcontact">
> <option value="question">Question</option>
> <option value="suggestion">Suggestion</option>
> <option value="gcomment">General Comment</option>
> <option value="fanmail">Fan Mail</option>
> <option value="other">Other</option>
> </select>
> <br>Message: <br><textarea name="message1" rows="10" cols="30"></textarea>
> <br><input type="submit" value="send">
> </form></center>
> <?php include("../footer.php"); ?>
>
> *Here is the form page processor:*
> <?php include("../header.php"); ?>
> <td bgcolor="#BFC4CB">
> <b>
> <font color="#333333">Processing your information . . .</font></b></td>
> </tr>
> </table>
> </td>
> </tr>
> <tr>
> <td bgcolor="#BFC4CB">
> <p>
> <font color="#333333">
> <?php
> $name = $_POST['name'];
> $email = $_POST['contact'];
> $reason = $_POST['reasonforcontact'];
> $message = $_POST['message1'];
>
> $to = "[EMAIL PROTECTED]";
>
> $subject = "Contact Form Submitted at GWD-Dev";
>
> $body = "Hello Austin,
>
> ".$name." has sent in a contact form at GWD-Dev. The reason he/she
> contacted you was for ".$reason.". Here is the message they submitted with
> their form:
>
>
>
> ".$message."
>
> The contact field of the form contained the following information:
> ".$email."
> Please remember to get back to them ASAP!!";
>
> $headers = "From: ".$name." <".$email.">\n";
>
>
>
> echo "Collecting information . . . . . . . . . . DONE!<p>";
>
> $mail_sent = @mail($to, $subject, $body, $headers);
>
> echo $mail_sent ? "<br>Sending contact form to webmaster . . . . . . . .
> DONE!<p>" : "<script>alert('The mail did not go through')</script>";
>
>
> echo "<br>. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
> .
> . . . .<p>";
>
> echo "<br>Thank you for contacting us, please expect a reply in anywhere
> from 1 to 24 hours. Make sure that our email address,
> [EMAIL PROTECTED]&
> [EMAIL PROTECTED], are not sent to your spam folder.";
>
>
> include("../footer.php"); ?>
>
> --
> Thanks, the webmaster of Galacticneo
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
You're missing a hard return in your From: header field. Email
servers won't accept just an \n at the end. Instead, you have to use
\r\n. That should fix the issue, but as itoctopus said, you should
also remove the error buffering (@) from the mail function in case
there are other errors.
--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107
--- End Message ---
--- Begin Message ---
Hi, all. I'm sure this question has been asked, but I was not able to
effectively search the forum archives, so I'm having to ask it again.
I'm trying to use the mail function to send email on OS X, but the email
gets rejected by the mail server I'm sending to. I get messages in
mail.loglike this:
"The IP you're using to send email is not authorized to send email directly
to our servers."
I tried sending mail through another server using the SMTP and smtp_port
settings in my php.ini files, but the settings seem to be ignored (perhaps
they are Windows only?). Can anyone tell me how I can successfully send
test emails on OS X?
Also, the From header does seem to be getting successfully set. Is there
anything wrong with this code?
mail('[EMAIL PROTECTED]', 'php test', 'this is the message.\nthis is another
line.', 'From: [EMAIL PROTECTED]'."\n\r");
Thanks,
Christian
--- End Message ---
--- Begin Message ---
Christian Cantrell wrote:
Hi, all. I'm sure this question has been asked, but I was not able to
effectively search the forum archives, so I'm having to ask it again.
I'm trying to use the mail function to send email on OS X, but the email
gets rejected by the mail server I'm sending to. I get messages in
mail.loglike this:
"The IP you're using to send email is not authorized to send email directly
to our servers."
I tried sending mail through another server using the SMTP and smtp_port
settings in my php.ini files, but the settings seem to be ignored (perhaps
they are Windows only?). Can anyone tell me how I can successfully send
test emails on OS X?
They are Windows only.
Also, the From header does seem to be getting successfully set. Is there
anything wrong with this code?
mail('[EMAIL PROTECTED]', 'php test', 'this is the message.\nthis is another
line.', 'From: [EMAIL PROTECTED]'."\n\r");
This is a problem with the destination mail server rejecting mail from
the machine you're sending it from. It has nothing to do with the
contents of the email or with PHP. Your best bet is to email
[EMAIL PROTECTED] (or whatever the real domain you're sending to is)
and ask them why your IP cannot send mail to their mail server.
-Stut
--- End Message ---
--- Begin Message ---
Christian Cantrell wrote:
Hi, all. I'm sure this question has been asked, but I was not able to
effectively search the forum archives, so I'm having to ask it again.
I'm trying to use the mail function to send email on OS X, but the email
gets rejected by the mail server I'm sending to. I get messages in
mail.loglike this:
"The IP you're using to send email is not authorized to send email directly
to our servers."
I tried sending mail through another server using the SMTP and smtp_port
settings in my php.ini files, but the settings seem to be ignored (perhaps
they are Windows only?). Can anyone tell me how I can successfully send
test emails on OS X?
Also, the From header does seem to be getting successfully set. Is there
anything wrong with this code?
mail('[EMAIL PROTECTED]', 'php test', 'this is the message.\nthis is another
line.', 'From: [EMAIL PROTECTED]'."\n\r");
Thanks,
Christian
Coming from a mail server admin point of view, this message to me would
mean that the mail server is using a service like Postini or some other
3rd party mail filtering system, and mail servers at bar.com are
allowing mail to come from the relaying servers at the 3rd party mail
filtering system.
Just a thought.
--
Jim Lucas
"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."
Unknown
--- End Message ---
--- Begin Message ---
On 6/9/07, Richard Lynch <[EMAIL PROTECTED]> wrote:
On Fri, June 8, 2007 2:48 pm, Chris Sommers wrote:
> I read many notes on apache_request_headers() about simulating this
> function
> when Apache is configured with PHP as a CGI. In looking at the
> $_SERVER
> variable definition, I do not see the Content-Type variable listed.
> Does
> someone know how to extract this in an Apache PHP CGI configuration?
A request has a Content-type header?...
I don't think it works like that...
Never seen the Content-type header either in a request, do you mean
the Accept header?
Tijnema
--- End Message ---
--- Begin Message ---
David,
Thank you for replying.
The way you write that makes me hope you understand how
mysql_real_escape_string should be used. You do understand that you don't
run it on the query, rather on the individual string variables that will be
passed to the query.
Thank you for your concern and clarification.
I do understand the distinction, though, and although my description was
terse, what I meant was that the content that is placed within the MySQL
queries are screened with mysql_real_escapte_string, but the MySQL
syntax of the query is left alone.
I'm pretty sure if I hadn't made that distinction, my site would have
malfunctioned immediately.
Thank you for following up.
--
Dave M G
Ubuntu Feisty 7.04
Kernel 2.6.20-16-386
--- End Message ---
--- Begin Message ---
Thanks, I'll check this out.
Till now I managed to get the result I wanted with :
<?php
for ($i=0 ; $i < strlen($post_text) ; $i++) {
$chr = $post_text{$i};
$ord = ord($chr);
if (($ord<32 or $ord>126) and ($ord != 13) and ($ord !=
10)){
Echo "BAD CHAR is : " . $ord;
break;
}
}
?>
berber
-----Original Message-----
From: news [mailto:[EMAIL PROTECTED] On Behalf Of Abdullah Ramazanoglu
Sent: Friday, June 08, 2007 11:43 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Re: high-bit characters
WeberSites LTD dedi ki:
> I'm trying to validate an RSS feed and getting errors about "high-bit
> characters".
> How can I check if a string contains any high-bit characters?
if (preg_match("/[\x80-\xff]/", $string)) {
# high-bit char found
} else {
# no high-bit char
}
--
Abdullah Ramazanoglu
aramazan ÄT myrealbox D0T cöm
--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
WeberSites LTD dedi ki:
> Thanks, I'll check this out.
>
> Till now I managed to get the result I wanted with :
>
> <?php
> for ($i=0 ; $i < strlen($post_text) ; $i++) {
> $chr = $post_text{$i};
> $ord = ord($chr);
> if (($ord<32 or $ord>126) and ($ord != 13) and ($ord !=
> 10)){
> Echo "BAD CHAR is : " . $ord;
> break;
> }
> }
> ?>
My suggestion finds high-bit characters (127-255), but you need to find
printable characters with the exception of \n and \r. So my suggestion
won't work for you, I'm afraid. Perhaps you want something like below?
$bad_string_flag = ! ctype_print(strtr($string, "\n\r", " "));
>From the docs, it seems that replacement string in strtr cannot be null for
correct operation, so I've used double blanks (or use any chars,
e.g. "NR"). The strtr part feels a bit clumsy, but you might be able to
find a better way in "XVII. Character Type Functions" or "CLXI. String
Functions" (PHP Manual).
Kind regards,
Abdullah
>
>
> berber
>
> -----Original Message-----
> From: news [mailto:[EMAIL PROTECTED] On Behalf Of Abdullah Ramazanoglu
> Sent: Friday, June 08, 2007 11:43 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Re: high-bit characters
>
> WeberSites LTD dedi ki:
>
>> I'm trying to validate an RSS feed and getting errors about "high-bit
>> characters".
>> How can I check if a string contains any high-bit characters?
>
> if (preg_match("/[\x80-\xff]/", $string)) {
> # high-bit char found
> } else {
> # no high-bit char
> }
>
> --
> Abdullah Ramazanoglu
> aramazan ÄT myrealbox D0T cöm
>
> --
> PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
> http://www.php.net/unsub.php
>
--
Abdullah Ramazanoglu
aramazan ÄT myrealbox D0T cöm
--- End Message ---
--- Begin Message ---
On 6/8/07, Richard Lynch <[EMAIL PROTECTED]> wrote:
On Thu, June 7, 2007 12:04 pm, Chris Boget wrote:
>> Have you uncommented or added `extension=php_mime_magic.dll` in
>> your php.ini file for mime_content_type()? What about adding
>> something like this, as well:
>
> extension=php_mime_magic.dll is commented out in my php.ini. So that
> explains why the mime_content_type() isn't working. That's fine. Is
> this
> DLL also responsible for filesize()?
>
>> Do you have anything in the `disable_functions =` area of your
>> php.ini?
>
> No, there are no disabled functions definined in my php.ini.
The fact that filesize is "failing" and stat is "failing" when you
give a specific filename suggests to me that your filename is at
fault.
Try things like:
echo file_exists($filename); // if it's there, it should be TRUE
$path = dirname($filename);
$dir = opendir($path) or die("$path is not there\n");
while (($file = readdir($dir)) !== false){
echo $file, ": ", filesize("$path/$file"), "<br />\n";
}
This will list all the files in the directory -- which may not be the
directory you think you are looking at, ESPECIALLY if you are using
relative directories.
>
> thnx,
> Chris
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
That wouldn't explain the fatal (exit 1) status for undefined
functions though, Rich. Chris, you didn't compile this from source,
right? If you're using a binary, it should work Out Of The Box [tm].
Are you using a development version or stable? Have you noticed
problems with other functions that are expected to work?
--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107
--- End Message ---
--- Begin Message ---
Hello there,
I'm currently writting and Internet Draft candidate to describe an HTTP
header that will be used to transfer timezone information from browsers to
servers. Compliant browsers will need to send a timezone string:
Timezone: +0200
that will specify their timezone offset. This way scripts will be able to
provide appropriate date/time strings/representations and/or content.
I'm sending this email as a request for comments. Any ideas/suggestions will
be greatly appreciated and will help in forming the final document.
You can find the current draft in:
http://www.it.teithe.gr/~v13/draft-sharhalakis-httptz-02.txt
This and all future versions will be available in the IETF I-D database at:
https://datatracker.ietf.org/public/idindex.cgi
Just search for 'httptz'. Revision 02 will be available really soon in the I-D
DB too.
Please CC me since I'm not subscribed to the mailing list.
Harhalakis Stefanos
--- End Message ---