Skip to content

Commit

Permalink
restore voting functionality, keep staff votes for later use
Browse files Browse the repository at this point in the history
  • Loading branch information
xathon committed Aug 16, 2021
1 parent 5f347f9 commit d2a626f
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 103 deletions.
15 changes: 15 additions & 0 deletions db_conn.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
require __DIR__ . '/vendor/autoload.php';
$dotenv = Dotenv\Dotenv::create(__DIR__, '.env');
$dotenv->load();
$dotenv->required(['DB_HOST', 'DB_NAME', 'DB_USER', 'DB_PASS', 'DB_PORT']);

$remote = mysqli_connect(getenv('DB_HOST'),
getenv('DB_USER'),
getenv('DB_PASS'),
getenv('DB_NAME'),
getenv('DB_PORT'));
if (mysqli_connect_errno()) {
printf("Couldn't connect to database! %s\n", mysqli_connect_error());
exit();
}
6 changes: 4 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
session_unset();


if(time()>1605459600) {
if(time()>1605459600 && false) { //TODO: edit the timestamp so it matches the desired end of the contest
//TODO edit the page for the new branding
echo '<html lang="en">
<head>
<link rel="apple-touch-icon" sizes="180x180" href="https://elohell.gg/media/img/favicon/apple-touch-icon.png?v=1">
Expand All @@ -20,7 +21,7 @@
<meta property="og:title" content="GitGud Logocontest" />
<meta property="og:type" content="website"/>
<meta property="og:url" content="https://logos.elohell.gg/" />
<meta property="og:image" content="https://elohell.gg/media/img/logos/ggs6/GG_V_C_Dark.png">
<meta property="og:image" content="https://elohell.gg/media/img/logos/ggs6/GG_V_C_Dark.png">
<meta property="og:description" content="Vote for your favorite logos in the Elo Hell Zotac GitGud Tournament!">
<meta name="theme-color" content="#FF882C">
Expand Down Expand Up @@ -73,6 +74,7 @@
</body>
</html>';
} else {
//TODO implement rebranding
echo '
<html lang="en">
<head>
Expand Down
21 changes: 3 additions & 18 deletions output.php
Original file line number Diff line number Diff line change
@@ -1,29 +1,15 @@
<?php
session_start();
include_once 'helpers.php';
include_once "db_conn.php";

//TODO seperate this into a snippet
require __DIR__ . '/vendor/autoload.php';
$dotenv = Dotenv\Dotenv::create(__DIR__, '.env');
$dotenv->load();
$dotenv->required(['DB_HOST', 'DB_NAME', 'DB_USER', 'DB_PASS', 'DB_PORT']);

$remote = mysqli_connect(getenv('DB_HOST'),
getenv('DB_USER'),
getenv('DB_PASS'),
getenv('DB_NAME'),
getenv('DB_PORT'));
if (mysqli_connect_errno()) {
printf("Couldn't connect to database! %s\n", mysqli_connect_error());
exit();
}
if(isset($_POST['selected'])) {
$query = "update logocontest.logos set active=0 where id = ".$_POST['selected'].";";
$result = mysqli_query($remote, $query);
}


$query = "select * from logocontest.output order by name ASC;";
$query = "select * from logocontest.output order by won_matchups/output.matchups DESC,output.matchups DESC ;";
$result = mysqli_query($remote, $query);


Expand All @@ -49,8 +35,7 @@
</div>
<div class="col-8" style="text-align: center">
<h1>All the logos to choose from!</h1>
<h1>Hint: click on a logo to see it in full size!</h1>
<h1>Output of the current votings</h1>
</div>
</div>
Expand Down
17 changes: 1 addition & 16 deletions staffvote.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,7 @@
<?php
session_start();
include_once 'helpers.php';

//TODO seperate this into a snippet
require __DIR__ . '/vendor/autoload.php';
$dotenv = Dotenv\Dotenv::create(__DIR__, '.env');
$dotenv->load();
$dotenv->required(['DB_HOST', 'DB_NAME', 'DB_USER', 'DB_PASS', 'DB_PORT']);

$remote = mysqli_connect(getenv('DB_HOST'),
getenv('DB_USER'),
getenv('DB_PASS'),
getenv('DB_NAME'),
getenv('DB_PORT'));
if (mysqli_connect_errno()) {
printf("Couldn't connect to database! %s\n", mysqli_connect_error());
exit();
}
include_once "db_conn.php";

$query = "select * from logocontest.output order by name ASC;";
$result = mysqli_query($remote, $query);
Expand Down
98 changes: 46 additions & 52 deletions thanks.php
Original file line number Diff line number Diff line change
@@ -1,61 +1,50 @@
<?php
session_start();
include_once "helpers.php";
include_once "db_conn.php";

require __DIR__ . '/vendor/autoload.php';
$dotenv = Dotenv\Dotenv::create(__DIR__, '.env');
$dotenv->load();
$dotenv->required(['DB_HOST', 'DB_NAME', 'DB_USER', 'DB_PASS', 'DB_PORT']);

$remote = mysqli_connect(getenv('DB_HOST'),
getenv('DB_USER'),
getenv('DB_PASS'),
getenv('DB_NAME'),
getenv('DB_PORT'));
if (mysqli_connect_errno()) {
printf("Couldn't connect to database! %s\n", mysqli_connect_error());
exit();
}

if($_POST == []) {
header("Location: staffvote.php");
}
$query = "select * from ivoted where sessionid = '".session_id()."'";
$q = mysqli_query($remote,$query);

if($q->num_rows > 0) {
echo "You tried to vote more than once, even though we told you not to. Ollie is very disappointed in you.";
die();
}
$query = "insert into ivoted values('".session_id()."',".time().")";
$q = mysqli_query($remote,$query);
if(time()>0 && false) {//TODO enter timestamp here
if($_POST == []) {
header("Location: staffvote.php");
}
// Single voting is only used for staff voting. During the regular voting time, you can vote as much as you want.
$query = "select * from ivoted where sessionid = '".session_id()."'";
$q = mysqli_query($remote,$query);

if($q->num_rows > 0) {
echo "You tried to vote more than once, even though we told you not to. Ollie is very disappointed in you.";
die();
}
$query = "insert into ivoted values('".session_id()."',".time().")";
$q = mysqli_query($remote,$query);

$query = "";
if(isset($_POST['ollieburn'])) {
$query = "update logocontest.logos set `ollieburn` = `ollieburn` + 1 where `id` = ".$_POST['ollieburn']."; ";
$query = "";
if(isset($_POST['ollieburn'])) {
$query = "update logocontest.logos set `ollieburn` = `ollieburn` + 1 where `id` = ".$_POST['ollieburn']."; ";
$q = mysqli_query($remote,$query);
}
$query = "update logocontest.logos set `paint` = `paint` + 1 where `id` = ".$_POST['paint']."; ";
$q = mysqli_query($remote,$query);
}
$query = "update logocontest.logos set `paint` = `paint` + 1 where `id` = ".$_POST['paint']."; ";
$q = mysqli_query($remote,$query);
$query = "update logocontest.logos set `animal` = `animal` + 1 where `id` = ".$_POST['animal']."; ";
$q = mysqli_query($remote,$query);
$query = "update logocontest.logos set `staff` = `staff` + 1 where `id` = ".$_POST['staff'].";";
$q = mysqli_query($remote,$query);
if(isset($_POST['ollieburn'])) {
$query = "select * from logos where id = ".$_POST['ollieburn'];
$query = "update logocontest.logos set `animal` = `animal` + 1 where `id` = ".$_POST['animal']."; ";
$q = mysqli_query($remote,$query);
$ollie = mysqli_fetch_assoc($q);
$query = "update logocontest.logos set `staff` = `staff` + 1 where `id` = ".$_POST['staff'].";";
$q = mysqli_query($remote,$query);
if(isset($_POST['ollieburn'])) {
$query = "select * from logos where id = ".$_POST['ollieburn'];
$q = mysqli_query($remote,$query);
$ollie = mysqli_fetch_assoc($q);
}
$query = "select * from logos where id = ".$_POST['paint'];
$q = mysqli_query($remote,$query);
$paint = mysqli_fetch_assoc($q);
$query = "select * from logos where id = ".$_POST['animal'];
$q = mysqli_query($remote,$query);
$animal = mysqli_fetch_assoc($q);
$query = "select * from logos where id = ".$_POST['staff'];
$q = mysqli_query($remote,$query);
$staff = mysqli_fetch_assoc($q);
}
$query = "select * from logos where id = ".$_POST['paint'];
$q = mysqli_query($remote,$query);
$paint = mysqli_fetch_assoc($q);
$query = "select * from logos where id = ".$_POST['animal'];
$q = mysqli_query($remote,$query);
$animal = mysqli_fetch_assoc($q);
$query = "select * from logos where id = ".$_POST['staff'];
$q = mysqli_query($remote,$query);
$staff = mysqli_fetch_assoc($q);



Expand Down Expand Up @@ -98,8 +87,10 @@
</div></div>
<div class="row" style="min-width: 720px">
';
if(isset($ollie)) {
echo '<div class="col-3" >

if(time()>0 && false) {//TODO enter timestamp here
if(isset($ollie)) {
echo '<div class="col-3" >
<div class="mx-auto">
<h2>OllieBurn award:</h2>
<a href="https://img.elohell.gg/overlay/teams/'.normalize_text($ollie['name']).'.png" target="_logo"><img style="margin:20px" class="img" src="https://img.elohell.gg/overlay/teams/'.normalize_text($ollie['name']).'.png" width="100px" alt="'.$ollie['name'].'"></a>
Expand All @@ -119,8 +110,8 @@
<h2>Staff Choice:</h2>
<a href="https://img.elohell.gg/overlay/teams/'.normalize_text($staff['name']).'.png" target="_logo"><img style="margin:20px" class="img" src="https://img.elohell.gg/overlay/teams/'.normalize_text($staff['name']).'.png" width="100px" alt="'.$staff['name'].'"></a>
</div>';
} else {
echo '
} else {
echo '
<div class="col-4">
<div class="mx-auto">
<h2 class="text-center">MSPaint award:</h2>
Expand All @@ -139,8 +130,11 @@
<a href="https://img.elohell.gg/overlay/teams/'.normalize_text($staff['name']).'.png" target="_logo"><img style="margin:20px" class="img" src="https://img.elohell.gg/overlay/teams/'.normalize_text($staff['name']).'.png" width="100px" alt="'.$staff['name'].'"></a>
</div>
</div>';
}
}



echo '
</div>
Expand Down
16 changes: 1 addition & 15 deletions vote.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
<?php
session_start();
include_once "helpers.php";

require __DIR__ . '/vendor/autoload.php';
$dotenv = Dotenv\Dotenv::create(__DIR__, '.env');
$dotenv->load();
$dotenv->required(['DB_HOST', 'DB_NAME', 'DB_USER', 'DB_PASS', 'DB_PORT']);

$remote = mysqli_connect(getenv('DB_HOST'),
getenv('DB_USER'),
getenv('DB_PASS'),
getenv('DB_NAME'),
getenv('DB_PORT'));
if (mysqli_connect_errno()) {
printf("Couldn't connect to database! %s\n", mysqli_connect_error());
exit();
}
include_once "db_conn.php";

if(isset($_POST['selected'])) {
//Store the Cantor number representing the IDs in the session.
Expand Down

0 comments on commit d2a626f

Please sign in to comment.