mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-04-04 22:53:27 -04:00
Add basic system of update
- Check on update.freshrss.org for new updates - Download script - Apply script - Need translations and verifications NOTE: current script on server indicates version 0.7.3 is an update of 0.8-dev ==> IT'S ONLY FOR MY TESTS! Script just does a backup of ./data actually... See https://github.com/marienfressinaud/FreshRSS/issues/411
This commit is contained in:
106
app/Controllers/updateController.php
Normal file
106
app/Controllers/updateController.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
class FreshRSS_update_Controller extends Minz_ActionController {
|
||||
public function firstAction() {
|
||||
$current_user = Minz_Session::param('currentUser', '');
|
||||
if (!$this->view->loginOk && Minz_Configuration::isAdmin($current_user)) {
|
||||
Minz_Error::error(
|
||||
403,
|
||||
array('error' => array(_t('access_denied')))
|
||||
);
|
||||
}
|
||||
|
||||
Minz_View::prependTitle(_t('update_system') . ' · ');
|
||||
}
|
||||
|
||||
public function indexAction() {
|
||||
if (file_exists(UPDATE_FILENAME)) {
|
||||
// There is an update file to apply!
|
||||
$this->view->message = array(
|
||||
'status' => 'good',
|
||||
'title' => _t('ok'),
|
||||
'body' => _t('update_can_apply', _url('update', 'apply'))
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public function checkAction() {
|
||||
$this->view->change_view('update', 'index');
|
||||
|
||||
if (file_exists(UPDATE_FILENAME)) {
|
||||
// There is already an update file to apply: we don't need to check
|
||||
// the webserver!
|
||||
$this->view->message = array(
|
||||
'status' => 'good',
|
||||
'title' => _t('ok'),
|
||||
'body' => _t('update_can_apply', _url('update', 'apply'))
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$c = curl_init(FRESHRSS_UPDATE_WEBSITE);
|
||||
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
|
||||
$result = curl_exec($c);
|
||||
|
||||
if (curl_getinfo($c, CURLINFO_HTTP_CODE) == 200) {
|
||||
$res_array = explode("\n", $result, 2);
|
||||
$status = $res_array[0];
|
||||
|
||||
if (strpos($status, 'UPDATE') === 0) {
|
||||
$script = $res_array[1];
|
||||
if (file_put_contents(UPDATE_FILENAME, $script) !== false) {
|
||||
$this->view->message = array(
|
||||
'status' => 'good',
|
||||
'title' => _t('ok'),
|
||||
'body' => _t('update_can_apply', _url('update', 'apply'))
|
||||
);
|
||||
} else {
|
||||
$this->view->message = array(
|
||||
'status' => 'bad',
|
||||
'title' => _t('damn'),
|
||||
'body' => _t('update_problem')
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$this->view->message = array(
|
||||
'status' => 'bad',
|
||||
'title' => _t('damn'),
|
||||
'body' => _t('no_update')
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$this->view->message = array(
|
||||
'status' => 'bad',
|
||||
'title' => _t('damn'),
|
||||
'body' => _t('update_server_not_found', FRESHRSS_UPDATE_WEBSITE)
|
||||
);
|
||||
}
|
||||
curl_close($c);
|
||||
}
|
||||
|
||||
public function applyAction() {
|
||||
require(UPDATE_FILENAME);
|
||||
$res = apply_update();
|
||||
|
||||
if ($res === true) {
|
||||
@unlink(UPDATE_FILENAME);
|
||||
|
||||
Minz_Session::_param('notification', array(
|
||||
'type' => 'good',
|
||||
'content' => Minz_Translate::t('update_finished')
|
||||
));
|
||||
|
||||
Minz_Request::forward(array(), true);
|
||||
} else {
|
||||
Minz_Session::_param('notification', array(
|
||||
'type' => 'bad',
|
||||
'content' => Minz_Translate::t('update_failed', $res)
|
||||
));
|
||||
|
||||
Minz_Request::forward(array('c' => 'update'), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -408,4 +408,6 @@ return array (
|
||||
'stats_entry_per_category' => 'Entries per category',
|
||||
'stats_top_feed' => 'Top ten feeds',
|
||||
'stats_entry_count' => 'Entry count',
|
||||
|
||||
'update_can_apply' => 'There is an available update. <a class="btn" href="%s">Apply</a>',
|
||||
);
|
||||
|
||||
@@ -408,4 +408,6 @@ return array (
|
||||
'stats_entry_per_category' => 'Articles par catégorie',
|
||||
'stats_top_feed' => 'Les dix plus gros flux',
|
||||
'stats_entry_count' => 'Nombre d’articles',
|
||||
|
||||
'update_can_apply' => 'Il y’a une mise à jour à appliquer. <a class="btn" href="%s">Appliquer</a>',
|
||||
);
|
||||
|
||||
@@ -1,25 +1,33 @@
|
||||
<ul class="nav nav-list aside">
|
||||
<li class="nav-header"><?php echo Minz_Translate::t ('configuration'); ?></li>
|
||||
<li class="item<?php echo Minz_Request::actionName () == 'display' ? ' active' : ''; ?>">
|
||||
<a href="<?php echo _url ('configure', 'display'); ?>"><?php echo Minz_Translate::t ('display_configuration'); ?></a>
|
||||
<li class="nav-header"><?php echo _t('configuration'); ?></li>
|
||||
<li class="item<?php echo Minz_Request::actionName() == 'display' ? ' active' : ''; ?>">
|
||||
<a href="<?php echo _url('configure', 'display'); ?>"><?php echo _t('display_configuration'); ?></a>
|
||||
</li>
|
||||
<li class="item<?php echo Minz_Request::actionName () == 'reading' ? ' active' : ''; ?>">
|
||||
<a href="<?php echo _url ('configure', 'reading'); ?>"><?php echo Minz_Translate::t ('reading_configuration'); ?></a>
|
||||
<li class="item<?php echo Minz_Request::actionName() == 'reading' ? ' active' : ''; ?>">
|
||||
<a href="<?php echo _url('configure', 'reading'); ?>"><?php echo _t('reading_configuration'); ?></a>
|
||||
</li>
|
||||
<li class="item<?php echo Minz_Request::actionName () == 'archiving' ? ' active' : ''; ?>">
|
||||
<a href="<?php echo _url ('configure', 'archiving'); ?>"><?php echo Minz_Translate::t ('archiving_configuration'); ?></a>
|
||||
<li class="item<?php echo Minz_Request::actionName() == 'archiving' ? ' active' : ''; ?>">
|
||||
<a href="<?php echo _url('configure', 'archiving'); ?>"><?php echo _t('archiving_configuration'); ?></a>
|
||||
</li>
|
||||
<li class="item<?php echo Minz_Request::actionName () == 'sharing' ? ' active' : ''; ?>">
|
||||
<a href="<?php echo _url ('configure', 'sharing'); ?>"><?php echo Minz_Translate::t ('sharing'); ?></a>
|
||||
<li class="item<?php echo Minz_Request::actionName() == 'sharing' ? ' active' : ''; ?>">
|
||||
<a href="<?php echo _url('configure', 'sharing'); ?>"><?php echo _t('sharing'); ?></a>
|
||||
</li>
|
||||
<li class="item<?php echo Minz_Request::actionName () == 'shortcut' ? ' active' : ''; ?>">
|
||||
<a href="<?php echo _url ('configure', 'shortcut'); ?>"><?php echo Minz_Translate::t ('shortcuts'); ?></a>
|
||||
<li class="item<?php echo Minz_Request::actionName() == 'shortcut' ? ' active' : ''; ?>">
|
||||
<a href="<?php echo _url('configure', 'shortcut'); ?>"><?php echo _t('shortcuts'); ?></a>
|
||||
</li>
|
||||
<li class="item<?php echo Minz_Request::actionName () == 'queries' ? ' active' : ''; ?>">
|
||||
<a href="<?php echo _url ('configure', 'queries'); ?>"><?php echo Minz_Translate::t ('queries'); ?></a>
|
||||
<li class="item<?php echo Minz_Request::actionName() == 'queries' ? ' active' : ''; ?>">
|
||||
<a href="<?php echo _url('configure', 'queries'); ?>"><?php echo _t('queries'); ?></a>
|
||||
</li>
|
||||
<li class="separator"></li>
|
||||
<li class="item<?php echo Minz_Request::actionName () == 'users' ? ' active' : ''; ?>">
|
||||
<a href="<?php echo _url ('configure', 'users'); ?>"><?php echo Minz_Translate::t ('users'); ?></a>
|
||||
<li class="item<?php echo Minz_Request::actionName() == 'users' ? ' active' : ''; ?>">
|
||||
<a href="<?php echo _url('configure', 'users'); ?>"><?php echo _t('users'); ?></a>
|
||||
</li>
|
||||
<?php
|
||||
$current_user = Minz_Session::param('currentUser', '');
|
||||
if (Minz_Configuration::isAdmin($current_user)) {
|
||||
?>
|
||||
<li class="item<?php echo Minz_Request::controllerName() == 'update' ? ' active' : ''; ?>">
|
||||
<a href="<?php echo _url('update', 'index'); ?>"><?php echo _t('update'); ?></a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
|
||||
@@ -75,6 +75,12 @@ if (Minz_Configuration::canLogIn()) {
|
||||
<li class="item"><a href="<?php echo _url('configure', 'queries'); ?>"><?php echo _t('queries'); ?></a></li>
|
||||
<li class="separator"></li>
|
||||
<li class="item"><a href="<?php echo _url('configure', 'users'); ?>"><?php echo _t('users'); ?></a></li>
|
||||
<?php
|
||||
$current_user = Minz_Session::param('currentUser', '');
|
||||
if (Minz_Configuration::isAdmin($current_user)) {
|
||||
?>
|
||||
<li class="item"><a href="<?php echo _url('update', 'index'); ?>"><?php echo _t('update'); ?></a></li>
|
||||
<?php } ?>
|
||||
<li class="separator"></li>
|
||||
<li class="item"><a href="<?php echo _url('stats', 'index'); ?>"><?php echo _t('stats'); ?></a></li>
|
||||
<li class="item"><a href="<?php echo _url('index', 'logs'); ?>"><?php echo _t('logs'); ?></a></li>
|
||||
|
||||
19
app/views/update/index.phtml
Normal file
19
app/views/update/index.phtml
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php $this->partial('aside_configure'); ?>
|
||||
|
||||
<div class="post">
|
||||
<h1><?php echo _t('update_system'); ?></h1>
|
||||
|
||||
<?php if (!empty($this->message)) { ?>
|
||||
<p class="alert <?php echo $this->message['status'] === 'bad' ? 'alert-error' : 'alert-warn'; ?>">
|
||||
<span class="alert-head"><?php echo $this->message['title']; ?></span>
|
||||
<?php echo $this->message['body']; ?>
|
||||
</p>
|
||||
<?php } ?>
|
||||
|
||||
<?php if (empty($this->message) || $this->message['status'] !== 'good') { ?>
|
||||
<p>
|
||||
<a href="<?php echo _url('update', 'check'); ?>" class="btn"><?php echo _t('update_check'); ?></a>
|
||||
<?php echo _i('help'); ?> <?php echo _t('update_last', $this->last_update_time); ?>
|
||||
</p>
|
||||
<?php } ?>
|
||||
</div>
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
define('FRESHRSS_VERSION', '0.8-dev');
|
||||
define('FRESHRSS_WEBSITE', 'http://freshrss.org');
|
||||
define('FRESHRSS_UPDATE_WEBSITE', 'http://update.freshrss.org?v=' . FRESHRSS_VERSION);
|
||||
|
||||
// PHP text output compression http://php.net/ob_gzhandler (better to do it at Web server level)
|
||||
define('PHP_COMPRESSION', false);
|
||||
@@ -13,6 +14,7 @@ define('FRESHRSS_PATH', dirname(__FILE__));
|
||||
define('PUBLIC_RELATIVE', '..');
|
||||
|
||||
define('DATA_PATH', FRESHRSS_PATH . '/data');
|
||||
define('UPDATE_FILENAME', DATA_PATH . '/update.php');
|
||||
define('LOG_PATH', DATA_PATH . '/log');
|
||||
define('CACHE_PATH', DATA_PATH . '/cache');
|
||||
|
||||
|
||||
@@ -26,12 +26,19 @@ class Minz_View {
|
||||
* Détermine si on utilise un layout ou non
|
||||
*/
|
||||
public function __construct () {
|
||||
$this->change_view(Minz_Request::controllerName(),
|
||||
Minz_Request::actionName());
|
||||
self::$title = Minz_Configuration::title ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Change le fichier de vue en fonction d'un controller / action
|
||||
*/
|
||||
public function change_view($controller_name, $action_name) {
|
||||
$this->view_filename = APP_PATH
|
||||
. self::VIEWS_PATH_NAME . '/'
|
||||
. Minz_Request::controllerName () . '/'
|
||||
. Minz_Request::actionName () . '.phtml';
|
||||
|
||||
self::$title = Minz_Configuration::title ();
|
||||
. $controller_name . '/'
|
||||
. $action_name . '.phtml';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user