$path = "$ENV{'PATH_TRANSLATED'}"; $path =~ s/submit-bbs-form.cgi//; $configFile = "config"; $configPath = $path.$configFile; require $configPath; $PARENT=1; sub lock{ if ($flock_exists == 1){ local ($file_handle); foreach $file_handle (@_){ flock($file_handle, 2); } } } sub unlock{ if ($flock_exists == 1){ local ($file_handle); foreach $file_handle (@_){ flock($file_handle, 8); } } } sub createInd{ open(original,"$STORAGE_DIR:bbs-data.original") || die "can't open $STORAGE_DIR:bbs-data.original "; open(ind,">> $STORAGE_DIR:bbs-data.html") || die "can't open $STORAGE_DIR:bbs-data.html "; &lock(ind); select(ind); while(){ print; } &unlock(ind); close(original); close(ind); chmod 0606, <$STORAGE_DIR:bbs-data.html>; open(original,"$STORAGE_DIR:zero.counter") || die "can't open $STORAGE_DIR:zero.counter "; open(ind,">> $STORAGE_DIR:counter") || die "can't open $STORAGE_DIR:counter "; &lock(ind); select(ind); while(){ print; } &unlock(ind); close(original); close(ind); chmod 0606, <$STORAGE_DIR:counter>; open(original,"$STORAGE_DIR:zero.counter") || die "can't open bbs-data.original "; open(ind,">> $STORAGE_DIR:thread_counter") || die "can't open bbs-data.original "; &lock(ind); select(ind); while(){ print; } &unlock(ind); close(original); close(ind); chmod 0606, <$STORAGE_DIR:thread_counter>; } sub getToken{ createInd unless (-e "$STORAGE_DIR:bbs-data.html"); if ($ENV{'QUERY_STRING'} != ''){ $PARENT=0; return ($ENV{'QUERY_STRING'}); } open(TOKEN,"$THREAD_TOKEN") || die "can't open $STORAGE_DIR:$file_handle.html\n"; &lock(TOKEN); while () { $tokenReturn = "$_"; chop($tokenReturn); } &unlock(TOKEN); close(TOKEN); open(TOKEN,"> $THREAD_TOKEN") || die "can't open $STORAGE_DIR:$file_handle.html\n"; &lock(TOKEN); $tokenNext = $tokenReturn + 1; select(TOKEN); print <<"DONE"; $tokenNext DONE &unlock(TOKEN); close(TOKEN); select(STDOUT); return $tokenReturn; } select(STDOUT); print "Content-type: text/html\n\n"; print <<"END"; bbs submit END $printme = getToken(); if ($PARENT == 0){ print "Reply to Message: $printme"; } else { print "New Message: $printme"; } print<<"END";
END print ""; print ""; print <<"END";

Name

E-mail

Subject

END