中國及香港 日本,韓國及南亞 臺灣
#!/usr/bin/perl require '../config.cgi'; use CGI::Carp qw(fatalsToBrowser); %in = (); &ReadParse(%in); print "Content-type: text/html \n\n"; &show_page; sub show_page{ print ""; print ""; $total = 0; $rowcount = 0; if ($in{'start'} >0) {$startVal = $in{'start'}-1;} else {$startVal = $in{'start'};} $endVal = $startVal + $numOfRecordsPerPage; $ranking = $in{'start'}; $volgorde = $in{'volgorde'}; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $mon = $mon+1; if ($mon < 10) {$mon = "0$mon"}; if ($mday < 10){ $mday = "0$mday"}; if ($hour < 10) { $hour = "0$hour"; } if ($min < 10) { $min = "0$min"; } if ($sec < 10) { $sec = "0$sec"; } if ($year =~ 99){$year = 1999;}else{$year = $year + 1900;} $date = "$year$mon"; foreach $fields(@results) { $color = '#000000'; if (($rowcount >= $startVal) && ($rowcount < $endVal)) { $c = $rowcount % 2; @fields = split (/\;/, $fields); print ""; print ""; # flag print ""; # country $url = substr($fields[9],0,7); if ($url ne "http://" && $url ne ""){$website = "http://"."$fields[9]";}else{$website = $fields[9];} print ""; if($fields[9] ne ""){ print ""; print ""; }else {print "";} if($fields[5] ne ""){ print ""; # phone }else{ print ""; } if($fields[6] ne ""){ print ""; # fax }else{ print ""; } if($fields[7] ne ""){ print ""; # email print ""; # fax }else {print "";} print ""; print ""; print ""; print ""; # leeg if($fields[8] ne ""){ print ""; # email print ""; # fax }else {print "";} print ""; print ""; $ranking++; } $rowcount++; $total++; } print ""; print "
$fields[2]
$fields[3]
$fields[4] $fields[4] $fields[5] $fields[6]$fields[7]
$fields[8]
"; } sub ReadParse { local (*in) = @_ if @_; local ($i, $key, $val); if ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN,$in,$ENV{'CONTENT_LENGTH'}); } else { $in = $ENV{'QUERY_STRING'}; if (!$in) { ($in = $ENV{'PATH_INFO'}) =~ s/^\///; } } @in = split(/&/,$in); foreach $i (0 .. $#in) { # Convert plus's to spaces $in[$i] =~ s/\+/ /g; # Split into key and value. ($key, $val) = split(/=/,$in[$i],2); # splits on the first =. # Convert %XX from hex numbers to alphanumeric $key =~ s/%(..)/pack("c",hex($1))/ge; $val =~ s/%(..)/pack("c",hex($1))/ge; # Associate key and value $in{$key} .= "\0" if (defined($in{$key})); # \0 is the multiple separator $in{$key} .= $val; } $db = "distributors"; $numOfRecordsPerPage = 1000; $groep= $in{'groep'}; ##### @results = (); open (DATABASE, "$distributorslijst"); flock(FILE, $LOCK_EX); while () { $row = $_; chop $row; @fields = split (/\;/, $row); # sorteeervelden $sortvelden = "$fields[1]"."$fields[2]"."$fields[4]"; if (($fields[1] eq $in{'groep'}) && $fields[4] ne "-"){ # sorteerveld vooraan plaatsen @nieuwelijst = ($sortvelden,$fields[0],$fields[1],$fields[2],$fields[3],$fields[4],$fields[5],$fields[6],$fields[7],$fields[8],$fields[9],$fields[10],$fields[11],$fields[12]); $sorteer = join ("\;", @nieuwelijst); push (@sorteerlijst, $sorteer); } } # sorteren @gesorteerd = sort @sorteerlijst; ### afdrukken gesorteerde lijst @gesorteerdelijst = (); # in nieuwe array zetten foreach $sorteerlijst(@gesorteerd) { @veld = split (/\;/, $sorteerlijst); @veldlijst = ($veld[1],$veld[2],$veld[3],$veld[4],$veld[5],$veld[6],$veld[7],$veld[8],$veld[9],$veld[10],$veld[11],$veld[12],$veld[13]); $gesorteerdelijst = join ("\;",@veldlijst); $nieuwelijst = "$gesorteerdelijst\n"; push (@results, $nieuwelijst); } close (DATABASE); ##### return length($in); }