]> git repositories - mysite.git/commitdiff
refactored /part/head.php
authorbochard <git@bochard.net>
Sat, 21 Feb 2026 04:41:59 +0000 (12:41 +0800)
committerbochard <git@bochard.net>
Sat, 21 Feb 2026 04:41:59 +0000 (12:41 +0800)
15 files changed:
email.php
guestbook.php
how_to/index.php
index.php
info.php
links.php
part/head.php
photo_album/index.php
weblog/.template
weblog/20250712.php
weblog/20250714.php
weblog/20250803.php
weblog/20250805.php
weblog/20250809.php
weblog/index.php

index c9487365183724b4fcd1886f81816fd0776fa990..c78aba2800c288929e09e0a439f8c031d564250a 100644 (file)
--- a/email.php
+++ b/email.php
@@ -1,11 +1,13 @@
 <?php
-       require_once("{$_SERVER['DOCUMENT_ROOT']}/part/head.php");
-       $pgtitle = "email";
-       $pgdescription = "";
-       $pgcss = [];
-       $pgjs = [];
-       head($pgtitle, $pgdescription, $pgcss, $pgjs);
+require_once("{$_SERVER['DOCUMENT_ROOT']}/part/head.php");
+head([
+       "title" => "email",
+       "meta" => [
+               ["name" => "description", "content" => "send me an email"]
+       ]
+]);
 ?>
+
 <body background="/image/background/stars.gif" style="color: white;">
 <center>
        <table>
index cbba13e4d6a15599793fbe1c6bd196631acfa7c2..b3ec37ec4c95901f0ece163893328b3f72b826f8 100644 (file)
@@ -1,11 +1,13 @@
 <?php
-       require_once("{$_SERVER['DOCUMENT_ROOT']}/part/head.php");
-       $pgtitle = "guestbook";
-       $pgdescription = "sign my guestbook";
-       $pgcss = [];
-       $pgjs = [];
-       head($pgtitle, $pgdescription, $pgcss, $pgjs);
+require_once("{$_SERVER['DOCUMENT_ROOT']}/part/head.php");
+head([
+       "title" => "guestbook",
+       "meta" => [
+               ["name" => "description", "content" => "sign my guestbook"]
+       ]
+]);
 ?>
+
 <body background="/image/background/bluesky.jpg">
        <center>
                <table>
index e2d6b03c7b76a6dd332a156f932529d1c34f7ee9..2b66bc31fac74ce26e9c3bc2ab109951a4ef107f 100644 (file)
@@ -1,11 +1,10 @@
 <?php
-       require_once("{$_SERVER['DOCUMENT_ROOT']}/part/head.php");
-       $pgtitle = "bochard's tutorials";
-       $pgdescription = "";
-       $pgcss = [];
-       $pgjs = [];
-       head($pgtitle, $pgdescription, $pgcss, $pgjs);
+require_once("{$_SERVER['DOCUMENT_ROOT']}/part/head.php");
+head([
+       "title" => "tutorials"
+]);
 ?>
+
 <body>
        <center>
                <table>
index 913492e669a7ebd11f2ad06cb466557ace45b1b1..2c8f951ee8587af512a1206d62027a6095e708f2 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1,11 +1,14 @@
 <?php\r
-       require_once("{$_SERVER['DOCUMENT_ROOT']}/part/head.php");\r
-       $pgtitle = "bochard's net home";\r
-       $pgdescription = "";\r
-       $pgcss = [];\r
-       $pgjs = [];\r
-       head($pgtitle, $pgdescription, $pgcss, $pgjs);\r
+require_once("{$_SERVER['DOCUMENT_ROOT']}/part/head.php");\r
+head([\r
+       "title" => "bochard's net home",\r
+       "meta" => [\r
+               ["name" => "robots", "content" => "index,follow"],\r
+               ["name" => "description", "content" => "the internet home of bochard - computers, pics, weblogs, and more..."]\r
+       ]\r
+]);\r
 ?>\r
+\r
 <body background="/image/background/clouds.gif">\r
 <center>\r
        <table width="900">\r
index 5ee4b186a694fde77701bbea32db9980209101a6..d06b3df3d165c4d96cf691ca4a12f9f2891cdf93 100644 (file)
--- a/info.php
+++ b/info.php
@@ -1,11 +1,13 @@
 <?php
-       require_once("{$_SERVER['DOCUMENT_ROOT']}/part/head.php");
-       $pgtitle = "about me";
-       $pgdescription = "";
-       $pgcss = [];
-       $pgjs = [];
-       head($pgtitle, $pgdescription, $pgcss, $pgjs);
+require_once("{$_SERVER['DOCUMENT_ROOT']}/part/head.php");
+head([
+       "title" => "about me",
+       "meta" => [
+               ["name" => "description", "content" => "wanna know more about the creator of this site???"]
+       ]
+]);
 ?>
+
 <body background="/image/background/bg1.gif">
        <center>
                <table>
index e45c19b1441e99d1f98ee9fd9fd2f556affeeb02..0e4ce134f96bf5b5bf6ccce32e1bfbf9aa6161ab 100644 (file)
--- a/links.php
+++ b/links.php
@@ -1,25 +1,27 @@
 <?php
-       require_once("{$_SERVER['DOCUMENT_ROOT']}/part/head.php");
-       $pgtitle = "cool links";
-       $pgdescription = "";
-       $pgcss = [];
-       $pgjs = [];
-       head($pgtitle, $pgdescription, $pgcss, $pgjs);
+require_once("{$_SERVER['DOCUMENT_ROOT']}/part/head.php");
+head([
+       "title" => "cool links",
+       "meta" => [
+               ["name" => "description", "content" => "some links that I found awesome."]
+       ]
+]);
 ?>
-<body bgcolor="#f7f7f7">
-       <center>
-               <table width="600" cellspacing="0" cellpadding="5" bgcolor="#f7f7f7">
-                       <tr>
-                               <td>
-                                       <h1>here are some really cool links I found...</h1>
-                                       I seldomly update this page. If you have a cool web site and would like to add here in the list, consider sending me an <a href="/email.php">email</a>.
-                                       <br><br>
-                                       2025, Dec. 17 - <em><a href="https://www.fieggen.com">Ian Feggen's website</a></em> - <small>"Professor Shoelace"</small>
-                                       <br>
-                                       2025, Dec. 17 - <em><a href="https://www.dvd3000.ca">dvd3000</a></em> - <small>I think, this is best web site I found XD</small>
-                               </td>
-                       </tr>
-               </table>
-       </center>
+
+<body>
+<center>
+       <table width="600" cellspacing="0" cellpadding="5">
+               <tr>
+                       <td>
+                               <h1>here are some really cool links I found...</h1>
+                               I seldomly update this page. If you have a cool web site and would like to add here in the list, consider sending me an <a href="/email.php">email</a>.
+                               <br><br>
+                               2025, Dec. 17 - <em><a href="https://www.fieggen.com">Ian Feggen's website</a></em> - <small>"Professor Shoelace"</small>
+                               <br>
+                               2025, Dec. 17 - <em><a href="https://www.dvd3000.ca">dvd3000</a></em> - <small>I think, this is best web site I found XD</small>
+                       </td>
+               </tr>
+       </table>
+</center>
 </body>
 </html>
index 83d84597be5b402e109975bed74a92412d66c808..31786668947d193f81c060c7926f700d8c52f3bd 100644 (file)
@@ -1,30 +1,69 @@
 <?php
 $part = "{$_SERVER['DOCUMENT_ROOT']}/part";
-function head($pgtitle, $pgdescription = null, $pgcss = [], $pgjs = []){?>
-  <!doctype html>
-  <html lang="en">
-  <head>
-      <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
-      <meta name="robots" content="index,follow">
-      <link rel="shortcut icon" href="/image/icon/pink-chair.png">
-      <meta name="viewport" content="width=1200,initial-scale=1.0,shrink-to-fit=no">
 
-    <title><?= htmlspecialchars($pgtitle, ENT_COMPAT);?></title>
-    <?php
-                       if($pgdescription){
-                               $content = htmlspecialchars($pgdescription, ENT_COMPAT);
-                               echo "<meta name=\"description\" content=\"$content\">";
+function head(array $head = []) {
+       $title = $head['title'] ?? "no title";
+       $meta = $head['meta'] ?? [];
+       $css = $head['css'] ?? [];
+       $js = $head['js'] ?? [];
+       $favicon = $head['favicon'] ?? "/image/icon/pink-chair.png";
+       
+       // default meta tags
+       $defaultMeta = [
+               ["name" => "robots", "content" => "index, follow"],
+               ["name" => "description", "content" => "no description..."]
+       ];
+       
+       foreach($defaultMeta as $default) {
+               $doesExist = false;
+               foreach($meta as $tag) {
+                       if(isset($tag['name']) && strtolower($tag['name']) === strtolower($default['name'])) {
+                               $doesExist = true;
+                               break;
                        }
-    ?>
-    
-    <link rel="stylesheet" href="/part/stylesheet/root.css?v=<?= filemtime("{$_SERVER['DOCUMENT_ROOT']}/part/stylesheet/root.css");?>">
-    <?php foreach($pgcss as $filename):?>
-      <link rel="stylesheet" href="<?= htmlspecialchars("/part/stylesheet/$filename?v="), filemtime("{$_SERVER['DOCUMENT_ROOT']}/stylesheet/$filename");?>">
-    <?php endforeach;?>
-    
-    <script type="text/javascript" src="/part/script/root.js?v=<?= filemtime("{$_SERVER['DOCUMENT_ROOT']}/part/script/root.js");?>"></script>
-    <?php foreach($pgjs as $filename):?>
-      <script type="text/javascript" src="<?= htmlspecialchars("/part/script/$filename?v="), filemtime("{$_SERVER['DOCUMENT_ROOT']}/script/$filename");?>"></script>
-    <?php endforeach;?>
-  </head>
-<?php }
+               }
+               if(!$doesExist) {
+                       $meta[] = $default;
+               }
+       }
+?>
+<!doctype html>
+<html lang="en">
+<head>
+       <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
+       <title><?= htmlspecialchars($title, ENT_COMPAT);?></title>
+       <link rel="shortcut icon" href="<?= htmlspecialchars($favicon, ENT_COMPAT);?>?v=<?= filemtime("{$_SERVER['DOCUMENT_ROOT']}/$favicon");?>">
+       <?php
+               foreach($meta as $tag) {
+                       $output = "";
+                       foreach($tag as $key => $val) {
+                               $output .= " " . htmlspecialchars($key, ENT_COMPAT) . "=\"" . htmlspecialchars($val, ENT_COMPAT) . "\"";
+                       }
+                       echo "<meta$output>\n\t";
+               }
+       ?>
+
+       <!-- stylesheets -->
+       <link rel="stylesheet" href="/part/stylesheet/root.css?v=<?= filemtime("{$_SERVER['DOCUMENT_ROOT']}/part/stylesheet/root.css");?>">
+       <?php foreach($css as $file):?>
+               <?php
+                       $filepath = $_SERVER['DOCUMENT_ROOT'] . $file;
+                       if(!file_exists($filepath)) continue;
+                       $version = filemtime($filepath);
+               ?>
+               <link rel="stylesheet" href="<?= htmlspecialchars("$file?v=$version", ENT_COMPAT);?>">
+       <?php endforeach;?>
+       
+       <!-- scripts -->
+       <script src="/part/script/root.js?v=<?= filemtime("{$_SERVER['DOCUMENT_ROOT']}/part/script/root.js");?>"></script>
+       <?php foreach($js as $file):?>
+               <?php
+                       $filepath = $_SERVER['DOCUMENT_ROOT'] . $file;
+                       if(!file_exists($filepath)) continue;
+                       $version = filemtime($filepath);
+               ?>
+               <script src="<?= htmlspecialchars("$file?v=$version", ENT_COMPAT);?>"></script>
+       <?php endforeach;?>
+</head>
+<?php
+}
index 6a91ced11c184be03b767c1111e7bbb77213cc3b..1e33795993afee6927185cb6a3ad83e475c959bd 100644 (file)
@@ -1,11 +1,10 @@
 <?php
-       require_once("{$_SERVER['DOCUMENT_ROOT']}/part/head.php");
-       $pgtitle = "my photo album";
-       $pgdescription = "";
-       $pgcss = [];
-       $pgjs = [];
-       head($pgtitle, $pgdescription, $pgcss, $pgjs);
+require_once("{$_SERVER['DOCUMENT_ROOT']}/part/head.php");
+head([
+       "title" => "my photo album"
+]);
 ?>
+
 <body>
        <center>
                <table>
index 891d3785a6b236736c2b6661b242035cfe7d7656..ef9876b3183edfa61d2b27b59045b15fb0a02ea8 100644 (file)
@@ -1,11 +1,10 @@
 <?php
-       require_once("{$_SERVER['DOCUMENT_ROOT']}/part/head.php");
-       $pgtitle = "";
-       $pgdescription = "";
-       $pgcss = [];
-       $pgjs = [];
-       head($pgtitle, $pgdescription, $pgcss, $pgjs);
+require_once("{$_SERVER['DOCUMENT_ROOT']}/part/head.php");
+head([
+       "title" => ""
+]);
 ?>
+
 <body>    
        <center>
                <table width="490">
index a0db9602a383621da49481d260090660569c04f8..944a234fea8583179a7ec30e7dfc74e3a989ec3d 100644 (file)
@@ -1,11 +1,10 @@
 <?php
-       require_once("{$_SERVER['DOCUMENT_ROOT']}/part/head.php");
-       $pgtitle = "A dream.";
-       $pgdescription = "";
-       $pgcss = [];
-       $pgjs = [];
-       head($pgtitle, $pgdescription, $pgcss, $pgjs);
+require_once("{$_SERVER['DOCUMENT_ROOT']}/part/head.php");
+head([
+       "title" => "A dream."
+]);
 ?>
+
 <body>    
        <center>
                <table width="490">
index cbbbffe7b61fc235a369a15381ba583328e3ed11..54cf7fc4b9d3b0a182150cba59d3251edaefe12a 100644 (file)
@@ -1,11 +1,10 @@
 <?php
-       require_once("{$_SERVER['DOCUMENT_ROOT']}/part/head.php");
-       $pgtitle = "The rain.";
-       $pgdescription = "";
-       $pgcss = [];
-       $pgjs = [];
-       head($pgtitle, $pgdescription, $pgcss, $pgjs);
+require_once("{$_SERVER['DOCUMENT_ROOT']}/part/head.php");
+head([
+       "title" => "The rain."
+]);
 ?>
+
 <body>    
        <center>
                <table width="490">
index 5eaf2f795e0cec891b4fb78effe8f8e0cfdb8ecc..e9de5045044c791267fbf76bd41b843a5c02e25d 100644 (file)
@@ -1,11 +1,10 @@
 <?php
-       require_once("{$_SERVER['DOCUMENT_ROOT']}/part/head.php");
-       $pgtitle = "New haircut";
-       $pgdescription = "";
-       $pgcss = [];
-       $pgjs = [];
-       head($pgtitle, $pgdescription, $pgcss, $pgjs);
+require_once("{$_SERVER['DOCUMENT_ROOT']}/part/head.php");
+head([
+       "title" => "New haircut"
+]);
 ?>
+
 <body>    
        <center>
                <table width="490">
index 1704249c7dfb16e84438a11c13b263c5bca604d4..9c6bf1f46cbc0c6713f8d3f117aa90595a874d26 100644 (file)
@@ -1,11 +1,10 @@
 <?php
-       require_once("{$_SERVER['DOCUMENT_ROOT']}/part/head.php");
-       $pgtitle = "University orientation";
-       $pgdescription = "";
-       $pgcss = [];
-       $pgjs = [];
-       head($pgtitle, $pgdescription, $pgcss, $pgjs);
+require_once("{$_SERVER['DOCUMENT_ROOT']}/part/head.php");
+head([
+       "title" => "University orientation"
+]);
 ?>
+
 <body>
        <center>    
                <table width="490">
index ba861d4a837d44ddaa85a59c077dd3e223bd323b..62e94c41bf3d8fa57387b1a72ceeb54c1d9d5b12 100644 (file)
@@ -1,11 +1,10 @@
 <?php
-       require_once("{$_SERVER['DOCUMENT_ROOT']}/part/head.php");
-       $pgtitle = "Our kitten died";
-       $pgdescription = "";
-       $pgcss = [];
-       $pgjs = [];
-       head($pgtitle, $pgdescription, $pgcss, $pgjs);
+require_once("{$_SERVER['DOCUMENT_ROOT']}/part/head.php");
+head([
+       "title" => "Our kitten died"
+]);
 ?>
+
 <body>    
        <center>
                <table width="490">
index 9b8472cedcb0cf8f75d7e3155b6f6e0d6fc5be82..71260ca65c76b87de153593defe11d59f8c02047 100644 (file)
@@ -1,11 +1,13 @@
 <?php
-       require_once("{$_SERVER['DOCUMENT_ROOT']}/part/head.php");
-       $pgtitle = "my thoughts";
-       $pgdescription = "";
-       $pgcss = [];
-       $pgjs = [];
-       head($pgtitle, $pgdescription, $pgcss, $pgjs);
+require_once("{$_SERVER['DOCUMENT_ROOT']}/part/head.php");
+head([
+       "title" => "weblog",
+       "meta" => [
+               ["name" => "description", "content" => "my thoughts..."]
+       ]
+]);
 ?>
+
 <body>    
        <center>
                <table width="490">