Jump to content

What the best way to covert to autoit


 Share

Recommended Posts

Hi all, what wood the et way to convert ths code to autoit code Thanks Beau

#!/usr/bin/perl
#
#
# usage:  gen-PHP-tagslist.pl <taglist.txt>
#
use Getopt::Std;
use File::Basename;

use vars qw/ $opt_d $opt_h $opt_v $opt_u/;
my $PROGRAM = "gen-PHP-tagslist.pl";
my $version="$PROGRAM - Version 1.00 - 07-Apr-2006";

my $usage = "$PROGRAM [-d] [-h] [-v] <tagslist>.txt

 where:
   -h = help (this message)
   -v = version
   -d = debug
   <taglist.txt>   This is the tagslist.txt file from weather-link 
                    
 Purpose:

Convert the tagslist.txt file into a silent PHP page so all the variables
are named as in Weather-Display and can be used in a page (when processed
by Weather-Display upload)

 Outputs:
   tagslist.php - Converted file in PHP format

";

getopts('dvh');

die "$version\n" if $opt_v;

my $debug = 0;
$debug = 1 if $opt_d;

my $infile = $ARGV[0];

die "$version\n\n$usage\n" if $opt_h or !$infile;


open (INFILE,"<$infile") or die "Unable to open $infile: $!\n";

my $inrec = '';
my @f = ();
my ($fname,$path,$fext) = fileparse($infile,".txt");

my $outfile = $path . $fname . ".php";

print STDOUT <<GREET;
$version
Input:  $infile
Output: $outfile

GREET
;

open (OUTFILE,">$outfile") or die "Unable to open $outfile: $!\n";


print OUTFILE <<EOHdr;
<?php
// converted $infile to $outfile for php tags
// by $version
// Author: Ken True - webmaster@saratoga-weather.org
//
// --------------------------------------------------------------------------
// allow viewing of generated source

if ( \$_REQUEST['sce'] == 'view' ) {
   download('view');
   exit;
}
EOHdr
;
my $recsin = 0;
my $fixedup = 0;

while (<INFILE>) {
  $inrec = $_;
  chomp($inrec);
  $recsin++;
  if ($inrec =~ m|^(\%\S+\%)|) {
    $tag = $1;
    $inrec =~ s|$tag\s*[\.]+||;  # remove the tag and leading dots
    $tagname = $tag;
    $tagname =~ s|\%||g;      # remove the % markers;
    $tagname =~ s|\-|_|g;    # replace - with _
    $tagname =~ s|\<|LT|g;  # replace < with LT
    $tagname =~ s|\>|GT|g;  # replace > with GT
    $tagname =~ s|\=||g;      # remove =
    $tagname =~ s|/|_|g;      # replace / with _
    $tagname =~ s|\,|CM|g;    # replace , with CM

    print OUTFILE "\$$tagname = \"$tag\";\t// $inrec\n";
    $fixedup++;
  } else {
    print OUTFILE "// $inrec\n";
  }


 }

print OUTFILE <<FINIS;

// end of generation script

//--self downloader --
 function download ( \$mode ) {
   \$filenameReal = \$_SERVER["PATH_TRANSLATED"];
   \$filenameLcl = substr(\$PHP_SELF,1);
   \$download_size = filesize(\$filenameReal);
   header('Pragma: public');
   header('Cache-Control: private');
   header('Cache-Control: no-cache, must-revalidate');
   if (\$mode == 'download' ) {
     header("Content-type: application/x-download");
     header("Content-Disposition: attachment; filename=\$filenameLcl;");
   } else {
     header("Content-type: text/plain");
   }
   header("Accept-Ranges: bytes");
   header("Content-Length: \$download_size");
   header('Connection: close');
   
   readfile(\$filenameReal);

 }

?>
FINIS
;

print STDERR <<EOR;

..Done.
$recsin weather tag records processed.
$fixedup weather PHP tags generated.
EOR
;
close (OUTFILE);
close (INFILE);
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...