Page 1 of 1

Hide E-mail address

Posted: Mon Aug 21, 2006 9:14 pm
by Henrie
Hide e-mail address (for GBook v 1.43)
For solution for GBook version 1.5 look for the post further down this thread.

Because it has been asked several times in this forum here's a modification for hiding the e-mail addresses in the guestbook.
It also has the possibility to view the e-mail address by entering the admin password.

There was a solution for GBook v. 1.41 in this post viewtopic.php?t=877 given by Klemen Stirn, but you could not view the e-mail address with this modification without opening the entries.txt file manually.

So here it goes.

Add after line 148

Code: Select all

seeIP($pass,$num);
this code

Code: Select all

    } elseif($a=='viewEmail') {
        $num=gbook_isNumber($_REQUEST['num'],'Invalid ID');
        confViewEmail($num);
    } elseif($a=='seeEmail') {
        $pass=gbook_input($_REQUEST['pass'],'Please enter your password');
        $num=gbook_isNumber($_REQUEST['num'],'Invalid ID');
        seeEmail($pass,$num);
Add after line 269 (original GBook) or line 276 (after previous addition)

Code: Select all

} // END confViewIP
this code

Code: Select all


function seeEmail($pass,$num) {
global $settings;
if ($pass != $settings[apass]) {problem('Wrong password!');}
$lines=file($settings['logfile']);
$myline=explode("\t",$lines[$num]);
if (empty($myline[2])) {$email='E-MAIL NOT AVAILABLE';}
else
{
	$email=rtrim($myline[2]);
}
?>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>The submitter of this post has entered the following e-mail adress:<br><b><?php echo $email; ?></b></p>
<p><a href="gbook.php?page=1">Click here to continue</a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<?php
printDownHTML();
exit();
} // END seeEmail

function confViewEmail($num) {
?>
<p>&nbsp;</p>
<p>&nbsp;</p>
<form action="gbook.php" method="POST"><input type="hidden" name="a" value="seeEmail">
<input type="hidden" name="num" value="<?php echo($num); ?>">
<p><b>Only guestbook administrator may view this e-mail address.</b></p>
<p>Please enter your administration password:<br>
<input type="password" name="pass" size="20"></p>
<p><input type="submit" value="View email"> | <a href="Javascript:history.go(-1)">Back</a></p>
</form>
<p>&nbsp;</p>
<p>&nbsp;</p>
<?php
printDownHTML();
exit();
} // END confViewEmail

Delete the following lines starting at line 796 (original GBook) or line 845 (after previous additions)

Code: Select all

if ($email)
{
	echo '<font class="smaller">E-mail:</font> <a href="mailto:'.$email.'" target="_blank" class="smaller">'.$email.'</a>';
}
Add after line 823 (original GBook) or line 868 (after previous edits)

Code: Select all

&nbsp;<a href="gbook.php?a=viewIP&num='.$i.'"><img src="images/ip.gif" width="14" height="14" border="0" alt="View IP address"></a>
this code

Code: Select all

&nbsp;<a href="gbook.php?a=viewEmail&num='.$i.'"><img src="images/email.gif" width="14" height="14" border="0" alt="View e-mail address"></a>
You can use this image Image (freely available from http://ndesign-studio.com/resources/pixel_icons.htm) or any other image with size 14x14 px as long as you place it in the images folder and name it email.gif

Greetings,
Henrie

Posted: Tue Feb 06, 2007 1:41 pm
by jayceegee
Hello Henrie,

My apologies for asking another favour so quickly after my request on spacing, but would it be possible to update the “hide email” for v1.5, again when time permits. The script you gave for 1.43 will not work with 1.5, as much of it has changed.

The (almost) perfect solution would be as described by Raiderguy in his request at viewtopic.php?t=1112 but in the opposite sense, that submitters would need to click a check box to hide their email address.
klemen did say he “may” add it in the next update, but with so many free scripts, there is no doubt a limit to what he can do in the time available, he still has to put bread on the table.

Regards, Jim.

Posted: Tue Feb 06, 2007 5:12 pm
by Henrie
Hi Jim,

I will look into it, not right now but maybe later today or later this week.

To make hiding the e-mail address optional for the writer would require adding a new field to the entries.txt file. This could make it incompatible with future versions of Gbook when Klemen decides to add new fields, so i'm reluctant to do this.

Greetings,
Henrie

Posted: Tue Feb 06, 2007 6:09 pm
by Klemen
Hi,

Henrie is correct, to give USER the option to hide/show his/her address would require new field in the text file. The solution in the next version will probably be ability for admin to select "hide e-mails" in the settings file and then have access to them only with his admin password.

Posted: Tue Feb 06, 2007 7:51 pm
by jayceegee
Hello Klemen and Henrie,

Thank you for your replies.

When Henrie does post the code here, it is a short term fix as the coding does change as the guestbook evolves.

As it is something that does get asked for, if Klemen can add it to his list of "to does" (I expect the list is large), it would be greatly appreciated by myself, and no doubt other members of the forum.

Many thanks. Jim.

Posted: Sun Feb 18, 2007 12:30 pm
by Henrie
Hello jayceegee,

It took a bit longer than a week but here it is.

Hide e-mail address (for GBook v 1.5)

This modification is for hiding the e-mail addresses in the guestbook.
It also has the possibility to view the e-mail address by entering the admin password.
It does not have an option for the writer to choose if his e-mail is shown or not.

It is the almost the same solution as for GBook v. 1.43 but this new solution has an option to set dis/enable hiding in the settings.php file.

So here it goes.

Open the file gbook.php (preferably in a editor with line numbers, for example PSPad)
Add after line 162

Code: Select all

seeIP($pass,$num);
this code

Code: Select all

    } elseif($a=='viewEmail') {
        $num=gbook_isNumber($_REQUEST['num'],'Invalid ID');
        confViewEmail($num);
    } elseif($a=='seeEmail') {
        $pass=gbook_input($_REQUEST['pass'],'Please enter your password');
        $num=gbook_isNumber($_REQUEST['num'],'Invalid ID');
        seeEmail($pass,$num);
Add after line 307 (original GBook) or line 313 (after previous addition)

Code: Select all

} // END confViewIP
this code

Code: Select all


function seeEmail($pass,$num) {
global $settings;
if ($pass != $settings[apass]) {problem('Wrong password!');}
$lines=file($settings['logfile']);
$myline=explode("\t",$lines[$num]);
if (empty($myline[2])) {$email='E-MAIL NOT AVAILABLE';}
else
{
	$email=rtrim($myline[2]);
}
?>
<p>&nbsp;</p>
<p>&nbsp;</p>

<p>The submitter of this post has entered the following e-mail adress:<br /><b><?php echo $email; ?></b></p>
<p><a href="gbook.php?page=1">Click here to continue</a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<?php
printDownHTML();
exit();
} // END seeEmail

function confViewEmail($num) {
?>
<h3 style="text-align:center">View E-mail address</h3>
<form action="gbook.php" method="post">
<table class="entries" cellspacing="0" cellpadding="4" border="0" width="450">
<tr>
<td>

<p>&nbsp;<br />
Only guestbook owner may view E-mail addresses of people who posted into this
guestbook. To view the E-mail for the selected post please enter
your administration password and click the "View E-mail" button.</p>

<table border="0">
<tr>
<td><p><b>Administration password:</b></p></td>
<td><p><input type="password" name="pass" size="20" /></p></td>
</tr>
</table>

<p>&nbsp;</p>
<p style="text-align:center"><input type="submit" value="View E-mail" /> | <a href="gbook.php">Cancel / Go back</a>
<input type="hidden" name="num" value="<?php echo($num); ?>" /><input type="hidden" name="a" value="seeEmail" /> </p>
<p>&nbsp;</p>
<p>&nbsp;</p>

</td>
</tr>
</table>
</form>
<?php
printDownHTML();
exit();
} // END confViewEmail
Change the following line 895 (original GBook) or line 961 (after previous additions)

Code: Select all

if ($email)
to

Code: Select all

if ($settings['show_email'] && $email)
Add after line 922 (original GBook) or line 988 (after previous edits)

Code: Select all

&nbsp;<a href="gbook.php?a=viewIP&num='.$i.'"><img src="images/ip.gif" width="14" height="14" alt="View IP address" style="border:none" /></a>
this code

Code: Select all

';
if ($settings['show_email']==0 && $email) {
	echo '&nbsp;<a href="gbook.php?a=viewEmail&num='.$i.'"><img src="images/email.gif" width="14" height="14" alt="View E-mail address" style="border:none" /></a>';
}
echo '
You can now close the gbook.php file

You can use this image Image (freely available from http://ndesign-studio.com/resources/pixel_icons.htm) or any other image with size 14x14 px as long as you place it in the images folder and name it email.gif

Last step, adding the option to the settings.php file.
Open the settings.php file
Add the following lines to it

Code: Select all

/* Show E-mail adresses in guestbook? 1 = YES, 0 = NO */
$settings['show_email']=0;
You can now save and close the settings.php file.

Greetings,
Henrie

Posted: Sun Feb 18, 2007 1:36 pm
by jayceegee
:D Henrie, you are a **STAR**, it works perfectly.

On behalf of myself and others who will use it. Thankyou for all the work you have put in to these script additions.

Perhaps Klemen may consider this script for the next upgrade to his superb guestbook. :D

Regards, Jim.

Thanks!

Posted: Fri Apr 20, 2007 5:52 pm
by Mac
Hello Henri,
Just like Jim (above post) I would like to thank you and Klemen for the work you put in to this script. It benefits many people.

I have implemented the manual code to hide email addresses and this works perfectly. This addition to the script is a very good one.

Regards and thanks