#!c:/perl/bin/perl -w ###################################################################### # Thanks for trying out NotePod! # # What is NotePod? It's a small notepad used for notes and memos. # # It's a cheap little script I threw together in an hour. # # Under what license is this? None! Do *whatever* you want with it! # # Modify it, throw it out, call it names, sell it, whatever. # # I will not be held responsable for lost data, etc, etc. # # Non-copyright 2002 by Nathan B. (you're not getting my last name!) # ###################################################################### use strict; my $version = "1.0"; $|++; # output buffering # Load modules use CGI::Carp qw(fatalsToBrowser); use CGI; use IO::Scalar; use Data::Dumper; use Fcntl ':flock'; # Declare variables use vars qw( $q %input %db $stdout $OUT $id ); # Get data input $q = new CGI; $input{$_} = $q->param($_) for $q->param(); # Load DB open LOCK, ">>lock.lck" or die "Could not open the lock file: $!\n"; flock LOCK, LOCK_EX or die "Could not flock the lock file: $!\n"; %db = (); do "db.dat"; # Print everything to a variable instead of STDOUT $OUT = new IO::Scalar \$stdout; select $OUT; # Branch off depending on action &main if !$input{'action'}; # Main Page &main("Changes Discarded.") if $input{'action'} eq "Cancel"; # Cancel Save &new_note if $input{'action'} eq "new"; # New Note &save_note if $input{'action'} eq "Save Note"; # Save Note &edit_note if $input{'action'} eq "edit"; # Edit Note &del if $input{'action'} eq "Delete Note"; # Delete Note &del(1) if $input{'action'} eq "delall"; # Delete All # Print HTTP/HTML Headers sub print_it { select STDOUT; # Print it all to STDOUT # Save DB $Data::Dumper::Purity = 1; $Data::Dumper::Indent = 0; open DATA, ">db.dat" or die "COuld not open database: $!\n"; flock DATA, LOCK_EX or die "Could not flock databse: $!\n"; print DATA Data::Dumper->Dump([\%db], ['*db']); close DATA; close LOCK; print qq|Content-type: text/html\n
| $_[1] |