/[informatika.old]/html/to_csv.cgi
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /html/to_csv.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Thu Oct 26 14:32:28 2000 UTC (23 years, 5 months ago) by dpavlin
Branch: MAIN
CVS Tags: HEAD
export novih e-mail adresa u CSV

1 dpavlin 1.1 #!/usr/local/bin/perl -w
2    
3     # export e-mail adresa za Filipa,
4     # Usage:
5     #
6     # to_csv.pl [yyyy-mm-dd]
7     #
8     # yyyy-mm-dd ... datum od kojeg se vr¹i export (datum zadnjeg exporta)
9    
10     use DBI;
11     use CGI qw/:standard/;
12     use CGI::Carp 'fatalsToBrowser';
13    
14     my $sql_where;
15    
16     my %labels;
17    
18     if (! param()) {
19     print header,
20     start_html('export novih e-mail-ova'),
21     start_form,
22     "od datuma:",
23     popup_menu(-name=>'yyyy',-values=>['2000','2001'],-default=>'2000',-labels=>\%labels),
24     popup_menu(-name=>'mm',-values=>['01','02','03','04','05','06','07','08','09','10','11','12'],-labels=>\%labels),
25     popup_menu(-name=>'dd',-values=>[
26     '01','02','03','04','05','06','07','08','09',
27     '10','11','12','13','14','15','16','17','18','19',
28     '20','21','22','23','24','25','26','27','28','29',
29     '30','31'
30     ],-labels=>\%labels),
31     submit(-value=>"Dump"),p,
32     end_form;
33    
34     } else {
35    
36     print "Content-type: text/plain\n\n";
37    
38     my $from_date=param('yyyy')."-".param('mm')."-".param('dd');
39    
40     my $mydbh = DBI->connect("DBI:Pg:dbname=informatika;user=dpavlin","","") || die $DBI::errstr;
41     $mysth = $mydbh->prepare("
42     select ime,prezime,alias||'\@pliva.hr' as email from osobe,e_mail where e_mail.osoba_id=osobe.id and datum_unesen >= '$from_date'
43     ") || die $mydbh->errstr();
44     $mysth->execute() || die $mysth->errstr();
45    
46     print "#",join(",",@{ $mysth->{NAME} }),"\n";
47     while (@myarr = $mysth->fetchrow_array() ) {
48     $out=join(",",@myarr);
49     $out=~tr/¹ð¾èæ©Ð®ÈÆ/šðžèæŠÐŽÈÆ/; # iso8859-2 -> 1250
50     print "$out\r\n";
51     }
52    
53     }

  ViewVC Help
Powered by ViewVC 1.1.26