Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- #### var
- use IO::File;
- $|=1;
- STDOUT->autoflush(1);
- $debug=1; ## recommended:0
- $bypassallrules=0; ## recommended:0
- $sucks=""; ## unused
- $sucks="sucks" if ($debug>=1);
- $timenow="";
- $printtimenow=1; ## print timenow: 0|1
- my $logfile = '/tmp/urlrewrite.log';
- open my $logfh, '>>', $logfile
- or die "Couldn't open $logfile for appending: $!\n" if $debug;
- $logfh->autoflush(1) if $debug;
- while () {
- $timenow=time()." " if ($printtimenow);
- #print $logfh "$timenow"."in : $_" if ($debug>=1);
- #print $logfh "in : $_" if ($debug>=1);
- chop; ## strip eol
- my $urlku = $_;
- #@X = split;
- @X = split(" ",$urlku);
- $a = $X[0]; ## chanel
- $b = $X[1]; ## url
- $c = $X[2]; ## ip
- $u = $b; ## url
- print $logfh "in : $_\n" if ($debug>=1);
- if ($bypassallrules){
- $out="$u"; ## map 1:1
- #utmgif
- } elsif ($u=~ m/^https?\:\/\/.*youtube\.com\/watch\?.*/) {
- $out="OK rewrite-url=$u&html5=1";
- } else {
- $out="ERR";
- }
- print $logfh "out: $a $out\n" if ($debug>=1);
- print "$a $out\n";
- }
- close $logfh if ($debug);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement