added voting system

This commit is contained in:
gtlsgamr 2022-08-12 16:09:48 +05:30
parent 93613ef6d5
commit b4cd2569c9
4 changed files with 46 additions and 19 deletions

View File

@ -15,12 +15,12 @@
<li>Received 150 rupees from @neovoidtk</li>
<li>Received 150 rupees from @JB</li>
<li style="text-decoration:line-through;">Received 150 rupees from @JB </li>- returned back :(
<li>Received 111 from @aryan_exists</li>
<li>Received 150 from Hello</li>
</ul>
<h5>Total: 1231</h5>
<h5>Total: 1081</h5>
</main>
<?php include("./includes/footer.php")?>

View File

@ -1,15 +0,0 @@
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/static/css/writ.css">
<body>
<header>
<h1><a href="/">~Tildevarsh</a></h1>
<nav>
<ul>
<li><a href="funds.html">funding info</a></li>
<li><a href="register.php">register</a></li>
</ul>
</nav>
</header>

View File

@ -8,8 +8,9 @@
<h1><a href="/">~Tildevarsh</a></h1>
<nav>
<ul>
<li><a href="funds.php">funding info</a></li>
<li><a href="register.php">register</a></li>
<li><a href="/funds">funding info</a></li>
<li><a href="/register">register</a></li>
<li><a href="/voting">voting</a></li>
</ul>
</nav>
</header>

41
voting.php Normal file
View File

@ -0,0 +1,41 @@
<?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>