#!/usr/bin/perl # Change to correct path. If unsure what path you have, telnet to your account # and type "which perl" without quotes. There you have it. ################################################################################ # YOU'VE GOT SCRIBBLE! # A piece of free guestbook software by Mr. Smith @ www.subademic.com. # Email: smith@subademic.com # -------------------- # SCRIBBLE VERSION 0.5 # -------------------- # This script and this header is tightly married, never separate the two. # You are not allowed to re-distribute this script in any shape, form or style. # Link www.subademic.com instead please. # # Please modify, enhance, trash, clean up, fix, or whatever you feel like. # Author takes no responsibility for anything, pre nor post modifies. # # Hope you find SCRIBBLE halfwhat useful! Drop me a note. ############################################################################# # If you alter names of the files, please reflect that here: # Do not change the extensions from 'cgi', they need be to "hide" the files. $cfg = "scribble_cfg.cgi"; $datafile = "scribble_dat.cgi"; # Leave scripturl as is or give the full system path to your script # Should be something like /cgi-bin/scribble/scribble.cgi $scripturl = "/cgi-bin/mrgtbk/scribble.cgi'}"; # Specify the scripts full adress ie # http://www.yoururl.to/scribble.cgi $script_http_url = "/scribble.cgi"; # cookie will expire in how many days? (adminpage access, consult documentation) $cookiedays = "365"; ############################################################################# # NO NEED TO MODIFY ANYTHING ELSE BELOW, DO IT ONLY IF YOU KNOW WHAT YOU'RE DOING. # You control your SCRIBBLE from the adminpage. ############################################################################# $query = "$ENV{'QUERY_STRING'}"; $method = "$ENV{'REQUEST_METHOD'}"; $storeip = "$ENV{'REMOTE_ADDR'}"; $query =~ tr/+/ /; $query =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; &loadsettings; &getpostcount; if ($method eq "POST"){ &postquery; } else { if ($query eq ""){ &$style_select; } else { &$query; } } ###################################################################################### # MY OWN STYLE START. ###################################################################################### # IF YOU WANT TO CREATE YOUR OWN LOOK OF THE POSTS, # DO SO HERE! IT'S EASY, IT'S FUN, IT'S GOOD FOR YOUR SITES LOOK & FEEL! # FIRST, PICK A NAME OR NUMBER OR SOMETHING FOR YOUR STYLE BELOW. # CHANGE "my_own_style" TO SOMETHING MORE APPEALING. # THIS WILL BE THE URL TO YOUR STYLE # (http://www.yourserver.com/cgi-bin/scribble/scribble.cgi?my_own_style ###################################################################################### sub my_own_style { if (open(FILE,"$datafile")) { flock(FILE,2); } print "Content-Type: text/html\n\n"; &style_head; while ($DATA = ) { if ($localcount == "$shownumb") { &style_foot; flock(FILE,8); close(FILE); exit; } else { &style_db_read; &allowcoding; &smileyconversion; print < $font1 Name: $name. From $city. Email: $email $font2$title $font3$msg $font4 $date $ipnumb $table_separator HTML $localcount++; } } &style_foot; flock(FILE,8); close(FILE); } ###################################################################################### # MY OWN STYLE END. ###################################################################################### ############################################# # NEW ENTRY. ############################################# sub postquery { &getdate; read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; # dont remove html tags at this point #$value =~ s/<([^>]|\n)*>//g; $FORM{$name} = $value; $FORM{'message'} =~ s/\cM\n/
/g; } $action = $FORM{'actioncode'}; if ($action eq "newentry") { $name = $FORM{'name'}; $city = $FORM{'city'}; $email = $FORM{'email'}; $title = $FORM{'title'}; $msg = $FORM{'message'}; #check so that stuff is posted if ($name eq "") { &diebook('Please enter your name.
Use your browsers back button to correct this.'); } if ($title eq "") { &diebook('Please enter a title for the message.
Use your browsers back button to correct this.'); } if ($msg eq "") { &diebook('This is a guestbook, not much use unless you type a message!
Use your browsers back button to correct this.'); } $name =~ s/<.*?>//g; $city =~ s/<.*?>//g; $email =~ s/<.*?>//g; $title =~ s/<.*?>//g; $msg =~ s/
/[linebreak]/g; # proceed to put info into the database if (open (FILE, "$datafile")) { flock(FILE,2); } @save = ; flock(FILE,8); close(FILE); if (open (FILE, ">$datafile")) { flock(FILE,2); } print FILE "$name``x$email``x$title``x$date``x$city``x$msg``x$storeip\n"; print FILE "@save"; flock(FILE,8); close(FILE); print "Content-Type: text/html\n\n"; print <

$font3 $pagetitle

$htmlfoot HTML } elsif ($action eq "savesettings") { $FORM{'table_separator'} =~ s/\cM\n//g; $FORM{'body_header'} =~ s/\cM\n//g; $FORM{'body_footer'} =~ s/\cM\n//g; $separator = "``x"; $guestnumber = "$FORM{'guestnumber'}"; $password = "$FORM{'password'}"; $allowcode = "$FORM{'allowcode'}"; #$convert_to_url = "$FORM{'convert_to_url'}"; $imagepath = "$FORM{'imagepath'}"; $showip = "$FORM{'showip'}"; $pagetitle = "$FORM{'pagetitle'}"; $bodycolor = "$FORM{'bodycolor'}"; $bodyimage = "$FORM{'bodyimage'}"; $link_color1 = "$FORM{'link_color1'}"; $link_state1 = "$FORM{'link_state1'}"; $link_color2 = "$FORM{'link_color2'}"; $link_state2 = "$FORM{'link_state2'}"; $tablewidth = "$FORM{'tablewidth'}"; $tdcolor1 = "$FORM{'tdcolor1'}"; $tdcolor2 = "$FORM{'tdcolor2'}"; $tdcolor3 = "$FORM{'tdcolor3'}"; $tdcolor4 = "$FORM{'tdcolor4'}"; $body_footer = "$FORM{'body_footer'}"; $font1_face = "$FORM{'font1_face'}"; $font1_size = "$FORM{'font1_size'}"; $font1_color = "$FORM{'font1_color'}"; $font1_style = "$FORM{'font1_style'}"; $font2_face = "$FORM{'font2_face'}"; $font2_size = "$FORM{'font2_size'}"; $font2_color = "$FORM{'font2_color'}"; $font2_style = "$FORM{'font2_style'}"; $font3_face = "$FORM{'font3_face'}"; $font3_size = "$FORM{'font3_size'}"; $font3_color = "$FORM{'font3_color'}"; $font3_style = "$FORM{'font3_style'}"; $font4_face = "$FORM{'font4_face'}"; $font4_size = "$FORM{'font4_size'}"; $font4_color = "$FORM{'font4_color'}"; $font4_style = "$FORM{'font4_style'}"; $shownumb = "$FORM{'shownumb'}"; $table_cellpadding = "$FORM{'table_cellpadding'}"; $table_cellspacing = "$FORM{'table_cellspacing'}"; $table_bgcolor = "$FORM{'table_bgcolor'}"; $tdalign1 = "$FORM{'tdalign1'}"; $tdalign2 = "$FORM{'tdalign2'}"; $tdalign3 = "$FORM{'tdalign3'}"; $tdalign4 = "$FORM{'tdalign4'}"; $table_separator = "$FORM{'table_separator'}"; $body_header = "$FORM{'body_header'}"; $style_select = "$FORM{'style_select'}"; $convert_to_smiley = "$FORM{'convert_to_smiley'}"; #$body_bg_img = "$FORM{'body_bg_img'}"; #$table_bg_image = "$FORM{'body_bg_img'}"; #$td1_bg_img = "$FORM{'td1_bg_img'}"; #$td2_bg_img = "$FORM{'td2_bg_img'}"; #$td3_bg_img = "$FORM{'td3_bg_img'}"; #$td4_bg_img = "$FORM{'td4_bg_img'}"; if (open (FILE, ">$cfg")) { flock(FILE,2); } print FILE "guestnumber$separator$guestnumber\n"; print FILE "pagetitle$separator$pagetitle\n"; print FILE "password$separator$password\n"; print FILE "allowcode$separator$allowcode\n"; print FILE "showip$separator$showip\n"; print FILE "imagepath$separator$imagepath\n"; print FILE "bodycolor$separator$bodycolor\n"; print FILE "bodyimage$separator$bodyimage\n"; print FILE "link_color1$separator$link_color1\n"; print FILE "link_state1$separator$link_state1\n"; print FILE "link_color2$separator$link_color2\n"; print FILE "link_state2$separator$link_state2\n"; print FILE "tablewidth$separator$tablewidth\n"; print FILE "tdcolor1$separator$tdcolor1\n"; print FILE "tdcolor2$separator$tdcolor2\n"; print FILE "tdcolor3$separator$tdcolor3\n"; print FILE "tdcolor4$separator$tdcolor4\n"; print FILE "font1_face$separator$font1_face\n"; print FILE "font1_size$separator$font1_size\n"; print FILE "font1_color$separator$font1_color\n"; print FILE "font1_style$separator$font1_style\n"; print FILE "font2_face$separator$font2_face\n"; print FILE "font2_size$separator$font2_size\n"; print FILE "font2_color$separator$font2_color\n"; print FILE "font2_style$separator$font2_style\n"; print FILE "font3_face$separator$font3_face\n"; print FILE "font3_size$separator$font3_size\n"; print FILE "font3_color$separator$font3_color\n"; print FILE "font3_style$separator$font3_style\n"; print FILE "font4_face$separator$font4_face\n"; print FILE "font4_size$separator$font4_size\n"; print FILE "font4_color$separator$font4_color\n"; print FILE "font4_style$separator$font4_style\n"; print FILE "body_footer$separator$body_footer\n"; print FILE "shownumb$separator$shownumb\n"; print FILE "body_header$separator$body_header\n"; print FILE "table_cellpadding$separator$table_cellpadding\n"; print FILE "table_cellspacing$separator$table_cellspacing\n"; print FILE "table_bgcolor$separator$table_bgcolor\n"; print FILE "tdalign1$separator$tdalign1\n"; print FILE "tdalign2$separator$tdalign2\n"; print FILE "tdalign3$separator$tdalign3\n"; print FILE "tdalign4$separator$tdalign4\n"; print FILE "table_separator$separator$table_separator\n"; print FILE "style_select$separator$style_select\n"; #print FILE "convert_to_url$separator$convert_to_url\n"; print FILE "convert_to_smiley$separator$convert_to_smiley\n"; #print FILE "body_bg_img$separator$body_bg_img\n"; flock(FILE,8); close(FILE); print "Content-Type: text/html\n\n"; print <SAVE!

$font3 Your settings should now have been saved.
(btw, if it's not saved it's likely you have wrong rights on the config file)

Check it out.

$htmlfoot HTML } elsif ($action eq "loginadmin") { &loginadmin; } else { &diebook; } } ############################################# # COOKIES. ############################################# sub loginpage { print "Content-Type: text/html\n\n"; print <Login $font3 PLEASE LOGIN TO ACCESS SCRIBBLE ADMINISTRATION

I take it you have the admin password up your sleeve somewhere.
Give it to me! :)

HTML } sub loginadmin { if ($FORM{'adminpassword'} eq "$password") { &setcookie; } else { &diebook('Wrong password.'); } } sub setcookie { $diecookiedate = cookieexpire($cookiedays); print "Set-Cookie: scribbleadmin=$password; path=/; $diecookiedate;"; print "Content-Type: text/html\n\n"; print <SCRIBBLE $font3 EVERYTHING SEEMS TO BE IN ORDER

Move on HTML } sub adminlogout { print "Set-Cookie: scribbleadmin=x; expires=Thu, 03-Feb-2000 00:00:00 GMT"; &$style_select; } ############################################# # DIEBOOK. ############################################# sub diebook { print "Content-Type: text/html\n\n"; print < $font3 Ooops, something did not go as you wanted.
Description: @_

$pagetitle $htmlfoot HTML exit; } ############################################# # GET DATE. ############################################# sub getdate { @days = ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'); @months = ('January','February','Mars','April','May','June','July','August','September','October','November','December'); ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time); $wday = $days[$wday]; $mon = $months[$mon]; $hour = sprintf("%2.2d",$hour); $min = sprintf("%2.2d",$min); $year = $year + 1900; $date = "$wday, $mday $mon $year \@ $hour:$min"; } ############################################# # CODING OF POSTS, WHAT TO ALLOW AND NOT. ############################################# sub allowcoding { if ($allowcode eq "none") { $msg =~ s/<.*?>//g; $msg =~ s/\[linebreak\]/
/g; #clean up display from scribblecode $msg =~ s/\[(.){3,9}?\]//g; } if ($allowcode eq "scribblecode") { #clean up display from htmlcode $msg =~ s/<.*?>//g; #safe to convert our linebreaks back to html $msg =~ s/\[linebreak\]/
/g; #scribblecode conversion $msg =~ s/\[bold\]//ig; $msg =~ s/\[\/bold\]/<\/b>/ig; $msg =~ s/\[italic\]//ig; $msg =~ s/\[\/italic\]/<\/i>/ig; $msg =~ s/\[underline\]//ig; $msg =~ s/\[\/underline\]/<\/u>/ig; $msg =~ s/\[red\]//ig; $msg =~ s/\[\/red\]/$font3/ig; $msg =~ s/\[blue\]//ig; $msg =~ s/\[\/blue\]/$font3/ig; $msg =~ s/\[orange\]//ig; $msg =~ s/\[\/orange\]/$font3/ig; $msg =~ s/\[green\]//ig; $msg =~ s/\[\/green\]/$font3/ig; } if ($allowcode eq "htmlcode") { $msg =~ s/\[linebreak\]/
/g; #clean up display from scribblecode $msg =~ s/\[(.){3,9}?\]//g; } } sub smileyconversion { if ($convert_to_smiley eq "yes") { $msg =~ s/(:\))//g; $msg =~ s/(:\()//g; $msg =~ s/(;\))//g; $msg =~ s/(:D)//ig; } } ############################################# # POSTCOUNT. ############################################# sub getpostcount { $postcount = "0"; if (open(FILE,"$datafile")) { flock(FILE,2); } while ($DATA = ) { $postcount++; } flock(FILE,8); close(FILE); } ############################################# # READ/SHOW. ############################################# sub style01 { if (open(FILE,"$datafile")) { flock(FILE,2); } print "Content-Type: text/html\n\n"; &style_head; while ($DATA = ) { if ($localcount == "$shownumb") { &style_foot; flock(FILE,8); close(FILE); exit; } else { &style_db_read; &allowcoding; &smileyconversion; print < $font1 Name: $name. From $city. Email: $email
$font2$title
$font3$msg
$font4 $date $ipnumb
$table_separator HTML $localcount++; } } &style_foot; flock(FILE,8); close(FILE); } sub style02 { if (open(FILE,"$datafile")) { flock(FILE,2); } print "Content-Type: text/html\n\n"; &style_head; while ($DATA = ) { if ($localcount == "$shownumb") { &style_foot; flock(FILE,8); close(FILE); exit; } else { &style_db_read; &allowcoding; &smileyconversion; print < $font1 Name:
$name.

From:
$city.

(send email) $font2 $title $font3$msg $font4$date $ipnumb $table_separator HTML $localcount++; } } &style_foot; flock(FILE,8); close(FILE); } sub style03 { if (open(FILE,"$datafile")) { flock(FILE,2); } print "Content-Type: text/html\n\n"; &style_head; while ($DATA = ) { if ($localcount == "$shownumb") { &style_foot; flock(FILE,8); close(FILE); exit; } else { &style_db_read; &allowcoding; &smileyconversion; print < $font3 "$msg" $font1
/ $name \@ $date $table_separator HTML $localcount++; } } &style_foot; flock(FILE,8); close(FILE); } sub style04 { if (open(FILE,"$datafile")) { flock(FILE,2); } print "Content-Type: text/html\n\n"; &style_head; while ($DATA = ) { if ($localcount == "$shownumb") { &style_foot; flock(FILE,8); close(FILE); exit; } else { &style_db_read; &allowcoding; &smileyconversion; print < $font1 Name: $name
Hometown: $city
Email: $email
Sent: $date
$title
$msg $font4 $ipnumb $table_separator HTML $localcount++; } } &style_foot; flock(FILE,8); close(FILE); } sub style05 { if (open(FILE,"$datafile")) { flock(FILE,2); } print "Content-Type: text/html\n\n"; &style_head; while ($DATA = ) { if ($localcount == "$shownumb") { &style_foot; flock(FILE,8); close(FILE); exit; } else { &style_db_read; &allowcoding; &smileyconversion; print < $font2 $title $font3 $msg $font1 $name, <$email>
$city, $date. $ipnumb $table_separator HTML $localcount++; } } &style_foot; flock(FILE,8); close(FILE); } ################################################################################# ################################################################################# # DEALING OUT DIFF STYLES. THESE SUBS ARE SHARED. ################################################################################# sub style_head { print "$htmlhead\n"; print "$bodytag\n"; print "$body_header\n"; print "$font1 Total number of guestbook posts: $postcount

\n"; } sub style_db_read { chop $DATA; ($name, $email, $title, $date, $city, $msg, $ip) = split "``x", $DATA; if ($showip eq "yes") { $ipnumb = "IP: $ip"; } else { $ipnumb = ""; } } sub style_foot { print "$body_footer "; print ""; print "Displaying the $localcount latest post out of $postcount total.

"; print "Powered by: The New Mitch Ryder On-Line"; print "$htmlfoot\n"; } ############################################# # LOADSETTINGS ############################################# sub loadsettings { open(FILE,$cfg); my @SETTINGS = ; close(FILE); foreach $i (@SETTINGS) { ($name, $value) = split(/``x/, $i); $value =~ s/\n//g; $Config{$name} = $value; } $guestnumber = "$Config{'guestnumber'}"; $password = "$Config{'password'}"; $allowcode = "$Config{'allowcode'}"; $imagepath = "$Config{'imagepath'}"; $showip = "$Config{'showip'}"; $pagetitle = "$Config{'pagetitle'}"; $bodycolor = "$Config{'bodycolor'}"; $bodyimage = "$Config{'bodyimage'}"; $shownumb = "$Config{'shownumb'}"; $link_color1 = "$Config{'link_color1'}"; $stylestatic = "$Config{'stylestatic'}"; $link_state1 = "$Config{'link_state1'}"; $stylehover = "$Config{'stylehover'}"; $link_color2 = "$Config{'link_color2'}"; $stylehover2 = "$Config{'stylehover2'}"; $link_state2 = "$Config{'link_state2'}"; $tablewidth = "$Config{'tablewidth'}"; $tdcolor1 = "$Config{'tdcolor1'}"; $tdcolor2 = "$Config{'tdcolor2'}"; $tdcolor3 = "$Config{'tdcolor3'}"; $tdcolor4 = "$Config{'tdcolor4'}"; $body_footer = "$Config{'body_footer'}"; $table_cellpadding = "$Config{'table_cellpadding'}"; $table_cellspacing = "$Config{'table_cellspacing'}"; $tdalign1 = "$Config{'tdalign1'}"; $tdalign2 = "$Config{'tdalign2'}"; $tdalign3 = "$Config{'tdalign3'}"; $tdalign4 = "$Config{'tdalign4'}"; $table_bgcolor = "$Config{'table_bgcolor'}"; $table_separator = "$Config{'table_separator'}"; $style_select = "$Config{'style_select'}"; #$convert_to_url = "$Config{'convert_to_url'}"; $convert_to_smiley = "$Config{'convert_to_smiley'}"; #create the 4 different fonttags $font1 = "<$Config{'font1_style'}>"; $font2 = "<$Config{'font2_style'}>"; $font3 = "<$Config{'font3_style'}>"; $font4 = "<$Config{'font4_style'}>"; #create the style type/css, html header, bodytag and htmlfoot $linkstyle = "\