Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules
Author Message
linuxtad
New Member
New Member



Joined: Mar 26, 2006
Posts: 9

PostPosted: Wed Mar 29, 2006 5:43 am Reply with quote

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
 
View user's profile Send private message
Guardian2003
Site Admin



Joined: Aug 28, 2003
Posts: 6799
Location: Ha Noi, Viet Nam

PostPosted: Wed Mar 29, 2006 6:07 am Reply with quote

As far as I know, only admin can email groups anyway.
Use the html BR tag for cariage returns
Code:
<br />
 
View user's profile Send private message Send e-mail
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Wed Mar 29, 2006 6:17 am Reply with quote

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.

_________________
Where Do YOU Stand?
HTML Newsletter::ShortLinks::Mailer::Downloads and more... 
View user's profile Send private message Visit poster's website
linuxtad







PostPosted: Wed Mar 29, 2006 6:58 am Reply with quote

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 Embarassed

Much appreciated!
Best regards,
TAd
 
TAd
Worker
Worker



Joined: Oct 11, 2004
Posts: 127
Location: Oregon, USA

PostPosted: Wed Mar 29, 2006 7:02 am Reply with quote

Look at that, I lost 9 posts to that name Smile Thanks Raven for fixing my Email address!
 
View user's profile Send private message Yahoo Messenger
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules

View next topic
View previous topic
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
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©