22 January 2021

Navigation PHP File


<?php
function showRegularFiles($path)
{
    $fileList = array();
    if($handle = opendir($path)) 
    {
        while (false !== ($file = readdir($handle))) 
        {
            if (!is_dir($file) && $file != 'index.php' 
                && $file != 'navigation.php' && $file[0] != '.') 
            {
               // echo '<a href = "'.$file.'">'."$file"."</a><br/>\n";
                array_push($fileList, $file);
            }
        }
        closedir($handle);
    }
    sort($fileList);
    foreach($fileList as $k)
    {
        echo '<li><a href = "'.$k.'">'."$k"."</a></li>\n";
    }
    unset($k);
}

function showDirectories($path)
{
    $dirList = array();
    if($handle = opendir($path)) 
    { 
        while (false !== ($file = readdir($handle))) 
        {
            if (is_dir($file) && $file != "." && $file != "..")
            {
               // echo '<a href = "'.$file.'">'."$file"."</a><br/>\n";
                array_push($dirList, $file);
            }
        }
        closedir($handle);
    }
    sort($dirList);
    foreach($dirList as $k)
    {
        echo '<li><a href = "'.$path."/".$k.'">'."$k"."</a></li>\n";
    }
    unset($k);
}
?>

<h2>Navigation</h2>

<hr />
<h3>Directories</h3>

<?php
echo '<ul>';
echo '<li><a href = "..">Parent Directory</a></li>';
showDirectories(".");
echo '</ul>';
echo '<hr/>';
echo '<h3>Files</h3>';
echo '<ul>';
showRegularFiles(".");
echo '</ul>';
echo '<hr />';
echo '<h3>Other Places</h3>';
echo '<ul>';
echo '<li><a href = "index.php">Back to Index Page</a></li>';
echo '<li><a href = "/~morrison/currentClasses">Current Courses Page</a></li>';
echo '<li><a href = "/~morrison">Morrison\'s Main Page</a></li>';
echo '</ul>';
?>

Typical Index Page



<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8"/> 
<link rel="stylesheet" href ="/~morrison/CSS/pageContent0220.css" />
<link rel="stylesheet" href ="/~morrison/CSS/boxes.css" />
<link rel="stylesheet" href ="/~morrison/CSS/gridLayout0820.css" />
<link rel="stylesheet" href ="/~morrison/CSS/menus.css" />
<link href="https://fonts.googleapis.com/css?family=EB+Garamond" rel="stylesheet">
<link rel = "shortcut icon" href = "/~morrison/CSS/rhino.ico"/>
<link rel="stylesheet" href="/~morrison/SCRIPTS/styles/sunburst.css"/>
<script src="/~morrison/SCRIPTS/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<style>
pre.prettyprint{
border: none;
margin-left:auto;
margin-right:auto;
width:80%;
}
table
{
    width:80%;
}
</style>
<!--
Uncomment for mathJax
<script type="text/javascript"
  src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
-->
<!--
Uncomment for JQuery
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
-->

        <title>22 January 2021</title>

</head>
<body>

<header>
<h2>22 January 2021</h2>
<?php include '/home/morrison/public_html/SCRIPTS/menus.php';
?>
</header>

<nav>
<?php
include '/home/morrison/public_html/SCRIPTS/navigation.php';
?>
</nav>

<main>
<pre><code>
&lt;?php
function showRegularFiles($path)
{
    $fileList = array();
    if($handle = opendir($path)) 
    {
        while (false !== ($file = readdir($handle))) 
        {
            if (!is_dir($file) &amp;&amp; $file != 'index.php' 
                &amp;&amp; $file != 'navigation.php' &amp;&amp; $file[0] != '.') 
            {
               // echo '&lt;a href = "'.$file.'"&gt;'."$file"."&lt;/a&gt;&lt;br/&gt;\n";
                array_push($fileList, $file);
            }
        }
        closedir($handle);
    }
    sort($fileList);
    foreach($fileList as $k)
    {
        echo '&lt;li&gt;&lt;a href = "'.$k.'"&gt;'."$k"."&lt;/a&gt;&lt;/li&gt;\n";
    }
    unset($k);
}

function showDirectories($path)
{
    $dirList = array();
    if($handle = opendir($path)) 
    { 
        while (false !== ($file = readdir($handle))) 
        {
            if (is_dir($file) &amp;&amp; $file != "." &amp;&amp; $file != "..")
            {
               // echo '&lt;a href = "'.$file.'"&gt;'."$file"."&lt;/a&gt;&lt;br/&gt;\n";
                array_push($dirList, $file);
            }
        }
        closedir($handle);
    }
    sort($dirList);
    foreach($dirList as $k)
    {
        echo '&lt;li&gt;&lt;a href = "'.$path."/".$k.'"&gt;'."$k"."&lt;/a&gt;&lt;/li&gt;\n";
    }
    unset($k);
}
?&gt;

&lt;h2&gt;Navigation&lt;/h2&gt;

&lt;hr /&gt;
&lt;h3&gt;Directories&lt;/h3&gt;

&lt;?php
echo '&lt;ul&gt;';
echo '&lt;li&gt;&lt;a href = ".."&gt;Parent Directory&lt;/a&gt;&lt;/li&gt;';
showDirectories(".");
echo '&lt;/ul&gt;';
echo '&lt;hr/&gt;';
echo '&lt;h3&gt;Files&lt;/h3&gt;';
echo '&lt;ul&gt;';
showRegularFiles(".");
echo '&lt;/ul&gt;';
echo '&lt;hr /&gt;';
echo '&lt;h3&gt;Other Places&lt;/h3&gt;';
echo '&lt;ul&gt;';
echo '&lt;li&gt;&lt;a href = "index.php"&gt;Back to Index Page&lt;/a&gt;&lt;/li&gt;';
echo '&lt;li&gt;&lt;a href = "/~morrison/currentClasses"&gt;Current Courses Page&lt;/a&gt;&lt;/li&gt;';
echo '&lt;li&gt;&lt;a href = "/~morrison"&gt;Morrison\'s Main Page&lt;/a&gt;&lt;/li&gt;';
echo '&lt;/ul&gt;';
?&gt;



</code></pre>
</main>
<footer>

<ul>
<li><a href = "../21Jan21/index.php">last class</a></li>
<li><a href = "../">next class</a></li>
<li><a href = "../index.php"> Back to Calendar View</a></li>
</ul>
</footer>
</body>
</html>