-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
184 lines (153 loc) · 6.03 KB
/
index.php
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
184
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Index</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Login</title>
<!-- CSS -->
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Roboto:400,100,300,500">
<link rel="stylesheet" href="assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="assets/css/form-elements.css">
<link rel="stylesheet" href="assets/css/style.css">
<!-- Favicon and touch icons -->
<link rel="shortcut icon" href="assets/ico/favicon.png">
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="assets/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="assets/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png">
<link rel="stylesheet" type="text/css" href="mystyle.css" >
<link href='https://fonts.googleapis.com/css?family=Roboto:400,100,300,300italic,700' rel='stylesheet' type='text/css' >
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script type="text/javascript" src="script.js"> </script>
<link rel="icon" href="img/icon1.png" type='image/x-icon'/>
<img src="https://img.icons8.com/ios-glyphs/30/000000/document.png">
</head>
<body onload="updateMostRecent(); setInterval( function() { refreshIndex(); }, 5000);">
<header id="fixed-header">
<!-- <a href="./index.php"> <img id="logo" src="logo.png" alt="Quora"/> </a> -->
<header id="fixed-header" >
<a href="./index.php"> <img id="logo" src="logo1.png" alt="Quora"/> </a>
<?php
session_start();
$loggedin = isset($_SESSION["loggedin"]) && $_SESSION["loggedin"] === true;
if($loggedin) : ?>
<a href="./logout.php" id="header-login" class="lg"><button>Logout</button></a>
<?php else : ?>
<a href="./login.php" id="header-login">Login</a><BR>
<!-- <a href="./signup.php" id="header-login">Signup</a> -->
<!-- <a href="./login.php" id="header-login" class="lg"><button>Login</button></a> -->
<!-- <a href="./signup.php" id="header-login" class="lg"><button>SignUp</button></a> -->
<?php endif; ?>
</header>
<?php if($loggedin) : ?>
<a href="form-question.php"><img src="FAB.png" alt="Submit a question" title="Submit a question" id="FAB" /></a>
<?php endif; ?>
<div id="question-list">
<!---
<?php
require_once('mysqli-connect.php');
DEFINE("maxPosts", 20);
require("update-top-answer.php");
$sql = "SELECT * FROM Questions ORDER BY id DESC";
$response = $conn->query($sql);
if($response) {
$count = 0;
while($row = mysqli_fetch_array($response)) {
updateTopAnswer($conn, $row["id"]);
if($count == maxPosts) {
break;
}
$count++;
$sql = "SELECT * FROM Users WHERE id=" . $row["user_id"];
$result = $conn->query($sql);
if($result) {
$user = mysqli_fetch_array($result);
$avatarpath = "./avatars/avatar-" . $row["user_id"] . ".png";
if(!file_exists($avatarpath)) {
$avatarpath = "avatar.png";
}
}
?>
<div class="question-display">
<a href=<?php echo "./question-detail.php?qid=" . $row["id"] ?> class="question"><?php echo $row["question_text"]; ?></a>
<img src=<?php echo "\"" . $avatarpath . "\""; ?> alt="Avatar" class="question-avatar">
<br />
<p class="date"><?php echo $row["time_asked"]; ?></p>
<a href= <?php echo "./question-detail.php?qid=" . $row["id"] ?> class="num-answers"><?php echo $row["num_answers"]; ?> answers</a>
<?php if($loggedin) { ?>
<a href=<?php echo "./form-answer.php?qid=" . $row["id"]; ?> class="answer-button">Answer!</a>
<?php } //end if ?>
<br />
<hr />
<aside class="answer-bottom-section">
<?php if($row["num_answers"] > 0) {
$sql = "SELECT * FROM Answers WHERE id=" . $row["top_answer_id"];
$result = $conn->query($sql);
$answer = mysqli_fetch_array($result);
$top_answer_user_id = $answer["user_id"];
$sql = "SELECT * FROM Users WHERE id=" . $top_answer_user_id;
$result = $conn->query($sql);
$top_answerer = NULL;
if($user = mysqli_fetch_array($result)) {
$top_answerer = $user;
}
$avatarpath = "./avatars/avatar-" . $top_answerer["id"] . ".png";
if(!file_exists($avatarpath)) {
$avatarpath = "avatar.png";
}
?>
<p class="inline answerer-name"><i>Top answer by <?php echo $top_answerer["username"]; ?></i></p>
<img src=<?php echo $avatarpath; ?> alt="Avatar" id="answer-avatar" />
<p class="top-answer"><?php echo $answer["answer_text"]; ?></p>
<?php } else { ?>
<p class="no-answers">There are no answers yet.<br />Be the first!</p>
<?php } ?>
</aside>
</div>
<?php
} //end while
mysqli_free_result($response);
} //end if
else { ?>
<div class="question-display post-display">
No questions found.
</div>
<?php } //end else ?>
</div>
-->
</body>
</html>
<script src="assets/js/jquery-1.11.1.min.js"></script>
<script src="assets/bootstrap/js/bootstrap.min.js"></script>
<script src="assets/js/jquery.backstretch.min.js"></script>
<script src="assets/js/scripts.js"></script>
<style type="text/css">
#logo
{
border:1px solid white;
border-radius: 50%;
margin-left:45px;
margin-bottom:20px;
}
.lg button
{
background-color: #379683;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 20px 10px;
cursor: pointer;
}
.lg button:hover
{
opacity:0.5;
}
</style>