Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include_once "$_SERVER[DOCUMENT_ROOT]/core/loader.php";
- $router->get('/', function () use ($user) {
- if ($user) {
- echo 'index page<pre>';
- print_r($user);
- } else {
- header("Location: /auth");
- }
- });
- $router->mount('/reports', function () use ($router) {
- $router->get('/', function () {
- echo 'reports overview';
- });
- $router->get('/{id}', function ($id) {
- echo 'report id ' . htmlentities($id);
- });
- $router->post('/new', function () {
- echo 'add report';
- print_r($_POST);
- });
- });
- $router->mount('/auth', function () use ($router,$url,$fsite_google,$auth,$user) {
- $router->get('/', function () use ($url, $fsite_google,$user) {
- $title = 'Авторизация';
- if ($user) {
- echo "Вы уже авторизованы";
- } else {
- include_once "$_SERVER[DOCUMENT_ROOT]/style/auth_form.tpl";
- $_SESSION['error_auth'] = '';
- }
- });
- $router->post('/', function () use ($auth) {
- if ($auth->check($_POST, $_SERVER['REMOTE_ADDR'])) {
- header("Location: /");
- } else {
- $_SESSION['error_auth'] = 'Не правильный пароль';
- header("Location: /auth");
- }
- });
- $router->get('/logout', function () {
- session_unset();
- header("Location: /");
- });
- });
- $router->run();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement