当前位置: 首页>>代码示例>>PHP>>正文


PHP Slim::flash方法代码示例

本文整理汇总了PHP中Slim\Slim::flash方法的典型用法代码示例。如果您正苦于以下问题:PHP Slim::flash方法的具体用法?PHP Slim::flash怎么用?PHP Slim::flash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Slim\Slim的用法示例。


在下文中一共展示了Slim::flash方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: function

}
$app->config(array('templates.path' => 'app/view/'));
$app->group('/', function () use($app) {
    $app->get('/', function () use($app) {
    });
});
$app->group('/login', function () use($app) {
    $app->get('/', function () use($app) {
        $app->render('login.php');
    });
    $app->post('/', function () use($app) {
        $data = $app->request()->post();
        $login = new LoginController();
        $result = $login->login($data);
        if ($result) {
            $app->flash('msgInfo', 'Bienvenido ' . $_SESSION['user']);
            if ($_SESSION['tipo'] == 1) {
                $app->redirect(URL . 'pacientes');
            }
            if ($_SESSION['tipo'] == 2) {
                $app->redirect(URL . 'turnos');
            }
            if ($_SESSION['tipo'] == 3) {
                $app->redirect(URL . 'guardias');
            }
            if ($_SESSION['tipo'] == 4) {
                $app->redirect(URL . 'turnos');
            }
        } else {
            $app->flash('msgError', 'Datos incorrectos.');
            $app->redirect(URL . 'login');
开发者ID:RodrigoBattagliero,项目名称:proyecto-simat,代码行数:31,代码来源:index.php

示例2: configureRoutes

 /**
  * Configure routes to be handled by application.
  *
  * @param \Slim\Slim $slim Application
  */
 protected function configureRoutes(\Slim\Slim $slim)
 {
     $middleware = array('must-revalidate' => function () use($slim) {
         $slim->response->headers->set('Cache-Control', 'private, must-revalidate, max-age=0');
         $slim->response->headers->set('Expires', 'Thu, 01 Jan 1970 00:00:00 GMT');
     }, 'inject-user' => function () use($slim) {
         $user = $slim->authManager->getUserData();
         $slim->view->set('user', $user);
     }, 'require-user' => function () use($slim) {
         if ($slim->authManager->isAnonymous()) {
             if ($slim->request->isGet()) {
                 $uri = $slim->request->getUrl() . $slim->request->getPath();
                 $qs = Form::qsMerge();
                 if ($qs) {
                     $uri = "{$uri}?{$qs}";
                 }
                 $_SESSION[AuthManager::NEXTPAGE_SESSION_KEY] = $uri;
             }
             // FIXME: use i18n
             $slim->flash('error', 'Login required');
             $slim->flashKeep();
             $slim->redirect($slim->urlFor('login'));
         }
     });
     $slim->group('/', $middleware['inject-user'], function () use($slim, $middleware) {
         App::redirect($slim, '', 'random', 'home');
         App::redirect($slim, 'index', 'random');
         $slim->get('random', function () use($slim) {
             $page = new Pages\Random($slim);
             $page->setI18nContext($slim->i18nContext);
             $page->setQuips($slim->quips);
             $page();
         })->name('random');
         $slim->get('random.json', function () use($slim) {
             $slim->response->headers->set('Content-Type', 'application/json');
             $page = new Pages\Random($slim);
             $page->setI18nContext($slim->i18nContext);
             $page->setQuips($slim->quips);
             $page->setTemplate('random.json');
             $page();
         })->name('random.json');
         $slim->get('search', function () use($slim) {
             $page = new Pages\Search($slim);
             $page->setI18nContext($slim->i18nContext);
             $page->setQuips($slim->quips);
             $page();
         })->name('search');
         $slim->get('top', function () use($slim) {
             $page = new Pages\Top($slim);
             $page->setI18nContext($slim->i18nContext);
             $page->setQuips($slim->quips);
             $page();
         })->name('top');
         App::template($slim, 'login');
         $slim->get('logout', $middleware['must-revalidate'], function () use($slim) {
             $slim->authManager->logout();
             $slim->redirect($slim->urlFor('home'));
         })->name('logout');
         App::template($slim, 'about');
         App::template($slim, 'help');
     });
     // end group '/'
     $slim->group('/quip/', $middleware['inject-user'], function () use($slim, $middleware) {
         $slim->get(':id', function ($id) use($slim) {
             $page = new Pages\Quip($slim);
             $page->setI18nContext($slim->i18nContext);
             $page->setQuips($slim->quips);
             $page($id);
         })->name('quip');
         $slim->get(':id/edit', $middleware['require-user'], function ($id) use($slim) {
             $page = new Pages\Edit($slim);
             $page->setI18nContext($slim->i18nContext);
             $page->setQuips($slim->quips);
             $page($id);
         })->name('edit');
         $slim->post(':id/post', $middleware['require-user'], function ($id) use($slim) {
             $page = new Pages\Edit($slim);
             $page->setI18nContext($slim->i18nContext);
             $page->setQuips($slim->quips);
             $page($id);
         })->name('edit_post');
         $slim->post(':id/delete', $middleware['require-user'], function ($id) use($slim) {
             $page = new Pages\Delete($slim);
             $page->setI18nContext($slim->i18nContext);
             $page->setQuips($slim->quips);
             $page($id);
         })->name('delete_post');
         $slim->post(':id/vote', $middleware['require-user'], function ($id) use($slim) {
             $page = new Pages\Vote($slim);
             $page->setI18nContext($slim->i18nContext);
             $page->setQuips($slim->quips);
             $page($id);
         })->name('vote_post');
     });
     $slim->group('/oauth/', function () use($slim) {
//.........这里部分代码省略.........
开发者ID:bd808,项目名称:quips,代码行数:101,代码来源:App.php

示例3: function

        $app->view()->appendData(array('userInfo' => $authData));
    }
    $app->view()->appendData(array('site_root' => $app->environment['SCRIPT_NAME'] . '/'));
});
$app->get('/', function () use($app) {
    $app->render('html/index.html');
})->name('index');
$app->get('/login', function () use($app) {
    $app->render('html/login.html');
})->name('login');
$app->post('/login', function () use($app) {
    $result = $app->authenticator->authenticate($app->request->post('username'), $app->request->post('password'));
    if ($result->isValid()) {
        $app->redirect($app->urlFor('profile'));
    } else {
        $app->flash('error', 'Invalid username or password provided');
        $app->redirect($app->urlFor('login'));
    }
});
$app->get('/logout', function () use($app) {
    $app->authenticator->logout();
    $app->redirect($app->urlFor('index'));
});
$app->get('/pwreset/:guid', function ($guid) use($app) {
    if (checkGUID($app->db, $guid)) {
        $app->render('html/pwreset.html', array('guid' => $guid));
    } else {
        $app->notFound();
    }
});
$app->post('/pwreset/:guid', function () use($app) {
开发者ID:greboid,项目名称:Holidays,代码行数:31,代码来源:index.php

示例4: function

        $app->halt(403);
    }
    $app->render('setup.html');
});
$app->post('/setup', function () use($app, $container) {
    if (count($container['userDao']->findAll()) > 0) {
        $app->halt(403, 'NO MOAR USERS ALLOWED');
    }
    $params = $app->request()->post();
    $email = filter_var($params['email'], FILTER_SANITIZE_EMAIL);
    $email = filter_var($email, FILTER_VALIDATE_EMAIL);
    if ($email) {
        try {
            $user = $container['userService']->createUser($email, $params['password'], $params['confirm-password']);
            $app->log->info(sprintf('New user %s has been created', $user['email']));
            $app->flash('joinSuccess', sprintf('Congrats %s! Now log in and get started!', $user['email']));
            $redirectTo = '/login';
        } catch (\PDOException $p) {
            $app->log->error(sprintf('Database error creating account for %s: %s', $email, $p->getMessage()));
            $app->flash('error', sprintf("Database error creating your account. Stop doing whatever bad thing you're doing!", $email));
            $redirectTo = '/setup';
        } catch (\Exception $e) {
            $app->log->error(sprintf('Error creating account for %s: %s', $email, $e->getMessage()));
            $app->flash('error', $e->getMessage());
            $redirectTo = '/setup';
        }
    } else {
        $app->flash('error', sprintf("'%s' is not a valid email address", $params['email']));
        $redirectTo = '/setup';
    }
    $app->redirect($redirectTo);
开发者ID:neophyt3,项目名称:flaming-archer,代码行数:31,代码来源:index.php

示例5: function

**/
$app->post('/', function () use($app, $dl, $mail) {
    // setup variables from the incoming post
    $album = $app->request->post('album');
    $email = $app->request->post('email');
    $code = strtoupper($app->request->post('code'));
    $subscribe = $app->request->post('mailing_list');
    $address = $app->request->post('address');
    // Set current entries to cookies
    $app->setCookie('code', $code);
    $app->setCookie('email', $email);
    $app->setCookie('album', $album);
    $app->setCookie('subscribe', $subscribe);
    // Make sure the Honey Pot field is empty.
    if (!empty($address)) {
        $app->flash('error', 'Your form submission has an error.');
        // Push them back to the main screen with generic error message
        $app->redirect($app->urlFor('home'));
    } elseif (!empty($code) && !empty($email)) {
        // Clean up the form submissions
        $cleanCode = filter_var($code, FILTER_SANITIZE_STRING);
        $cleanEmail = filter_var($email, FILTER_SANITIZE_EMAIL);
        $cleanAlbum = filter_var($album, FILTER_SANITIZE_STRING);
        // validate the email format
        $validEmail = filter_var($cleanEmail, FILTER_VALIDATE_EMAIL);
        // Validate the code entered
        $validCode = $dl->validate_code($album, $code);
        // Check if the code and email entered are valid
        if ($validEmail && $validCode === 200) {
            // Subscribe the user if they kept the subscribe option checked
            if ($subscribe) {
开发者ID:nblakefriend,项目名称:download,代码行数:31,代码来源:index.php

示例6: flash

 public function flash($key, $value)
 {
     parent::flash($key, $value);
     return $this;
 }
开发者ID:suryakencana,项目名称:tekkadan,代码行数:5,代码来源:Zi.php

示例7: strtolower

    $username = $app->request->post('username');
    if ($username) {
        // lower case the username.
        $username = strtolower(trim($username));
        // see if there's already a User node with this username
        $checkuser = UserService::getByUsername($username);
        // No? then save it
        if (is_null($checkuser)) {
            // setup the object
            $user = new User();
            $user->username = $username;
            // save it
            UserService::save($user);
            // Authenticate user
            $_SESSION['username'] = $username;
            $app->flash('joinSuccess', true);
            $app->redirect($app->urlFor('social-graph'));
        } else {
            // show the "try again" message.
            $app->render('home/index.mustache', array('error' => 'The username "' . $username . '" already exists. Please try again.'));
        }
    } else {
        // username field was empty
        $app->render('home/index.mustache', array('error' => 'Please enter a username.'));
    }
});
// social - edit a user
$app->put('/user/edit', function () use($app) {
    $params = json_decode($app->request->getBody());
    $user = UserService::getByUsername($_SESSION['username']);
    $user->firstname = $params->firstname;
开发者ID:graphstory,项目名称:graph-kit-php,代码行数:31,代码来源:app.php


注:本文中的Slim\Slim::flash方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。