$app->flash('addPhotoError', "Error trying to add a photo. Try again?"); $app->log->error(sprintf('Error adding a photo with data: %s: %s', $data, $e->getMessage())); } $app->redirect('/admin'); }); $app->post('/admin/delete-photo', function () use($app, $container) { $day = $app->request()->post('day'); $container['imageService']->delete($day); $container['cache']->flush(); $app->redirect('/admin'); }); $app->map('/login', function () use($app, $container) { $email = null; if ($app->request()->isPost()) { $email = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL); $result = $container['userService']->authenticate($email, $_POST['password']); if ($result->isValid()) { $app->redirect('/admin'); } else { $messages = $result->getMessages(); $app->flashNow('error', $messages[0]); } } $app->render('login.html', array('email' => $email)); })->via('GET', 'POST'); $app->get('/logout', function () use($app, $container) { $container['userService']->clearIdentity(); $app->redirect('/'); }); // Run app $app->run();
} $dataArray = array('time' => time(), 'message' => "Run finish"); header("Content-Type: application/json"); echo json_encode($dataArray); exit; }); // add new repeater to list $app->post('/add', function () use($app) { $app->log->info("Echolink CRON System - '/add' route"); $req = $app->request(); if (masterPassword == $req->post('masterpassword')) { $echolinksys = new System("mysql:host=" . host . ";dbname=" . database, username, password); $status = $echolinksys->addRepeater($req->post('callname'), $req->post('email')); if ($status == true) { $app->log->info("Echolink CRON System - add new Repeater to DB"); $app->flashNow('info', 'Add repeater!'); } else { $app->log->info("Echolink CRON System - is exist Repeater to DB"); $app->flashNow('info', 'Fail adding repeater!'); } } $url = $app->urlFor('list', array()); $app->redirect($url); })->name('add'); // delete repeater $app->post('/delete', function () use($app) { $app->log->info("Echolink CRON System - '/delete' route"); $req = $app->request(); if (masterPassword == $req->post('masterpassword')) { $echolinksys = new System("mysql:host=" . host . ";dbname=" . database, username, password); $status = $echolinksys->removeRepeater($req->post('callname'));
public function flashNow($key, $value) { parent::flashNow($key, $value); return $this; }