#!/usr/bin/perl #path to perl ############################################################### # This program is being distributed as Freeware. It may be used and # modified free of charge use, so long as this copyright notice remain intact. # 2b Guestbook v.2.0 Freeware # Script created by Sergey Totsky thebest@mail.ru # http://forumru.virtualave.net/aguest/ ################################################################ print "Content-type: text/html\n\n"; if ($ENV{'QUERY_STRING'}) {$namevalues = $ENV{'QUERY_STRING'};} else {read(STDIN, $namevalues, $ENV{'CONTENT_LENGTH'});} @pairs = split(/&/, $namevalues); 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///g; $value =~ s/<([^>]|\n)*>//g; $form{$name} = $value;} #--------~~~~~VARIABLES~~~~~~~-------# #path where info will be stored $base = "base.txt"; #header of every page $header = "header.htm"; #footer of every page $footer = "footer.htm"; #pic for table creation $pix = "pixel.gif"; # this picture split visitor post and admin reply ............ $line = "dots.gif"; #Url to script $scripturl = "http://www.crumlinviaduct.co.uk/cgi-bin/viabook/2bguest.pl"; # visitor will see this name when you reply some post $adminname = "Admin"; # also visitor will see this E-mail $adminmail = "john\@crumlinviaduct.co.uk"; #end of editing ! #now run script http://www.crumlinviaduct.co.uk/cgi-bin/viabook/2bguest.pl?action=home #if You want to make guestbook in Your language #translate this VARIABLES>> $namevar ="Name : "; $countryvar = "Country : "; $mailvar = "E-mail (optional) :"; $post_data = "Post Date : "; $urlvar = "Location : "; $added = "Diolch Thanks. Message Received."; $signgbvar = "Sign Guestbook"; $viewgbvar = "View Guestbook"; $form_contact_info = "Visitor Information :"; $form_name = "Your Name :"; $form_mail ="E-mail :"; $form_country ="Country : "; $form_url ="Site Url :"; $form_message ="Message :"; &header; ########end translation $action = $form{'action'}; $page = $form{'page'}; $first = $form{'first'}; $ip = $ENV{'REMOTE_ADDR'}; if ($action eq 'form') {&form;} if ($action eq 'view') {&view;} if ($action eq 'sform') {&sform;} if ($action eq 'home') {&home;} sub view { if ($first eq '1') {$kick = 0;$pageval1 = 0;} else {$kick = 10*$first-10;$pageval1 = 50*$first-50;} $pagesssma = 0+$kick;$pagesssmb = 1+$kick;$pagesssmc = 2+$kick;$pagesssmd = 3+$kick; $pagesssme = 4+$kick;$pagesssmf = 5+$kick;$pagesssmg = 6+$kick;$pagesssmh = 7+$kick; $pagesssmi = 8+$kick;$pagesssmj = 9+$kick;$pagesssmj = 10+$kick; $ar = 1+$kick;$br = 2+$kick;$cr = 3+$kick;$dr = 4+$kick;$er = 5+$kick;$fr = 6+$kick; $gr = 7+$kick;$hr = 8+$kick;$ir = 9+$kick;$jr = 10+$kick;$pagevala = 0+$pageval1;$pagevalb = 5+$pageval1; $pagevalc = 10+$pageval1;$pagevald = 15+$pageval1;$pagevale = 20+$pageval1;$pagevalf = 25+$pageval1; $pagevalg = 30+$pageval1;$pagevalh = 35+$pageval1;$pagevali = 40+$pageval1;$pagevalj = 45+$pageval1; $aa ="$ar";$bb =" | $br";$cc =" | $cr";$dd =" | $dr";$ee =" | $er"; $ff =" | $fr";$gg =" | $gr";$hh =" | $hr";$ii =" | $ir"; $jj = " | $jr"; $a ="$ar"; $b =" | $br"; $c =" | $cr"; $d =" | $dr"; $e =" | $er"; $f =" | $fr"; $g =" | $gr"; $h =" | $hr"; $i =" | $ir"; $j =" | $jr"; ######end~ open (FE, "$base")|| die "not found"; @lines = ; foreach $lines (@lines){$howmanylines++;} $perpage = "7"; $pagesss = $howmanylines/$perpage; @lines = reverse(@lines); ($as,$bs,$cs,$ds,$es,$fs,$gs) = (0,1,2,3,4,5,6); @kat = ($as+$page,$bs+$page,$cs+$page,$ds+$page,$es+$page,$fs+$page,$gs+$page); if ($howmanylines > $page+7) {$astop1 = $as+$page+1;$astop2 = $gs+$page+1;} else {$astop1 = $as+$page+1; $astop2 = $howmanylines;} #header print qq~

[ $signgbvar ]

~; #end header foreach (@lines[@kat]){ ($id,$month,$day,$year,$date,$name,$mail,$url,$country,$ip,$desc,$reply) = split('[|]',$_); if($url eq ""){$urld = "";} else {$urld = "$url";} if($country eq ""){$country = "";} if($name ne ""){ ############################################## print qq~

$desc

$name $mail

$url $country on -$date

~; if($reply ne ""){ print qq~

 

~; } print qq~ ~; } } print "
Pages "; if ($first > "1") {print " < ";} if ($pagesssma < $pagesss) {if ($page eq $pagevala) {print $aa;}else {print $a;}} if ($pagesssmb < $pagesss) {if ($page eq $pagevalb) {print $bb;}else {print $b;}} if ($pagesssmc < $pagesss) {if ($page eq $pagevalc) {print $cc;}else {print $c;}} if ($pagesssmd < $pagesss) {if ($page eq $pagevald) {print $dd;}else {print $d;}} if ($pagesssme < $pagesss) {if ($page eq $pagevale) {print $ee;}else {print $e;}} if ($pagesssmf < $pagesss) {if ($page eq $pagevalf) {print $ff;}else {print $f;}} if ($pagesssmg < $pagesss) {if ($page eq $pagevalg) {print $gg;}else {print $g;}} if ($pagesssmh < $pagesss) {if ($page eq $pagevalh) {print $hh;}else {print $h;}} if ($pagesssmi < $pagesss) {if ($page eq $pagevali) {print $ii;}else {print $i;}} if ($pagesssmj < $pagesss) {if ($page eq $pagevalj) {print $jj;}else {print $j;}} if ($pagesssmj < $pagesss) {print " \>";} print qq~

Total entries : $howmanylines

~; &iocopy; } ########~~~Submit Form~~~~ sub form { print qq~

Fill in the blanks 

Your Name :
E-mail (optional) :
Country :
Location :
Message :

~; } sub error { print qq~ Error

E\~r\~r\~o\~r :

  $message


\< Go Back
~; &footer; exit 0 ; return 1 ; } sub header { open(FILE,"$header"); while() { print $_; } } sub footer { open(FILE,"$footer"); while() { print $_; } } sub home { print qq~ ~; } sub sform { if ($ENV{'QUERY_STRING'}) {$namevalues = $ENV{'QUERY_STRING'};} else {read(STDIN, $namevalues, $ENV{'CONTENT_LENGTH'});} @pairs = split(/&/, $namevalues); 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///g; $value =~ s/<([^>]|\n)*>//g; $form{$name} = $value;} $message = "" ; $found_err = "" ; $words= '30' ; $vocal = "temp_words.txt"; $message = "" ; $found_err = "" ; $new_word = $form{'desc'}; $new_word =~ s/ /\n/g; $new_word =~ s/<([^>]|\n)*>//g; open(FILE, ">$vocal"); print FILE "$new_word" ; close(FILE); open(FILE, "$vocal"); @eword = ; close(FILE); foreach $eword(@eword) { chomp($eword); if (length("$eword") > $words ){ $errmsg = "

No more grrrrrrrrrr pleeeeeeeeease

\n" ; $message = $message.$errmsg ; $serror = 1 ; } } @months = ('Jan','Feb','Mar','Apr','May','June','July','Aug','Sept','Oct','Nov','Dec'); @days = ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'); ($sec,$min,$hour,$mday,$mon,$year,$wday) = (localtime(time))[0,1,2,3,4,5,6]; $year += 1900;$date = "$months[$mon] $mday,$year"; @months_digi = ('01','02','03','04','05','06','07','08','09','10','11','12'); @days_digi = ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'); ($sec,$min,$hour,$mday,$mon,$year,$wday) = (localtime(time))[0,1,2,3,4,5,6]; $year += 1900; $months_digi = "$months_digi[$mon]"; $day = "$mday"; if (length($day)<2) {$day = "0$day"} #random ID $tt = time; $n=substr($tt,4,); $id="$n$$"; $name = $form{'name'}; $mail = $form{'mail'}; $url = $form{'url'}; $country = $form{'country'}; $desc = $form{'desc'}; $desc =~ s//>/g;$desc =~ s/\cM//g;$desc =~ s/\n\n/

/g; $desc =~ s/\n/
/g; #name check $errmsg = "

Enter Your Name

\n" ; if (length($name)<2) { $message = $message.$errmsg ; $serror = 1 ; } #description check $errmsg = "

Comment field must be between 5 and 1000 characters

\n" ; if (length($desc)<5 || length($desc)>1000) { $message = $message.$errmsg ; $serror = 1 ; } if ($serror) { &error; } open(FE, ">>$base"); print FE "$id|$months_digi|$day|$year|$date|$name|$mail|$url|$country|$ip|$desc|$reply|\n"; close(FE); &thanks; &home; } sub thanks { print qq~
$added