Skip to content

Commit

Permalink
added thanks page
Browse files Browse the repository at this point in the history
  • Loading branch information
xathon committed Oct 4, 2020
1 parent 494bb4e commit 39aea7e
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 26 deletions.
38 changes: 21 additions & 17 deletions css/bootstrap.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
--white: #fff;
--gray: #6c757d;
--gray-dark: #343a40;
--primary: #007bff;
--primary: #ff852a;
--secondary: #6c757d;
--success: #28a745;
--info: #17a2b8;
Expand Down Expand Up @@ -60,7 +60,7 @@ body {
line-height: 1.5;
color: #212529;
text-align: left;
background-color: #fff;
background-color: #212121;
}

[tabindex="-1"]:focus:not(:focus-visible) {
Expand All @@ -76,6 +76,8 @@ hr {
h1, h2, h3, h4, h5, h6 {
margin-top: 0;
margin-bottom: 0.5rem;
font-family: "Barlow Condensed", sans-serif;
color: #fff;
}

p {
Expand Down Expand Up @@ -581,8 +583,8 @@ pre code {
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
margin-right: -15px;
margin-left: -15px;
margin-right: 0px;
margin-left: 0px;
}

.no-gutters {
Expand Down Expand Up @@ -2543,21 +2545,21 @@ fieldset:disabled a.btn {

.btn-primary {
color: #fff;
background-color: #007bff;
border-color: #007bff;
background-color: #ff852a;
border-color: #ff852a;
}

.btn-primary:hover {
color: #fff;
background-color: #0069d9;
border-color: #0062cc;
background-color: #d9781d;
border-color: #d9781d;
}

.btn-primary:focus, .btn-primary.focus {
color: #fff;
background-color: #0069d9;
border-color: #0062cc;
box-shadow: 0 0 0 0.2rem rgba(38, 143, 255, 0.5);
background-color: #d9781d;
border-color: #d9781d;
box-shadow: 0 0 0 0.2rem rgba(255, 133, 42, 0.5);
}

.btn-primary.disabled, .btn-primary:disabled {
Expand All @@ -2569,13 +2571,13 @@ fieldset:disabled a.btn {
.btn-primary:not(:disabled):not(.disabled):active, .btn-primary:not(:disabled):not(.disabled).active,
.show > .btn-primary.dropdown-toggle {
color: #fff;
background-color: #0062cc;
border-color: #005cbf;
background-color: #d9781d;
border-color: #d9781d;
}

.btn-primary:not(:disabled):not(.disabled):active:focus, .btn-primary:not(:disabled):not(.disabled).active:focus,
.show > .btn-primary.dropdown-toggle:focus {
box-shadow: 0 0 0 0.2rem rgba(38, 143, 255, 0.5);
box-shadow: 0 0 0 0.2rem rgba(255, 133, 42, 0.5);
}

.btn-secondary {
Expand Down Expand Up @@ -4854,8 +4856,8 @@ input[type="button"].btn-block {
display: flex;
-ms-flex-flow: row wrap;
flex-flow: row wrap;
margin-right: -15px;
margin-left: -15px;
margin-right: 0px;
margin-left: 0px;
}
.card-deck .card {
-ms-flex: 1 0 0%;
Expand Down Expand Up @@ -10256,4 +10258,6 @@ a.text-dark:hover, a.text-dark:focus {
border-color: #dee2e6;
}
}
/*# sourceMappingURL=bootstrap.css.map */
/*# sourceMappingURL=bootstrap.css.map */

/*Custom*/
4 changes: 4 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
<?php
session_start();
unset($_SESSION)
//select winner.name,loser.name from matchups left join logos winner on winner.id = matchups.winner left join logos loser on loser.id = matchups.loser;

?>

<html>
<head>
<link href="css/bootstrap.css" rel="stylesheet">
</head>
<body>
<div class="row" style="height: 20em"></div>
<div class="row">
<div class="col-3">

Expand Down
32 changes: 32 additions & 0 deletions thanks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
session_start();
if (isset($_SESSION['completed'])) $_SESSION['completed'] = [];

echo '<html>
<head>
<link href="css/bootstrap.css" rel="stylesheet">
</head>
<body>
<div class="row">
<div class="col-3">
</div>
<div class="col-6" style="text-align: center">
<h1>Logo contest</h1>
<h3>Thanks for voting!</h3>
</div>
</div>
<div class="row">
<div class="col-3">
</div>
<div class="col-6" style="text-align: center">
<a class="btn btn-primary" role="button" href="vote.php">Go agane</a>
</div>
</div>
</body>
</html>';



2 changes: 1 addition & 1 deletion upload.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php

session_start();

if (count($_FILES) > 0) {
$f = array_pop($_FILES);
Expand Down
46 changes: 38 additions & 8 deletions vote.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,52 @@
$query .= ($_POST['selected'] == $_POST['ID1'] ? $_POST['ID2'] : $_POST['ID1']).";";
$q = mysqli_query($remote,$query);


$query = "insert into matchups values ('" . $_POST['matchID'] . "', ";
$query .= ($_POST['selected'] == $_POST['ID1'] ? $_POST['ID1'] : $_POST['ID2']).", ";
$query .= ($_POST['selected'] == $_POST['ID1'] ? $_POST['ID2'] : $_POST['ID1']).",'";
$query .= session_id()."',default);";
$q = mysqli_query($remote,$query);

}

if(!isset($_SESSION['count'])){
if(!isset($_SESSION['numberLogos'])){
$query = "select count(id) from logos; ";
$rCount = mysqli_query($remote,$query);
$_SESSION['count'] = mysqli_fetch_assoc($rCount)['count(id)'];
$_SESSION['numberLogos'] = mysqli_fetch_assoc($rCount)['count(id)'];
//echo "queried!";
}

if(!isset($_SESSION['completed'])){
$_SESSION['completed'] = [];
}


if(sizeof($_SESSION['completed']) > 20) {

echo '<html>
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport">
<title>Redirecting...</title>
<meta content="0; URL=thanks.php" http-equiv="refresh">
</head>
</html>';
exit();
}

// To ensure that no logo pair is shown twice, we use a Cantor Pairing Function to store the information about the already shown pairs.
$imageID1=0;
$imageID2=0;
$maxcount= ($_SESSION['count'] * ($_SESSION['count'] - 1) / 2); //maximum retries, redundant?
$maxcount= ($_SESSION['numberLogos'] * ($_SESSION['numberLogos'] - 1) / 2); //maximum retries, redundant?

for($i = 0; $i < $maxcount; $i++) {
//get two different, random numbers
do {
$imageID1 = rand(1,$_SESSION['count']);
$imageID2 = rand(1,$_SESSION['count']);
$imageID1 = rand(1,$_SESSION['numberLogos']);
$imageID2 = rand(1,$_SESSION['numberLogos']);

} while ($imageID1 == $imageID2);

Expand Down Expand Up @@ -83,6 +105,7 @@
</div>
<div class="col-6" style="text-align: center">
<h1>Choose one!</h1>
<h3>'.sizeof($_SESSION['completed']).'/20</h3>
</div>
</div>
Expand All @@ -101,9 +124,16 @@
//image 1

$query = "select name,logo from logos where id = ".$imageID1." or id = ".$imageID2.";";
$rImg1 = mysqli_query($remote,$query);
$Img1 = mysqli_fetch_assoc($rImg1);
$Img2 = mysqli_fetch_assoc($rImg1);
$rImg = mysqli_query($remote,$query);
if($imageID1 < $imageID2) {
$Img1 = mysqli_fetch_assoc($rImg);
$Img2 = mysqli_fetch_assoc($rImg);
} else {
$Img2 = mysqli_fetch_assoc($rImg);
$Img1 = mysqli_fetch_assoc($rImg);
}

echo '<input type="hidden" name="matchID" value="'.bin2hex(random_bytes(10)).'">';
echo '<input type="hidden" name="ID1" value="'.$imageID1.'">';
echo '<input type="hidden" name="ID2" value="'.$imageID2.'">';

Expand Down

0 comments on commit 39aea7e

Please sign in to comment.