/[ldap]/html/vizitka.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

Diff of /html/vizitka.cgi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by dpavlin, Wed May 24 17:39:36 2000 UTC revision 1.3 by dpavlin, Wed May 24 18:37:26 2000 UTC
# Line 25  $ldap->bind;   # anonymous Line 25  $ldap->bind;   # anonymous
25  0x0160 => '©', 0x0110 => 'Ð', 0x010c => 'È', 0x0106 => 'Æ', 0x017d => '®'  0x0160 => '©', 0x0110 => 'Ð', 0x010c => 'È', 0x0106 => 'Æ', 0x017d => '®'
26  );  );
27    
28    %iso2utf_tab = (
29    '¹' => 0x0161, 'ð' => 0x0111, 'è' => 0x010d, 'æ' => 0x0107, '¾' => 0x017e,
30    '©' => 0x0160, 'Ð' => 0x0110, 'È' => 0x010c, 'Æ' => 0x0106, '®' => 0x017d
31    );
32    
33  sub utf2iso {  sub utf2iso {
34          my $out;          local($_)=@_;
35          foreach (@_) {          s/([\xC0-\xDF])([\x80-\xBF])/$utf2iso_tab{unpack("c",$1)<<6&0x07C0|unpack("c",$2)&0x003F}/ge;
36                  s/([\xC0-\xDF])([\x80-\xBF])/$utf2iso_tab{unpack("c",$1)<<6&0x07C0|unpack("c",$2)&0x003F}/ge;          s/([\xE0-\xEF])([\x80-\xBF])([\x80-\xBF])/$utf2iso_tab{unpack("c",$1)<<12&0xF000|unpack("c",$2)<<6&0x0FC0|unpack("c",$3)&0x003F}/ge;
37                  s/([\xE0-\xEF])([\x80-\xBF])([\x80-\xBF])/$utf2iso_tab{unpack("c",$1)<<12&0xF000|unpack("c",$2)<<6&0x0FC0|unpack("c",$3)&0x003F}/ge;          s/([\xF0-\xF7])([\x80-\xBF])([\x80-\xBF])([\x80-\xBF])/$utf2iso_tab{unpack("c",$1)<<18&0x1C0000|unpack("c",$2)<<12&0x3F000|unpack("c",$3)<<6&0x0FC0|unpack("c",$4)&0x003F}/ge;
38                  s/([\xF0-\xF7])([\x80-\xBF])([\x80-\xBF])([\x80-\xBF])/$utf2iso_tab{unpack("c",$1)<<18&0x1C0000|unpack("c",$2)<<12&0x3F000|unpack("c",$3)<<6&0x0FC0|unpack("c",$4)&0x003F}/ge;          return $_;
39                  $out.=$_;  }
40    sub iso2utf {
41            local($_)=@_;
42    
43            sub utf8 {
44                    local($_)=@_;
45                    return $_ < 0x80 ? chr($_) :
46                     $_ < 0x800 ? chr($_>>6&0x3F|0xC0) . chr($_&0x3F|0x80) :
47                      chr($_>>12&0x0F|0xE0).chr($_>>6&0x3F|0x80).chr($_&0x3F|0x80);
48          }          }
49          return $out;          s/([¹ðè澩ÐÈÆ®])/utf8($iso2utf_tab{$1})/ge;
50            return $_;
51  }  }
52    
53  print  print
54  #       header(-type => 'text/html;charset=UTF-8'),          header(-type => 'text/html;charset=ISO-8859-2'),
         header,  
55          start_html('Naruèivanje vizitki'),          start_html('Naruèivanje vizitki'),
56          start_form,          start_form,
57          "Upi¹ite svoje ",popup_menu(-name=>'what',          "Upi¹ite svoje ",popup_menu(-name=>'what',
# Line 54  print Line 67  print
67  if(param()) {  if(param()) {
68          $mesg = $ldap->search (          $mesg = $ldap->search (
69                  base    => 'o=agrokor.hr',                  base    => 'o=agrokor.hr',
70                  filter  => param('what').'='.param('search')                  filter  => param('what').'='.iso2utf(param('search'))
71                  );                  );
72          my $max = $mesg->count;          my $max = $mesg->count;
73          if ($max > 1) {          if ($max > 1) {
# Line 83  if(param()) { Line 96  if(param()) {
96                  print b("Nije naðena niti jedna osoba");                  print b("Nije naðena niti jedna osoba");
97          } else {                  } else {        
98                  my $entry = $mesg->entry(0);                  my $entry = $mesg->entry(0);
99                  my @data = ( $entry->get('cn') );                  my @data = ( utf2iso($entry->get('cn')) );
100                  sub add_opt {                  sub add_opt {
101                          ($label,$data) = @_;                          ($label,$data) = @_;
102                          if ($data) {                          if ($data) {
103                                  push @data,"$label $data";                                  push @data,"$label ".utf2iso($data);
104                          }                          }
105                  }                  }
106                  add_opt "",$entry->get('ou');                  add_opt "",$entry->get('ou');
# Line 97  if(param()) { Line 110  if(param()) {
110                  add_opt "tel: ",$entry->get('telephonenumber');                  add_opt "tel: ",$entry->get('telephonenumber');
111                  add_opt "fax: ",$entry->get('facsimiletelephonenumber');                  add_opt "fax: ",$entry->get('facsimiletelephonenumber');
112  #               add_opt ": ",$entry->get('');  #               add_opt ": ",$entry->get('');
113                  push @data,"Narudzba za ".param("kom")." komada\n";                  push @data,"Narud¾ba za ".param("kom")." komada\n";
114                  print join("<br>\n",@data);                  print join("<br>\n",@data);
115                  open(MAIL,"|/usr/lib/sendmail $email");                  open(MAIL,"|/usr/lib/sendmail $email");
116                  print MAIL join("\n",@data);                  print MAIL join("\n",@data);

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

  ViewVC Help
Powered by ViewVC 1.1.26