+aladin
authorJan Kratochvil <jan.kratochvil@redhat.com>
Wed, 11 Sep 2013 08:04:01 +0000 (10:04 +0200)
committerJan Kratochvil <jan.kratochvil@redhat.com>
Wed, 11 Sep 2013 08:04:01 +0000 (10:04 +0200)
public_html/cgi-bin/aladin [new file with mode: 0755]

diff --git a/public_html/cgi-bin/aladin b/public_html/cgi-bin/aladin
new file mode 100755 (executable)
index 0000000..0125253
--- /dev/null
@@ -0,0 +1,70 @@
+#! /usr/bin/perl
+use strict;
+use warnings;
+use LWP::Simple;
+use HTML::Entities;
+binmode STDOUT,":utf8";
+$|=1;
+my $args;
+if (exists $ENV{"QUERY_STRING"}) {
+  0==@ARGV or die "ARGV count != 0";
+  $args=$ENV{"QUERY_STRING"};
+} else {
+  1==@ARGV or die "ARGV count != 1";
+  $args=$ARGV[0];
+}
+my $URL="http://pr-asv.chmi.cz/aladin/index.php?$args";
+my $URLhtml=encode_entities $URL;
+if ($ENV{"GATEWAY_INTERFACE"}) {
+  print <<"EOH";
+Content-type: text/html; charset=utf8
+Pragma-directive: no-cache
+Cache-directive: no-cache
+Cache-control: no-cache
+Pragma: no-cache
+Expires: 0
+
+EOH
+}
+print <<"EOH";
+<html><head>
+<title>aladin@{[ !$URLhtml?"":": $URLhtml" ]}</title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf8">
+</head><body>
+<form action="idnes-foto" method="get">
+       <input type="text" name="url" size="50" value="$URLhtml">
+       <input type="submit">
+</form>
+<hr>
+EOH
+my $content=get $URL;
+print "<table><tr><th></th>",map(sprintf("<th>%02dh</th>",$_*6),0..3),"</tr>\n";
+my $day="";
+my $days=0;
+my @day;
+sub flushday() {
+  print "<tr><td>$day</td>\n";
+  if (!$days) {
+    unshift @day,"" while @day<4;
+  } else {
+    push @day,"" while @day<4;
+  }
+  print "<td>$_</td>\n" for @day;
+  print "</tr>\n";
+  @day=();
+  $days++;
+}
+while ($content=~m{\n<tr><td bgcolor=wheat align=center>([^<>]*)<br>.*?<td bgcolor=lightgrey align=center>\s*(?:<img src=(http://portal.chmi.cz/files/portal/docs/meteo/ov/aladin/results/public/mapy/data/\S+)|([^<>]+))}gs) {
+  if ($day ne $1) {
+    flushday() if @day;
+    $day=$1;
+  }
+  push @day,$3||"<img src=\"$2\">";
+}
+flushday();
+print <<"EOH";
+</table>
+<hr>
+<p>EOF</p>
+</body></html>
+EOH