Admin that writes to a text file

Sharky Forums


Results 1 to 5 of 5

Thread: Admin that writes to a text file

  1. #1
    Goldfish
    Join Date
    Jun 2001
    Location
    Austin, Texas, US
    Posts
    54

    Post Admin that writes to a text file

    I'm looking for a CGI script that creates an Admin section where you can basically write a blurb and click submit and have it write over a .txt file. Simple right? why can't I find one?

    Thanks!

    ------------------
    "That's Right, I Said It,"
    "That's Right, I Said It,"

  2. #2
    Hammerhead Shark
    Join Date
    Oct 2000
    Location
    Toronto, Canada
    Posts
    1,493

    Post

    I just wrote one for you, am i nice?

    Code:
    #!/usr/bin/perl
    print "Content-type: text/html\n\n";
    
    $filename = "player.txt";
    
    # Get the input
    read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
    @pairs = split(/&/, $buffer);	# Split the name-value pairs
    
    
    open (FILE, ">>$filename");
    foreach $pair (@pairs) {
       ($name, $value) = split(/=/, $pair);
    
       # Un-Webify plus signs and %-encoding
       $value =~ tr/+/ /;
       $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
       $value =~ s/<!--(.|\n)*-->//g;
       $value =~ s/<([^>]|\n)*>//g;
       
       if ($value eq "Submit") { last; } else {
       	print FILE "$value#";
       }
    }
    print FILE "\n";
    close (FILE);
    Basically, it parse thru the whole form and write all the fields in the file, seperated by a # sign.

    ------------------
    DHAHL3seasons GP:73 G:121 A:55 Pts:176 GWG:12 +/-:184
    UWSWA1season GP:9 G:12 A:8 Pts:20 GWG:3 +/-:-3

    uwcdc.com or namgor.com
    DHAHL3seasons GP:73 G:121 A:55 Pts:176 GWG:12 +/-:184
    UWSWA6seasons GP:41 G:53 A:46 Pts:99 GWG:5 +/-:-25
    MCBHL3seasons GP:14 G:20 A:8 Pts:28 GWG:4 +/-:19

    uwcdc.com or monkis.com

  3. #3
    Goldfish
    Join Date
    Jun 2001
    Location
    Austin, Texas, US
    Posts
    54

    Talking

    Very nice, where do I send the shareware fee to?



    ------------------
    "That's Right, I Said It,"
    "That's Right, I Said It,"

  4. #4
    Goldfish
    Join Date
    Jun 2001
    Location
    Austin, Texas, US
    Posts
    54

    Post

    OK Sorry, I'm not trying to be difficult, How can I clear the .txt file from the same form page as the one that submits the text?

    ------------------
    "That's Right, I Said It,"
    "That's Right, I Said It,"

  5. #5
    Hammerhead Shark
    Join Date
    Oct 2000
    Location
    Toronto, Canada
    Posts
    1,493

    Post

    You want to clear the text file? Then upload a blank file

    Otherwise you need more codes... so are you sending me the shareware fees? (j/k)

    ------------------
    DHAHL3seasons GP:73 G:121 A:55 Pts:176 GWG:12 +/-:184
    UWSWA1season GP:9 G:12 A:8 Pts:20 GWG:3 +/-:-3

    uwcdc.com or namgor.com
    DHAHL3seasons GP:73 G:121 A:55 Pts:176 GWG:12 +/-:184
    UWSWA6seasons GP:41 G:53 A:46 Pts:99 GWG:5 +/-:-25
    MCBHL3seasons GP:14 G:20 A:8 Pts:28 GWG:4 +/-:19

    uwcdc.com or monkis.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •