pages/voting.php

42 lines
1002 B
PHP

<?php
$votefile = "/home/*/.vote";
$yes = 0;
$no = 0;
foreach (glob($votefile) as $vote){
if(!is_file($vote) || gettype(fgets(fopen($vote,'r'))=='boolean')){
continue;
}
else{
$file = fopen($vote,'r');
$line = fgets($file);
if($line=='1'){
$yes+=1;
}
if($line=='0'){
$no+=1;
}
fclose($file);
}
}
include ('includes/header.php');
?>
<main>
<h3>Voting</h3>
<p>Welcome to tildevarsh's voting system. Currently it is a unique feature
of tildevarsh where users will be able to vote into important decisions related
to the tilde. This page will show past and ongoing motions that were / are
being voted to. Users can vote by editing a single file `.vote` in
their home directories. To vote 'yes', change the first line to just 1. To vote
no, make it a 0. This is a very rudimentary system and will be changed to allow
different options in the future.</p>
<h4>Current Motion: <b>none<b></h4>
<h5>
Results:
<br>
Yes - <?php echo $yes ?>
<br>
No - <?php echo $no ?>
</main>