-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathindex.php
executable file
·134 lines (127 loc) · 6.82 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
<?php
session_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="mobile-web-app-capable" content="yes">
<link href="/src/styles/styles.css" rel="stylesheet">
<link href="/src/styles/timeline.css" rel="stylesheet">
<link href="/src/styles/menus.css" rel="stylesheet">
<link href="/src/styles/responsive.css" rel="stylesheet">
<script defer src="https://cdn.jsdelivr.net/npm/@twemoji/api@latest/dist/twemoji.min.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.6.0/css/all.min.css" integrity="sha512-Kc323vGBEqzTmouAECnVceyQqyqdsSiqLQISBL29aUW4U/M7pSPA/gEUZQqv1cwx4OnYxTxve5UMg5GT6L4JJg==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script src="/src/scripts/general.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<title>Compose a Chirp - Chirp</title>
</head>
<body>
<header>
<div id="desktopMenu">
<nav>
<img src="/src/images/icons/chirp.svg" alt="Chirp" onclick="playChirpSound()">
<a href="/"><img src="/src/images/icons/house.svg" alt=""> Home</a>
<a href="explore"><img src="/src/images/icons/search.svg" alt=""> Discover</a>
<?php if (isset($_SESSION['username'])): ?>
<a href="/notifications"><img src="/src/images/icons/bell.svg" alt=""> Notifications</a>
<a href="/messages"><img src="/src/images/icons/envelope.svg" alt=""> Direct Messages</a>
<a href="<?php echo isset($_SESSION['username']) ? '/user?id=' . htmlspecialchars($_SESSION['username']) : '/signin'; ?>">
<img src="/src/images/icons/person.svg" alt=""> Profile
</a>
<?php endif; ?>
</nav>
<div id="menuSettings">
<?php if (isset($_SESSION['username']) && $_SESSION['username'] == 'chirp'): ?>
<a href="/admin">🛡️ Admin panel</a>
<?php endif; ?>
<a href="/settings/account">⚙️ Settings</a>
<?php if (isset($_SESSION['username'])): ?>
<a href="/signout.php">🚪 Sign out</a>
<?php else: ?>
<a href="/signin/">🚪 Sign in</a>
<?php endif; ?>
</div>
<button id="settingsButtonWrapper" type="button" onclick="showMenuSettings()">
<img class="userPic" src="<?php echo isset($_SESSION['profile_pic']) ? htmlspecialchars($_SESSION['profile_pic']) : '/src/images/users/guest/user.svg'; ?>"
alt="<?php echo isset($_SESSION['username']) ? htmlspecialchars($_SESSION['username']) : 'guest'; ?>">
<div>
<p class="usernameMenu"><?php echo isset($_SESSION['name']) ? htmlspecialchars($_SESSION['name']) : 'Guest'; ?>
<?php if (isset($_SESSION['is_verified']) && $_SESSION['is_verified']): ?>
<img class="emoji" src="/src/images/icons/verified.svg" alt="Verified">
<?php endif; ?>
</p>
<p class="subText">
@<?php echo isset($_SESSION['username']) ? htmlspecialchars($_SESSION['username']) : 'guest'; ?>
</p>
</div>
<p class="settingsButton">⚙️</p>
</button>
</div>
</header>
<main>
<div id="cancelModal" class="modal">
<div class="modal-content">
<h2>Save as draft?</h2>
<p>It seems like you've written something without chirping it.<br>Do you want Chirpie to hold on to what you wrote and store it as a draft on your device?</p>
<button id="saveDraftButton" class="modal-button">Save as draft</button>
<button id="discardDraftButton" class="modal-button">No</button>
</div>
</div>
<div id="feedCompose">
<div id="iconChirp">
<img src="/src/images/icons/chirp.svg" alt="Chirp">
</div>
<div class="title">
<p class="selected">Compose a Chirp</p>
</div>
<form method="POST" action="/compose/submit.php">
<div id="composer">
<textarea name="chirpComposeText" maxlength="500" placeholder="What's on your mind?" oninput="updateCharacterCount(this)"></textarea>
</div>
<div id="exploreChirp" class="searchButtons">
<button type="button" class="cancelChirp" onclick="slideDown()">Cancel</button>
<p id="charCount">500 characters remaining</p>
<button type="submit" class="postChirp" onclick="slideDownPost()">Chirp</button>
</div>
</form>
<div class="title">
<p class="selected">Drafts</p>
</div>
<div class="drafts-container">
<p class="subText">You have no drafts.</p>
</div>
</div>
</main>
<aside id="sideBar">
<?php include '../include/sideBar.php';?>
</aside>
<footer>
<div class="mobileMenuFooter">
<a href="/"><img src="/src/images/icons/house.svg" alt="Home"></a>
<a href="/discover"><img src="/src/images/icons/search.svg" alt="Discover"></a>
<a href="/notifications"><img src="/src/images/icons/bell.svg" alt="Notifications"></a>
<a href="/messages"><img src="/src/images/icons/envelope.svg" alt="Direct Messages"></a>
<a href="<?php echo isset($_SESSION['username']) ? '/user?id=' . htmlspecialchars($_SESSION['username']) : '/signin'; ?>"><img src="/src/images/icons/person.svg" alt="Profile"></a>
</div>
</footer>
<script>
<?php
if (isset($_SESSION['error_message'])) {
echo 'console.error(' . json_encode($_SESSION['error_message']) . ');';
unset($_SESSION['error_message']); // Clear the error message after displaying it
}
?>
function updateCharacterCount(textarea) {
const maxChars = 500;
const charCountElement = document.getElementById('charCount');
const remainingChars = maxChars - textarea.value.length;
charCountElement.textContent = `${remainingChars} characters remaining`;
}
</script>
</body>
</html>