#!/opt/perl-5.6.1/bin/perl -T ###[ down_acr.cgi ]########################################################### # # Download your favorite acrobat reader, and perhaps even register it, # while you're at it. # # Programmer : Hartog C. de Mik (aka: Sinister) # Start-date : 2002-07-02 # End-date : 2002-... # Version : 0.1 # # Remarks : # +--------------------------------------------------------------------+ # | * Had to heavily modify ApacheParse for this, so it could cope | # | with JavaScripts... *sigh* | # | | # | | # +--------------------------------------------------------------------+ # # 2002-11-04 RB Heavily changed script becaause of download manager stuff # (with 5.1) main changes - %DATA hash and ChooseReader() routines # ###[ (c) 2organize - 2002 ]################################################### ############################################################################## # # Script set up. ############################################################################## BEGIN { push @INC, "/www/cgi"; } # use some modules use strict; no strict 'refs'; use Fcntl ':flock'; # import LOCK_* constants # that's nice - the below are _all_ in house mods. use AdobePath; use CGI; # for loging. use Date::Format; # init those objects and special vars. umask 002; $|=1; my $log_dir = $SiteLogDir; my $cgi = CGI->new(); # roots && files my $wwwroot = $::SiteRootDir; my $prod_root = $::SiteRootDir . "/products/acrobat"; my $temp_root = ""; my $log_file = $log_dir ."/downld_acr.cgi.log"; my $register_log = $log_dir . "/downld_acr.cgi.register.log"; my $noreader = "/products/acrobat/unavail.html"; my %subst; # servers my $httpserver = "http://download.adobe.com/pub/adobe/acrobatreader"; my $ftpserver = "ftp://ftp.adobe.com/pub/adobe/acrobatreader"; # log first - think later... my $retval = logString($log_file, "\t", time(), $cgi->remote_addr, $cgi->query_string()); error("stuff went very wrong in an early stage...") if !$retval; ############################################################################## # # Script logic is set up here ############################################################################## ##### Define the templates to use and the file names and sizes for ##### each product, platform, and language. Format is: ##### NOTE: as of 200104 only the file name is actually being used!!! ##### ##### %DATA = ( ##### product => { ##### platform => { ##### language => file name ##### } ##### } ##### ); my %DATA = ( reader => { Win98NT => { 'Chinese Simplified' => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AcroReader51_CHS.exe', 'Chinese Traditional' => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AcroReader51_CHT.exe', Danish => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AcroReader51_DAN.exe', German => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AcroReader51_DEU.exe', English => 'http://ardownload.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AcroReader51_ENU.exe', Spanish => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AcroReader51_ESP.exe', French => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AcroReader51_FRA.exe', Italian => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AcroReader51_ITA.exe', Japanese => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AcroReader51_JPN.exe', Korean => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AcroReader51_KOR.exe', Dutch => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AcroReader51_NLD.exe', Norwegian => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AcroReader51_NOR.exe', Portuguese => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/ar505ptb.exe', Finnish => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AcroReader51_SUO.exe', Swedish => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AcroReader51_SVE.exe', ME_English => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/arme505enu.exe', ME_French => 'http://download.adobe.com/pub/adobe/acrobatreader/win/4.x/arme405fre.exe', ME_Hebrew => 'http://download.adobe.com/pub/adobe/acrobatreader/win/4.x/arme405heb.exe', ME_Arabic => 'http://download.adobe.com/pub/adobe/acrobatreader/win/4.x/arme405ara.exe', CE_English => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/arce505enu.exe', CE_Czech => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/arce505cze.exe', 'CE_ Greek' => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/arce505grk.exe', 'CE_ Hungarian'=> 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/arce505hun.exe', 'CE_ Polish' => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/arce505pol.exe', }, Win95 => { English => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/ar505enu.exe', Japanese => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/ar505jpn.exe', French => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/ar505fra.exe', German => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/ar505deu.exe', Spanish => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/ar505esp.exe', Italian => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/ar505ita.exe', Swedish => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/ar505sve.exe', Dutch => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/ar505nld.exe', Portuguese => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/ar505ptb.exe', 'Chinese Simplified' => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/ar505chs.exe', 'Chinese Traditional' => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/ar505cht.exe', Korean => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/ar505kor.exe', Danish => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/ar505dan.exe', Finnish => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/ar505suo.exe', Norwegian => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/ar505nor.exe', ME_English => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/arme505enu.exe', ME_French => 'http://download.adobe.com/pub/adobe/acrobatreader/win/4.x/arme405fre.exe', ME_Hebrew => 'http://download.adobe.com/pub/adobe/acrobatreader/win/4.x/arme405heb.exe', ME_Arabic => 'http://download.adobe.com/pub/adobe/acrobatreader/win/4.x/arme405ara.exe', CE_English => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/arce505enu.exe', CE_Czech => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/arce505cze.exe', 'CE_ Greek' => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/arce505grk.exe', 'CE_ Hungarian'=> 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/arce505hun.exe', 'CE_ Polish' => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/arce505pol.exe', }, 'Win 3.1' => { English => 'http://download.adobe.com/pub/adobe/acrobatreader/win/3.x/ar16e301.exe', French => 'http://download.adobe.com/pub/adobe/acrobatreader/win/3.x/ar16f301.exe', German => 'http://download.adobe.com/pub/adobe/acrobatreader/win/3.x/ar16d301.exe', Spanish => 'http://download.adobe.com/pub/adobe/acrobatreader/win/3.x/ar16s301.exe', Italian => 'http://download.adobe.com/pub/adobe/acrobatreader/win/3.x/ar16i301.exe', Swedish => 'http://download.adobe.com/pub/adobe/acrobatreader/win/3.x/ar16v301.exe', Dutch => 'http://download.adobe.com/pub/adobe/acrobatreader/win/3.x/ar16n301.exe', }, 'OS/2 Warp' => { English => 'http://download.adobe.com/pub/adobe/acrobatreader/os2/3.x/aro2e30.exe', French => 'http://download.adobe.com/pub/adobe/acrobatreader/os2/3.x/aro2f30.exe', German => 'http://download.adobe.com/pub/adobe/acrobatreader/os2/3.x/aro2d30.exe', Spanish => 'http://download.adobe.com/pub/adobe/acrobatreader/os2/3.x/aro2s30.exe', Italian => 'http://download.adobe.com/pub/adobe/acrobatreader/os2/3.x/aro2i30.exe', Swedish => 'http://download.adobe.com/pub/adobe/acrobatreader/os2/3.x/aro2v30.exe', Dutch => 'http://download.adobe.com/pub/adobe/acrobatreader/os2/3.x/aro2n30.exe', }, 'Mac_9.1' => { 'Chinese Simplified' => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/5.1/AcroReader51_CHS.bin', 'Chinese Traditional' => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/5.1/AcroReader51_CHT.bin', Danish => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/5.1/AcroReader51_DAN.bin', Dutch => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/5.1/AcroReader51_NLD.bin', English => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/5.1/AcroReader51_ENU.bin', Finnish => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/5.1/AcroReader51_SUO.bin', French => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/5.1/AcroReader51_FRA.bin', German => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/5.1/AcroReader51_DEU.bin', Italian => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/5.1/AcroReader51_ITA.bin', Japanese => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/5.1/AcroReader51_JPN.bin', Korean => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/5.1/AcroReader51_KOR.bin', Norwegian => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/5.1/AcroReader51_NOR.bin', Portuguese => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/ar505ptb.bin', Spanish => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/5.1/AcroReader51_ESP.bin', Swedish => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/5.1/AcroReader51_SVE.bin', ME_English => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/arme505enu.bin', ME_French => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/4.x/arme405fre.bin', ME_Hebrew => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/4.x/arme405heb.bin', ME_Arabic => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/4.x/arme405ara.bin', CE_English => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/arce505enu.bin', CE_Czech => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/arce505cze.bin', 'CE_ Greek' => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/arce505grk.bin', 'CE_ Hungarian' => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/arce505hun.bin', 'CE_ Polish' => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/arce505pol.bin', }, 'Mac_8.6' => { 'Chinese Simplified' => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/ar505chs.bin', 'Chinese Traditional' => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/ar505cht.bin', Danish => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/ar505dan.bin', Dutch => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/ar505nld.bin', English => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/ar505enu.bin', Finnish => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/ar505suo.bin', French => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/ar505fra.bin', German => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/ar505deu.bin', Italian => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/ar505ita.bin', Japanese => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/ar505jpn.bin', Korean => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/ar505kor.bin', Norwegian => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/ar505nor.bin', Portuguese => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/ar505ptb.bin', Spanish => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/ar505esp.bin', Swedish => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/ar505sve.bin', ME_English => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/arme505enu.bin', ME_French => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/4.x/arme405fre.bin', ME_Hebrew => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/4.x/arme405heb.bin', ME_Arabic => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/4.x/arme405ara.bin', CE_English => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/arce505enu.bin', CE_Czech => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/arce505cze.bin', 'CE_ Greek' => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/arce505grk.bin', 'CE_ Hungarian' => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/arce505hun.bin', 'CE_ Polish' => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/arce505pol.bin', }, 'Mac_pre_8.6' => { English => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/4.x/ar405eng.bin', Japanese => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/4.x/ar405jpn.bin', French => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/4.x/ar405fre.bin', German => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/4.x/ar405deu.bin', Spanish => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/4.x/ar405esl.bin', Italian => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/4.x/ar405ita.bin', Swedish => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/4.x/ar405swe.bin', Dutch => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/4.x/ar405dut.bin', Portuguese => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/4.x/ar405por.bin', 'Chinese Simplified' => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/4.x/ar40chs.bin', 'Chinese Traditional' => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/4.x/ar405cht.bin', Korean => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/4.x/ar405kor.bin', ME_English => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/4.x/arme405eng.bin', ME_French => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/4.x/arme405fre.bin', ME_Hebrew => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/4.x/arme405heb.bin', ME_Arabic => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/4.x/arme405ara.bin', CE_English => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/4.x/arce405eng.bin', }, 'Mac68K_.bin' => { English => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/3.x/ar302.bin', Japanese => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/3.x/ardr30aj.bin', French => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/3.x/ardr301f.bin', German => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/3.x/ardr301d.bin', Spanish => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/3.x/ardr301s.bin', Italian => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/3.x/ardr301i.bin', Swedish => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/3.x/ardr301v.bin', Dutch => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/3.x/ardr301n.bin', }, 'Mac68K_.hqx' => { English => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/3.x/ar302.sit.hqx', Japanese => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/3.x/ardr30aj.sit.hqx', French => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/3.x/ardr301f.sit.hqx', German => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/3.x/ardr301d.sit.hqx', Spanish => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/3.x/ardr301s.sit.hqx', Italian => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/3.x/ardr301i.sit.hqx', Swedish => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/3.x/ardr301v.sit.hqx', Dutch => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/3.x/ardr301n.sit.hqx', }, 'Digital Unix' => { English => 'http://download.adobe.com/pub/adobe/acrobatreader/unix/4.x/fdec-rs-405.tar.gz', }, LINUX => { English => 'http://download.adobe.com/pub/adobe/acrobatreader/unix/5.x/linux-506.tar.gz', }, 'IBM AIX' => { English => 'http://download.adobe.com/pub/adobe/acrobatreader/unix/5.x/aix-506.tar.gz', }, SunOS => { English => 'http://download.adobe.com/pub/adobe/acrobatreader/unix/3.x/ar302sun.tar.Z', }, Solaris => { English => 'http://download.adobe.com/pub/adobe/acrobatreader/unix/5.x/solaris-506.tar.gz', }, 'X86 Solaris' => { English => 'http://download.adobe.com/pub/adobe/acrobatreader/unix/4.x/sunx86-ar-405.tar.gz', }, 'SGI IRIX' => { English => 'http://download.adobe.com/pub/adobe/acrobatreader/unix/4.x/irix-rs-405.tar.gz', }, 'HP-UX' => { English => 'http://download.adobe.com/pub/adobe/acrobatreader/unix/5.x/hpux-506.tar.gz', }, PalmOS => { English => 'http://download.adobe.com/pub/adobe/acrobatreader/win/palmos/accrreadpalmosv11.exe', }, PocketPC => { English => 'http://download.adobe.com/pub/adobe/acrobatreader/win/pocketpc/acrobatreader.exe', }, }, search => { Win98NT => { 'Chinese Simplified' => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AcroReader51_CHS_full.exe', 'Chinese Traditional' => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AcroReader51_CHT_full.exe', Danish => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AcroReader51_DAN_full.exe', German => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AcroReader51_DEU_full.exe', English => 'http://ardownload.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AcroReader51_ENU_full.exe', Spanish => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AcroReader51_ESP_full.exe', French => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AcroReader51_FRA_full.exe', Italian => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AcroReader51_ITA_full.exe', Japanese => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AcroReader51_JPN_full.exe', Korean => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AcroReader51_KOR_full.exe', Dutch => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AcroReader51_NLD_full.exe', Norwegian => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AcroReader51_NOR_full.exe', #Portuguese => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AcroReader51_PTB_full.exe', Finnish => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AcroReader51_SUO_full.exe', Swedish => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AcroReader51_SVE_full.exe', CE_English => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/arce505enu.exe', CE_Czech => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/arce505cze.exe', 'CE_ Greek' => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/arce505grk.exe', 'CE_ Hungarian' => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/arce505hun.exe', 'CE_ Polish' => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/arce505pol.exe', ME_English => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/arme505enu.exe', }, Win95 => { English => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/rp505enu.exe', French => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/rp505fra.exe', German => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/rp505deu.exe', Spanish => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/rp505esp.exe', Italian => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/rp505ita.exe', Swedish => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/rp505sve.exe', Dutch => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/rp505nld.exe', CE_English => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/arce505enu.exe', CE_Czech => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/arce505cze.exe', 'CE_ Greek' => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/arce505grk.exe', 'CE_ Hungarian' => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/arce505hun.exe', 'CE_ Polish' => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/arce505pol.exe', ME_English => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/arme505enu.exe', }, 'Win 3.1' => { English => 'http://download.adobe.com/pub/adobe/acrobatreader/win/3.x/rs16e301.exe', French => 'http://download.adobe.com/pub/adobe/acrobatreader/win/3.x/rs16f301.exe', German => 'http://download.adobe.com/pub/adobe/acrobatreader/win/3.x/rs16d301.exe', Spanish => 'http://download.adobe.com/pub/adobe/acrobatreader/win/3.x/rs16s301.exe', Italian => 'http://download.adobe.com/pub/adobe/acrobatreader/win/3.x/rs16i301.exe', Swedish => 'http://download.adobe.com/pub/adobe/acrobatreader/win/3.x/rs16v301.exe', Dutch => 'http://download.adobe.com/pub/adobe/acrobatreader/win/3.x/rs16n301.exe', }, 'Mac_9.1' => { 'Chinese Simplified' => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/5.1/AcroReader51_CHS_full.bin', 'Chinese Traditional' => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/5.1/AcroReader51_CHT_full.bin', Danish => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/5.1/AcroReader51_DAN_full.bin', Dutch => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/5.1/AcroReader51_NLD_full.bin', English => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/5.1/AcroReader51_ENU_full.bin', Finnish => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/5.1/AcroReader51_SUO_full.bin', French => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/5.1/AcroReader51_FRA_full.bin', German => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/5.1/AcroReader51_DEU_full.bin', Italian => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/5.1/AcroReader51_ITA_full.bin', Japanese => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/5.1/AcroReader51_JPN_full.bin', Korean => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/5.1/AcroReader51_KOR_full.bin', Norwegian => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/5.1/AcroReader51_NOR_full.bin', #Portuguese => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/5.1/AcroReader51_PTB_full.bin', Spanish => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/5.1/AcroReader51_ESP_full.bin', Swedish => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/5.1/AcroReader51_SVE_full.bin', CE_English => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/arce505enu.bin', CE_Czech => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/arce505cze.bin', 'CE_ Greek' => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/arce505grk.bin', 'CE_ Hungarian' => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/arce505hun.bin', 'CE_ Polish' => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/arce505pol.bin', ME_English => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/arme505enu.bin', }, 'Mac_8.6' => { Dutch => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/ar500nld.bin', English => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/ar505enu.bin', French => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/ar505fra.bin', German => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/ar505deu.bin', Italian => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/ar500ita.bin', Japanese => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/ar505jpn.bin', Spanish => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/ar500esp.bin', Swedish => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/ar500sve.bin', CE_English => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/arce505enu.bin', CE_Czech => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/arce505cze.bin', 'CE_ Greek' => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/arce505grk.bin', 'CE_ Hungarian' => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/arce505hun.bin', 'CE_ Polish' => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/arce505pol.bin', ME_English => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/5.x/arme505enu.bin', }, 'Mac_pre_8.6' => { English => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/4.x/rs405eng.bin', French => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/4.x/rs405fre.bin', German => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/4.x/rs405deu.bin', Spanish => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/4.x/rs405esl.bin', Italian => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/4.x/rs405ita.bin', Swedish => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/4.x/rs405swe.bin', Dutch => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/4.x/rs405dut.bin', }, 'Mac68K_.bin' => { English => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/3.x/arws301e.sea.bin', French => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/3.x/arws301f.sea.bin', German => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/3.x/arws301d.sea.bin', Spanish => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/3.x/arws301s.sea.bin', Italian => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/3.x/arws301i.sea.bin', Swedish => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/3.x/arws301v.sea.bin', Dutch => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/3.x/arws301n.sea.bin', }, 'Mac68K_.hqx' => { English => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/3.x/arws301e.sit.hqx', French => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/3.x/arws301f.sit.hqx', German => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/3.x/arws301d.sit.hqx', Spanish => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/3.x/arws301s.sit.hqx', Italian => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/3.x/arws301i.sit.hqx', Swedish => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/3.x/arws301v.sit.hqx', Dutch => 'http://download.adobe.com/pub/adobe/acrobatreader/mac/3.x/arws301n.sit.hqx', }, 'Digital Unix' => { English => 'http://download.adobe.com/pub/adobe/acrobatreader/unix/4.x/fdec-rs-405.tar.gz', }, LINUX => { English => 'http://download.adobe.com/pub/adobe/acrobatreader/unix/5.x/linux-506.tar.gz', }, 'IBM AIX' => { English => 'http://download.adobe.com/pub/adobe/acrobatreader/unix/5.x/aix-506.tar.gz', }, SunOS => { English => 'http://download.adobe.com/pub/adobe/acrobatreader/unix/3.x/acrdsrch_sunos_301.tar.gz', }, Solaris => { English => 'http://download.adobe.com/pub/adobe/acrobatreader/unix/5.x/solaris-506.tar.gz', }, 'SGI IRIX' => { English => 'http://download.adobe.com/pub/adobe/acrobatreader/unix/4.x/irix-rs-405.tar.gz', }, 'HP-UX' => { English => 'http://download.adobe.com/pub/adobe/acrobatreader/unix/5.x/hpux-506.tar.gz', }, PalmOS => { English => 'http://download.adobe.com/pub/adobe/acrobatreader/win/palmos/accrreadpalmosv11.exe', }, }, esdreaderdl => { Win98NT => { English => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_ENU.exe', French => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_FRA.exe', German => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_DEU.exe', Japanese => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_JPN.exe', Dutch => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_NLD.exe', Danish => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_DAN.exe', Norwegian => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_NOR.exe', Swedish => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_SVE.exe', Finnish => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_SUO.exe', Spanish => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_ESP.exe', Italian => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_ITA.exe', #Portuguese => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_PTB.exe', 'Chinese Simplified' => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_CHS.exe', 'Chinese Traditional' => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_CHT.exe', Korean => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_KOR.exe', }, }, esdsearchdl => { Win98NT => { English => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_ENU_full.exe', French => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_FRA_full.exe', German => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_DEU_full.exe', Japanese => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_JPN_full.exe', Dutch => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_NLD_full.exe', Danish => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_DAN_full.exe', Norwegian => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_NOR_full.exe', Swedish => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_SVE_full.exe', Finnish => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_SUO_full.exe', Spanish => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_ESP_full.exe', Italian => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_ITA_full.exe', #Portuguese => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_PTB_full.exe', 'Chinese Simplified' => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_CHS_full.exe', 'Chinese Traditional' => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_CHT_full.exe', Korean => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_KOR_full.exe', }, }, esdreader => { Win98NT => { English => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_ENU.aom', French => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_FRA.aom', German => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_DEU.aom', Japanese => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_JPN.aom', Dutch => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_NLD.aom', Danish => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_DAN.aom', Norwegian => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_NOR.aom', Swedish => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_SVE.aom', Finnish => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_SUO.aom', Spanish => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_ESP.aom', Italian => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_ITA.aom', #Portuguese => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_PTB.aom', 'Chinese Simplified' => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_CHS.aom', 'Chinese Traditional' => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_CHT.aom', Korean => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_KOR.aom', }, }, esdsearch => { Win98NT => { English => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_ENU_full.aom', French => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_FRA_full.aom', German => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_DEU_full.aom', Japanese => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_JPN_full.aom', Dutch => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_NLD_full.aom', Danish => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_DAN_full.aom', Norwegian => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_NOR_full.aom', Swedish => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_SVE_full.aom', Finnish => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_SUO_full.aom', Spanish => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_ESP_full.aom', Italian => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_ITA_full.aom', #Portuguese => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_PTB_full.aom', 'Chinese Simplified' => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_CHS_full.aom', 'Chinese Traditional' => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_CHT_full.aom', Korean => 'http://download.adobe.com/pub/adobe/acrobatreader/win/5.x/5.1/AdbeDnldmgr_KOR_full.aom', }, }, ); ############################################################################## # # Script begins about here... ############################################################################## if ( !$cgi->param("Location") || !$cgi->param("Language") || !$cgi->param("Platform") ) { # no wanted parameters what so ever, from page one. Perhaps we # should display page one ... ? my $message = "You have not completed the fields: "; foreach (qw(Location Language Platform)) { $message .= "$_ " if !$cgi->param($_); } $message .= "
These are mandatory
"; print $cgi->header; print ParseSSI("$prod_root/readstep2.html",0); } else { # -- complete - save registration info (if any) my $test; foreach ( qw(Country Name Email) ) { $test++ if ($cgi->param($_)); } if ( $test > 0 ) { my $date = time2str("%C",time()); logString($register_log,"|",time(),$date,$cgi->query_string()); } # -- make printing the download page possible # special PalmOS # if ($cgi->param('Platform') eq 'PalmOS') { my $server = ""; # redir to US for these my $c_code; $c_code = $::CountryCode; if ( grep { /$c_code/ } ( 'no', 'fi', 'dk' , 'se', 'nl' ) ) { $server="http://www.adobe.com"; } print "Location: $server/products/acrobat/acrrpalmdload.html\n\n"; exit; } #special PocketPC if ($cgi->param('Platform') eq 'PocketPC'){ my $server = "http://www.adobe."; my $extra = ""; my %lang_conv= ( 'German' => 'de', 'French' => 'fr', 'Italian' => 'it', 'Spanish' => 'es', 'English' => 'co.uk', 'Japanese' => 'co.jp'); my $ppc_lang = $cgi->param("Language"); $ppc_lang =~ s/\n//g; # redir to US for these if ( exists $lang_conv{$ppc_lang} ){ $server .= $lang_conv{$ppc_lang}; } else { print $cgi->header(); print ParseSSI("$::SiteRootDir/products/acrobat/unavail.html"); exit; } print "Location: $server/products/acrobat/acrrppcdload.html\n\n"; exit; } my ($http,$ftp,$file); ($http,$ftp,$file) = chooseReader($cgi); if (!$http) { print $cgi->header(); print ParseSSI("$::SiteRootDir/products/acrobat/unavail.html"); exit; } $subst{'HTTPLINK'} = "http-download"; # -- print the download page print "Refresh: 7; URL=$ftp\n"; print $cgi->header(); print ParseSSI("$::SiteRootDir/products/acrobat/thankyou.html"); } $cgi->DESTROY; # clean up when you leave. ############################################################################## # # HTML features ... (?) ############################################################################## sub error { my ( $string, $no_warn ) = @_; print $cgi->header(); print qq{ Error in script

Error in script

$string

}; warn($0,"\t", time(),"\t",$string,"\n") unless $no_warn; $cgi->DESTROY; exit(0); } ############################################################################## # # Logic features. ############################################################################## sub chooseReader { my $cgi = shift; my $platform = $cgi->param('Platform') || "Win 95"; my $language = $cgi->param('Language') || "English"; my $product = $cgi->param('SearchCB') eq 'Y' ? 'search' : 'reader'; my $location = $cgi->param('Location') || 'USA'; #hm.. not used :-( my $esddlproduct = $cgi->param('SearchCB') eq 'Y' ? 'esdsearchdl' : 'esdreaderdl'; my $esdproduct = $cgi->param('SearchCB') eq 'Y' ? 'esdsearch' : 'esdreader'; if ($cgi->param('esdcanuse') && ! $cgi->param('esdcanhandle') && exists $DATA{$esddlproduct}{$platform}{$language}) { $product = $esddlproduct } if ($cgi->param('esdcanuse') && $cgi->param('esdcanhandle') && exists $DATA{$esdproduct}{$platform}{$language}) { $product = $esdproduct; } my ( $http, $ftp ); my $file = $DATA{$product}{$platform}{$language}; if($file){ if ( $file !~ /^http/) { $ftp = "$ftpserver/$file"; $http = "$httpserver/$file"; } else { $ftp = $file; $http = $file; } } return ($http,$ftp,$file); } ############################################################################## # # Neat features ... (?) ############################################################################## sub logString { ## logs a string to a file - what more do you want? # get, check and repair routine input my ( $file, $sep, @what ) = @_; return 0 if !$file; return 1 if !@what; # empty strings OK - return 1 # do it! if (my $FILE = openLock($file, ">>")) { # beautify string; foreach my $string ( @what ) { $string =~ s/[\n\r]+//g; # remove newline stuff } print $FILE join($sep, @what),"\n"; return closeFile($FILE); } else { # failed to open file, return 0 return 0; } return 1; } sub openLock { ## open and lock a file, and return the filename, all of course ## within the parameters of taint-safety. # get, check and repair routine input my ( $file,$mode ) = @_; return 0 if !$file; $mode ||="<"; # make sure it is taint-safe. my ($open) = $file =~ m/^([\w\d\/\_\s\.]+)/; $open =~ s/\.\.//g; # open the file and lock it my $FILE; open($FILE, $mode . $open) || return 0; flock($FILE,LOCK_EX); # perhaps we waited, find the end... seek($FILE, 0, 2) unless $mode eq "<"; # dont if we're reading... # return the filehandle. return($FILE); } sub closeFile { ## unlock and close a filehandle. my ($FILE) = @_; flock($FILE, LOCK_UN); close($FILE); return 1; } # checks if an attribute is available # won't work very well when value of attribute is attribute name # like src = input ...will trigger both on src and input (yep, shit happens) sub HasAttribute{ my $str = shift; my $attrib = shift; my $res=""; # print "looking for $attrib in $str\n"; if ($str =~ /[\s<\/-]$attrib[\s=>]/i) { $res = 1; } else { $res=0; } return $res; } # finds attributes of type : # att = value # att = 'value' # att = "value" # # RB added [<\s] before attribute. still dirty match [=\s*] but it seems to work... sub GetAttribute{ my $str = shift; my $attrib = shift; my $res=""; if ($str =~ /[<\s]$attrib[=\s]*\'([^\']*)\'/i) { $res = $1; } if ($res eq "") { if ($str =~ /[<\s]$attrib[=\s]*\"([^\"]*)\"/i) { $res =$1; } } if ($res eq "") { if ($str =~ /[<\s]$attrib[=\s]*([^\s>]*)/i) { $res =$1; } } if (($res eq '""')||($res eq "''")) { $res = ""; } return $res; } # modifues attribs of type : # att = value # att = 'value' # att = "value" # or adds it if not found sub SetAttribute{ my $str = shift; my $attrib = shift; my $newvalue = shift; my $res=""; # print "setting attribute $attrib=$newvalue\n"; if (($str =~ s/($attrib[=\s]*)[^\s>]*/$1\'$newvalue\'/i) == 0) { if (($str =~ s/($attrib[=\s]*\")[^\"]*/$1$newvalue/i)== 0) { if (($str =~ s/($attrib[=\s]*\')[^\']*/$1$newvalue/i) == 0) { $str =~ s/([\>]*)>/$1 $attrib='$newvalue'>/ } } } return $str; } sub DelAttribute{ my $str = shift; my $attrib = shift; my $res=""; # print "removing attribute $attrib from $str\n"; if (!HasAttribute($str, $attrib)) { # print "DelAttrib: never mind\n"; return $str; } if (($str =~ s/$attrib[=\s]*[^\s>]*//i) == 0) { if (($str =~ s/$attrib[=\s]*\"[^\"]*//i)== 0) { if (($str =~ s/$attrib[=\s]*\'[^\']*//i) == 0) { #not found; probably a 'single' attribute (without value) $str =~ s/([\s<\/])$attrib([\s=>])/$1$2/i; #has same problems as HasAttribute...; } } } return $str; } sub IsComment{ my $str = shift; my $res; if ($str =~ m//s) { $res = 1; } else { $res=0; } return $res; } #use for setting 'single' values sub AddAttribute{ my $str = shift; my $attrib = shift; my $res=""; # print "adding attribute $attrib to $str\n"; if (HasAttribute($str, $attrib)) { # print "AddAttrib: never mind\n"; return $str; } else { #not found $str =~ s/([\>]*)>/$1 $attrib>/ } return $str; } sub ReadFile{ my $file = shift; my $res= ""; open(FFILE, "<$file") || error("Readfile: can't open $file"); while (my $line = ) { $res .= $line; } return $res; } sub ParseSSI{ my $file = shift; my $firsttime = shift; my $compform = ReadFile($file); my ($tag,$rest); my $result = ""; my $depth = 0; my @ig = (); # ignore array -> holds ignore flag for each nested if #first time; only replace $$tags$$ and includes $compform =~ s/\$\$([^\$]*)\$\$/$subst{$1}/gi; my ($tag, $rest); while ($compform =~ /(<[^>]*>)([^<]*)/g) { next if FixUnbalancedComment(\$tag, \$rest, $1, $2); # $tag = $1; # $rest = $2; # print "PROCESSING: TAG|$tag|\nREST|$rest|\n"; if (IsComment($tag)) { # includes... if (HasAttribute($tag,"#include")) { if ((my $incfile= GetAttribute($tag, "virtual")) ne "") { #read file $tag = ParseSSI($wwwroot . $incfile); } } elsif (HasAttribute($tag,"#if")) { #eval the expression my $expr = GetAttribute($tag, "expr"); my $res = EvalApacheExpr($expr); push @ig, ($res ? 0 : 1); $depth++; $tag =""; } elsif (HasAttribute($tag,"#endif")) { $depth--; pop @ig; $tag =""; } elsif (HasAttribute($tag,"#else")) { $ig[$#ig]= ($ig[$#ig])? 0 : 1; $tag =""; } } my $prnt = (grep { /1/ } @ig) ? 0 : 1; if ($prnt) { $result .= $tag . $rest ; } } # print "PARSSI $file ready\n"; return $result; } sub EvalApacheExpr{ my $expr = shift; my $res = ""; #only support $HTTP_USER_AGENT=/Win/ - type for now if ( $expr =~ /^\$(\w*)=\/([\s\w\[\]-]*)\/$/ ) { if ($ENV{$1} =~ /$2/) { $res = 1; } else { $res = 0; } } else { my_die("couldn't parse apache expression $expr"); } return $res; } sub FixUnbalancedComment{ my $r_tag = shift; my $r_rest = shift; my $found_tag = shift; my $found_rest = shift; my $unbal =0; # print "\nTAG:$found_tag|\nREST:|$found_rest|\n"; # print "check balance of |$$r_tag| \n"; if ($$r_tag =~ /^/ ) { #prev hit was unbalanced; glue rest to tag; em,pty $rest $$r_tag .= $$r_rest; $$r_rest=''; if ($$r_tag =~ /^/ ) { $$r_tag .= $found_tag; $$r_rest= $found_rest; } } else { #prev hit was just a normal hit $$r_tag = $found_tag; $$r_rest= $found_rest; #do not process if not balanced! } #check if broken if ($$r_tag =~ /^/ ) { #still not fixed :-( glue rest to tag $$r_tag .= $$r_rest; $$r_rest=''; } #set $unbal flag! if ($$r_tag =~ /^/ ) { $unbal = 1; #was not balanced -> do not process! } else { $unbal = 0; } # print "|$$r_tag| is unbalanced ? $unbal\n"; # print "RESULT [$unbal]: |$$r_tag|, |$$r_rest|\n"; return( $unbal) }