First jameswitzema.net commit

This commit is contained in:
Lao Tzu
2026-05-29 11:30:10 -07:00
commit 32cc108c4a
200 changed files with 1200635 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
<?php
// Footer file for common footers
$foothtml = <<<EOF
<div id='foot'>
<div id='footbar'>
<a href='mailto:me@jameswitzeman.net'>me@jameswitzeman.net</a>
</div>
</div>
EOF;
echo $foothtml;
?>
+120
View File
@@ -0,0 +1,120 @@
<?php
// Build <head> html with included
// CSS, etc
function build_head() {
echo "<head>";
$content = <<<EOF
<title>World Wide Witzeman</title>
EOF;
echo $content;
//Import css
echo "<style>";
echo file_get_contents("css/fonts.css");
echo file_get_contents("css/colors.css");
echo file_get_contents("css/appearance.css");
echo "</style>";
echo "</head>";
}
// Get content from file at path $path
// $recnum keeps memory of numbers of recursion.
// We need this ability to wrap the final string
// in <div> elements.
function get_content($path, $recnum = 0) {
$extracontent = "";
$output = "";
// Get contents of the file
$fcontent = file_get_contents($path);
// If the file has an <!--include [path]--> comment,
// then call this function on that path too.
$includestart = strpos($fcontent, "<!--");
// First, check if a comment exists
if ($includestart) {
// Remove <!--
$includeend = strpos($fcontent, "-->") + 2;
$includelen = $includeend - $includestart + 1;
$include_str = substr($fcontent, $includestart, $includelen);
// Then, check if the string has "include"
$includestart = strpos($include_str, "include");
if ($includestart) {
// If it does, get the file to include
// and put it in $include_str
$include_str = substr(
$include_str,
$includestart + 7, // +7 removes "include"
strlen($includestart) - 4); // -4 removes -->
$include_str = trim($include_str);
}
// Call the function on this string as path,
// increment recursion to ensure we don't get lost
$extracontent = get_content($include_str, $recnum + 1);
}
$output = $fcontent . $extracontent . $output;
if ($recnum == 0) {
$output = "<div class='content'>" . $output . "</div>";
}
return $output;
}
// Remove filename endings from any string which is a file path.
function clean_fn($string) {
// To do this, we are going to move upwards from the
// bottom of the string, looking for '.' and '/' characters.
// When we find a '.' char, we then check if there is any '/'
// placed after it. If this is true, we are dealing with a folder
// that has a '.' in its name, which we do not want to alter.
// If it is not true, we can remove all characters after the '.'
// and then check the next '.' up the string.
$exitcond = FALSE;
$index = -1;
$index_lastper = -1;
$index_lastslash = 1;
$final_index = 0;
// Iterate over the string, looking for slashes and periods.
while (abs($index) < strlen($string) && !$exitcond) {
// If we find a period, save the index.
if ($string[$index] == '.') {
$index_lastper = $index;
}
// If we find a slash, save the index.
else if ($string[$index] == '/') {
$index_lastslash = $index;
$exitcond = TRUE;
}
// Compare the indices. If there is no
// slash before the period, that's our
// final index.
if ($index_lastper > $index_lastslash) {
$final_index = $index_lastper;
}
$index--;
}
if (abs($final_index) > 0) {
$output = substr($string, 0, $final_index);
//$output = $output . " | " . $index_lastper . " | " . $index_lastslash;
}
else {
$output = $string;
}
return $output;
}
// Quick function to build MOTD with optional delimiter
function build_motd($strings, $delimiter = "\t") {
$motd = $strings[0];
for ($i = 1; $i < sizeof($strings); $i++) {
$motd = $motd . $delimiter . $strings[$i];
}
return $motd;
}
?>
+62
View File
@@ -0,0 +1,62 @@
<?php
require_once "functions.php";
// Header file for drawing common headers
// Initialized Variables
$path = "/"; // Path of the current content file
$headhtml = ""; // Header HTML to display
$strindex = 0; // Int for indexing strings
$findstr = ""; // String for searching
$motd = ""; // Message of the Day for header
// Defined Variables
$datea = getdate();
$datestr = $datea["month"] . " " . $datea["mday"] . ", " . $datea["year"];
// Build the <head> element.
build_head();
// Here, get the path of the HTML to display in the body, and save it
// in a string.
if (sizeof($_GET) == 0) {
$path = "content/home.html";
}
else {
$path = "content/" . $_GET['q'];
}
// Build title and top bar.
$headhtml = <<<EOF
<div id='head'>
<div id='titlebar'>
<div class='item1'><h1>world-wide-witzeman</h1></div>
<div class='item2'></div>
</div>
<div id='subhead'>
<div id='motd'></div>
<ul>
<li><a href='?'>home</a></li>
<li><a href='?q=services.html'>services</a></li>
<li><a href='?q=contact.html'>contact</a></li>
<li><a href='?q=about.html'>about</a></li>
</ul>
</div>
</div>
EOF;
// Build MOTD (Message of the Day.)
$motd = build_motd(array(
// $_SERVER['HTTP_X_FORWARDED_FOR'],
// $datestr,
clean_fn($path),
));
//$motd = $_SERVER['REMOTE_ADDR'] . "\t" . $datestr . "\t" . clean_fn($path);
// We want the 'data' div to contain our message of the day
// we're displaying. So, we insert that in the proper place.
$findstr = "motd";
$strindex = strpos($headhtml, $findstr) + 6;
$headhtml = substr_replace($headhtml, $motd, $strindex, 0);
echo $headhtml;
?>