$tags = $regExp->match(trim($_POST['tags'])); $description = $regExp->match(trim($_POST['description'])); $public = $regExp->match($_POST['public']); $terminate = $regExp->match($_POST['terminate']); $foo = new Foo(); $foo->id = $file_id; $foo->tags = $tags; $foo->public = $public; $foo->description = $description; $foo->terminate = $terminate; $foomapper = new FooMapper($db); $foomapper->save($foo); $app->redirect("{$id}"); } })->via('GET', 'POST')->name('FileEdit'); $app->get('/:id/:preview', function ($id, $preview) use($app) { ini_set('display_errors', 'On'); error_reporting('E_ALL'); $db = $app->db; $foo = new Foo(); $foo->token = $id; $mapper = new FooMapper($db); $files = $mapper->selectToken($foo); if (empty($files)) { $app->error(); } $checkrights = new Checkrights(); $checkrights->RenderPreview($files, $app, $preview); ini_set('display_errors', 'Off'); })->name('preview'); });
<?php $app->get('/download/:id', function ($id) use($app) { ini_set('display_errors', 'On'); error_reporting('E_ALL'); $db = $app->db; $foo = new Foo(); $foo->token = $id; $mapper = new FooMapper($db); $files = $mapper->selectToken($foo); $checkrights = new Checkrights(); $checkrights->Download($files, $app, $id); })->name('download');
<?php $app->get('/delete/:id', function ($page) use($app) { ini_set('display_errors', 'On'); error_reporting('E_ALL'); // $files=$app->db->query("SELECT * FROM files WHERE `token` = '$id'")->fetchALL(PDO::FETCH_ASSOC); $db = $app->db; $foo = new Foo(); $foo->token = $page; $mapper = new FooMapper($db); $files = $mapper->selectToken($foo); ini_set('display_errors', 'Off'); //$app->db->query("DELETE FROM files WHERE `token`='$id'"); $checkrights = new Checkrights(); $checkrights->Delete($files, $app, $page); })->name('delete');