Index: trunk/extensions/SecurePoll/cacert-both.crt |
— | — | @@ -1,76 +0,0 @@ |
2 | | -MIIGCDCCA/CgAwIBAgIBATANBgkqhkiG9w0BAQQFADB5MRAwDgYDVQQKEwdSb290 |
3 | | -IENBMR4wHAYDVQQLExVodHRwOi8vd3d3LmNhY2VydC5vcmcxIjAgBgNVBAMTGUNB |
4 | | -IENlcnQgU2lnbmluZyBBdXRob3JpdHkxITAfBgkqhkiG9w0BCQEWEnN1cHBvcnRA |
5 | | -Y2FjZXJ0Lm9yZzAeFw0wNTEwMTQwNzM2NTVaFw0zMzAzMjgwNzM2NTVaMFQxFDAS |
6 | | -BgNVBAoTC0NBY2VydCBJbmMuMR4wHAYDVQQLExVodHRwOi8vd3d3LkNBY2VydC5v |
7 | | -cmcxHDAaBgNVBAMTE0NBY2VydCBDbGFzcyAzIFJvb3QwggIiMA0GCSqGSIb3DQEB |
8 | | -AQUAA4ICDwAwggIKAoICAQCrSTURSHzSJn5TlM9Dqd0o10Iqi/OHeBlYfA+e2ol9 |
9 | | -4fvrcpANdKGWZKufoCSZc9riVXbHF3v1BKxGuMO+f2SNEGwk82GcwPKQ+lHm9WkB |
10 | | -Y8MPVuJKQs/iRIwlKKjFeQl9RrmK8+nzNCkIReQcn8uUBByBqBSzmGXEQ+xOgo0J |
11 | | -0b2qW42S0OzekMV/CsLj6+YxWl50PpczWejDAz1gM7/30W9HxM3uYoNSbi4ImqTZ |
12 | | -FRiRpoWSR7CuSOtttyHshRpocjWr//AQXcD0lKdq1TuSfkyQBX6TwSyLpI5idBVx |
13 | | -bgtxA+qvFTia1NIFcm+M+SvrWnIl+TlG43IbPgTDZCciECqKT1inA62+tC4T7V2q |
14 | | -SNfVfdQqe1z6RgRQ5MwOQluM7dvyz/yWk+DbETZUYjQ4jwxgmzuXVjit89Jbi6Bb |
15 | | -6k6WuHzX1aCGcEDTkSm3ojyt9Yy7zxqSiuQ0e8DYbF/pCsLDpyCaWt8sXVJcukfV |
16 | | -m+8kKHA4I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ciBGUkVFIGhlYWQg |
62 | | -b3ZlciB0byBodHRwOi8vd3d3LmNhY2VydC5vcmcwDQYJKoZIhvcNAQEEBQADggIB |
63 | | -ACjH7pyCArpcgBLKNQodgW+JapnM8mgPf6fhjViVPr3yBsOQWqy1YPaZQwGjiHCc |
64 | | -nWKdpIevZ1gNMDY75q1I08t0AoZxPuIrA2jxNGJARjtT6ij0rPtmlVOKTV39O9lg |
65 | | -18p5aTuxZZKmxoGCXJzN600BiqXfEVWqFcofN8CCmHBh22p8lqOOLlQ+TyGpkO/c |
66 | | -gr/c6EWtTZBzCDyUZbAEmXZ/4rzCahWqlwQ3JNgelE5tDlG+1sSPypZt90Pf6DBl |
67 | | -Jzt7u0NDY8RD97LsaMzhGY4i+5jhe1o+ATc7iwiwovOVThrLm82asduycPAtStvY |
68 | | -sONvRUgzEv/+PDIqVPfE94rwiCPCR/5kenHA0R6mY7AHfqQv0wGP3J8rtsYIqQ+T |
69 | | -SCX8Ev2fQtzzxD72V7DX3WnRBnc0CkvSyqD/HMaMyRa+xMwyN2hzXwj7UfdJUzYF |
70 | | -CpUCTPJ5GhD22Dp1nPMd8aINcGeGG7MW9S/lpOt5hvk9C8JzC6WZrG/8Z7jlLwum |
71 | | -GCSNe9FINSkYQKyTYOGWhlC0elnYjyELn8+CkcY7v2vcB5G5l1YjqrZslMZIBjzk |
72 | | -zk6q5PYvCdxTby78dOs6Y5nCpqyJvKeyRKANihDjbPIky/qbn3BHLt4Ui9SyIAmW |
73 | | -omTxJBzcoTWcFbLUvFUufQb1nA5V9FrWk9p2rSVzTMVD |
Index: trunk/extensions/SecurePoll/tally.php |
— | — | @@ -1,295 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -if ( php_sapi_name() != 'cli' ) { |
5 | | - die( "" ); |
6 | | -} |
7 | | - |
8 | | -if ( !isset( $argv[1] ) ) { |
9 | | - die( "You must provide a vote log file on the command line.\n" ); |
10 | | -} |
11 | | - |
12 | | -$boardCandidates = array(); |
13 | | -/* |
14 | | -$boardCandidates = array( "John Doe" => "A", |
15 | | - "Jane Doe" => "B", |
16 | | - "Joe Bloggs" => "C", |
17 | | - "John Smith" => "D", |
18 | | - "A. N. Other" => "E" ); |
19 | | -*/ |
20 | | - |
21 | | -$end = "-----END PGP MESSAGE-----"; |
22 | | -$contents = file_get_contents( $argv[1] ); |
23 | | -if ( $contents === false ) { |
24 | | - die( "Couldn't open input file.\n" ); |
25 | | -} |
26 | | -$entries = explode( $end, $contents ); |
27 | | - |
28 | | -$infile = tempnam( "/tmp", "gpg" ); |
29 | | -$outfile = tempnam( "/tmp", "gpg" ); |
30 | | - |
31 | | -if ( !isset( $argv[2] ) ) { |
32 | | - $votesfile = "results.txt"; |
33 | | -} else { |
34 | | - $votesfile = $argv[2]; |
35 | | -} |
36 | | -$vfs = fopen( $votesfile, "w" ); |
37 | | -fwrite( $vfs, "== Candidates ==\n" ); |
38 | | -foreach ( $boardCandidates as $name => $index ) { |
39 | | - fwrite( $vfs, "* Candidate " . $index . " : " . $name . "\n" ); |
40 | | -} |
41 | | -fwrite( $vfs, "\n== Votes ==\n" ); |
42 | | - |
43 | | -foreach ( $entries as $i => $entry ) { |
44 | | - $entry = trim( $entry . $end ); |
45 | | - |
46 | | - if ( $entry == $end ) { |
47 | | - continue; |
48 | | - } |
49 | | -# print "{{{$entry}}}\n\n"; |
50 | | - $file = fopen( $infile, "w" ); |
51 | | - fwrite( $file, trim( $entry ) . "\n" ); |
52 | | - fclose( $file ); |
53 | | - `gpg -q --batch --yes -do $outfile $infile`; |
54 | | - $lines = file( $outfile ); |
55 | | - $ballot = process_line( $lines[0] ); |
56 | | - $ballots[ $i ] = $ballot; |
57 | | - |
58 | | - asort( $ballot ); |
59 | | - $vote = "# "; |
60 | | - $aliasBallot =& $ballot; |
61 | | - foreach ( $aliasBallot as $cname => $crank ) { |
62 | | - $vote .= $boardCandidates[ $cname ]; |
63 | | - |
64 | | - $ncrank = current( $aliasBallot ); // current() return the next element for an array alias inside a foreach() |
65 | | - if ( $ncrank ) { |
66 | | - $vote .= ( $crank < $ncrank ) ? "," : ""; |
67 | | - } |
68 | | - } |
69 | | - fwrite( $vfs, $vote . "\n" ); |
70 | | -} |
71 | | - |
72 | | -unlink( $infile ); |
73 | | -unlink( $outfile ); |
74 | | - |
75 | | -$defeatMatrix = get_defeat_matrix( $ballots ); |
76 | | - |
77 | | -$wvMatrix = get_wv_matrix( $defeatMatrix ); |
78 | | -$marginMatrix = get_margin_matrix( $defeatMatrix ); |
79 | | - |
80 | | -$beatpathWVMatrix = $wvMatrix; |
81 | | -$beatpathMMatrix = $marginMatrix; |
82 | | -get_wvm_beatpath_matrix( $beatpathWVMatrix, $beatpathMMatrix ); |
83 | | - |
84 | | -$orderedCandidates = sort_candidate_by_wins( $boardCandidates, $beatpathWVMatrix, $beatpathMMatrix ); |
85 | | - |
86 | | -# ## Output results ### |
87 | | -fwrite( $vfs, "== Pairwise defeats matrix ==\n" ); |
88 | | -output_table( $vfs, $defeatMatrix ); |
89 | | -fwrite( $vfs, "\nFor the above table, a row beats a column by N votes.\n\n" . |
90 | | - "== Strengths of the direct paths ==\n=== Winning votes ===\n" ); |
91 | | -output_table( $vfs, $wvMatrix ); |
92 | | -fwrite( $vfs, "\n=== Margins ===\n" ); |
93 | | -output_table( $vfs, $marginMatrix ); |
94 | | -fwrite( $vfs, "\n== Strengths of the strongest paths ==\n=== Winning votes ===\n" ); |
95 | | -output_table( $vfs, $beatpathWVMatrix ); |
96 | | -fwrite( $vfs, "\n=== Modified Margins ===\n" ); |
97 | | -output_table( $vfs, $beatpathMMatrix ); |
98 | | -fwrite( $vfs, "\n== Ranked results ==\n" ); |
99 | | -array_flip( $orderedCandidates ); |
100 | | -foreach ( $orderedCandidates as $winner => $l ) { |
101 | | - fwrite( $vfs, "# " . $winner . "\n" ); |
102 | | -} |
103 | | - |
104 | | -fclose( $vfs ); |
105 | | - |
106 | | -# ----------------------------------------------------------- |
107 | | - |
108 | | -function process_line( $line ) { |
109 | | - $importantBit = substr( $line, strpos( $line, ":" ) + 1 ); |
110 | | - $set = array_map( "trim", explode( ",", $importantBit ) ); |
111 | | - |
112 | | - foreach ( $set as $i ) { |
113 | | - $rank = substr( $i, strpos( $i, "[" ) + 1 ); |
114 | | - $rank = substr( $rank, 0, -1 ); |
115 | | - |
116 | | - $ballot[ substr( $i, 0, - ( strlen( $rank ) + 2 ) ) ] = (int)$rank; |
117 | | - // ^^^ |
118 | | - // '[',']' |
119 | | - } |
120 | | - |
121 | | - return $ballot; |
122 | | -} |
123 | | - |
124 | | -function get_defeat_matrix( $ballots ) { |
125 | | - global $boardCandidates; |
126 | | - foreach ( $boardCandidates as $c => $ci ) { |
127 | | - foreach ( $boardCandidates as $opp => $oi ) { |
128 | | - $defeats[ $c ][ $opp ] = 0; |
129 | | - } |
130 | | - } |
131 | | - |
132 | | - foreach ( $ballots as $ballot ) { |
133 | | - foreach ( $ballot as $candidate => $rank ) { |
134 | | - foreach ( $ballot as $opponent => $oppRank ) { |
135 | | - if ( $candidate != $opponent ) { |
136 | | - if ( $rank < $oppRank ) { |
137 | | - $defeats[ $candidate ][ $opponent ]++; |
138 | | - } |
139 | | - } |
140 | | - } |
141 | | - } |
142 | | - } |
143 | | - |
144 | | - return $defeats; |
145 | | -} |
146 | | - |
147 | | -function get_wv_matrix( $defeats ) { |
148 | | - global $boardCandidates; |
149 | | - foreach ( $boardCandidates as $c => $ci ) { |
150 | | - foreach ( $boardCandidates as $opp => $oi ) { |
151 | | - $matrix[ $c ][ $opp ] = 0; |
152 | | - } |
153 | | - } |
154 | | - |
155 | | - foreach ( $defeats as $candidate => $opponents ) { |
156 | | - foreach ( $opponents as $opponent => $votes ) { |
157 | | - if ( $candidate != $opponent ) { |
158 | | - if ( $votes > $defeats[ $opponent ][ $candidate ] ) { |
159 | | - $matrix[ $candidate ][ $opponent ] = $votes; |
160 | | - $matrix[ $opponent ][ $candidate ] = 0; |
161 | | - } |
162 | | - } |
163 | | - } |
164 | | - } |
165 | | - |
166 | | - return $matrix; |
167 | | -} |
168 | | - |
169 | | -function get_margin_matrix( $defeats ) { |
170 | | - global $boardCandidates; |
171 | | - foreach ( $boardCandidates as $c => $ci ) { |
172 | | - foreach ( $boardCandidates as $opp => $oi ) { |
173 | | - $matrix[ $c ][ $opp ] = 0; |
174 | | - } |
175 | | - } |
176 | | - |
177 | | - foreach ( $defeats as $candidate => $opponents ) { |
178 | | - foreach ( $opponents as $opponent => $votes ) { |
179 | | - if ( $candidate != $opponent ) { |
180 | | - if ( $votes > $defeats[ $opponent ][ $candidate ] ) { |
181 | | - $matrix[ $candidate ][ $opponent ] = $votes - $defeats[ $opponent ][ $candidate ]; |
182 | | - $matrix[ $opponent ][ $candidate ] = 0; |
183 | | - } |
184 | | - } |
185 | | - } |
186 | | - } |
187 | | - |
188 | | - return $matrix; |
189 | | -} |
190 | | - |
191 | | -function get_beatpath_matrix( $pairwise ) { |
192 | | - foreach ( $paths as $c => $opps ) { |
193 | | - foreach ( $opps as $opp => $dummy1 ) { |
194 | | - if ( $c != $opp ) { |
195 | | - foreach ( $opps as $k => $dummy2 ) { |
196 | | - if ( ( $c != $k ) && ( $opp != $k ) ) { |
197 | | - $paths[ $opp ][ $k ] = max( $paths[ $opp ][ $k ], |
198 | | - min( $paths[ $opp ][ $c ], $paths[ $c ][ $k ] ) ); |
199 | | - } |
200 | | - } |
201 | | - } |
202 | | - } |
203 | | - } |
204 | | - |
205 | | - return $paths; |
206 | | -} |
207 | | - |
208 | | -# Winning votes determine victory strength, with margins as a tiebreaker. |
209 | | -function get_wvm_beatpath_matrix( &$wvp, &$mp ) { |
210 | | - foreach ( $wvp as $c => $opps ) { |
211 | | - foreach ( $opps as $opp => $dummy1 ) { |
212 | | - if ( $c != $opp ) { |
213 | | - foreach ( $opps as $k => $dummy2 ) { |
214 | | - if ( ( $c != $k ) && ( $opp != $k ) ) { |
215 | | - if ( ( $wvp[ $c ][ $k ] < $wvp[ $opp ][ $c ] ) || |
216 | | - ( ( $wvp[ $c ][ $k ] == $wvp[ $opp ][ $c ] ) && |
217 | | - ( $mp[ $c ][ $k ] < $mp[ $opp ][ $c ] ) ) ) { |
218 | | - $wvipath = $wvp[ $c ][ $k ]; |
219 | | - $mipath = $mp[ $c ][ $k ]; |
220 | | - } else { |
221 | | - $wvipath = $wvp[ $opp ][ $c ]; |
222 | | - $mipath = $mp[ $opp ][ $c ]; |
223 | | - } |
224 | | - |
225 | | - if ( ( $wvp[ $opp ][ $k ] < $wvipath ) || |
226 | | - ( ( $wvp[ $opp ][ $k ] == $wvipath ) && |
227 | | - ( $mp[ $opp ][ $k ] < $mipath ) ) ) { |
228 | | - $wvp[ $opp ][ $k ] = $wvipath; |
229 | | - $mp[ $opp ][ $k ] = $mipath; |
230 | | - } |
231 | | - } |
232 | | - } |
233 | | - } |
234 | | - } |
235 | | - } |
236 | | -} |
237 | | - |
238 | | -function sort_candidate_by_wins( $candidates, $wvpaths, $mpaths ) { |
239 | | - if ( count ( $candidates ) == 0 ) { |
240 | | - return array(); |
241 | | - } |
242 | | - |
243 | | - $winners = $candidates; |
244 | | - |
245 | | - foreach ( $candidates as $c => $dummy1 ) { |
246 | | - foreach ( $candidates as $opp => $dummy2 ) { |
247 | | - if ( $c != $opp ) { |
248 | | - if ( ( $wvpaths[ $c ][ $opp ] > $wvpaths[ $opp ][ $c ] ) || |
249 | | - ( ( $wvpaths[ $c ][ $opp ] == $wvpaths[ $opp ][ $c ] ) && |
250 | | - ( $mpaths[ $c ][ $opp ] > $mpaths[ $opp ][ $c ] ) ) ) { |
251 | | - unset( $winners[ $opp ] ); |
252 | | - } |
253 | | - } |
254 | | - } |
255 | | - } |
256 | | - |
257 | | - if ( count( $winners ) > 1 ) { |
258 | | - $ties = ""; |
259 | | - foreach ( $winners as $wname => $wl ) { |
260 | | - $ties .= ( $wname . ", " ); |
261 | | - } |
262 | | - $ties = substr( $ties, 0, -2 ); |
263 | | - |
264 | | - print "Ties between : " . $ties . "\n"; |
265 | | - } |
266 | | - |
267 | | - foreach ( $winners as $w => $l ) { |
268 | | - unset( $candidates[ $w ] ); |
269 | | - } |
270 | | - |
271 | | - return ( $winners + sort_candidate_by_wins( $candidates, $wvpaths, $mpaths ) ); |
272 | | -} |
273 | | - |
274 | | -function output_table( &$fs, &$matrix ) { |
275 | | - global $boardCandidates; |
276 | | - |
277 | | - $line = "{| class=\"wikitable\" style=\"text-align:center\"\n|-\n! \n"; |
278 | | - foreach ( $boardCandidates as $name => $idx ) { |
279 | | - $line .= ( "! " . $idx . "\n" ); |
280 | | - } |
281 | | - $line .= "|-\n"; |
282 | | - foreach ( $matrix as $c => $opponents ) { |
283 | | - $line .= ( "| '''" . $boardCandidates[ $c ] . "'''\n" ); |
284 | | - foreach ( $opponents as $o => $val ) { |
285 | | - if ( $c == $o ) { |
286 | | - $line .= "| -\n"; |
287 | | - } else { |
288 | | - $line .= ( "| " . $matrix[ $c ][ $o ] . "\n" ); |
289 | | - } |
290 | | - } |
291 | | - $line .= "|-\n"; |
292 | | - } |
293 | | - $line .= "|}\n"; |
294 | | - |
295 | | - fwrite( $fs, $line ); |
296 | | -} |