change links on top with link
This commit is contained in:
parent
7d44dc86d2
commit
1d951c063d
57
index.php
57
index.php
|
@ -39,6 +39,35 @@
|
|||
array_unshift($_SESSION['index'], $dir . '/' . $title);
|
||||
}
|
||||
|
||||
function linksdiv($content)
|
||||
{
|
||||
$divcontent = '<div class="grey">';
|
||||
$links = array();
|
||||
if (preg_match_all('/\[\[(.*)\]\]/', $content, $links, PREG_SET_ORDER))
|
||||
{
|
||||
$divcontent .= '<br><div>Internal links:</div>';
|
||||
foreach($links as $link)
|
||||
{
|
||||
$divcontent .= '<div>
|
||||
<a href="index.php?open=true¶m=' . urlencode($link[1]) . '">' . $link[1] . '</a>
|
||||
</div>';
|
||||
}
|
||||
}
|
||||
$links = array();
|
||||
if (preg_match_all('/https:(.*)\b/', $content, $links, PREG_SET_ORDER))
|
||||
{
|
||||
$divcontent .= '<br><div>External links:</div>';
|
||||
foreach($links as $link)
|
||||
{
|
||||
$divcontent .= '<div>
|
||||
<a target="_blank" href="https:' . $link[1] . '">https:' . $link[1] . '</a>
|
||||
</div>';
|
||||
}
|
||||
}
|
||||
$divcontent .= '</div>';
|
||||
return $divcontent;
|
||||
}
|
||||
|
||||
$nextpage = 'home';
|
||||
|
||||
if (isset($_GET['clip']) && $_GET['param'])
|
||||
|
@ -47,7 +76,7 @@
|
|||
savenote('todo', $content);
|
||||
$_GET['param'] = '';
|
||||
}
|
||||
else if (isset($_POST['save']) || isset($_POST['home']))
|
||||
else if (isset($_POST['save']) || isset($_POST['home']) || isset($_POST['links']))
|
||||
{
|
||||
$title = $_POST['title'];
|
||||
$content = $_POST['content'];
|
||||
|
@ -109,7 +138,7 @@
|
|||
{
|
||||
$content = file_get_contents($dir . '/' . $title);
|
||||
}
|
||||
|
||||
|
||||
$lines = substr_count($content, "\r\n");
|
||||
$words = substr_count($content, " ") + $lines;
|
||||
$chars = strlen($content);
|
||||
|
@ -118,30 +147,6 @@
|
|||
|
||||
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¶m=' . urlencode($link[1]) . '">' . $link[1] . '</a>
|
||||
</div>';
|
||||
}
|
||||
echo '<br>';
|
||||
}
|
||||
$links = array();
|
||||
if (preg_match_all('/https:(.*)\b/', $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>';
|
||||
}
|
||||
}
|
||||
else if ($nextpage == 'home')
|
||||
{
|
||||
|
|
8
note.php
8
note.php
|
@ -4,11 +4,15 @@
|
|||
<input type="submit" name="save" value="save" accesskey="s">
|
||||
<input type="submit" name="delete" value="delete" accesskey="d">
|
||||
<input type="submit" name="preview" value="preview" accesskey="p">
|
||||
<input type="submit" name="links" value="links" accesskey="l">
|
||||
<span class="grey"><?echo $lines; ?> lines</span>
|
||||
<span class="grey"><?echo $words; ?> words</span>
|
||||
<span class="grey"><?echo $chars; ?> chars</span>
|
||||
<br>
|
||||
<input autocomplete="off" class="title" name="title" value="<? echo $title; ?>">
|
||||
<?php if (isset($_POST['links']))
|
||||
{
|
||||
echo linksdiv($content);
|
||||
}?>
|
||||
<div><input autocomplete="off" class="title" name="title" value="<? echo $title; ?>"></div>
|
||||
</div>
|
||||
<div class="editor">
|
||||
<textarea rows="<? echo $rows; ?>" autofocus name="content" spellcheck="false"><? echo $content; ?></textarea>
|
||||
|
|
Loading…
Reference in New Issue