function handleUserProject($id) { $app = \Slim\Slim::getInstance(); $project = getProjectOr404($id); if (!empty($_SESSION['user']) && $project['dct:creator'] == $_SESSION['user']['username']) { removeUserProject($id); } else { $app->flash('error', 'あなたの作成したプロジェクトではありません'); $app->redirect($app->config('static_path') . ''); } }
$_SESSION['id'] = $id; $data['_token'] = publishToken(); $data = array_merge($data, $_SESSION); $app->render('upload.php', $data); })->conditions(array('id' => '[a-f0-9]{24}')); $app->get('/upload(/:action)(/:id)', 'authenticateUser', function ($action = 'new', $id = null) use($app) { $data = array(); $_SESSION['action'] = $action; switch ($action) { case 'fork': $_SESSION['project'] = getProjectOr404($id); $_SESSION['id'] = $id; break; case 'edit': if (preg_match('/[a-f0-9]{24}/', $id)) { $_SESSION['project'] = getProjectOr404($id); if (!empty($_SESSION['user']) && $_SESSION['project']['dct:creator'] == $_SESSION['user']['username']) { $_SESSION['id'] = $id; } else { $app->flash('error', 'あなたの作成したプロジェクトではありません'); $app->redirect($app->config('static_path')); } } else { $app->flash('error', '不正なプロジェクトIDです'); $app->redirect($app->config('static_path')); } break; case 'new': unset($_SESSION['project']); break; default: