https://wikimedia.org.au/w/index.php?title=Election_software/index.php&feed=atom&action=history
Election software/index.php - Revision history
2024-03-29T11:58:49Z
Revision history for this page on the wiki
MediaWiki 1.40.1
https://wikimedia.org.au/w/index.php?title=Election_software/index.php&diff=10841&oldid=prev
Bilby: minor update to ui - merges precluding options with standard generation, adds box to specify number of posts
2013-10-27T04:03:34Z
<p>minor update to ui - merges precluding options with standard generation, adds box to specify number of posts</p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 04:03, 27 October 2013</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l1">Line 1:</td>
<td colspan="2" class="diff-lineno">Line 1:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div><pre></div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div><pre></div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;"></del></div></td><td colspan="2" class="diff-side-added"></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div><?php</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div><?php</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l492">Line 492:</td>
<td colspan="2" class="diff-lineno">Line 491:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> $output .= "<tr><td>".$row['name']."</td>";</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> $output .= "<tr><td>".$row['name']."</td>";</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> $output .= "<td><a href=\"?action=export&category=".$row['id']."\">[Export]</a></td>";</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> $output .= "<td><a href=\"?action=export&category=".$row['id']."\">[Export]</a></td>";</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> $output .= "<td><a href=\"?action=generate&category=".$row['id']."\">[<del style="font-weight: bold; text-decoration: none;">Generate]</a></td>";</del></div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> $output .= "<td><a href=\"?action=generate&category=".$row['id']."\">[<ins style="font-weight: bold; text-decoration: none;">Count</ins>]</a></td>";</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;"> $output .= "<td><a href=\"?action=generatespecial&category=".$row['id']."\">[Preclude Nominees</del>]</a></td>";</div></td><td colspan="2" class="diff-side-added"></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> }</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> }</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> }</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> }</div></td></tr>
<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l506">Line 506:</td>
<td colspan="2" class="diff-lineno">Line 504:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> }</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> }</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> if ($_REQUEST['action'] == "<del style="font-weight: bold; text-decoration: none;">generate</del>")</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> if ($_REQUEST['action'] == "<ins style="font-weight: bold; text-decoration: none;">generatefinalresult</ins>")</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> {</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> {</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> $category = stripslashes($_REQUEST['category']);</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> $category = stripslashes($_REQUEST['category']);</div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> $positions = stripslashes($_REQUEST['positions']);</ins></div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> include ("tally.inc");</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> include ("tally.inc");</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> }</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> }</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> if ($_REQUEST['action'] == "<del style="font-weight: bold; text-decoration: none;">generatespecial</del>")</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> // In some cases, more than one candidate will need to be elected for a category.</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> // For example, five people may be competing for three seats.</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> // Accordingly, we need some code prior to the tally to enter how many positions</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> // are needed. Later this number will be stored in the db, but for now I don't</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> // want to modify the db.</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> if ($_REQUEST['action'] == "<ins style="font-weight: bold; text-decoration: none;">generate</ins>")</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> {</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> {</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> $category = stripslashes($_REQUEST['category']);</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> $category = stripslashes($_REQUEST['category']);</div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> $year = stripslashes($_REQUEST['year']);</ins></div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> $<del style="font-weight: bold; text-decoration: none;">output .</del>= "<del style="font-weight: bold; text-decoration: none;"><p>To remove a nominee from the count, select the nominee in the list below</del>.<del style="font-weight: bold; text-decoration: none;"></p>\n"</del>;</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> // Grab the category details. Make sure that the category exists.</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> $<ins style="font-weight: bold; text-decoration: none;">sql = "SELECT * FROM Categories WHERE id</ins>=".<ins style="font-weight: bold; text-decoration: none;">$category</ins>;</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> $<del style="font-weight: bold; text-decoration: none;">output .</del>= <del style="font-weight: bold; text-decoration: none;">'<form action="'.$defaultpage.'" method="post">';</del></div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> $<ins style="font-weight: bold; text-decoration: none;">result </ins>= <ins style="font-weight: bold; text-decoration: none;">mysql_query(</ins>$<ins style="font-weight: bold; text-decoration: none;">sql)</ins>;</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;"> $output .= '<input type="hidden" name="action" value="generate" />';</del></div></td><td colspan="2" class="diff-side-added"></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;"> $output .= '<input type="hidden" name="category" value="'.</del>$<del style="font-weight: bold; text-decoration: none;">category.'" />'</del>;</div></td><td colspan="2" class="diff-side-added"></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> $<del style="font-weight: bold; text-decoration: none;">output .</del>= <del style="font-weight: bold; text-decoration: none;">"<table cellpadding</del>=<del style="font-weight: bold; text-decoration: none;">\"3\" cellspacing</del>=<del style="font-weight: bold; text-decoration: none;">\"0\" border=\"0\">\n"</del>;</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> <ins style="font-weight: bold; text-decoration: none;">if (</ins>$<ins style="font-weight: bold; text-decoration: none;">result && mysql_num_rows($result) </ins>== <ins style="font-weight: bold; text-decoration: none;">1)</ins></div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;"> </del>$output <del style="font-weight: bold; text-decoration: none;">.</del>= "<<del style="font-weight: bold; text-decoration: none;">tr bgcolor=\</del>"<del style="font-weight: bold; text-decoration: none;">#cccccc\</del>"<del style="font-weight: bold; text-decoration: none;">><th>Name</th><th>Remove</th></del></<del style="font-weight: bold; text-decoration: none;">tr</del>>\n";</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> {</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> $category </ins>= <ins style="font-weight: bold; text-decoration: none;">mysql_fetch_array($result, MYSQL_ASSOC)</ins>;</div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> </ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> </ins>$output = "<<ins style="font-weight: bold; text-decoration: none;">h2>Nominees for </ins>"<ins style="font-weight: bold; text-decoration: none;">.$category['name'].</ins>"</<ins style="font-weight: bold; text-decoration: none;">h2</ins>>\n";</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;"> </del>$sql = "SELECT * FROM Nominees WHERE category = ".$category;</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> </ins>$sql = "SELECT * FROM Nominees WHERE category=".$category<ins style="font-weight: bold; text-decoration: none;">['id']</ins>;</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br/></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;"> </del>$result = mysql_query($sql);</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> </ins>$result = mysql_query($sql)<ins style="font-weight: bold; text-decoration: none;">;</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> </ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> if ($result && mysql_num_rows($result) > 0)</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> { </ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> // Nominees found. Give the help.</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> $output .= "<p>The following are the nominees for this category. If, ";</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> $output .= "for whatever reason, one of these nominees must be precluded, ";</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> $output .= "select the box next to their name. This will remove them ";</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> $output .= "from the election, and any votes will be redistributed.</p>";</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> </ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> $output .= '<form action="'.$defaultpage.'" method="post">';</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> $output .= '<input type="hidden" name="action" value="generatefinalresult" />';</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> $output .= '<input type="hidden" name="category" value="'.$category['id'].'" />';</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> </ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> $output .= "<table><tr><th>Nominee</th><th>Exclude</th></tr>\n";</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> </ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> while ($row = mysql_fetch_array($result, MYSQL_ASSOC))</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> {</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> $output .= "<tr><td>".$row['description']."</td>";</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> $output .= "<td><input type=\"checkbox\" name=\"".$row['id']."_checked\"/></td></tr>\n";</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> }</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> </ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> $output .= "</table>\n";</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> </ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> $output .= "<p>Most categries are expected to have only one winner. ";</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> $output .= "If this category requires more than one winner, increase ";</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> $output .= "the value in the \"Positions available\" box.</p>";</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> </ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> $output .= "<p>Positions available: <input type=\"text\" name=\"positions\" value=\"1\" /></p>\n"</ins>;</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;"> if (</del>$<del style="font-weight: bold; text-decoration: none;">result && mysql_num_rows(</del>$<del style="font-weight: bold; text-decoration: none;">result) </del>> <del style="font-weight: bold; text-decoration: none;">0)</del></div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> </ins>$<ins style="font-weight: bold; text-decoration: none;">output .= '<p><input type="submit" value="Count votes" /></p>';</ins></div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;"> {</del></div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> </ins>$<ins style="font-weight: bold; text-decoration: none;">output .= '</form</ins>><ins style="font-weight: bold; text-decoration: none;">';</ins></div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> <del style="font-weight: bold; text-decoration: none;">while ($row = mysql_fetch_array($result, MYSQL_ASSOC))</del></div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> }</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> <ins style="font-weight: bold; text-decoration: none;">else</ins></div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> {</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> {</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> $output .= "<<del style="font-weight: bold; text-decoration: none;">tr</del>><del style="font-weight: bold; text-decoration: none;"><td>"</del>.<del style="font-weight: bold; text-decoration: none;">$row['description']."</del></<del style="font-weight: bold; text-decoration: none;">td</del>><del style="font-weight: bold; text-decoration: none;">";</del></div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> $output .= "<<ins style="font-weight: bold; text-decoration: none;">p</ins>><ins style="font-weight: bold; text-decoration: none;">No candidates found</ins>.</<ins style="font-weight: bold; text-decoration: none;">p</ins>>\<ins style="font-weight: bold; text-decoration: none;">n</ins>";</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;"> $output .= "<td><input type=\"checkbox</del>\<del style="font-weight: bold; text-decoration: none;">" name=\"".$row['id']."_checked\"/></td></del>";</div></td><td colspan="2" class="diff-side-added"></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> }</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> }</div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> }</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> else</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> {</ins></div></td></tr>
<tr><td colspan="2" class="diff-side-deleted"></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"> $output .= "<p>No category found.</p>\n";</ins></div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> }</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> }</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> <del style="font-weight: bold; text-decoration: none;">$output .= '<p><input type="submit" value="Count votes" </del>/<del style="font-weight: bold; text-decoration: none;">><</del>/<del style="font-weight: bold; text-decoration: none;">p>';</del></div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> //<ins style="font-weight: bold; text-decoration: none;">include ("tally</ins>.<ins style="font-weight: bold; text-decoration: none;">inc")</ins>;</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;"> $output </del>.<del style="font-weight: bold; text-decoration: none;">= '</form>'</del>;</div></td><td colspan="2" class="diff-side-added"></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> }</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> }</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td></tr>
<!-- diff cache key wikimaus_officialwikidb:diff::1.12:old-7693:rev-10841 -->
</table>
Bilby
https://wikimedia.org.au/w/index.php?title=Election_software/index.php&diff=7693&oldid=prev
Bilby: added mailto: per change to source
2012-11-19T04:59:56Z
<p>added mailto: per change to source</p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 04:59, 19 November 2012</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l147">Line 147:</td>
<td colspan="2" class="diff-lineno">Line 147:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> else</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> else</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> {</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> {</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> $output .= '<p><em>An account with those details has already been created. Please contact <a href="'.$email.'">'.$email.'</a> for assistance.</em></p>';</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> $output .= '<p><em>An account with those details has already been created. Please contact <a href="<ins style="font-weight: bold; text-decoration: none;">mailto:</ins>'.$email.'">'.$email.'</a> for assistance.</em></p>';</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> }</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> }</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> }</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> }</div></td></tr>
<!-- diff cache key wikimaus_officialwikidb:diff::1.12:old-6977:rev-7693 -->
</table>
Bilby
https://wikimedia.org.au/w/index.php?title=Election_software/index.php&diff=6977&oldid=prev
Bilby: Minor change to update CSS tags, no change to code.
2012-10-15T03:51:11Z
<p>Minor change to update CSS tags, no change to code.</p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 03:51, 15 October 2012</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l677">Line 677:</td>
<td colspan="2" class="diff-lineno">Line 677:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> foreach($categories as $categoryID => $content)</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> foreach($categories as $categoryID => $content)</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> {</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> {</div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> $form .= '<div class="<del style="font-weight: bold; text-decoration: none;">ditmarcategory</del>"><div class="<del style="font-weight: bold; text-decoration: none;">ditmarcategorytitle</del>">'.$content['name'].'</div>';</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> $form .= '<div class="<ins style="font-weight: bold; text-decoration: none;">votingcategory</ins>"><div class="<ins style="font-weight: bold; text-decoration: none;">votingcategorytitle</ins>">'.$content['name'].'</div>';</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> $form .= "\n";</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> $form .= "\n";</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td></tr>
<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l691">Line 691:</td>
<td colspan="2" class="diff-lineno">Line 691:</td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> // And generate the code. </div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> // And generate the code. </div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td></tr>
<tr><td class="diff-marker" data-marker="−"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> $nomineeText = '<div class="<del style="font-weight: bold; text-decoration: none;">ditmarnominee</del>"><input type="text" name="'.$nomineeDetails['id'].'" size="1" value="'.$votes[$nomineeDetails['id']].'" '.$display.' /> '.$nomineeDetails['description'].'</div>';</div></td><td class="diff-marker" data-marker="+"></td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> $nomineeText = '<div class="<ins style="font-weight: bold; text-decoration: none;">votingnominee</ins>"><input type="text" name="'.$nomineeDetails['id'].'" size="1" value="'.$votes[$nomineeDetails['id']].'" '.$display.' /> '.$nomineeDetails['description'].'</div>';</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> $nomineeText .= "\n";</div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> $nomineeText .= "\n";</div></td></tr>
<tr><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td><td class="diff-marker"></td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td></tr>
</table>
Bilby
https://wikimedia.org.au/w/index.php?title=Election_software/index.php&diff=5377&oldid=prev
Bilby: Added code
2011-09-11T06:01:22Z
<p>Added code</p>
<p><b>New page</b></p><div><pre><br />
<br />
<?php<br />
<br />
include('config.php');<br />
<br />
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');<br />
<br />
mysql_select_db($dbname);<br />
<br />
session_start();<br />
<br />
$output = "";<br />
$access = "standard";<br />
$displayTemplate = true;<br />
<br />
// ------------------------------------------------------------------------------------<br />
// Login code<br />
//<br />
// Covers both creating a new account and logging in once one is created.<br />
// ------------------------------------------------------------------------------------<br />
<br />
// ------------------------------------------------------------------------------------<br />
// Create account<br />
// ------------------------------------------------------------------------------------<br />
<br />
if ($_REQUEST['action'] == "create")<br />
{<br />
// Clean up data submitted in case of problems (especially SQL injection attacks).<br />
$username = stripslashes($_REQUEST['name']);<br />
$useraddress = stripslashes($_REQUEST['address']);<br />
$useremail = stripslashes($_REQUEST['email']);<br />
$username = mysql_real_escape_string($username);<br />
$useraddress = mysql_real_escape_string($useraddress);<br />
$useremail = mysql_real_escape_string($useremail);<br />
<br />
// Make sure that a username was provided.<br />
if ($username != "")<br />
{<br />
// If email was included, load the details based on username and email.<br />
if ($useremail != "")<br />
{<br />
$sql = "SELECT * FROM Voters WHERE name='".$username."' AND email='".$useremail."'";<br />
}<br />
// If not, just rely on the username alone.<br />
else<br />
{<br />
$sql = "SELECT * FROM Voters WHERE name='".$username."'";<br />
}<br />
<br />
$result = mysql_query($sql);<br />
<br />
// Check to see if the details already exist. If a row was returned, they do, and thus<br />
// we can't use the combination, so I'll give an error message below.<br />
// Otherwise we can create the new account.<br />
<br />
if ($result && mysql_num_rows($result) == 0)<br />
{<br />
// This is a tad odd, but I wanted a unique password as it makes me feel a tad safer.<br />
// Thus this auto-generates a password (on the grounds that an auto-generated random<br />
// password is bound to be safer than the typical user-generated one), and then checks<br />
// to see if it already exists by querying the database. The odds are very small, so <br />
// in almost all instances this will just be a minor speed bump, but it makes me feel<br />
// safer. If it does exist a new one will be generated, and it will keep checking.<br />
<br />
// Note that the password is encrypted using a Unix-style crypt function. Thus getting<br />
// access to the db won't give you access to a user's password. Of course, getting<br />
// access to the db is still very bad.<br />
<br />
// Thinking about it, I'm surprised I didn't use a do-while, but I never remember to<br />
// use them. :)<br />
<br />
$passwordcopies = 1;<br />
<br />
while ($passwordcopies > 0)<br />
{<br />
$userpassword = generatePassword(10);<br />
$encryptedUserPassword = crypt($userpassword, $salt);<br />
$sql = "SELECT * FROM Voters WHERE password = '$encryptedUserPassword'";<br />
$result = mysql_query($sql);<br />
$passwordcopies = mysql_num_rows($result);<br />
}<br />
<br />
// Reference code is a unique identifier for the particular user, employed for a single login.<br />
// As it is 20 digits, I'm not so concerned about conflicts. The main role here is to<br />
// cover any cases where someone has logged in, wandered off, and logged in at a different<br />
// computer - the second login generates a new reference code, and thus the old login <br />
// will no longer function. It seemed like a good idea at the time.<br />
<br />
$referencecode = generatePassword(20);<br />
<br />
// Cool. Time to generate the SQL.<br />
<br />
$sql = "INSERT INTO Voters (name, address, ip, lastaccessed, checked, approved, password, email, code) ";<br />
$sql .= "VALUES ('".$username."', '".$useraddress."', '12', Now(), false, false, '".$encryptedUserPassword."', '".$useremail."', '".$referencecode."')";<br />
<br />
mysql_query($sql);<br />
$userid = mysql_insert_id();<br />
<br />
// Register the session variables.<br />
// I've commented out the old approach, but left it here for legacy systems.<br />
//session_register("userid");<br />
//session_register("referencecode");<br />
<br />
$_SESSION['userid'] = $userid;<br />
$_SESSION['referencecode'] = $referencecode;<br />
<br />
// Almost done. Now for the messages. There are two possibilities. If they have entered<br />
// an email address, we can send them an email containing their random password and <br />
// instructions. I do note that sending a secure password over email is a problem, but<br />
// such is the internet. Alternativly, if they didn't enter an email address, they <br />
// get a message but, obviously, don't get an email. I generate that message twice<br />
// just in case later we want to say something different in each situation.<br />
<br />
if ($useremail != "")<br />
{<br />
$message = "Thankyou for registering to vote in the ".$year." Wikimedia Australia elections. ".<br />
"If you would like to change your vote, or if you choose not to ".<br />
"complete the process in one sitting, please visit ".$url." ".<br />
"and enter the code: ".$userpassword;<br />
<br />
$headers = "From: ".$email."\r\n".<br />
"Reply-To: ".$email."\r\n".<br />
"X-Mailer: PHP/".phpversion();<br />
mail($useremail, "WMAU Board Election" , $message, $headers);<br />
<br />
$output .= "<blockquote><em>Thankyou for registering to vote in the ".$year." Wikimedia Australia elections. ".<br />
"If you would like to change your vote once it has been submitted, or if you choose not to ".<br />
"complete the process in one sitting, please revisit this page ".<br />
"and enter the code: </em>".$userpassword."<em> - a copy of which has been sent to your email address.</em></blockquote>";<br />
}<br />
else<br />
{<br />
$output .= "<blockquote><em>Thankyou for registering to vote for the ".$year." Wikimedia Australia elections. ".<br />
"If you would later like to change your vote, or if you choose not to ".<br />
"complete the process in one sitting, please revisit this page ".<br />
"and enter the code: </em>".$userpassword."</blockquote>";<br />
}<br />
<br />
// As they have now registered we provide them with the instructions on what to do next.<br />
<br />
$output .= file_get_contents($instructions);<br />
}<br />
<br />
// Error message in an account with that username or username + email has been previously <br />
// created.<br />
else<br />
{<br />
$output .= '<p><em>An account with those details has already been created. Please contact <a href="'.$email.'">'.$email.'</a> for assistance.</em></p>';<br />
}<br />
}<br />
}<br />
<br />
// ------------------------------------------------------------------------------------<br />
// Login<br />
// ------------------------------------------------------------------------------------<br />
<br />
elseif ($_REQUEST['action'] == "login" && $_REQUEST['password'] != "")<br />
{<br />
// Make sure the submitted data is safe.<br />
$userpassword = stripslashes($_REQUEST['password']);<br />
$userpassword = mysql_real_escape_string($userpassword);<br />
<br />
// Encrypt the password - I store it in encrypted form, so we need to encrypt it here<br />
// to make sure it matches what is in the database, as the crypt function is one way. This<br />
// makes me happy.<br />
$encryptedUserPassword = crypt($userpassword, $salt);<br />
<br />
$sql = "SELECT * FROM Voters WHERE password = '$encryptedUserPassword'";<br />
<br />
$result = mysql_query($sql);<br />
<br />
// Check to see if there is an account with that password and username.<br />
<br />
if ($result && mysql_num_rows($result) == 1)<br />
{<br />
// If there is ...<br />
$row = mysql_fetch_array($result, MYSQL_ASSOC);<br />
$userid = $row['id'];<br />
<br />
// ... generate the session key ...<br />
$referencecode = generatePassword(20);<br />
<br />
// ... register the session variables ...<br />
<br />
$_SESSION['userid'] = $userid;<br />
$_SESSION['referencecode'] = $referencecode;<br />
<br />
//session_register("userid"); // Legacy code<br />
//session_register("referencecode"); // Legacy code<br />
<br />
// ... and update the database with the new code and the current date/time, before ...<br />
$sql = "UPDATE Voters SET lastaccessed=Now(), code='".$referencecode."' WHERE id=".$userid;<br />
mysql_query($sql);<br />
<br />
// ... providing the instructions.<br />
$output .= file_get_contents($instructions);<br />
}<br />
}<br />
<br />
<br />
// ------------------------------------------------------------------------------------<br />
// Voting and Admin Functions<br />
//<br />
// Methods that are used if, and only if, the user has logged in.<br />
// ------------------------------------------------------------------------------------<br />
<br />
// First, check to see if the user has logged in. If not we'll need to give them the introduction <br />
// text instead. Note that this uses the newer isset($_SESSION[]) rather than the older<br />
// session_is_registered(), although I've left the older form commented out for legacy code.<br />
<br />
//if (!session_is_registered("userid"))<br />
if (!isset($_SESSION['userid'])) <br />
{<br />
// $output .= file_get_contents($introform);<br />
$output .= str_replace('ditmar.php', $defaultpage, file_get_contents($introform));<br />
}<br />
<br />
// If they have logged in, we can start doing real work.<br />
else<br />
{<br />
// First, we need to grab their info, as we will need their details.<br />
$sql = "SELECT * FROM Voters WHERE id='".$_SESSION['userid']."'";<br />
<br />
$result = mysql_query($sql);<br />
<br />
// Hopefully someone was returned. If not something has gone horribly wrong.<br />
<br />
if ($result && mysql_num_rows($result) == 1)<br />
{<br />
$row = mysql_fetch_array($result, MYSQL_ASSOC);<br />
<br />
$referencecode = $row['code'];<br />
$access = $row['access'];<br />
<br />
// Quickly check to see if we need to generate the form. We do if they aren't creating an account,<br />
// logging in or haven't specified what the task is.<br />
<br />
if (!isset($_REQUEST['action']) || $_REQUEST['action'] == "login" || $_REQUEST['action'] == "create")<br />
{<br />
if ($access != "admin") // admins can't vote<br />
{<br />
$output .= generateVotingForm($year, $_SESSION['userid']);<br />
}<br />
}<br />
<br />
// Ok. If they don't need the form, what if they need to submit a vote? That's what this is <br />
// for.<br />
<br />
if ($_REQUEST['action'] == "savevotes")<br />
{<br />
$errors = "";<br />
<br />
if ($referencecode == $_SESSION['referencecode'])<br />
{<br />
// Load nominees and votes.<br />
<br />
$categories = loadNominees($year);<br />
$votes = loadVotes($_SESSION['userid']);<br />
<br />
// Cool. Time to cycle through the nominees and record the votes.<br />
<br />
foreach ($categories as $categoryID => $categoryDetails)<br />
{<br />
$numberOfNominees = count($categoryDetails['nominees']);<br />
<br />
$voteCount = "";<br />
$tooBig = false;<br />
$nonInt = false;<br />
<br />
// Loop through the nominees so we can check to see if a value has been added.<br />
<br />
foreach ($categoryDetails['nominees'] as $nomineeDetails)<br />
{<br />
if (!isset($_REQUEST[$nomineeDetails['id']]) || $_REQUEST[$nomineeDetails['id']] == "") { $_REQUEST[$nomineeDetails['id']] = 0; }<br />
<br />
// Make sure that what they submitted was a number. If so we can save it.<br />
<br />
if (is_numeric($_REQUEST[$nomineeDetails['id']]))<br />
{<br />
// Record the vote to check for errors later.<br />
$voteCount[$_REQUEST[$nomineeDetails['id']]]++;<br />
<br />
// Check for a couple of quick errors better handled here.<br />
if ($_REQUEST[$nomineeDetails['id']] > $numberOfNominees) { $tooBig = true; } // Check to see if the numbers end at the right value<br />
else if ($_REQUEST[$nomineeDetails['id']] != intval($_REQUEST[$nomineeDetails['id']])) { $nonInt = true; } // Check to see if the numbers is an int or not<br />
<br />
// Record the vote.<br />
if ($votes[$nomineeDetails['id']] != "")<br />
{<br />
$sql = "UPDATE Votes SET vote = ".$_REQUEST[$nomineeDetails['id']]." WHERE voterid = ".$_SESSION['userid']." AND nomineeid = ".$nomineeDetails['id'];<br />
mysql_query($sql);<br />
}<br />
else<br />
{<br />
$sql = "INSERT INTO Votes (voterid, nomineeid, vote) VALUES (".$_SESSION['userid'].", ".$nomineeDetails['id'].", ".$_REQUEST[$nomineeDetails['id']].")";<br />
mysql_query($sql);<br />
}<br />
}<br />
}<br />
<br />
// Now that we've updated the votes, record the time the votes were entered.<br />
<br />
$sql = "UPDATE Voters SET votesubmitted=Now() WHERE id=".$_SESSION['userid'];<br />
mysql_query($sql);<br />
<br />
$double = false;<br />
$endFound = false;<br />
$falseEnd = false;<br />
<br />
// This checks for come common errors. Note that I saved the values first - that was deliberate, as<br />
// I don't want to loose someone's votes even if they aren't correct. This way<br />
// they don't have to start again.<br />
<br />
for ($i = 1; $i <= $numberOfNominees; $i++)<br />
{<br />
if ($voteCount[$i] > 1) { $double = true; } // Checks for two nominees with the same vote: eg, two in one category getting 3<br />
if ($voteCount[$i] == 0) { $endFound = true; } <br />
else if ($endFound) { $falseEnd = true; } // Checks to see if a number was skipped. Eg. Entering 1, 3, & 4, but not entering a 2.<br />
}<br />
<br />
// Work out the formal error messages.<br />
if ($tooBig || $nonInt || $double || $falseEnd)<br />
{<br />
$errors .= "<p>".$categoryDetails['name']."</p>\n<ul>\n";<br />
<br />
if ($tooBig) { $errors .= "<li>One of your values was too large</li>\n"; }<br />
if ($nonInt) { $errors .= "<li>Only whole numbers are able to be used</li>\n"; }<br />
if ($double) { $errors .= "<li>Two of the nominees have been given the same value</li>\n"; }<br />
if ($falseEnd) { $errors .= "<li>The values need to be sequential, starting from 1</li>\n"; }<br />
<br />
$errors .= "</ul>\n";<br />
}<br />
}<br />
<br />
if ($errors) { $errors = "<p>Some errors were detected in your submission. While your vote has been recorded, you may wish to make some changes.</p>\n\n".$errors; }<br />
}<br />
<br />
if ($_REQUEST['submit'] == "Save and Continue")<br />
{<br />
$output .= "<blockquote><p><em>Your votes have been saved.</em></p>$errors</blockquote>";<br />
$output .= generateVotingForm($year, $_SESSION['userid']);<br />
}<br />
else if ($errors)<br />
{<br />
$output .= "<blockquote><p>Thankyou for your votes. They have been recorded.</p>";<br />
$output .= $errors;<br />
$output .= "<p>If you have the code that was provided to when you you first logged in, you might wish to <a href=\"".$url."?action=logout\">quit</a> and return to make repairs later. ";<br />
$output .= "Otherwise, you can <a href=\"".$url."\">return to the voting form</a> and make some changes now.</p></blockquote>";<br />
}<br />
else<br />
{<br />
$output .= "<blockquote><p>Thankyou for your votes. They have been recorded.</p>";<br />
$output .= "<p>If you have retained the code provided earlier, you will be able to revisit this page should you wish to make changes to your votes. ";<br />
$output .= "</p></blockquote>";<br />
session_destroy();<br />
}<br />
}<br />
<br />
// ------------------------------------------------------------------------------------<br />
// Admin Functions<br />
//<br />
// Methods specifically for an admin.<br />
// ------------------------------------------------------------------------------------<br />
<br />
if ($access == "admin")<br />
{<br />
// Load the admin menu<br />
$menu = file_get_contents($adminmenu);<br />
<br />
// This handles updating voters as they are checked and (hopefully) approved.<br />
<br />
if ($_REQUEST['action'] == "updatevoters")<br />
{<br />
// Grab the voters.<br />
<br />
$sql = "SELECT * FROM Voters";<br />
<br />
$result = mysql_query($sql);<br />
<br />
$recordsUpdated = 0;<br />
<br />
// Loop through them, checking to see if a value was for that one, and update<br />
// the record accordingly.<br />
if ($result && mysql_num_rows($result) > 0)<br />
{<br />
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))<br />
{<br />
$checked = 0;<br />
if ($_REQUEST[$row['id']."_checked"] == "on") { $checked = 1; }<br />
<br />
$approved = 0;<br />
if ($_REQUEST[$row['id']."_approved"] == "on") { $approved = 1; }<br />
<br />
if ($checked != $row['checked'] || $approved != $row['approved'])<br />
{<br />
$sql = "UPDATE Voters SET checked=".$checked.", approved=".$approved." WHERE id=".$row['id'];<br />
mysql_query($sql);<br />
$recordsUpdated++;<br />
}<br />
}<br />
}<br />
<br />
$output .= "<blockquote><em>".$recordsUpdated." records updated.</em></blockquote>\n";<br />
<br />
$_REQUEST['action'] = "voters";<br />
}<br />
<br />
// List all the voters so that we can update their status as they are checked and confirmed.<br />
<br />
if ($_REQUEST['action'] == "voters")<br />
{<br />
$output .= '<form action="'.$defaultpage.'" method="post">';<br />
$output .= '<input type="hidden" name="action" value="updatevoters" />';<br />
<br />
$output .= "<table width=\"100%\" cellpadding=\"2\" cellspacing=\"0\" border=\"0\">\n";<br />
$output .= "<tr><th>Name</th><th>Address</th><th>Email</th><th>Access</th><th>Accessed</th><th>Voted</th><th>Checked</th><th>Approved</th></tr>\n";<br />
<br />
$sql = "SELECT * FROM Voters";<br />
<br />
$result = mysql_query($sql);<br />
<br />
if ($result && mysql_num_rows($result) > 0)<br />
{<br />
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))<br />
{<br />
$output .= "\t<tr>\n";<br />
$output .= "\t\t<td>".$row['name']."</td>\n";<br />
$output .= "\t\t<td>".$row['address']."</td>\n";<br />
$output .= "\t\t<td><a href=\"mailto:".$row['email']."\">".$row['email']."</a></td>\n";<br />
$output .= "\t\t<td>".$row['access']."</td>\n";<br />
$output .= "\t\t<td>".$row['lastaccessed']."</td>\n";<br />
$output .= "\t\t<td><a href=\"?voterid=".$row['id']."&action=display\">".$row['votesubmitted']."</a></td>\n";<br />
$output .= "\t\t<td><input type=\"checkbox\" name=\"".$row['id']."_checked\"";<br />
if ($row['checked']) { $output .= " checked"; }<br />
$output .= " /></td>\n";<br />
$output .= "\t\t<td><input type=\"checkbox\" name=\"".$row['id']."_approved\"";<br />
if ($row['approved']) { $output .= " checked"; }<br />
$output .= " /></td>\n";<br />
$output .= "\t</tr>\n";<br />
}<br />
}<br />
<br />
$output .= "</table>";<br />
$output .= '<p><input type="submit" value="Update" /></p>';<br />
$output .= '</form>';<br />
}<br />
<br />
// Display the votes for a given voter.<br />
<br />
if ($_REQUEST['action'] == "display" && $_REQUEST['voterid'] != "")<br />
{<br />
<br />
$sql = "SELECT * FROM Voters WHERE id=".$_REQUEST['voterid'];<br />
<br />
$result = mysql_query($sql);<br />
<br />
if ($result && mysql_num_rows($result) == 1)<br />
{<br />
$row = mysql_fetch_array($result, MYSQL_ASSOC);<br />
<br />
$output .= "<p><strong>Name:</strong> ".$row['name']."<br />\n";<br />
$output .= "<p><strong>Address:</strong> ".$row['address']."<br />\n";<br />
$output .= "<p><strong>Email:</strong> <a href=\"mailto:".$row['email']."\">".$row['email']."</a><br />\n";<br />
$output .= "<p><strong>Checked:</strong> ";<br />
if ($row['checked']) { $output .= "Yes<br />\n"; } else { $output .= "No<br />\n"; }<br />
$output .= "<p><strong>Approved:</strong> ";<br />
if ($row['approved']) { $output .= "Yes<br />\n"; } else { $output .= "No<br />\n"; }<br />
$output .= "<p><strong>Submitted:</strong> ".$row['votesubmitted']."</p>\n";<br />
<br />
$output .= generateVotingForm($year, $row['id'], false, false);<br />
}<br />
}<br />
<br />
// List the categories in order to generate results<br />
<br />
if ($_REQUEST['action'] == "results")<br />
{<br />
$output .= "<h1>Result Generation</h1>";<br />
<br />
$output .= "<table cellpadding=\"3\" cellspacing=\"0\" border=\"0\">\n";<br />
$output .= "<tr bgcolor=\"#cccccc\"><td colspan=\"3\">Category</td></tr>\n";<br />
<br />
$sql = "SELECT * FROM Categories";<br />
<br />
$result = mysql_query($sql);<br />
<br />
if ($result && mysql_num_rows($result) > 0)<br />
{<br />
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))<br />
{<br />
$output .= "<tr><td>".$row['name']."</td>";<br />
$output .= "<td><a href=\"?action=export&category=".$row['id']."\">[Export]</a></td>";<br />
$output .= "<td><a href=\"?action=generate&category=".$row['id']."\">[Generate]</a></td>";<br />
$output .= "<td><a href=\"?action=generatespecial&category=".$row['id']."\">[Preclude Nominees]</a></td>";<br />
}<br />
}<br />
}<br />
<br />
if ($_REQUEST['action'] == "export")<br />
{<br />
$displayTemplate = false;<br />
$output = "";<br />
$category = stripslashes($_REQUEST['category']);<br />
include ("export.inc");<br />
}<br />
<br />
if ($_REQUEST['action'] == "generate")<br />
{<br />
$category = stripslashes($_REQUEST['category']);<br />
include ("tally.inc");<br />
}<br />
<br />
if ($_REQUEST['action'] == "generatespecial")<br />
{<br />
$category = stripslashes($_REQUEST['category']);<br />
<br />
$output .= "<p>To remove a nominee from the count, select the nominee in the list below.</p>\n";<br />
<br />
$output .= '<form action="'.$defaultpage.'" method="post">';<br />
$output .= '<input type="hidden" name="action" value="generate" />';<br />
$output .= '<input type="hidden" name="category" value="'.$category.'" />';<br />
<br />
$output .= "<table cellpadding=\"3\" cellspacing=\"0\" border=\"0\">\n";<br />
$output .= "<tr bgcolor=\"#cccccc\"><th>Name</th><th>Remove</th></tr>\n";<br />
<br />
$sql = "SELECT * FROM Nominees WHERE category = ".$category;<br />
<br />
$result = mysql_query($sql);<br />
<br />
if ($result && mysql_num_rows($result) > 0)<br />
{<br />
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))<br />
{<br />
$output .= "<tr><td>".$row['description']."</td>";<br />
$output .= "<td><input type=\"checkbox\" name=\"".$row['id']."_checked\"/></td>";<br />
}<br />
}<br />
<br />
$output .= '<p><input type="submit" value="Count votes" /></p>';<br />
$output .= '</form>';<br />
}<br />
<br />
}<br />
<br />
// Logout.<br />
<br />
if ($_REQUEST['action'] == "logoff")<br />
{<br />
$output .= "<p>Thankyou for using the Ditmarator for your WMAU voting needs.</p>";<br />
<br />
unset($_SESSION['userid']);<br />
unset($_SESSION['referencecode']);<br />
}<br />
}<br />
}<br />
<br />
// ------------------------------------------------------------------------------------<br />
// Generate Password<br />
//<br />
// A simple bit of code, using a fairly ugly method, that generates a random combination<br />
// of upper case letters, lower case letters and numbers of a secified length.<br />
// ------------------------------------------------------------------------------------<br />
<br />
function generatePassword($size = 10)<br />
{<br />
$newpassword = "";<br />
<br />
for ($i = 0; $i < $size; $i++)<br />
{<br />
$type = rand(0,2);<br />
<br />
if ($type == 0) { $newpassword .= rand(1,9); }<br />
<br />
if ($type == 1) { $newpassword .= chr(rand(65,90)); }<br />
<br />
if ($type == 2) { $newpassword .= chr(rand(97,122)); }<br />
}<br />
<br />
return $newpassword;<br />
}<br />
<br />
// ------------------------------------------------------------------------------------<br />
// Load Nominees<br />
//<br />
// Loads the nominees and categories for a given year.<br />
// ------------------------------------------------------------------------------------<br />
<br />
function loadNominees($year)<br />
{<br />
// This joins the two tables - nominees and categories - based on category ID, but limits them <br />
// to the current year. Note that the categories have an order number, which they are sorted on.<br />
<br />
$query = "SELECT Nominees.id, Nominees.description, Nominees.category, Categories.name FROM Categories, Nominees WHERE Categories.id = Nominees.category AND year = ".$year." ORDER BY Categories.order, Nominees.id";<br />
$result = mysql_query($query);<br />
<br />
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))<br />
{<br />
// If some categories and nominees were found for the given year, this drops them all into<br />
// a big set of multi-dimensional arrays (objects would be trendier and more robust, but <br />
// this will do) and returns them ready for whatever the calling method had in mind.<br />
<br />
$categories[$row['category']]['name'] = $row['name'];<br />
<br />
$numNominees = count($categories[$row['category']]['nominees']);<br />
<br />
$categories[$row['category']]['nominees'][$numNominees]['id'] = $row['id'];<br />
$categories[$row['category']]['nominees'][$numNominees]['description'] = $row['description']; <br />
}<br />
<br />
return $categories;<br />
}<br />
<br />
// ------------------------------------------------------------------------------------<br />
// Load the votes that have been submitted<br />
//<br />
// Loads all the votes from a given user. Doesn't care about year, but that will be<br />
// fixed when the connection with nominees is made.<br />
// ------------------------------------------------------------------------------------<br />
<br />
function loadVotes($userid)<br />
{<br />
$sql = "SELECT * FROM Votes WHERE voterid = ".$userid;<br />
<br />
$result = mysql_query($sql);<br />
<br />
if ($result && mysql_num_rows($result) > 0)<br />
{<br />
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))<br />
{<br />
$votes[$row['nomineeid']] = $row['vote'];<br />
}<br />
}<br />
<br />
return $votes;<br />
}<br />
<br />
// ------------------------------------------------------------------------------------<br />
// Generate the Voting Form<br />
//<br />
// Generates the voting form by querying the database.<br />
//<br />
// $year: the year to collect the votes for.<br />
// $userid: the user who is about to vote.<br />
// $editable: whether or not this form can be edited. The default is true.<br />
// $random: whether or place nominees for each category in random order. The default is false.<br />
// ------------------------------------------------------------------------------------<br />
<br />
function generateVotingForm($year, $userid, $editable = true, $random = false)<br />
{<br />
// These first two are interesting. The first loads the categories, which I guess<br />
// is less interesting than I originally thought. But the second loads the current<br />
// user's votes. This is cool, as we can now populate the form with what they have<br />
// already entered, so they don't need to start from scratch each time.<br />
<br />
$categories = loadNominees($year);<br />
$votes = loadVotes($userid);<br />
<br />
$form = "";<br />
<br />
// It is possible to generate a display-only form. If it isn't editable, don't add<br />
// the form details. Otherwise we'll need then.<br />
<br />
if ($editable)<br />
{<br />
$form .= '<form action="'.$defaultpage.'" method="post">';<br />
$form .= '<input type="hidden" name="action" value="savevotes" />';<br />
$display = "enabled";<br />
}<br />
else<br />
{<br />
$display = "disabled";<br />
}<br />
<br />
// Cool. Now we loop through all the categories we've loaded ...<br />
<br />
foreach($categories as $categoryID => $content)<br />
{<br />
$form .= '<div class="ditmarcategory"><div class="ditmarcategorytitle">'.$content['name'].'</div>';<br />
$form .= "\n";<br />
<br />
$count = 0;<br />
$noawardText = "";<br />
<br />
// Then loop through all the nominees ...<br />
<br />
foreach ($content['nominees'] as $nomineeDetails)<br />
{<br />
if ($votes[$nomineeDetails['id']] == 0) { $votes[$nomineeDetails['id']] = ""; }<br />
<br />
// And generate the code. <br />
<br />
$nomineeText = '<div class="ditmarnominee"><input type="text" name="'.$nomineeDetails['id'].'" size="1" value="'.$votes[$nomineeDetails['id']].'" '.$display.' /> '.$nomineeDetails['description'].'</div>';<br />
$nomineeText .= "\n";<br />
<br />
// No Award is a special case, so this manages it. The aim is for "No award"<br />
// always to come last, even if the listing is random, so we need to identify<br />
// which nominee it is and treat it separately.<br />
<br />
if ($nomineeDetails['description'] == "No Award")<br />
{<br />
$noawardText = $nomineeText;<br />
}<br />
else<br />
{<br />
$nomineeCode[$count++] = $nomineeText;<br />
}<br />
}<br />
<br />
// If it is to be random, this handles the random order for the nominees.<br />
<br />
if ($random)<br />
{<br />
for ($i = 0; $i < $count; $i++)<br />
{<br />
$chosen = rand(0,count($nomineeCode)-1);<br />
$form .= $nomineeCode[$chosen];<br />
for ($j = $chosen; $j < count($nomineeCode) - 1; $j++)<br />
{<br />
$nomineeCode[$j] = $nomineeCode[$j+1]; <br />
}<br />
unset($nomineeCode[count($nomineeCode)-1]);<br />
}<br />
}<br />
<br />
// Otherwise we just add them in order.<br />
else<br />
{<br />
for ($i = 0; $i < $count; $i++)<br />
{<br />
$form .= $nomineeCode[$i];<br />
}<br />
}<br />
<br />
// No Award is added to the end whatever happens.<br />
$form .= $noawardText;<br />
<br />
$form .= "</div>\n";<br />
}<br />
<br />
// Finish off the form stuff.<br />
<br />
if ($editable)<br />
{<br />
$form .= '<p><input type="submit" name="submit" value="Save and Continue" />';<br />
$form .= ' <input type="submit" name="submit" value="Save and Quit" /></p>';<br />
$form .= '</form>';<br />
}<br />
<br />
return $form;<br />
}<br />
<br />
if($displayTemplate) { include($template); }<br />
<br />
mysql_close($conn);<br />
<br />
?><br />
</pre></div>
Bilby