Welcome to Geeklog, Anonymous Thursday, December 26 2024 @ 10:35 pm EST

Geeklog Forums

HTML Story Email


Status: offline

congleal

Forum User
Full Member
Registered: 11/08/04
Posts: 179
Is is possible to offer an html option as part of emailing a story from a geeklog website? Just wondering...
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
There's no option for HTML emails, if that's what you mean. It's simply not built in.

bye, Dirk
 Quote

Turner

Anonymous
In (site url)/profiles.php, consider replacing the mailstory function with the hack below.

Text Formatted Code
function mailstory ($sid, $to, $toemail, $from, $fromemail, $shortmsg)
{
        global $_CONF, $_TABLES, $_USER, $LANG01, $LANG08;

    $html = '';
    $femail = '';
    $retval = COM_refresh (COM_buildUrl ($_CONF['site_url']
                                         . '/article.php?story=' . $sid));
    // check for correct $_CONF permission
    if (empty ($_USER['username']) &&
        (($_CONF['loginrequired'] == 1) || ($_CONF['emailstoryloginrequired'] == 1))) {
        return $retval;
    }

    // check if emailing of stories is disabled
    if ($_CONF['hideemailicon'] == 1) {
        return $retval;
    }

    // check mail speedlimit
    COM_clearSpeedlimit ($_CONF['speedlimit'], 'mail');
    if (COM_checkSpeedlimit ('mail') > 0) {
        return $retval;
    }

        $sql = "SELECT uid,title,introtext,bodytext,postmode,UNIX_TIMESTAMP(date) AS day FROM {$_TABLES['stories']} WHERE sid = '$sid'";
        $result = DB_query ($sql);
        $A = DB_fetchArray ($result);
        $html = '';

if ($A['postmode'] == 'html') {
    $html = true;
    $shortmsg = COM_stripslashes ($shortmsg);
    $femail = '<a href="mailto:' . $fromemail . '">' . $fromemail . '</a>';

    $mailtext = sprintf ($LANG08[23], $from, $femail);

        if (strlen ($shortmsg) > 0) {
                $mailtext .= '<br><br>' . sprintf ($LANG08[28], $from) . $shortmsg . '<br>';
        }
    $mailtext .= '------------------------------------------------------------'
              . '<br>'
              . COM_undoSpecialChars (stripslashes ($A['title'])) . '<br>'
              . strftime ($_CONF['date'], $A['day']) . '<br>';

    if ($_CONF['contributedbyline'] == 1) {
        $author = DB_getItem ($_TABLES['users'], 'username', "uid={$A['uid']}");
        $mailtext .= $LANG01[1] . ' ' . $author . '<br>';
    }
    $mailtext .= stripslashes($A['introtext']).'<br>'
                . stripslashes($A['bodytext']).'<br>'
                . '------------------------------------------------------------'.'<br>'
                . $LANG08[24] . '<br> <a href="'
                . COM_buildUrl ($_CONF['site_url'] . '/article.php?story=' . $sid
                        . '#comments')
                . '">' . COM_buildUrl ($_CONF['site_url'] . '/article.php?story=' . $sid . '#comments') . '</a>';
} else {
    $html = false;
    $shortmsg = COM_stripslashes ($shortmsg);
        $mailtext = sprintf ($LANG08[23], $from, $fromemail) . LB;
        if (strlen ($shortmsg) > 0) {
                $mailtext .= LB . sprintf ($LANG08[28], $from) . $shortmsg . LB;
        }
    $mailtext .= '------------------------------------------------------------'
              . LB . LB
              . COM_undoSpecialChars (stripslashes ($A['title'])) . LB
              . strftime ($_CONF['date'], $A['day']) . LB;

    if ($_CONF['contributedbyline'] == 1) {
        $author = DB_getItem ($_TABLES['users'], 'username', "uid={$A['uid']}");
        $mailtext .= $LANG01[1] . ' ' . $author . LB;
    }
    $mailtext .= LB
                . COM_undoSpecialChars(stripslashes(strip_tags($A['introtext']))).LB.LB
                . COM_undoSpecialChars(stripslashes(strip_tags($A['bodytext']))).LB.LB
                . '------------------------------------------------------------'.LB
                . $LANG08[24] . LB
        . COM_buildUrl ($_CONF['site_url'] . '/article.php?story=' . $sid
                        . '#comments');
}

    $mailto = COM_formatEmailAddress ($to, $toemail);
    $mailfrom = COM_formatEmailAddress ($from, $fromemail);
        $subject = COM_undoSpecialChars(strip_tags(stripslashes('Re: '.$A['title'])));

    COM_mail ($mailto, $subject, $mailtext, $mailfrom, $html);
    COM_updateSpeedlimit ('mail');

        // Increment numemails counter for story
    DB_query ("UPDATE {$_TABLES['stories']} SET numemails = numemails + 1 WHERE sid = '$sid'");

        return $retval;
}

 


It is very trashy, of course. I could have made this a lot better. But, I am very new to this stuff and just wanted to get something up fast. This works (except for the link to the webpage located within the LANG variable.) I figured it would hold me until the real coders fix it. I put in a bug report on it. Hopefully this helps you or someone else in the meantime.

(If someone has the REAL way to fix this, please post it so I can enjoy it and maybe it'll even quick get into the main code.)

Jeff
 Quote

Status: offline

congleal

Forum User
Full Member
Registered: 11/08/04
Posts: 179
I've tested it on my website and it works! However, only one thing...when you email the story it emails the entire story instead of just the intro text with a link back to the website and story. Can you fix this?

Thanks,

Lee
 Quote

Turner

Anonymous

Raplace the following
Text Formatted Code
    $mailtext .= stripslashes($A['introtext']).'<br>'
                . stripslashes($A['bodytext']).'<br>'

 


with this

Text Formatted Code
    $mailtext .= stripslashes($A['introtext']).'<br>'
 


Also replace the following:
Text Formatted Code
    $mailtext .= LB
                . COM_undoSpecialChars(stripslashes(strip_tags($A['introtext']))).LB.LB
                . COM_undoSpecialChars(stripslashes(strip_tags($A['bodytext']))).LB.LB

 


with this

Text Formatted Code
    $mailtext .= LB
                . COM_undoSpecialChars(stripslashes(strip_tags($A['introtext']))).LB.LB

 


We are just keeping the bodytext stuff from being added to the mailtext.

Hope it works for you. Its dirty and emarrassing, but I think it works.
 Quote

Status: offline

congleal

Forum User
Full Member
Registered: 11/08/04
Posts: 179
We're almost there...the only link that displays is to make a commenton the story, which is ok but it doesn't link back to the rest of the story, i.e.

"Comment on this story at
http://www.archangelreport.com/article.php?story=John_Paul_II#comments"

Thank you very much for your help and responsiveness.
 Quote

Turner

Anonymous
Oh yes.

Find this line:
Text Formatted Code
COM_buildUrl ($_CONF['site_url'] . '/article.php?story=' . $sid
                        . '#comments');
 


Make it look like this:
Text Formatted Code
COM_buildUrl ($_CONF['site_url'] . '/article.php?story=' . $sid);
 


We took off the "#comment" so that the link points only to the story.
 Quote

Status: offline

samstone

Forum User
Full Member
Registered: 09/29/02
Posts: 820
Great hack!
 Quote

Status: offline

congleal

Forum User
Full Member
Registered: 11/08/04
Posts: 179
Now....can you and an html feature for the Daily Digest?

Thanks,

Lee
 Quote

All times are EST. The time is now 10:35 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content