$o.="\t<tr><td align=\"center\" colspan=\"2\">".floor($dfout[2]/1024)."GB used of ".floor($dfout[1]/1024)."GB (".floor($dfout[3]/1024)."GB available)</td></tr>\n";
$o.="\t<tr><td align=\"center\" colspan=\"2\">".floor($dfout[2]/1024)."GB used of ".floor($dfout[1]/1024)."GB (".floor($dfout[3]/1024)."GB available)</td></tr>\n";
trigger_error("You are not logged in.",E_USER_WARNING);
# You can't vote if you're not logged in!
trigger_error("You are not logged in.",E_USER_WARNING);
}else{
# The election hasn't started yet
if(strtotime('now')<strtotime(ELECTION_START))trigger_error("The polling station is not yet open. Voting begins on ".date('l jS F, Y \a\t H:i',strtotime(ELECTION_START)).".");
# The election is over - display the results
elseif(strtotime('now')>strtotime(ELECTION_END)){
require_once("../lib/members.php");
$members=newMembers;
$role=$DB->GetAll("SELECT post FROM election_candidates GROUP BY post");
foreach($roleas$post){
$candidate[$post['post']]=$DB->GetAll("SELECT username, manifesto_link FROM election_candidates WHERE post=?",$post['post']);
$candidate[$post['post']][$i]['votes']=$DB->GetOne("SELECT count(username) FROM election_votes WHERE ".$post['post']."=?",array($person['username']));
$i++;
}
}
$smarty->assign("candidate",$candidate);
$output=$smarty->fetch('election-results.tpl');
}else{
# It's election time
# Check the user hasn't already voted
$vote_details=$DB->GetRow("SELECT time, ipaddress FROM election_votes WHERE username=?",$session->username);
if(count($vote_details)>0){
trigger_error("You already voted on ".date('l jS F, Y \a\t H:i',strtotime($vote_details['time']))." from IP address ".$vote_details['ipaddress'].".",E_USER_WARNING);
$output="<p>Please email the Returning Officer at <a href=\"mailto:vote@sucs.org\">vote@sucs.org</a> with any queries.</p>\n<p>Once polling has closed on ".date('l jS F, Y \a\t H:i',strtotime(ELECTION_END)).", the election results will be available on this page.</p>";
}else{
if($_POST['submit']=="Cast Votes"){
# We have a ballot paper to process
$output="<h2>Thank you for your vote</h2>\n<p>You will shortly receive an email confirming your vote.</p>\n<p>Once polling has closed on ".date('l jS F, Y \a\t H:i',strtotime(ELECTION_END)).", the election results will be available on this page.</p>";
# Establish which positions are contested
$role=$DB->GetCol("SELECT post FROM election_candidates GROUP BY post HAVING count(username) > 1");
$fail=FALSE;
$invalid_candidate=FALSE;
$abstain_count=0;
foreach($roleas$post){
if($_POST[$post]=="abstain")$abstain_count++;
# check that we have a valid option selected
if(!($DB->GetOne("SELECT username FROM election_candidates WHERE post=? AND username=?",array($post,$_POST[$post]))||$_POST[$post]=="abstain"))$fail=TRUE;
mail("SUCS Returning Officer <vote@sucs.org>","[SUCS Election] Vote received from ".$vote['username'],$ro_message,"From: SUCS Election ".ELECTION_YEAR." <vote@sucs.org>");
mail($session->fullname." <".$session->username."@sucs.org>","[SUCS Election] Thanks For Voting",$voter_message,"From: SUCS Election ".ELECTION_YEAR." <vote@sucs.org>");
}
}
}else{
display_ballot();
}
}else{
# Display the ballot paper
display_ballot();
}
}
}
# The election hasn't started yet
if(strtotime('now')<strtotime(ELECTION_START))trigger_error("The polling station is not yet open. Voting begins on ".date('l jS F, Y \a\t H:i',strtotime(ELECTION_START)).".");
# The election is over - display the results
elseif(strtotime('now')>strtotime(ELECTION_END)){
require_once("../lib/members.php");
$members=newMembers;
$role=$DB->GetAll("SELECT post FROM election_candidates GROUP BY post");
foreach($roleas$post){
$candidate[$post['post']]=$DB->GetAll("SELECT username, manifesto_link FROM election_candidates WHERE post=?",$post['post']);
$candidate[$post['post']][$i]['votes']=$DB->GetOne("SELECT count(username) FROM election_votes WHERE ".$post['post']."=?",array($person['username']));
$i++;
}
}
$smarty->assign("candidate",$candidate);
$output=$smarty->fetch('election-results.tpl');
}else{
# It's election time
# Check the user hasn't already voted
$vote_details=$DB->GetRow("SELECT time, ipaddress FROM election_votes WHERE username=?",$session->username);
if(count($vote_details)>0){
trigger_error("You already voted on ".date('l jS F, Y \a\t H:i',strtotime($vote_details['time']))." from IP address ".$vote_details['ipaddress'].".",E_USER_WARNING);
$output="<p>Please email the Returning Officer at <a href=\"mailto:vote@sucs.org\">vote@sucs.org</a> with any queries.</p>\n<p>Once polling has closed on ".date('l jS F, Y \a\t H:i',strtotime(ELECTION_END)).", the election results will be available on this page.</p>";
}else{
if($_POST['submit']=="Cast Votes"){
# We have a ballot paper to process
$output="<h2>Thank you for your vote</h2>\n<p>You will shortly receive an email confirming your vote.</p>\n<p>Once polling has closed on ".date('l jS F, Y \a\t H:i',strtotime(ELECTION_END)).", the election results will be available on this page.</p>";
# Establish which positions are contested
$role=$DB->GetCol("SELECT post FROM election_candidates GROUP BY post HAVING count(username) > 1");
$fail=FALSE;
$invalid_candidate=FALSE;
$abstain_count=0;
foreach($roleas$post){
if($_POST[$post]=="abstain")$abstain_count++;
# check that we have a valid option selected
if(!($DB->GetOne("SELECT username FROM election_candidates WHERE post=? AND username=?",array($post,$_POST[$post]))||$_POST[$post]=="abstain"))$fail=TRUE;
if(strtotime('now')>strtotime(ELECTION_START)&&strtotime('now')<strtotime(ELECTION_END)&&!$DB->GetOne("SELECT username FROM election_votes where username=?",$session->username)){
$messages['info'][]="<strong>You haven't voted yet</strong><br />\nThe SUCS Executive Election is in progress. <a href=\"/Vote\">Vote now!</a>\n";
$messages['info'][]="<strong>You haven't voted yet</strong><br />\nThe SUCS Executive Election is in progress. <a href=\"/Vote\">Vote now!</a>\n";
$smarty->assign("news",$DB->GetArray("(SELECT * FROM news WHERE expiry > now() ORDER BY date DESC LIMIT 3) UNION SELECT * FROM news WHERE sticky=true and expiry > now() ORDER BY date DESC"));
$smarty->assign("news",$DB->GetArray("(SELECT * FROM news WHERE expiry > now() ORDER BY date DESC LIMIT 3) UNION SELECT * FROM news WHERE sticky=true and expiry > now() ORDER BY date DESC"));
$output="<div class=\"cbb\"><h3>You are logged in</h3><p>If you would like to contribute to the site or report a bug, please contact imranh.</p></div>";
$output="<div class=\"cbb\"><h3>You are logged in</h3><p style=\"text-align: center;\">Why not join our <a href=\"#\" onclick=\"window.open('/mw/','Milliways','height=600,width=800,menubar=no,resizable=yes,location=no,directories=no,scrollbars=yes,status=no,toolbar=no')\" style=\"font-size: 150%; font-weight: bold; color: #ffc62b;\">Live Chat</a>?</p></div>";
$output="<div class=\"cbb\"><h3>You are logged in</h3><p>If you would like to contribute to the site or report a bug, please contact imranh.</p></div>";
$output="<div class=\"cbb\"><h3>You are logged in</h3><p style=\"text-align: center;\">Why not join our <a href=\"#\" onclick=\"window.open('/mw/','Milliways','height=600,width=800,menubar=no,resizable=yes,location=no,directories=no,scrollbars=yes,status=no,toolbar=no')\" style=\"font-size: 150%; font-weight: bold; color: #ffc62b;\">Live Chat</a>?</p></div>";
//include('users.php');
//$output .= $result;
include('electionreminder.php');
$output.=$result;
include('electionreminder.php');
$output.=$result;
}
$output.="<div class=\"cbb\"><h3>SUCS Tools</h3><p>Download the SUCS Tools to make it easier to access SUCS services from your computer.</p><ul><li><a href=\"/files/sucstools-latest.exe\">SUCS Tools for Windows</a></li><li><a href=\"/files/SUCS-latest.dmg\">SUCS Tools for Mac OS X</a></li></ul><p>More information about the tools is available in \"<a href=\"/Knowledge/Help/SUCS%20Services/Using%20the%20SUCS%20Tools\">Using the SUCS Tools</a>\".</p></div>";
$res=$mwdb->prepare("select distinct strftime('%Y',added) from mwuri");
$res->execute();
$yearlist=$res->fetchAll(PDO::FETCH_COLUMN,0);
$smarty->assign("yearlist",$yearlist);
$res=$mwdb->prepare("select distinct strftime('%m',added) from mwuri where strftime('%Y',added) = ?");
$res->execute(array(date("Y",$today)));
$mlist=$res->fetchAll(PDO::FETCH_COLUMN,0);
$monthlist=array();
foreach($mlistas$m){
$monthlist[$m]=$cal['abbrevmonths'][(int)$m];
}
$smarty->assign("monthlist",$monthlist);
$res=$mwdb->prepare("select distinct strftime('%d',added) from mwuri where strftime('%Y-%m',added) = ?");
$res->execute(array(date("Y-m",$today)));
$daylist=$res->fetchAll(PDO::FETCH_COLUMN,0);
$smarty->assign("daylist",$daylist);
if($today===FALSE&&isset($search)){
// do a search
$res=$mwdb->prepare("select *, time(added,'localtime') as hour, date(added,'localtime') as day from mwuri where title like ? or url like ? order by added desc");
$term="%".$search."%";
$res->execute(array($term,$term));
$data=$res->fetchAll(PDO::FETCH_ASSOC);
}else{
//standard date based lookup
$res=$mwdb->prepare("select *, time(added,'localtime') as hour, date(added,'localtime') as day from mwuri where date(added,'localtime')=? order by added desc");
$res=$mwdb->prepare("select distinct strftime('%Y',added) from mwuri");
$res->execute();
$yearlist=$res->fetchAll(PDO::FETCH_COLUMN,0);
$smarty->assign("yearlist",$yearlist);
$res=$mwdb->prepare("select distinct strftime('%m',added) from mwuri where strftime('%Y',added) = ?");
$res->execute(array(date("Y",$today)));
$mlist=$res->fetchAll(PDO::FETCH_COLUMN,0);
$monthlist=array();
foreach($mlistas$m){
$monthlist[$m]=$cal['abbrevmonths'][(int)$m];
}
$smarty->assign("monthlist",$monthlist);
$res=$mwdb->prepare("select distinct strftime('%d',added) from mwuri where strftime('%Y-%m',added) = ?");
$res->execute(array(date("Y-m",$today)));
$daylist=$res->fetchAll(PDO::FETCH_COLUMN,0);
$smarty->assign("daylist",$daylist);
if($today===FALSE&&isset($search)){
// do a search
$res=$mwdb->prepare("select *, time(added,'localtime') as hour, date(added,'localtime') as day from mwuri where title like ? or url like ? order by added desc");
$term="%".$search."%";
$res->execute(array($term,$term));
$data=$res->fetchAll(PDO::FETCH_ASSOC);
}else{
//standard date based lookup
$res=$mwdb->prepare("select *, time(added,'localtime') as hour, date(added,'localtime') as day from mwuri where date(added,'localtime')=? order by added desc");
$res=$mwdb->prepare("select *, time(added,'localtime') as hour, date(added,'localtime') as day from mwdoing where user=? order by added desc");
$res->execute(array($wantuser));
}else{
$res=$mwdb->prepare("select *, time(added,'localtime') as hour, date(added,'localtime') as day from mwdoing where strftime('%Y-%m',added,'localtime')=? order by added desc");
$res->execute(array(date("Y-m",$today)));
}
//$res = $mwdb->prepare("select *, time(added,'localtime') as hour, date(added,'localtime') as day from mwdoing where date(added,'localtime')=? order by added desc");
//$res->execute(array(date("Y-m-d",$today)));
$data=$res->fetchAll(PDO::FETCH_ASSOC);
$smarty->assign("statuslist",$data);
$res=$mwdb->prepare("select distinct strftime('%Y',added) from mwdoing");
$res->execute();
$yearlist=$res->fetchAll(PDO::FETCH_COLUMN,0);
$smarty->assign("yearlist",$yearlist);
$res=$mwdb->prepare("select distinct strftime('%m',added) from mwdoing where strftime('%Y',added) = ?");
$res->execute(array(date("Y",$today)));
$mlist=$res->fetchAll(PDO::FETCH_COLUMN,0);
$monthlist=array();
foreach($mlistas$m){
$monthlist[$m]=$cal['abbrevmonths'][(int)$m];
}
$smarty->assign("monthlist",$monthlist);
$res=$mwdb->prepare("select distinct strftime('%d',added) from mwdoing where strftime('%Y-%m',added) = ?");
$res=$mwdb->prepare("select *, time(added,'localtime') as hour, date(added,'localtime') as day from mwdoing where user=? order by added desc");
$res->execute(array($wantuser));
}else{
$res=$mwdb->prepare("select *, time(added,'localtime') as hour, date(added,'localtime') as day from mwdoing where strftime('%Y-%m',added,'localtime')=? order by added desc");
$res->execute(array(date("Y-m",$today)));
}
//$res = $mwdb->prepare("select *, time(added,'localtime') as hour, date(added,'localtime') as day from mwdoing where date(added,'localtime')=? order by added desc");
//$res->execute(array(date("Y-m-d",$today)));
$data=$res->fetchAll(PDO::FETCH_ASSOC);
$smarty->assign("statuslist",$data);
$res=$mwdb->prepare("select distinct strftime('%Y',added) from mwdoing");
$res->execute();
$yearlist=$res->fetchAll(PDO::FETCH_COLUMN,0);
$smarty->assign("yearlist",$yearlist);
$res=$mwdb->prepare("select distinct strftime('%m',added) from mwdoing where strftime('%Y',added) = ?");
$res->execute(array(date("Y",$today)));
$mlist=$res->fetchAll(PDO::FETCH_COLUMN,0);
$monthlist=array();
foreach($mlistas$m){
$monthlist[$m]=$cal['abbrevmonths'][(int)$m];
}
$smarty->assign("monthlist",$monthlist);
$res=$mwdb->prepare("select distinct strftime('%d',added) from mwdoing where strftime('%Y-%m',added) = ?");
$res=$mwdb->prepare("select distinct tag, substr(tag,2) as name, count(tag) as count from mwtag group by tag order by count(tag) desc limit 20");
$res->execute();
$data=$res->fetchAll(PDO::FETCH_ASSOC);
$smarty->assign("toplist",$data);
$res=$mwdb->prepare("select distinct tag, substr(tag,2) as name, count(tag) as count, max(added) as dated, date(max(added)) as day from mwtag group by tag order by max(added) desc limit 20");
$res=$mwdb->prepare("select distinct tag, substr(tag,2) as name, count(tag) as count from mwtag group by tag order by count(tag) desc limit 20");
$res->execute();
$data=$res->fetchAll(PDO::FETCH_ASSOC);
$smarty->assign("toplist",$data);
$res=$mwdb->prepare("select distinct tag, substr(tag,2) as name, count(tag) as count, max(added) as dated, date(max(added)) as day from mwtag group by tag order by max(added) desc limit 20");