sub refresh_commodmap() {
die unless $pctb;
+ $pctb =~ s,/*$,,;
my $resp= $ua->get("$pctb/commodmap.php?version=2");
die $resp->status_line unless $resp->is_success;
print $o or die $!;
}
+sub save_upload_html ($$) {
+ my ($which, $resptxt) = @_;
+ open R, ">./#upload-$which#.html" or die $!;
+ print R $resptxt or die $!;
+ close R or die $!;
+}
+
sub main__upload () {
+ my $ocean= $ENV{'YPPSC_OCEAN'}; die unless $ocean;
+ my $island= $ENV{'YPPSC_ISLAND'}; die unless $island;
die unless $pctb;
my $o= genmarketdata();
+ $pctb =~ s,/*$,,;
my $url= "$pctb/upload.php";
- $url= "http://www.chiark.greenend.org.uk/ucgi/~ijackson/check/upload.php";
my $content= {
'marketdata' => [ undef, "marketdata.gz",
Content_Type => 'application/gzip',
Content => $o
]
};
+
+ print STDERR "Uploading data to server...\n";
+
my $resp= $ua->post("$url", Content => $content,
Content_Type => 'form-data');
die $resp->status_line unless $resp->is_success;
- print "[[ ",$resp->content," ]]\n";
+ my $resptxt= $resp->content();
+ save_upload_html('1', $resptxt);
+
+ open R, ">./#upload-1#.html" or die $!;
+ print R $resptxt or die $!;
+ close R or die $!;
+
+ my @filenames= $resptxt =~
+ m/input\s+type="hidden"\s+name="filename"\s+value=\"([_.0-9a-z]+)\"/ig;
+ @filenames or die;
+
+ my @forcerls= $resptxt =~
+ m/input\s+type="hidden"\s+name="forcereload"\s+value=\"([1-9]\d+)\"/ig;
+ @forcerls or die;
+
+ my $filename= $filenames[0];
+ my $forcerl= $forcerls[0];
+
+ $ocean= ucfirst lc $ocean;
+ my @oceanids= $resptxt =~
+ m/\<option value\=\"(\d+)\"\>$ocean\<\/option\>/;
+ @oceanids==1 or die "@oceanids ?";
+
+ my $islandid;
+ while ($resptxt =~
+ m/^islands\[\d+\]\[\d+\]\=new\s+option\(\"(.*)\"\,(\d+)\)\s*$/mig
+ ) {
+ next unless $1 eq $island;
+ $islandid= $2;
+ }
+ defined $islandid or die;
+
+ die "@filenames ?" if grep { $_ ne $filename } @filenames;
+ die "@forcerls ?" if grep { $_ ne $forcerl } @forcerls;
+
+ my $setisland= {
+ 'action' => 'setisland',
+ 'filename' => $filename,
+ 'forcereload' => $forcerl,
+ 'ocean' => $oceanids[0],
+ 'island' => $islandid,
+ };
+
+ print STDERR "Setting ocean and island...\n";
+
+ $resp= $ua->post("${url}IWJTEST", $setisland);
+ die $resp->status_line unless $resp->is_success;
+
+ $resptxt= $resp->content();
+ save_upload_html('2', $resptxt);
+
+
+
+#
+#http://pctb.ilk.org/upload.php?&ocean=2&island=48&action=setisland&forcereload=1244748679&filename=PFayDW' >v.html
+#
+# print ">$filename|$forcerl|@oceanids|$islandid<\n";
- system 'printenv|sort';
+ system 'printenv|grep YPP|sort';
}