fix php warnings

This commit is contained in:
quenousimporte 2024-10-15 11:38:15 +02:00
parent 71635ab255
commit 84c63e69a3
2 changed files with 51 additions and 43 deletions

View File

@ -37,11 +37,15 @@
{ {
global $dir; global $dir;
$path = $dir . '/' . $title; $path = $dir . '/' . $title;
$lastchanged = filemtime($path . '.md'); $filename = $path . '.md';
if (file_exists($filename))
{
$lastchanged = filemtime($filename);
$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($filename);
if ($tempcontent != $content) if ($tempcontent != $content)
{ {
$temptitle = $title . '_conflict_' . $lastchanged; $temptitle = $title . '_conflict_' . $lastchanged;
@ -49,7 +53,9 @@
array_unshift($_SESSION['index'], $dir . '/' . $temptitle); array_unshift($_SESSION['index'], $dir . '/' . $temptitle);
} }
} }
file_put_contents($path . '.md', $content); }
file_put_contents($filename, $content);
removefromindex($title); removefromindex($title);
array_unshift($_SESSION['index'], $path); array_unshift($_SESSION['index'], $path);
} }

View File

@ -2,6 +2,8 @@
require('common.php'); require('common.php');
// handle save actions // handle save actions
if (count($_POST) > 0)
{
$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']) || isset($_POST['preview']))
@ -44,9 +46,9 @@
header("Location: index.php"); header("Location: index.php");
exit; exit;
} }
}
// main // main
$title = ''; $title = '';
$content = false; $content = false;
if (isset($_GET['new'])) if (isset($_GET['new']))