-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
290 lines (248 loc) · 9.56 KB
/
index.php
File metadata and controls
290 lines (248 loc) · 9.56 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
<?php
include('config.php');
session_start(); // Start the session
include('sessionCheck.php');
if(isset($_GET['exit'])){}
// Check if $_SESSION['selected_session'] is set
if (isset($_SESSION['selected_session'])) {
// Unset (remove) $_SESSION['selected_session']
unset($_SESSION['selected_session']);
}
//retriving user info
$username = $_SESSION['username'];
$userDataFile = "users/" . $username . ".php";
// Function to get user data from file
function getUserData($userDataFile) {
$userData = array();
if (file_exists($userDataFile)) {
$lines = file($userDataFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($lines as $line) {
list($key, $value) = explode(':', $line, 2);
$userData[trim($key)] = trim($value);
}
}
return $userData;
}
$userData = getUserData($userDataFile);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/style.css">
<script href="js/offline.js"></script>
<link rel="icon" type="image/png" href="favicon.png">
<link rel="manifest" href="manifest.json">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="lib/icons/css/all.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<style>
body {
font-family: 'Arial', sans-serif;
margin: 0;
padding: 0;
background-color: #f5f5f5;
}
#options-container {
max-width: 800px;
margin: 50px auto;
background-color: #fff;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h2 {
color: #333;
}
ul {
list-style: none;
padding: 0;
}
li {
margin-bottom: 10px;
}
p {
margin: 0;
}
input[type="text"] {
padding: 8px;
width: 100%;
box-sizing: border-box;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 10px;
}
th,
td {
border: 1px solid #ddd;
padding: 8px;
text-align: left;
}
th {
background-color: #f2f2f2;
}
a {
text-decoration: none;
color: #3498db;
}
.thumbnail {
max-width: 150px;
max-height: 150px;
background-color: #fff;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
transition: transform 0.2s ease-in-out; /* Add transition for smooth scaling */
}
.thumbnail:hover {
transform: scale(3); /* Scale the image by 10% on hover */
}
</style>
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/js/offline.js');
}
</script>
<script>
if (typeof navigator.serviceWorker !== 'undefined') {
navigator.serviceWorker.register('/js/offline.js')
}
</script>
<title>CMA - Collaboration Management Assistant</title>
</head>
<body>
<?php
$pageName ='index.php';
include('lib/nav.php');
include('lib/sus_re_dir.php');
?>
<div id="options-container">
<ul>
<table border="1" id="recordsTable">
<thead>
<tr>
<th>
<input type="text" id="searchInput" placeholder="Search Record" onkeyup="filterRecords()"><a href="advanced-search.php"><i class="fa-solid fa-magnifying-glass"> </i> Advanced search</a>
</th>
</tr>
</thead>
</table>
<table border="1" id="itemsTable">
<thead>
<tr>
<th>
<font size="3"><i id="update-icon"></i>
<i class="fa-solid fa fa-hdd-o"> </i> </font> <font size="2"><?php include('lib/size.php'); ?></font>
<script>
function fetchUpdateStatus() {
$.ajax({
url: 'update_request.php',
method: 'GET',
success: function(data) {
$('#update-icon').html(data);
},
error: function() {
$('#update-icon').html('<p>Error loading update status</p>');
}
});
}
// Fetch update status immediately
fetchUpdateStatus();
// Set interval to fetch update status every 30 seconds
setInterval(fetchUpdateStatus, 30000);
</script>
</th>
</tr>
</thead>
<tbody>
<?php
// Function to get all available chat sessions
function getAvailableSessions() {
$sessionFolder = "sessions/";
$sessions = glob($sessionFolder . "*_session.txt");
$result = [];
foreach ($sessions as $sessionFile) {
$content = file_get_contents($sessionFile);
// Use a regular expression to find the first image name in the file
$pattern = '/\[file: (.*?\.(?:jpg|png|gif))\]/i';
if (preg_match($pattern, $content, $matches)) {
$imageName = $matches[1];
} else {
$imageName = '../lib/img/folder-open.png';
}
$sessionName = basename($sessionFile, '_session.txt');
$result[] = [
'name' => $sessionName,
'image' => $imageName
];
}
return $result;
}
$availableSessions = getAvailableSessions();
// Set caching headers for images
$cacheTime = 604800; // 1 week (604800 seconds)
$cacheExpire = gmdate('D, d M Y H:i:s', time() + $cacheTime) . ' GMT';
header('Cache-Control: public, max-age=' . $cacheTime . ', immutable');
header('Expires: ' . $cacheExpire);
foreach ($availableSessions as $session) {
echo '<tr><td>';
if (!empty($session['image'])) {
$imageModifiedTime = filemtime('images/' . $session['image']);
$imageUrl = 'images/' . $session['image'] . '?v=' . $imageModifiedTime;
echo '<img src="' . $imageUrl . '"
class="thumbnail"
alt="Session Image"
width="50"
height="30"
style="
object-fit: cover;
margin-right: 10px;
border-radius: 2px;
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
">';
}
echo '<a href="login.php?session=' . $session['name'] . '">' . $session['name'] . '</a></td></tr>';
}
?>
</tbody>
</table>
</ul>
</div>
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', function () {
navigator.serviceWorker.register('/service-worker.js')
.then(function (registration) {
console.log('Service Worker registered:', registration);
})
.catch(function (err) {
console.log('Service Worker registration failed:', err);
});
});
}
</script>
<script>
function filterRecords() {
var input, filter, table, tr, td, i, txtValue;
input = document.getElementById("searchInput");
filter = input.value.toUpperCase();
table = document.getElementById("itemsTable");
tr = table.getElementsByTagName("tr");
for (i = 0; i < tr.length; i++) {
td = tr[i].getElementsByTagName("td")[0];
if (td) {
txtValue = td.textContent || td.innerText;
if (txtValue.toUpperCase().indexOf(filter) > -1) {
tr[i].style.display = "";
} else {
tr[i].style.display = "none";
}
}
}
}
</script>
<script src="js/nav.js"></script>
</body>
</html>