]> git.bochard.net Git - mysite.git/commitdiff
added head.php
authorbochard <mail@bochard.net>
Sat, 12 Jul 2025 10:11:17 +0000 (18:11 +0800)
committerbochard <mail@bochard.net>
Sat, 12 Jul 2025 10:39:20 +0000 (18:39 +0800)
index.php
parts/head.php [new file with mode: 0644]

index 8e7ed295e722550b46f18a2508a3b3d4bb6fcb6a..3e8d21d7574e0088ec528ba1ec4e209255e2fca6 100755 (executable)
--- a/index.php
+++ b/index.php
@@ -1,19 +1,10 @@
 <?php\r
   $parts = $_SERVER['DOCUMENT_ROOT'] . '/parts';\r
+  require_once($parts . '/head.php');\r
+  $pgtitle = "bochard's net home";\r
+  $pgdescription = "Welcome to my net home! this website are my space to show my hobbies, thoughts, and other fun stuffs. I am an 18 years old who learned how to code just by myself. Hope you enjoy visiting my site! :)";\r
+  head($pgtitle, $pgdescription);\r
 ?>\r
-<!DOCTYPE html>\r
-<html lang="en">\r
-<head>\r
-    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\r
-    <meta name="robots" content="index, follow">\r
-    <link rel="shortcut icon" href="/images/icons/favicon.ico">\r
-\r
-  <title>bochard's net home</title>\r
-  <meta name="description" content="Welcome to my net home! this website are my space to show my hobbies, thoughts, and other fun stuffs. I am an 18 years old who learned how to code just by myself. Hope you enjoy visiting my site! :)">\r
-\r
-  <!-- stylesheet/s i use -->\r
-  <link rel="stylesheet" href="/stylesheets/root.css">\r
-</head>\r
 <body>    \r
   <table>\r
     <tr>\r
diff --git a/parts/head.php b/parts/head.php
new file mode 100644 (file)
index 0000000..608e05a
--- /dev/null
@@ -0,0 +1,19 @@
+<?php
+function head($pgtitle, $pgdescription, $pgcss = []){ ?>
+  <!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="/images/icons/favicon.ico">
+
+    <title><?= htmlspecialchars($pgtitle, ENT_COMPAT); ?></title>
+    <meta name="description" content="<?= htmlspecialchars($pgdescription, ENT_COMPAT); ?>">
+
+    <!-- stylesheet/s i use -->
+    <link rel="stylesheet" href="/stylesheets/root.css?v=<?= filemtime($_SERVER['DOCUMENT_ROOT']. '/stylesheets/root.css'); ?>">
+    <?php foreach($pgcss as $filepath): ?>
+      <link rel="stylesheet" href="<?= htmlspecialchars($filepath) . '?v=' . filemtime($filepath); ?>">
+    <?php endforeach; ?>
+  </head>
+<?php }