This commit is contained in:
quenousimporte 2024-03-06 11:53:57 +01:00
parent 605fbe5d2e
commit cc57cbfab1
3 changed files with 84 additions and 92 deletions

View File

@ -10,58 +10,3 @@
<input autocomplete="off" class="title" name="param" value="<?php echo $param; ?>">
</div>
</form>
<div class="editor">
<?php
$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 '<div><a href=index.php?open=true&param=' . urlencode($name) . '>' . $name .'</a>';
if ($action == 'tags')
{
$tags = array();
$hastags = preg_match_all('/tags:(.*)/i', $content, $tags, PREG_SET_ORDER);
if ($hastags)
{
$tagslist = explode(',', $tags[0][1]);
echo '<span class="grey"> ';
foreach ($tagslist as $tag)
{
$tag = trim($tag);
echo('<a class="grey" href="index.php?tags=true&param=' . $tag . '">' . $tag . '</a> ');
}
echo '</span>';
}
}
else if ($action == 'search')
{
$pos = strpos(strtolower($content), strtolower($param));
echo '<span class="grey"> <b>' . $param . '</b>' . substr($content, $pos + strlen($param), 42) . '</span>';
}
echo'</div>';
}
}
?>
</div>

View File

@ -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 '<div>Internal links:</div>';
foreach($links as $link)
{
echo '<div>
<a href="index.php?open=true&param=' . urlencode($link[1]) . '">' . $link[1] . '</a>
</div>';
}
echo '<br>';
}
$links = array();
if (preg_match_all('/https:(.*)[ \r]/', $content, $links, PREG_SET_ORDER))
{
echo '<div>External links:</div>';
foreach($links as $link)
{
echo '<div>
<a target="_blank" href="https:' . $link[1] . '">https:' . $link[1] . '</a>
</div>';
}
echo '<br>';
}
echo '<span class="grey">' . $title . ' - ' . $now . ' - ' . $length . 'c - ' . $words . 'w - ' . $lines . 'l </span>';
}
else
{
@ -136,6 +169,57 @@
$param = $_GET['param'];
}
require('home.php');
echo '<div class="editor">';
$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 '<div><a href=index.php?open=true&param=' . urlencode($name) . '>' . $name .'</a>';
if ($action == 'tags')
{
$tags = array();
$hastags = preg_match_all('/tags:(.*)/i', $content, $tags, PREG_SET_ORDER);
if ($hastags)
{
$tagslist = explode(',', $tags[0][1]);
echo '<span class="grey"> ';
foreach ($tagslist as $tag)
{
$tag = trim($tag);
echo('<a class="grey" href="index.php?tags=true&param=' . $tag . '">' . $tag . '</a> ');
}
echo '</span>';
}
}
else if ($action == 'search')
{
$pos = strpos(strtolower($content), strtolower($param));
echo '<span class="grey"> <b>' . $param . '</b>' . substr($content, $pos + strlen($param), 42) . '</span>';
}
echo'</div>';
}
}
echo '</div>';
}
?>
</body>

View File

@ -1,10 +1,3 @@
<?
$lines = substr_count($content, "\r\n") + 1;
$words = $lines + substr_count($content, " ");
$rows = max(20, $lines) * 2;
$length = strlen($content);
?>
<form action="index.php" method="POST">
<div>
<input type="submit" name="home" value="home" accesskey="h">
@ -19,33 +12,3 @@
</div>
<input hidden name="previoustitle" value="<? echo $title; ?>">
</form>
<?
$links = array();
if (preg_match_all('/\[\[(.*)\]\]/', $content, $links, PREG_SET_ORDER))
{
echo '<div>Internal links:</div>';
foreach($links as $link)
{
echo '<div>
<a href="index.php?open=true&param=' . urlencode($link[1]) . '">' . $link[1] . '</a>
</div>';
}
echo '<br>';
}
$links = array();
if (preg_match_all('/https:(.*)[ \r]/', $content, $links, PREG_SET_ORDER))
{
echo '<div>External links:</div>';
foreach($links as $link)
{
echo '<div>
<a target="_blank" href="https:' . $link[1] . '">https:' . $link[1] . '</a>
</div>';
}
echo '<br>';
}
echo '<span class="grey">' . $title . ' - ' . $now . ' - ' . $length . 'c - ' . $words . 'w - ' . $lines . 'l </span>';
?>