#!/usr/bin/perl use strict; use Fcntl ':flock'; # # 4est web designs # # 4est Logging, version 2.50 # # Last Modified: 23:26 5/3/2005 # Web Site: http://www.semithere.net # This script is Copyright © 2005 Forrest Jones ####################### ## START USER CONFIG ## ####################### ########## Administrator Settings ########## my $adminName = "ben_admin"; # Name my $adminEmail = 'benjami1@comcast.net'; # Email address my $adminPass = "adminpass"; # Password ################## Layout ################## my $align = "center"; # Table alignment my $width = "95%"; # Table width my $fontB = 'STYLE="font-size: 11px;'; # Big font my $fontS = 'STYLE="font-size: 11px;"'; # Small font my $hrDiv = '
'; # Entry divider code, e.g.
############# Feature Settings ############# my $cookieExpiration = 7; # Number of days for a cookie to stay active my $postPass = "admin"; # Post password -- Leave blank to disable or enter admin to use the Administrator password my $sendAdminEmail = "no"; # Send email to Administrator when someone posts (yes/no) my $htmlEmail = "yes"; # When emailing the Administrator encode email as HTML (yes/no) my $multiUsers = "no"; # Multiple users (yes/no) my $enableComment = "yes"; # Enable commenting (yes/no) my $enablePseudo = "yes"; # Enable pseudo code (yes/no) my $enableAttachments = "no"; # Enable admin attachments (yes/no) my $autoLinkUrls = "yes"; # Automatically link urls (yes/no) my $maxEntries = 4; # Number of entries to display on the main page my $timeZone = "EST"; # Time zone my $hourAdjust = -5; # GMT offset in hours my $timeFormat = 12; # Time format, 12 or 24 hour (12/24) my $dateFormat = 1; # Date format, 1. (Sunday, July 20, 2003) 2. (Sunday, 20 July 2003) (1/2) my $titleFormat = 1; # Title format, 1. (Date / Title @ Time) 2. (Title / Date @ Time) (1/2) my $maxUploadFiles = 5; # Number of file fields on the upload page my $imgFormat = "gif"; # Emoticon and Pseudo Code image format (gif/jpg/png/etc.) ################## Paths ################### my $articlesPath = "articles"; # Path to the articles dir my $imagesPath = "images"; # Path to the pseudo images dir my $uploadsPath = "uploads"; # Path to the uploads dir my $workingPath = "working"; # Path to the working dir my $templatePath = "template.html"; # Path to template file my $sendmailPath = "/usr/sbin/sendmail"; # Path to your unix sendmail program ################## Other ################### # Use 4est Management cookie my $mCookie = ""; # 4est Management cookie unique bit e.g. root my $mCookiePath = ""; # Path to 4est Management script e.g. ../ # For language reasons my @wdays = qw!Monday Tuesday Wednesday Thursday Friday Saturday Sunday!; my @months = qw!January February March April May June July August September October November December!; # Pseudo code and Smiley lists my @smiley = qw!smiley|":)" wink|";)" cheesy|":D" grin|";D" angry|">:(" sad|":(" shocked|":o" cool|"8-)" huh|":?(" rolleyes|"8)" tongue|":P" embarassed|";(" lipsrsealed|":-X" undecided|":-/" kiss|":-*" cry|":'(" laugh|":-D" thumbup|"^=" thumbdown|"v=" exclamation|"\!\!\!" question|"???" star|"***" idea|":\!)"!; my @pseudo = qw!url|"[url=]","[/url]" img|"[img=]","[/img]" email|"[email=]","[/email]" bold|"[b]","[/b]" italicize|"[i]","[/i]" underline|"[u]","[/u]" strike|"[s]","[/s]" left|"[left]","[/left]" center|"[center]","[/center]" right|"[right]","[/right]" size|"[size=2]","[/size]" font|"[font=Verdana]","[/font]" list|"[list]\n[*]\n[/list]" hr|"[hr]" table|"[table][row][column][/column][column][/column][/row][/table]" column|"[column]","[/column]" row|"[row]","[/row]"!; ##################### ## END USER CONFIG ## ##################### # In script error checking #BEGIN { $| = 1; open (STDERR, ">&STDOUT"); print qq~Content-type: text/html\n\n~; } # Get form data my (%FORM, %COOKIE); &getData; my $ran = ""; my $expdate = cookieTime(); # Global SSI override (on/off) if (!$FORM{'ssi'}) { $FORM{'ssi'} = "off"; } # Set script name and url my $indexUrl = "http://"; (my $path = $ENV{'SCRIPT_NAME'}) =~ s/^(.+?)[0-9a-z_-]*\.[a-z]{2,3}$/$1/g; (my $uniqueBit = $path) =~ s!^/(.+?)/$!$1!g; (my $indexCgi = $ENV{'SCRIPT_NAME'}) =~ s/^.+?([0-9a-z_-]*\.[a-z]{2,3})$/$1/g; ($indexUrl .= $ENV{'HTTP_HOST'}) =~ s/^(.+?)\/$/$1/g; ($indexUrl .= $path) =~ s!^(.+?)/$!$1!g; my $imagesDir = "$indexUrl/$imagesPath"; my $formUrl = "$indexUrl/$indexCgi"; $uniqueBit =~ s!/!!g; my $uniqueBitX = $uniqueBit; if (!$uniqueBit) { $uniqueBit = "root"; } if ($mCookie && $COOKIE{"$mCookie-pass"}) { $uniqueBit = "$mCookie"; } # Encrypt password my $adminPassCrypt; if ($mCookie && $COOKIE{"$mCookie-pass"}) { $adminPassCrypt = crypt($adminPass, "iN"); } else { $adminPassCrypt = crypt($adminPass, "wL"); } # Init Check if (!-e $workingPath && !$COOKIE{"$uniqueBit-error"}) { print qq|Set-Cookie: $uniqueBit-error=no; path=$path; expires=$expdate\n|; print "Location:$formUrl?action=admin\n\n"; exit; } if (!$COOKIE{"$uniqueBit-error"}) { &fileCheck; } my $first = &counter("first", "0", "yes"); # Set alternate theme my $templateFile; if ($mCookie && $COOKIE{"$mCookie-pass"} && $COOKIE{"$mCookie-theme"} && !$COOKIE{"$uniqueBitX-theme"}) { $COOKIE{"$uniqueBitX-theme"} = $mCookiePath . $COOKIE{"$uniqueBit-theme"}; } if ($FORM{'theme'}) { print qq|Set-Cookie: $uniqueBitX-theme=$FORM{'theme'}; path=$path; expires=$expdate\n|; $templateFile = "$FORM{'theme'}.html"; } elsif ($COOKIE{"$uniqueBitX-theme"}) { $templateFile = qq|$COOKIE{"$uniqueBitX-theme"}.html|; } else { $templateFile = $templatePath; } # Get template my $topPage = template($templateFile,"top"); my $bottomPage = template($templateFile,"bottom"); # Redirect to the admin / post page if ($ENV{'QUERY_STRING'} =~ /^admin/) { $FORM{'action'} = "admin"; } if ($ENV{'QUERY_STRING'} =~ /^post/) { $FORM{'action'} = "post"; } ####################################################### ## No Action if (!$FORM{'action'}) { my $month = &getMonth(1); my $year = &getYear(1); my $count = &counter("counter", "0", "yes"); open(IN, "$articlesPath/articles.db"); flock(IN, LOCK_SH); my @data = ; close(IN); my $lastNum = scalar(@data); my $num; if ($maxEntries > $lastNum) { $maxEntries = $lastNum; } $topPage =~ s//Weblog/g; print "Content-type: text/html\n\n"; if ($FORM{'ssi'} ne "on") {print $topPage;} for ($num = 1; $num <= $maxEntries; $num++) { chomp($data[$lastNum - $num]); my @field = split(/\|/, $data[$lastNum - $num]); open(COM, "$workingPath/$month\_$year\_$field[4].db"); flock(COM, LOCK_SH); my $comNum = ; close(COM); if (!$comNum) { $comNum = "0"; } print qq| \n|; print qq| \n|; print qq| \n|; if ($enableComment eq "yes" or $multiUsers eq "yes" or $COOKIE{"$uniqueBit-pass"}) { print qq| \n|; print qq| \n|; if ($enableComment eq "yes" or $multiUsers eq "yes") { print qq| \n|; } if ($enableComment eq "yes") { print qq| \n|; } elsif ($multiUsers eq "yes") { print qq| \n|; } if ($multiUsers eq "yes") { print qq| \n|; } else { print qq| \n|; } if ($enableComment eq "yes" or $multiUsers eq "yes") { print qq| \n|; } if ($field[9] && $enableComment eq "no" && $multiUsers eq "no" && $enableAttachments eq "yes") { print qq| \n|; print qq| \n|; print qq| \n|; } if ($COOKIE{"$uniqueBit-pass"} && ($enableComment eq "yes" or $multiUsers eq "yes")) { print qq| \n|; print qq| \n|; print qq| \n|; } if ($COOKIE{"$uniqueBit-pass"}) { print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; } print qq| \n|; if ($enableComment eq "yes" or $multiUsers eq "yes" or $COOKIE{"$uniqueBit-pass"}) { print qq| \n|; print qq| \n|; print qq|
\n|; } else { print qq| \n|; } if ($titleFormat eq 1) { print qq| $field[0]
\n|; print qq| $field[1] @ $field[2] $timeZone
\n|; } elsif ($titleFormat eq 2) { print qq| $field[1]
\n|; print qq| $field[0] @ $field[2] $timeZone
\n|; } print qq| $field[3]\n|; if ($enableComment eq "yes" or $multiUsers eq "yes" or $COOKIE{"$uniqueBit-pass"}) { print qq|

\n|; } print qq|
read comments ($comNum) / write comment |; print qq|$field[5] (|; if ($field[6]) { print qq|www|; } else { print qq|www|; } print qq| / |; if ($field[7]) { print qq|@|; } else { print qq|@|; } print qq|)|; if ($field[9] && $enableAttachments eq "yes") { print qq|   File(s) Attached|; } print qq||; if ($field[9] && $enableAttachments eq "yes") { print qq|File(s) Attached|; } else { print qq| |; } print qq|
File(s) Attached
 
|; if ($first <= 0) { print qq|Edit -- Delete|; } print qq|IP: $field[8]
|; } else { print qq| |; } print qq|
$hrDiv
\n|; } print qq|
|; if (($multiUsers eq "yes" && -e "$articlesPath/articles.db") or $COOKIE{"$uniqueBit-pass"}) { print qq|Post -- |; } if (-e "$articlesPath/articles.db") { print qq|Archive|; } if ($COOKIE{"$uniqueBit-pass"} && -e "$articlesPath/articles.db") { print qq| -- Admin Menu|; } print qq|
\n|; if ($FORM{'ssi'} ne "on") {print $bottomPage;} } ####################################################### ## View Entry if ($FORM{'action'} eq "viewEntry") { $ran++; my $month = &getMonth(1); my $year = &getYear(1); my $whereTo; my $check = &checkForm(); if ($check == 2) { if ($FORM{'month'} eq $month && $FORM{'year'} eq $year) { $whereTo = "articles"; } else { $whereTo = "$FORM{'month'}_$FORM{'year'}"; } } open(IN, "$articlesPath/$whereTo.db") or dienice("Can't read $whereTo.db code 1 : $! \n"); flock(IN, LOCK_SH); my @data = ; close(IN); chomp($data[$FORM{'id'} - 1]); my @field = split(/\|/, $data[$FORM{'id'} - 1]); open(COM, "$workingPath/$FORM{'month'}_$FORM{'year'}_$field[4].db"); flock(COM, LOCK_SH); my $comNum = ; close(COM); if (!$comNum) { $comNum = "0"; } $topPage =~ s//Entry Viewer/g; print "Content-type: text/html\n\n"; if ($FORM{'ssi'} ne "on") {print $topPage;} print qq| \n|; print qq| \n|; if ($enableComment eq "yes" or $multiUsers eq "yes" or $COOKIE{"$uniqueBit-pass"}) { print qq| \n|; print qq| \n|; if ($enableComment eq "yes" or $multiUsers eq "yes") { print qq| \n|; } if ($enableComment eq "yes") { print qq| \n|; } elsif ($multiUsers eq "yes") { print qq| \n|; } if ($multiUsers eq "yes") { print qq| \n|; } elsif ($enableComment eq "yes") { print qq| \n|; } if ($enableComment eq "yes" or $multiUsers eq "yes") { print qq| \n|; } if (($COOKIE{"$uniqueBit-pass"} && $whereTo eq "articles") && ($enableComment eq "yes" or $multiUsers eq "yes")) { print qq| \n|; print qq| \n|; print qq| \n|; } if ($COOKIE{"$uniqueBit-pass"} && $whereTo eq "articles") { print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; } if ($field[9] && $enableAttachments eq "yes") { print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; } print qq| \n|; if ($enableComment eq "yes" or $multiUsers eq "yes" or $COOKIE{"$uniqueBit-pass"}) { print qq| \n|; print qq| \n|; print qq|
\n|; } else { print qq| \n|; } if ($titleFormat eq 2) { print qq| $field[0]
\n|; print qq| $field[1] @ $field[2] $timeZone
\n|; } elsif ($titleFormat eq 1) { print qq| $field[1]
\n|; print qq| $field[0] @ $field[2] $timeZone
\n|; } print qq| $field[3]\n|; if ($enableComment eq "yes" or $multiUsers eq "yes" or $COOKIE{"$uniqueBit-pass"}) { print qq|

\n|; } print qq|
read comments ($comNum) / write comment |; print qq|$field[5] (|; if ($field[6]) { print qq|www|; } else { print qq|www|; } print qq| / |; if ($field[7]) { print qq|@|; } else { print qq|@|; } print qq|) 
 
|; if ($first <= 0) { print qq|Edit -- Delete|; } print qq|IP: $field[8]
 
Attached files:

\n|; my @files = split(/\*/, $field[9]); foreach my $file (@files) { print qq| Attached File $file
\n|; } print qq|
 
|; } else { print qq| |; } print qq|
$hrDiv
\n|; print qq|
|; if ($multiUsers eq "yes" && -e "$articlesPath/articles.db") { print qq|Post -- |; } print qq|Main Page -- Archive|; if ($COOKIE{"$uniqueBit-pass"}) { print qq| -- Admin Menu|; } print qq|
\n|; if ($FORM{'ssi'} ne "on") {print $bottomPage;} } ####################################################### ## View Archive if ($FORM{'action'} eq "viewArchive") { $ran++; my $year = &getYear(1); if (!$FORM{'year'}) { $FORM{'year'} = $year; } open(IN, "$workingPath/prior_months.db") or dienice("Can't read prior_months.db code 2 : $! \n"); flock(IN, LOCK_SH); my @data = ; close(IN); my $lastNum = scalar(@data); my $num; $topPage =~ s//Archive/g; print "Content-type: text/html\n\n"; if ($FORM{'ssi'} ne "on") {print $topPage;} print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq|
\n|; print qq| \n|; for ($num = 1; $num <= $lastNum; $num++) { my $num2 = $num - 1; chomp($data[$lastNum - $num]); chomp($data[$lastNum - $num2]); my @field = split(/\|/, $data[$lastNum - $num]); my @field2 = split(/\|/, $data[$lastNum - $num2]); if ($field[1] ne $field2[1]) { if ($FORM{'year'} eq $field2[1] or $FORM{'year'} eq $field[1] && $year ne $field[1]) { print qq| \n|; print qq| \n|; print qq| \n|; } print qq| \n|; if ($FORM{'year'} ne $field[1]) { print qq| \n|; } elsif ($FORM{'year'} eq $field[1]) { print qq| \n|; } print qq| \n|; print qq| \n|; } if ($FORM{'year'} eq $field[1]) { print qq| \n|; print qq| \n|; print qq| \n|; } } print qq|
 
  |; if ($FORM{'year'} eq $field[1]) { print qq|$field[1]|; } else { print qq|$field[1]|; } print qq|
$field[0]
\n|; print qq|

$hrDiv
\n|; print qq|
|; if ($multiUsers eq "yes" && -e "$articlesPath/articles.db") { print qq|Post -- |; } print qq|Main Page|; if ($COOKIE{"$uniqueBit-pass"}) { print qq| -- Admin Menu|; } print qq|
\n|; if ($FORM{'ssi'} ne "on") {print $bottomPage;} } ####################################################### ## Display Archive if ($FORM{'action'} eq "displayArchive") { $ran++; my $month = &getMonth(1); my $year = &getYear(1); my $whereTo; my $check = &checkForm(); if ($check == 2) { if ($FORM{'month'} eq $month && $FORM{'year'} eq $year) { $whereTo = "articles"; } else { $whereTo = "$FORM{'month'}_$FORM{'year'}"; } } $topPage =~ s//Archive/g; print "Content-type: text/html\n\n"; if ($FORM{'ssi'} ne "on") {print $topPage;} open(IN, "$articlesPath/$whereTo.db") or dienice("Can't read $whereTo.db code 3 : $! \n"); flock(IN, LOCK_SH); while() { chomp; my @file = split(/\n/); foreach my $line (@file) { my @field = split(/\|/, $line); open(COM, "$workingPath/$FORM{'month'}_$FORM{'year'}_$field[4].db"); flock(COM, LOCK_SH); my $comNum = ; close(COM); if (!$comNum) { $comNum = "0"; } print qq| \n|; print qq| \n|; print qq| \n|; if ($enableComment eq "yes" or $multiUsers eq "yes" or $COOKIE{"$uniqueBit-pass"}) { print qq| \n|; print qq| \n|; if ($enableComment eq "yes" or $multiUsers eq "yes") { print qq| \n|; } if ($enableComment eq "yes") { print qq| \n|; } elsif ($multiUsers eq "yes") { print qq| \n|; } if ($multiUsers eq "yes") { print qq| \n|; } else { print qq| \n|; } if ($enableComment eq "yes" or $multiUsers eq "yes") { print qq| \n|; } if ($field[9] && $enableComment eq "no" && $multiUsers eq "no" && $enableAttachments eq "yes") { print qq| \n|; print qq| \n|; print qq| \n|; } if (($COOKIE{"$uniqueBit-pass"} && $whereTo eq "articles") && ($enableComment eq "yes" or $multiUsers eq "yes")) { print qq| \n|; print qq| \n|; print qq| \n|; } if ($COOKIE{"$uniqueBit-pass"} && $whereTo eq "articles") { print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; } print qq| \n|; if ($enableComment eq "yes" or $multiUsers eq "yes" or $COOKIE{"$uniqueBit-pass"}) { print qq| \n|; print qq| \n|; print qq|
\n|; } else { print qq| \n|; } if ($titleFormat eq 1) { print qq| $field[0]
\n|; print qq| $field[1] @ $field[2] $timeZone
\n|; } elsif ($titleFormat eq 2) { print qq| $field[1]
\n|; print qq| $field[0] @ $field[2] $timeZone
\n|; } print qq| $field[3]\n|; if ($enableComment eq "yes" or $multiUsers eq "yes" or $COOKIE{"$uniqueBit-pass"}) { print qq|

\n|; } print qq|
read comments ($comNum) / write comment |; print qq|$field[5] (|; if ($field[6]) { print qq|www|; } else { print qq|www|; } print qq| / |; if ($field[7]) { print qq|@|; } else { print qq|@|; } print qq|)|; if ($field[9] && $enableAttachments eq "yes") { print qq|   File(s) Attached|; } print qq||; if ($field[9] && $enableAttachments eq "yes") { print qq|File(s) Attached|; } else { print qq| |; } print qq|
File(s) Attached
 
|; if ($first <= 0) { print qq|Edit -- Delete|; } print qq|IP: $field[8]
|; } else { print qq| |; } print qq|
$hrDiv
\n|; } } close(IN); print qq|
|; if ($multiUsers eq "yes" && -e "$articlesPath/articles.db") { print qq|Post -- |; } print qq|Main Page -- Archive|; if ($COOKIE{"$uniqueBit-pass"}) { print qq| -- Admin Menu|; } print qq|
\n|; if ($FORM{'ssi'} ne "on") {print $bottomPage;} } ####################################################### ## Read Comment if ($FORM{'action'} eq "readComment") { $ran++; my $month = &getMonth(1); my $year = &getYear(1); my $whereTo; my $check = &checkForm(); if ($check == 2) { if ($FORM{'month'} eq $month && $FORM{'year'} eq $year) { $whereTo = "articles"; } else { $whereTo = "$FORM{'month'}_$FORM{'year'}"; } } open(IN, "$articlesPath/$whereTo.db") or dienice("Can't read $whereTo.db code 4 : $! \n"); flock(IN, LOCK_SH); my @data = ; close(IN); chomp($data[$FORM{'id'} - 1]); my @field = split(/\|/, $data[$FORM{'id'} - 1]); $topPage =~ s//Comments/g; print "Content-type: text/html\n\n"; if ($FORM{'ssi'} ne "on") {print $topPage;} print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; if ($multiUsers eq "yes") { print qq| \n|; } else { print qq| \n|; } print qq| \n|; if ($field[9] && $enableComment eq "no" && $multiUsers eq "no" && $enableAttachments eq "yes") { print qq| \n|; print qq| \n|; print qq| \n|; } if ($COOKIE{"$uniqueBit-pass"} && $whereTo eq "articles") { print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; } print qq| \n|; print qq| \n|; print qq| \n|; print qq|
\n|; if ($titleFormat eq 1) { print qq| $field[0]
\n|; print qq| $field[1] @ $field[2] $timeZone
\n|; } elsif ($titleFormat eq 2) { print qq| $field[1]
\n|; print qq| $field[0] @ $field[2] $timeZone
\n|; } print qq| $field[3]\n|; print qq|

\n|; print qq|
write comment|; print qq|$field[5] (|; if ($field[6]) { print qq|www|; } else { print qq|www|; } print qq| / |; if ($field[7]) { print qq|@|; } else { print qq|@|; } print qq|)|; if ($field[9] && $enableAttachments eq "yes") { print qq|   File(s) Attached|; } print qq||; if ($field[9] && $enableAttachments eq "yes") { print qq|File(s) Attached|; } else { print qq| |; } print qq|
File(s) Attached
 
|; if ($first <= 0) { print qq|Edit -- Delete|; } print qq|IP: $field[8]

$hrDiv
\n|; open(IN, "$articlesPath/$FORM{'month'}_$FORM{'year'}_$FORM{'id'}.db"); flock(IN, LOCK_SH); while() { chomp; my @file = split(/\n/); foreach my $line (@file) { my ($name, $email, $subject, $message, $date, $time, $www, $counter, $ip) = split(/\|/, $line); print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; if ($COOKIE{"$uniqueBit-pass"}) { print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; } print qq| \n|; print qq| \n|; print qq| \n|; print qq|
\n|; if ($titleFormat eq 1) { print qq| $subject
\n|; print qq| $date @ $time $timeZone
\n|; } elsif ($titleFormat eq 2) { print qq| $date
\n|; print qq| $subject @ $time $timeZone
\n|; } print qq| $message\n|; print qq|

\n|; print qq|
$name (|; if ($www) { print qq|www|; } else { print qq|www|; } print qq| / |; if ($email) { print qq|@|; } else { print qq|@|; } print qq|) 
 
Edit -- DeleteIP: $ip

$hrDiv
\n|; } } close(IN); print qq|
|; if ($multiUsers eq "yes" && -e "$articlesPath/articles.db") { print qq|Post -- |; } print qq|Main Page -- Archive|; if ($COOKIE{"$uniqueBit-pass"}) { print qq| -- Admin Menu|; } print qq|
\n|; if ($FORM{'ssi'} ne "on") {print $bottomPage;} } ####################################################### ## Write Comment if ($FORM{'action'} eq "writeComment") { $ran++; my $month = &getMonth(1); my $year = &getYear(1); my $whereTo; my $check = &checkForm(); if ($check == 2) { if ($FORM{'month'} eq $month && $FORM{'year'} eq $year) { $whereTo = "articles"; } else { $whereTo = "$FORM{'month'}_$FORM{'year'}"; } } open(IN, "$articlesPath/$whereTo.db") or dienice("Can't read $whereTo.db code 5 : $! \n"); flock(IN, LOCK_SH); my @data = ; close(IN); chomp($data[$FORM{'id'} - 1]); my @field = split(/\|/, $data[$FORM{'id'} - 1]); $FORM{'text'} =~ s!//n!\n!g; $topPage =~ s//Comments/g; print "Content-type: text/html\n\n"; if ($FORM{'ssi'} ne "on") {print $topPage;} print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; if ($multiUsers eq "yes") { print qq| \n|; } else { print qq| \n|; } print qq| \n|; if ($field[9] && $enableComment eq "no" && $multiUsers eq "no" && $enableAttachments eq "yes") { print qq| \n|; print qq| \n|; print qq| \n|; } if ($COOKIE{"$uniqueBit-pass"} && $whereTo eq "articles") { print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; } print qq| \n|; print qq| \n|; print qq| \n|; print qq|
\n|; if ($titleFormat eq 1) { print qq| $field[0]
\n|; print qq| $field[1] @ $field[2] $timeZone
\n|; } elsif ($titleFormat eq 2) { print qq| $field[1]
\n|; print qq| $field[0] @ $field[2] $timeZone
\n|; } print qq| $field[3]\n|; print qq|

\n|; print qq|
read comments|; print qq|$field[5] (|; if ($field[6]) { print qq|www|; } else { print qq|www|; } print qq| / |; if ($field[7]) { print qq|@|; } else { print qq|@|; } print qq|)|; if ($field[9] && $enableAttachments eq "yes") { print qq|   File(s) Attached|; } print qq||; if ($field[9] && $enableAttachments eq "yes") { print qq|File(s) Attached|; } else { print qq| |; } print qq|
File(s) Attached
 
|; if ($first <= 0) { print qq|Edit -- Delete|; } print qq|IP: $field[8]

$hrDiv
\n|; if ($FORM{'msg'}) { print qq|
$FORM{'msg'}
\n|; } print qq|
\n|; if (!$FORM{'cid'}) { print qq| \n|; } else { print qq| \n|; print qq| \n|; print qq| \n|; } print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq|
\n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq|
Name:
Subject:
Email Address:
Web Site:
\n|; print qq|
\n|; print qq| \n|; if ($enablePseudo eq "yes") { print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; } print qq| \n|; print qq| \n|; print qq| \n|; print qq|
\n|; foreach my $smiley (@smiley) { my ($name, $value) = split(/\|/, $smiley); my $alt = ucfirst($name); print qq| $alt\n|; } print qq|
\n|; foreach my $pseudo (@pseudo) { my ($name, $value) = split(/\|/, $pseudo); print qq| $name\n|; } print qq|
\n|; print qq|
\n|; print qq|
\n|; print qq|
$hrDiv
\n|; print qq|
|; if ($multiUsers eq "yes" && -e "$articlesPath/articles.db") { print qq|Post -- |; } print qq|Main Page -- Archive|; if ($COOKIE{"$uniqueBit-pass"}) { print qq| -- Admin Menu|; } print qq|
\n|; if ($FORM{'ssi'} ne "on") {print $bottomPage;} } ####################################################### ## Write Comment X if ($FORM{'action'} eq "writeCommentX") { my ($err, $msg); if (!$FORM{'name'}) { $msg .= "Please fill in the Name field
"; $err++; } if (!$FORM{'subject'}) { $msg .= "Please fill in the Subject field
"; $err++; } if ($FORM{'email'}) { $FORM{'email'}=~s/ //g; if (&checkEmail($FORM{'email'}) != 1) { $msg .= "Bad email address
"; $err++; } } if (!$FORM{'text'}) { $msg .= "Please fill in the Text field
"; $err++; } if ($err) { $FORM{'text'} =~ s!\n!//n!g; $FORM{'text'} =~ s!=!%3D!g; print "Location:$formUrl?action=writeComment&month=$FORM{'month'}&year=$FORM{'year'}&id=$FORM{'id'}&msg=$msg&name=$FORM{'name'}&subject=$FORM{'subject'}&email=$FORM{'email'}&www=$FORM{'www'}&text=$FORM{'text'}\n\n"; exit; } my $userDate = &getDate; my $userTime = &getTime; my $check = &checkForm(); my $counter; if ($check == 2) { $counter = &counter("$FORM{'month'}_$FORM{'year'}_$FORM{'id'}", "+"); } my $text = &modIn($FORM{'text'}); $text =~ s!<[sS][cC][rR][iI][pP][tT]!!g; $text =~ s!>$articlesPath/$whereTo") or dienice("Can't write to comments_$FORM{'id'}.db code 6 : $! \n"); flock(OUT, LOCK_EX); seek(OUT, 0, 2); print OUT "$FORM{'name'}|$FORM{'email'}|$FORM{'subject'}|$text|$userDate|$userTime|$www|$counter|$ENV{'REMOTE_ADDR'}\n"; close(OUT); if ($sendAdminEmail eq "yes") { if (!$FORM{'email'}) { $FORM{'email'} = "no_email_address\@nowhere.com"; } my $email; if ($htmlEmail eq "yes") { $email = qq|Mime-Version: 1.0\nContent-type: text/html; charset="iso-8859-1"\n|; } $email .= qq|From: "$FORM{'name'}" <$FORM{'email'}>\n|; $email .= qq|To: $adminEmail\n|; $email .= qq|Subject: Weblog Comment: $FORM{'subject'}\n|; if ($htmlEmail eq "yes") { $email .= qq|\n|; $email .= qq|\n|; $email .= qq|$text

\n|; $email .= qq|Numb: $counter
\n|; if ($ENV{'REMOTE_ADDR'}) { $email.= qq|Addy: $ENV{'REMOTE_ADDR'}
\n|; } if ($www) { $email.= qq|Site: $FORM{'www'}
\n|; } $email .= qq|
View this comment -- Edit this comment -- Delete this comment\n|; $email .= qq|\n|; $email .= qq||; } elsif ($htmlEmail eq "no") { $email .= qq|$FORM{'text'}\n\n|; $email .= qq|Numb: $counter\n|; if ($ENV{'REMOTE_ADDR'}) { $email .= qq|Addy: $ENV{'REMOTE_ADDR'}\n|; } if ($www) { $email .= qq|Site: $FORM{'www'}\n|; } $email .= qq|\nView this comment:\n|; $email .= qq|$formUrl?action=readComment&month=$FORM{'month'}&year=$FORM{'year'}&id=$FORM{'id'}\n\n|; $email .= qq|Edit this comment:\n|; $email .= qq|$formUrl?action=editComment&month=$FORM{'month'}&year=$FORM{'year'}&id=$FORM{'id'}&cid=$counter\n\n|; $email .= qq|Delete this comment:\n|; $email .= qq|$formUrl?action=deleteComment&month=$FORM{'month'}&year=$FORM{'year'}&id=$FORM{'id'}&cid=$counter|; } $email =~ s/\[\[.*?\]\]//sig; open (MAIL,"| $sendmailPath -t"); print MAIL $email; close(MAIL); } print "Location:$formUrl?action=readComment&month=$FORM{'month'}&year=$FORM{'year'}&id=$FORM{'id'}\n\n"; } ####################################################### ## Edit Comment if ($FORM{'action'} eq "editComment") { if ($adminPass) { if ($COOKIE{"$uniqueBit-pass"} eq $adminPassCrypt) { &editComment; } else { print "Location:$formUrl?action=login&redir=action%3DeditComment%26month%3D$FORM{'month'}%26year%3D$FORM{'year'}%26id%3D$FORM{'id'}%26cid%3D$FORM{'cid'}\n\n"; } } else { dienice("The Admin Password is blank. Please set it to something other than a null value.\n","1"); } sub editComment{ if (!$FORM{'first'}) { open(IN, "$articlesPath/$FORM{'month'}_$FORM{'year'}_$FORM{'id'}.db") or dienice("Can't read $FORM{'month'}_$FORM{'year'}_$FORM{'id'}.db code 7 : $! \n"); flock(IN, LOCK_SH); my @data = ; close(IN); chomp($data[$FORM{'cid'} - 1]); my @field = split(/\|/, $data[$FORM{'cid'} - 1]); $field[3] = &htmlMod($field[3]); $field[3] =~ s!\n!//n!g; $field[3] =~ s!=!%3D!g; print "Location:$formUrl?action=writeComment&month=$FORM{'month'}&year=$FORM{'year'}&id=$FORM{'id'}&cid=$FORM{'cid'}&name=$field[0]&subject=$field[2]&email=$field[1]&www=$field[6]&text=$field[3]\n\n"; exit; } my ($err, $msg); if (!$FORM{'name'}) { $msg .= "Please fill in the Name field
"; $err++; } if (!$FORM{'subject'}) { $msg .= "Please fill in the Subject field
"; $err++; } if ($FORM{'email'}) { $FORM{'email'}=~s/ //g; if (&checkEmail($FORM{'email'}) != 1) { $msg .= "Bad email address
"; $err++; } } if (!$FORM{'text'}) { $msg .= "Please fill in the Text field
"; $err++; } if ($err) { $FORM{'text'} =~ s!\n!//n!g; $FORM{'text'} =~ s!=!%3D!g; print "Location:$formUrl?action=writeComment&month=$FORM{'month'}&year=$FORM{'year'}&id=$FORM{'id'}&cid=$FORM{'cid'}&msg=$msg&name=$FORM{'name'}&subject=$FORM{'subject'}&email=$FORM{'email'}&www=$FORM{'www'}&text=$FORM{'text'}\n\n"; exit; } my $text = &modIn($FORM{'text'}); my $www; if ($FORM{'www'} =~ /^http:\/\/.+?$/ or $FORM{'www'} =~ /^www\..+?$/) { $FORM{'www'} =~ s!^(www\..+?)$!http://$1!g; $www = $FORM{'www'}; } else { $www = ""; } open(IN, "$articlesPath/$FORM{'month'}_$FORM{'year'}_$FORM{'id'}.db") or dienice("Can't read $FORM{'month'}_$FORM{'year'}_$FORM{'id'}.db code 8 : $! \n"); flock(IN, LOCK_SH); my @data = ; close(IN); chomp($data[$FORM{'cid'} - 1]); my @field=split(/\|/, $data[$FORM{'cid'} - 1]); $data[$FORM{'cid'} - 1] = "$FORM{'name'}|$FORM{'email'}|$FORM{'subject'}|$text|$field[4]|$field[5]|$www|$field[7]|$field[8]\n"; open(OUT, ">$articlesPath/$FORM{'month'}_$FORM{'year'}_$FORM{'id'}.db") or dienice("Can't write to $FORM{'month'}_$FORM{'year'}_$FORM{'id'}.db code 9 : $! \n"); flock(OUT, LOCK_EX); seek(OUT, 0, 0); truncate(OUT, 0); print OUT @data; close(OUT); print "Location:$formUrl?action=readComment&month=$FORM{'month'}&year=$FORM{'year'}&id=$FORM{'id'}\n\n"; } } ####################################################### ## Delete Comment if ($FORM{'action'} eq "deleteComment") { if ($adminPass) { if ($COOKIE{"$uniqueBit-pass"} eq $adminPassCrypt) { &deleteComment; } else { print "Location:$formUrl?action=login&redir=action%3DdeleteComment%26month%3D$FORM{'month'}%26year%3D$FORM{'year'}%26id%3D$FORM{'id'}%26cid%3D$FORM{'cid'}\n\n"; } } else { dienice("The Admin Password is blank. Please set it to something other than a null value.\n","1"); } sub deleteComment { if ($FORM{'err'}) { $ran++; $topPage =~ s//Comments/g; print "Content-type: text/html\n\n"; if ($FORM{'ssi'} ne "on") {print $topPage;} print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq|
\n|; print qq| There seems to be a problem with the comment you are trying to delete.
Just guessing, but maybe it doesn't exist?   read comments\n|; print qq|
\n|; if ($FORM{'ssi'} ne "on") {print $bottomPage;} exit; } open(IN, "$articlesPath/$FORM{'month'}_$FORM{'year'}_$FORM{'id'}.db") or dienice("Can't read $FORM{'month'}_$FORM{'year'}_$FORM{'id'}.db code 10 : $! \n"); flock(IN, LOCK_SH); my @data = ; close(IN); my $lastNum = scalar(@data); if ($FORM{'cid'} > $lastNum) { print "Location:$formUrl?action=deleteComment&month=$FORM{'month'}&year=$FORM{'year'}&id=$FORM{'id'}&err=yes\n\n"; exit; } if (!$FORM{'cid'}) { print "Location:$formUrl?action=deleteComment&month=$FORM{'month'}&year=$FORM{'year'}&id=$FORM{'id'}&err=yes\n\n"; exit; } if ($FORM{'cid'} eq 0) { print "Location:$formUrl?action=deleteComment&month=$FORM{'month'}&year=$FORM{'year'}&id=$FORM{'id'}&err=yes\n\n"; exit; } if (!$FORM{'first'}) { $ran++; $topPage =~ s//Comments/g; print "Content-type: text/html\n\n"; if ($FORM{'ssi'} ne "on") {print $topPage;} print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq|
\n|; print qq| Are you sure you want to delete this comment?   YES -- NO\n|; print qq|
\n|; if ($FORM{'ssi'} ne "on") {print $bottomPage;} exit; } my ($num, $fixedNum, @modData); for ($num = 1; $num <= $lastNum; $num++) { chomp($data[$num - 1]); my @field = split(/\|/, $data[$num - 1]); next if ($FORM{'cid'} eq $field[7]); if ($FORM{'cid'} < $field[7]) { $fixedNum = $num - 1; } else { $fixedNum = $num; } push(@modData,"$field[0]|$field[1]|$field[2]|$field[3]|$field[4]|$field[5]|$field[6]|$fixedNum|$field[8]\n"); } open(OUT, ">$articlesPath/$FORM{'month'}_$FORM{'year'}_$FORM{'id'}.db") or dienice("Can't write to $FORM{'month'}_$FORM{'year'}_$FORM{'id'}.db code 11 : $! \n"); flock(OUT, LOCK_EX); seek(OUT, 0, 0); truncate(OUT, 0); print OUT @modData; close(OUT); &counter("$FORM{'month'}_$FORM{'year'}_$FORM{'id'}", "-"); print "Location:$formUrl?action=readComment&month=$FORM{'month'}&year=$FORM{'year'}&id=$FORM{'id'}\n\n"; } } ####################################################### ## Delete Entry if ($FORM{'action'} eq "deleteEntry") { if ($adminPass) { if ($COOKIE{"$uniqueBit-pass"} eq $adminPassCrypt) { &deleteEntry; } else { print "Location:$formUrl?action=login&redir=action%3DdeleteEntry%26id%3D$FORM{'id'}\n\n"; } } else { dienice("The Admin Password is blank. Please set it to something other than a null value.\n","1"); } sub deleteEntry { if ($FORM{'err'}) { $ran++; $topPage =~ s//Delete Entry/g; print "Content-type: text/html\n\n"; if ($FORM{'ssi'} ne "on") {print $topPage;} print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq|
\n|; print qq| There seems to be a problem with the entry you are trying to delete.
Just guessing, but maybe it doesn't exist or there is only one entry?

Main Page\n|; print qq|
\n|; if ($FORM{'ssi'} ne "on") {print $bottomPage;} exit; } my $month = &getMonth; my $year = &getYear; open(IN, "$articlesPath/articles.db") or dienice("Can't read articles.db code 12 : $! \n"); flock(IN, LOCK_SH); my @data = ; close(IN); my $lastNum = scalar(@data); if ($FORM{'id'} eq 0) { print "Location:$formUrl?action=deleteEntry&err=yes\n\n"; exit; } if ($lastNum eq 1) { print "Location:$formUrl?action=deleteEntry&err=yes\n\n"; exit; } if ($FORM{'id'} > $lastNum) { print "Location:$formUrl?action=deleteEntry&err=yes\n\n"; exit; } if (!$FORM{'id'}) { print "Location:$formUrl?action=deleteEntry&err=yes\n\n"; exit; } if (!$FORM{'first'}) { $ran++; $topPage =~ s//Delete Entry/g; print "Content-type: text/html\n\n"; if ($FORM{'ssi'} ne "on") {print $topPage;} print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq|
\n|; print qq| Are you sure you want to delete this entry?   YES -- NO\n|; print qq|
\n|; if ($FORM{'ssi'} ne "on") {print $bottomPage;} exit; } chomp($data[$lastNum - 1]); my @dataX = split(/\|/, $data[$lastNum - 1]); if ($dataX[9]) { my @files = split(/\*/, $dataX[9]); foreach my $file (@files) { unlink ("$uploadsPath/$file"); } } unlink ("$articlesPath/$month\_$year\_$FORM{'id'}.db"); unlink ("$workingPath/$month\_$year\_$FORM{'id'}.db"); my ($num, $fixedNum, @modData); for ($num = 1; $num <= $lastNum; $num++) { chomp($data[$num - 1]); my @field = split(/\|/, $data[$num - 1]); next if ($FORM{'id'} eq $field[4]); if ($FORM{'id'} < $field[4]) { $fixedNum = $num - 1; } else { $fixedNum = $num; } push(@modData,"$field[0]|$field[1]|$field[2]|$field[3]|$fixedNum|$field[5]|$field[6]|$field[7]|$field[8]|$field[9]\n"); if (-e "$articlesPath/$month\_$year\_$num.db") { rename("$articlesPath/$month\_$year\_$num.db","$articlesPath/$month\_$year\_$fixedNum.db") or dienice("Can't rename $month\_$year\_$num.db code 13 : $! \n"); } if (-e "$workingPath/$month\_$year\_$num.db") { rename("$workingPath/$month\_$year\_$num.db","$workingPath/$month\_$year\_$fixedNum.db") or dienice("Can't rename $month\_$year\_$num.db code 14 : $! \n"); } } open(OUT, ">$articlesPath/articles.db") or dienice("Can't write to articles.db code 15 : $! \n"); flock(OUT, LOCK_EX); seek(OUT, 0, 0); truncate(OUT, 0); print OUT @modData; close(OUT); &counter("counter", "-"); print "Location:$formUrl\n\n"; } } ####################################################### ## Post if ($FORM{'action'} eq "post") { $ran++; my $counter = &counter("counter", "0", "yes"); my (@field, $text, $postFields); if ($FORM{'id'} && !$FORM{'msg'}) { open(IN, "$articlesPath/articles.db"); flock(IN, LOCK_SH); my @data = ; close(IN); chomp($data[$FORM{'id'} - 1]); @field = split(/\|/, $data[$FORM{'id'} - 1]); $text = &htmlMod($field[3]); chomp($text); $text =~ s/ $//g; if (!$FORM{'files'} && !$FORM{'noFiles'}) { $FORM{'files'} = $field[9]; } } else { $field[5] = $FORM{'name'}; $field[1] = $FORM{'title'}; $field[7] = $FORM{'email'}; $field[6] = $FORM{'www'}; ($text = $FORM{'text'}) =~ s!//n!\n!g; } $topPage =~ s//Post/g; print "Content-type: text/html\n\n"; if ($FORM{'ssi'} ne "on") {print $topPage;} print qq| \n|; print qq| \n|; print qq|
\n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; if ($FORM{'msg'}) { print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; } print qq| \n|; if ($FORM{'msg'}) { print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; } if (!$COOKIE{"$uniqueBit-pass"} && $multiUsers eq "yes") { print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; } print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; if (!$COOKIE{"$uniqueBit-pass"} && $multiUsers eq "yes") { print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; } if (!$COOKIE{"$uniqueBit-pass"}) { if ($postPass) { print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; } } if ($COOKIE{"$uniqueBit-pass"} && !$FORM{'msg'}) { print qq| \n|; print qq| \n|; print qq| \n|; if ($first <= 0) { print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; } print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; } else { if ($dateFormat eq 1) { $postFields .= qq| \n|; } elsif ($dateFormat eq 2) { $postFields .= qq| \n|; } } if ($COOKIE{"$uniqueBit-pass"} && $FORM{'files'} && $enableAttachments eq "yes") { print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; } elsif ($COOKIE{"$uniqueBit-pass"} && $enableAttachments eq "yes") { print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; } print qq| \n|; print qq| \n|; print qq| \n|; if ($enablePseudo eq "yes") { print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; } print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq|
$FORM{'msg'}
 
Name:  
Title:  
Email:  
Web Site:  
Password:  
 
ID Number: \n|; print qq| \n|; print qq| \n|; print qq|  
Time: \n|; } if ($timeFormat eq 24 && !$FORM{'msg'}) { my $hour = &getTime("hour24"); my $min = &getTime("min"); if ($COOKIE{"$uniqueBit-pass"}) { print qq| \n|; print qq| : \n|; print qq| \n|; } else { $postFields .= qq| \n|; $postFields .= qq| \n|; } } elsif ($timeFormat eq 12 && !$FORM{'msg'}) { my $hour = &getTime("hour12"); my $min = &getTime("min"); my $amPm = &getTime("ampm"); if ($COOKIE{"$uniqueBit-pass"}) { print qq| \n|; print qq| : \n|; print qq| \n|; print qq| \n|; } else { $postFields .= qq| \n|; $postFields .= qq| \n|; $postFields .= qq| \n|; } } my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = gmtime(time() + $hourAdjust * 60 * 60); $year = $year + 1900; my @montharray = (31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); my $maxdays = $montharray[$mon]; my $month = $months[$mon]; if ($month eq "February") { if ($year %4 eq 0 && ($year %100 ne 0 or $year %400 eq 0)) { $maxdays = 29; } else { $maxdays = 28; } } my $wDay = $wday; if ($COOKIE{"$uniqueBit-pass"} && !$FORM{'msg'}) { print qq| Keep original time
Date: \n|; print qq| \n|; print qq| Keep original date
 
 Attached files:

 
 \n|; my @field = split(/\*/, $FORM{'files'}); foreach my $file (@field) { print qq| Attached File $file|; if ($file =~ /^.+?\.[gG][iI][fF]$/ or $file =~ /^.+?\.[jJ][pP][gG]$/ or $file =~ /^.+?\.[pP][nN][gG]$/) { print qq| [insert]|; } print qq|
\n|; } print qq| \n|; print qq|
 
 
  
 
  
 
\n|; foreach my $smiley (@smiley) { my ($name, $value) = split(/\|/, $smiley); my $alt = ucfirst($name); print qq| $alt\n|; } print qq|
\n|; foreach my $pseudo (@pseudo) { my ($name, $value) = split(/\|/, $pseudo); print qq| $name\n|; } print qq|
 
\n|; if (!$FORM{'msg'}) { print qq|$postFields|; } print qq|
\n|; print qq|
$hrDiv
\n|; print qq|
Main Page -- Archive|; if ($COOKIE{"$uniqueBit-pass"}) { print qq| -- Admin Menu|; } print qq|
\n|; if ($FORM{'ssi'} ne "on") {print $bottomPage;} } ####################################################### ## Post X if ($FORM{'action'} eq "postX") { if ($FORM{'idc'} or $FORM{'button'}) { print "Location:$formUrl?action=post&id=$FORM{'id'}\n\n"; exit; } if ($FORM{'attachments'}) { $FORM{'text'} =~ s!\n!//n!g; $FORM{'text'} =~ s!=!%3D!g; print "Location:$formUrl?action=fileSelect&id=$FORM{'id'}&name=$FORM{'name'}&title=$FORM{'title'}&email=$FORM{'email'}&www=$FORM{'www'}&hour=$FORM{'hour'}&min=$FORM{'min'}&m=$FORM{'ampm'}&keepTime=$FORM{'keepTime'}&keepDate=$FORM{'keepDate'}&date=$FORM{'date'}&text=$FORM{'text'}&files=$FORM{'files'}\n\n"; exit; } my ($err, $msg); if ($multiUsers eq "yes" && !$COOKIE{"$uniqueBit-pass"}) { if (!$FORM{'name'}) { $msg .= "Please fill in the Name field
"; $err++; } } if (!$FORM{'title'}) { $msg .= "Please fill in the Title field
"; $err++; } if ($multiUsers eq "yes") { if ($FORM{'email'}) { $FORM{'email'}=~s/ //g; if (&checkEmail($FORM{'email'}) != 1) { $msg .= "Bad email address
"; $err++; } } } if ($multiUsers eq "yes" && !$COOKIE{"$uniqueBit-pass"} && $postPass) { if (!$FORM{'pass'}) { $msg .= "Please fill in the Password field
"; $err++; } } if (!$FORM{'text'}) { $msg .= "Please fill in the Text field
"; $err++; } if ($err) { $FORM{'text'} =~ s!\n!//n!g; $FORM{'text'} =~ s!=!%3D!g; print "Location:$formUrl?action=post&id=$FORM{'id'}&name=$FORM{'name'}&title=$FORM{'title'}&email=$FORM{'email'}&www=$FORM{'www'}&hour=$FORM{'hour'}&min=$FORM{'min'}&m=$FORM{'ampm'}&keepTime=$FORM{'keepTime'}&keepDate=$FORM{'keepDate'}&date=$FORM{'date'}&text=$FORM{'text'}&files=$FORM{'files'}&msg=$msg\n\n"; exit; } if (!$adminPass) { dienice("The Admin Password is blank. Please set it to something other than a null value.\n","1"); exit; } if ($FORM{'buttonX'} eq "Preview") { $FORM{'text'} =~ s!\n!
!g; $FORM{'text'} =~ s!=!%3D!g; print "Location:$formUrl?action=preView&name=$FORM{'name'}&title=$FORM{'title'}&email=$FORM{'email'}&www=$FORM{'www'}&hour=$FORM{'hour'}&min=$FORM{'min'}&m=$FORM{'ampm'}&date=$FORM{'date'}&text=$FORM{'text'}&files=$FORM{'files'}\n\n"; exit; } if ($COOKIE{"$uniqueBit-pass"} eq $adminPassCrypt or $FORM{'pass'} eq $adminPass or $FORM{'pass'} eq $postPass or !$postPass) { &postX; } else { $FORM{'text'} =~ s!\n!//n!g; $FORM{'text'} =~ s!=!%3D!g; print "Location:$formUrl?action=post&id=$FORM{'id'}&name=$FORM{'name'}&title=$FORM{'title'}&email=$FORM{'email'}&www=$FORM{'www'}&hour=$FORM{'hour'}&min=$FORM{'min'}&m=$FORM{'ampm'}&keepTime=$FORM{'keepTime'}&keepDate=$FORM{'keepDate'}&date=$FORM{'date'}&text=$FORM{'text'}&files=$FORM{'files'}&msg=Bad password
\n\n"; exit; } sub postX { my ($time, $date, $www, $text, $num, @field, @data); if (-e "$articlesPath/articles.db") { open(IN, "$articlesPath/articles.db"); flock(IN, LOCK_SH); @data = ; close(IN); chomp($data[$FORM{'id'} - 1]); @field = split(/\|/, $data[$FORM{'id'} - 1]); } if ($FORM{'keepTime'} eq "yes") { $time = $field[2]; } else { if (!$FORM{'hour'} && !$FORM{'min'}) { $time = &getTime; } else { $time = "$FORM{'hour'}:$FORM{'min'}"; if ($timeFormat eq 12) { $time .= " $FORM{'ampm'}"; } } } if ($FORM{'keepDate'} eq "yes") { $date = $field[0]; } else { if (!$FORM{'date'}) { $date = &getDate; } else { $date = "$FORM{'date'}"; } } if (!$FORM{'name'} && !$field[5]) { $FORM{'name'} = $adminName; } else { $FORM{'name'} = $field[5]; } if (!$FORM{'title'}) { $FORM{'title'} = $field[1]; } if ($FORM{'www'} =~ /^http:\/\/.+?$/ or $FORM{'www'} =~ /^www\..+?$/) { $FORM{'www'} =~ s!^(www\..+?)$!http://$1!g; $www = $FORM{'www'}; } else { $www = ""; } if (!$FORM{'text'}) { $text = $field[3]; } else { $text = &modIn($FORM{'text'}); if ($multiUsers eq "yes" && !$COOKIE{"$uniqueBit-pass"}) { $text =~ s!<[sS][cC][rR][iI][pP][tT]!!g; $text =~ s!= 1) { my $yearX = &getYear; my $monthX = &getMonth; open(IN, "$workingPath/prior_months.db") or dienice("Can't read prior_months.db code 16 : $! \n"); flock(IN, LOCK_SH); my @data = ; close(IN); my $lastNum = scalar(@data); chomp($data[$lastNum - 1]); my @field = split(/\|/, $data[$lastNum - 1]); open(IN, "$workingPath/month.db") or dienice("Can't read month.db code 17 : $! \n"); flock(IN, LOCK_SH); my $priorMonth = ; close(IN); unlink ("$workingPath/counter.db") or dienice("Can't delete counter.db code 18 : $! \n"); unlink ("$workingPath/first.db") or dienice("Can't delete first.db code 19 : $! \n"); $num = &counter("counter", "+"); open(OUT, ">$workingPath/month.db") or dienice("Can't write to month.db code 20 : $! \n"); flock(OUT, LOCK_EX); seek(OUT, 0, 0); truncate(OUT, 0); print OUT $monthX; close(OUT); open(OUT, ">>$workingPath/prior_months.db") or dienice("Can't write to prior_months.db code 21 : $! \n"); flock(OUT, LOCK_EX); seek(OUT, 0, 2); print OUT "$monthX|$yearX\n"; close(OUT); rename("$articlesPath/articles.db","$articlesPath/$priorMonth\_$field[1].db") or dienice("Can't rename articles.db to $priorMonth\_$field[1].db code 22 : $! \n"); open(OUT, ">$articlesPath/articles.db") or dienice("Can't write to articles.db code 23 : $! \n"); flock(OUT, LOCK_EX); seek(OUT, 0, 0); truncate(OUT, 0); print OUT "$date|$FORM{'title'}|$time|$text|$num|$FORM{'name'}|$www|$FORM{'email'}|$ENV{'REMOTE_ADDR'}|$FORM{'files'}\n"; close(OUT); } elsif (!$FORM{'id'}) { $num = &counter("counter", "+"); open(OUT, ">>$articlesPath/articles.db") or dienice("Can't write to articles.db code 24 : $! \n"); flock(OUT, LOCK_EX); seek(OUT, 0, 2); print OUT "$date|$FORM{'title'}|$time|$text|$num|$FORM{'name'}|$www|$FORM{'email'}|$ENV{'REMOTE_ADDR'}|$FORM{'files'}\n"; close(OUT); } elsif ($FORM{'id'}) { if (!$FORM{'files'} && !$FORM{'noFiles'}) { $FORM{'files'} = $field[9]; } $data[$FORM{'id'} - 1] = "$date|$FORM{'title'}|$time|$text|$FORM{'id'}|$FORM{'name'}|$www|$FORM{'email'}|$field[8]|$FORM{'files'}\n"; open(OUT, ">$articlesPath/articles.db") or dienice("Can't write to articles.db code 25 : $! \n"); flock(OUT, LOCK_EX); seek(OUT, 0, 0); truncate(OUT, 0); print OUT @data; close(OUT); } if ($multiUsers eq "yes" && $sendAdminEmail eq "yes" && !$COOKIE{"$uniqueBit-pass"}) { my $month = &getMonth; my $year = &getYear; if (!$FORM{'email'}) { $FORM{'email'} = "no_email_address\@nowhere.com"; } my $email; if ($htmlEmail eq "yes") { $email = qq|Mime-Version: 1.0\nContent-type: text/html; charset="iso-8859-1"\n|; } $email .= qq|From: "$FORM{'name'}" <$FORM{'email'}>\n|; $email .= qq|To: $adminEmail\n|; $email .= qq|Subject: Weblog Post: $FORM{'title'}\n|; if ($htmlEmail eq "yes") { $email .= qq|\n|; $email .= qq|\n|; $email .= qq|$text

\n|; $email .= qq|Numb: $num
\n|; if ($ENV{'REMOTE_ADDR'}) { $email.= qq|Addy: $ENV{'REMOTE_ADDR'}
\n|; } if ($www) { $email.= qq|Site: $www
\n|; } if ($FORM{'files'} && $enableAttachments eq "yes") { $email .= qq|Files:|; my @field = split(/\*/, $FORM{'files'}); foreach my $file (@field) { $email .= qq| $file|; } $email .= qq|
\n|; } $email .= qq|
View this entry -- Edit this entry -- Delete this entry\n|; $email .= qq|\n|; $email .= qq||; } elsif ($htmlEmail eq "no") { $email .= qq|$FORM{'text'}\n\n|; $email .= qq|Numb: $num\n|; if ($ENV{'REMOTE_ADDR'}) { $email .= qq|Addy: $ENV{'REMOTE_ADDR'}\n|; } if ($www) { $email .= qq|Site: $www\n|; } if ($FORM{'files'} && $enableAttachments eq "yes") { $email .= qq|Files:|; my @field = split(/\*/, $FORM{'files'}); foreach my $file (@field) { $email .= qq| $file|; } $email .= qq|
\n|; } $email .= qq|\nView this entry:\n|; $email .= qq|$formUrl?action=viewEntry&month=$month&year=$year&id=$num\n\n|; $email .= qq|Edit this entry:\n|; $email .= qq|$formUrl?action=post&id=$num\n\n|; $email .= qq|Delete this entry:\n|; $email .= qq|$formUrl?action=deleteEntry&id=$num|; } $email =~ s/\[\[.*?\]\]//sig; open (MAIL,"| $sendmailPath -t"); print MAIL $email; close(MAIL); } print "Location:$formUrl\n\n"; } } ####################################################### ## Preview Entry if ($FORM{'action'} eq "preView") { $ran++; if (!$FORM{'name'}) { $FORM{'name'} = $adminName; } my $www; if ($FORM{'www'} =~ /^http:\/\/.+?$/ or $FORM{'www'} =~ /^www\..+?$/) { $FORM{'www'} =~ s!^(www\..+?)$!http://$1!g; $www = $FORM{'www'}; } else { $www = ""; } $FORM{'text'} = &modIn($FORM{'text'}); if ($multiUsers eq "yes" && !$COOKIE{"$uniqueBit-pass"}) { $FORM{'text'} =~ s!<[sS][cC][rR][iI][pP][tT]!!g; $FORM{'text'} =~ s!/Entry Viewer/g; print "Content-type: text/html\n\n"; if ($FORM{'ssi'} ne "on") {print $topPage;} print qq| \n|; print qq| \n|; if ($multiUsers eq "yes" or $COOKIE{"$uniqueBit-pass"}) { print qq| \n|; print qq| \n|; if ($multiUsers eq "yes") { print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; } if ($FORM{'files'} && $enableAttachments eq "yes") { print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; } print qq| \n|; if ($multiUsers eq "yes" or $COOKIE{"$uniqueBit-pass"}) { print qq| \n|; print qq| \n|; print qq|
\n|; } else { print qq| \n|; } if ($titleFormat eq 2) { print qq| $FORM{'date'}
\n|; print qq| $FORM{'title'} @ $FORM{'hour'}:$FORM{'min'} $FORM{'ampm'} $timeZone
\n|; } elsif ($titleFormat eq 1) { print qq| $FORM{'title'}
\n|; print qq| $FORM{'date'} @ $FORM{'hour'}:$FORM{'min'} $FORM{'ampm'} $timeZone
\n|; } print qq| $FORM{'text'}\n|; if ($multiUsers eq "yes" or $COOKIE{"$uniqueBit-pass"}) { print qq|

\n|; } print qq|
 |; print qq|$FORM{'name'} (|; if ($www) { print qq|www|; } else { print qq|www|; } print qq| / |; if ($FORM{'email'}) { print qq|@|; } else { print qq|@|; } print qq|)
 
Attached files:

\n|; my @files = split(/\*/, $FORM{'files'}); foreach my $file (@files) { print qq| Attached File $file
\n|; } print qq|
 
|; } else { print qq| |; } print qq|
$hrDiv
\n|; print qq| \n|; if ($FORM{'ssi'} ne "on") {print $bottomPage;} } ####################################################### ## File(s) Select if ($FORM{'action'} eq "fileSelect" && $enableAttachments eq "yes" && $COOKIE{"$uniqueBit-pass"}) { $ran++; if ($FORM{'delete'}) { $FORM{'files'} =~ s!$FORM{'delete'}\*!!g; unlink ("$uploadsPath/$FORM{'delete'}"); } $topPage =~ s//Attach Files/g; print "Content-type: text/html\n\n"; if ($FORM{'ssi'} ne "on") {print $topPage;} print qq| \n|; if ($FORM{'files'}) { print qq|
\n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq|
Attached files:

\n|; my @field = split(/\*/, $FORM{'files'}); foreach my $file (@field) { print qq| Attached File $file    [remove]
\n|; } print qq|
 
\n|; print qq|
\n|; print qq|
$hrDiv
\n|; } print qq|
\n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; if ($FORM{'msg'}) { print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; } for (my $num = 1; $num <= $maxUploadFiles; $num++) { print qq| \n \n \n \n|; } print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; } else { print qq|Finished">\n|; } print qq| \n|; print qq|
$FORM{'msg'}
 
File $num:\n   \n Overwrite\n
 
\n|; print qq|
\n|; if ($FORM{'ssi'} ne "on") {print $bottomPage;} } ####################################################### ## Admin if ($FORM{'action'} eq "admin") { $ran++; if ($adminPass) { if ($COOKIE{"$uniqueBit-pass"} eq $adminPassCrypt) { &admin; } else { print "Location:$formUrl?action=login&redir=action%3Dadmin\n\n"; } } else { dienice("The Admin Password is blank. Please set it to something other than a null value.\n","1"); } sub admin { print qq|Set-Cookie: $uniqueBit-error=; path=$path; expires=Tue, 01-Jan-1980 12:00:00 GMT\n|; open(IN, "$indexCgi") or dienice("Can't read $indexCgi code 26 : $! \n"); flock(IN, LOCK_SH); my @data = ; close(IN); chomp($data[6], $data[8]); $data[6] =~ s!^# 4est Logging, (.+?)$!$1!g; $data[8] =~ s!^# Last Modified: (.+?)$!$1!g; $ENV{'SCRIPT_NAME'} =~ s!^(.+?)$indexCgi$!$1!g; $topPage =~ s//4est Logging/g; print "Content-type: text/html\n\n"; if ($FORM{'ssi'} ne "on") {print $topPage;} print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq|
Admin Menu
 
\n|; print qq|
    \n|; if ($COOKIE{"$uniqueBit-pass"} =~ /^wL/) { print qq|
  • Logout
  • \n|; } print qq|
  • Add / Edit Entry
  • \n|; print qq|
\n|; print qq|
\n|; print qq|
\n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq|
Script Info:
\n|; print qq| $data[6] -- $data[8]
\n|; print qq| Script Name: $indexCgi
\n|; print qq| Script Path: $ENV{'SCRIPT_NAME'}
\n|; print qq| Articles Path: $articlesPath|; if (!-e $articlesPath or !-w $articlesPath or !-x $articlesPath) { print qq|, Does not exist| if !-e $articlesPath; if (-e $articlesPath) { print qq|, Not Writable| if !-w $articlesPath; print qq|, Not Executable| if !-x $articlesPath; print qq|, You must set permissions to 755|; } } print qq|\n
Uploads Path: $uploadsPath|; if (!-e $uploadsPath or !-w $uploadsPath or !-x $uploadsPath) { print qq|, Does not exist| if !-e $uploadsPath; if (-e $uploadsPath) { print qq|, Not Writable| if !-w $uploadsPath; print qq|, Not Executable| if !-x $uploadsPath; print qq|, You must set permissions to 755|; } } print qq|\n
Working Path: $workingPath|; if (!-e $workingPath or !-w $workingPath or !-x $workingPath) { print qq|, Does not exist| if !-e $workingPath; if (-e $workingPath) { print qq|, Not Writable| if !-w $workingPath; print qq|, Not Executable| if !-x $workingPath; print qq|, You must set permissions to 755|; } } print qq|\n
Upload Script: upload.cgi|; if (!-e "upload.cgi" or !-x "upload.cgi") { print qq|, Does not exist| if !-e "upload.cgi"; if (-e "upload.cgi") { print qq|, Not Executable| if !-x "upload.cgi"; print qq|, You must set permissions to 755|; } } print qq|\n
Template file: $templateFile
\n|; print qq| URL to the images dir: $imagesPath
\n|; print qq|
\n|; print qq|
\n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq|
Server Info:
\n|; print qq| Perl Version: $]
\n|; print qq| Operating System: $^O
\n|; print qq| File System Root: $ENV{'DOCUMENT_ROOT'}
\n|; print qq| Server Software: $ENV{SERVER_SOFTWARE}\n|; print qq|
\n|; if ($FORM{'ssi'} ne "on") {print $bottomPage;} } } ####################################################### ## Login page if ($FORM{'action'} eq "login") { $ran++; $topPage =~ s//Login/g; print "Content-type: text/html\n\n"; if ($FORM{'ssi'} ne "on") {print $topPage;} print qq| \n|; if ($FORM{'msg'}) { print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; } print qq| \n|; print qq| \n|; print qq| \n|; print qq|
$FORM{'msg'}
 
\n|; print qq| Login
\n|; print qq|
\n|; print qq| \n|; print qq| \n|; print qq| Password: \n|; print qq| \n|; print qq|
\n|; print qq| \n|; print qq|
\n|; if ($FORM{'ssi'} ne "on") {print $bottomPage;} } ####################################################### ## Login set page if ($FORM{'action'} eq "loginX") { $ran++; if ($adminPass) { if ($FORM{'pass'} eq $adminPass) { print qq|Set-Cookie: $uniqueBit-pass=$adminPassCrypt; path=$path; expires=$expdate\n|; if ($FORM{'redir'}) { print "Location:$formUrl?$FORM{'redir'}\n\n"; } else { print "Location:$formUrl?action=admin\n\n"; } } else { $FORM{'redir'} =~ s!&!%26!g; $FORM{'redir'} =~ s!=!%3D!g; print "Location:$formUrl?action=login&msg=Bad Password&redir=$FORM{'redir'}\n\n"; } } else { dienice("It would appear that the master password variable is a null value.
We can't go on like this, it just isn't right, so would you please set it.\n","1"); } } ####################################################### ## Logout page if ($FORM{'action'} eq "logout") { $ran++; print qq|Set-Cookie: $uniqueBit-pass=; path=$path; expires=Tue, 01-Jan-1980 12:00:00 GMT\n|; $topPage =~ s//Logout/g; print "Content-type: text/html\n\n"; if ($FORM{'ssi'} ne "on") {print $topPage;} print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq| \n|; print qq|
\n|; print qq| Successfully logged out
\n|; print qq|
Main Page
\n|; print qq|
\n|; if ($FORM{'ssi'} ne "on") {print $bottomPage;} } ####################################################### ## JavaScript if ($FORM{'action'} eq "javaScript") { $ran++; print "Content-type: text/html\n\n"; print qq||; } ####################################################### ## End Check if ($FORM{'action'} && !$ran) { $topPage =~ s//Action Check/g; print "Content-type: text/html\n\n"; if ($FORM{'ssi'} ne "on") {print $topPage;} print qq|
This action ( $FORM{'action'} ) is not a valid action.
|; if ($FORM{'ssi'} ne "on") {print $bottomPage;} } ####################################################### ## Get Form Data sub getData { my (@pairs, $buffer, $pair, $name, $value); @pairs = split(/;./,$ENV{'HTTP_COOKIE'}); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $COOKIE{$name} = $value; } if ($ENV{'REQUEST_METHOD'} eq 'GET') { @pairs = split(/&/, $ENV{'QUERY_STRING'}); } elsif ($ENV{'REQUEST_METHOD'} eq 'POST') { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); } foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $name =~ tr/+/ /; $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $name =~ s/\n//g; $value =~ tr/+/ /; $value =~ s/%0D//g; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s/\|/|/g; $FORM{$name} = $value; } return(1); } ####################################################### ## Mod In sub modIn{ my $inText = $_[0]; $inText =~ s!\n!
!isg; if($autoLinkUrls eq "yes" ) { $inText =~ s~([^\w\"\=\[\]]|[\n\b]|\A)\\*(\w+://[\w\~\.\;\:\,\$\-\+\!\*\?/\=\&\@\#\%]+\.[\w\~\;\:\$\-\+\!\*\?/\=\&\@\#\%]+[\w\~\;\:\$\-\+\!\*\?/\=\&\@\#\%])~$1$2~isg; $inText =~ s~[^(?:\://\w+)]([^\"\=\[\]/\:\.]|[\n\b]|\A)\\*(www\.[^\.][\w\~\.\;\:\,\$\-\+\!\*\?/\=\&\@\#\%]+\.[\w\~\;\:\$\-\+\!\*\?/\=\&\@\#\%]+[\w\~\;\:\$\-\+\!\*\?/\=\&\@\#\%])~$1$2~isg; } if ($enablePseudo eq "yes") { $inText =~ s!\[url(.+?)\[\/url\]!''!iseg; $inText =~ s!\[email\](.+?)\[/email\]!$1!ig; $inText =~ s!\[email=(.+?)\](.+?)\[\/email\]!$2!isg; $inText =~ s~\[b\](.+?)\[/b\]~$1~isg; $inText =~ s~\[i\](.+?)\[/i\]~$1~isg; $inText =~ s~\[u\](.+?)\[/u\]~$1~isg; $inText =~ s~\[s\](.+?)\[/s\]~$1~isg; $inText =~ s~\[nbsp\]~ ~g; $inText =~ s~\[hr\]~$hrDiv~g; $inText =~ s~\[font=(.+?)\](.+?)\[/font\]~$2~isg; $inText =~ s~\[size=(.+?)\](.+?)\[/size\]~$2~isg; $inText =~ s~\[left\](.+?)\[/left\]~
$1
~isg; $inText =~ s~\[center\](.+?)\[/center\]~
$1
~isg; $inText =~ s~\[right\](.+?)\[/right\]~
$1
~isg; $inText =~ s~\[list\]~
    ~isg; $inText =~ s~\[\*\]~
  • ~isg; $inText =~ s~\[/list\]~
~isg; $inText =~ s~\[table(.*?)\]~~g; $inText =~ s~\[/table\]~~g; $inText =~ s~\[tbody(.*?)\]~~isg; $inText =~ s~\[/tbody\]~~isg; $inText =~ s~\[row(.*?)\]~~isg; $inText =~ s~\[/row\]~~isg; $inText =~ s~\[column(.*?)\]~~isg; $inText =~ s~\[/column\]~~isg; $inText =~ s~\[tr(.*?)\]~~isg; $inText =~ s~\[/tr\]~~isg; $inText =~ s~\[td(.*?)\]~~isg; $inText =~ s~\[/td\]~~isg; foreach my $smiley (@smiley) { my ($name, $value) = split(/\|/, $smiley); $value =~ s/"(.+?)"/$1/g; my $alt = ucfirst($name); $inText =~ s/\Q$value\E/\$alt/g; } } return $inText; } ####################################################### ## HTML Mod sub htmlMod { my $htmlMod = $_[0]; $htmlMod =~ s/
/\n/g; if ($enablePseudo eq "yes") { foreach my $smiley (@smiley) { my ($name, $value) = split(/\|/, $smiley); $value =~ s/"(.+?)"/$1/g; my $alt = ucfirst($name); $htmlMod =~ s!$alt!$value!isg; } $htmlMod =~ s!$hrDiv!\[hr\]!isg; $htmlMod =~ s!\(.+?)\!\[b\]$1\[/b\]!isg; $htmlMod =~ s!\(.+?)\!\[i\]$1\[/i\]!isg; $htmlMod =~ s!\(.+?)\!\[u\]$1\[/u\]!isg; $htmlMod =~ s!\(.+?)\!\[s\]$1\[/s\]!isg; $htmlMod =~ s!!'[url' . linkEmFrom($1) . '[/url]'!iseg; $htmlMod =~ s!!'[img' . imgEmFrom($1) . '[/img]'!iseg; $htmlMod =~ s~(.+?)~\[font=$1\]$2\[/font\]~isg; $htmlMod =~ s~(.+?)~\[size=$1\]$2\[/size\]~isg; $htmlMod =~ s~
(.+?)
~\[left\]$1\[/left\]~isg; $htmlMod =~ s~
(.+?)
~\[center\]$1\[/center\]~isg; $htmlMod =~ s~
(.+?)
~\[right\]$1\[/right\]~isg; $htmlMod =~ s~ ~\[nbsp\]~g; $htmlMod =~ s~
    ~\[list\]~isg; $htmlMod =~ s~
  • ~\[\*\]~isg; $htmlMod =~ s~
~\[/list\]~isg; $htmlMod =~ s~~\[table$1\]~g; $htmlMod =~ s~~\[/table\]~g; $htmlMod =~ s~~\[tbody$1\]~isg; $htmlMod =~ s~~\[/tbody\]~isg; $htmlMod =~ s~~\[row$1\]~isg; $htmlMod =~ s~~\[/row\]~isg; $htmlMod =~ s~~\[column$1\]~isg; $htmlMod =~ s~~\[/column\]~isg; } return $htmlMod; } ####################################################### ## RegEx links to HTML sub linkEmTo { my $link = $_[0]; if ($link =~ /^\].+?$/) { $link =~ s!^\](.+?)$!$1!isg; $link = qq|$link">$link|; } if ($link =~ /^=.+? target=\].+?$/) { $link =~ s!^=(.+?) target=\](.+?)$!$1" TARGET="_self">$2!isg; } if ($link =~ /^=.+? target=.+?\].+?$/) { $link =~ s!^=(.+?) target=(.+?)\](.+?)$!$1" TARGET="$2">$3!isg; } if ($link =~ /^=.+?\].+?$/) { $link =~ s!^=(.+?)\](.+?)$!$1">$2!isg; } return $link; } ####################################################### ## RegEx links from HTML sub linkEmFrom { my $link = $_[0]; if ($link =~ /^.+?" TARGET=".+?">.+?$/) { $link =~ s!^(.+?)" TARGET="(.+?)">(.+?)$!=$1 target=$2\]$3!isg; } if ($link =~ /^.+?">.+?$/) { my $a = $link; my $b = $link; $a =~ s!^(.+?)">.+?$!$1!isg; $b =~ s!^.+?">(.+?)$!$1!isg; if ($a eq $b) { $link =~ s!^(.+?)">.+?$!\]$1!isg; } else { $link =~ s!^(.+?)">(.+?)$!=$1\]$2!isg; } } return $link; } ####################################################### ## RegEx images to HTML sub imgEmTo { my $img = $_[0]; if ($img =~ /^=.+? height= width=\]/) { $img =~ s!^=(.+?) height= width=\](.*)!SRC="$1" ALT="$2"!isg; } if ($img =~ /^=.+? height=.+? width=.+?\]/) { $img =~ s!^=(.+?) height=(.+?) width=(.+?)\](.*)!HEIGHT="$2" SRC="$1" WIDTH="$3" ALT="$4"!isg; } if ($img =~ /^=.+? height=\]/) { $img =~ s!^=(.+?) height=\](.*)!SRC="$1" ALT="$2"!isg; } if ($img =~ /^=.+? height=.+?\]/) { $img =~ s!^=(.+?) height=(.+?)\](.*)!HEIGHT="$2" SRC="$1" ALT="$3"!isg; } if ($img =~ /^=.+? width=\]/) { $img =~ s!^=(.+?) width=\](.*)!SRC="$1" ALT="$2"!isg; } if ($img =~ /^=.+? width=.+?\]/) { $img =~ s!^=(.+?) width=(.+?)\](.*)!SRC="$1" WIDTH="$2" ALT="$3"!isg; } if ($img =~ /^\].+?$/) { $img =~ s!^\](.+?)$!$1!isg; $img = qq|SRC="$img" ALT=""|; } if ($img =~ /^=.+?\]/) { $img =~ s!^=(.+?)\](.*)!SRC="$1" ALT="$2"!isg; } return $img; } ####################################################### ## RegEx images from HTML sub imgEmFrom { my $img = $_[0]; if ($img =~ /^HEIGHT=".+?" SRC=".+?" WIDTH=".+?"/) { $img =~ s!^HEIGHT="(.+?)" SRC="(.+?)" WIDTH="(.+?)" ALT="(.*)"$!=$2 height=$1 width=$3\]$4!isg; } if ($img =~ /^HEIGHT=".+?" SRC=".+?"/) { $img =~ s!^HEIGHT="(.+?)" SRC="(.+?)" ALT="(.*)"$!=$2 height=$1\]$3!isg; } if ($img =~ /^SRC=".+?" WIDTH=".+?"/) { $img =~ s!^SRC="(.+?)" WIDTH="(.+?)" ALT="(.*)"$!=$1 width=$2\]$3!isg; } if ($img =~ /^SRC=".+?" ALT=""$/) { $img =~ s!^SRC="(.+?)" ALT=""$!$1!isg; $img = qq|\]$img|; } if ($img =~ /^SRC=".+?"/) { $img =~ s!^SRC="(.+?)" ALT="(.*)"$!=$1\]$2!isg; } return $img; } ####################################################### ## RegEx email from HTML sub emailEmFrom { my $email = $_[0]; my $a = $email; my $b = $email; $a =~ s!^(.+?)">.+?$!$1!isg; $b =~ s!^.+?">(.+?)$!$1!isg; if ($a eq $b) { $email =~ s!^(.+?)">.+?$!\]$1!isg; } else { $email =~ s!^(.+?)">(.+?)$!=$1\]$2!isg; } return $email; } ####################################################### ## File Check sub fileCheck { if (!-e "$workingPath/month.db") { my $month = &getMonth; open(OUT, ">$workingPath/month.db") or dienice("Can't write to month.db code 27 : $! \n"); flock(OUT, LOCK_EX); seek(OUT, 0, 0); truncate(OUT, 0); print OUT $month; close(OUT); } if (!-e "$workingPath/prior_months.db") { my $year = &getYear; my $month = &getMonth; open(OUT, ">$workingPath/prior_months.db") or dienice("Can't write to prior_months.db code 28 : $! \n"); flock(OUT, LOCK_EX); seek(OUT, 0, 0); truncate(OUT, 0); print OUT "$month|$year\n"; close(OUT); } my $monthX = &getMonth; open(IN, "$workingPath/month.db") or dienice("Can't read month.db code 29 : $! \n"); flock(IN, LOCK_SH); my $priorMonth = ; close(IN); my $first = &counter("first", "0", "yes"); if ($monthX ne $priorMonth && $first <= 0) { &counter("first", "+"); } } ####################################################### ## Increment counter with return value sub counter { my ($file, $operation, $displayOnly) = @_; my (@countermyfile, $keycounter); open(IN,"$workingPath/$file.db"); flock(IN, LOCK_SH); (@countermyfile=); $keycounter=$countermyfile[0]; if ($operation eq "+") { $keycounter++; } elsif ($operation eq "-") { $keycounter = $keycounter - 1; } close(IN); if ($keycounter > 99999999) { $keycounter=10000000; } if ($displayOnly ne "yes") { open(OUT,">$workingPath/$file.db"); flock(OUT, LOCK_EX); seek(OUT, 0, 0); truncate(OUT, 0); print OUT $keycounter; close(OUT); } return $keycounter; } ####################################################### ## Month and year check sub checkForm { my $checked; foreach (@months) { if ($FORM{'month'} eq $_) { $checked++; } } if ($FORM{'year'} =~ /^[0-9]{4,4}$/) { $checked++; } return $checked; } ####################################################### ## Check for valid email address sub checkEmail { if ($_[0] =~ /^[0-9]*$/) { return(0); } else { if ($_[0] =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)|(\.$)/ or ($_[0] !~ /^.+\@localhost$/ && $_[0] !~ /^.+\@\[?(\w|[-.])+\.[a-zA-Z]{2,3}|[0-9]{1,3}\]?$/)) { return(0); } else { return(1); } } } ####################################################### ## Cookie Time sub cookieTime { srand(time); my @ctMonths = ("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"); my @days = ("Sun","Mon","Tue","Wed","Thu","Fri","Sat"); my ($sec,$min,$hr,$mday,$mon,$yr,$wday,$yday,$isdst) = gmtime(time+(86400*$cookieExpiration)); # format must be Wed, DD-Mon-YYYY HH:MM:SS GMT my $timestr = sprintf("%3s, %02d-%3s-%4d %02d:%02d:%02d GMT", $days[$wday],$mday,$ctMonths[$mon],$yr+1900,$hr,$min,$sec); return $timestr; } ####################################################### ## Get Date sub getDate { my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = gmtime(time() + $hourAdjust * 60 * 60); $year = $year + 1900; my @days = qw!1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31!; if ($dateFormat eq 1) { return "$wdays[$wday-1], $months[$mon] $days[$mday-1], $year"; } elsif ($dateFormat eq 2) { return "$wdays[$wday-1], $days[$mday-1] $months[$mon] $year"; } } ####################################################### ## Get Time sub getTime { my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = gmtime(time() + $hourAdjust * 60 * 60); my $hour24 = $hour; my $hour12 = $hour; if ($hour > 12) { $hour12 = $hour - 12; } $hour12 = 12 if $hour12 == 0; my $amPm = "AM"; if ($hour >= 12){ $amPm = "PM"; } $min = '0' x (2 - length($min)) . $min; $sec = '0' x (2 - length($sec)) . $sec; $hour24 = '0' x (2 - length($hour24)) . $hour24; my $time; if (!$_[0] && $timeFormat eq "12") { $time = "$hour12:$min $amPm"; } elsif (!$_[0] && $timeFormat eq "24") { $time = "$hour24:$min"; } if ($_[0] eq "hour12") { $time = $hour12; } if ($_[0] eq "hour24") { $time = $hour24; } if ($_[0] eq "min") { $time = $min; } if ($_[0] eq "ampm") { $time = $amPm; } return $time; } ####################################################### ## Get Month sub getMonth { my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = gmtime(time() + $hourAdjust * 60 * 60); if ($first >= 1 && $_[0]) { open(IN, "$workingPath/prior_months.db") or dienice("Can't read prior_months.db code 30 : $! \n"); flock(IN, LOCK_SH); my @data = ; close(IN); my $lastNum = scalar(@data); chomp($data[$lastNum - 1]); my @field = split(/\|/, $data[$lastNum - 1]); return $field[0]; } else { return $months[$mon]; } } ####################################################### ## Get Year sub getYear { my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = gmtime(time() + $hourAdjust * 60 * 60); $year = $year + 1900; if ($first >= 1 && $_[0]) { open(IN, "$workingPath/prior_months.db") or dienice("Can't read prior_months.db code 31 : $! \n"); flock(IN, LOCK_SH); my @data = ; close(IN); my $lastNum = scalar(@data); chomp($data[$lastNum - 1]); my @field = split(/\|/, $data[$lastNum - 1]); return $field[1]; } else { return $year; } } ####################################################### ## Returns the HTML template sub template { my ($template, $request) = @_; my ($marker, $returnvalue, $method); if ($request eq "top") { $method = 0; } elsif ($request eq "bottom") { $method = 1; } open(TEMPLATE,"$template"); flock(TEMPLATE, LOCK_SH); while (