#!/usr/local/bin/perl ############################## #Post article of information # # by Matthew Manela # ############################## require 'subparseform.lib'; # sub parsing $basedir = "/data1/blah.net/blah/"; $baseurl = "http://blah.blah.net"; &Parse_Form; print "Content-type: text/html\n\n"; $tpass=$formdata{password}; $article=$formdata{text}; $destination=$formdata{destination}; #the source of the file to write to @info=split(/\n/,$article); # set $file to location of txt file $file="$basedir$destination\.txt"; # make sure destination is within parameters if($destination=~/^([a-zA-Z])+$/){ &main; }else{ &filename; } sub main{ if(-e $file){ open(WRITE, ">$file")|| &filename; foreach $line (@info){ print WRITE "$line\n"; } close(WRITE); }else{ &filename; } sub filename{ print"You can't write to that file!\n"; exit; }
#!/usr/local/bin/perl # Get article form link and display # by Matthew Manela require 'subparseform.lib'; # sub parsing $basedir = "/data1/blah.net/blahs/"; $baseurl = "http://blah.blah.net"; &Parse_Form; print "Content-type: text/html\n\n"; $article=$formdata{'article'}; $page=$formdata{'page'}; $maxlength=43; $next=$page+1; $previous=$page-1; $start=($page-1)*$maxlength; $finish=$page*$maxlength; &main; sub main{ $file="$basedir$article\.txt"; open(TOP, "$basedir/top\.htm")|| &filename; @top=<TOP>; close(TOP); open(BOTTOM, "$basedir/bottom\.htm")|| &filename; @bottom=<BOTTOM>; close(BOTTOM); open(READ, "$file")|| &filename; my @info = grep { !/^\s*$/ } <READ>; chomp(@info); close(READ); $length=@info; foreach $part (@top) { if ($part=~/^<\/head>$/){ print"<base href=\"http://blah.blah.net\"></head>\n"; }else{ print"$part\n"; } } for($i=$start;$i<$finish;$i++){ if ($info[$i]=~ m/<!--\#include/) { }else{ print"$info[$i]\n"; } } if (($length>$finish)&&($page>1)){ print"<p align=left>  <font color=yellow><--</font> <a hre +f=\"http://blah.blah.net/cgi-bin/article.cgi?article=$article&page=$p +revious\">Go to the previous page</a><a href=\"http://blah.blah.net/c +gi-bin/article.cgi?article=$article&page=$next\">Continue to the next page</a> <font color=yellow>--></font> &nb +sp</p>\n"; }elsif(($length>$finish)&&($page==1)){ print"<p align=right><a href=\"http://blah.blah.net/cgi-bin/article.cg +i?article=$article&page=$next\">Continue to the next page</a> <fo +nt color=yellow>--></font>  </p>\n"; } foreach $thing (@bottom){ print"$thing\n"; } } sub filename{ print"<html><head><title>Article does not exist</title></head><body>\n +"; print"Sorry, That article does not exist.<br>\n"; print"</body></html>"; exit; }
In reply to Re: Re: Posting Program
by Jemts
in thread Posting Program
by Jemts
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |