Author |
Message |
linuxtad
New Member


Joined: Mar 26, 2006
Posts: 9
|
Posted:
Wed Mar 29, 2006 5:43 am |
|
Hello,
I would really appreciate some help with this. Within the Email Groups feature when you input text into the text area, upon sending the email it treats carriage returns as spaces. Input text looks like:
Quote: |
Text here
and
Here.
|
Current output that is sent via Email looks like:
Quote: |
Text here and Here.
|
Here is the code for NSNGroupsUsersEmail.php:
Code:
<?php
/********************************************************/
/* NSN Groups */
/* By: NukeScripts Network (webmaster@nukescripts.net) */
/* http://www.nukescripts.net */
/* Copyright © 2000-2005 by NukeScripts Network */
/********************************************************/
$pagetitle = _GR_ADMIN." ".$gr_config['version_number'].": "._GR_GROUPSEMAIL;
include("header.php");
title("$pagetitle");
NSNGroupsAdmin();
echo "<br>\n";
OpenTable();
echo "<center><form method='post' action='".$admin_file.".php'>\n";
echo "<b>"._GR_TYPE.":</b> <select name='etype'>\n";
echo "<option value='0'>"._GR_TEXT."</option>\n<option value='1'>"._GR_HTML."</option>\n";
echo "</select><br><br>\n";
echo "<b>"._GR_FROMA.":</b> $aname<br><br>\n";
echo "<b>"._GR_TO.":</b> <select name='gid'>\n";
echo "<option value='0'>"._GR_ALLGR."</option>\n";
$result = $db->sql_query("SELECT `gid`, `gname` FROM `".$prefix."_nsngr_groups` ORDER BY `gname`");
while (list($gid, $gname) = $db->sql_fetchrow($result)) { echo "<option value='$gid'>$gname</option>\n"; }
echo "</select><br><br>\n";
echo "<b>"._GR_SUB.":</b> <input type='text' name='gsubject' size='50'><br><br>\n";
echo "<b>"._GR_MES.":</b><br><textarea name='gcontent' $textrowcol></textarea><br><br>\n";
echo "<input type='hidden' name='aname' value='$aname'>\n";
echo "<input type='hidden' name='amail' value='$amail'>\n";
echo "<input type='hidden' name='op' value='NSNGroupsUsersEmailSend'>\n";
echo "<input type='submit' value='"._GR_SEND."'>\n";
echo "</form>";
CloseTable();
include("footer.php");
?>
|
Here is the code for NSNGroupsUsersEmailSend.php:
Code:
<?php
/********************************************************/
/* NSN Groups */
/* By: NukeScripts Network (webmaster@nukescripts.net) */
/* http://www.nukescripts.net */
/* Copyright © 2000-2005 by NukeScripts Network */
/********************************************************/
$gcontent = nl2br(stripslashes($gcontent));
$headers = "MIME-Version: 1.0\n";
if($etype < 1) {
$headers .= "Content-Type: text/plain; charset=iso-8859-1\n";
$gcontent .= "\n--------------------\n"._GR_THANK.";\n$aname <$amail>";
} else {
$headers .= "Content-Type: text/html; charset=iso-8859-1\n";
$gcontent .= "<hr>"._GR_THANK.";<br><a href='mailto:$amail'>$aname</a>";
}
$headers .= "From: $aname <$amail>\r\n";
$headers .= "Return-Path: $amail\r\n";
$headers .= "Reply-To: $amail\r\n";
$headers .= "X-Mailer: NSN Groups";
if($gid == 0) {
$gsubject = "[$sitename "._GR_GLET."]: ".stripslashes($gsubject)."";
$result = $db->sql_query("SELECT `uid` FROM `".$user_prefix."_nsngr_users`");
while(list($guid) = $db->sql_fetchrow($result)) {
list($email) = $db->sql_fetchrow($db->sql_query("SELECT `user_email` FROM `".$user_prefix."_users` WHERE `user_id`='$guid'"));
$to = ""._GR_GLET." <$email>";
mail($to, $gsubject, $gcontent, $headers);
}
Header("Location: ".$admin_file.".php?op=NSNGroups");
} else {
list($gname) = $db->sql_fetchrow($db->sql_query("SELECT `gname` FROM `".$prefix."_nsngr_groups` WHERE `gid`='$gid'"));
$gsubject = "[$gname "._GR_GLET."]: ".stripslashes($gsubject)."";
$result = $db->sql_query("SELECT `uid` FROM `".$prefix."_nsngr_users` WHERE `gid`='$gid'");
while(list($guid) = $db->sql_fetchrow($result)) {
list($email) = $db->sql_fetchrow($db->sql_query("SELECT `user_email` FROM `".$user_prefix."_users` WHERE `user_id`='$guid'"));
$to = "$gname <$email>";
mail($to, $gsubject, $gcontent, $headers);
}
Header("Location: ".$admin_file.".php?op=NSNGroups");
}
?>
|
After attempting a fix, I found that be changing line 10 in the file NSNGroupsUsersEmailSend.php from:
Code:$gcontent = stripslashes($gcontent);
|
To
Code:$gcontent = nl2br(stripslashes($gcontent));
|
I can select Type: HTML and email it displays correctly. If I use Type: Text and Email, I get the following:
Code:Test event!!<br /> Description: This is a test event!! The Portland Zoo!<br /> <br />
|
What is a workable solution for this so that a user can have the text appear as intended regardless of HTML or TEXT Type selection?
Best regards,
Thomas |
|
|
|
 |
Guardian2003
Site Admin

Joined: Aug 28, 2003
Posts: 6799
Location: Ha Noi, Viet Nam
|
Posted:
Wed Mar 29, 2006 6:07 am |
|
As far as I know, only admin can email groups anyway.
Use the html BR tag for cariage returns |
|
|
|
 |
montego
Site Admin

Joined: Aug 29, 2004
Posts: 9457
Location: Arizona
|
Posted:
Wed Mar 29, 2006 6:17 am |
|
The nl2br function should only be used if the option you are after is the HTML send because it is going to replace all your "newlines" (carriage returns) to a <br /> HTML tag, which is the valid HTML equivalent.
Try placing an IF statement around your change so that it only does that when your admin selected the HTML option. |
_________________ Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! |
|
|
 |
linuxtad

|
Posted:
Wed Mar 29, 2006 6:58 am |
|
Hello,
Thank you for your replies. I decided to make it easy on the other Admins, I left the nl2br function and then edited the file NSNGroupsUsersEmail.php line
Code:
echo "<option value='0'>"._GR_TEXT."</option>\n<option value='1'>"._GR_HTML."</option>\n";
|
To
Code:
echo "<option value='1'>"._GR_HTML."</option>\n";
|
Removing the option to send Type of "Text".
Someday I will learn the correct way, when the "easy" way does not work lol
I like the idea of the "IF" statement but I am unsure how to write it out so that it would work correctly, my feeble attempts failed
Much appreciated!
Best regards,
TAd |
|
|
|
 |
TAd
Worker


Joined: Oct 11, 2004
Posts: 127
Location: Oregon, USA
|
Posted:
Wed Mar 29, 2006 7:02 am |
|
Look at that, I lost 9 posts to that name Thanks Raven for fixing my Email address! |
|
|
|
 |
|