Compare commits
2 Commits
4a3061fccd
...
020545feb3
Author | SHA1 | Date |
---|---|---|
quenousimporte | 020545feb3 | |
quenousimporte | ce1867bcf0 |
23
index.php
23
index.php
|
@ -10,12 +10,13 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<?php
|
<?php
|
||||||
|
error_reporting(E_ALL);
|
||||||
require 'settings.php';
|
require 'settings.php';
|
||||||
|
|
||||||
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>';
|
echo '<p>Access denied.</p></body></html>';
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,9 +35,23 @@
|
||||||
function savenote($title, $content)
|
function savenote($title, $content)
|
||||||
{
|
{
|
||||||
global $dir;
|
global $dir;
|
||||||
file_put_contents($dir . '/' . $title, $content);
|
$path = $dir . '/' . $title;
|
||||||
|
$lastchanged = filemtime($path);
|
||||||
|
$previous = $_POST['lastchanged'];
|
||||||
|
if ( (int)$lastchanged > (int)$previous)
|
||||||
|
{
|
||||||
|
$tempcontent = file_get_contents($path);
|
||||||
|
if ($tempcontent != $content)
|
||||||
|
{
|
||||||
|
$temptitle = $title . '_' . $lastchanged;
|
||||||
|
file_put_contents($dir . '/' . $temptitle, $tempcontent);
|
||||||
|
array_unshift($_SESSION['index'], $dir . '/' . $temptitle);
|
||||||
|
echo '<div class="grey">Conflict detected. See backup: ' . $temptitle . '</div>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file_put_contents($path, $content);
|
||||||
removefromindex($title);
|
removefromindex($title);
|
||||||
array_unshift($_SESSION['index'], $dir . '/' . $title);
|
array_unshift($_SESSION['index'], $path);
|
||||||
}
|
}
|
||||||
|
|
||||||
function linksdiv($content)
|
function linksdiv($content)
|
||||||
|
@ -137,6 +152,8 @@
|
||||||
$content = file_get_contents($dir . '/' . $title);
|
$content = file_get_contents($dir . '/' . $title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearstatcache();
|
||||||
|
$lastchanged = filemtime($dir . '/' . $title);
|
||||||
$lines = substr_count($content, "\r\n");
|
$lines = substr_count($content, "\r\n");
|
||||||
$words = substr_count($content, " ") + $lines;
|
$words = substr_count($content, " ") + $lines;
|
||||||
$chars = strlen($content);
|
$chars = strlen($content);
|
||||||
|
|
1
note.php
1
note.php
|
@ -6,6 +6,7 @@
|
||||||
<input type="submit" name="links" value="links" accesskey="l">
|
<input type="submit" name="links" value="links" accesskey="l">
|
||||||
<input type="submit" name="stats" value="stats" accesskey="i">
|
<input type="submit" name="stats" value="stats" accesskey="i">
|
||||||
<input type="submit" name="delete" value="delete" accesskey="d">
|
<input type="submit" name="delete" value="delete" accesskey="d">
|
||||||
|
<input hidden name="lastchanged" value="<? echo $lastchanged; ?>">
|
||||||
<?php
|
<?php
|
||||||
if (isset($_POST['stats']))
|
if (isset($_POST['stats']))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue