mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-04-04 06:35:40 -04:00
Show the version number during update process.
Number is stored inside the data/last_update.txt file and shown if there is an update script. See https://github.com/FreshRSS/FreshRSS/issues/699
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
class FreshRSS_update_Controller extends Minz_ActionController {
|
||||
|
||||
public function firstAction() {
|
||||
$current_user = Minz_Session::param('currentUser', '');
|
||||
if (!FreshRSS_Auth::hasAccess('admin')) {
|
||||
Minz_Error::error(403);
|
||||
}
|
||||
@@ -12,8 +12,8 @@ class FreshRSS_update_Controller extends Minz_ActionController {
|
||||
$this->view->update_to_apply = false;
|
||||
$this->view->last_update_time = 'unknown';
|
||||
$this->view->check_last_hour = false;
|
||||
$timestamp = (int)@file_get_contents(DATA_PATH . '/last_update.txt');
|
||||
if (is_numeric($timestamp) && $timestamp > 0) {
|
||||
$timestamp = @filemtime(join_path(DATA_PATH, 'last_update.txt'));
|
||||
if ($timestamp !== false) {
|
||||
$this->view->last_update_time = timestamptodate($timestamp);
|
||||
$this->view->check_last_hour = (time() - 3600) <= $timestamp;
|
||||
}
|
||||
@@ -30,11 +30,12 @@ class FreshRSS_update_Controller extends Minz_ActionController {
|
||||
);
|
||||
} elseif (file_exists(UPDATE_FILENAME)) {
|
||||
// There is an update file to apply!
|
||||
$version = file_get_contents(join_path(DATA_PATH, 'last_update.txt'));
|
||||
$this->view->update_to_apply = true;
|
||||
$this->view->message = array(
|
||||
'status' => 'good',
|
||||
'title' => _t('gen.short.ok'),
|
||||
'body' => _t('feedback.update.can_apply')
|
||||
'body' => _t('feedback.update.can_apply', $version)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -82,13 +83,17 @@ class FreshRSS_update_Controller extends Minz_ActionController {
|
||||
'body' => _t('feedback.update.none')
|
||||
);
|
||||
|
||||
@file_put_contents(DATA_PATH . '/last_update.txt', time());
|
||||
@touch(join_path(DATA_PATH, 'last_update.txt'));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$script = $res_array[1];
|
||||
if (file_put_contents(UPDATE_FILENAME, $script) !== false) {
|
||||
$version = explode(' ', $status, 2);
|
||||
$version = $version[1];
|
||||
@file_put_contents(join_path(DATA_PATH, 'last_update.txt'), $version);
|
||||
|
||||
Minz_Request::forward(array('c' => 'update'));
|
||||
} else {
|
||||
$this->view->message = array(
|
||||
@@ -111,7 +116,7 @@ class FreshRSS_update_Controller extends Minz_ActionController {
|
||||
|
||||
if ($res === true) {
|
||||
@unlink(UPDATE_FILENAME);
|
||||
@file_put_contents(DATA_PATH . '/last_update.txt', time());
|
||||
@file_put_contents(join_path(DATA_PATH, 'last_update.txt'), '');
|
||||
Minz_Request::good(_t('feedback.update.finished'));
|
||||
} else {
|
||||
Minz_Request::bad(_t('feedback.update.error', $res),
|
||||
|
||||
Reference in New Issue
Block a user