I know I should have used strict and warnings. Sorry!
Also a very very simple and unsafe security by fixed ip-numbercheck, probably not really safe so I suggest you build a better security option yourself ;)
#!/usr/bin/perl # # flashupdate.pl # by teabag <tony@lvp-site.nl> last rev. 09/04/03 # This Perl script create Flash variables and write them # to an text file, which you can load into your flash site. ################################################################# # Instructions # 1. Define the 3 variables # 2. Upload update.pl script to your /cgi-bin or (cgi)folder # using ASCII mode and CHMOD 755 # 3. Upload an empty (.txt) file named to the path (../data)you speci +fy # in $full_path # 4. Run and RESET/DELETE the script by calling it from an HTML form +of from a # Flash-generated form (using Get URL, with option Variables: Send + using POST) ################################################################# # Define these variables! # relative path form script to dir where datafile is located # no trailing slash! # added just a simple fixed ip-numbercheck $myipnumber = "123.45.67.890"; $full_path = "/htdocs/data"; $data_file = "update.txt"; checkip(); @days = ('Sunday','Monday','Tuesday','Wednesday', 'Thursday','Friday','Saturday'); @months = ('january','february','march','april','may','june','july +', 'august','september','october','november','december'); + ($sec,$min,$hour,$mday,$mon,$year,$wday) = (localtime(time))[0,1,2,3,4,5,6]; $time = sprintf("%02d:%02d:%02d",$hour,$min,$sec); $year += 1900; $date_for_logfile = "$mday $months[$mon] $year, $time"; 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/~!/ ~!/g; $value =~ s/\+/ /g; $value =~ s/<([^>])*>//g; $value =~ s/(\r)+/\-\-/g; $value =~ s/\n+//g; $value=~s/\<SCRIPT//gi; $value=~s/\<\/SCRIPT\>//gi; $value=~s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; #substitute flash special characters $value =~ s/\%/%25/g; # filters and fixes '%' $value =~ s/\+/%2b/g; # filters and fixes '+' $value =~ s/\=/%3D/g; # filters and fixes '=' $value =~ s/\&/%26/g; # filters and fixes '&' $value =~ s/\$/%24/g; # filters and fixes '$' $value =~ s/\{/%7B/g; # filters and fixes '{' $value =~ s/\}/%7D/g; # filters and fixes '}' # this line below strips linebreaks, delete comment tag if you get pro +blems # with the layout! The linebreaks will then work properly, in the layo +ut # $value =~ s/\n/ /g; #filters and deletes the lin +ebreaks $FORM{$name} = $value; push (@formdata,$name); push (@formdata,$value); } %formdata=@formdata; %formdata; foreach $key (keys(%formdata)){ push (@fieldnames,$key); } open (RESULTS,">$full_path/$data_file") || die "Couldn't open file +: $!\n"; foreach $fieldname (@fieldnames) { print RESULTS "$fieldname=$formdata{$fieldname}&" } print RESULTS "updated=$date_for_logfile"; close (RESULTS); # Print Results to your browser print "Content-type:text/html\n\n"; print <<flash_vars_top; <html> <head> <title>Results</title> </head> <body> <center> <b>Your Flash variables created $date_for_logfile :</b><br> flash_vars_top # for each variable name (field name in your form), # print its name & value pair to the web page foreach $fieldname (@fieldnames) { print "<b>$fieldname</b> - $formdata{$fieldname}<br>\n"; } print "</center>\n</body>\n</html>\n"; exit; sub checkip{ if ($ENV{REMOTE_ADDR} eq $myipnumber){ } else { print "Content-type: text/html\n\n"; print "<html><head><title>Error!</title></head><body bgcolor=white><p> +</p><p><center> <font face=\"Verdana, Arial\" color=red size=\"3\"><b>Invalid ip-numbe +r</b> </font></center></p></body></html>"; exit; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: Quick 'n very dirty flash-variables updatescript
by merlyn (Sage) on Apr 09, 2003 at 15:19 UTC | |
by Coruscate (Sexton) on Apr 09, 2003 at 21:55 UTC | |
by merlyn (Sage) on Apr 09, 2003 at 23:04 UTC | |
by teabag (Pilgrim) on Apr 10, 2003 at 15:18 UTC | |
|
(jeffa) Re: Quick 'n very dirty flash-variables updatescript
by jeffa (Bishop) on Apr 09, 2003 at 16:21 UTC | |
|
Quick 'n cleaner flash-variables updatescript
by Ovid (Cardinal) on Apr 09, 2003 at 23:36 UTC | |
|
Re: Quick 'n very dirty flash-variables updatescript
by teabag (Pilgrim) on Apr 10, 2003 at 15:30 UTC |