#!/usr/bin/perl ## PARSE HTML FORM DATA INTO ASSOCIATIVE ARRAY @in require "/home/shroom/public_html/cgi-lib.pl"; &ReadParse; ## FILE NAME OF DB FILE (MIGHT HAVE TO chmod ugo+w) $DB_FILE = "ll.db"; $TIME = time; ## SNARF THE TIME $TYPE = $in{type}; $SUBMIT = $in{'submit'}; if ($SUBMIT eq "post") { $LINK = $in{link}; $DESC = $in{desc}; $ORIGINAL = `cat $DB_FILE`; open (FD, "> $DB_FILE"); flock (FD, LOCK_EX); print FD qq[$LINK\t$TIME\t$ENV{REMOTE_ADDR}\t$TYPE\t$DESC\n$ORIGINAL]; flock (FD, LOCK_UN); close (FD); ## MAKE SURE WE RE-RENDER THE HTML FILES $SUBMIT = "render"; } if ($SUBMIT eq "edit") { open (F, $DB_FILE); print qq {Content-type: text/html\n\n}; print qq[
]; close (F); exit (0); } if ($SUBMIT eq "mutate") { open (FD, "> $DB_FILE"); flock (FD, LOCK_EX); print FD $in{db}; flock (FD, LOCK_UN); close (FD); $SUBMIT = "render"; } if ($SUBMIT eq "render") { ## OPEN FILE DESCRIPTOR AND FILES FOR EACH LEETLINK TYPE open (FPT, "types.db"); while (\n]; ## DUMP TO RESPECTIVE TYPE LIST $desc =~ s/ .*//; $_ = "FP" . $type; print $_ qq{$desc\n}; } flock (FH, LOCK_UN); close (FH); close (FD); print qq{Location: http://shroom.dv8.org/ll/\n\n}; exit 0; } sub Time2Date { my ($TIME) = @_; if ($TIME =~ /[^0-9]/) { $TIME; } else { ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($TIME); sprintf("%s %d, %d %d:%s%d%s", (('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec')[$mon]), $mday, $year+1900, 1+(($hour-1)%12), $min>9?'':'0', $min, ( $hour>11)?"pm":"am"); } } # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # HTML HEADER STUFF HERE # print qq{Content-type: text/html
| original board home |