Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unusual Guest Book 1

Status
Not open for further replies.

usakjw

Programmer
Sep 8, 2005
47
US
I want to have a guest book on my site. However I want to be able to have an unknown to the public page, and possibly pass word protected, where I can delete entries from the guest book if I want to. I realize that this will take at least two seperate scripts.

I am a VB programmer. However I know very little on CGI and understand even less. If somebody can point me in the right direction I would greatly appreciate it

Thank you

KJW
 
you could do it with one script but two is OK, one for the public and one for the administrator. Are you asking for help coding such a guestbook using perl?
 
Yes. I have very little to no idea how to even start writing a script like this. If some one would not mind writing it form me I would appreciate it. If you would, although you don't have to if you do not want to, take the time explain the code to me so that I can learn it (CGI). I would like to learn as much as possibl
 
Hi

KJW, please give us more detail. For example, is anything of that guestbook already done, and if yes, what it does ?

An other important question would be, how the posts are stored ? And what kind of webserver you use and what rights you have ?

I think, the easy way is to have two scripts :
[ul]
[li]for public use - list the existing posts and has a form for new posts[/li]
[li]for private use - list the existing posts with an order number beside each, and a form in which you can enter the number of a post to delete[/li]
[/ul]
The access to the second script could be restricted by the webserver through HTTP authentication.

Feherke.
 
feherke

The only thing that I have done on the Guest Book is the form.

It collects the First and Last name, and comments.

I have no idea where to even start with the CGI.

I pretty sure that I am using a unix server (I did not set up the domain). I do not know about the rights that I have. So far every thing I have done I have been allowed to do I do not know if it helps, but the hosting company is Hostway.

KevinADC and ChrisHunt

I will check out the links that you provided

Thanks for the help

KJW
 
Hi

This Hostway ? There is something about Your own CGI-BIN, but no details. Sometimes this mean on that you are able to select some scripts from those already existing on the server, but you can not upload yours.

I would try to upload the below script in the [tt]cgi-bin[/tt] directory, then to access it from a browser.
Code:
#! /usr/bin/perl

print "Content-type: text/plain\n\n";

foreach (keys %ENV) { print "$_ = $ENV{$_}\n"; }

Anyway, please inform as about your intentions, you want your own script, or just use something available on the net.

Feherke.
 
I am capable of uploading my own scripts if I want.

They do have their own scripts on the server but they are not what I want.

I have tried to download their code but everytime I do it is garled and unreadable. I have also tried it out and did not like it. For one thing (do not understand how or why) it took me to a different (completely differnt than mine) were the book was hosted (I guess). I want to be able to format the guest book just like the rest of my page. I'm using SSI to include a menu and other items on every page. I do not want my visitors to have to go back to the main page every time they want to go to a different part of the site.

I have checked out some of the links mentioned by KevinADC and ChrisHunt. They all have the guest books pre made which is fine, but I want the code explained to me so that I can learn to write my own CGI's. If no one wants to help me with the code and explain what is is doing and how it works. Does any body know of a good web site that does?

feherke
I do think that I would rather have two files as you suggested. I think that it would work better.

I realize that everybody does not want to do someone else work. I am trying to learn and would appreciate any help. Hopefully in the future I can return any and all favors.

KJW
 
Hi

I'm happy to read about your willing to learn.

The possible solution I wrote, depends on the right to use .haccess files on the server to restrict the access to protected files. Hostway use Apache webserver, so is fairly possible to be enabled.

If you already use SSI, you can continue with them. The output created by the code from my above post could be included in a HTML document :
Code:
<!--#include virtual=/cgi-bin/env.pl -->
Assuming that you saved it as env.pl and uploaded it in the cgi-bin directory.

Try this, then we will see how to continue.

Feherke.
 
I can use .htaccess. I am already using for a 404 error page.

I do not weather or not hostway uses apache or not. I can find out though.

I have uploaded the pl file and put the line in your last file into a shtml file and uploaded it as well. When I loaded the shtml file I got no response or atleast none that I seen. What is the output suppose to be.


KJW
 
Hi

That script simply list the environment variables. Because it's output is plain text, there must be a couple of lines of unformated text.

See View | Page source in your browser. Is that [tt][highlight white]<!--#include virtual=/cgi-bin/env.pl -->[/highlight][/tt] line stil there ? You put it in a regular file with .shtml extension, right ?

Feherke.
 
Ok I got it to work. I had to put quotes around the /cgi-bin/env.pl

Here is the output

QUERY_STRING = SERVER_ADDR = 66.113.130.179 DOCUMENT_NAME = env.shtml HTTP_ACCEPT_LANGUAGE = en-us DOCUMENT_PATH_INFO = SERVER_PROTOCOL = INCLUDED HTTP_CONNECTION = Keep-Alive REMOTE_PORT = 2073 DATE_GMT = Friday, 09-Sep-2005 16:40:00 GMT HTTP_USER_AGENT = Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 1.0.3705) HTTP_ACCEPT = */* HTTP_HOST = GATEWAY_INTERFACE = CGI/1.1 SERVER_SOFTWARE = Apache/1.3.31 (Unix) FrontPage/5.0.2.2634 SERVER_ADMIN = webmaster@lyndatyler.com LAST_MODIFIED = Friday, 09-Sep-2005 11:39:38 CDT USER_NAME = lyndatyler REMOTE_ADDR = 68.232.95.136 SCRIPT_NAME = /cgi-bin/env.pl SERVER_NAME = HTTP_ACCEPT_ENCODING = gzip, deflate DATE_LOCAL = Friday, 09-Sep-2005 11:40:00 CDT DOCUMENT_ROOT = / REQUEST_URI = /env/env.shtml UNIQUE_ID = QyG64EJxgrMAABh9EdI DOCUMENT_URI = /env/env.shtml SCRIPT_FILENAME = / REQUEST_METHOD = GET PATH = /usr/local/bin:/usr/bin:/bin SERVER_PORT = 80

KJW
 
Just got e-mail from my hosting company that the OS is Linux and that it is running Apache



KJW
 
Hi

I wrote a draft guestbook. Works with my Apache 2.0.54 on Linux. Is based on my above mentioned idea :
[ul]
[li]gb_public.shtml - allows posting messages with some basic restrictions[/li]
[li]gb_private.shtml - password protected through HTTP autentication by the webserver, allows deleting of messages[/li]
[/ul]

Both files contains only the static part, the message list is included from the output of two Perl scripts. Messages are stored in a plain text file in tab-separated format.

Later I realized that my idea was not as good as for first glance seems. But I finalized it anyway, because with this SSI + CGI combination you could customize the appearance with fewer modifications in the script, editing mostly the HTML.

Please try it and notify me if anything missing.

( Note : file will be removed after awhile. )

Feherke.
 
feherke

This is basiclly what I want. However on the form says that the email address will not be shown, but it is. I would only want to use it to send a Thank you e-mail which I can do. Is it possible to hide the IP and e-mail address from public view but veiw it on the private side

The gb_private, I can not get it to allow me log in. I have tried the user and password provided in the comments in the HTACCESS file. I have also tried creating my own. Where should the HTPASSWORD be put? In the cgi-bin, in the root folder or in the same folder as the SHTML files. (I put the in a folder called guest). Also where should the HTACCESS file go just to make sure I'm putting in the right place. I have it in the root directory for my 404 error page.

Thank you for your help

KJW
 
Hi

No, only name, date, subject and message are listed. E-mail address and IP is displayed only in the confirmation. And yes of course, those details can be listed by gb_private.pl. Change the line 44 to put them in another line :
Code:
print "<p>(",++$nr,") <b>$mes[2]</b> ( ".(localtime $mes[0])." ) : <i>$mes[4]</i><br>[red]( by $mes[3] from $mes[1] )<br>[/red]$mes[5]<br></p>";

The .htaccess file must be in the same directory where gb_private.shtml is. .htpasswd could be anywhere, but is recommended to put it near the .htaccess which refers it. Sadly on my machine I must use absolute path in .htaccess to the .htpasswd file, you must find out the actual path on that server.

I have to mention, that the ability to use .htaccess files and the kind of local settings allowed in it, may be restricted by global settings.

Feherke.
 
feherke

I have got exactly what I want now!! Thank you

I had pictured check booxes to select the ones to be deleted but I think this will work better

Two problems though I still can not get the authentication to work. I had bypassed this by not uploading the .htaccess and .htpasswd files.

Second I have tried to figure this out on my own with what little bit I know about CGI and perl, but I could not get it to work. I want to receive a notification via e-mail that a new entry has been added to the guest book. I have written a send MAIL program for the site, but I could not get it to work for this. What line do I need to add to print the visitors information (all of it) to the email. I have tried every thing I could think of.

Thanks Again

KJW
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top