change gui use combobox to select action
This commit is contained in:
parent
ccd63ea392
commit
74d2c4f86d
49
index.php
49
index.php
|
@ -46,23 +46,30 @@
|
|||
|
||||
echo '<div><a accesskey="h" href="' . $root . '">home</a></div><br>';
|
||||
|
||||
if (isset($_POST['savebutton']))
|
||||
$action = '';
|
||||
if (isset($_POST['action'])) $action = $_POST['action'];
|
||||
else if (isset($_GET['action'])) $action = $_GET['action'];
|
||||
|
||||
$param = '';
|
||||
if (isset($_GET['param'])) $param = $_GET['param'];
|
||||
|
||||
if ($action == 'save')
|
||||
{
|
||||
$title = $_POST['title'];
|
||||
$content = $_POST['content'];
|
||||
file_put_contents($dir . '/' . $title, $content);
|
||||
$_GET['openaction'] = true;
|
||||
$_GET['userdata'] = $title;
|
||||
$action = 'open';
|
||||
$param = $title;
|
||||
}
|
||||
else if (isset($_POST['deletebutton']))
|
||||
else if ($action == 'delete')
|
||||
{
|
||||
$title = $_POST['title'];
|
||||
rename($dir . '/' . $title, $dir . '/' . $title . '.del');
|
||||
}
|
||||
|
||||
if (isset($_GET['openaction']))
|
||||
if ($action == 'open')
|
||||
{
|
||||
$title = $_GET['userdata'];
|
||||
$title = $param;
|
||||
|
||||
$content = '';
|
||||
if (!file_exists($dir . '/' . $title))
|
||||
|
@ -78,8 +85,11 @@
|
|||
|
||||
echo '<form action="index.php" method="POST">
|
||||
<div>
|
||||
<input type="submit" name="savebutton" value="save" accesskey="s">
|
||||
<input accesskey="d" type="submit" name="deletebutton" value="delete">
|
||||
<select name="action">
|
||||
<option value="save">save</option>
|
||||
<option value="delete">delete</option>
|
||||
</select>
|
||||
<input type="submit" name="go" value="go" accesskey="g">
|
||||
</div>
|
||||
<br>
|
||||
<div><input class="title" name="title" value="' . $title . '"></div><br>
|
||||
|
@ -91,15 +101,18 @@
|
|||
else
|
||||
{
|
||||
$defaulttitle = date("Y-m-d H.i.s", time());
|
||||
if (isset($_GET['userdata']))
|
||||
if ($param)
|
||||
{
|
||||
$defaulttitle = $_GET['userdata'];
|
||||
$defaulttitle = $param;
|
||||
}
|
||||
echo '<form action="index.php" method="GET">
|
||||
<input list="notes" name="userdata" value="' . $defaulttitle . '">
|
||||
<input accesskey="n" type="submit" name="openaction" value="open">
|
||||
<input accesskey="f" type="submit" name="filteraction" value="filter">
|
||||
<input accesskey="g" type="submit" name="searchaction" value="search">
|
||||
<input name="param" value="' . $defaulttitle . '">
|
||||
<select name="action">
|
||||
<option value="open">open</option>
|
||||
<option value="filter">filter</option>
|
||||
<option value="search">search</option>
|
||||
</select>
|
||||
<input accesskey="g" type="submit" value="go">
|
||||
</form>';
|
||||
echo '<br>';
|
||||
|
||||
|
@ -113,17 +126,17 @@
|
|||
{
|
||||
$name = basename($path);
|
||||
if (!str_ends_with($name, '.del')
|
||||
&& (!isset($_GET['filteraction']) || str_contains($name, $_GET['userdata'])))
|
||||
&& ($action != 'filter' || str_contains($name, $param)))
|
||||
{
|
||||
if (isset($_GET['searchaction']))
|
||||
if ($action == 'search')
|
||||
{
|
||||
$content = file_get_contents($path);
|
||||
if (!str_contains($content, $_GET['userdata']))
|
||||
if (!str_contains($content, $param))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
echo '<div><a href=index.php?openaction&userdata=' . urlencode($name) . '>' . $name .'</a></div>';
|
||||
echo '<div><a href=index.php?action=open¶m=' . urlencode($name) . '>' . $name .'</a></div>';
|
||||
}
|
||||
}
|
||||
echo '<br>';
|
||||
|
|
Loading…
Reference in New Issue