4 * Show paste creation form
8 * - file name (default: default.php)
11 * Creates and redirects to display page
13 require_once 'www-header.php';
15 if (isset($_POST['file'])) {
17 $repoDir = $GLOBALS['phorkie']['cfg']['repos'];
18 $n = count(glob($repoDir . '/*', GLOB_ONLYDIR));
19 $dir = $repoDir . '/' . $n . '/';
20 mkdir($dir, 0777);//FIXME
21 $vc = new VersionControl_Git($dir);
22 $vc->initRepository();
23 file_put_contents($dir . '.git/description', $_POST['description']);
25 foreach ($_POST['file'] as $num => $arFile) {
26 if ($arFile['name'] != '') {
27 $fname = $arFile['name'];
29 $fname = 'phork' . $num . '.' . $arFile['type'];
31 $fpath = $dir . $fname;
32 file_put_contents($fpath, $arFile['content']);
33 //fixme: let the class do that when it is able to
34 $command = $vc->getCommand('add')
38 $command = $vc->getCommand('commit')
39 ->setOption('message', 'initial paste')
52 render('index', array('file' => $phork, 'description' => ''));