Exemple #1
0
 public function checkUserRegistered()
 {
     $cookie = $this->requestCookies['token'];
     if ($cookie == '') {
         $cookie = HashGenerator::generateSalt();
         $this->responseCookies->set('token', $cookie, '1 month');
     }
     $user = $this->em->getRepository('Uppu3\\Entity\\User')->findOneBy(array('token' => $cookie));
     if (!$user) {
         $salt = HashGenerator::generateSalt();
         $user = \Uppu3\Helper\UserHelper::saveAnonymousUser($salt, $this->em, $cookie);
     }
     return $user;
 }
Exemple #2
0
    $filesCount = $filesCount->getArrayResult();
    $list = [];
    foreach ($filesCount as $count) {
        $list[$count[1]] = $count[2];
    }
    $app->render('users.html', array('users' => $users, 'page' => $page, 'filesCount' => $list));
});
$app->get('/users/:id/', function ($id) use($app) {
    $helper = new FormatHelper();
    $page = 'users';
    $user = $app->em->getRepository('Uppu3\\Entity\\User')->findOneById($id);
    $files = $app->em->getRepository('Uppu3\\Entity\\File')->findByUploadedBy($id);
    $app->render('user.html', array('user' => $user, 'files' => $files, 'helper' => $helper, 'page' => $page));
});
$app->delete('/users/:id/', 'checkAuthorization', function ($id) use($app) {
    \Uppu3\Helper\UserHelper::userDelete($id, $app->em);
    $app->redirect('/users');
});
$app->delete('/view/:id/', 'checkAuthorization', function ($id) use($app) {
    $fileHelper = new \Uppu3\Helper\FileHelper($app->em);
    $fileHelper->fileDelete($id);
    $app->redirect('/list');
});
$app->get('/list', 'checkAuthorization', function () use($app) {
    $helper = new FormatHelper();
    $page = 'list';
    $files = $app->em->getRepository('Uppu3\\Entity\\File')->findBy([], ['uploaded' => 'DESC'], 50, 0);
    $app->render('list.html', array('files' => $files, 'page' => $page, 'helper' => $helper));
});
$app->post('/send/:id', function ($id) use($app) {
    $parent = isset($_POST['parent']) ? $app->em->find('Uppu3\\Entity\\Comment', $app->request->params('parent')) : null;