aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-08-12 20:15:46 +0200
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-08-12 20:15:46 +0200
commit909d8747ba09f9c9a6ac895f1f4f0763bdb27a55 (patch)
treed3b848870d6c3721716057e215ebaf93271dd52c
parent1e71e672501f1d57a3d13cc7cb185f65a28c7b1d (diff)
Update system now uses HTTPS connection
- Add some curl checks - Refactor code
-rw-r--r--app/Controllers/updateController.php60
-rw-r--r--constants.php2
2 files changed, 33 insertions, 29 deletions
diff --git a/app/Controllers/updateController.php b/app/Controllers/updateController.php
index fa62f4a70..857d975b2 100644
--- a/app/Controllers/updateController.php
+++ b/app/Controllers/updateController.php
@@ -44,43 +44,47 @@ class FreshRSS_update_Controller extends Minz_ActionController {
$c = curl_init(FRESHRSS_UPDATE_WEBSITE);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($c, CURLOPT_SSL_VERIFYPEER, true);
+ curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 2);
$result = curl_exec($c);
+ $c_status = curl_getinfo($c, CURLINFO_HTTP_CODE);
+ curl_close($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', 'Cannot save the update script')
- );
- }
- } else {
- $this->view->message = array(
- 'status' => 'bad',
- 'title' => _t('damn'),
- 'body' => _t('no_update')
- );
- }
- } else {
+ if ($c_status !== 200) {
$this->view->message = array(
'status' => 'bad',
'title' => _t('damn'),
'body' => _t('update_server_not_found', FRESHRSS_UPDATE_WEBSITE)
);
+ return;
}
- curl_close($c);
+ $res_array = explode("\n", $result, 2);
+ $status = $res_array[0];
+ if (strpos($status, 'UPDATE') !== 0) {
+ $this->view->message = array(
+ 'status' => 'bad',
+ 'title' => _t('damn'),
+ 'body' => _t('no_update')
+ );
+
+ return;
+ }
+
+ $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', 'Cannot save the update script')
+ );
+ }
}
public function applyAction() {
diff --git a/constants.php b/constants.php
index a968b82f4..ba9c508dc 100644
--- a/constants.php
+++ b/constants.php
@@ -1,7 +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);
+define('FRESHRSS_UPDATE_WEBSITE', 'https://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);