4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: ch€ri{Bi}² on June 01, 2005, 08:23:08 PM

Title: [MOD] Send complete HTML-Postcards in mailboxes
Post by: ch€ri{Bi}² on June 01, 2005, 08:23:08 PM
Tested with 4images1.7
this mod allows users to send the complete ecard thanks to an email in HTML language .
the sender can choose between those notifications :
never forget to backup the files which you will modify.

 >> 04 files to edit from 4images root:

[change]/postcards.php
[change]/templates/<yourtemplate>/postcard_create.html
[change]/templates/<yourtemplate>/postcard_preview.html
[change]/lang/<yourlanguage>/main.php

 >> 01 new file to create from 4images root:

[new]/include/html_mime_mail.php


------ Installation ------

STEP 1:
Open postcards.php
1.1:
Find:
Code: [Select]
$recipient_email = un_htmlspecialchars(trim($HTTP_POST_VARS['recipient_email'])); Add after:
Code: [Select]
$email_format = $HTTP_POST_VARS['email_format'];
1.2:
Find:
Code: [Select]
include(ROOT_PATH.'includes/email.php');
    $site_email = new Email();
    $site_email->set_to(stripslashes($recipient_email));
    $site_email->set_from(stripslashes($sender_email), stripslashes($sender_name));
    $site_email->set_subject($lang['send_postcard_emailsubject']);
    $site_email->register_vars(array(
      "sender_name" => stripslashes($sender_name),
      "sender_email" => stripslashes($sender_email),
      "recipient_name" => stripslashes($recipient_name),
      "postcard_url" => stripslashes($postcard_url),
      "postcard_send_date" => format_date($config['date_format']." ".$config['time_format'], $current_time),
      "site_name" => $config['site_name']
    ));
    $site_email->set_body("postcard_message", $config['language_dir']);
    $site_email->send_email();
Replace with:
Code: [Select]

 if ($email_format == 'html' || $email_format == 'txthtml') {
 // email html
 
    include(ROOT_PATH.'includes/html_mime_mail.php');

  $html_to_send .= "<center>
   <table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\">
      <tr>
        <td>
          <table border=\"0\" cellspacing=\"0\" cellpadding=\"1\">
            <tr>
              <td bgcolor=\"".$border_color."\">
                <table border=\"0\" cellspacing=\"0\" cellpadding=\"10\" bgcolor=\"".$bg_color."\">
                  <tr>
                      <td valign=\"top\"><div><img src=\"".MEDIA_PATH."/".$cat_id."/".$image_row['image_media_file']."\" border=\"0\" /></div></td>
                    <td valign=\"top\" width=\"200\" height=\"250\">
                      <div align=\"right\"><img src=\"".TEMPLATE_PATH."/images/stamp.gif\" border=\"0\" /></div>
                      <br /><br />
                      <b><font face=\"".$font_face."\" color=\"".$font_color."\" size=\"4\">".$headline."</font></b>
  <br /><br />
                      <font face=\"".$font_face."\" color=\"".$font_color."\" size=\"2\">".$message."</font>
  <br /><br />
                      <font face=\"".$font_face."\" color=\"".$font_color."\" size=\"2\">".$sender_name."</font><br />
  <a href=\"mailto:".$sender_email."\"><font face=\"".$font_face."\" color=\"".$font_color."\" size=\"2\">".$sender_email."</font></a>
                    </td>
                  </tr>
                </table>
              </td>
            </tr>
          </table>
           <br />
        </td>
      </tr>
    </table>
     
         <b><font face=\"".$font_face."\" color=\"".$font_color."\" size=\"2\">See your eCard <a href=\"".$postcard_url."\">here</a>.</font><br />
         ".$config['site_name']."</center>";
 
  $mel = new html_mime_mail(102400, "iso-8859-1");
 
  $fp      = fopen(MEDIA_PATH."/".$cat_id."/".$image_row['image_media_file'], "r");
  $bin_img = fread($fp, filesize(MEDIA_PATH."/".$cat_id."/".$image_row['image_media_file']));
  fclose($fp);
  $mel->add_img($bin_img, MEDIA_PATH."/".$cat_id."/".$image_row['image_media_file'], "image/jpeg");
 
  $fp      = fopen(TEMPLATE_PATH."/images/stamp.gif", "r");
  $bin_img = fread($fp, filesize(TEMPLATE_PATH."/images/stamp.gif"));
  fclose($fp);
  $mel->add_img($bin_img, TEMPLATE_PATH."/images/stamp.gif", "image/gif");

  $mel->add_body($html_to_send);

  $mel->build_mail("base64", 5);

  $mel->send($sender_name, $sender_email, $recipient_name, $recipient_email, "eCard for you !");

  //echo $mel->get_rfc822($sender_name, $sender_email, $recipient_name, $recipient_email, "test ecard");

  } // end if

  if ($email_format == 'txt' || $email_format == 'txthtml') {
    include(ROOT_PATH.'includes/email.php');
    $site_email = new Email();
    $site_email->set_to(stripslashes($recipient_email));
    $site_email->set_from(stripslashes($sender_email), stripslashes($sender_name));
    $site_email->set_subject($lang['send_postcard_emailsubject']);
    $site_email->register_vars(array(
      "sender_name" => stripslashes($sender_name),
      "sender_email" => stripslashes($sender_email),
      "recipient_name" => stripslashes($recipient_name),
      "postcard_url" => stripslashes($postcard_url),
      "postcard_send_date" => format_date($config['date_format']." ".$config['time_format'], $current_time),
      "site_name" => $config['site_name']
    ));
    $site_email->set_body("postcard_message", $config['language_dir']);
    $site_email->send_email();
  } // end if
now, you can modify the code in $html_to_send .= to customize the final email.

1.3:
Find:
Code: [Select]

    $main_template = "postcard_preview";
    $image = get_media_code($image_row['image_media_file'], $image_id, $cat_id, $image_row['image_name'], $mode, 1);
    $thumbnail = get_thumbnail_code($image_row['image_media_file'], $image_row['image_thumb_file'], $image_id, $cat_id, $image_row['image_name'], $mode);
    $site_template->register_vars(array(
Add right after:
Code: [Select]

         "lang_postcard_email_format" => $lang['postcard_email_format'],
         "postcard_email_format" => ($HTTP_POST_VARS['email_format'] == 'txt') ? 'text' : (($HTTP_POST_VARS['email_format'] == 'html') ? 'HTML' : 'text & HTML'), 
         "email_format" => $HTTP_POST_VARS['email_format'],

1.4:
Find:
Code: [Select]

if ($action == "createcard") {
  if (!$sendprocess) {
    $bg_color = "";
    $border_color = "";
    $font_color = "";
    $font_face = "";
    $sender_name = ($user_info['user_level'] != GUEST) ? $user_info['user_name'] : "";
    $sender_email = ($user_info['user_level'] != GUEST) ? $user_info['user_email'] : "";
    $recipient_name = "";
    $recipient_email = "";
    $headline = "";
    $message = "";
  }
  $image = get_media_code($image_row['image_media_file'], $image_id, $cat_id, $image_row['image_name'], $mode, 1);
  $thumbnail = get_thumbnail_code($image_row['image_media_file'], $image_row['image_thumb_file'], $image_id, $cat_id, $image_row['image_name'], $mode);
  $site_template->register_vars(array(
Add right after:
Code: [Select]

      "lang_postcard_email_format" => $lang['postcard_email_format']."?",

Step 2:
Open /lang/<yourlanguage>/main.php
Add at the end of the file, just before ?> :
Code: [Select]
$lang['postcard_email_format'] = "Type of notification";
Step 3:
Open /templates/<yourtemplate>/postcard_create.html
Add this:
Code: [Select]

                            <tr>
                              <td class="row2" valign="top"><b>{lang_postcard_email_format}</b></td>
                              <td class="row2" valign="top">
                                <table border=0 cellspacing=3 cellpadding=1>
                                  <tr>
                                    <td>
                                      <input name="email_format" type="radio" value="txt" checked />
                                    </td>
                                    <td><font face="arial">Text</font></td>
                                    <td>
                                      <input name="email_format" type="radio" value="html" />
                                    </td>
                                    <td><font face="verdana">HTML</font></td>
                                    <td>
                                      <input name="email_format" type="radio" value="txthtml" />
                                    </td>
                                    <td><font face="arial">text & HTML</font></td>
                                  </tr>
                                </table>
                              </td>
                            </tr>

Step 4:
Open /templates/<yourtemplate>/postcard_preview.html
Add this:
Code: [Select]

<B>{lang_postcard_email_format}:</B> {postcard_email_format}
and this:
Code: [Select]

    <INPUT type="hidden" name="email_format" value="{email_format}" />

Step 5:
Download attched file, unzip it and copy it in 4images/includes/ directory.

------ END of Installation ------
 it should work !!! :wink:
Title: Re: [MOD] Send complete HTML-Postcards in mailboxes
Post by: DigitalOldschool on June 03, 2005, 03:59:47 PM
Hey,

This is something I'd really like to use. Unfortunately when I go to test it out I get the following error message:

Code: [Select]
error :: cannot attach ./data/media/6/JordansHaircut03.jpg (limited to 100ko/mail) !!!
Is that a server side setting or something in the HTML_MIME_MAIL.PHP file?

Thanks again for this mod and hopefully I can get it to work.

-DigitalOldschool
Title: Re: [MOD] Send complete HTML-Postcards in mailboxes
Post by: drhtm on June 03, 2005, 04:53:58 PM
Hey,

This is something I'd really like to use. Unfortunately when I go to test it out I get the following error message:

Code: [Select]
error :: cannot attach ./data/media/6/JordansHaircut03.jpg (limited to 100ko/mail) !!!
Is that a server side setting or something in the HTML_MIME_MAIL.PHP file?

Thanks again for this mod and hopefully I can get it to work.

-DigitalOldschool

I'm getting the same error and I made sure I added each step to the letter!

However when I tested it, I received two emails.  One from the orginal notification and a second one with the ecard as a HTML file.  However the image is not there, only the message, stamp and a link to the orginal image.  For some reason, the image never got attached?

Title: Re: [MOD] Send complete HTML-Postcards in mailboxes
Post by: drhtm on June 03, 2005, 05:57:58 PM
Have you looked at this thread? 

http://www.4homepages.de/forum/index.php?topic=7462.0

Title: Re: [MOD] Send complete HTML-Postcards in mailboxes
Post by: ch€ri{Bi}² on June 03, 2005, 06:02:36 PM
Is that a server side setting or something in the HTML_MIME_MAIL.PHP file?
you're right for the error!
there is a limit for attached files in the mail (see html_mime_mail.php line 58).
if you want to modify this, find this code in html_mime_mail.php:
Code: [Select]
function html_mime_mail($limit=102400, $charset="iso-8859-1", $headers="")
and change 102400 (value of $limit)  by whatever you want.
it should work better now  :wink:
Title: Re: [MOD] Send complete HTML-Postcards in mailboxes
Post by: DigitalOldschool on June 03, 2005, 07:52:56 PM
Quote
if you want to modify this, find this code in html_mime_mail.php:
Code: [Select]
function html_mime_mail($limit=102400, $charset="iso-8859-1", $headers="")and change 102400 (value of $limit)  by whatever you want.

Unfortunately I tried that before posting here. I changed it all the way up to 500kb and it still gives me the error.
Any other suggestions?

Thanks.
Title: Re: [MOD] Send complete HTML-Postcards in mailboxes
Post by: ch€ri{Bi}² on June 03, 2005, 08:30:46 PM
But did you try a more important value?
And what is the size of your image?

The error message is explicit: it is a problem of size.
Try to increase the value of limit up to 3Mb (  :arrow: 3000000). Generally mailboxes accept this size...

or try to inhibit this code (responsible for the check of the size of the attach):
Code: [Select]
if(($this->msg_att_size + strlen($fichier)) > $this->limit_up)
{ # erreur
printf("<font color=\"#ff0000\"><b>error</b></font> :: cannot attach <b>%s</b> (limited to 100ko/mail) !!!<br>\n", $nom);
$rtval = false;
}
but if you do that, I do not know if the script will continue to work correctly  :?

 this check is done 2 times in the code : change the error message to know the part whitch fails.

Title: Re: [MOD] Send complete HTML-Postcards in mailboxes
Post by: DigitalOldschool on June 03, 2005, 08:58:38 PM
Well, I had to disable the code to do the limit size check, because nothing else would work for some reason.
It was happening with the first error check. weird.
Oh well, no worries on someone trying to send a HUGE image because I am the only one who uploads the images
and they are a set width, so they're not too big. (>300kb)

Anyway, thanks for your assistance with this. Good Mod!

-DigitalOldschool
Title: Re: [MOD] Send complete HTML-Postcards in mailboxes
Post by: mantra on June 04, 2005, 07:20:46 AM
 :idea:maybe we can resize the image before it posting to milbox
Title: Re: [MOD] Send complete HTML-Postcards in mailboxes
Post by: ch€ri{Bi}² on June 05, 2005, 01:36:19 AM
 finaly i find why it was limilited to 100Ko !!!!
change this code in the modified postcard.php:

Code: [Select]
$mel = new html_mime_mail(102400, "iso-8859-1");
by this one :
Code: [Select]
$mel = new html_mime_mail(1024000, "iso-8859-1");
now it should work :wink:
Title: Re: [MOD] Send complete HTML-Postcards in mailboxes
Post by: drhtm on June 05, 2005, 02:41:03 AM
for me it works. wonderful MOD.  oh by the way, is there a way to know if the receiver received the ecard instead of clicking on the link?
Title: Re: [MOD] Send complete HTML-Postcards in mailboxes
Post by: ch€ri{Bi}² on June 05, 2005, 04:12:30 PM
is it what you want ?
 :arrow:  [Mod] Notify sender on received eCard (http://www.4homepages.de/forum/index.php?topic=4167.0)
Title: Re: [MOD] Send complete HTML-Postcards in mailboxes
Post by: drhtm on June 05, 2005, 08:52:57 PM
is it what you want ?
 :arrow:  [Mod] Notify sender on received eCard (http://www.4homepages.de/forum/index.php?topic=4167.0)


that one i have, but what about your mod?  when the receiver receives the email, they don't need to click on the link and hence the sender won't know if they received it, correct?  so how can we resolve this?
Title: Re: [MOD] Send complete HTML-Postcards in mailboxes
Post by: ch€ri{Bi}² on June 05, 2005, 10:27:38 PM
There is a possibility of calling a script PHP by the  HTML tag : IMG to verify that the user opened the mail.
When the script contained in an img tag is activated (the image is shown), the calling page (the mail, in this case) supplies information, notably your IP address but it is especially interesting because it indicates that the user opened well your mail.

the code is like this :
Code: [Select]
<img src="www.yoursite.com/script.php?mail=refer" width="1" height="1">in this case, script.php can send a mail or do whatever you want with the information in parameters...

This method can be used by hackers.  :twisted:
Consequently we see more and more mail reader which do not show the images...

I do not want that the users support this risk, because this tag is used without their knowledge!!! I prefer codes without surprises!  :wink:
Title: Re: [MOD] Send complete HTML-Postcards in mailboxes
Post by: Martin.G on August 05, 2005, 10:28:37 AM
I tried this mod but it doesn`t work.

I am using 4images 1.7.1.

When I send the postcard the system shows me a successful action (Vielen Dank! Ihre eCardwurde erfolgreich versendet), but I do not recieve any e-mail whether I choose html or txt.

Any idea what goes wrong?

Title: Re: [MOD] Send complete HTML-Postcards in mailboxes
Post by: V@no on August 05, 2005, 02:33:53 PM
and do u receive any kind fof emails through 4images at all?
Title: Re: [MOD] Send complete HTML-Postcards in mailboxes
Post by: Martin.G on August 05, 2005, 09:48:19 PM
As long as I have not installed the mod above it works.

As soon as I have made the described changes I do not get any e-mail by sending an eCard.
Title: Re: [MOD] Send complete HTML-Postcards in mailboxes
Post by: TheOracle on August 06, 2005, 04:30:54 AM
That's strange. I have never seen this kind of array in 4images before :

Quote

"lang_postcard_email_format" => $lang['postcard_email_format']."?",


I thought it needed to be like this :

Code: [Select]

"lang_postcard_email_format" => $lang['postcard_email_format'],


Have I missed something ? :|
Title: Re: [MOD] Send complete HTML-Postcards in mailboxes
Post by: V@no on August 06, 2005, 04:54:40 AM
its actualy just append ? to the end of the string in the $lang['postcard_email_format'] variable ;)

it's like:
Code: [Select]
$lang['postcard_email_format'] = "cool";
echo $lang['postcard_email_format']."?";
it will output:
Quote
cool?
Title: Re: [MOD] Send complete HTML-Postcards in mailboxes
Post by: ch€ri{Bi}² on August 08, 2005, 02:08:54 AM
When I send the postcard the system shows me a successful action (Vielen Dank! Ihre eCardwurde erfolgreich versendet), but I do not recieve any e-mail whether I choose html or txt.

humm.. the end of step 1.2 is almost the same than original code. then if you choose TXT or Both TXT  & HTML, a part of the script works like original code : i just add a condition. if you remove the last if in  step 1.2, a normal txt email will be sent.

if not you should restore your backup files  and try to re-install  the mod  :wink:
Title: Re: [MOD] Send complete HTML-Postcards in mailboxes
Post by: ID25 on August 14, 2005, 05:32:42 PM
I tried this mod but it doesn`t work.
I am using 4images 1.7.1.
When I send the postcard the system shows me a successful action (Vielen Dank! Ihre eCardwurde erfolgreich versendet), but I do not recieve any e-mail whether I choose html or txt.
Any idea what goes wrong?
With version 1.7.1 many problems at this time,
try to download 1.7, you search this from google ;)
something wrong with global.php and paging system...
Title: Re: [MOD] Send complete HTML-Postcards in mailboxes
Post by: renicolay on November 13, 2005, 05:54:53 PM
Any idea if this is somthing that is easily fixed for 1.71? I've been working on this feature and would love to have it on my site?
Title: Re: [MOD] Send complete HTML-Postcards in mailboxes
Post by: ch€ri{Bi}² on November 15, 2005, 09:46:37 AM
Quote
With version 1.7.1 many problems at this time,
this mod works very well with v1.7.1  :wink:
Title: Re: [MOD] Send complete HTML-Postcards in mailboxes
Post by: renicolay on November 16, 2005, 09:36:59 PM
Thanks! I'll try and reinstall the MOD.

Title: Re: [MOD] Send complete HTML-Postcards in mailboxes
Post by: Michael on December 21, 2005, 11:46:48 PM
Thanks for wonderful MOD  :D
Title: Re: [MOD] Send complete HTML-Postcards in mailboxes
Post by: Eagle Eye on December 30, 2005, 08:29:23 PM
I have just installed this mod and its working fine!  :)
I have also uploaded FCKeditor and integrated it into the message field, the out produced is in html and on the card preview the raw html code is show…. :x

Is it possible that the HTML code is integrated into the postcard, so that formatted text is show and not the raw html codes:?:
Thanks for this useful mod  :D
Title: Re: [MOD] Send complete HTML-Postcards in mailboxes
Post by: V@no on December 31, 2005, 01:38:17 AM
omg...you are letting your visitors use HTML? did you know only one line of javascript code needed to get control of your gallery if you let use HTML?
bad idea!
Title: Re: [MOD] Send complete HTML-Postcards in mailboxes
Post by: ch€ri{Bi}² on December 31, 2005, 10:52:59 AM
Is it possible that the HTML code is integrated into the postcard, so that formatted text is show and not the raw html codes:?:
yes it is possible here the solution:

open postcard.php file in your root

everywhere you find this :
Code: [Select]
$message = htmlspecialchars(trim($HTTP_POST_VARS['message']));add after:
Code: [Select]
$message_preview  = un_htmlspecialchars(trim($HTTP_POST_VARS['message']));
you must  also register a new var called $message_preview corresponding to the last change
i.e : find
Quote
"message" => stripslashes($message),
add after:
Quote
"message_preview" => stripslashes($message_preview),

and in your template, if you want to display formated HMTL message, don't use {message} but modify it to {message_preview}  
but as v@no said : it is very risky... :roll:
try to use FCKeditor with a basic tool bar :wink:
Title: Re: [MOD] Send complete HTML-Postcards in mailboxes
Post by: Eagle Eye on December 31, 2005, 11:16:09 AM
Happy New Year!  

Thanks V@no  & cheribibi  :D

I guess warning by one of the best php coder should not be ignored!!! :idea:

don’t want to see my hard work blown into air by leaving silly security holes, thanks guys I will not be using this addition…

p.s V@no, is there any way to work around this? like not allowing JavaScript? will this help "try to use FCKeditor with a basic tool bar" or the answer is simple, “don’t allow visitors to use html codes in your gallery”  :(


Thanks a lot


Edited: I have noticed that after “ecard preview”, the “modify ecard” button does not work, like if I press it once no change, the second time it goes back to the photo details page….

Is this a bug? or its my mistake somewhere…

Title: Re: [MOD] Send complete HTML-Postcards in mailboxes
Post by: cj_storm on January 11, 2006, 10:49:28 AM
Send please on email (storm@e1.ru) the working postcards.php
And that after a step 1.2 that does not come :(