-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_pages.php
81 lines (66 loc) · 1.31 KB
/
admin_pages.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
<?php
require_once("models/config.php");
if (!securePage($_SERVER['PHP_SELF'])){die();}
$pages = getPageFiles(); //Retrieve list of pages in root usercake folder
$dbpages = fetchAllPages(); //Retrieve list of pages in pages table
$creations = array();
$deletions = array();
//Check if any pages exist which are not in DB
foreach ($pages as $page){
if(!isset($dbpages[$page])){
$creations[] = $page;
}
}
//Enter new pages in DB if found
if (count($creations) > 0) {
createPages($creations) ;
}
if (count($dbpages) > 0){
//Check if DB contains pages that don't exist
foreach ($dbpages as $page){
if(!isset($pages[$page['page']])){
$deletions[] = $page['id'];
}
}
}
//Delete pages from DB if not found
if (count($deletions) > 0) {
deletePages($deletions);
}
//Update DB pages
$dbpages = fetchAllPages();
echo "
</div>
<div id='main'>
<table class='admin'>
<tr><th>Id</th><th>Page</th><th>Access</th></tr>";
//Display list of pages
foreach ($dbpages as $page){
echo "
<tr>
<td>
".$page['id']."
</td>
<td>
<a href ='admin_page.php?id=".$page['id']."'>".$page['page']."</a>
</td>
<td>";
//Show public/private setting of page
if($page['private'] == 0){
echo "Public";
}
else {
echo "Private";
}
echo "
</td>
</tr>";
}
echo "
</table>
</div>
<div id='bottom'></div>
</div>
</body>
</html>";
?>