The script is one i am modifying.. it's called weblibs... there are 4 files total... weblibs.pl, input.txt, and the 2 files you can swap back and forth for testing.. goodfile and badfile. Create these 4 files and put them in cgi directory.

weblibs.pl
#!/usr/bin/perl ############################################ ## ## ## WebLibs ## ## by Darryl Burgdorf ## ## (e-mail burgdorf@awsd.com) ## ## ## ## last modified: 6/7/97 ## ## copyright (c) 1997 ## ## ## ## latest version is available from ## ## http://awsd.com/scripts/ ## ## ## ############################################ # COPYRIGHT NOTICE: # # Copyright 1997 Darryl C. Burgdorf. All Rights Reserved. # # This program may be used and modified free of charge by anyone, so # long as this copyright notice and the header above remain intact. B +y # using this program you agree to indemnify Darryl C. Burgdorf from an +y # liability. # # Selling the code for this program without prior written consent is # expressly forbidden. Obtain permission before redistributing this # program over the Internet or in any other medium. In all cases # copyright and header must remain intact. # VERSION HISTORY: # # 1.00 06/07/97 Initial "public" release $InputFile = "input.txt"; $TextFile = "goodfile.txt"; $CGIURL = "weblibs.pl"; print "Content-type: text/html\n\n"; read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs){ ($name, $value) = split(/=/, $pair); $name =~ tr/+/ /; $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; if ($FORM{$name}) { $FORM{$name} = "$FORM{$name}, $value"; } else { $FORM{$name} = $value; push (@variables,$name); } } if ($FORM{'TextFile'}) { &SendFile; } if (-d $TextFile) { opendir(FILES,$TextFile); @tempfiles = readdir(FILES); closedir(FILES); foreach $file (@tempfiles) { if (-T "$TextFile/$file") { push (@files, $file); } } srand(); $files = @files; $file = @files[int(rand($files))]; $TextFile = $TextFile."/".$file; } open (FILE,"$TextFile"); @LINES = <FILE>; close (FILE); $text = join(' ',@LINES); $text =~ s/\n/ /g; $text =~ s/</\n</g; $text =~ s/>/>\n/g; @text = split('\n',$text); undef (@variables); foreach $line (@text) { if ($line =~ s/<!--(.*)-->/$1/) { push (@variables,$line); } } @sortedvariables = sort (@variables); open (FILE,"$InputFile"); @LINES = <FILE>; close (FILE); foreach $line (@LINES) { if ($line =~ /<!--InputWords-->/i) { print "<FORM METHOD=POST ACTION=\"$CGIURL\">\n"; print "<INPUT TYPE=HIDDEN NAME=TextFile "; print "VALUE=\"$TextFile\">\n"; print "<P><CENTER><TABLE>\n"; foreach $variable (@sortedvariables) { next if ($variable eq $lastvariable); print "<TR><TD ALIGN=RIGHT><P>$variable: </TD>"; print "<TD><INPUT TYPE=TEXT NAME=\"$variable\" SIZE=25>"; print "</TD></TR>\n"; $lastvariable = $variable; } print "</TABLE></P>\n"; print "<P><INPUT TYPE=SUBMIT VALUE=\"See the Results!\">\n"; print "</CENTER></P></FORM>\n"; } else { print $line; } } exit; sub SendFile { open (FILE,"$FORM{'TextFile'}"); @LINES = <FILE>; close (FILE); $text = join(' ',@LINES); $text =~ s/\n/ /g; foreach $variable (@variables) { if ($FORM{$variable} eq "") { print "incomplete!\n"; exit; } $text =~ s/<!--$variable-->/<STRONG>$FORM{$variable}<\/STRONG> +/g; } $text =~ s/A\/an <STRONG>(a|e|i|o|u)/An <STRONG>$1/g; $text =~ s/a\/an <STRONG>(a|e|i|o|u)/an <STRONG>$1/g; $text =~ s/A\/an/A/g; $text =~ s/a\/an/a/g; print $text; exit; }
The only configuration you have to do in the weblibs.pl file is on the $Textfile variable... swapping goodfile and badfile... which are listed here...

Goodfile:
<html> <body> These are the words you input: <!--input words--> </BODY> </HTML>

Badfile:
<html> <head> <script language="JavaScript"> <!-- function load(){ document.write("<img src='image.jpg' width='1' height='1'>"); window.location="<!--input variable-->";}//--> </script> </head> <body onload=load()> <img src="http://yoursite/dir1/image.jpg" width="1" height="1"><br> </BODY> </HTML>
The last file is input.txt...
<HTML> <HEAD><TITLE>The WebScripts &quot;Mad&quot; WebLibs Game</TITLE></HEAD +> <BODY BGCOLOR="#ffffff" TEXT="#0000cc" LINK="#000000" ALINK="#666666" +VLINK="#666666" BACKGROUND="http://awsd.com/scripts/graphics/backgrou +nd.gif"> <P ALIGN=CENTER><STRONG>INPUT YOUR WORD CHOICES:</STRONG></P> <!--InputWords--> <BLOCKQUOTE><P><SMALL>All stories are adapted from <EM>Mad Libs #2 (So +n of Mad Libs)</EM>, copyright 1959, 1976, 1982 by Price/Stern/Sloan +Publishers, Inc., Los Angeles CA 90048.</SMALL></P></BLOCKQUOTE> </BLOCKQUOTE> </FONT> </BODY> </HTML>
Goodfile prints out fine.. but badfile get's an error. I suspect it's the javascript delimiters in badfile.. since weblibs.pl uses the same delimiters. Not sure if pattern matching can help. I didn't list the script at first cause i didn't think anyone would want to go through all this hassle. -Lisa

In reply to Re: Re: Re: Re: Re: Re: File glitch by wolverina
in thread File glitch by wolverina

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.