X-Git-Url: https://git.cweiske.de/phorkie.git/blobdiff_plain/5f427dd38c8d47711ea73015076bb390761e05dd..4d3b1690a86631b4b1abc74dfa4c4e5bde8faf10:/www/index.php diff --git a/www/index.php b/www/index.php index 31aef7d..044ac35 100644 --- a/www/index.php +++ b/www/index.php @@ -14,13 +14,14 @@ require_once 'www-header.php'; if (isset($_POST['file'])) { //save - $repoDir = $GLOBALS['phorkie']['cfg']['repos']; - $n = count(glob($repoDir . '/*', GLOB_ONLYDIR)); - $dir = $repoDir . '/' . $n . '/'; - mkdir($dir, 0777);//FIXME - $vc = new VersionControl_Git($dir); + $rs = new Repositories(); + $repo = $rs->createNew(); + $vc = $repo->getVc(); $vc->initRepository(); - file_put_contents($dir . '.git/description', $_POST['description']); + foreach (glob($repo->repoDir . '/.git/hooks/*') as $hookfile) { + unlink($hookfile); + } + file_put_contents($repo->repoDir . '.git/description', $_POST['description']); foreach ($_POST['file'] as $num => $arFile) { if ($arFile['name'] != '') { @@ -28,7 +29,7 @@ if (isset($_POST['file'])) { } else { $fname = 'phork' . $num . '.' . $arFile['type']; } - $fpath = $dir . $fname; + $fpath = $repo->repoDir . $fname; file_put_contents($fpath, $arFile['content']); //fixme: let the class do that when it is able to $command = $vc->getCommand('add') @@ -37,9 +38,10 @@ if (isset($_POST['file'])) { } $command = $vc->getCommand('commit') ->setOption('message', 'initial paste') + ->setOption('author', 'Anonymous ') ->execute(); //redirect to phork - redirect($n); + redirect($repo->getLink('display')); } $phork = array(