Index: trunk/extensions/BoardVote/tally.php |
— | — | @@ -15,8 +15,7 @@ |
16 | 16 | } |
17 | 17 | $entries = explode( $end, $contents ); |
18 | 18 | |
19 | | -$ctally = array(); |
20 | | -$vtally = array(); |
| 19 | +$tally = array(); |
21 | 20 | $infile = tempnam( "/tmp", "gpg" ); |
22 | 21 | $outfile = tempnam( "/tmp", "gpg" ); |
23 | 22 | |
— | — | @@ -30,40 +29,26 @@ |
31 | 30 | $file = fopen( $infile, "w" ); |
32 | 31 | fwrite( $file, trim( $entry ) . "\n" ); |
33 | 32 | fclose( $file ); |
34 | | - `gpg --batch --yes -do $outfile $infile`; |
| 33 | + `gpg -q --batch --yes -do $outfile $infile`; |
35 | 34 | $lines = file( $outfile ); |
36 | | - $cset = process_line( $lines[0] ); |
37 | | - $vset = process_line( $lines[1] ); |
38 | | - foreach ( $cset as $c ) { |
39 | | - if ( !array_key_exists( $c, $ctally ) ) { |
40 | | - $ctally[$c] = 0; |
| 35 | + $set = process_line( $lines[0] ); |
| 36 | + foreach ( $set as $c ) { |
| 37 | + if ( !array_key_exists( $c, $tally ) ) { |
| 38 | + $tally[$c] = 0; |
41 | 39 | } |
42 | | - $ctally[$c]++; |
| 40 | + $tally[$c]++; |
43 | 41 | } |
44 | | - foreach ( $vset as $v ) { |
45 | | - if ( !array_key_exists( $v, $vtally ) ) { |
46 | | - $vtally[$v] = 0; |
47 | | - } |
48 | | - |
49 | | - $vtally[$v]++; |
50 | | - } |
51 | 42 | } |
52 | 43 | |
53 | 44 | unlink( $infile ); |
54 | 45 | unlink( $outfile ); |
55 | 46 | |
56 | | -arsort( $ctally ); |
57 | | -arsort( $vtally ); |
| 47 | +arsort( $tally ); |
58 | 48 | |
59 | | -print "Contributing representative\n"; |
60 | | -foreach ( $ctally as $candidate => $tally ) { |
61 | | - printf( "%-30s%d\n", $candidate, $tally ); |
| 49 | +foreach ( $tally as $candidate => $count ) { |
| 50 | + printf( "%-30s%d\n", $candidate, $count ); |
62 | 51 | } |
63 | 52 | |
64 | | -print "\nVolunteer representative\n"; |
65 | | -foreach ( $vtally as $candidate => $tally ) { |
66 | | - printf( "%-30s%d\n", $candidate, $tally ); |
67 | | -} |
68 | 53 | |
69 | 54 | #----------------------------------------------------------- |
70 | 55 | |