Example #1
0
$app->get('/f/thumb/:res/:mode/:src+', function ($res, $mode, $src) use($app) {
    $sides = explode("x", $res);
    $width = $sides[0];
    $height = $sides[1];
    $origFile = implode("/", $src);
    $origFileValid = urldecode($origFile);
    $origName = array_pop($src);
    $origDir = implode("/", $src);
    $thumbName = $origDir . "/thumb-{$res}-{$mode}-{$origName}";
    if (file_exists($thumbName)) {
        $info = getimagesize($thumbName);
        MyPreviewThumbnail::sendHeader($info[2]);
        readfile($thumbName);
    } else {
        try {
            $brandNewPic = MyPreviewThumbnail::resize($origFileValid, $width, $height, $mode, true);
        } catch (myPreviewException $e) {
            echo $e;
        }
        MyPreviewThumbnail::sendHeader(MyPreviewThumbnail::getType());
        readfile($brandNewPic);
    }
});
$app->get('/f/:id', function ($id) use($app) {
    session_start();
    $flash = $_SESSION['slim.flash'];
    $file = $app->FileGateway->getData($id);
    $comments = $app->CommentGateway->getAllFileComments($id);
    if ($file) {
        $app->render('details.phtml', array('file' => $file, 'title' => $file->name, 'comments' => $comments, 'app' => $app, 'flash' => $flash));
    } else {