function auth() { if (!empty($_GET['database'])) { // Return unauthorized if the requested database could not be found if (!Model\Database\select($_GET['database'])) { return array('api_version' => 3, 'auth' => 0); } } $credentials = Database::get('db')->hashtable('settings')->get('username', 'fever_token'); $api_key = md5($credentials['username'] . ':' . $credentials['fever_token']); $response = array('api_version' => 3, 'auth' => (int) (@$_POST['api_key'] === $api_key), 'last_refreshed_on_time' => time()); return $response; }
function getCredentials() { return Database::get('db')->hashtable('settings')->get('username', 'password'); }
function save(array $values) { // Update the password if needed if (!empty($values['password'])) { $values['password'] = password_hash($values['password'], PASSWORD_BCRYPT); } else { unset($values['password']); } unset($values['confirmation']); // If the user does not want content of feeds, remove it in previous ones if (isset($values['nocontent']) && (bool) $values['nocontent']) { Database::get('db')->table('items')->update(array('content' => '')); } if (Database::get('db')->hashtable('settings')->put($values)) { reload(); return true; } return false; }
function disable($feed_id) { return Database::get('db')->table('feeds')->eq('id', $feed_id)->save(array('enabled' => 0)); }
function download_content_id($item_id) { $item = get($item_id); $content = download_content_url($item['url']); if (!empty($content)) { if (!Config\get('nocontent')) { // Save content Database::get('db')->table('items')->eq('id', $item['id'])->save(array('content' => $content)); } Config\write_debug(); return array('result' => true, 'content' => $content); } Config\write_debug(); return array('result' => false, 'content' => ''); }
/** * Return a new sequence token and update the database * * @access public * @param string $token Session token * @return string */ function update($token) { $new_sequence = Config\generate_token(); Database::get('db')->table(TABLE)->eq('token', $token)->update(array('sequence' => $new_sequence)); return $new_sequence; }
Session\flash_error(t('Unable to update Miniflux, check the console for errors.')); } } Response\redirect('?action=config'); }); // Re-generate tokens 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::get('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