This is more of a curiosity than anything. The comment system on my site automatically generates an email to me whenever a comment is posted. In it is a link to approve the comment, and a link to deny the comment.
这比什么都有趣。我的网站上的评论系统会自动生成一封邮件给我,只要有评论被发布。其中有一个批准评论的链接,以及一个拒绝评论的链接。
$my_headers = 'MIME-Version: 1.0' . "\n";
$my_headers .= 'Content-type: text/html; charset=iso-8859-1' . "\n";
$my_headers .= 'From: MYSITE.com <ealert@mysite.com>' . "\n";
$subject = "Comment Received";
$messagei = "Comment from " . addslashes($_POST['commentName']) ." on ".addslashes($title)."." . "<br /><br />" .addslashes($commentCommment);
$messagei .= "<br /><br />
<strong>OPTIONS:</strong>
<br /><br /><a href='http://www.MYSITE.com/edit/instaprove.php?Approve=Approve&commentid=".$lastID."'>
<h2>http://www.MYSITE.com/edit/instaprove.php?Approve=Approve&commentid=".$lastID."</h2> (Approve Comment)</a>
<br /><br /><br /><a href='http://www.MYSITE.com/edit/instaprove.php?Remove=Remove&commentid=".$lastID."'>
<h2>http://www.MYSITE.com/edit/instaprove.php?Remove=Remove&commentid=".$lastID."</h2> (Delete Comment)</a>";
mail('comments@mysite.com',$subject,$messagei,$my_headers,"-fealert@mysite.com");
99% of the time it works just fine, but every once in a while, instead of generating the approval link correctly, as in
99%的情况下,它可以正常工作,但是每隔一段时间,而不是正确地生成审批链接,比如in
http://www.mysite.com/edit/instaprove.php?Approve=Approve&commentid=142631
,
http://www.mysite.com/edit/instaprove.php?Approve=Approve&commentid=142631,
it generates it with a space in it, so the link I get in the email goes to
它产生了一个空间,所以我收到的邮件链接到
http://www.mysite.com/edit/instaprove.ph%20p?Approve=Approve&commentid=142631
http://www.mysite.com/edit/instaprove.ph%20p?Approve=Approve&commentid=142631
Strange, no?
奇怪,不是吗?
Edit: For clarification - When this happens, the link is written out in the email correctly (.php
), but the link it goes to is broken (.ph p
).
编辑:澄清一下——当这种情况发生时,链接被正确地写在电子邮件中(.php),但是链接被破坏了(。ph值p)。
Edit 8/12: It just happened again. The link text is correct:
编辑8/12:再次发生。链接文本是正确的:
http://www.mysite.com/edit/instaprove.php?Approve=Approve&commentid=142858
http://www.mysite.com/edit/instaprove.php?Approve=Approve&commentid=142858
but the link renders as
但是链接呈现为
http://www.mysite.com/edit/%20instaprove.php?Approve=Approve&commentid=142858
http://www.mysite.com/edit/%20instaprove.php?Approve=Approve&commentid=142858
So, when it does show up, the mystery space is showing up at different points in the link.
所以,当它出现的时候,这个神秘的空间就会出现在链接的不同点上。
2 个解决方案
#1
6
I had a similar problem with spaces and also strange "!\n" appearing in the source of my email.
我对空间也有类似的问题,而且很奇怪!\n"出现在我的电子邮件来源。
This was because of very long lines. Adding some "\n" in the content of the email solve the problem.
这是因为队伍很长。在邮件内容中添加一些“\n”可以解决问题。
#2
1
This is pretty strange.. You may want to just do a string replace on the URL itself replace any whitespace with no characters since it apparently sometimes grabs a random whitespace somehow.
这是很奇怪的。您可能想要在URL本身上做一个字符串替换,替换任何没有字符的空白,因为它显然有时会捕获一个随机空格。
str_replace(" ", "", "http://www.MYSITE.com/edit/instaprove.php?Approve=Approve&commentid=12304728")
It is a pretty strange problem.
这是一个相当奇怪的问题。
My only other option in thought would be to change the charset to UTF-8
我的另一个想法是将字符集改为UTF-8
#1
6
I had a similar problem with spaces and also strange "!\n" appearing in the source of my email.
我对空间也有类似的问题,而且很奇怪!\n"出现在我的电子邮件来源。
This was because of very long lines. Adding some "\n" in the content of the email solve the problem.
这是因为队伍很长。在邮件内容中添加一些“\n”可以解决问题。
#2
1
This is pretty strange.. You may want to just do a string replace on the URL itself replace any whitespace with no characters since it apparently sometimes grabs a random whitespace somehow.
这是很奇怪的。您可能想要在URL本身上做一个字符串替换,替换任何没有字符的空白,因为它显然有时会捕获一个随机空格。
str_replace(" ", "", "http://www.MYSITE.com/edit/instaprove.php?Approve=Approve&commentid=12304728")
It is a pretty strange problem.
这是一个相当奇怪的问题。
My only other option in thought would be to change the charset to UTF-8
我的另一个想法是将字符集改为UTF-8