#!/usr/local/bin/perl ################################################################# # Message Board V4.5.1 (Freeware) # # This program is distributed as freeware. We are not # responsible for any damages that the program causes # to your system. It may be used and modified free of # charge, as long as the copyright notice # in the program that give me credit remain intact. # If you find any bugs in this program. It would be thankful # if you can report it to us at cgifactory@cgi-factory.com. # However, that email address above is only for bugs reporting. # We will not respond to the messages that are sent to that # address. If you have any trouble installing this program. # Please feel free to post a message on our CGI Support Forum. # Selling this script is absolutely forbidden and illegal. ################################################################## # # COPYRIGHT NOTICE: # # Copyright 1999-2001 CGI-Factory.com TM # A subsidiary of SiliconSoup.com LLC # # # Web site: http://www.cgi-factory.com # E-Mail: cgifactory@cgi-factory.com # Released Date: Junuary 13, 2001 # # Message Board V4.5.1 is protected by the copyright # laws and international copyright treaties, as well as other # intellectual property laws and treaties. ################################################################### $fullpath="./"; push(@INC, $fullpath); ##don't change this variable unless you know what you are doing $bench="0"; ###You may need to change following variables to full system path if you are using windows servers $mcfg="mcfg.cgi"; $vcfg="vcfg.cgi"; # $start=(times)[0]; if ($ENV{'REQUEST_METHOD'} eq 'GET') { @pairs = split(/&/, $ENV{'QUERY_STRING'}); } else { 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; $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s/\n/\s/g; if ($name && $value) { $input{$name} = $value; } if ($value=~ tr/;<>*|`&$!#()[]{}:'"//) { print "Content-type: text/html\n\n"; &header; print "

Action canceled

\n"; print "Please don't use weird symbols\n"; &footer; exit; } } @months = ('January','February','March','April','May','June','July','August','September','October','November','December'); @days = ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'); eval { require "$mcfg"; require "$vcfg"; }; if ($@) { print "Content-type: text/html\n\n"; &error("Unable to load $mcfg and $vcfg. Please check out the readme file."); } #cookie if ($use_cookie eq "y" or $username_cookie) { @nvpairs=split(/; /, $ENV{'HTTP_COOKIE'}); foreach $pair (@nvpairs) { ($name, $value) = split(/=/, $pair); $cookie{$name} = $value; } } if ($cookie{'MBuser'}) { ($user_name, $user_email)=split(/\|/, $cookie{'MBuser'}); } # if ($use_cookie eq "y") { $time=time; $expires+=$time+2592000; local($sec,$min,$hour,$mday,$mon,$year,$wday) = gmtime($expires); $year+=1900; $expires="$days[$wday], $mday-$months[$mon]-$year $hour:$min:$sec GMT"; if (!$cookie{board1}) { print "Set-Cookie: board1=$time; path=/; expires= $expires;\n"; } else { print "Set-Cookie: board1=$time; path=/; expires= $expires;\n" if ($time-$cookie{board1}>=$reset_cookie); } } print "Content-type: text/html\n\n"; open (board, "<$bdata/board1.bd") or &error("unable to open board1.bd"); if ($flock eq "y") { flock board, 2; } @board=; close (board); chomp(@board[0]); chomp(@board[1]); chomp(@board[2]); chomp(@board[3]); chomp(@board[4]); $messages=@board[0]; $messages2=@board[1]; #starting to get the message array opendir (DIR, "$messages") or &error("Unable to open the dir for reading"); @reading=readdir(DIR); @reading=grep(/\.dat/, @reading); close (DIR); $total=0; COUNTING:foreach $read(@reading) { $read=~ s/\.dat//; open (content, "<$messages/$read.dat") or next COUNTING; @content=; close (content); $order[$total]="@content[2]x$read"; $total++; } @order=sort(@order); @order=reverse(@order); #start to create the message index page if ($input{'next'} and $input{'next'}<$total and $input{'next'}>=0) { @order=splice(@order, $input{'next'}); } else { $input{'next'}=0; } if (@board[4]==0) { $closed="[forum closed] "; } &header; print < EOF $num=0; print "
@board[2] $closed  
"; print "\n"; if ($num==$max) { print "
\n \n \n \n \n"; if ($total==0) { print ""; print "\n"; print "
  Subject: กระทู้ Replies: From: ผู้โพส Last Post: เวลาโพส 
  No messages were posted.---
\n"; &skip; } Opening:foreach $order (@order) { @xorder=split (/x/, "$order"); chomp(@xorder[1]); open (data, "<$messages/@xorder[1].dat") or next Opening; @data=; close (data); #time chomp(@data[2]); ($sec,$min,$hour,$mday,$mon,$year,$wday) = (localtime(@data[2]))[0,1,2,3,4,5,6]; $sec = sprintf("%.02d",$sec); $min = sprintf("%.02d",$min); $hour = sprintf("%.02d",$hour); $mday = sprintf("%.02d",$mday); $year += 1900; #date format if ($date_format==1) { $date = "$days[$wday], $months[$mon] $mday, $year at $hour:$min:$sec"; } elsif ($date_format==2) { $mon++; $date = "$mday/$mon/$year $hour:$min:$sec"; } else { $mon++; $date = "$mon/$mday/$year $hour:$min:$sec"; } # $num++; if (!@data[4]) { @data[4]=$default_icon; } $temp_color=$color1; $color1=$color2; $color2=$temp_color; print "
"; if ($use_cookie eq "y") { if (@data[2]>$cookie{board1}) { print "\"New"; } else { print " "; } } else { print " "; } @xorder[1]="@xorder[1]\-@data[5]" if (@data[5]>0); print " @data[0] @data[1] @data[3] $date
\n"; ©right; &links; if (@board[4]==1) { &post_box; } if ($bench==1) { $end=(times)[0]; print "
It took ", ($end - $start) , " second to complete this job (start: $start end $end)"; } &footer; exit; } } sub skip { print "\n"; ©right; &links; if (@board[4]==1) { &post_box; } if ($bench==1) { $end=(times)[0]; print "
It took ", ($end - $start) , " second to complete this job (start: $start end $end)"; } &footer; exit; } print "\n"; ©right; &links; if (@board[4]==1) { &post_box; } if ($bench==1) { $end=(times)[0]; print "
It took ", ($end - $start) , " second to complete this job (start: $start end $end)"; } &footer; exit; #post box sub post_box { print "


\n"; # Print the posting form ############################################## print qq| \n \n \n \n
\n \n \n
\n \n \n \n \n |; print qq|
\n \n Post a new message: ตั้งกระทู้ใหม่\n \n
\n
\n \n \n \n \n \n \n \n \n \n \n |; if ($username_cookie eq "y") { print qq| \n \n \n \n |; } if ($replymail eq "y") { print qq| \n \n \n \n |; } print qq| \n \n \n \n \n \n \n \n \n \n \n \n \n
\n \n Name: ชื่อ\n \n \n \n
\n \n Email: อีเมล์\n \n \n \n
\n \n \n บันทึกชื่อและอีเมล์\n \n
\n
\n
\n \n \n ส่งอีเมล์เตือนเมื่อมีผู้โพสตอบกระทู้:\n Yes  \n No\n \n
\n
\n
\n \n Subject: ชื่อเรื่อง \n \n \n
\n \n Message: ข้อความ\n \n \n \n \n
\n \n \n \n \n
|; } #####quick search sub copyright { print "
Message Board by yoyoo.com
"; } #####################links sub links { print ""; print " Pages: "; $link=int($total/$max); $link2=$total%$max; unless ($link2==0) { $link++; } $next=0; $count=1; for ($count; $count<=$link; $count++) { if ($input{'next'}==$next) { print "$count "; $next=$next+$max; } else { print "$count "; $next=$next+$max; } } print ""; } ######################header input sub header { $vheader_file="$fullpath/vheader.txt"; open (header, "<$vheader_file") or &error("Unable to open the vheader file"); @header=
; close(header); print @header; } ####################footer input sub footer { $vfooter_file="$fullpath/vfooter.txt"; open (footer, "<$vfooter_file") or &error("Unable to open the vfooter file"); @footer=