Because in another thread someone asked for the extra field too and because it has been asked several times more, I decided to finally post it.
But first a warning:
This modification may make the entries.txt flatfile database incompatible with future versions of the guestbook.
The content of the extra field will be stored in the entries.txt flatfile database. Newer versions of GBook may use more fields itself for extra functionality. This will make that in that case the entries.txt file -that contains contents of the extra field added by this modification- can not be used together with the newer version of GBook.
Now that you know about the possible risks of using this modification, here it goes.
Extra field for GBook version 1.7
Open the file sign_form.php
This can be found in your templates/default folder (or other template name if you created it).
This code is needed for adding the extra field to your 'sign guestbook' page.
Search for (lines 54-56)
Code: Select all
<div class="clear"></div>
<div class="gbook_left"><span class="gbook_entries"><b><?php echo $lang['t16']; ?></b></span></div>
Add at the empty line 55
Code: Select all
/* extra field modification by Henrie >> HL06 start */
<div class="gbook_left"><span class="gbook_entries"><?php echo $lang['hl06_t01']; ?></span></div>
<div class="gbook_right"><input type="text" name="extrafield1" value="<?php echo $newfield1; ?>" size="45" /></div>
<div class="clear"></div>
/* extra field modification by Henrie >> HL06 end */
save and close the sign_form.php file.
If you want the extra field to appear in another part of the sign page, you can insert the code at another location. But it is best to put it first at this location and after making all the modifications test that it is working before you move it.
Open the file comments.php
This can be found in your templates/default folder (or other template name if you created it).
This code is needed for displaying the extra field in your guestbook page.
Search for (lines 22-25)
Code: Select all
if ($email)
{
echo '<span class="gbook_submitted_by">'.$lang['t20'].' '.$email.'</span><br class="clear" />';
}
Below it add
Code: Select all
/* extra field modification by Henrie >> HL06 start */
if ($extrafield1)
{
echo '<span class="gbook_submitted_by">'.$lang['hl_t10'].' '.$extrafield1.'</span><br class="clear" />';
}
/* extra field modification by Henrie >> HL06 end */
save and close the comments.php file.
If you want the extra field to appear in another part of the guestbook entry, you can insert the code at another location. But it is best to put it first at this location and after making all the modifications test that it is working before you move it.
Open the file gbook.php
Part 1 of 12: PrintEntries
This code is needed for reading the fields from the entries.txt file and together with comments.php file display the entries in the guestbook.
Search for (line 1079)
Code: Select all
list($name,$from,$email,$url,$comment,$added,$isprivate,$reply)=explode($delimiter,$lines[$i]);
and replace it with
Code: Select all
/* extra field modification by Henrie >> HL06 part 1 of 12: PrintEntries start (extrafield1 added and IP to fill the gap) */ list($name,$from,$email,$url,$comment,$added,$isprivate,$reply,$IP,$extrafield1)=explode($delimiter,$lines[$i]);
/* extra field modification by Henrie >> HL06 part 1 of 12: PrintEntries end */
Part 2 of 12: PrintSign
This code is used for displaying the 'sign guestbook' page.
Search for (line 1011)
Code: Select all
function printSign($name='',$from='',$email='',$url='',$comments='',$nosmileys='',$isprivate='',$error='',$spamanswer='')
and replace it with
Code: Select all
/* extra field modification by Henrie >> HL06 part 2 of 12: PrintSign start (extrafield1 added) */
function printSign($name='',$from='',$email='',$url='',$extrafield1='',$comments='',$nosmileys='',$isprivate='',$error='',$spamanswer='')
/* extra field modification by Henrie >> HL06 part 2 of 12: PrintSign end */
Part 3 of 12: e-mail notification
This code is used to send you an e-mail when a new entry is added
Search for (line 981)
Code: Select all
$message.= "$lang[t20] $email\n";
and directly below it add
Code: Select all
/* extra field modification by Henrie >> HL06 part 3 of 12: e-mail notification start (extrafield1 added) */
$message.= "$lang[hl06_t02] $extrafield1\n";
/* extra field modification by Henrie >> HL06 part 3 of 12: e-mail notification end */
If you want the extra field to appear in another part of the message, you can insert the code at another location. But it is best to put it first at this location and after making all the modifications test that it is working before you move it.
Part 4 of 12: approval e-mail
This code is used to send you an e-mail when you have approving of new messages activated
Search for (line 943)
Code: Select all
$message.= "$lang[t20] $email\n";
and directly below it add
Code: Select all
/* extra field modification by Henrie >> HL06 part 4 of 12: approval e-mail start */
$message.= "$lang[hl06_t02] $extrafield1\n";
/* extra field modification by Henrie >> HL06 part 4 of ?: approval e-mail end */
If you want the extra field to appear in another part of the message, you can insert the code at another location. But it is best to put it first at this location and after making all the modifications test that it is working before you move it.
Part 5 of 12: add entry
This code is used to add the entry to the flatfile database file
Search for (line 907)
Code: Select all
$addline = $name.$delimiter.$from.$delimiter.$email.$delimiter.$url.$delimiter.$comments.$delimiter.$added.$delimiter.$isprivate.$delimiter.'0'.$delimiter.$_SERVER['REMOTE_ADDR']."\n";
and replace it with
Code: Select all
/* extra field modification by Henrie >> HL06 part 5 of 12: add entry start (delimiter and extrafield1 added) */
$addline = $name.$delimiter.$from.$delimiter.$email.$delimiter.$url.$delimiter.$comments.$delimiter.$added.$delimiter.$isprivate.$delimiter.'0'.$delimiter.$_SERVER['REMOTE_ADDR'].$delimiter.$extrafield1."\n";
/* extra field modification by Henrie >> HL06 part 5 of 12: add entry end */
Part 6 of 12: filter bad words
This code is used to filter any bad words using the badwords file.
Search for (line 890)
and add following code directly below
Code: Select all
/* extra field modification by Henrie >> HL06 part 6 of 12: filter bad words start */
$newfield1 = filter_bad_words($newfield1); //HL06: newfield added
/* extra field modification by Henrie >> HL06 part 6 of 12: filter bad words end */
Part 7 of 12: JunkMark
This code is used to check the message with JunkMark. I do not actually know if it will check the field as I do not know the JunkMark code because it is encoded. If you do not want to use JunkMark for the extra field, than skip this.
Search for (line 860)
Code: Select all
$junk_mark = JunkMark($name,$from,$email,$url,$comments);
and replace it with
Code: Select all
/* extra field modification by Henrie >> HL06 part 7 of 12: JunkMark start (extrafield1 added) */
$junk_mark = JunkMark($name,$from,$email,$url,$extrafield1,$comments);
/* extra field modification by Henrie >> HL06 part 7 of 12: JunkMark end */
Part 8 of 12: display error
This code is used to display an error message if needed.
Search for (line 854)
Code: Select all
printSign($name,$from,$email,$url,$comments,$sign_nosmileys,$sign_isprivate,$error_buffer,$spamanswer);
and replace it with
Code: Select all
/* extra field modification by Henrie >> HL06 part 8 of 12: display error start (extrafield1 added) */
printSign($name,$from,$email,$url,$extrafield1,$comments,$sign_nosmileys,$sign_isprivate,$error_buffer,$spamanswer);
/* extra field modification by Henrie >> HL06 part 8 of 12: display error end */
Part 9 of 12: error message
This code is used to create an error message for a defined condition.
If you don't need the extra field being checked for being empty (or another condition you creat yourself), than skip this part.
Search for (lines 783-787)
Code: Select all
if ($url=='INVALID')
{
$error_buffer .= $lang['e05'].'<br class="clear" />';
$url = '';
}
and directly below it add
Code: Select all
/* extra field modification by Henrie >> HL06 part 9 of 12: error message start */
if (empty($extrafield1))
{
$error_buffer .= $lang['hl06_e01'].'<br class="clear" />';
}
/* extra field modification by Henrie >> HL06 part 9 of 12: error message end */
Part 10 of 12: add entry
This code is used to add the entry to prepare the entry for being added to the guestbook.
Search for (lines 760)
Code: Select all
$from = gbook_input($_POST['from']);
and directly below it add
Code: Select all
/* extra field modification by Henrie >> HL06 part 10 of 12: add entry start */
$extrafield1 = gbook_input($_POST['extrafield1']);
/* extra field modification by Henrie >> HL06 part 10 of 12: add entry end */
Part 11 of 12: notify visitor
This code is used for the message sent to the visitor when a reply is made to his/her guestbook entry.
Search for (lines 476)
and directly below it add
Code: Select all
/* extra field modification by Henrie >> HL06 part 11 of 12: notify visitor start */
$extrafield1 = $myline[9];
/* extra field modification by Henrie >> HL06 part 11 of 12: notify visitor end */
Part 12 of 12: reply message
This code is used for the reply to a message.
Search for (lines 458)
Code: Select all
$myline = array(0=>'',1=>'',2=>'',3=>'',4=>'',5=>'',6=>'',7=>'',8=>'');
and replace it with
Code: Select all
/* extra field modification by Henrie >> HL06 part 12 of 12: reply message start (added ,9=>'') */
$myline = array(0=>'',1=>'',2=>'',3=>'',4=>'',5=>'',6=>'',7=>'',8=>'',9=>'');
/* extra field modification by Henrie >> HL06 part 12 of 12: reply message end */
save and close the gbook.php file.
Open the file language.inc.php
Add the following code before the
?> at the end of the file:
Code: Select all
/* Language strings for modifications by Henrie */
$lang['hl06_t01']='<b>Your extra field 1:</b>'; // used for field name on sign page
$lang['hl06_t02']='Extra field 1:'; // used for field name in E-mail and guestbook page
$lang['hl06_e01']='Please enter your name extra field 1:';
When you are not using it as a required field, than remove the <b> and </b> from the above code.
save and close the language.inc.php file.
This shoud be it.
Only basic posting has been tested. So please let me know if something does not work.
Greetings,
Henrie