Beispiel #1
0
        }
    } elseif (Model\RememberMe\has_cookie()) {
        Model\RememberMe\refresh();
    }
    // Load translations
    $language = Model\Config\get('language') ?: 'en_US';
    Translator\load($language);
    // Set timezone
    date_default_timezone_set(Model\Config\get('timezone') ?: 'UTC');
    // HTTP secure headers
    Response\csp(array('media-src' => '*', 'img-src' => '*', 'frame-src' => Model\Config\get_iframe_whitelist(), 'referrer' => 'no-referrer'));
    Response\xframe();
    Response\xss();
    Response\nosniff();
    if (ENABLE_HSTS && Helper\is_secure_connection()) {
        Response\hsts();
    }
});
// Show help
Router\get_action('show-help', function () {
    Response\html(Template\load('show_help'));
});
// Show the menu for the mobile view
Router\get_action('more', function () {
    Response\html(Template\layout('show_more', array('menu' => 'more')));
});
// Image proxy (avoid SSL mixed content warnings)
Router\get_action('proxy', function () {
    Model\Proxy\download(rawurldecode(Request\param('url')));
    exit;
});
Beispiel #2
0
<?php

use PicoFarad\Router;
use PicoFarad\Response;
use PicoFarad\Request;
use PicoFarad\Template;
// Logout and destroy session
Router\get_action('logout', function () {
    Model\User\logout();
    Response\redirect('?action=login');
});
// Display form login
Router\get_action('login', function () {
    if (Model\User\is_loggedin()) {
        Response\redirect('?action=unread');
    }
    Response\html(Template\load('login', array('errors' => array(), 'values' => array('csrf' => Model\Config\generate_csrf()), 'databases' => Model\Database\get_list(), 'current_database' => Model\Database\select())));
});
// Check credentials and redirect to unread items
Router\post_action('login', function () {
    $values = Request\values();
    Model\Config\check_csrf_values($values);
    list($valid, $errors) = Model\User\validate_login($values);
    if ($valid) {
        Response\redirect('?action=unread');
    }
    Response\html(Template\load('login', array('errors' => $errors, 'values' => $values + array('csrf' => Model\Config\generate_csrf()), 'databases' => Model\Database\get_list(), 'current_database' => Model\Database\select())));
});