#!/usr/local/bin/perl -w use strict; use CGI; my $basedir = "/data1/blah.net/blah/"; my $baseurl = "http://blah.blah.net"; my $q=CGI::new(); my $tpass = $q->param('password'); my $article = $q->param('text'); my $destination = $q->param('destination'); # set $file to location of txt file my $file="$basedir$destination\.txt"; # strip out all possible SSI calls here, not below (ie, remove all comments) $article =~ s///gis; # make sure destination is within parameters (allow underscores as well if ($destination !~ /^\w+$/){ &filename; } # ?? only overwrite existing file? If so use -T instead # if(-e $file) if(-T $file) { open(WRITE, ">$file") || &filename; print WRITE "$line\n"; close(WRITE); } else { &filename; } sub filename{ print $q->header, $q->start_html, $q->h4("Error: You can't write to that file!"), $q->end_html; exit(0); } ####################################################################### #!/usr/local/bin/perl-w use strict; use CGI; my $q = CGI::new(); my $basedir = "/data1/blah.net/blahs/"; my $baseurl = "http://blah.blah.net"; my $article = $q->param('article'); my $page = $q->param('page'); my $maxlength = 43; my $next = $page+1; my $previous = $page-1; my $start = ($page-1)*$maxlength; my $finish = $page*$maxlength; my $file="$basedir$article\.txt"; open(TOP, "$basedir/top\.htm")|| &filename; my $top= join '',(); close(TOP); open(BOTTOM, "$basedir/bottom\.htm")|| &filename; my $bottom = join '', (); close(BOTTOM); open(READ, "$file")|| &filename; my @info = (); close(READ); $length=@info; $top =~ s|||is; print $q->header, $top; print $q->header, $q->start_html, $info[$start..$finish]; # note, this -> $info[$start..$finish]; may not work - it's late and seemed like a good idea :) if ( ($length>$finish) && ($page>1) ) { print $q->p("  ", $q->font({-color=>'yellow'}, '<-- ' ), $q->a({-href => "http://blah.blah.net/cgi-bin/article.cgi?article=$article&page=$previous"}, 'Go to the previous page' ), $q->a({-href => "http://blah.blah.net/cgi-bin/article.cgi?article=$article&page=$next"}, 'Continue to the next page' ), $q->font({-color=>'yellow'}, ' -->' ) ); } elsif ( ($length>$finish) && ($page==1) ) { print $q->p({-align => 'right'}, $q->a({-href => "http://blah.blah.net/cgi-bin/article.cgi?article=$article&page=$next"}, 'Continue to the next page' ), $q->font({-color=>'yellow'}, ' -->' ) ); } print $bottom, $q->end_html; exit(0); sub filename{ print $q->header, $q->start_html( -title => 'Article does not exist'), $q->p('Sorry, That article does not exist), $q->end_html; exit(0); } #### $article =~ s/\s+/ /gs; $article =~ s|([^\n]\b{0,100})|$1
|gs;