rpicms

A CMS for the Raspberry Pi
git clone git://archive.git.mtrnord.blog/RpicmsTeam/rpicms.git
Log | Files | Refs | README | LICENSE

user_pages.php (1294B)


      1 <h2>User-Pages</h2>
      2 <?php
      3 require_once($root."/core/backend/admin/modules/modul_normal-login/models/config.php");
      4 $pages = getPageFiles(); //Retrieve list of pages in root usercake folder
      5 $dbpages = fetchAllPages(); //Retrieve list of pages in pages table
      6 $creations = array();
      7 $deletions = array();
      8 
      9 //Check if any pages exist which are not in DB
     10 foreach ($pages as $page){
     11 	if(!isset($dbpages[$page])){
     12 		$creations[] = $page;
     13 	}
     14 }
     15 
     16 //Enter new pages in DB if found
     17 if (count($creations) > 0) {
     18 	createPages($creations)	;
     19 }
     20 
     21 if (count($dbpages) > 0){
     22 	//Check if DB contains pages that don't exist
     23 	foreach ($dbpages as $page){
     24 		if(!isset($pages[$page['page']])){
     25 			$deletions[] = $page['id'];
     26 		}
     27 	}
     28 }
     29 
     30 //Delete pages from DB if not found
     31 if (count($deletions) > 0) {
     32 	deletePages($deletions);
     33 }
     34 
     35 //Update DB pages
     36 $dbpages = fetchAllPages();
     37 ?>
     38 <table class="table table-striped">
     39 <tr><th>Id</th><th>Page</th><th>Access</th></tr>
     40 <?php
     41 //Display list of pages
     42 foreach ($dbpages as $page){
     43 	echo "
     44 	<tr>
     45 	<td>
     46 	".$page['id']."
     47 	</td>
     48 	<td>
     49 	<a href='admin.php?page_id=".$page['id']."#usercenter'>".$page['page']."</a>
     50 	</td>
     51 	<td>";
     52 
     53 	//Show public/private setting of page
     54 	if($page['private'] == 0){
     55 		echo "Public";
     56 	}
     57 	else {
     58 		echo "Private";
     59 	}
     60 
     61 	echo "
     62 	</td>
     63 	</tr>";
     64 }
     65 ?>
     66 </table>