1
+ <?php
2
+ session_start ();
3
+ if ($ _SESSION ['admin ' ] != 2 ) {
4
+ header ("Location: ./login.php " );
5
+ }
6
+ include_once ('db.php ' );
7
+
8
+ // user data arrays
9
+ $ articleIDs = array ();
10
+ $ articleNames = array ();
11
+ $ articleTime = array ();
12
+
13
+ $ id = @$ _GET ['id ' ];
14
+ if (isset ($ id )) {
15
+ $ result = $ conn ->query ("delete from document where id=' $ id' " );
16
+ }
17
+
18
+ $ result = $ conn ->query ("SELECT * FROM document " );
19
+ while ($ row =mysqli_fetch_assoc ($ result ))//将result结果集中查询结果取出一条
20
+ {
21
+ array_push ($ articleIDs ,$ row ["id " ]);
22
+ array_push ($ articleNames ,$ row ["name " ]);
23
+ array_push ($ articleTime , $ row ["time " ]);
24
+
25
+ }
26
+
27
+ // encode to json format for js
28
+ $ articleIDs = json_encode ($ articleIDs );
29
+ $ articleNames = json_encode ($ articleNames );
30
+ $ articleTime = json_encode ($ articleTime );
31
+
32
+
33
+
34
+ ?>
35
+
36
+ <!DOCTYPE html>
37
+ <html lang="en">
38
+
39
+ <head>
40
+
41
+ <meta charset="utf-8">
42
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
43
+ <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
44
+ <meta name="description" content="">
45
+ <meta name="author" content="">
46
+
47
+ <title>Summarize</title>
48
+
49
+ <!-- Custom fonts for this template-->
50
+ <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.css">
51
+ <link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
52
+ <link
53
+ href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i"
54
+ rel="stylesheet">
55
+
56
+ <!-- Custom styles for this template-->
57
+ <link href="css/sb-admin-2.min.css" rel="stylesheet">
58
+ <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.css">
59
+
60
+ </head>
61
+
62
+ <body id="page-top">
63
+
64
+ <!-- Page Wrapper -->
65
+ <div id="wrapper">
66
+
67
+ <!-- Sidebar -->
68
+ <ul class="navbar-nav bg-gradient-primary sidebar sidebar-dark accordion" id="accordionSidebar">
69
+
70
+ <!-- Sidebar - Brand -->
71
+ <a class="sidebar-brand d-flex align-items-center justify-content-center" href="#">
72
+ <div class="sidebar-brand-icon rotate-n-15">
73
+ <i class="fa fa-file-text"></i>
74
+ </div>
75
+ <div class="sidebar-brand-text mx-3">X-uni <sup>v3</sup></div>
76
+ </a>
77
+
78
+ <!-- Divider -->
79
+ <hr class="sidebar-divider my-0">
80
+
81
+ <!-- Nav Item - Dashboard -->
82
+ <li class="nav-item">
83
+ <a class="nav-link" href="./userPanel.php">
84
+ <i class="fa fa-address-card"></i>
85
+ <span>User Panel</span></a>
86
+ </li>
87
+
88
+ <li class="nav-item active">
89
+ <a class="nav-link" href="./articlePanel.php">
90
+ <i class="fa fa-file-text"></i>
91
+ <span>Article Panel</span></a>
92
+ </li>
93
+
94
+
95
+ </ul>
96
+ <!-- End of Sidebar -->
97
+
98
+ <!-- Content Wrapper -->
99
+ <div id="content-wrapper" class="d-flex flex-column">
100
+
101
+ <!-- Main Content -->
102
+ <div id="content">
103
+
104
+ <!-- Topbar -->
105
+ <nav class="navbar navbar-expand navbar-light bg-white topbar mb-4 static-top shadow">
106
+
107
+ <!-- Sidebar Toggle (Topbar) -->
108
+ <button id="sidebarToggleTop" class="btn btn-link d-md-none rounded-circle mr-3">
109
+ <i class="fa fa-bars"></i>
110
+ </button>
111
+
112
+ <div class="col-6">
113
+ <!-- !!!!!!!!!!!!!!! -->
114
+ <h5 class="m-0 font-weight-bold text-primary">Welcome back, Manager</h5>
115
+ </div>
116
+
117
+ <!-- Topbar Navbar -->
118
+ <ul class="navbar-nav ml-auto">
119
+
120
+ <!-- Nav Item - User Information -->
121
+ <li class="nav-item dropdown no-arrow">
122
+ <a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button"
123
+ data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
124
+ <span class="mr-2 d-none d-lg-inline text-gray-600 small"><?php echo $ _SESSION ['name ' ];?> </span>
125
+ <img class="img-profile rounded-circle"
126
+ src="img/undraw_profile.svg">
127
+ </a>
128
+ <?php if (isset ($ _SESSION ['admin ' ])) :?>
129
+ <!-- Dropdown - User Information -->
130
+ <div class="dropdown-menu dropdown-menu-right shadow animated--grow-in"
131
+ aria-labelledby="userDropdown">
132
+ <a class="dropdown-item" href="#" data-toggle="modal" data-target="#logoutModal">
133
+ <i class="fas fa-sign-out-alt fa-sm fa-fw mr-2 text-gray-400"></i>
134
+ Logout
135
+ </a>
136
+ </div>
137
+ <?php endif ;?>
138
+ </li>
139
+
140
+ </ul>
141
+
142
+ </nav>
143
+ <!-- End of Topbar -->
144
+
145
+ <!-- Begin Page Content -->
146
+ <div class="container-fluid">
147
+
148
+ <!-- Page Heading
149
+ <h1 class="h3 mb-2 text-gray-800">Tables</h1>
150
+ <p class="mb-4">DataTables is a third party plugin that is used to generate the demo table below.
151
+ For more information about DataTables, please visit the <a target="_blank"
152
+ href="https://datatables.net">official DataTables documentation</a>.</p> -->
153
+
154
+ <!-- DataTales Example -->
155
+ <div class="card shadow mb-4">
156
+ <div class="card-header py-3">
157
+ <h6 class="m-0 font-weight-bold text-primary">User Control Panel</h6>
158
+ </div>
159
+ <div class="card-body">
160
+ <div class="table-responsive">
161
+ <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
162
+ <thead>
163
+ <tr>
164
+ <th>ID</th>
165
+ <th>Article Name</th>
166
+ <th>Upload Time</th>
167
+ <th>Manipulation</th>
168
+ </tr>
169
+ </thead>
170
+ <tfoot>
171
+ <tr>
172
+ <th>ID</th>
173
+ <th>Article Name</th>
174
+ <th>Upload Time</th>
175
+ <th>Manipulation</th>
176
+ </tr>
177
+ </tfoot>
178
+
179
+ <!-- !Need Backend! Tbody stores the content of each user information-->
180
+ <tbody id = "userSheet">
181
+
182
+ </tbody>
183
+ </table>
184
+ </div>
185
+ </div>
186
+ </div>
187
+
188
+ </div>
189
+ <!-- /.container-fluid -->
190
+
191
+ </div>
192
+ <!-- End of Main Content -->
193
+
194
+ <!-- Footer -->
195
+ <footer class="sticky-footer bg-white">
196
+ <div class="container my-auto">
197
+ <div class="copyright text-center my-auto">
198
+ <span>Copyright © Your Website 2020</span>
199
+ </div>
200
+ </div>
201
+ </footer>
202
+ <!-- End of Footer -->
203
+
204
+ </div>
205
+ <!-- End of Content Wrapper -->
206
+
207
+ </div>
208
+ <!-- End of Page Wrapper -->
209
+
210
+ <!-- Scroll to Top Button-->
211
+ <a class="scroll-to-top rounded" href="#page-top">
212
+ <i class="fas fa-angle-up"></i>
213
+ </a>
214
+
215
+ <!-- Logout Modal-->
216
+ <div class="modal fade" id="logoutModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
217
+ aria-hidden="true">
218
+ <div class="modal-dialog" role="document">
219
+ <div class="modal-content">
220
+ <div class="modal-header">
221
+ <h5 class="modal-title" id="exampleModalLabel">Ready to Leave?</h5>
222
+ <button class="close" type="button" data-dismiss="modal" aria-label="Close">
223
+ <span aria-hidden="true">×</span>
224
+ </button>
225
+ </div>
226
+ <div class="modal-body">Select "Logout" below if you are ready to end your current session.</div>
227
+ <div class="modal-footer">
228
+ <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
229
+ <a class="btn btn-primary" href="./out.php">Logout</a>
230
+ </div>
231
+ </div>
232
+ </div>
233
+ </div>
234
+
235
+ <!-- Bootstrap core JavaScript-->
236
+ <script src="vendor/jquery/jquery.min.js"></script>
237
+ <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
238
+
239
+ <!-- Core plugin JavaScript-->
240
+ <script src="vendor/jquery-easing/jquery.easing.min.js"></script>
241
+
242
+ <!-- Custom scripts for all pages-->
243
+ <script src="js/sb-admin-2.min.js"></script>
244
+
245
+ <!-- Page level plugins -->
246
+ <script src="vendor/datatables/jquery.dataTables.min.js"></script>
247
+ <script src="vendor/datatables/dataTables.bootstrap4.min.js"></script>
248
+
249
+ <!-- Page level custom scripts -->
250
+ <script src="js/demo/datatables-demo.js"></script>
251
+
252
+ <script type="text/javascript">
253
+ var userIDs = <?php echo $ articleIDs ; ?> ;
254
+ var userNames = <?php echo $ articleNames ; ?> ;
255
+ var userEmails = <?php echo $ articleTime ; ?> ;
256
+
257
+ //
258
+ userSheet = document.getElementById("userSheet");
259
+
260
+ for (var i = 0; i < userIDs.length; i++) {
261
+ // Initial tr
262
+ var tr = document.createElement("tr");
263
+
264
+ // td appends
265
+ var newUserID = document.createElement("td");
266
+ newUserID.innerText = String(userIDs[i]);
267
+ tr.appendChild(newUserID);
268
+
269
+ var newUsername = document.createElement("td");
270
+ newUsername.innerText = String(userNames[i]);
271
+ tr.appendChild(newUsername);
272
+
273
+ var newEmail = document.createElement("td");
274
+ newEmail.innerText = String(userEmails[i]);
275
+ tr.appendChild(newEmail);
276
+
277
+ var newBlock = document.createElement("td");
278
+ tr.appendChild(newBlock);
279
+
280
+ var newButton = document.createElement("a");
281
+ newButton.setAttribute("class", "btn btn-google btn-block");
282
+ newButton.id = String(userIDs[i]);
283
+ newButton.onclick = function() {
284
+ window.location = "./articlePanel.php?id="+this.id;
285
+ }
286
+
287
+
288
+ const trashIcon = document.createElement("i");
289
+ trashIcon.setAttribute("class", "fa fa-bitbucket");
290
+ newButton.appendChild(trashIcon);
291
+
292
+ const ss = document.createElement("span");
293
+ newButton.appendChild(ss);
294
+
295
+ ss.innerText = " Delete";
296
+ tr.appendChild(newButton);
297
+ newBlock.appendChild(newButton);
298
+
299
+ userSheet.appendChild(tr);
300
+
301
+ }
302
+
303
+ console.log("Iteratively output finished");
304
+ </script>
305
+ </body>
306
+
307
+ </html>
0 commit comments