-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdashboard.php
executable file
·155 lines (145 loc) · 5.29 KB
/
dashboard.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
<?php
// Restrict access only to administrators
$administrators = [1];
require_once "./configuration.php";
require_once "./languages.php";
// Check if user is logged in
$row = verifySession(true);
if (!$row) {
logout();
die();
}
$userId = $row["user_id"];
if ($maintenance && !in_array($userId, $administrators)) {
header("Location: ./maintenance");
die();
}
$sql = "UPDATE `profiles` SET `last_active`=CURRENT_TIMESTAMP WHERE `user_id`=$userId";
$connection->query($sql) or die(word("error-occurred") . " CULA1"); // Code update last active 1
?>
<!DOCTYPE html>
<html lang="<?php echo $htmlLang; ?>">
<head>
<title><?php echo word("dashboard"); ?></title>
<?php echo metaTags(2); ?>
<link rel="stylesheet" href="<?php echo fileLink("assets/dashboard.css"); ?>">
<script src="https://kit.fontawesome.com/d6e7bd37b5.js" crossorigin="anonymous"></script>
</head>
<body>
<div class="container">
<div class="main">
<div class="profiles-block">
<div class="newMsgBtnWrapper">
<button class="newMsgBtn" onclick="my.newChat()"><i class="fa-regular fa-pen-to-square"></i> <?php echo word("new-message"); ?></button>
</div>
<div class="profiles-list-wrapper">
<ul id="profiles-list"></ul>
<div class="loader"></div>
</div>
<div class="my-profile-section">
<div class="my-profile-block" onclick="my.profile.modal()">
<!-- Later on there will be a row value for dnd, online, or appear offline -->
<div class="profile-picture-wrapper">
<img id="myPicture" class="online" src="<?php echo $row["picture"]; ?>">
<div class="status-circle online"></div>
</div>
<div>
<span id="myName"><?php echo $row["name"]; ?></span>
<br>
<span id="myUsername">@<?php echo $row["username"]; ?></span>
</div>
</div>
<button onclick="my.settings.modal()"><i class="fas fa-gear"></i></button>
</div>
</div>
<div class="messages-block">
<div class="recipientBlock" style="display:none;">
<button class="backBtn" onclick="showProfileList()"><i class="fa-solid fa-chevron-left"></i></button>
<img>
<div>
<span></span>
<br>
<span></span>
</div>
</div>
<div class="messagesContainer" style="display: none;">
<div class="messages">
<div class="loader"></div>
<label><?php echo word("loading-messages"); ?></label>
</div>
</div>
<div class="messageBar" style="display:none;">
<button class="mediaBtn"><i class="fa-solid fa-upload"></i></button>
<textarea class="msg" placeholder="Message"></textarea>
<button class="sendBtn"><i class="fa-solid fa-arrow-right"></i></button>
</div>
<div class="no-profile-selection">
<p><?php echo word("nothing-to-see"); ?></p>
</div>
</div>
</div>
</div>
<script src="<?php echo fileLink("node_modules/jquery/dist/jquery.min.js"); ?>"></script>
<script src="<?php echo fileLink("node_modules/sweetalert2/dist/sweetalert2.all.min.js"); ?>"></script>
<link rel="stylesheet" href="<?php echo fileLink("assets/swal-dark.css"); ?>">
<script>
const vapidPublic = <?php echo '"' . $vapidPublic . '";'; if ($row["username"] === null) { ?>
Swal.fire({
title: "<?php echo word("pick-username"); ?>",
input: "text",
inputAttributes: {
autocapitalize: "off",
spellcheck: "false"
},
showCancelButton: false,
allowEscapeKey: false,
allowOutsideClick: false,
confirmButtonText: "<?php echo word("continue"); ?>",
showLoaderOnConfirm: true,
preConfirm: (username) => {
if (username === "") {
Swal.showValidationMessage(
`<?php echo word("blank-username"); ?>`
)
} else {
if (RegExp(/[-!#@$%^&*()_+|~=`{}\[\]:";"<>?,.\\\/\s]/g).test(username)) {
Swal.showValidationMessage(
`<?php echo word("invalid-username-characters"); ?>`
)
} else {
return $.post("processes", {
process: "updateUsername",
data: username
})
.then(response => {
console.log(response);
response = JSON.parse(response);
if (!response.ok) {
throw new Error(response.statusText)
}
return response
})
.catch(error => {
Swal.showValidationMessage(
error
)
})
}
}
}
//allowOutsideClick: () => !Swal.isLoading()
}).then((result) => {
if (result.isConfirmed) {
console.log(result.value)
Toast.fire({
icon: "success",
title: `<?php echo word("welcome,"); ?> ${result.value.username}`,
})
}
})
<?php } ?>
</script>
<script src="<?php echo fileLink("assets/jquery.quickfit.js"); ?>"></script>
<script src="<?php echo fileLink("assets/dashboard.js"); ?>"></script>
</body>
</html>