various fix
This commit is contained in:
parent
58291bd62b
commit
40a0a574a9
16
common.php
16
common.php
|
@ -21,10 +21,6 @@
|
|||
{
|
||||
$zip->addFile($path, basename($path));
|
||||
}
|
||||
else
|
||||
{
|
||||
echo"file does not exist";
|
||||
}
|
||||
}
|
||||
}
|
||||
$zip->close();
|
||||
|
@ -34,24 +30,22 @@
|
|||
readfile($zip_name);
|
||||
|
||||
unlink($zip_name);
|
||||
exit;
|
||||
}
|
||||
|
||||
function savenote($title, $content)
|
||||
{
|
||||
global $dir;
|
||||
$path = $dir . '/' . $title;
|
||||
$lastchanged = filemtime($path);
|
||||
$lastchanged = filemtime($path . '.md');
|
||||
$previous = $_POST['lastchanged'];
|
||||
if ((int)$lastchanged > (int)$previous)
|
||||
{
|
||||
$tempcontent = file_get_contents($path . '.md');
|
||||
if ($tempcontent != $content)
|
||||
{
|
||||
$temptitle = $title . '_' . $lastchanged;
|
||||
$temptitle = $title . '_conflict_' . $lastchanged;
|
||||
file_put_contents($dir . '/' . $temptitle . '.md', $tempcontent);
|
||||
array_unshift($_SESSION['index'], $dir . '/' . $temptitle);
|
||||
echo '<div class="grey">Conflict detected. See backup: ' . $temptitle . '</div>';
|
||||
}
|
||||
}
|
||||
file_put_contents($path . '.md', $content);
|
||||
|
@ -74,7 +68,6 @@
|
|||
header('Content-disposition: attachment; filename=' . basename($path));
|
||||
header('Content-type: text/markdown');
|
||||
readfile($path);
|
||||
exit;
|
||||
}
|
||||
|
||||
function linksdiv($content)
|
||||
|
@ -118,8 +111,9 @@
|
|||
return $preview;
|
||||
}
|
||||
|
||||
// Main
|
||||
if ($password && (!isset($_SERVER['PHP_AUTH_PW']) || $_SERVER['PHP_AUTH_PW'] != $password)) {
|
||||
// authent
|
||||
if ($password && (!isset($_SERVER['PHP_AUTH_PW']) || $_SERVER['PHP_AUTH_PW'] != $password))
|
||||
{
|
||||
header('WWW-Authenticate: Basic realm="bbn"');
|
||||
header('HTTP/1.0 401 Unauthorized');
|
||||
echo '<p>Access denied.</p></body></html>';
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
if (isset($_GET['download']))
|
||||
{
|
||||
downloadall();
|
||||
exit;
|
||||
}
|
||||
|
||||
$filter = '';
|
||||
|
|
14
note.php
14
note.php
|
@ -4,8 +4,7 @@
|
|||
// handle save actions
|
||||
$title = $_POST['title'];
|
||||
$content = $_POST['content'];
|
||||
|
||||
if (isset($_POST['save']) || isset($_POST['home']) || isset($_POST['download']))
|
||||
if (isset($_POST['save']) || isset($_POST['home']) || isset($_POST['download']) || isset($_POST['preview']))
|
||||
{
|
||||
savenote($title, $content);
|
||||
|
||||
|
@ -19,12 +18,18 @@
|
|||
if (isset($_POST['download']))
|
||||
{
|
||||
downloadnote($dir . '/' . $title . '.md');
|
||||
exit;
|
||||
}
|
||||
else if (isset($_POST['home']))
|
||||
{
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
else if (isset($_POST['preview']))
|
||||
{
|
||||
header("Location: note.php?preview=1&title=" . $title);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
header("Location: note.php?title=" . $title);
|
||||
|
@ -39,11 +44,6 @@
|
|||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
else if (isset($_POST['preview']))
|
||||
{
|
||||
header("Location: note.php?preview=1&title=" . $title);
|
||||
exit;
|
||||
}
|
||||
|
||||
// main
|
||||
|
||||
|
|
Loading…
Reference in New Issue