-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadvanced-search.php
More file actions
211 lines (178 loc) · 4.92 KB
/
advanced-search.php
File metadata and controls
211 lines (178 loc) · 4.92 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
<?php
session_start();
// Check if the user is logged in, redirect to chat.php
if (!isset($_SESSION['username'])) {
header('Location: login.php');
exit();
}
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">
<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">
<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;
}
mark {
color: BLACK; /* Using hexadecimal */
background-color: #f5beba;
}
</style>
<style>
#searchResults {
margin-top: 20px;
}
.thumbnail {
max-width: 150px;
max-height: 150px;
margin-bottom: 10px;
background-color: #fff;
padding: 5px;
border-radius: 10px;
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('/service-worker.js')
.then(registration => {
console.log('Service Worker registered with scope:', registration.scope);
})
.catch(error => {
console.error('Service Worker registration failed:', error);
});
}
</script>
<title>CAS - Database</title>
</head>
<body>
<?php
include('lib/nav.php');
include('lib/sus_re_dir.php');
?>
<div id="options-container">
<h1>Advanced Search</h1>
<input
type="text"
id="searchTerm"
placeholder="Enter search term"
value="<?php echo date('y.m.d'); ?>"
onkeydown="handleKeyPress(event)"
onfocus="clearDateValue(this)"
onclick="clearDateValue(this)"
/>
<button onclick="searchFiles()" style="display: block; margin-top: 7px;">Search</button>
<div id="searchResults"></div>
<script>
function searchFiles() {
var searchTerm = document.getElementById("searchTerm").value.trim();
if (searchTerm === "") {
alert("Please enter a search term.");
return;
}
var xhr = new XMLHttpRequest();
xhr.open(
"GET",
"search.php?term=" + encodeURIComponent(searchTerm),
true
);
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
document.getElementById("searchResults").innerHTML = xhr.responseText;
}
};
xhr.send();
}
function handleKeyPress(event) {
if (event.keyCode === 13) {
// Check if Enter key is pressed
event.preventDefault(); // Prevent form submission
searchFiles(); // Trigger the searchFiles function
}
}
function clearDateValue(input) {
input.value = "";
}
</script>
</div>
</body>
</html>