#!/usr/bin/perl # HFCC stuff ( see http://www.hfcc.org/data/index.html ) # name: index.cgi - main index to all the swbc searches # by: Tomas Hood $| = 1; my $oldQuery = 1; my $SendEmail = 0; my $SendMailFrom = "nw7us\@hfradio.org"; my $SendMailTo = "nw7us\@hfradio.org"; my $downloadOK = 0; my $goPublic = 1; my $solarReport = ""; my $mail_prog = '/usr/lib/sendmail' ; my $theRootDir = "/home/hfradio/database/swl"; my $theLogFile = $theRootDir . "/swbc_lookup.log"; my $templateDir = "/home/hfradio/html/swbc"; my $html_header = "Content-type: text/html\n\n"; my $gmtTime = `date -u +%H:%M:%S`; chop $gmtTime; my $showTime = `date -u +%H%M`; chop $showTime; my $gmtDay = `date -u +%Y-%m-%d`; chop $gmtDay; my $styleSheet = "/home/hfradio/html/cgi-bin/styles.format"; my $theMenu = "/home/hfradio/html/cgi-bin/menu.format"; my $theLinks = "shortwave links"; my $remoteHost = $ENV{'REMOTE_HOST'}; my $httpFrom = $ENV{'HTTP_FROM'}; my $httpUserAgent = $ENV{'HTTP_USER_AGENT'}; my $httpRemoteHost = $ENV{'REMOTE_HOST'}; my $httpReferer = $ENV{'HTTP_REFERER'}; my $httpRemoteAdr = $ENV{'REMOTE_ADDR'}; my $theSearch = ""; my $theTable = ""; my $mailTable = ""; my $tnum = 0; &GetFormInput; doSolarData(); my ($result, $conn); my ($okToGoOn) = 0; my ($message) = ""; print $html_header; if ($goPublic) { $okToGoOn = 1; } else { if ($remoteHost =~ m|ttcnet|i) { $okToGoOn = 1; } else { $okToGoOn = 0; } } if (! $okToGoOn) { print < Database Down for a while...
I am trying to work out with Bernd Friedewald, of ILG
some kind of arrangement to obtain current data.

I await his reply to me. I hope for a discussion with him.
In the meantime, I am working on alternative sources and
will recreate the database. So hang in there. I will attempt to provide
a good look-up service for those who cannot handle huge amounts of
data, or are at a place where they cannot store data on their local
machine.

So, I am working on a new database. This page is down for a while.
Please try again later. Thank you.
YE1 } else { use DBI; my ($dsn, $result, $conn); $dsn = "DBI:mysql:database=swl;host=localhost"; eval { $dbh = DBI->connect($dsn, "proptomas", "pr0pag8sion", {'RaiseError' => 1}); }; if ($@) { $okToGoOn = 0; $errMsg = $@; $message = "Error hooking up to the database. Message is
"; $message .= "$errMsg
\n"; print STDERR "No sql connection... " . $errMsg ."\n"; print < Database Down for a while...
This page is down for updating. It might take a while.
Please try again later. Thank you.
YE2 } else { #print STDERR "postgresql connection ok ... \n"; @foundItems = (); @downloadList = (); if (exists ($field{'private'})) { $private = $field{'private'}; } if (! exists ($field{'search'})) { &showForm(1); } else { if (0) { } else { $theSearch = $field{'freq'}; $theSearch =~ tr/\.\,\-\=\+\;\://d; $theSearch =~ tr/ //d; $theSearch =~ tr/a-zA-Z//d; $theSearch .= ".00"; my $Query = ""; if ($oldQuery) { $Query = "SELECT hfcc_sched.freq,hfcc_sched.utc_time_start,hfcc_sched.utc_time_end,"; $Query .= "hfcc_sched.power,hfcc_sched.days,hfcc_sched.lang,hfcc_sched.modulation,"; $Query .= "hfcc_site.sitename,hfcc_admin.country,"; $Query .= "hfcc_bcst.station "; $Query .= "FROM hfcc_sched,hfcc_site,hfcc_admin,hfcc_bcst "; $Query .= "WHERE freq='" . $theSearch . "' AND "; $Query .= "hfcc_site.sitekey=hfcc_sched.location AND "; $Query .= "hfcc_admin.adminkey=hfcc_sched.country AND "; $Query .= "hfcc_bcst.bcstkey=hfcc_sched.station"; } else { $Query = "SELECT hfcc_sched.freq,hfcc_sched.utc_time_start,hfcc_sched.utc_time_end,"; $Query .= "hfcc_sched.power,hfcc_sched.days,hfcc_sched.lang,hfcc_sched.modulation,"; $Query .= "hfcc_site.sitename,hfcc_admin.country,"; $Query .= "hfcc_bcst.station,schedule_flat.lang "; $Query .= "FROM hfcc_sched,hfcc_site,hfcc_admin,hfcc_bcst,schedule_flat "; $Query .= "WHERE hfcc_sched.freq='" . $theSearch . "' AND "; $Query .= "hfcc_site.sitekey=hfcc_sched.location AND "; $Query .= "hfcc_admin.adminkey=hfcc_sched.country AND "; $Query .= "hfcc_bcst.bcstkey=hfcc_sched.station AND "; $Query .= "schedule_flat.utc_time_start=hfcc_sched.utc_time_start AND "; $Query .= "schedule_flat.freq='" . $theSearch . "'"; print STDERR "[$Query]\n"; } my $sth = $dbh->prepare("$Query"); eval { $sth->execute(); }; if ($@) { $okToGoOn = 0; $message = "Error getting the data out of the database. Message is
"; $message .= "
$@

\n"; print STDERR "No good: $message\n"; } else { my %IfoundItems = (); while (my $ref = $sth->fetchrow_hashref()) { my ($freq) = $ref->{'freq'}; my ($utcTimeStart) = $ref->{'utc_time_start'}; my ($utcTimeEnd) = $ref->{'utc_time_end'}; my ($power) = $ref->{'power'}; my ($days) = $ref->{'days'}; my ($lang) = $ref->{'lang'}; my ($modulation) = $ref->{'modulation'}; my ($sitename) = $ref->{'sitename'}; my ($country) = $ref->{'country'}; my ($station) = $ref->{'station'}; my ($ilg_lang) = $ref->{'lang'}; $freq =~ tr/ //d; if ($oldQuery) { } else { $lang = $ilg_lang; } if (! length($lang) ) { $lang = "Unknown"; } $utcTimeStart =~ tr/\://d; $utcTimeStart =~ m|(\d\d\d\d)\d\d|; $utcTimeStart = $1; $utcTimeEnd =~ tr/\://d; $utcTimeEnd =~ m|(\d\d\d\d)\d\d|; $utcTimeEnd = $1; if ($lang =~ m|^eng$|i) { $lang = "English"; } elsif ($lang =~ m|^swa$|i) { $lang = "Swahili"; } elsif ($lang =~ m|^urd$|i) { $lang = "Urdu"; } elsif ($lang =~ m|^deu$|i) { $lang = "Deutsch (German)"; } elsif ($lang =~ m|^Ind$|i) { $lang = "Indonesian"; } elsif ($lang =~ m|^Kaz$|i) { $lang = "Kazakh"; } elsif ($lang =~ m|^Zho$|i) { $lang = "Zhongwen (Chinese Mandarin)"; } elsif ($lang =~ m|^Mul$|i) { $lang = "English or Multilingual"; } if ($station =~ m|International Broadcasting Bureau|ims) { if ($country =~ m|United States|ims) { $station =~ s|International Broadcasting Bureau|VOA - Voice of America|imsg; #} elsif ($country =~ m|Germany|ims) { # $station =~ s|International Broadcasting Bureau|DWI - Deutsche Welle International|imsg; } elsif ($country =~ m|Greece|ims) { $station =~ s|International Broadcasting Bureau|Greece Radio International|imsg; } else { $station =~ s|International Broadcasting Bureau|VOA - Voice of America|imsg; } # elsif ($country =~ m|Sri Lanka|ims) { # $station =~ s|International Broadcasting Bureau|Sri Lanka Radio International|imsg; #} } if ($station =~ m|Voice of the Andes|ims) { $station =~ s|Voice of the Andes|HCJB - Voice of the Andes|imsg; } if ($station =~ m|Vlaamse Radio en Televisie|ims) { $station =~ s|Vlaamse Radio en Televisie|Radio Vlaanderen International \(Belgium\)|imsg; } if ($station =~ m|Radio \& TV of the Peoples Republic of China|ims) { $station =~ s|Radio \& TV of the Peoples Republic of China|China Radio International|imsg; } if ($station =~ m|Leap of Faith|ims) { $station = "WTWW (Leap of Faith, Inc.)"; } $count++; my $utcTime = $utcTimeStart . "-" . $utcTimeEnd; my $recKey = $freq . $utcTime . $station . $days . $lang . $country . $power . $modulation . $sitename; my $newRec = "$freq\t$utcTime\t$station\t$days\t$lang\t$country\t$power\t$modulation\t$sitename"; $IfoundItems{$recKey} = $newRec; } $sth->finish(); foreach my $iKey (sort keys (%IfoundItems)) { push (@foundItems, $IfoundItems{$iKey}); } my $count = @foundItems; if ($count) { #my $tt = "_freq__time__station__country__days__lang__power__sitename_\n"; my $tt = "_time__station__country__days__lang__power__sitename_\n"; my $tx = "_time_ _station_ _country_ _days_ _lang_ _power_ _sitename_\n"; $mailTable = ""; $theTable = "
\n"; $theTable .= "
Yellow highlights current transmissions
\n"; $theTable .= "
\n"; $theTable .= "
\n"; my $trh = $tt; $trh =~ s|||ig; $tRow =~ s||ig; $tRow =~ s||\n"; open (OUTSF, "> /hfradio/html/swbc/$dlFileName"); foreach $sfreq (@downloadList) { print OUTSF "$sfreq\n"; } close (OUTSF); } $theTable .= "
||ig; $trh =~ s|_freq_|FREQ|ig; $trh =~ s|_time_|Time|ig; $trh =~ s|_station_|Station|ig; $trh =~ s|_country_|Country|ig; $trh =~ s|_lang_|Language|ig; $trh =~ s|_days_|Days|ig; $trh =~ s|_modulation_|AM/SSB|ig; $trh =~ s|_power_|Power (kW)|ig; $trh =~ s|_sitename_|Site|ig; $theTable .= $trh; my $txh = $tx; $txh =~ s|_freq_|FREQ|ig; $txh =~ s|_time_|Time|ig; $txh =~ s|_station_|Station|ig; $txh =~ s|_country_|Country|ig; $txh =~ s|_lang_|Language|ig; $txh =~ s|_days_|Days|ig; $txh =~ s|_modulation_|AM/SSB|ig; $txh =~ s|_power_|Power (kW)|ig; $txh =~ s|_sitename_|Site|ig; $mailTable .= $txh; my $color = 0; foreach $stationRec (sort (@foundItems)) { my ($tRow) = $tt; my ($lRow) = $tx; my ($freq,$utcTime,$station,$days,$lang,$country,$power,$modulation,$sitename) = split(/\t/, $stationRec); $tnum++; if ($color == 0) { $tRow =~ s|
||ig; $color = 1; } else { $color = 0; } $utcTime =~ m|^(\d{4})[^\d]*(\d{4})$|imsg; my ($startTime_) = $1; my ($endTime_) = $2; #print STDERR "st_ = [$startTime_], et_ = [$endTime_]\n"; my $lFreq = $freq; my $lutcTime = $utcTime; my $lstation = $station; my $lcountry = $country; my $llang = $lang; my $ldays = $days; my $lpower = $power; my $lmodulation = $modulation; my $lsitename = $sitename; if ( (($showTime >= $startTime_) && ($showTime <= $endTime_)) || (($showTime >= $startTime_) && (($endTime_ < $startTime_) && ($endTime_ < $showTime))) || (($startTime_ > $endTime_) && ($endTime_ > $showTime)) ) { $lutcTime = "* $utcTime"; $freq = "$freq"; $utcTime = "$utcTime"; $station = "$station"; $country = "$country"; $lang = "$lang"; $days = "$days"; $modulation = "$modulation"; $sitename = "$sitename"; $tRow =~ s||
|ig; } $tRow =~ s|_freq_|$freq|ig; $tRow =~ s|_time_|$utcTime|ig; $tRow =~ s|_station_|$station|ig; $tRow =~ s|_country_|$country|ig; $tRow =~ s|_lang_|$lang|ig; $tRow =~ s|_days_|$days|ig; $tRow =~ s|_modulation_|$modulation|ig; $tRow =~ s|_sitename_|$sitename|ig; $tRow =~ s|_power_|$power|ig; $theTable .= $tRow; $lRow =~ s|_freq_|$lFreq|ig; $lRow =~ s|_time_|$lutcTime|ig; $lRow =~ s|_station_|$lstation|ig; $lRow =~ s|_country_|$lcountry|ig; $lRow =~ s|_lang_|$llang|ig; $lRow =~ s|_days_|$ldays|ig; $lRow =~ s|_modulation_|$lmodulation|ig; $lRow =~ s|_sitename_|$lsitename|ig; $lRow =~ s|_power_|$lpower|ig; $mailTable .= $lRow; if (0) { #$downloadOK) { my ($newFreqL) = $freq; my ($newStation) = $station; $newFreqL =~ s|\.||g; $newFreqL =~ s|\||g; $newFreqL =~ s|\||g; $newFreqL =~ s|^(\d+?)(\d\d\d)(\d\d)$|$1\.$2|; $newStation =~ s|\||g; $newStation =~ s|\||g; push(@downloadList, "$newStation\t$newFreqL\tAM\t\t"); } } if (0) { #$downloadOK) { my ($rte_time) = `date -u +\"%Y-%d-%m_%H%M\"`; chop ($rte_time); my ($pid) = $$; my ($dlFileName) = "search_results" . "." . $pid . ".frq"; $theTable .= "

Shift-Click here to Download "; $theTable .= "Results for YPLog
Total Found: $tnum

\n"; $mailTable .= "\nTotal Found: $tnum\n"; } else { $theTable = "
\nNothing found for $theSearch
\n
\n
\n"; } &sendPrivateMail(); &showForm(2); } } } } } sub showForm { my ($option) = @_; my $what = ""; my $lastSearch = "Last Five Searched:
\n"; `tail -n 5 $theLogFile > $theLogFile.last`; open (RLOG, "$theLogFile.last"); while () { my $rLine = $_; if (m|Search\:\s+(\d+)|i) { $rLine =~ m|Search\:\s+(\d+)|i; $what = $1; $lastSearch .= "$what
\n"; } } close (RLOG); open (STYLE, "$styleSheet") || die "Could not read $styleSheet: $!\n"; $_style = ""; while (