#!/usr/bin/perl -w # odeon.cgi # Open Source Odeon courtesy of Bwch'r Bant Productions. # A front-end to Odeon Cinemas' film information (www.odeon.co.uk) without # the nasty browser-specific stuff of the original site. # This is a slightly modified v0.1.1 (film names now sentence-case). # No rights reserved. Install it where you like. Change anything. Copy freely. # You'll need the LWP module, which should be installed on most competent hosts. # (Yes, this is a Perl script, for those who haven't twigged yet.) # You can currently download this script from www.geocities.com/opensourceodeon/ # Kudos to Matthew Somerville for the original idea. Matthew has no responsibility # for this script. # You can call it with: # ?cmd=N - now showing # ?cmd=C - coming soon # ?cmd=F&film=filmname - film details # ?cmd=R - list regions # ?cmd=R®ion=regionname - list cinemas in that region # ?cmd=A&cinema=cinemaname - what's on at that cinema # # and you can even supply a stylesheet URL in the css parameter. # =================================== # Main code starts here # =================================== # ----- Initialisation use LWP::Simple; Parse_Form(); $cmd=lc($formdata{'cmd'}); $"=', '; # ----- HTTP header and top of page print "Content-type: text/html\n\n
"; if (exists $formdata{'css'}) { print '\n"; $suffix="&css=".$formdata{'css'}; } else { $suffix = ''; } print <Open Source Odeon: Now showing | Coming soon | Find a cinema
Running time $var{'runtime'} minutes
"; print "Director $var{'director'}
"; @stars=ParseCSV($var{'keyCast'}); if (@stars) { print "Starring: @stars
"; } if ($var{'showing'}==1) { print "Now showing "; } else { print "
Coming soon "; } print "(released $var{'releaseDate'}) "; @cinemas=ParseCSV($var{'cinema_id'}); if (@cinemas) { print "at:"; ListCinemas(@cinemas); } print "
"; } elsif ($cmd eq 'r') { # ----- Region or cinema listing if (exists $formdata{'region'}) { # List cinemas in a region $region=$formdata{'region'}; $regionreadable=$region; $regionreadable=~s/_/ /g; print "For information, call $var{'filmlineNumber'}
"; print "Disability information call $var{'disabilityNumber'}
"; $loveseat=$var{'love_seat'}; $audio=$var{'dda'}; # Cinema information print "Address: $var{'address'}
"; for ($i=17; $i<=$#ojs2; $i++) { if ($ojs2[$i]=~/new header\("([^"]*)","([^"]*)"\)/) { print "$1: $2
\n"; } } if ($loveseat eq 'Y') { print "Lurve seats available
\n"; } if ($audio eq 'Y') { print "Audio description technology installed
\n"; } } # ================================= # Subroutines follow # ================================= # ------ Get_Odeon_JS subroutine # takes query string for Display.page, returns document as string sub Get_Odeon_JS { my $qs=$_[0]; return split(/\n/,get ("http://www.odeon.co.uk/pls/Odeon/Display.page?$qs")) or die ("Couldn't get $qs: $!\n"); } # ------ Parse_Form subroutine # this version handles both POST and GET 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); } } 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; if ($formdata{$key}) { $formdata{$key} .= ", $value"; } else { $formdata{$key} = $value; } } } # ------------------- # ParseCSV subroutine sub ParseCSV { my $str = @_ ? shift : $_; my @ret; while ($str =~ /\G\s*(?!$)("[^"]*(?:""[^"]*)*"|[^,"]*),?/g) { push @ret, $1; $ret[-1] =~ s/\s+$//; if ($ret[-1] =~ s/^"//) { chop $ret[-1]; $ret[-1] =~ s/""/"/g } } return @ret; } sub ParseCSVSingleQuotes { my $str=substr($_[0],1).",'"; return split(/','/,$str); } # ------------------- # Paramify subroutine sub Paramify { my $str=$_[0]; $str=~s/['.]//g; $str=~s/ /_/g; return $str; } # ---------------------- # WriteRegion subroutine sub WriteRegion { my $region=$_[0]; my $regurl=Paramify($region); print "