|
@@ -2,7 +2,7 @@
|
|
|
|
|
|
|
|
class FreshRSS_update_Controller extends FreshRSS_ActionController {
|
|
class FreshRSS_update_Controller extends FreshRSS_ActionController {
|
|
|
|
|
|
|
|
- const LASTUPDATEFILE = 'last_update.txt';
|
|
|
|
|
|
|
+ private const LASTUPDATEFILE = 'last_update.txt';
|
|
|
|
|
|
|
|
public static function isGit(): bool {
|
|
public static function isGit(): bool {
|
|
|
return is_dir(FRESHRSS_PATH . '/.git/');
|
|
return is_dir(FRESHRSS_PATH . '/.git/');
|
|
@@ -46,8 +46,12 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController {
|
|
|
|
|
|
|
|
public static function hasGitUpdate(): bool {
|
|
public static function hasGitUpdate(): bool {
|
|
|
$cwd = getcwd();
|
|
$cwd = getcwd();
|
|
|
|
|
+ if ($cwd === false) {
|
|
|
|
|
+ Minz_Log::warning('getcwd() failed');
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
chdir(FRESHRSS_PATH);
|
|
chdir(FRESHRSS_PATH);
|
|
|
- $output = array();
|
|
|
|
|
|
|
+ $output = [];
|
|
|
try {
|
|
try {
|
|
|
exec('git fetch --prune', $output, $return);
|
|
exec('git fetch --prune', $output, $return);
|
|
|
if ($return == 0) {
|
|
if ($return == 0) {
|
|
@@ -69,6 +73,10 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController {
|
|
|
/** @return string|true */
|
|
/** @return string|true */
|
|
|
public static function gitPull() {
|
|
public static function gitPull() {
|
|
|
$cwd = getcwd();
|
|
$cwd = getcwd();
|
|
|
|
|
+ if ($cwd === false) {
|
|
|
|
|
+ Minz_Log::warning('getcwd() failed');
|
|
|
|
|
+ return 'getcwd() failed';
|
|
|
|
|
+ }
|
|
|
chdir(FRESHRSS_PATH);
|
|
chdir(FRESHRSS_PATH);
|
|
|
$output = [];
|
|
$output = [];
|
|
|
$return = 1;
|
|
$return = 1;
|
|
@@ -149,7 +157,6 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$script = '';
|
|
$script = '';
|
|
|
- $version = '';
|
|
|
|
|
|
|
|
|
|
if (self::isGit()) {
|
|
if (self::isGit()) {
|
|
|
if (self::hasGitUpdate()) {
|
|
if (self::hasGitUpdate()) {
|
|
@@ -166,18 +173,28 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController {
|
|
|
} else {
|
|
} else {
|
|
|
$auto_update_url = FreshRSS_Context::$system_conf->auto_update_url . '/?v=' . FRESHRSS_VERSION;
|
|
$auto_update_url = FreshRSS_Context::$system_conf->auto_update_url . '/?v=' . FRESHRSS_VERSION;
|
|
|
Minz_Log::debug('HTTP GET ' . $auto_update_url);
|
|
Minz_Log::debug('HTTP GET ' . $auto_update_url);
|
|
|
- $c = curl_init($auto_update_url);
|
|
|
|
|
- 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);
|
|
|
|
|
- $c_error = curl_error($c);
|
|
|
|
|
- curl_close($c);
|
|
|
|
|
-
|
|
|
|
|
- if ($c_status !== 200) {
|
|
|
|
|
|
|
+ $curlResource = curl_init($auto_update_url);
|
|
|
|
|
+
|
|
|
|
|
+ if ($curlResource === false) {
|
|
|
|
|
+ Minz_Log::warning('curl_init() failed');
|
|
|
|
|
+ $this->view->message = [
|
|
|
|
|
+ 'status' => 'bad',
|
|
|
|
|
+ 'title' => _t('gen.short.damn'),
|
|
|
|
|
+ 'body' => _t('feedback.update.server_not_found', $auto_update_url)
|
|
|
|
|
+ ];
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ curl_setopt($curlResource, CURLOPT_RETURNTRANSFER, true);
|
|
|
|
|
+ curl_setopt($curlResource, CURLOPT_SSL_VERIFYPEER, true);
|
|
|
|
|
+ curl_setopt($curlResource, CURLOPT_SSL_VERIFYHOST, 2);
|
|
|
|
|
+ $result = curl_exec($curlResource);
|
|
|
|
|
+ $curlGetinfo = curl_getinfo($curlResource, CURLINFO_HTTP_CODE);
|
|
|
|
|
+ $curlError = curl_error($curlResource);
|
|
|
|
|
+ curl_close($curlResource);
|
|
|
|
|
+
|
|
|
|
|
+ if ($curlGetinfo !== 200) {
|
|
|
Minz_Log::warning(
|
|
Minz_Log::warning(
|
|
|
- 'Error during update (HTTP code ' . $c_status . '): ' . $c_error
|
|
|
|
|
|
|
+ 'Error during update (HTTP code ' . $curlGetinfo . '): ' . $curlError
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
$this->view->message = array(
|
|
$this->view->message = array(
|
|
@@ -188,7 +205,7 @@ class FreshRSS_update_Controller extends FreshRSS_ActionController {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $res_array = explode("\n", $result, 2);
|
|
|
|
|
|
|
+ $res_array = explode("\n", (string)$result, 2);
|
|
|
$status = $res_array[0];
|
|
$status = $res_array[0];
|
|
|
if (strpos($status, 'UPDATE') !== 0) {
|
|
if (strpos($status, 'UPDATE') !== 0) {
|
|
|
$this->view->message = array(
|
|
$this->view->message = array(
|