-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofile.php
More file actions
174 lines (130 loc) · 4.19 KB
/
profile.php
File metadata and controls
174 lines (130 loc) · 4.19 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
<?php
session_start();
require("inc/checker.php");
require("inc/config.php");
if($_SESSION['clogin']==false || !$_SESSION['cuserid'])
{ // User not logged in.
header("refresh:0;url=login.php");
exit();
}
if(!$_GET['userid']){ // If no userid is passed.
header("refresh:0;url=index.php");
exit();
}
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo $appname; ?> - Profile</title>
<?php include 'inc/styles.php'; ?>
</head>
<body class="mainbody">
<?php
include 'header.php';
?>
<main>
<?php
// Retreiving all the information about the user.
$query1 = $db->query("SELECT * FROM ".$subs."users WHERE userid='".$_GET['userid']."'");
if($db->numrows($query1)==0){
// No user with the userid found.
echo "<br><br>No such user found. Redirecting to home.<br><br>";
header("refresh:2;url=index.php");
exit();
}
// If found.
$userdet = $db->fetch($query1);
// Printing the details of each user.
?>
<div align="center">
<?php
echo "<h2>".$userdet['username']."</h2>";
echo $userdet['name']."<br><br>";
// Gathering all the public confessions.
$query2 = $db->query("SELECT * FROM ".$subs."confessions WHERE recid='".$_GET['userid']."' AND showonprofile=1");
if($db->numrows($query2)==0){
echo "<br>No Public Confessions.<br>";
}
else{
$numrows = $db->numrows($query2);
// ------------
// Paginating
// ------------
$rowsperpage = 5;
$totalpages = ceil($numrows / $rowsperpage);
if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) {
$currentpage = (int) $_GET['currentpage'];
} else {
$currentpage = 1;
}
if ($currentpage > $totalpages) {
$currentpage = $totalpages;
}
if ($currentpage < 1) {
$currentpage = 1;
}
$offset = ($currentpage - 1) * $rowsperpage;
$sql = "SELECT * FROM ".$subs."confessions WHERE recid='".$_GET['userid']."' AND showonprofile=1 LIMIT $offset, $rowsperpage";
$result = $db->query($sql);
while ($list = $db->fetch($result)) {
// Displaying
echo "<div class='confession' style='text-align:left;'>
<div class='act'>
".$list['confession']."
</div>
<div class='options'>
";
echo "<div class='cstamp'>".$list['cstamp']."</div><div class='right'>";
echo "</div>
</div>
</div><br>";
}
?>
<div align="center">
<br><br>
<?php
$range = 5;
if ($currentpage > 1) {
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> ";
$prevpage = $currentpage - 1;
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> ";
}
for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) {
if (($x > 0) && ($x <= $totalpages)) {
if ($x == $currentpage) {
echo " <span class='activepage'>{$x}</span> ";
} else {
echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> ";
}
}
}
if ($currentpage != $totalpages) {
$nextpage = $currentpage + 1;
if($totalpages>1)
{
echo " <span class='nextpage'><a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a></span> ";
echo " <span class='nextpage'><a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a></span> ";
}
}
?>
</div>
<?php
}
?>
</div>
<br>
<div align="center"><h4><u>Submit Confession</u></h4></div>
<form id='confessionsform' align='center' action="submitconf.php" method="POST">
<!-- FORM FOR SUBMITTING CONFESSIONS TO THE USER -->
<textarea name='confession' placeholder="Confession" id='confessionarea'></textarea>
<br>
<button type="submit" id='submit'>Submit</button>
</form>
<?php
?>
</main>
<?php
include 'footer.php';
?>
</body>
</html>