diff --git a/home.php b/home.php index 0bc30cc..348ad44 100644 --- a/home.php +++ b/home.php @@ -10,58 +10,3 @@ -
- -' . $name .''; - if ($action == 'tags') - { - $tags = array(); - $hastags = preg_match_all('/tags:(.*)/i', $content, $tags, PREG_SET_ORDER); - if ($hastags) - { - $tagslist = explode(',', $tags[0][1]); - echo ' '; - foreach ($tagslist as $tag) - { - $tag = trim($tag); - echo('' . $tag . ' '); - } - echo ''; - } - } - else if ($action == 'search') - { - $pos = strpos(strtolower($content), strtolower($param)); - echo ' ' . $param . '' . substr($content, $pos + strlen($param), 42) . ''; - } - echo'
'; - } -} - -?> - - diff --git a/index.php b/index.php index ccb2eb1..60580b1 100644 --- a/index.php +++ b/index.php @@ -127,7 +127,40 @@ { $content = file_get_contents($dir . '/' . $title); } + + $lines = substr_count($content, "\r\n") + 1; + $words = $lines + substr_count($content, " "); + $rows = max(20, $lines) * 2; + $length = strlen($content); + require('note.php'); + + $links = array(); + if (preg_match_all('/\[\[(.*)\]\]/', $content, $links, PREG_SET_ORDER)) + { + echo '
Internal links:
'; + foreach($links as $link) + { + echo '
+ ' . $link[1] . ' +
'; + } + echo '
'; + } + $links = array(); + if (preg_match_all('/https:(.*)[ \r]/', $content, $links, PREG_SET_ORDER)) + { + echo '
External links:
'; + foreach($links as $link) + { + echo '
+ https:' . $link[1] . ' +
'; + } + echo '
'; + } + + echo '' . $title . ' - ' . $now . ' - ' . $length . 'c - ' . $words . 'w - ' . $lines . 'l '; } else { @@ -136,6 +169,57 @@ $param = $_GET['param']; } require('home.php'); + + echo '
'; + $files = glob($dir . '/*'); + usort($files, function($a, $b) + { + return filemtime($b) - filemtime($a); + }); + + foreach($files as $path) + { + $tags = ''; + $name = basename($path); + if (!str_ends_with($name, '.del') && ($action != 'filter' || str_contains(strtolower($name), strtolower($param)))) + { + if ($action == 'search' || $action == 'tags') + { + $content = file_get_contents($path); + + if (($action == 'search' && !str_contains(strtolower($content), strtolower($param))) || + ($action == 'tags' && !preg_match('/tags:.*' . $param . '/i', $content))) + { + continue; + } + } + echo '
' . $name .''; + if ($action == 'tags') + { + $tags = array(); + $hastags = preg_match_all('/tags:(.*)/i', $content, $tags, PREG_SET_ORDER); + if ($hastags) + { + $tagslist = explode(',', $tags[0][1]); + echo ' '; + foreach ($tagslist as $tag) + { + $tag = trim($tag); + echo('' . $tag . ' '); + } + echo ''; + } + } + else if ($action == 'search') + { + $pos = strpos(strtolower($content), strtolower($param)); + echo ' ' . $param . '' . substr($content, $pos + strlen($param), 42) . ''; + } + echo'
'; + } + } + + echo '
'; } ?> diff --git a/note.php b/note.php index f600766..e1f90c6 100644 --- a/note.php +++ b/note.php @@ -1,10 +1,3 @@ - -
@@ -19,33 +12,3 @@
- -Internal links:'; - foreach($links as $link) - { - echo '
- ' . $link[1] . ' -
'; - } - echo '
'; -} -$links = array(); -if (preg_match_all('/https:(.*)[ \r]/', $content, $links, PREG_SET_ORDER)) -{ - echo '
External links:
'; - foreach($links as $link) - { - echo '
- https:' . $link[1] . ' -
'; - } - echo '
'; -} - -echo '' . $title . ' - ' . $now . ' - ' . $length . 'c - ' . $words . 'w - ' . $lines . 'l '; - -?>