Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> General/Other Stuff
Author Message
Truden
New Member
New Member



Joined: Dec 14, 2004
Posts: 18
Location: Johannesburg/South Africa

PostPosted: Fri May 13, 2005 12:36 pm Reply with quote

Hi Friends,

Before I put my request for help, I'd like to thank you guys for all the great job you are doing.
Thank You.

I don't know if I can ask for help that does not concern your product, but I'll give a try Smile

I modified Submit News module, combining it with Recommend Us, so any post will be send by email to recipient.
You can see the module working at http://forgiveness.truden.com
Please do not post if you don't really need to do it.
The posted is approved automatically and get published immediately.
Any anonymous can post.

My problem is that the email has all that <br> at the end of all lines.
I did try different ways to clean it up, but if the mail is clean, the article doesn't have new lines (nl2br).

Before to give you the code I'd like you to know that I'm not programmer, but carpenter.
I learned to read php by myself, and started to make changes for my own needs.
If you see any bad parts in the code, please correct me.

Thank you in advance for your help.
Do not wary if you don't have time for me.
I can understand you Smile

Here is the index.php for Submit News module:
Code:
<?php


/************************************************************************/
/* PHP-NUKE: Web Portal System                                          */
/* ===========================                                          */
/*                                                                      */
/* Copyright (c) 2002 by Francisco Burzi                                */
/* http://phpnuke.org                                                   */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/*                                                                      */
/************************************************************************/
/*         Additional security & Abstraction layer conversion           */
/*                           2003 chatserv                              */
/*      http://www.nukefixes.com -- http://www.nukeresources.com        */
/************************************************************************/

if ( !defined('MODULE_FILE') )
{
   die("You can't access this file directly...");
}
@require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
get_lang($module_name);
$pagetitle = "- "._SUBMITNEWS."";

function defaultDisplay() {
    global $AllowableHTML, $prefix, $user, $cookie, $anonymous, $currentlang, $multilingual, $db, $module_name;
    @include('header.php');
    OpenTable();
    echo "<center><font class=\"title\"><b>"._SUBMITNEWS."</b></font><br><br>";
    echo "<font class=\"content\"><i>"._SUBMITADVICE."</i></font></center><br>";
    CloseTable();
    echo "<br>";
    OpenTable();
    if (is_user($user)) getusrinfo($user);
    echo "<table width=\"100%\"  border=\"0\" cellspacing=\"4\" cellpadding=\"0\"><form action=\"modules.php?name=$module_name\" method=\"post\">";
    echo "<br><br>"
       ."<tr><td><b>"._FYOURNAME." </b></td><td width=\"70%\"> <input type=\"text\" name=\"yname\" value=\"$yn\" size=\"35\"> <font color=\"red\">*</font></td></tr>\n"
      ."<tr><td><b>"._FYOUREMAIL." </b></td><td width=\"70%\"> <input type=\"text\" name=\"ymail\" value=\"$ye\" size=\"35\"> <font color=\"red\">*</font></td></tr>\n"
      ."<tr><td><b>"._FFRIENDNAME." </b></td><td width=\"70%\"> <input type=\"text\" name=\"fname\" size=\"35\"> <font color=\"red\">*</font></td></tr>\n"
            ."<tr><td><b>"._FFRIENDEMAIL." </b></td><td width=\"70%\"> <input type=\"text\" name=\"fmail\" size=\"35\"> <font color=\"red\">*</font></td></tr></table><br><br>\n"
        ."<br><br><b>"._SUBTITLE."</b> "
        ."<input type=\"text\" name=\"subject\" size=\"50\" maxlength=\"80\"><br><font class=\"content\"></font>"
        ."<br>"
        ."<b>"._TOPIC.":</b> <select name=\"topic\"><br>";
    $result = $db->sql_query("SELECT topicid, topictext FROM ".$prefix."_topics ORDER BY topictext");
    echo "<option value=\"\">"._SELECTTOPIC."</option><br>\n";
    while ($row = $db->sql_fetchrow($result)) {
   $topicid = intval($row['topicid']);
   $topics = stripslashes(check_html($row['topictext'], "nohtml"));
        if ($topicid == $topic) {
       $sel = "selected ";
   }
       echo "<option $sel value=\"$topicid\">$topics</option><br>\n";
   $sel = "";
    }
    echo "<br><br>";
    echo "</select>";
    if ($multilingual == 1) {
   echo "<br><br><b>"._LANGUAGE.": </b>"
       ."<select name=\"alanguage\">";
   $handle=opendir('language');
   while ($file = readdir($handle)) {
       if (preg_match("/^lang\-(.+)\.php/", $file, $matches)) {
           $langFound = $matches[1];
           $languageslist .= "$langFound ";
       }
   }
   closedir($handle);
   $languageslist = explode(" ", $languageslist);
   sort($languageslist);
   for ($i=0; $i < sizeof($languageslist); $i++) {
       if($languageslist[$i]!="") {
      echo "<option value=\"$languageslist[$i]\" ";
       if($languageslist[$i]==$currentlang) echo "selected";
      echo ">".ucfirst($languageslist[$i])."</option>\n";
       }
   }
   echo "</select>";
    } else {
   echo "<input type=\"hidden\" name=\"alanguage\" value=\"$language\">";
    }
   echo "<br><br>"
        ."<b>"._STORYTEXT."</b> <i>("._HTMLISFINE.")</i>:<br>"
   ."<textarea cols=\"50\" rows=\"12\" maxlength=\"255\" name=\"story\"></textarea><br>"
        ."<br><br><b>"._EXTENDEDTEXT."</b> <i>("._THEREST.")</i>:<br>"
   ."<textarea cols=\"50\" rows=\"12\" name=\"storyext\"></textarea><br>"
   ."</font><br><br>"
        ."<font class=\"content\">"._ALLOWEDHTML."<br>";
    while (list($key,) = each($AllowableHTML)) echo " &lt;".$key."&gt;";
        echo "<br><br>"
   ."<select name=\"posttype\">\n"
   ."<option value=\"exttrans\" selected>"._EXTRANS."</option>\n"
   ."<option value=\"html\" >"._HTMLFORMATED."</option>\n"
   ."<option value=\"plaintext\">"._PLAINTEXT."</option>\n"
   ."</select>";
    echo "<br><br><input type=\"submit\" name=\"op\" value=\""._PREVIEW."\">&nbsp;&nbsp;"
   ."<br></form>";
    CloseTable();
    @include('footer.php');
}

function PreviewStory($name, $address, $subject, $story, $storyext, $topic, $alanguage, $posttype, $yname, $fname, $fmail, $ymail) {
    global $user, $cookie, $bgcolor1, $bgcolor2, $anonymous, $prefix, $multilingual, $AllowableHTML, $db, $module_name, $yname, $fname, $fmail, $ymail;
    @include('header.php');
    $fname = stripslashes(FixQuotes(check_html(removecrlf($fname))));
    $fmail = stripslashes(FixQuotes(check_html(removecrlf($fmail))));
    $yname = stripslashes(FixQuotes(check_html(removecrlf($yname))));
    $ymail = stripslashes(FixQuotes(check_html(removecrlf($ymail))));
    $subject = stripslashes(check_html($subject, "nohtml"));
    $story = stripslashes($story);
    $storyext = stripslashes($storyext);
    $f_story = nl2br($story);
   $f_storyext = nl2br($storyext);
    $story2 = "$f_story<br><br>$f_storyext";
    OpenTable();
    echo "<center><font class=\"title\"><b>"._NEWSUBPREVIEW."</b></font>";
    CloseTable();
    echo "<br>";
    OpenTable();
    if ($fname == "" || $fmail == "" || $yname == "" || $ymail == "") {
   echo "<br><br><br><center><font class=\"title\">"._TEXTFIELD."</font><br><br>";
   }else{
    echo "<center><b>$yname, </b><i>"._STORYLOOK."</i></center><br><br>";
    echo "<table width=\"70%\" bgcolor=\"$bgcolor2\" cellpadding=\"0\" cellspacing=\"1\" border=\"0\"align=\"center\"><tr><td>"
   ."<table width=\"100%\" bgcolor=\"$bgcolor1\" cellpadding=\"8\" cellspacing=\"1\" border=\"0\"><tr><td>";
    if ($topic=="") {
        $topicimage="AllTopics.gif";
        $warning = "<center><blink><b>"._SELECTTOPIC."</b></blink></center>";
    } else {
        $warning = "";
        $row = $db->sql_fetchrow($db->sql_query("SELECT topicimage FROM ".$prefix."_topics WHERE topicid='$topic'"));
   $topicimage = stripslashes($row['topicimage']);
    }
    echo "<img src=\"images/topics/$topicimage\" border=\"0\" align=\"right\">";
    themepreview($subject, $story2);
    echo "$warning"
   ."</td></tr></table></td></tr></table>"
   ."<br><br>";
}
    CloseTable();
    echo "<br>";
    OpenTable();
    echo "<table width=\"100%\"  border=\"0\" cellspacing=\"4\" cellpadding=\"0\"><form action=\"modules.php?name=$module_name\" method=\"post\">";
        echo "<br><br>"
       ."<tr><td><b>"._FYOURNAME." </b></td><td width=\"70%\"><input type=\"text\" name=\"yname\" value=\"$yname\" size=\"35\"> <font color=\"red\">*</font></td></tr>\n"
      ."<tr><td><b>"._FYOUREMAIL." </b></td><td width=\"70%\"> <input type=\"text\" name=\"ymail\" value=\"$ymail\" size=\"35\"> <font color=\"red\">*</font></td></tr>\n"
      ."<tr><td><b>"._FFRIENDNAME." </b></td><td width=\"70%\"> <input type=\"text\" name=\"fname\" value=\"$fname\" size=\"35\"> <font color=\"red\">*</font></td></tr>\n"
            ."<tr><td><b>"._FFRIENDEMAIL." </b></td><td width=\"70%\"> <input type=\"text\" name=\"fmail\" value=\"$fmail\" size=\"35\"> <font color=\"red\">*</font></td></tr></table><br><br>\n";
    echo "<br><br><b>"._SUBTITLE.":</b><br>"
   ."<input type=\"text\" name=\"subject\" size=\"50\" maxlength=\"80\" value=\"$subject\">"
   ."<br><br><b>"._TOPIC.": </b><select name=\"topic\">";
    $result2 = $db->sql_query("SELECT topicid, topictext FROM ".$prefix."_topics ORDER BY topictext");
    echo "<OPTION VALUE=\"\">"._SELECTTOPIC."</option>\n";
    while ($row2 = $db->sql_fetchrow($result2)) {
   $topicid = intval($row2['topicid']);
   $topics = stripslashes(check_html($row2['topictext'], "nohtml"));
        if ($topicid == $topic) {
       $sel = "selected ";
   }
   echo "<option $sel value=\"$topicid\">$topics</option><br>\n";
   $sel = "";
    }
    echo "</select>";
    echo "<br><br>";
    if ($multilingual == 1) {
   echo "<br><br><b>"._LANGUAGE.": </b>"
       ."<select name=\"alanguage\">";
   $handle=opendir('language');
   while ($file = readdir($handle)) {
       if (preg_match("/^lang\-(.+)\.php/", $file, $matches)) {
           $langFound = $matches[1];
           $languageslist .= "$langFound ";
       }
   }
   closedir($handle);
   $languageslist = explode(" ", $languageslist);
   sort($languageslist);
   for ($i=0; $i < sizeof($languageslist); $i++) {
       if($languageslist[$i]!="") {
      echo "<option value=\"$languageslist[$i]\" ";
      if($languageslist[$i]==$alanguage) echo "selected";
      echo ">".ucfirst($languageslist[$i])."</option>\n";
       }
   }
   echo "</select>";
    }

    echo "<br><br><b>"._STORYTEXT."</b> <i>("._HTMLISFINE.")</i>:<br>"
        ."<textarea cols=\"50\" rows=\"12\" name=\"story\">$story</textarea><br>"
   ."<br><b>"._EXTENDEDTEXT."</b> <i>("._THEREST."):</i><br>"
   ."<textarea cols=\"50\" rows=\"12\" name=\"storyext\">$storyext</textarea><br>"
   ."<br>"
   .""._ALLOWEDHTML."<br>";
    while (list($key,) = each($AllowableHTML)) echo " &lt;".$key."&gt;";
            echo "<br><br>"
   ."<select name=\"posttype\">\n"
   ."<option value=\"exttrans\" selected>"._EXTRANS."</option>\n"
   ."<option value=\"html\" >"._HTMLFORMATED."</option>\n"
   ."<option value=\"plaintext\">"._PLAINTEXT."</option>\n"
   ."</select>&nbsp;&nbsp;<img src=\"http://www.truden.com/images/dot8.gif\" width=\"12\" border=\"no\">";
    echo "<br><br>"
        ."<input type=\"submit\" name=\"op\" value=\""._PREVIEW."\">&nbsp;&nbsp;"
   ."<input type=\"submit\" name=\"op\" value=\""._OK."\">&nbsp;&nbsp;"
   ."</form>";
    CloseTable();
    @include('footer.php');
}

function submitStory($name, $address, $subject, $story, $storyext, $topic, $alanguage, $posttype, $yname, $fname, $fmail, $ymail) {
    global $user, $EditedMessage, $cookie, $anonymous, $notify, $notify_email, $notify_subject, $notify_message, $notify_from, $prefix, $db, $yname, $fname, $fmail, $ymail, $domain;
    $domain = $_SERVER["REMOTE_ADDR"];
    $fname = stripslashes(FixQuotes(check_html(removecrlf($fname))));
    $fmail = stripslashes(FixQuotes(check_html(removecrlf($fmail))));
    $yname = stripslashes(FixQuotes(check_html(removecrlf($yname))));
    $ymail = stripslashes(FixQuotes(check_html(removecrlf($ymail))));
    $subject = ereg_replace("\"", "''", $subject);
    $subject = FixQuotes(filter_text($subject, "nohtml"));
    $story = FixQuotes(nl2br(htmlspecialchars(check_words($story))));
    $storyext = FixQuotes(nl2br(htmlspecialchars(check_words($storyext))));
    $subject = $subject;
    $user = $yname;
    $name = $yname;
    $message = "\n$subject\n\n$story\n$storyext \n\n\n"._THISLETTER."\n";
    if ($fname == "" || $fmail == "" || $yname == "" || $ymail == "") {
    @include('header.php');
    OpenTable();
       echo "<br><br><br><center><font class=\"title\">"._TEXTFIELD."</font><br><br>";
    CloseTable();
    @include('footer.php');
    }
    elseif($posttype=="exttrans") {
   mail($fmail, $subject, $message, "From: \"$yname\" <$ymail>\nX-Mailer: PHP/" . phpversion());
    $result = $db->sql_query("insert into ".$prefix."_stories values (NULL, '$catid', '$name', '$subject', now(), '$story', '$storyext', '0', '0', '$topic', '$name', '', '0', '$alanguage', '0', '0', '0', '0','0',' ')");
    if(!$result) {
       echo ""._ERROR."<br>";
   exit();
    }
    if($notify) {
   $notify_message = "$notify_message\n\n\n========================================================\n$subject\n\n\n$story\n\n$storyext\n\n$name\n\n$domain";
       mail($notify_email, $notify_subject, $notify_message, "From: $notify_from\nX-Mailer: PHP/" . phpversion());
    }
    @include('header.php');
    OpenTable();
    $waiting = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_queue"));
    echo "<center><font class=\"title\">"._SUBSENT."</font><br><br>"
   ."<font class=\"content\"><b>"._THANKSSUB."</b><br><br>"
   .""._SUBTEXT."";
    CloseTable();
    @include('footer.php');
}elseif($posttype=="html") {
    @include('header.php');
    OpenTable();
   mail($fmail, $subject, $message, "From: \"$yname\" <$ymail>\nX-Mailer: PHP/" . phpversion());
   if($notify) {
   $notify_message = "$notify_message\n\n\n========================================================\n$subject\n\n\n$name\n\n$domain";
       mail($notify_email, $notify_subject, $notify_message, "From: $notify_from\nX-Mailer: PHP/" . phpversion());
    }
       echo "<center><font class=\"title\">"._SUBSENT."</font><br><br>"
   ."<font class=\"content\"><b>"._THANKSSUB."</b><br><br>"
   .""._SUBTEXT."";
    CloseTable();
    @include('footer.php');
}else{
    $result = $db->sql_query("insert into ".$prefix."_stories values (NULL, '$catid', '$name', '$subject', now(), '$story', '$storyext', '0', '0', '$topic', '$name', '', '0', '$alanguage', '0', '0', '0', '0','0',' ')");
    if(!$result) {
       echo ""._ERROR."<br>";
   exit();
    }
    if($notify) {
   $notify_message = "$notify_message\n\n\n========================================================\n$subject\n\n\n$story\n\n$storyext\n\n$name\n\n$domain";
       mail($notify_email, $notify_subject, $notify_message, "From: $notify_from\nX-Mailer: PHP/" . phpversion());
    }
    @include('header.php');
    OpenTable();
    $waiting = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_queue"));
    echo "<center><font class=\"title\">"._SUBSENT."</font><br><br>"
   ."<font class=\"content\"><b>"._THANKSSUB."</b><br><br>"
   .""._SUBTEXT."";
    CloseTable();
}
@include('header.php');
    OpenTable();
       echo "<br><br><br><center><font class=\"title\">"._TEXTFIELD."</font><br><br>";
    CloseTable();
    @include('footer.php');

}
switch($op) {

    case ""._PREVIEW."":
   PreviewStory($name, $address, $subject, $story, $storyext, $topic, $alanguage, $posttype);
   break;

    case ""._OK."":
   SubmitStory($name, $address, $subject, $story, $storyext, $topic, $alanguage, $posttype);
   break;

    default:
   defaultDisplay();
   break;

}

?>


Another question, which is maybe easier:
How to make the comments of the articles to have the name of the users, inserted by them if they are posting as anonymous, which is the only way for this web site?
 
View user's profile Send private message Visit poster's website
Raven
Site Admin/Owner



Joined: Aug 27, 2002
Posts: 17088

PostPosted: Fri May 13, 2005 9:42 pm Reply with quote

This is a support site where we attempt to answer any and all questions concerning things technical, spiritual, life, death, etc. Wink Of course we answer questions other than just about NukeSentinel(TM).

If I understand your post correctly you are just asking to clean the email of <br> tags, correct? If so, then have you tried something like this? I will just state one example and if there is more code you will see what to do. Where you have
Code:
mail($fmail, $subject, $message,

Modify to this to convert the <br> tags to \n
Code:
mail($fmail, $subject, str_replace('<br>',"\n",$message),

Modify to this to delete the <br> tags completely
Code:
mail($fmail, $subject, str_replace('<br>','',$message),
 
View user's profile Send private message
Truden







PostPosted: Sat May 14, 2005 9:06 am Reply with quote

Thank You, Raven Smile
Thank You, Friend.

Yes I did try with
Code:
str_replace('<br>','',$message)

but I'm stupid Very Happy
I had <br /> in the mail, and I did not notice that SMALL difference...
So, I thought that it is not the right way to do it, but after you said the same I was afraid to think that you are wrong, Wink and looking more carefully, I notice the mistake.

It works.

Thank You again.

What about my question for the comments in News?
I'm using NSN News and I'd like instead of having "Anonymous" in the comments, to give option, users to put their names.

BTHW, you are the first PHP-Nuke Web Site, which I now, that puts spirituality in discussion forums.

God Bless You
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> General/Other Stuff

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 ©