Current Tally Ayes: ".$foobar->ayes." Nays: ".$foobar->nays."

"; return true; } function vote_is_in_progress($userid) { // check whether a vote is already ongoing $now=time(); $query="select count(id) as count from banishment_vote where userid=".$userid." and end_time>".$now; $result = mysql_query($query); if (!$result) { echo "Database error attempting to read banishment_vote table 1.

"; echo "query: $query"; return -1; } $foobar = mysql_fetch_object($result); if (!$foobar) { echo "Database error attempting to read banishment_vote table 2.

"; return -1; } return $foobar->count; } function start_vote($config,$logged_in_user,$user,$category,$reason) { $now=time(); $fin=$now+21600; if ( vote_is_in_progress($user->id) !=0 ) { echo "A banishment vote is already underway for this user.

"; return 0; } $query="insert into banishment_vote (userid,modid,start_time,end_time) values (".$user->id.",".$logged_in_user->id.",".$now.",".$fin.")"; $result = mysql_query($query); if (!$result) { echo "Database error attempting to insert to banishment_vote table.

"; return 0; } $voteid=mysql_insert_id(); $query="insert into banishment_votes (voteid,modid,time,yes) values (". $voteid .",". $logged_in_user->id .",". $now .",1)"; $result = mysql_query($query); if (!$result) { echo "Database error attempting to insert to banishment_votes table.

"; return 0; } $query="update forum_preferences set banished_until=".$fin." where userid=".$user->id; $result = mysql_query($query); echo "Banishment vote started.

"; current_tally($voteid); return send_banish_vote_email($user, 86400*14, $reason, $now+21600); } function vote_yes($config,$logged_in_user,$user) { $now=time(); // Check that a vote is underway. if (vote_is_in_progress($user->id)<1) { echo "No banishment vote is underway for this user.

"; return 0; } // Find the voteid $query="select id as voteid from banishment_vote where userid=".$user->id." and end_time>".$now; $result = mysql_query($query); $foobar = mysql_fetch_object($result); if (!$foobar) { echo "Database error attempting to read banishment_vote table.

"; return 0; } $voteid=$foobar->voteid; // Check whether mod has voted already. $query="select count(id) as count from banishment_votes where voteid=".$voteid." and modid=".$logged_in_user->id; $result = mysql_query($query); $foobar = mysql_fetch_object($result); if (!$foobar) { echo "Database error attempting to read banishment_vote table.

"; return 0; } if ($foobar->count > 0) { echo "You have already voted in this election.

"; current_tally($voteid); return 0; } // insert the vote $query="insert into banishment_votes (voteid,modid,time,yes) values (" . $voteid .",". $logged_in_user->id .",". $now .",1)"; $result = mysql_query($query); if (!$result) { echo "Database error attempting to insert to banishment_votes table.

"; return 0; } echo "Vote recorded: Aye

"; current_tally($voteid); return 1; } function vote_no($config,$logged_in_user,$user) { // Check that a vote is underway. $now=time(); if (vote_is_in_progress($user->id)<1) { echo "No banishment vote is underway for this user.

"; return 0; } // Find the voteid $query="select id as voteid from banishment_vote where userid=".$user->id." and end_time>".$now; $result = mysql_query($query); $foobar = mysql_fetch_object($result); if (!$foobar) { echo "Database error attempting to read banishment_vote table.

"; return 0; } $voteid=$foobar->voteid; // Check whether mod has voted already. $query="select count(id) as count from banishment_votes where voteid=".$voteid ." and modid=".$logged_in_user->id; $result = mysql_query($query); $foobar = mysql_fetch_object($result); if (!$foobar) { echo "Database error attempting to read banishment_vote table.

"; return 0; } if ($foobar->count > 0) { echo "You have already voted in this election.

"; current_tally($voteid); return 0; } // insert the vote $query="insert into banishment_votes (voteid,modid,time,yes) values (" . $voteid .",". $logged_in_user->id .",". $now .",0)"; $result = mysql_query($query); if (!$result) { echo "Database error attempting to insert to banishment_votes table.

"; return 0; } echo "Vote recorded: Nay

"; current_tally($voteid); return 1; } ?>