Here's the source for admin_news.cgi. The more I thought about it, the more I realized you people probably need this source to fully understand what the other script does. Also, I keep getting an error in my log that says: edit_article.cgi: Use of uninitialized value at (eval 11) line 17. OR it says something like: admin_news.cgi: Use of uninitialized value at (eval 12) line 17. or something of that nature. The script runs, but it gives me errors like that in my error_log. Anyway, here's admin_news.cgi:
#!/usr/bin/perl -wT # admin_news.cgi use strict; use lib "..."; /* like in edit_news.cgi, I'm not giving this to you */ use CGI; use Ntdw10Error; use Fcntl qw/ :flock /; my $NEWS_DIR = "$ENV{DOCUMENT_ROOT}/news"; my $q = new CGI; if ( $q->param() ) { my @params = $q->param(); my $first = shift @params; if ( $first =~ /^(\d+)$/ ) { $q->param( $first ) =~ /^edit$/i and do { print $q->redirect( "/admin/edit_article.cgi?story=".$first ); }; $q->param( $first ) =~ /^delete$/i and do { delete_story( $first ); }; } else { print $q->redirect( "/admin/edit_article.cgi" ); } } print $q->header( "text/html" ), $q->start_html( { -title => "News Administration", -style => { -src => "/admin.css" }, -script => { -src => "/ntdw10.js" } } ), $q->start_form, $q->h2( "News Administration" ), $q->p( "Here you can edit and delete existing stories as well as create new stories." ), $q->hr; over_tab(); print $q->submit( -name => "new", -value => "Create New Story" ), $q->hr, $q->p( "Go to the " . $q->a( { -href => "/index.html" }, "NTDW10 Homepage" . "." ) ), $q->hr, $q->script( "page_copyright();" ), $q->end_html; sub over_tab { local ( *DIR, *STORY ); my ($headline, $date); print '<TABLE BORDER=1>'; opendir DIR, $NEWS_DIR or error( $q, "Cannot open $NEWS_DIR: $!" ); my @filename = reverse( sort( grep !/^\./, readdir DIR ) ); for ( my $i = 0 ; $i < @filename ; $i++ ) { open STORY, "$NEWS_DIR/$filename[$i]" or error( $q, "Cannot open $filename[$i]: $!" ); flock STORY, LOCK_SH; $headline = <STORY>; chomp $headline; $date = get_date( $filename[$i] ); close STORY; print $q->Tr( $q->td( $q->submit( -name => "$filename[$i]", -value => "Edit" ), $q->submit( -name => "$filename[$i]", -value => "Delete", -onClick => "return confirm('Are you sure you want to delete this?')" ) ), $q->td( $q->p( "$headline | $date" ) ), ); } print '</TABLE>'; closedir DIR; } sub get_date { my $filename = shift; (my $date = localtime $filename ) =~ s/ +\d+:\d+:\d+/,/; return $date; } sub delete_story { my $story = shift; my( $st ) = $story =~ /^(\d+)$/ or die "Illegal filename: '$story'"; my( $file ) = "$NEWS_DIR/$st" =~ /^(.+)$/; unlink $file or die "Cannot remove story $file: $!"; } __________________________________________________ Do You Yahoo!? Make a great connection at Yahoo! Personals. http://personals.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]