Make config more robust

This commit is contained in:
Clortox 2021-01-04 19:18:26 -05:00
parent 610e15a68c
commit 187501c286
3 changed files with 52 additions and 10 deletions

View File

@ -30,7 +30,17 @@
<h2>Folders</h2>
</div>
<div class="card-body">
<p>Select a catagory to start browsing</p>
<?php
if(!$isDir){
echo <<< errorblock
<h2><b>THERE ARE NO TRACKED DIRECTORIES,
OR THERE IS AN ERROR IN YOU CONFIGURATION.
PLEASE CHECK 'var/config'</b></h2>
errorblock;
exit();
}
?>
<p>Select a category to start browsing</p>
<table id="catTable" class="display table text-white">
<thead>
<tr>

View File

@ -14,11 +14,20 @@
* These can start with "#" to direct to a tag on the page, could be an internal
* link by using "/listing.php?folder=SomeFolder", or could be an external site
*
* $nav_rname and $nav_rlink are for a link on the right side of the nav bar.
* This link is by default an ad for this repo, however you can disable it by
* setting $isrNav to false, or change it to advertise anything you choose!
*
* The navbar can be disabled by changing isNav to false
*
* These associate in order ie the Tag $nav_names[3] will direct the user to
* the link in $nav_links[3]
*
*/
$isNav = true;
$isrNav = true;
$nav_names = array(
'Home',
'Github',
@ -29,6 +38,10 @@
'https://github.com/Clortox',
);
//$nav_rname = 'Git this site!';
//$nav_rlink = 'https://github.com/Clortox/SimpleFileRepository';
/* Directory Variables
*
* Each variable in $dir_dirs will be a listing
@ -43,6 +56,8 @@
* the title $dir_names[3]
*/
$isDir = true;
$dir_names = array(
'Printable Guns',
'GNU Software',
@ -85,4 +100,20 @@
' is asking for help with their homework from ',
);
//Be safe, check arrays
if(empty($nav_names) or empty($nav_links)){
$isNav = false;
} else if(count($nav_names) !== count($nav_links)){
$isNav = false;
}
if(empty($dir_names) or empty($dir_dirs)){
$isDir = false;
} else if (count($dir_names) !== count($dir_dirs)){
$isDir = false;
}
if(empty($convo)){
$isConvo = false;
}
?>

View File

@ -12,17 +12,18 @@
$saying = $convo[rand(0,count($convo)-1)];
echo '<p>' . $clientip . $saying . $serverip . '</p>';
}
if($isNav){
echo '<nav class="navbar navbar-expand-lg
navbar-dark border border-secondary">';
foreach($nav_names as $index=>$name){
echo '<a class="navbar-brand" href="' . $nav_links[$index] . '">'
. $name . '</a>';
}
echo '</nav>';
}
?>
<nav class="navbar navbar-expand-lg navbar-dark border border-secondary">
<?php
foreach($nav_names as $index=>$name){
echo '<a class="navbar-brand" href="' . $nav_links[$index] . '">'
. $name . '</a>';
}
?>
</nav>
</div>
</header>