예제 #1
0
    $feed_id = Request\int_param('feed_id', 0);
    Model\Item\set_read($id);
    Response\Redirect('?action=' . $redirect . '&offset=' . $offset . '&feed_id=' . $feed_id . '#item-' . $id);
});
// Mark item as unread and redirect to the listing page
Router\get_action('mark-item-unread', function () {
    $id = Request\param('id');
    $redirect = Request\param('redirect', 'history');
    $offset = Request\int_param('offset', 0);
    $feed_id = Request\int_param('feed_id', 0);
    Model\Item\set_unread($id);
    Response\Redirect('?action=' . $redirect . '&offset=' . $offset . '&feed_id=' . $feed_id . '#item-' . $id);
});
// Mark item as removed and redirect to the listing page
Router\get_action('mark-item-removed', function () {
    $id = Request\param('id');
    $redirect = Request\param('redirect', 'history');
    $offset = Request\int_param('offset', 0);
    $feed_id = Request\int_param('feed_id', 0);
    Model\Item\set_removed($id);
    Response\Redirect('?action=' . $redirect . '&offset=' . $offset . '&feed_id=' . $feed_id);
});
Router\post_action('latest-feeds-items', function () {
    $items = Model\Item\get_latest_feeds_items();
    $nb_unread_items = Model\Item\count_by_status('unread');
    $feeds = array_reduce($items, function ($result, $item) {
        $result[$item['id']] = array('time' => $item['updated'] ?: 0, 'status' => $item['status']);
        return $result;
    }, array());
    Response\json(array('feeds' => $feeds, 'nbUnread' => $nb_unread_items));
});
예제 #2
0
파일: config.php 프로젝트: elais/miniflux
Router\get_action('generate-tokens', function () {
    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)) {
예제 #3
0
        Response\Redirect('?action=show&menu=' . $menu . '&id=' . $id);
    }
    Response\Redirect('?action=' . $menu . '&offset=' . $offset . '&feed_id=' . $feed_id . '#item-' . $id);
});
// Display bookmarks page
Router\get_action('bookmarks', function () {
    $offset = Request\int_param('offset', 0);
    $nb_items = Model\Item\count_bookmarks();
    $items = Model\Item\get_bookmarks($offset, Model\Config\get('items_per_page'));
    Response\html(Template\layout('bookmarks', array('favicons' => Model\Feed\get_item_favicons($items), 'original_marks_read' => Model\Config\get('original_marks_read'), 'order' => '', 'direction' => '', 'display_mode' => Model\Config\get('items_display_mode'), 'items' => $items, 'nb_items' => $nb_items, 'offset' => $offset, 'items_per_page' => Model\Config\get('items_per_page'), 'nothing_to_read' => Request\int_param('nothing_to_read'), 'nb_unread_items' => Model\Item\count_by_status('unread'), 'menu' => 'bookmarks', 'title' => t('Bookmarks') . ' (' . $nb_items . ')')));
});
// Display bookmark feeds
Router\get_action('bookmark-feed', function () {
    // Check token
    $feed_token = Model\Config\get('feed_token');
    $request_token = Request\param('token');
    if ($feed_token !== $request_token) {
        Response\text('Access Forbidden', 403);
    }
    // Build Feed
    $writer = new Atom();
    $writer->title = t('Bookmarks') . ' - Miniflux';
    $writer->site_url = Helper\get_current_base_url();
    $writer->feed_url = $writer->site_url . '?action=bookmark-feed&token=' . urlencode($feed_token);
    $bookmarks = Model\Item\get_bookmarks();
    foreach ($bookmarks as $bookmark) {
        $article = Model\Item\get($bookmark['id']);
        $writer->items[] = array('id' => $article['id'], 'title' => $article['title'], 'updated' => $article['updated'], 'url' => $article['url'], 'content' => $article['content']);
    }
    Response\xml($writer->execute());
});
예제 #4
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;
});