We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Perl; For a mate, fast please
Topic Started: May 25 2005, 12:27 PM (547 Views)
JoeC
Euch! IE tastes horrible!
[ *  *  *  *  * ]
OK, my mate is trying to make his own watered down CMS, using Flash and then a script to edit text files. He just doesn't know scripting.

He found this example (he's modified it and the link points to his version), but it doesn't work. You will however note, that when you've edited it, and try to view your changes, it flickers to what you changed it to. Also, the Status box never says completed, even when it is.

Anyway, here are the current files:


UpdateVars.cgi
Code:
 
#!/usr/bin/perl

require "subparseform.lib";
&Parse_Form;

@New =  ("Title=$Title&Content=$Content");

$Title = $formdata{'Title'};
$Content = $formdata{'Content'};

@New =  ("Title=$Title&Content=$Content");

open (LOG, ">>http://www.davidturpy.com/perl/Ex2TextFile.txt") || &ErrorMessage;
print LOG "@New";
close (LOG);


print "Content-type: text/html\n\n";
print "Status=Success - Your Comments have beed updated. Please return to the main area to see the results";

sub ErrorMessage {
print "Content-type: text/html\n\n";
print "Status=Connection Failed Please Check the path to the text File";
exit;
}



subparseform.lib
Code:
 
sub Parse_Form {
if ($ENV{'REQUEST_METHOD'} eq 'GET') {
 @pairs = split(/&/, $ENV{'QUERY_STRING'});
} elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
 read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
 @pairs = split(/&/, $buffer);
 
 if ($ENV{'QUERY_STRING'}) {
  @getpairs =split(/&/, $ENV{'QUERY_STRING'});
  push(@pairs,@getpairs);
  }
} else {
 print "Content-type: text/html\n\n";
 print "<P>Use Post or Get";
}

foreach $pair (@pairs) {
 ($key, $value) = split (/=/, $pair);
 $key =~ tr/+/ /;
 $key =~ 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;

 $value =~s/<!--(.|\n)*-->//g;

 if ($formdata{$key}) {
  $formdata{$key} .= ", $value";
 } else {
  $formdata{$key} = $value;
 }
}
}
1;




Ex2TextFile.txt (the file it changes)
Code:
 
Title=This is the Title&Content=This is body content, both should be editable!!



And then there's minimal scripting in Flash, which just says that the variable "Title" is the title text and the variable "Content".

Any ideas at all are very useful, and fast replies are best :P If you need any more info, just let me know :)
Offline Profile Quote Post Goto Top
 
JoeC
Euch! IE tastes horrible!
[ *  *  *  *  * ]
Bump please? Still need help. Just because it says fast doesn't mean I don't appreciate an answer a couple of days later =)
Offline Profile Quote Post Goto Top
 
JoeC
Euch! IE tastes horrible!
[ *  *  *  *  * ]
Well...5 days later still might be reasonable...anyone?
Offline Profile Quote Post Goto Top
 
shockwave-
My other title is a Ferrari
[ *  * ]
I don't think many people here know Perl :)
Offline Profile Quote Post Goto Top
 
Seth
Member Avatar
I has a pony
[ *  *  *  *  *  *  *  *  * ]
And for good reason :D Perl is dead.
Offline Profile Quote Post Goto Top
 
JoeC
Euch! IE tastes horrible!
[ *  *  *  *  * ]
Lol. There's always someone knows something that's totally useless :P I just hope there's several of them on IF.
Offline Profile Quote Post Goto Top
 
Player1-ZNS
Member Avatar
The Ultimate Player
[ *  * ]
perl is hard that is why! Try www.htmlgoodies.com
Offline Profile Quote Post Goto Top
 
Stefan
Member Avatar
Mew?
[ *  *  *  *  *  *  * ]
Joezif
May 30, 2005 09:41 PM
Lol. There's always someone knows something that's totally useless :P I just hope there's several of them on IF.

If you ever plan to do some programming for the Commodore 64 in C64 BASIC V2 and need help, just ask ^_^
Offline Profile Quote Post Goto Top
 
JoeC
Euch! IE tastes horrible!
[ *  *  *  *  * ]
Thanks, I'll bear that in mind - I'm sure I'll get a request for a highly complex piece of programming for that any day now, watch your PM inbox :P
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Technology Chat · Next Topic »
Add Reply