-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.php
More file actions
183 lines (178 loc) · 8.47 KB
/
Copy pathmain.php
File metadata and controls
183 lines (178 loc) · 8.47 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<?php
session_name("deadBox");
session_start(); //start session and if valid isn't set then redirect to the splash page
if ($_SESSION['valid'] != 1) {
header("Location: ./index.php");
}
//require necessary files to connect to database
require_once('./php/database.php');
//require databse functions file
require('./php/user_db.php');
//include TMDb wrapper class
//include('./php/TMDb.php');
//create new tmdb object with my API key
//$tmdb = new TMDb('a592c64a025525d496607cdd273be6b3');
//grab the userID from the current session
$userID = $_SESSION['userID'];
//call get_actors() which queries the database for the actors that the user has voted for
$actors = get_actors('actorID', 'profileImg', 'actorBio', 'actorName', 'movieImg', 'movieSynopsis', 'votes', 'userID', $userID);
//query the database for the top voted movie (stopping point) for each actor aggregated for all users
$votes = get_topVotes();
//count created to add bootstrap rows every four actors
$count = 0;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>deadBox</title>
<link rel="shortcut icon" href="./img/favicon.ico">
<link rel="stylesheet" href="./css/bootstrap.css">
<link rel="stylesheet" href="./css/joyride-2.1.css">
<link rel="stylesheet" href="./css/style.css">
</head>
<?php
flush();
?>
<body class="main">
<div class="navbar navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a href="http://ps11.pstcc.edu/~c2230a11/site/main.php" class="navbar-brand" id="preSearch1">deadBox</a>
</div>
<div class="navbar-collapse collapse">
<form class="navbar-form navbar-left" id="form1" role="search">
<div class="form-group">
<input class="form-control typeahead search" type="text" id="text1" placeholder="Search" value="">
<button type="button" class="btn searchButton" id="button1"><span class="glyphicon glyphicon-search searchIcon"></span>
</button>
</div>
<!--<button type="submit" class="btn btn-default">Submit</button>-->
</form>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" id="preSearch2" class="dropdown-toggle" data-toggle="dropdown">Hello, <?php echo $_SESSION['username']; ?> <span class="glyphicon glyphicon-cog drop"></span></a>
<ul class="dropdown-menu">
<li><a id="trending" href="#">Trending</a></li>
<!--<li><a href="#">Settings</a></li>-->
<!--<li><a href="http://ps11.pstcc.edu/~c2230a11/feeds/">News</a></li>-->
<li>
<form action="./php/logout.php" method="post">
<button type="submit" class="btn logOutButton"><a class="logOut" href="http://ps11.pstcc.edu/~c2230a11/site/index.php">Sign Out</a></button>
</form>
</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
<section class="content">
<div class="container" id="content">
<?php
if ($actors->num_rows == 0) {
echo '<h2>Go forth and search to vote!</h2>'; //if the user hasn't voted for any actors yet, tell them to do so
}
?>
<?php foreach ($actors as $actor) : ?>
<?php
//for every actor that the user has voted for, check against the top votes.
//if the actorID from top votes matches the current actor, pull in the information for the top voted movie
foreach ($votes as $vote) {
if ($vote['aID'] == $actor['actorID']) {
$topMovie = $vote['topMovie'];
$movieImg = $vote['movieImg'];
$movieSynopsis = $vote['movieSynopsis'];
}
}
//every four actors insert a new row
if (($count == 0) || ($count % 4 == 0)) {
echo '<div class="row featurette"></div>';
}
//increment the count
$count++;
//flush the buffer contents (a silly optimization)
flush();
?>
<div class="col-lg-3 col-sm-3 col-md-3 col-xs-6">
<!--this is bad practice. store the necessary information in unrelated html attributes. this is a crazy hack. don't do this.-->
<a href="#" class="actorButton tada">
<img class="featurette-image img-responsive actor" id="<?php echo $actor['actorID']; ?>" src="http://d3gtl9l2a4fn1j.cloudfront.net/t/p/w500<?php echo $actor['profileImg']; ?>" data-src="holder.js/500x500/auto" alt="<?php echo $actor['actorName']; ?>" name="<?php echo $actor['actorBio']; ?>" width="http://d3gtl9l2a4fn1j.cloudfront.net/t/p/w500<?php echo $movieImg?>" usemap="<?php echo $movieSynopsis?>">
<p class="actorName text-center" id="http://d3gtl9l2a4fn1j.cloudfront.net/t/p/w500<?php echo $actor['movieImg']; ?>" name="<?php echo $actor['movieSynopsis']; ?>"><?php echo $actor['actorName']; ?></p>
</a>
</div>
<?php endforeach; ?>
</div>
</section>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h2 class="modal-title text-center">Vote or die!</h2>
</div>
<div class="modal-body">
<div class="container text-center">
<h3>Would you like to vote for this movie?</h3>
<img class="featurette-image img-responsive voteImg" id="voteImg" src="" data-src="holder.js/25%x25%/auto" alt="Generic placeholder image">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary vote" id="vote"><a href="./main.php">Vote!</a></button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<ol id="preSearchRide">
<li data-button="Next">
<h2>Welcome!</h2>
<p>This is your main page. You will see actors you have voted for here.</p>
<p>*Please note* This tour uses cookies. Turn them on if you don't want to see this tour after the initial login.</p>
</li>
<li data-id="preSearch1" data-button="Next" data-options="tipLocation:top;tipAnimation:fade">
<h2>Getting Around</h2>
<p>You can get back to this page at any time by clicking the logo.</p>
</li>
<li data-id="preSearch2" data-button="Next" data-options="tipLocation:top;tipAnimation:fade">
<h2>Getting Out</h2>
<p>Click your name at anytime for the option to log out.</p>
</li>
<li data-id="text1" data-button="Next" data-options="tipLocation:top;tipAnimation:fade">
<h2>Searching</h2>
<p>Find actors and cast judgment upon them!</p>
</li>
<li data-button="Next">
<h2>Results</h2>
<p>After searching, the content of the main page will be replaced with the credits of the searched-for actor/actress in chronological order.</p>
</li>
<li data-button="Next">
<h2>Voting</h2>
<p>To vote, click on the film with which you think the actor/actress should have ended his or her career.</p>
</li>
<li data-button="Next">
<h2>Changed your mind?</h2>
<p>If at any point you want to change a vote for an actor's drop-dead point, just search for that actor and re-vote!</p>
</li>
<li data-button="Let Me Vote Already...">
<h2>Personalized Content</h2>
<p>After your vote is submitted, any unlucky souls that you have cast judgement upon will appear here.</p>
<p>You can click an actor's image to read their bio and view the consensus on when he/she jumped the shark!</p>
</li>
</ol>
<script src="http://code.jquery.com/jquery.js"></script>
<script src="./js/bootstrap.js"></script>
<script src="./js/typeahead.js"></script>
<script type="text/javascript" src="./js/jquery.cookie.js"></script>
<script type="text/javascript" src="./js/modernizr.mq.js"></script>
<script type="text/javascript" src="./js/jquery.joyride-2.1.js"></script>
<script src="./js/test.js"></script>
</body>
</html>