diff options
author | 53hornet <atc@53hor.net> | 2021-12-22 20:09:51 -0500 |
---|---|---|
committer | 53hornet <atc@53hor.net> | 2021-12-22 20:09:51 -0500 |
commit | b50664b861e98948df44472122f63f91b73e0a0a (patch) | |
tree | ae2211ce8768724421139eabcf7d0da298df0c24 /index.php | |
parent | 9409834cbad547e94f153eca28c53fee4b57af2a (diff) | |
download | 53hor-b50664b861e98948df44472122f63f91b73e0a0a.tar.xz 53hor-b50664b861e98948df44472122f63f91b73e0a0a.zip |
feat: automatic manpage links
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -5,7 +5,11 @@ $page = strtok(strtok($_SERVER['REQUEST_URI'], '/'), '?'); if (empty($page)) { include('./pages/index.php'); } else if (!empty($page) && $page[0] >= '0' && $page[0] <= '9' && is_readable("./posts/$page.php")) { - include("./posts/$page.php"); + $script = file_get_contents("./posts/$page.php"); + $re = '/<code>([^\(<>\)]*)\(([0-9])\)<\/code>/m'; + $subst = '<a target="_blank" href="https://www.freebsd.org/cgi/man.cgi?query=$1&sektion=$2&format=ascii">$1($2)</a>'; + $script = preg_replace($re, $subst, $script); + eval("?>$script<?php"); } else if (!empty($page) && is_readable("./pages/$page.php")) { include("./pages/$page.php"); } else { |