public function testFlashData() { $s = new \Slim\Slim(); $s->get('/bar', function () use($s) { $s->flashNow('info', 'bar'); }); $s->run(); $this->assertEquals(array('info' => 'bar'), $s->flashData()); }
public function testSetFlashForCurrentRequest() { $s = new \Slim\Slim(); $s->get('/bar', function () use($s) { $s->flashNow('info', 'bar'); }); $s->run(); $env = $s->environment(); $this->assertEquals('bar', $env['slim.flash']['info']); }
Config::set('system_id', ''); } // get payutcClient function getPayutcClient($service) { return new \JsonClient\AutoJsonClient(Config::get('payutc_server'), $service, array(CURLOPT_PROXY => Config::get('proxy')), "Payutc Json PHP Client", isset($_SESSION['payutc_cookie']) ? $_SESSION['payutc_cookie'] : ""); } $payutcClient = getPayutcClient("WEBSALE"); $admin = $payutcClient->isSuperAdmin(); $isAdminFondation = $payutcClient->isAdmin(); $status = $payutcClient->getStatus(); $app = new \Slim\Slim(); $app->hook('slim.before', function () use($app, $payutcClient, $admin) { // check that system is installed if (!Config::isInstalled()) { $app->flashNow('info', 'This application is not yet configured, please click <a href="install" >here</a> !'); } global $status; if (!in_array($app->request->getResourceUri(), ['/about', '/login'])) { if (!isset($status) || empty($status->user)) { // Il n'était pas encore connecté en tant qu'icam. $app->flash('info', "Vous devez être connecté pour accéder au reste de l'application"); $app->redirect('about'); } else { if (!empty($status->user) && (empty($status->application) || isset($status->application->app_url) && strpos($status->application->app_url, 'shotgun') === false)) { // il était connecté en tant qu'icam mais l'appli non try { $result = $payutcClient->loginApp(array("key" => Config::get('payutc_key'))); $status = $payutcClient->getStatus(); } catch (\JsonClient\JsonException $e) { $app->flashNow('info', "error login application, veuillez finir l'installation de Shotgun");
} $app->get('/login', '\\App\\Controller\\AuthController:login')->name('auth@login'); $app->get('/logout', '\\App\\Controller\\AuthController:logout')->name('auth@logout'); $app->post('/login', '\\App\\Controller\\AuthController:dologin')->name('auth@dologin'); $app->post('/user/create', '\\App\\Controller\\UserController:create')->name('user@create'); $app->get('/', function () use($app) { $app->redirectTo('Menu@Display'); })->name('home'); $app->get('/display', function () use($app) { // Sample log message // $app->log->info("Slim-Skeleton '/' route"); // Render index view //$app->render('index.html', array('name' => 'test')); $result = DB::statement("SHOW TABLES"); if (!$result) { $app->flashNow('error', mysql_error()); } elseif (is_bool($result)) { $app->flashNow('success', "Query was successful, but returned no results."); } else { $columns = array(); foreach ($result[0] as $column => $data) { if (!is_int($column)) { array_push($columns, $column); } } $app->flashNow('columns', $columns); $app->flashNow('rows', $result); } $app->flashNow('query', $app->request->post('query')); return $app->render('display.html', array('page' => 'Display')); })->name('Menu@Display');
$slim->render('edit_config.php', array("config" => $config)); })->name("config"); $slim->post('/config', function () use($slim) { $config = get_config(); // only save what we're expecting $values = array(); $values["access_rights"] = $_POST["access_rights"]; $values["organisation_name"] = $_POST["organisation_name"]; $values["master_profile_uuid"] = $_POST["master_profile_uuid"]; $values["cert_uuid"] = $_POST["cert_uuid"]; $values["mdm_uuid"] = $_POST["mdm_uuid"]; $values["mdm_certificate_password"] = $_POST["mdm_certificate_password"]; $values["mdm_topic"] = $_POST["mdm_topic"]; $values["root_url"] = $_POST["root_url"]; if ($_FILES["mdm_certificate"]['size'] > 0 and $_FILES["mdm_certificate"]["error"] > 0) { $slim->flashNow('error', 'MDM Cerfiticate failed to upload'); } else { if ($_FILES["mdm_certificate"]['size'] > 0) { $data = file_get_contents($_FILES['mdm_certificate']['tmp_name']); $data = base64_encode($data); $values["mdm_certificate"] = $data; } save_config($config->id, $values); $slim->flashNow('success', 'Config Saved'); $config = get_config(); } $slim->render('edit_config.php', array("config" => $config)); })->name("save_config"); /** Our profiles pages */
$usu = $_SESSION['id_usuario']; $result = Dispositivo::anadirDispositivo($tiposelect, $inputLatitude, $inputLongitude, $usu); //0->KO / 1->OK / 2->Existe el usuario / 3->registro OK correo KO /*Códigos de mensajes= -err_reg_usr-->Error al registrar el usuario -usr_reg_OK-->Usuario registrado correctamente. -usr_em_exist-->Usuario o email existentes -usr_OK_em_F -->Usuario registrado, correo fallido */ if ($result == 1) { $app->flash('message', "El dipsositivo insertado correctamente"); $app->redirect($app->urlfor('panel')); } else { if ($result == 0) { $app->flashNow('message', "No existe el dipsositivo"); $app->redirect($app->urlfor('panel')); } else { $app->flashNow('message', "El dipsositivo no está validado, valida para poder acceder."); $app->redirect($app->urlfor('panel')); } } } }); //btnmodDispositivos $app->post('/btnmodDispositivos', function () use($app) { require_once 'Modelos/Dispositivo.php'; if (!isset($_SESSION['id_usuario'])) { //render login $app->redirect($app->urlfor('Inicio')); } else {