In index.php
though the name can be anything, I have an array at the very top for now, just for testing purposes.
<?php
$settings = array(
enabled => true,
id => "KMS",
theme=>"kms_standard",
);
?>
I started this to use as information to use in my CMS table. Basically I am scanning the main directory for pages and other directories. Then I echo a li
out to the "table" showing information though I need more information than just the date it was created/edited.
EX:
Page Name | Identifier | Status | Theme | Created/Edited
index.php CMS Enabled Dark 12/12/12 12:00
To get the created/edited date I use date('l jS \of F Y h:i:s A',filemtime('../'.$page))
Is there a way to set data like this for a document and then get it, if not how would i use the array in a for each loop without including the entire file. I believe if I do include($file)
it will parse all the HTML and PHP, but I only need the $settings
variable from that page. I hope I am making myself clear enough. If not example below
function is_dir_empty($dir) {
if (!is_readable($dir)) return NULL;
$handle = opendir($dir);
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
return FALSE;
}
}
return TRUE;
}
$pages = scandir('../',0);
foreach($pages as $page){
if(is_dir('../'.$page) && !is_dir_empty('../'.$page)){
//iterate deeper to get these files as well
}elseif(!is_dir('../'.$page)){
$file = get_file('../'.$page);//basically get the array of information some how
echo '<div class="row" id="'.removeExtensions($page).'"><ul>'.
'<li class="fifths"><div class="checkbox_container">'.
'<input type="checkbox" id="'.$kpage.'_check" value="'.$page.'" class="checkbox" name="delete_page[]" />'.
'<label for="'.$kpage.'_check"><span></span></label></div>'.$kpage.'</li>'.
'<li class="fifths">'.$file['id'].'</li>'.
'<li class="fifths">'.$file['enabled'].'</li>'.
'<li class="fifths">'.$file['theme'].'</li>'.
'<li class="fifths" title="'.date('l jS \of F Y h:i:s A',filemtime('../'.$page)).'">'.date('l jS \of F Y h:i:s A',filemtime('../'.$page)).'</li></ul></div>';
}
}
UPDATE FOR FUTURE REFERENCES This works perfectly
JSON
{
"index.php":{
"enabled":"true",
"theme":"dark",
"identifier":"KMS"
}
}
dashboard
$jsona = file_get_contents("../pages.json");
$jsonb = json_decode($jsona,true);
$data = $jsonb['pages'];