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