-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathadmin.php
More file actions
213 lines (183 loc) · 6.87 KB
/
admin.php
File metadata and controls
213 lines (183 loc) · 6.87 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
<?php
session_start();
// Check if the user is logged in
if (!isset($_SESSION['user_id'])) {
// Redirect to the login page or display a message
$error = "পাতাটি দেখতে আগে সাইনইন করুন।";
header("Location: signin_page.php?error=" . urlencode($error));
exit();
}
if (isset($_SESSION['role'])) {
if ($_SESSION['role'] != "admin") {
// Redirect to the login page or display a message
$error = "পাতাটি শুধুমাত্র ব্যবস্থাপকদের জন্য বরাদ্দ।";
header("Location: index.php?error=" . urlencode($error));
exit();
}
}
// Include the database connection file
include 'db-connection.php'; // Replace with the actual path to your database connection file
// Initialize variables to store data
$analyticsData = array();
$visitsData = array();
$contactsData = array(); // Added a new array for contacts data
// Query to retrieve data from the Analytics table
$analyticsQuery = "SELECT id, event_type, event_description, event_datetime FROM analytics ORDER BY event_datetime DESC LIMIT 10";
// Execute the query
$analyticsResult = $conn->query($analyticsQuery);
// Check if the query was successful
if ($analyticsResult) {
// Fetch data from the Analytics table and store it in the $analyticsData array
while ($row = $analyticsResult->fetch_assoc()) {
$analyticsData[] = $row;
}
} else {
// Handle any database query errors for the Analytics table
echo "Error: ";
}
// Query to retrieve data from the Visits table
$visitsQuery = "SELECT id, ip_address, visit_datetime FROM visits ORDER BY visit_datetime DESC LIMIT 10";
// Execute the query
$visitsResult = $conn->query($visitsQuery);
// Check if the query was successful
if ($visitsResult) {
// Fetch data from the Visits table and store it in the $visitsData array
while ($row = $visitsResult->fetch_assoc()) {
$visitsData[] = $row;
}
} else {
// Handle any database query errors for the Visits table
echo "Error: ";
}
// Query to retrieve data from the Contacts table (corrected variable names)
$contactsQuery = "SELECT contact_id, email FROM contacts ORDER BY contact_id DESC LIMIT 10";
// Execute the query
$contactsResult = $conn->query($contactsQuery);
// Check if the query was successful
if ($contactsResult) {
// Fetch data from the Contacts table and store it in the $contactsData array
while ($row = $contactsResult->fetch_assoc()) {
$contactsData[] = $row;
}
} else {
// Handle any database query errors for the Contacts table
echo "Error: ";
}
// Close the database connection
$conn->close();
?>
<!-- Header -->
<?php
include_once('pagename.php');
$page = 'admin';
include_once('header.php');
include_once('message.php');
?>
<section class="admin">
<div class="container mt-4">
<div class="row justify-content-center">
<div class="col-lg-9">
<div class="c_title text-center">
<h1 class="c_h1 yellow form-title">ব্যাবস্থাপনা পাতা</h1>
<p class="c_p ash">সব তথ্য দেখুন</p>
</div>
</div>
</div>
<div class="row justify-content-center">
<div class="col-lg-9">
<div class="c_title text-center">
<strong class="c_p ash">পরিসংখ্যান</strong>
</div>
</div>
</div>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>আইডি</th>
<th>ঘটনা</th>
<th>বর্ণনা</th>
<th>তারিখ ও সময়</th>
</tr>
</thead>
<tbody>
<?php
// Loop through and display data from the Analytics table
foreach ($analyticsData as $row) {
echo '<tr>';
echo '<td>' . $row['id'] . '</td>';
echo '<td>' . $row['event_type'] . '</td>';
echo '<td>' . $row['event_description'] . '</td>';
echo '<td>' . $row['event_datetime'] . '</td>';
echo '</tr>';
}
?>
</tbody>
</table>
</div>
<div class="row justify-content-center" style="margin-top: 50px;">
<div class="col-lg-9">
<div class="c_title text-center">
<strong class="c_p ash">ভিজিটের তথ্য</strong>
</div>
</div>
</div>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>আইডি</th>
<th>আইপি এড্রেস</th>
<th>তারিখ ও সময়</th>
</tr>
</thead>
<tbody>
<?php
// Loop through and display data from the Visits table
foreach ($visitsData as $row) {
echo '<tr>';
echo '<td>' . $row['id'] . '</td>';
echo '<td>' . $row['ip_address'] . '</td>';
echo '<td>' . $row['visit_datetime'] . '</td>';
echo '</tr>';
}
?>
</tbody>
</table>
</div>
<div class="row justify-content-center" style="margin-top: 50px;">
<div class="col-lg-9">
<div class="c_title text-center">
<strong class="c_p ash">যোগাযোগ তথ্য</strong>
</div>
</div>
</div>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>আইডি</th>
<th>ইমেইল ঠিকানা</th>
</tr>
</thead>
<tbody>
<?php
// Loop through and display data from the Visits table
foreach ($contactsData as $row) {
echo '<tr>';
echo '<td>' . $row['contact_id'] . '</td>';
echo '<td>' . $row['email'] . '</td>';
echo '</tr>';
}
?>
</tbody>
</table>
</div>
</div>
</section>
<?php
// Include the footer file
include_once('footer.php');
?>
</body>
</html>