[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
CVS Update: fgo.ca
- To: cvs@lists.cleannorth.org
- Subject: CVS Update: fgo.ca
- From: Dan Brosemer <odin@cleannorth.org>
- Date: Sun, 8 Jun 2008 22:19:45 -0401 (EDT)
- List-help: <mailto:cvs-request@lists.cleannorth.org?subject=help>
- List-post: <mailto:cvs@lists.cleannorth.org>
- List-subscribe: <mailto:cvs-request@lists.cleannorth.org?subject=subscribe>
- List-unsubscribe: <mailto:cvs-request@lists.cleannorth.org?subject=unsubscribe>
- Resent-date: Sun, 8 Jun 2008 22:19:49 -0401 (EDT)
- Resent-from: cvs@lists.cleannorth.org
- Resent-message-id: <PTTXfC.A.D-C.bNJTIB@skroob.cleannorth.org>
- Resent-sender: cvs-request@lists.cleannorth.org
Log Message:
-----------
Actually do stuff... nothing goes in the db yet, but we are close.
Modified Files:
--------------
fgo.ca/public_html:
butternut.pl
Revision Data
-------------
Index: butternut.pl
===================================================================
RCS file: /cvs/fgo.ca/public_html/butternut.pl,v
retrieving revision 1.2
retrieving revision 1.3
diff -Lpublic_html/butternut.pl -Lpublic_html/butternut.pl -u -r1.2 -r1.3
--- public_html/butternut.pl
+++ public_html/butternut.pl
@@ -43,11 +43,18 @@
exit;
};
-$gleipnir->sidebar('patch');
+$gleipnir->sidebar('butternut');
do { print $gleipnir->output; exit } if ( $gleipnir->done );
-$gleipnir = ShowPage( -gleipnir => $gleipnir );
+if ($cgi->param('data'))
+ {
+ $gleipnir = AcceptUpload( -gleipnir => $gleipnir );
+ }
+else
+ {
+ $gleipnir = ShowPage( -gleipnir => $gleipnir );
+ };
print $gleipnir->output;
exit;
@@ -65,6 +72,14 @@
sub AcceptUpload
{
+
+ my %options = @_;
+ my $gleipnir = $options{-gleipnir};
+ my $cgi = $gleipnir->cgi;
+ my $dbh = $gleipnir->dbh;
+
+ my $file = $cgi->param('data');
+
my %appendix2 =
(
C4 => 'plotno1',
@@ -325,9 +340,13 @@
);
my %tab = ( appendix4 => \%appendix4, appendix5 => \%appendix5 );
+
+ my $contents = "";
+ my ($zfh, $ztmp) = Archive::Zip::tempFile();
+ while (<$file>) { print $zfh $_ };
my $zip = Archive::Zip->new();
- unless ($zip->read($ARGV[0]) == AZ_OK)
+ unless ($zip->readFromFileHandle($zfh) == AZ_OK)
{
die 'read error';
};
@@ -336,6 +355,7 @@
my ($fh, $tmp) = Archive::Zip::tempFile();
close $fh;
my @errors = ();
+ my @messages = ();
foreach my $member (@members)
{
@@ -343,23 +363,30 @@
$member->extractToFileNamed($tmp);
unless ($member->fileName() =~ m/\.xls/i)
{
- push @errors, $member->fileName()." does not look like an Excel file.";
+ push @errors, {message => $member->fileName()." does not look like an Excel file." };
unlink($tmp);
next;
};
my $type = typeof($tmp, $member->fileName());
unless ($type)
{
- push @errors, $member->fileName()." is not a recognized file.";
+ push @errors, {message => $member->fileName()." is not a recognized file." };
unlink($tmp);
next;
};
- print $member->fileName()." is $type\n";
+ push @messages, {message => $member->fileName()." is $type" };
my $data = '';
$data = nontabparse($tmp, $nontab{$type}) if ($nontab{$type});
$data = tabparse($tmp, $tab{$type}) if ($tab{$type});
+ push @messages, {message => Data::Dump::dump($data)};
unlink($tmp);
};
+ close $zfh;
+ unlink $ztmp;
+
+ my $template = $gleipnir->template('butternut/results');
+ $template->param(errors => \@errors, messages => \@messages);
+ return $gleipnir->body($template->output);
};
sub xl2idx
@@ -405,8 +432,6 @@
my $format = shift;
my %data = map { ($format->{$_} => $sheet[(xl2idx($_))[0]][(xl2idx($_))[1]]) } keys %{$format};
- print Data::Dump::dump(%data);
- print "\n";
return \%data;
};
@@ -433,8 +458,6 @@
$i++;
push @data, \%row;
};
- print Data::Dump::dump(@data);
- print "\n";
return \@data;
};
- Prev by Date: CVS Update: fgo.ca
- Next by Date: CVS Update: fgo.ca
- Previous by thread: CVS Update: fgo.ca
- Next by thread: CVS Update: fgo.ca
- Index(es):