Copy of post to visitor ?

Dr. GBooky is here to help you with your guestbook problems ...
Post Reply
jaap
Posts: 54
Joined: Sat May 06, 2006 1:54 pm

Copy of post to visitor ?

Post by jaap »

Version of script: 1.7

Hi Henrie,

In version 1.7 I don't see the option to send a copy of the post to the visitor after signing the guestbook ?

Your version had this option.

Jaap.
Henrie
Posts: 1095
Joined: Sun Aug 14, 2005 8:57 pm

Post by Henrie »

Hello Jaap,

I thought i could just take the solution out of my HL-mod version guestbook and paste it in version 1.7, but it took a little more modification.

But it is done now.

Notification posts to the visitor for GBook version 1.7

Open file gbook.php

Part 1 of 4: Notification of normal post
Search for (lines 993-994)

Code: Select all

/* Let the first page know a new entry has been submitted */
define('NOTICE',$lang['t47']);
Paste the following code directly before it on empty line 992.

Code: Select all

    /* Notification posts to the visitor modification by Henrie >> part 1 of 4: Notification of normal post */
    if (!(empty($email)) && $settings['notify_visitor'] == 1)
    {
      $char = array('.','@');
      $repl = array('.','@');
      $email=str_replace($repl,$char,$email);
      $message = sprintf($lang['t76'],$name)."\n\n";
      $message.= sprintf($lang['hl_t02'],$settings['gbook_title'])."\n\n";
      $message.= "$lang[hl_t03]\n";
      $message.= "$lang[t17] $name\n";
      $message.= "$lang[t18] $from\n";
      $message.= "$lang[t20] $email\n";
      $message.= "$lang[t19] $url\n";
      $message.= "$lang[t44]\n";
      $message.= "$comments_nosmileys\n\n";
      $message.= "$lang[hl_t04]\n";
      $message.= "$settings[gbook_url]\n\n";
      $message.= "$lang[t79]\n\n";
      $message.= "$settings[website_title]\n";
      $message.= "$settings[website_url]\n";

      mail($email,$lang['hl_t01'],$message,"From: $settings[website_title] <$settings[admin_email]>\nReply-to: $settings[admin_email]\nReturn-path: $settings[admin_email]\nContent-type: text/plain; charset=".$lang['enc']);
    }
    /* End of Notification posts to the visitor modification by Henrie >> part 1 of 4: Notification of normal post */
Part 2 of 4: Notification of post waiting for approval
Search for (lines 955-956)

Code: Select all

/* Let the first page know a new entry has been submitted for approval */ 
define('NOTICE',$lang['t85']);
Paste the following code directly before it on empty line 954.

Code: Select all

    /* Notification posts to the visitor modification by Henrie >> part 2 of 4: Notification of post waiting for approval */
    if (!(empty($email)) && $settings['notify_visitor'] == 1)
    {
      $char = array('.','@');
      $repl = array('.','@');
      $email=str_replace($repl,$char,$email);
      $message = sprintf($lang['t76'],$name)."\n\n";
      $message.= sprintf($lang['hl_t05'],$settings['gbook_title'])."\n\n";
      $message.= "$lang[hl_t03]\n";
      $message.= "$lang[t17] $name\n";
      $message.= "$lang[t18] $from\n";
      $message.= "$lang[t20] $email\n";
      $message.= "$lang[t19] $url\n";
      $message.= "$lang[t44]\n";
      $message.= "$comments_nosmileys\n\n";
      $message.= "$lang[t79]\n\n";
      $message.= "$settings[website_title]\n";
      $message.= "$settings[website_url]\n";

      mail($email,$lang['hl_t01'],$message,"From: $settings[website_title] <$settings[admin_email]>\nReply-to: $settings[admin_email]\nReturn-path: $settings[admin_email]\nContent-type: text/plain; charset=".$lang['enc']);
    }
    /* End of Notification posts to the visitor modification by Henrie >> part 2 of 4: Notification of post waiting for approval */
Part 3 of 4: Notification of approval/rejection
Search for (line 272)

Code: Select all

} // END approveEntry()
Paste the following code directly before it on empty line 271.

Code: Select all

	/* Notification posts to the visitor modification by Henrie >> part 3 of 4: Notification of approval/rejection */
	$myline = explode("\t",$addline);
	$email = $myline[2];
	
	if (!(empty($email)) && $settings['notify_visitor'] == 1)
    {
	  $char = array('.','@');
	  $repl = array('&#46;','&#64;');
	  $email=str_replace($repl,$char,$email);
	  $message = sprintf($lang['t76'],$name)."\n\n";
	  if (!$approve)
      {
        $message.= sprintf($lang['hl_t08'],$settings['gbook_title'])."\n\n";
      }
      else
      {
        $message.= sprintf($lang['hl_t07'],$settings['gbook_title'])."\n\n";
        $message.= "$lang[hl_t04]\n";
        $message.= "$settings[gbook_url]\n\n";
      }
      $message.= "$lang[t79]\n\n";
      $message.= "$settings[website_title]\n";
      $message.= "$settings[website_url]\n";

      mail($email,$lang['hl_t01'],$message,"From: $settings[website_title] <$settings[admin_email]>\nReply-to: $settings[admin_email]\nReturn-path: $settings[admin_email]\nContent-type: text/plain; charset=".$lang['enc']);
	  }
    /* End of Notification posts to the visitor modification by Henrie >> part 3 of 4: Notification of approval/rejection */
Part 4 of 4: Notification of approval/rejection
Search for (line 250)

Code: Select all

define('NOTICE',$lang['t87']);
Replace it with the following code

Code: Select all

    /* Notification posts to the visitor modification by Henrie >> part 4 of 4: Notification of approval/rejection */
    $addline = file_get_contents($file);
    /* End of Notification posts to the visitor modification by Henrie >> part 4 of 4: Notification of approval/rejection */
    define('NOTICE',$lang['t87']);
save and close the gbook.php file

Open the file settings.php
Find

Code: Select all

/* Notify visitor when you reply to his/her guestbook entry? 1 = YES, 0 = NO */ 
$settings['notify_visitor']=0;
and change it to

Code: Select all

/* Notify visitor when you reply to his/her guestbook entry? 1 = YES, 0 = NO */
/* This setting is also used for the Notification posts to the visitor modification by Henrie */
$settings['notify_visitor']=1;
Open the file language.inc.php
Add

Code: Select all

/* Language strings for modifications by Henrie */
$lang['hl_t01']='Thank you for signing my Guestbook.'; // E-mail subject
$lang['hl_t02']='Thank your for signing the %s Guestbook.'; // Text inside e-mail
$lang['hl_t03']='This is what you wrote:';
$lang['hl_t04']='Visit the below URL to view your message:';
$lang['hl_t05']='Thank your for signing the %s Guestbook. Your entry is waiting for approval and you will be notified when it has been approved.'; // Text inside e-mail
$lang['hl_t06']='Approval/rejection of your Guestbook entry'; // E-mail subject
$lang['hl_t07']='Your entry for the %s Guestbook has been approved.';
$lang['hl_t08']='Your entry for the %s Guestbook has been rejected.';
add it before ?>


Greetings,
Henrie
Last edited by Henrie on Fri Jan 01, 2010 9:48 pm, edited 1 time in total.
I do not monitor the Gbook forums regularly anymore since I do not use the Gbook script myself anymore for a long time. But it helped me a lot in learning to understand php.
jaap
Posts: 54
Joined: Sat May 06, 2006 1:54 pm

Post by jaap »

Thanks Henrie, you are genious :D Works perfect.

I buy you a beer [ of een Buckler :lol: als je wilt ] tomorrow !

Jaap.
Henrie
Posts: 1095
Joined: Sun Aug 14, 2005 8:57 pm

Post by Henrie »

I received your donation for a drink :D
Hartelijk bedankt (for those non-dutch reader: Thank you very much).
I will enjoy some extra drinks when celebrating new-year.

Happy New Year!

Henrie
I do not monitor the Gbook forums regularly anymore since I do not use the Gbook script myself anymore for a long time. But it helped me a lot in learning to understand php.
donaldjeo
Posts: 1
Joined: Tue Mar 09, 2010 11:10 am

Post by donaldjeo »

Hmmm.. nice code. i also use it for my site and its work. thanks to you for sending this code. its my pleasure that if you can give another code for editing. may be that ill easy against it... :wink:
The [url=http://www.mcsepractice.com]mcse[/url] has been designed for knowledgeable security professionals in the field of security which is one of the fastest growing fields in IT.
Henrie
Posts: 1095
Joined: Sun Aug 14, 2005 8:57 pm

Post by Henrie »

Hello donaldjeo,

You are welcome :wink:

I am not sure what additional function you are asking. What would you like to edit?

Greetings,
Henrie
I do not monitor the Gbook forums regularly anymore since I do not use the Gbook script myself anymore for a long time. But it helped me a lot in learning to understand php.
asaki
Posts: 6
Joined: Sat Jun 23, 2012 6:37 pm

Re: Copy of post to visitor ?

Post by asaki »

I have tried this modification in GB 1.7. I cannot get return msg that post is approved or rejected. Btw I think that in approval section part 2 of 4 should be:
$message.= sprintf($lang['hl_t05'],$settings['gbook_title'])."\n\n";
and not
$message.= sprintf($lang['hl_t04'],$settings['gbook_title'])."\n\n"

See language file:
$lang['hl_t04']='Visit the below URL to view your message:';

$lang['hl_t05']='Thank your for signing the %s Guestbook. Your entry is waiting for approval and you will be notified when it has been approved.'; // Text inside e-mail
Eduspin
Posts: 2
Joined: Wed Jan 16, 2013 10:05 pm

Re: Copy of post to visitor ?

Post by Eduspin »

I have the same issue as asaki, changed ['hl_t04'] in ['hl_t05'] as suggested and is an improvement already, but i still don't receive an e-mail when the message is approved or declined. Any suggestions would be appreciated.
Henrie
Posts: 1095
Joined: Sun Aug 14, 2005 8:57 pm

Re: Copy of post to visitor ?

Post by Henrie »

Somehow I overlooked Asaki's post. I changed ['hl_t04'] to ['hl_t05'] now in the approval section part 2 of 4.

@Eduspin
I am sorry, but i do not have time to look at the code now to check if it is working or not. I think I tested i thoroughly when I first wrote te code, so I think it should work.

Just to be sure i understand you right, you are talking about the visitor not receiving a mail when you have approved or disapporove the message of the visitor?

Greetings,
Henrie.
I do not monitor the Gbook forums regularly anymore since I do not use the Gbook script myself anymore for a long time. But it helped me a lot in learning to understand php.
Eduspin
Posts: 2
Joined: Wed Jan 16, 2013 10:05 pm

Re: Copy of post to visitor ?

Post by Eduspin »

Henrie wrote:Somehow I overlooked Asaki's post. I changed ['hl_t04'] to ['hl_t05'] now in the approval section part 2 of 4.

@Eduspin
I am sorry, but i do not have time to look at the code now to check if it is working or not. I think I tested i thoroughly when I first wrote te code, so I think it should work.

Just to be sure i understand you right, you are talking about the visitor not receiving a mail when you have approved or disapporove the message of the visitor?

Greetings,
Henrie.
Yes, you understand right. Thank you for your reply.
There is no hurry since i can manually send the approval for the time being.
The guestbook is at the moment at a testlocation at the server.
It is going to take a while before it's all as i like it.
When i reply a message the visitor gets an email about it, but not the approval or disapproval email.
Thanks.
Henrie
Posts: 1095
Joined: Sun Aug 14, 2005 8:57 pm

Re: Copy of post to visitor ?

Post by Henrie »

Hello Eduspin,

I finally had time to look into the issue of the notification mail of approval or rejection not being sent to the visitor.
I found the error and have to apologise to all who used the code in the past, because i think it may have never worked properly.
The error is in part 3 of 4. I used the following code

Code: Select all

    /* Notification posts to the visitor modification by Henrie >> part 3 of 4: Notification of approval/rejection */
    if (!(empty($email)) && $settings['notify_visitor'] == 1)
    {
      $char = array('.','@');
      $repl = array('.','@');
      $email=str_replace($repl,$char,$email);
      $message = sprintf($lang['t76'],$name)."\n\n";
      if (!$approve)
      {
        $message.= sprintf($lang['hl_t08'],$settings['gbook_title'])."\n\n";
      }
      else
      {
        $message.= sprintf($lang['hl_t07'],$settings['gbook_title'])."\n\n";
        $message.= "$lang[hl_t04]\n";
        $message.= "$settings[gbook_url]\n\n";
      }
      $message.= "$lang[t79]\n\n";
      $message.= "$settings[website_title]\n";
      $message.= "$settings[website_url]\n";

      mail($email,$lang['hl_t01'],$message,"From: $settings[website_title] <$settings[admin_email]>\nReply-to: $settings[admin_email]\nReturn-path: $settings[admin_email]\nContent-type: text/plain; charset=".$lang['enc']);
    }
    /* End of Notification posts to the visitor modification by Henrie >> part 3 of 4: Notification of approval/rejection */
The problem is that this code does not read the e-mail of the visitor properly and therefor can not sent the notification e-mail after approval or rejection to the visitor.
The following code should fix it, use it instead of the previously posted part 3 of 4.

Code: Select all

	/* Notification posts to the visitor modification by Henrie >> part 3 of 4: Notification of approval/rejection */
	$myline = explode("\t",$addline);
	$email = $myline[2];
	
	if (!(empty($email)) && $settings['notify_visitor'] == 1)
    {
	  $char = array('.','@');
	  $repl = array('&#46;','&#64;');
	  $email=str_replace($repl,$char,$email);
	  $message = sprintf($lang['t76'],$name)."\n\n";
	  if (!$approve)
      {
        $message.= sprintf($lang['hl_t08'],$settings['gbook_title'])."\n\n";
      }
      else
      {
        $message.= sprintf($lang['hl_t07'],$settings['gbook_title'])."\n\n";
        $message.= "$lang[hl_t04]\n";
        $message.= "$settings[gbook_url]\n\n";
      }
      $message.= "$lang[t79]\n\n";
      $message.= "$settings[website_title]\n";
      $message.= "$settings[website_url]\n";

      mail($email,$lang['hl_t01'],$message,"From: $settings[website_title] <$settings[admin_email]>\nReply-to: $settings[admin_email]\nReturn-path: $settings[admin_email]\nContent-type: text/plain; charset=".$lang['enc']);
	  }
    /* End of Notification posts to the visitor modification by Henrie >> part 3 of 4: Notification of approval/rejection */
I also applied this code to the original post viewtopic.php?p=12533#p12533 now.

It should work, but if you are having any issues with it, please let me know.

Greetings,
Henrie
I do not monitor the Gbook forums regularly anymore since I do not use the Gbook script myself anymore for a long time. But it helped me a lot in learning to understand php.
Post Reply