forked from makandz/MyUsers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin_pages.php
43 lines (36 loc) · 973 Bytes
/
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
<?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();
require_once("models/header.php");
include("models/menu.php");
include("include/html-templates/admin_pages.php");
include("models/plugins.php");
?>