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!

Flashkit guestbook .cgi script - is this configured right?

Status
Not open for further replies.

mjstone323

Technical User
Jan 11, 2002
57
US
Hi all -
I'm a complete newbie to this - I'm hoping someone has experience with both Flash and CGI -
I've been trying to get Matthias Kannengiesser's guestbook script to work. Here's the "book.cgi" script:

#!/usr/bin/perl

###############################################################
#
# Created by Matthias Kannengiesser
# Free to use for your own projects
# Made in Feb. 1998
# Modified for Flash in Nov. 1999
# Posted by #
# This script is a modified training version from the great
# authors Selena Sol and Matthew M. Wright. Thanx for the
# inspiration. I saw many other CGI based guestbook, but
# I think these modfified functions are good, too !
#
###############################################################

#### Set the Variables ##############################

$basedir="/usr/local/$listfile="kitbook.txt";
@referers = ('
#### Referer Check ##################################

&check_url;

sub check_url {

local($check_referer) = 0;

if ($ENV{'HTTP_REFERER'}) {
foreach $referer (@referers) {
if ($ENV{'HTTP_REFERER'} =~ m|https?://([^/]*)$referer|i) {
$check_referer = 1;
last;
}
}
}
else {
$check_referer = 1;
}

if ($check_referer != 1) { print "Error!\n"; }
}

###################################################


if (!$ARGV[0]) {
if($ENV{'REQUEST_METHOD'} eq 'GET')
{ $ARGV[0] = $ENV{'QUERY_STRING'};
}
else
{ read(STDIN, $ARGV[0], $ENV{'CONTENT_LENGTH'});
}
}
if ($ARGV[0]) {
%FORM;
&get_arg;

if ($FORM{'todo'} eq 'read' ) {
&read_book;
}

if ($FORM{'todo'} eq 'sign' ) {
&sign_book;
}
}
else {
print "no parameters!\n";
}

#### Initialize Arguments ##################################

sub get_arg {
@pairs = split(/&/, $ARGV[0]);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|\n)*-->//g;
$FORM{$name} = $value;
} #foreach
} #end get_arg


#### Read Book ##################################

sub read_book {
open (LISTE,&quot;<$basedir/$listfile&quot;) || die $!;
@liste = <LISTE>;
close (LISTE);
$ccount=0;
print &quot;Content-type: text/html\n\n&quot;;
foreach $zeile (@liste){
#print &quot;coeof=true&&quot;;
print $zeile;
print &quot;&&quot;;
$ccount++;
} #foreach
print &quot;&count=$ccount&eof=true&quot;;
}

#### Sign Book ##################################

sub sign_book {
$ccount=1;
&datum;
open (LISTE,&quot;<$basedir/$listfile&quot;) || die $!;
@liste = <LISTE>;
close (LISTE);
foreach $zeile (@liste){ $ccount++; }

open (BOOK,&quot;>>$basedir/$listfile&quot;) || die $!;
print BOOK &quot;aname$ccount=$FORM{'name'}&acomment$ccount=$FORM{'comment'}&aurl$ccount=$FORM{'url'}&adate$ccount=$long_date&aemail$ccount=$FORM{'email'}\n&quot;;
close (BOOK);

print &quot;Content-type: text/html\n\n&quot;;
print &quot;eof=true&quot;;
} #end sign_book

#### Get Date and Time ##################################
#### y2k Fix ##################################

sub datum {
@days = ('Sunday','Monday','Tuesday','Wednesday',
'Thursday','Friday','Saturday');
@months = ('January','February','March','April','May','June','July',
'August','September','October','November','December');


($sec,$min,$hour,$mday,$mon,$year,$wday) = (localtime(time))[0,1,2,3,4,5,6];
$time = sprintf(&quot;%02d.%02d&quot;,$hour,$min);
if ($mday < 10) { $mday = &quot;0$mday&quot;; }
# $time = sprintf(&quot;%02d:%02d:%02d&quot;,$hour,$min,$sec);
$year += 1900;
$long_date = &quot;$mday\. $months[$mon] $year ($time Clock)&quot;;
# $long_date = &quot;$days[$wday], $months[$mon] $mday, $year at $time&quot;;
}

exit;

Wow - it looks neat and tidy in this screen - the script gets very bunched up in Notepad. :)
So my question is - if this is all correct - why won't my guestbook go past the &quot;Read Entry&quot; section? In the working demo, it automatically takes you to the section where you can read entries *or* add a new one. The instructions say just to change the &quot;$basedir&quot; line and change the &quot;local($check_referer) = 0;&quot; to &quot;1&quot;. Also, in the Flash file, to change the loadVariables in the &quot;Read Entry&quot; section and in the Submit button from &quot; to reflect my website's path. (Is this supposed to be the same as the $basedir line?)
Hope someone can help me - I'm not sure what else I can do & I don't want to give up on this - I did too much work making the guestbook look purty! :)
Thanks -
Marianne Stone
 
BTW -
I do know that the files need to be uploaded into certain directories, and then chmoded... in case anyone was wondering. :) I don't think this is the problem.
Marianne
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top