mattice Posted March 12, 2003 Share Posted March 12, 2003 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', '[email protected]', '[ 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: // mail report - NOTE THE BLUE ADDITION! tep_mail('Tell A Friend', '[email protected]', '[ 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" Link to comment Share on other sites More sharing options...
Ian-San Posted March 12, 2003 Share Posted March 12, 2003 Fantastic - many thanks :D Ian-san Flawlessnet Link to comment Share on other sites More sharing options...
Guest Posted March 13, 2003 Share Posted March 13, 2003 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!! Link to comment Share on other sites More sharing options...
jeanjerome Posted March 13, 2003 Share Posted March 13, 2003 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 Link to comment Share on other sites More sharing options...
mattice Posted March 13, 2003 Author Share Posted March 13, 2003 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" Link to comment Share on other sites More sharing options...
mattice Posted March 13, 2003 Author Share Posted March 13, 2003 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" Link to comment Share on other sites More sharing options...
Guest Posted March 13, 2003 Share Posted March 13, 2003 Thanks Mattice - got it working just great now! Fabulous feature!! Link to comment Share on other sites More sharing options...
Farrukh Posted March 13, 2003 Share Posted March 13, 2003 Excellent option ! Thanks for the quick mod :) Works smoothly Link to comment Share on other sites More sharing options...
jeanjerome Posted March 14, 2003 Share Posted March 14, 2003 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. Link to comment Share on other sites More sharing options...
Druide Posted March 14, 2003 Share Posted March 14, 2003 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 ;) Link to comment Share on other sites More sharing options...
Druide Posted March 14, 2003 Share Posted March 14, 2003 oops my mistake double posting start at the Code: Robert We all need to learn it once, how hard it may seem when you look at it, also you will master it someday ;) Link to comment Share on other sites More sharing options...
omps Posted March 28, 2003 Share Posted March 28, 2003 this is my line 136 to 140 where do i put the code live long and prosper Link to comment Share on other sites More sharing options...
omps Posted March 28, 2003 Share Posted March 28, 2003 <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> live long and prosper Link to comment Share on other sites More sharing options...
Guest Posted March 30, 2003 Share Posted March 30, 2003 It is working great. I love it. Thank you Mattice OkayM. Link to comment Share on other sites More sharing options...
MikeMike Posted April 1, 2003 Share Posted April 1, 2003 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? Link to comment Share on other sites More sharing options...
Druide Posted April 2, 2003 Share Posted April 2, 2003 that must have been an April Fools joke from you or Apache Robert We all need to learn it once, how hard it may seem when you look at it, also you will master it someday ;) Link to comment Share on other sites More sharing options...
MikeMike Posted April 2, 2003 Share Posted April 2, 2003 I wish it was... but it was not. I tried two times and got around 100 emails before I stopped the server. Link to comment Share on other sites More sharing options...
luca75 Posted April 17, 2003 Share Posted April 17, 2003 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> Link to comment Share on other sites More sharing options...
TB Posted April 20, 2003 Share Posted April 20, 2003 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." Link to comment Share on other sites More sharing options...
luca75 Posted April 21, 2003 Share Posted April 21, 2003 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: Link to comment Share on other sites More sharing options...
Waza04 Posted April 21, 2003 Share Posted April 21, 2003 What is the error?? Warren Link to comment Share on other sites More sharing options...
luca75 Posted April 22, 2003 Share Posted April 22, 2003 I see the code in process page, last procediment :shock: Link to comment Share on other sites More sharing options...
jonsteward Posted July 21, 2003 Share Posted July 21, 2003 I too also only see the code outputed on the screen when I run this mod Link to comment Share on other sites More sharing options...
stretchr Posted July 21, 2003 Share Posted July 21, 2003 Nice addition. Thank you Mattice! "It's a small world... But I wouldn't want to paint it!" Stephen Wright Link to comment Share on other sites More sharing options...
bdaug001 Posted July 24, 2003 Share Posted July 24, 2003 i removed the tell-a-friend box from my store to make room for other things; is it really that popular? for anyone who has made the silent email modification, any feedback on whether customers use it and how useful it is in generating leads? Ben Daughtry Dachitech Software www.dtechsoftware.com --B Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.