X-Git-Url: http://git.shiar.net/minimedit.git/blobdiff_plain/28b42031be26e959ff042fdf6fc58ca0c66ccb40..d1afddfdc3f5d901b26a064d9422978e5e8a8acd:/edit.php diff --git a/edit.php b/edit.php index ca9639c..9ba0d04 100644 --- a/edit.php +++ b/edit.php @@ -60,5 +60,19 @@ if (!file_exists(dirname($filename)) and !mkdir(dirname($filename))) if (!file_put_contents($filename, $upload)) abort("fout bij schrijven van $filename", '500 save error'); +if (is_writable('../.git')) { + $gitmsg = preg_replace('/\.html$/', '', $filename).": edit from {$_SERVER['REMOTE_ADDR']}"; + $gitcmd = 'git'; + $gitcmd .= ' -c user.name='.escapeshellarg($User['name']); + $gitcmd .= ' -c user.email='.escapeshellarg("{$User['name']}@lijtweg.nl"); + $gitcmd .= ' commit -q'; + $gitcmd .= ' -m '.escapeshellarg($gitmsg); + $gitcmd .= ' -- '.escapeshellarg($filename); + exec("$gitcmd 2>&1", $gitlog, $gitstatus); + if ($gitstatus) { + trigger_error("git commit failure $gitstatus: ".implode("\n", $gitlog), E_USER_WARNING); + } +} + abort("Bestand opgeslagen");