-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhome.php
More file actions
295 lines (270 loc) · 12.8 KB
/
home.php
File metadata and controls
295 lines (270 loc) · 12.8 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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
<?php
// Start the session to maintain user login state
session_start();
// Check if user is logged in, redirect if not
if (!isset($_SESSION['user_id'])) {
header("Location: login.htm");
exit();
}
// gaouser dont make the mistake again
require 'api/v1/db_connection.php';
// Get user's guilds
$userId = $_SESSION['user_id'];
$stmt = $conn->prepare("SELECT g.id, g.name, g.guild_icon FROM guilds g
JOIN guild_members gm ON g.id = gm.guild_id
WHERE gm.user_id = ?");
$stmt->bind_param("i", $userId);
$stmt->execute();
$result = $stmt->get_result();
$guilds = [];
while ($row = $result->fetch_assoc()) {
$guilds[] = $row;
}
$stmt->close();
// Get user's direct message channels
$stmt = $conn->prepare("SELECT dmc.channel_id, u.username AS user1_name, u2.username AS user2_name
FROM direct_message_channels dmc
JOIN users u ON dmc.user1_id = u.id
JOIN users u2 ON dmc.user2_id = u2.id
WHERE dmc.user1_id = ? OR dmc.user2_id = ?");
$stmt->bind_param("ii", $userId, $userId);
$stmt->execute();
$result = $stmt->get_result();
$dms = [];
while ($row = $result->fetch_assoc()) {
$dms[] = [
"channel_id" => $row['channel_id'],
"name" => ($row['user1_name'] === $_SESSION['username']) ? $row['user2_name'] : $row['user1_name']
];
}
$stmt->close();
// Get current guild info if specified
$currentGuildId = isset($_GET['guild_id']) ? (int)$_GET['guild_id'] : (count($guilds) > 0 ? $guilds[0]['id'] : null);
$currentGuildName = "";
$currentGuildIcon = "";
if ($currentGuildId) {
$stmt = $conn->prepare("SELECT name, guild_icon FROM guilds WHERE id = ?");
$stmt->bind_param("i", $currentGuildId);
$stmt->execute();
$stmt->bind_result($currentGuildName, $currentGuildIcon);
$stmt->fetch();
$stmt->close();
}
$conn->close();
?>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>OpenGuild</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
<link href="styles.css" rel="stylesheet">
</head>
<body bgcolor="#212121">
<table width="100%" height="100%" cellpadding="0" cellspacing="0">
<!-- Guild Name -->
<tr width="100%" valign="top" height=50>
<td><img src="openguildappoff.png" id="openguild-icon" style="margin: 8px; cursor: pointer;"></td>
<td height=50 width="100%" id="guild-name" valign=middle align=middle>
<?php echo htmlspecialchars($currentGuildName); ?>
</td>
</tr>
<!-- Categories and Channels -->
<tr valign="top" height=100%>
<td>
<table width="100%" height="100%" cellpadding="0" cellspacing="0">
<tr>
<td align=center>
<div id="guild-list">
<?php foreach ($guilds as $guild): ?>
<div class="guild-item <?php echo ($guild['id'] == $currentGuildId) ? 'active-guild' : ''; ?>"
data-guild-id="<?php echo $guild['id']; ?>">
<?php if (!empty($guild['guild_icon'])): ?>
<img src="<?php echo htmlspecialchars($guild['guild_icon']); ?>" alt="Guild Icon" style="width: 100%; height: 100%; object-fit: cover;">
<?php else: ?>
<div style="width: 100%; height: 100%; background-color: #444; display: flex; align-items: center; justify-content: center;">
<?php echo htmlspecialchars($guild['name']); ?>
</div>
<?php endif; ?>
</div>
<?php endforeach; ?>
<img src="newserver.png" id="create-guild-btn" style="cursor: pointer;">
</div>
</td>
</tr>
</table>
</td>
<td width="100%">
<table height=100% cellspacing=0 cellpadding=0>
<tr height=100%>
<td height=100%>
<table width=100% cellspacing=0 cellpadding=12 height=100% bgcolor=#1e1e1e>
<tr>
<td valign=middle>
<div id="channels-list" style="width: 200px; height: 100%; background-color: #1e1e1e;" class="scrollable-container">
<!-- Channels will be loaded here -->
</div>
</td>
</tr>
</table>
</td>
<td width=100% height=100%>
<div id="message-container" style="height: 100%; min-width: 100%;" class="message-container" class="scrollable-container">
<!-- Messages will be loaded here -->
</div>
</td>
<td>
<div id="members-list" style="width: 200px; height: 100%; background-color: #1e1e1e; padding: 10px;">
<h4 style="color: rgba(8,156,68,1); margin-bottom: 10px;">Members</h4>
<div id="members-container"></div>
</div>
</td>
</tr>
<tr>
<td>
<table cellpadding=5>
<tr>
<td width=100% align=center><?php echo($_SESSION['username']);?></td>
<td><img src=cog.png id="cog-icon" style="cursor: pointer;"></td>
</tr>
</table>
</td>
<td>
<input id="message-input" class="message-box" placeholder="Type your message..."></input>
<!-- <button id="send-message-btn">Send</button> -->
</td>
</tr>
</table>
</td>
</tr>
<!-- Message Input -->
</table>
<!-- User Settings Modal -->
<div id="user-settings-modal" class="user-set-modal" style="display: none;">
<div class="modal-content">
<h3>User Settings</h3>
<table width="100%" cellpadding="10" cellspacing="0">
<tr>
<!-- Left Side: Settings Form -->
<td width="50%" valign="top">
<div class="settings-form">
<div class="form-group">
<label for="banner-image-url">Banner Image URL:</label>
<input type="text" id="banner-image-url" placeholder="Enter banner image URL" class="settings-input">
</div>
<div class="form-group">
<label for="pfp-url">Profile Picture URL:</label>
<input type="text" id="pfp-url" placeholder="Enter profile picture URL" class="settings-input">
</div>
<div class="form-group">
<label for="gradient-color-1">Gradient Color 1:</label>
<div class="color-input-wrapper">
<input type="text" id="gradient-color-1" placeholder="#RRGGBB" class="settings-input color-code">
<input type="color" id="gradient-color-1-picker" class="color-picker">
</div>
</div>
<div class="form-group">
<label for="gradient-color-2">Gradient Color 2:</label>
<div class="color-input-wrapper">
<input type="text" id="gradient-color-2" placeholder="#RRGGBB" class="settings-input color-code">
<input type="color" id="gradient-color-2-picker" class="color-picker">
</div>
</div>
<div class="form-actions">
<button id="save-user-settings" class="settings-button">Save</button>
<button id="close-user-settings" class="settings-button">Cancel</button>
</div>
<div class="form-group">
<label for="user-status">Status:</label>
<select id="user-status" class="settings-input">
<option value="0">Offline (Invisible)</option>
<option value="1">Online</option>
<option value="2">Do Not Disturb</option>
<option value="3">Away</option>
<option value="4">Developing</option>
<option value="5">Gaming</option>
</select>
</div>
</div>
</td>
<!-- Right Side: Profile Preview -->
<!-- Right Side: Profile Preview -->
<td width="50%" valign="top">
<div id="user-profile-preview" style="width: 320px; height: 480px; position: relative; border-radius: 8px; overflow: hidden;">
<!-- Gradient Background -->
<div id="preview-gradient" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"></div>
<!-- Profile Picture (Positioned at the Top) -->
<div id="preview-pfp" style="position: absolute; z-index: 2000; top: 40px; left: 20px; width: 80px; height: 80px; border-radius: 50%; background-size: cover; background-position: center; border: 4px solid #1e1e1e;">
<div class="status-indicator status-<?php echo $user_status; ?>"></div>
</div> <!-- Banner Image -->
<div id="preview-banner" style="position: absolute; top: 0; left: 0; width: 100%; height: 100px; background-size: cover; background-position: center;"></div>
</div>
</td>
</tr>
</table>
</div>
</div>
<!-- Create Guild Form -->
<div class="overlay" id="overlay"></div>
<div class="create-guild-form" id="create-guild-form">
<h3>Create New Guild</h3>
<input type="text" id="guild-name-input" placeholder="Guild Name">
<button id="submit-guild-btn">Create</button>
<button id="cancel-guild-btn">Cancel</button>
</div>
<!-- Guild Name Context Menu -->
<div id="guild-name-context-menu" class="context-menu" style="display: none;">
<ul>
<li id="invite-guild">Invite</li>
<li id="settings-guild">Settings</li>
</ul>
</div>
<!-- Full-Screen Settings Modal -->
<div id="settings-modal" class="modal" style="display: none;">
<div class="modal-content">
<h3>Guild Settings</h3>
<label for="guild-icon-url">Guild Icon URL:</label>
<input type="text" id="guild-icon-url" placeholder="Enter image URL">
<button id="save-guild-icon">Save</button>
<button id="close-settings-modal">Close</button>
</div>
</div>
<script>
const currentGuildId = <?php echo $currentGuildId ? $currentGuildId : 'null'; ?>;
const currentGuildName = "<?php echo htmlspecialchars($currentGuildName); ?>";
const currentGuildIcon = "<?php echo htmlspecialchars($currentGuildIcon); ?>";
const guilds = <?php echo json_encode($guilds); ?>;
const userId = <?php echo $_SESSION['user_id']; ?>;
const username = "<?php echo $_SESSION['username']; ?>";
</script>
<!-- Message Context Menu -->
<div id="message-context-menu" class="context-menu" style="display: none;">
<ul>
<li id="delete-message-option">Delete Message</li>
</ul>
</div>
<!-- Add DM section -->
<div id="dm-list" style="width: 200px; height: 100%; background-color: #1e1e1e; padding: 10px;">
<h4 style="color: rgba(8,156,68,1); margin-bottom: 10px;">Direct Messages</h4>
<?php foreach ($dms as $dm): ?>
<div class="dm-item" data-channel-id="<?php echo $dm['channel_id']; ?>" style="cursor: pointer; margin-bottom: 10px;">
<?php echo htmlspecialchars($dm['name']); ?>
</div>
<?php endforeach; ?>
</div>
<script>
// Add event listeners for DM items
document.querySelectorAll('.dm-item').forEach(item => {
item.addEventListener('click', function() {
const channelId = this.getAttribute('data-channel-id');
currentChannelId = channelId;
fetchMessages();
});
});
</script>
<script src="home.js">
</script>
</body>
</html>