Exemple #1
0
    if (Model\Config\check_csrf(Request\param('csrf'))) {
        Model\Config\new_tokens();
    }
    Response\redirect('?action=config');
});
// Optimize the database manually
Router\get_action('optimize-db', function () {
    if (Model\Config\check_csrf(Request\param('csrf'))) {
        Database::getInstance('db')->getConnection()->exec('VACUUM');
    }
    Response\redirect('?action=database');
});
// Download the compressed database
Router\get_action('download-db', function () {
    if (Model\Config\check_csrf(Request\param('csrf'))) {
        Response\force_download('db.sqlite.gz');
        Response\binary(gzencode(file_get_contents(Model\Database\get_path())));
    }
});
// Display preferences page
Router\get_action('config', function () {
    Response\html(Template\layout('config', array('errors' => array(), 'values' => Model\Config\get_all() + array('csrf' => Model\Config\generate_csrf()), 'languages' => Model\Config\get_languages(), 'timezones' => Model\Config\get_timezones(), 'autoflush_read_options' => Model\Config\get_autoflush_read_options(), 'autoflush_unread_options' => Model\Config\get_autoflush_unread_options(), 'paging_options' => Model\Config\get_paging_options(), 'theme_options' => Model\Config\get_themes(), 'sorting_options' => Model\Config\get_sorting_directions(), 'display_mode' => Model\Config\get_display_mode(), 'redirect_nothing_to_read_options' => Model\Config\get_nothing_to_read_redirections(), 'nb_unread_items' => Model\Item\count_by_status('unread'), 'menu' => 'config', 'title' => t('Preferences'))));
});
// Update preferences
Router\post_action('config', function () {
    $values = Request\values() + array('nocontent' => 0, 'image_proxy' => 0, 'favicons' => 0, 'debug_mode' => 0, 'original_marks_read' => 0);
    Model\Config\check_csrf_values($values);
    list($valid, $errors) = Model\Config\validate_modification($values);
    if ($valid) {
        if (Model\Config\save($values)) {
            Session\flash(t('Your preferences are updated.'));
Exemple #2
0
    }
    Model\Config\write_debug();
    if (isset($feed_id) && $feed_id !== false) {
        Session\flash(t('Subscription added successfully.'));
        Response\redirect('?action=feed-items&feed_id=' . $feed_id);
    } else {
        if (!isset($error_message)) {
            $error_message = t('Error occured.');
        }
        Session\flash_error($error_message);
    }
    Response\html(Template\layout('add', array('values' => $values + array('csrf' => Model\Config\generate_csrf()), 'nb_unread_items' => Model\Item\count_by_status('unread'), 'groups' => Model\Group\get_all(), 'menu' => 'feeds', 'title' => t('Subscriptions'))));
});
// OPML export
Router\get_action('export', function () {
    Response\force_download('feeds.opml');
    Response\xml(Model\Feed\export_opml());
});
// OPML import form
Router\get_action('import', function () {
    Response\html(Template\layout('import', array('errors' => array(), 'nb_unread_items' => Model\Item\count_by_status('unread'), 'menu' => 'feeds', 'title' => t('OPML Import'))));
});
// OPML importation
Router\post_action('import', function () {
    if (Model\Feed\import_opml(Request\file_content('file'))) {
        Session\flash(t('Your feeds have been imported.'));
        Response\redirect('?action=feeds');
    } else {
        Session\flash_error(t('Unable to import your OPML file.'));
        Response\redirect('?action=import');
    }