|
|
|
@ -3,7 +3,7 @@ |
|
|
|
|
use PicoDb\Database; |
|
|
|
|
|
|
|
|
|
// Display a form to add a new database |
|
|
|
|
Router\get_action('new-db', function() { |
|
|
|
|
Router\get_action('new-db', function () { |
|
|
|
|
if (ENABLE_MULTIPLE_DB) { |
|
|
|
|
Response\html(Template\layout('new_db', array( |
|
|
|
|
'errors' => array(), |
|
|
|
@ -20,18 +20,16 @@ Router\get_action('new-db', function() { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// Create a new database |
|
|
|
|
Router\post_action('new-db', function() { |
|
|
|
|
Router\post_action('new-db', function () { |
|
|
|
|
if (ENABLE_MULTIPLE_DB) { |
|
|
|
|
$values = Request\values(); |
|
|
|
|
Model\Config\check_csrf_values($values); |
|
|
|
|
list($valid, $errors) = Model\Database\validate($values); |
|
|
|
|
|
|
|
|
|
if ($valid) { |
|
|
|
|
|
|
|
|
|
if (Model\Database\create(strtolower($values['name']).'.sqlite', $values['username'], $values['password'])) { |
|
|
|
|
Session\flash(t('Database created successfully.')); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
} else { |
|
|
|
|
Session\flash_error(t('Unable to create the new database.')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -51,7 +49,7 @@ Router\post_action('new-db', function() { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// Confirmation box before auto-update |
|
|
|
|
Router\get_action('confirm-auto-update', function() { |
|
|
|
|
Router\get_action('confirm-auto-update', function () { |
|
|
|
|
Response\html(Template\layout('confirm_auto_update', array( |
|
|
|
|
'nb_unread_items' => Model\Item\count_by_status('unread'), |
|
|
|
|
'menu' => 'config', |
|
|
|
@ -60,7 +58,7 @@ Router\get_action('confirm-auto-update', function() { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// Auto-update |
|
|
|
|
Router\get_action('auto-update', function() { |
|
|
|
|
Router\get_action('auto-update', function () { |
|
|
|
|
if (ENABLE_AUTO_UPDATE) { |
|
|
|
|
if (Model\AutoUpdate\execute(Model\Config\get('auto_update_url'))) { |
|
|
|
|
Session\flash(t('Miniflux is updated!')); |
|
|
|
@ -73,7 +71,7 @@ Router\get_action('auto-update', function() { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// Re-generate tokens |
|
|
|
|
Router\get_action('generate-tokens', function() { |
|
|
|
|
Router\get_action('generate-tokens', function () { |
|
|
|
|
if (Model\Config\check_csrf(Request\param('csrf'))) { |
|
|
|
|
Model\Config\new_tokens(); |
|
|
|
|
} |
|
|
|
@ -82,7 +80,7 @@ Router\get_action('generate-tokens', function() { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// Optimize the database manually |
|
|
|
|
Router\get_action('optimize-db', function() { |
|
|
|
|
Router\get_action('optimize-db', function () { |
|
|
|
|
if (Model\Config\check_csrf(Request\param('csrf'))) { |
|
|
|
|
Database::getInstance('db')->getConnection()->exec('VACUUM'); |
|
|
|
|
} |
|
|
|
@ -91,7 +89,7 @@ Router\get_action('optimize-db', function() { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// Download the compressed database |
|
|
|
|
Router\get_action('download-db', function() { |
|
|
|
|
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()))); |
|
|
|
@ -99,7 +97,7 @@ Router\get_action('download-db', function() { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// Display preferences page |
|
|
|
|
Router\get_action('config', function() { |
|
|
|
|
Router\get_action('config', function () { |
|
|
|
|
Response\html(Template\layout('config', array( |
|
|
|
|
'errors' => array(), |
|
|
|
|
'values' => Model\Config\get_all() + array('csrf' => Model\Config\generate_csrf()), |
|
|
|
@ -120,17 +118,15 @@ Router\get_action('config', function() { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// Update preferences |
|
|
|
|
Router\post_action('config', function() { |
|
|
|
|
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.')); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
} else { |
|
|
|
|
Session\flash_error(t('Unable to update your preferences.')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -157,14 +153,13 @@ Router\post_action('config', function() { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// Get configuration parameters (AJAX request) |
|
|
|
|
Router\post_action('get-config', function() { |
|
|
|
|
Router\post_action('get-config', function () { |
|
|
|
|
$return = array(); |
|
|
|
|
$options = Request\values(); |
|
|
|
|
|
|
|
|
|
if (empty($options)) { |
|
|
|
|
$return = Model\Config\get_all(); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
} else { |
|
|
|
|
foreach ($options as $name) { |
|
|
|
|
$return[$name] = Model\Config\get($name); |
|
|
|
|
} |
|
|
|
@ -174,7 +169,7 @@ Router\post_action('get-config', function() { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// Display help page |
|
|
|
|
Router\get_action('help', function() { |
|
|
|
|
Router\get_action('help', function () { |
|
|
|
|
Response\html(Template\layout('help', array( |
|
|
|
|
'config' => Model\Config\get_all(), |
|
|
|
|
'nb_unread_items' => Model\Item\count_by_status('unread'), |
|
|
|
@ -184,7 +179,7 @@ Router\get_action('help', function() { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// Display about page |
|
|
|
|
Router\get_action('about', function() { |
|
|
|
|
Router\get_action('about', function () { |
|
|
|
|
Response\html(Template\layout('about', array( |
|
|
|
|
'csrf' => Model\Config\generate_csrf(), |
|
|
|
|
'config' => Model\Config\get_all(), |
|
|
|
@ -196,7 +191,7 @@ Router\get_action('about', function() { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// Display database page |
|
|
|
|
Router\get_action('database', function() { |
|
|
|
|
Router\get_action('database', function () { |
|
|
|
|
Response\html(Template\layout('database', array( |
|
|
|
|
'csrf' => Model\Config\generate_csrf(), |
|
|
|
|
'config' => Model\Config\get_all(), |
|
|
|
@ -208,7 +203,7 @@ Router\get_action('database', function() { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// Display API page |
|
|
|
|
Router\get_action('api', function() { |
|
|
|
|
Router\get_action('api', function () { |
|
|
|
|
Response\html(Template\layout('api', array( |
|
|
|
|
'config' => Model\Config\get_all(), |
|
|
|
|
'nb_unread_items' => Model\Item\count_by_status('unread'), |
|
|
|
@ -218,7 +213,7 @@ Router\get_action('api', function() { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// Display bookmark services page |
|
|
|
|
Router\get_action('services', function() { |
|
|
|
|
Router\get_action('services', function () { |
|
|
|
|
Response\html(Template\layout('services', array( |
|
|
|
|
'errors' => array(), |
|
|
|
|
'values' => Model\Config\get_all() + array('csrf' => Model\Config\generate_csrf()), |
|
|
|
@ -228,14 +223,13 @@ Router\get_action('services', function() { |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// Update bookmark services |
|
|
|
|
Router\post_action('services', function() { |
|
|
|
|
Router\post_action('services', function () { |
|
|
|
|
$values = Request\values() + array('pinboard_enabled' => 0, 'instapaper_enabled' => 0); |
|
|
|
|
Model\Config\check_csrf_values($values); |
|
|
|
|
|
|
|
|
|
if (Model\Config\save($values)) { |
|
|
|
|
Session\flash(t('Your preferences are updated.')); |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
} else { |
|
|
|
|
Session\flash_error(t('Unable to update your preferences.')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|