This crude Perl script creates (Macromedia) Flash-style variables and writes them to an text file, which you can load into your flash site.
It allows you to make textupdates and save the updated text from within your flash webpage.

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; } }

In reply to Quick 'n very dirty flash-variables updatescript by teabag

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.