Exemple #1
0
    }
});
$app->get('/files(/:page)', function ($page = 1) use($app) {
    $num = 100;
    $files = $app->FileGateway->getLatestFiles($num);
    $app->render('latestFiles.phtml', array('files' => $files, 'title' => 'Последние файлы', 'active' => 'files'));
});
$app->get('/about', function () use($app) {
    $app->render('about.phtml', array('title' => 'О нас', 'active' => 'about'));
});
$app->post('/comment', function () use($app) {
    $requestVars = $app->request->post();
    $commentHandler = new CommentsController($app->CommentGateway, $requestVars);
    $comments = $commentHandler->addComment();
    if (!$comments) {
        $app->render('commentError.phtml', array("params" => $commentHandler->getParamsFromCache(), "title" => "Заполните все поля"));
    } else {
        $app->response->redirect("/f/{$requestVars['fileId']}", 303);
    }
});
$app->get('/showFullPicture/:id', function ($id) use($app) {
    $file = $app->FileGateway->getData($id);
    if (file_exists($file->path)) {
        $app->render('pictureView.phtml', array('title' => $file->name, 'file' => $file, 'path' => $file->path));
    }
});
$app->post('/modify/:id', function ($id) use($app) {
    session_start();
    $description = $app->request->post('description');
    if (isset($_SESSION['fileId']) && array_key_exists("{$id}", $_SESSION['fileId'])) {
        $app->FileGateway->changeDescription($id, $description);