Jump to content



Latest News: (loading..)

* * * * * 1 votes

[TIP / TRICK] Tell A Friend Reporting


This topic has been archived. This means that you cannot reply to this topic.
61 replies to this topic

#-19   mattice

mattice
  • Members
  • 2,637 posts

Posted 12 March 2003 - 03:05 PM

Tell A Friend Reporting

The Tell a Friend feature on osCommerce is a popular feature.
Is it? You don't really know, do you? And who is sending what?
And what are they saying?
Might be your competitor telling his buddies to adapt their price to 90% of yours?

A very simple but sufficient hack in /catalog/tell_a_friend.php will give the answers to all above questions.
And ofcoarse silently.. so the customer never knows, just like we SysGods like it ;)

Changes to make

In /catalog/tell_a_friend.php (around line 139) where the tep_mail() function is called you add the following AFTER the tep_mail() line:

// Mail a (silent) report to the web owner:

 

 // get ip

  if (getenv('HTTP_X_FORWARDED_FOR')) {

      $ip=getenv('HTTP_X_FORWARDED_FOR');

    } else {

      $ip=getenv('REMOTE_ADDR');

  }



// build report

    $report  = 'Here are the details of the T.A.F. submission by ' . $from_name . ' on ' . date("D M j G:i:s Y") . ':';

    $report .= "nn" . 'Recipient details: ' . $HTTP_POST_VARS['friendname'] . ' - ' . $HTTP_POST_VARS['friendemail'];

    $report .= "n" . 'Sender details: ' . $from_name . ' - ' . $from_email_address;

    $report .= "n" . 'Sender ip address: ' . $ip;

    $report .= "n" . 'Personal message: ' . "nn" . $HTTP_POST_VARS['yourmessage'];

    $report .= "nn" . 'Product link: ' . HTTP_SERVER . DIR_WS_CATALOG . FILENAME_PRODUCT_INFO . '?products_id=' . $HTTP_GET_VARS['products_id'];



// mail report

    tep_mail('Tell A Friend', 'you@youraddress.com', '[ REPORT ] Tell a Friend Usage', stripslashes($report), '', $from_email_address);

Things to remember
Note that if you use MIME e-mail you should change all occurances of "n" to "<br>".
Furthermore you should obviously change the e-mail address used to reflect your own.

Regards,

Mattice



PS:

Quote

// mail report - NOTE THE BLUE ADDITION!
   tep_mail('Tell A Friend', 'you@youraddress.com', '[ REPORT ] Tell a Friend Usage', stripslashes($report), '', $from_email_address, '');

"Politics is the art of preventing people from taking part in affairs which properly concern them"

#-18   Ian-San

Ian-San
  • Members
  • 764 posts

Posted 12 March 2003 - 05:35 PM

Fantastic - many thanks :D
Ian-san
Flawlessnet

#-17   Josaram

Josaram
  • Members
  • 60 posts

Posted 13 March 2003 - 01:15 AM

I am running MS1 loaded, and cannot seem to find the correct place to insert this code.  Every natural break after TEP MAIL results in email going to receiver, but not a copy to my shop, and you never a "email sent" message on the store.

Could you show me the full phrase you need to insert this code after?

Thanks for any assistance - this sounds like a wonderful idea!!

#-16   jeanjerome

jeanjerome
  • Members
  • 34 posts

Posted 13 March 2003 - 06:35 AM

Mattice!

Great snippet of code! Thanks!

Now we just need to feed the data in mysql and get some stats report out of it from the admin!

Jean  :D

#-15   mattice

mattice
  • Members
  • 2,637 posts

Posted 13 March 2003 - 07:14 AM

Quote

I am running MS1 loaded, and cannot seem to find the correct place to insert this code.  Every natural break after TEP MAIL results in email going to receiver, but not a copy to my shop, and you never a "email sent" message on the store.

Could you show me the full phrase you need to insert this code after?

Thanks for any assistance - this sounds like a wonderful idea!!

Okay, here's the snippet from the latest (v 1.35 ) /catalog/tell_a_friend.php which is in MS1,
this is line number 136 to 140:

 $email_body .= sprintf(TEXT_EMAIL_LINK, tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id'])) . "nn" .

sprintf(TEXT_EMAIL_SIGNATURE, STORE_NAME . "n" . HTTP_SERVER . DIR_WS_CATALOG . "n");

                  



  tep_mail($HTTP_POST_VARS['friendname'], $HTTP_POST_VARS['friendemail'], $email_subject, stripslashes($email_body), '', $from_email_address);



/*----------------------------

INSERT MATTICE CODE 

HERE, MAKE SURE IT HAS

NO LINE BREAKS IN IT !

-----------------------------*/



?>

Mattice
"Politics is the art of preventing people from taking part in affairs which properly concern them"

#-14   mattice

mattice
  • Members
  • 2,637 posts

Posted 13 March 2003 - 07:21 AM

Quote

Now we just need to feed the data in mysql and get some stats report out of it from the admin!

Why? Personally I do not see the benefit of storing the tell-a-friend copies in the database, I prefer to have them e-mailed, like any 'semi-security' report. But by all means feel free to write it! :D

Mattice
"Politics is the art of preventing people from taking part in affairs which properly concern them"

#-13   Josaram

Josaram
  • Members
  • 60 posts

Posted 13 March 2003 - 02:59 PM

Thanks Mattice - got it working just great now!  Fabulous feature!!

#-12   Farrukh

Farrukh
  • Members
  • 480 posts

Posted 13 March 2003 - 06:19 PM

Excellent option ! Thanks for the quick mod :)

Works smoothly

#-11   jeanjerome

jeanjerome
  • Members
  • 34 posts

Posted 14 March 2003 - 08:29 AM

Mattice...

Well getting these email everyday is nice to have immediate info and as you said make sure no one abuse the system.

But would not it be nice to see a report over a few months period with how may tell-a-friends/month, which items are the most suggested, ups and downs, etc.

I have a simillar system using a Perl based tell-a-friend, and I could not live without! At some point I will get used to PHP... for now I will probably interface it with a log file and a perl script...

Again thanks for your contrib. It's very motivating to get small snippet of codes and try to understand vs. going through the all oscommerce scripts!

Jean.

#-10   Druide

Druide
  • Members
  • 882 posts

Posted 14 March 2003 - 06:05 PM

In /catalog/tell_a_friend.php (around line 139) where the tep_mail() function is called you add the following AFTER the tep_mail() line:

// Mail a (silent) report to the web owner:
if (CONFIG_SEND_TO_A_FRIEND == 'true') {

// get ip
  if (getenv('HTTP_X_FORWARDED_FOR')) {
      $ip=getenv('HTTP_X_FORWARDED_FOR');
    } else {
      $ip=getenv('REMOTE_ADDR');
  }

// build report
    $report  = 'Here are the details of the T.A.F. submission by ' . $from_name . ' on ' . date("D M j G:i:s Y") . ':';
    $report .= "nn" . 'Recipient details: ' . $HTTP_POST_VARS['friendname'] . ' - ' . $HTTP_POST_VARS['friendemail'];
    $report .= "n" . 'Sender details: ' . $from_name . ' - ' . $from_email_address;
    $report .= "n" . 'Sender ip address: ' . $ip;
    $report .= "n" . 'Personal message: ' . "nn" . $HTTP_POST_VARS['yourmessage'];
    $report .= "nn" . 'Product link: ' . HTTP_SERVER . DIR_WS_CATALOG . FILENAME_PRODUCT_INFO . '?products_id=' . $HTTP_GET_VARS['products_id'];

// mail report
    tep_mail('Tell A Friend', EMAIL_SEND_TO_A_FRIEND, '[ REPORT ] Tell a Friend Usage', stripslashes($report), '', $from_email_address);
}


insert into your MySQL database:

INSERT INTO configuration (configuration_id, configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES ('', 'Send To A Friend - Control ON/OFF', 'CONFIG_SEND_TO_A_FRIEND', 'true', 'Would you like to get an email when a visitor uses Send To A Friend ?', 12, 800, '2003-03-14 12:20:07', '2003-03-14 12:20:07', NULL, 'tep_cfg_select_option(array('true', 'false'),');
INSERT INTO configuration (configuration_id, configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES ('', 'Send To A Friend - Email', 'EMAIL_SEND_TO_A_FRIEND', 'your email', 'Send an Email to this address when someone uses Send to a friend option', 12, 801, '2003-03-14 12:20:07', '2003-03-14 12:20:07', NULL, NULL);

In /catalog/tell_a_friend.php (around line 139) where the tep_mail() function is called you add the following AFTER the tep_mail() line:



// Mail a (silent) report to the web owner: 

if (CONFIG_SEND_TO_A_FRIEND == 'true') {



// get ip 

  if (getenv('HTTP_X_FORWARDED_FOR')) { 

      $ip=getenv('HTTP_X_FORWARDED_FOR'); 

    } else { 

      $ip=getenv('REMOTE_ADDR'); 

  } 



// build report 

    $report  = 'Here are the details of the T.A.F. submission by ' . $from_name . ' on ' . date("D M j G:i:s Y") . ':'; 

    $report .= "nn" . 'Recipient details: ' . $HTTP_POST_VARS['friendname'] . ' - ' . $HTTP_POST_VARS['friendemail']; 

    $report .= "n" . 'Sender details: ' . $from_name . ' - ' . $from_email_address; 

    $report .= "n" . 'Sender ip address: ' . $ip; 

    $report .= "n" . 'Personal message: ' . "nn" . $HTTP_POST_VARS['yourmessage']; 

    $report .= "nn" . 'Product link: ' . HTTP_SERVER . DIR_WS_CATALOG . FILENAME_PRODUCT_INFO . '?products_id=' . $HTTP_GET_VARS['products_id']; 



// mail report 

    tep_mail('Tell A Friend', EMAIL_SEND_TO_A_FRIEND, '[ REPORT ] Tell a Friend Usage', stripslashes($report), '', $from_email_address);

}

insert into your MySQL database:
this will put the config options in Admin > Configuration > E-mail options
INSERT INTO configuration (configuration_id, configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES ('', 'Send To A Friend - Control ON/OFF', 'CONFIG_SEND_TO_A_FRIEND', 'true', 'Would you like to get an email when a visitor uses Send To A Friend ?', 12, 800, '2003-03-14 12:20:07', '2003-03-14 12:20:07', NULL, 'tep_cfg_select_option(array('true', 'false'),');

INSERT INTO configuration (configuration_id, configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES ('', 'Send To A Friend - Email', 'EMAIL_SEND_TO_A_FRIEND', 'your email', 'Send an Email to this address when someone uses Send to a friend option', 12, 801, '2003-03-14 12:20:07', '2003-03-14 12:20:07', NULL, NULL);

thanks Mattice
Robert

We all need to learn it once, how hard it may seem when you look at it, also you will master it someday ;)

#-9   Druide

Druide
  • Members
  • 882 posts

Posted 14 March 2003 - 06:07 PM

oops

my mistake double posting

start at the
Code:

#-8   omps

omps
  • Members
  • 209 posts

Posted 28 March 2003 - 05:03 PM

this is my line 136 to 140 where do i put the code

#-7   omps

omps
  • Members
  • 209 posts

Posted 28 March 2003 - 05:09 PM

<td class="main"><?php echo FORM_FIELD_FRIEND_NAME; ?></td>
                    <td class="main"><?php echo tep_draw_input_field('friendname');?></td>
                  </tr>
                  <tr>
                    <td class="main"><?php echo FORM_FIELD_FRIEND_EMAIL; ?></td>

#-6   okaym

okaym
  • Members
  • 5 posts

Posted 30 March 2003 - 06:24 AM

It is working great. I love it.
Thank you  Mattice
OkayM.

#-5   MikeMike

MikeMike
  • Members
  • 153 posts

Posted 01 April 2003 - 08:37 PM

I tried this on tell_a_friend.php,v 1.28 2002/10/08 and I had to stop my server.

It sent me one correct email and then it kept on creating emails from "Apache" and sending them to me without any information:

Here are the details of the T.A.F. submission by  on Tue Apr 1 15:05:55 2003:

Recipient details:  -
Sender details:  -
Sender ip address: 66.82.9.32
Personal message:

Don't this code work with ver 1.28 or did I mess something up?

#-4   Druide

Druide
  • Members
  • 882 posts

Posted 02 April 2003 - 01:01 AM

that must have been an April Fools joke from you or Apache

#-3   MikeMike

MikeMike
  • Members
  • 153 posts

Posted 02 April 2003 - 08:01 AM

I wish it was... but it was not.
I tried two times and got around 100 emails before I stopped the server.

#-2   luca75

luca75
  • Members
  • 97 posts

Posted 17 April 2003 - 03:18 PM

Sorry, but when I paste the code ?

This is my code from 129 to 159 line
            <td class="formAreaTitle"><br><?php echo FORM_TITLE_FRIEND_DETAILS; ?></td>

          </tr>

          <tr>

            <td class="main"><table border="0" width="100%" cellspacing="0" cellpadding="2" class="formArea">

              <tr>

                <td class="main"><table border="0" cellspacing="0" cellpadding="2">

                  <tr>

                    <td class="main"><?php echo FORM_FIELD_FRIEND_NAME; ?></td>

                    <td class="main"><?php echo tep_draw_input_field('friendname');?></td>

                  </tr>

                  <tr>

                    <td class="main"><?php echo FORM_FIELD_FRIEND_EMAIL; ?></td>

                    <td class="main"><?php echo tep_draw_input_field('friendemail', $HTTP_GET_VARS['send_to']);?></td>

                  </tr>

                </table></td>

              </tr>

            </table></td>

          </tr>

          <tr>

            <td class="formAreaTitle"><br><?php echo FORM_TITLE_FRIEND_MESSAGE; ?></td>

          </tr>

          <tr>

            <td class="main"><table border="0" width="100%" cellspacing="0" cellpadding="2" class="formArea">

              <tr>

                <td><?php echo tep_draw_textarea_field('yourmessage', 'soft', 40, 8);?></td>

              </tr>

            </table></td>

          </tr>

        </table></td>

      </tr>

      <tr>


#-1   TB

TB
  • Members
  • 624 posts

Posted 20 April 2003 - 06:11 PM

You've gone past the relevant lines...

Do a search for the 'tep_mail' statement.
tep_mail($HTTP_POST_VARS['friendname'], $HTTP_POST_VARS['friendemail'], $email_subject, stripslashes($email_body), '', $from_email_address);

There should only be the one (two after you've complete the mod) 'tep_mail' in the file.
Once you find it, follow the instructions from there.

HTH,
Tony
"The price of success is perseverance.  The price of failure comes much cheaper."

#0   luca75

luca75
  • Members
  • 97 posts

Posted 21 April 2003 - 02:51 PM

I've pasted the code after this

tep_mail($HTTP_POST_VARS['friendname'], $HTTP_POST_VARS['friendemail'], $email_subject, stripslashes($email_body), '', $from_email_address);

But I've error in process page  :cry: