aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2019-01-26 16:03:29 +0100
committerGravatar GitHub <noreply@github.com> 2019-01-26 16:03:29 +0100
commit8dcdde6251ae4dfc690b1a014488df125c5e5cdc (patch)
treef5762ac9c76acf708a50534f081e558489ccad86 /lib
parentf0a359619fa2936d66a2b96dd086d4686e7405fa (diff)
parent38e8e265e0f2ead830aa12e7ef81de12599405b5 (diff)
Merge pull request #2220 from FreshRSS/dev1.13.1
FreshRSS 1.13.1
Diffstat (limited to 'lib')
-rw-r--r--lib/Minz/Configuration.php17
-rw-r--r--lib/Minz/Session.php6
-rw-r--r--lib/favicons.php1
-rw-r--r--lib/lib_install.php1
-rw-r--r--lib/lib_rss.php20
5 files changed, 25 insertions, 20 deletions
diff --git a/lib/Minz/Configuration.php b/lib/Minz/Configuration.php
index 3e486d68e..aae3accc6 100644
--- a/lib/Minz/Configuration.php
+++ b/lib/Minz/Configuration.php
@@ -27,23 +27,16 @@ class Minz_Configuration {
/**
* Parse a file and return its data.
*
- * If the file does not contain a valid PHP code returning an array, an
- * empty array is returned anyway.
- *
* @param $filename the name of the file to parse.
* @return an array of values
- * @throws Minz_FileNotExistException if the file does not exist.
+ * @throws Minz_FileNotExistException if the file does not exist or is invalid.
*/
public static function load($filename) {
- if (!file_exists($filename)) {
- throw new Minz_FileNotExistException($filename);
- }
-
- $data = include($filename);
+ $data = @include($filename);
if (is_array($data)) {
return $data;
} else {
- return array();
+ throw new Minz_FileNotExistException($filename);
}
}
@@ -117,7 +110,7 @@ class Minz_Configuration {
$this->default_filename = $default_filename;
$this->_configurationSetter($configuration_setter);
- if (!is_null($this->default_filename)) {
+ if ($this->default_filename != null) {
$this->data = self::load($this->default_filename);
}
@@ -126,7 +119,7 @@ class Minz_Configuration {
$this->data, self::load($this->config_filename)
);
} catch (Minz_FileNotExistException $e) {
- if (is_null($this->default_filename)) {
+ if ($this->default_filename == null) {
throw $e;
}
}
diff --git a/lib/Minz/Session.php b/lib/Minz/Session.php
index c94f2b646..97b15c4d0 100644
--- a/lib/Minz/Session.php
+++ b/lib/Minz/Session.php
@@ -61,7 +61,11 @@ class Minz_Session {
public static function getCookieDir() {
// Get the script_name (e.g. /p/i/index.php) and keep only the path.
- $cookie_dir = empty($_SERVER['REQUEST_URI']) ? '/' : $_SERVER['REQUEST_URI'];
+ $cookie_dir = '';
+ if (!empty($_SERVER['HTTP_X_FORWARDED_PREFIX'])) {
+ $cookie_dir .= rtrim($_SERVER['HTTP_X_FORWARDED_PREFIX'], '/ ');
+ }
+ $cookie_dir .= empty($_SERVER['REQUEST_URI']) ? '/' : $_SERVER['REQUEST_URI'];
if (substr($cookie_dir, -1) !== '/') {
$cookie_dir = dirname($cookie_dir) . '/';
}
diff --git a/lib/favicons.php b/lib/favicons.php
index fe2e65f1f..7a2d1187e 100644
--- a/lib/favicons.php
+++ b/lib/favicons.php
@@ -22,6 +22,7 @@ function isImgMime($content) {
}
function downloadHttp(&$url, $curlOptions = array()) {
+ prepareSyslog();
syslog(LOG_INFO, 'FreshRSS Favicon GET ' . $url);
if (substr($url, 0, 2) === '//') {
$url = 'https:' . $url;
diff --git a/lib/lib_install.php b/lib/lib_install.php
index d51a37e58..6e4df4e9c 100644
--- a/lib/lib_install.php
+++ b/lib/lib_install.php
@@ -81,6 +81,7 @@ function generateSalt() {
function checkDb(&$dbOptions) {
$dsn = '';
$driver_options = null;
+ prepareSyslog();
try {
switch ($dbOptions['type']) {
case 'mysql':
diff --git a/lib/lib_rss.php b/lib/lib_rss.php
index 333920c8c..89e9ddfea 100644
--- a/lib/lib_rss.php
+++ b/lib/lib_rss.php
@@ -202,12 +202,19 @@ function html_only_entity_decode($text) {
return strtr($text, $htmlEntitiesOnly);
}
+function prepareSyslog() {
+ return COPY_SYSLOG_TO_STDERR ? openlog("FreshRSS", LOG_PERROR | LOG_PID, LOG_USER) : false;
+}
+
function customSimplePie($attributes = array()) {
$system_conf = Minz_Configuration::get('system');
$limits = $system_conf->limits;
$simplePie = new SimplePie();
$simplePie->set_useragent(FRESHRSS_USERAGENT);
$simplePie->set_syslog($system_conf->simplepie_syslog_enabled);
+ if ($system_conf->simplepie_syslog_enabled) {
+ prepareSyslog();
+ }
$simplePie->set_cache_location(CACHE_PATH);
$simplePie->set_cache_duration($limits['cache_duration']);
@@ -364,9 +371,9 @@ function get_user_configuration($username) {
join_path(FRESHRSS_PATH, 'config-user.default.php'));
} catch (Minz_ConfigurationNamespaceException $e) {
// namespace already exists, do nothing.
- Minz_Log::warning($e->getMessage());
+ Minz_Log::warning($e->getMessage(), USERS_PATH . '/_/log.txt');
} catch (Minz_FileNotExistException $e) {
- Minz_Log::warning($e->getMessage());
+ Minz_Log::warning($e->getMessage(), USERS_PATH . '/_/log.txt');
return null;
}
@@ -375,14 +382,13 @@ function get_user_configuration($username) {
function httpAuthUser() {
- if (isset($_SERVER['REMOTE_USER'])) {
+ if (!empty($_SERVER['REMOTE_USER'])) {
return $_SERVER['REMOTE_USER'];
- }
-
- if (isset($_SERVER['REDIRECT_REMOTE_USER'])) {
+ } elseif (!empty($_SERVER['REDIRECT_REMOTE_USER'])) {
return $_SERVER['REDIRECT_REMOTE_USER'];
+ } elseif (!empty($_SERVER['HTTP_X_WEBAUTH_USER'])) {
+ return $_SERVER['HTTP_X_WEBAUTH_USER'];
}
-
return '';
}