-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
75 lines (61 loc) · 2.03 KB
/
index.php
File metadata and controls
75 lines (61 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
// INCLUDES
include 'inc.php';
// ACTIONS
dbConnect($config[0]);
$do = getValue('do');
// Do: Log out
if ($do == 'logout') {
// do logout
if (checkLogin()) {
setcookie($cookie_name, $cookie_value_logout, $cookie_expire, $cookie_path, $cookie_domain, 0);
header('Location: ' . $request_uri);
}
else {
$message = new Message('You are now logged out.', 0);
}
}
// Do: Vote
if ($do == 'vote' && getValue('win') && getValue('lose')) {
// Get image id's
$win = getValue('win');
$lose = getValue('lose');
// Send vote
voteImage($win, $lose);
// Set message
$message = new Message("Vote recorded successfully.", 0);
}
?>
<?php include 'inc.head.php'; ?>
<title>ImgRate</title>
</head>
<body>
<div class="container-fluid front text-center">
<div class="row-fluid">
<div class="span12">
<header>
<?php include 'inc.nav.php'; ?>
</header>
<?php include 'inc.message.php'; ?>
<?php $img = selectImages(); ?>
<article>
<h1 class="title">Rate</h1>
<p>Below you see two randomly selected images. Choose which you like better by clicking the image. On the Stats-page you can find the ratings of the images.</p>
<ul class="thumbnails">
<li class="span3 offset3">
<a href="?do=vote&win=<?php print $img[0]->id; ?>&lose=<?php print $img[1]->id; ?>" title="Vote this image" class="thumbnail">
<img src="images/<?php print $img[0]->src; ?>" class="fixed-size">
</a>
</li>
<li class="span3">
<a href="?do=vote&win=<?php print $img[1]->id; ?>&lose=<?php print $img[0]->id; ?>" title="Vote this image" class="thumbnail">
<img src="images/<?php print $img[1]->src; ?>" class="fixed-size">
</a>
</li>
</ul>
</article>
</div>
</div>
<?php include 'inc.footer.php'; ?>
</body>
</html>