I have setup a guest book on my brother's website Paul Owen Lewis and I want to change the way the entries look. Change the font, spacing, add a small icon to denote the beginning of a new entry, etc... kinda like This One. I believe to do this I need to edit the "guestbook.pl" file on my host server (and I have done this so far to edit the background, etc.) but I can't find anywhere that I would edit it to change the way the entries look.

The guestbook.pl file

Any I deas? Am I way off track here?

Thanks, RS

Yes, You need to edit the CGI (the guestbook.pl) in order to modify the appearance of the entries. The thing to understand here, is that guestbook.pl actually edit's the html file that contains the guestbook entries. So, guestbook.pl opens the file polguestbook.html, and reads everything that's in it, into an array. Then, it modifies the information in the array (it adds a new guestbook entry), then it re-writes polguestbook.html back to the disk. If you want to try a little experiment, load the guestbook web page: http://paulowenlewis.com/guestbook/polguestbook.html, and then right click on the page and view page source. Hit F3 (find), and type in --begin
that's where the CGI (guestbook.pl) actually starts making changes to the file. In the CGI, search for: # Open Link File to Output
Everywhere below that where you see:

print GUEST "whatever in here";

is actually where the entries are being added to the HTML file. So, you can modify those lines to contain fonts, tables, or images. This line, for instance:

print GUEST "<b>$FORM{'comments'}</b><br>\n";

is where it actually writes to the HTML file, what the user typed and submitted. So, you could remove the Bold tags, or add italics, or whatever you want in order to make it look the way you want it to. Let me know if this helps, or if you need further assistance.

Ok, thanks... just don't know the lingo yet I guess. I'll be working on it and let you know when I have it done so you can see... (If'n ya want)

Thanks again Coma!

RS

P.S. can you tell from lookin at the .pl file why my date/time appears as "-" insted of showing the date/time? In my old GB it appeared as... 12:22 am - Monday, April 11, 2005

Sure Can. The command that the .pl file is using to get the date and time is the unix date command, which is found under /usr/bin, you can see that it refers to the path here:

$date_command = "/usr/bin/date";

Now, the date is actually called twice, in 2 different formats. A Short Format and A Long Format, Which is saved into 2 different variables here:

# Get the Date for Entry
$date = `$date_command +"%A, %B %d, %Y at %T (%Z)"`; chop($date);
$shortdate = `$date_command +"%D %T %Z"`; chop($shortdate);

I don't know the version of unix that this page is being hosted on (or even if it is unix, maybe it's with windows with active Perl, I honestly don't know), but I know that it is different from the server I host mine on. If you have shell access, which I bet you can connect through SSH (Secure Shell) to the server, you can execute the linux command "man" which is a manual page. So: man date
will give you the manual page about the date command. On my server, It is as follows (on yours, I'll bet it's different):

%A Represents The Day Of The Week (Monday, Tuesday, Wednesday, etc)
%B Represents The Month (april, may, june)
%d Represents The Day Of The Month (19, 20)
%Y Represents The Year (2005)
%T Represents The Time (18:08:21)
%Z Represents The Time Zone (EDT)

Now mind you, that's on my server, the server hosting your page might use a different set of internal variables, I don't know. In order for me to get the date to appear like this: 04/20/05, I have to use a: date +"%D"
And it turns out perfect. Anyway, in the .pl file, it also writes to the .HTML file with a - before date. I'll be perfectly honest, I don't see where the time comes in to play before the - in the .pl file, unless you changed something on me recently in the .pl file and didn't update the .txt file to reflect those changes. But here are the lines that affect where the time and date are written to the .html file:

if ($separator eq '1') {
     print GUEST " - $date<hr>\n\n";
} else {
     print GUEST " - $date<p>\n\n";
}

You can see that it uses a - right off the bat before adding the $date to the file, what I don't get, is where the time is printed in that, but I'm guessing some changes where made in the .pl file, not shown in the .txt. I hope this helps a little, if this seems fairly confusing, I apologize, just ask and I will help to break it down.

The server I am running on is Unix based - here is some info from the serverinfo.cgi file...

SERVER_SOFTWARE: Apache/1.3.33 (Unix) mod_fastcgi/2.4.2 FrontPage/5.0.2.2635 mod_jk/1.2.6

As for the time and date shown... no I didn't change the .pl file, I copied the entries and the code from my old guestbook and added them to my new "guestbook.html" page so that I could retain my old entries and have then look like my new ones.

Ok, I have seen the - $date_command = "/usr/bin/date"; - and $date = `$date_command +"%A, %B %d, %Y at %T (%Z)"`; chop($date); near the top of the .pl file, but I don't know how to format it in the "# Open Link File to Output" section so that the date appears as desired. The time is desired, but not essential.

Thanks for your input so far, it has been invaluable!

Well, at the "# Open Link File to Output" section, where you see:

if ($separator eq '1') {
         print GUEST " - $date<hr>\n\n";
      }
      else {
         print GUEST " - $date<p>\n\n";
      }

Try changing the - to a /, and if that doesn't work, I'll put on my sunglasses, and start digging into it in my infamous "Code Mode" ;)

Ok Coma, get out your sunglasses :cool:

I tried exactly what you said, and also tried a few of my own creative ideas... none workded :sad: Everything I replaced the - with just appeared verbatim in the GB entry like the dash did... ie: a/,

Thanks for your persistence.

So, It showed up the same as before, with the -, even when you changed it to a /????

Something just struck me like a ton of bricks about this too! The .pl file ONLY CHANGES THE .HTML FILE WHEN THERE IS A NEW ENTRY!!! That slipped my mind altogether. Basically, Only new entries would have the "changed" date, not the ones that are already there, because that time and date has already been written to the .HTML file in that format. So, only new entries would show up with the new date and time format. Also, the old entries would have to be changed by hand in order to look the same as the new entries!!!! I forgot completely that it re-writes the .HTML file, and only adds the new data! Sorry about that, I should have caught that one sooner!

no, not with the "-"... with whatever I replaced the "-" with, like the "a/"

When I do change the - to a/, it just prints (or diplays) "a/" insted of the "-"

Yes, that's right. I changed the HTML manually in the old entries, sorry I didn't mean for you to lose your mind.


so, am I out of luck here?

What I mean is, when I go to http://davidrl41.signmyguestbook.com/, or http://paulowenlewis.com/guestbook/polguestbook.html, the date still shows as: 12:22 am - Monday,April 11, 2005
If you change the - to a / it shows up as: 12:22 am / Monday, April 11, 2005, right? When I go to those websites, I'm still seeing the date with the -, so it appears as though it has not been changed in the HTML file. The .pl file only writes to the HTML file when there is a new post, and for that matter, it only writes the new post... it doesn't re-write any other information. I'm going to copy the source HTML page to my server, so that I can tinker around with it, and see what is happening with the date.

*puts on his sunglasses*

I copied the html that made up the existing entries from the "signmyguestbook" page and pasted it into the "paulowenlewis" page so I wouldn't lose them. The .pl file has never made a date appear. When I edit the .pl file and changed the - to a/ I got nothing but what I put there. If I leave the - there and make a new entry I get the -. If I put the a/ in there and make a new entry I get a/ not the date.

Feel free to make new entries if you want to test it. I'll check it periodically and delete your entries... Just put your name in as comatose and I will know to delete it.

Thanks again!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.