Browse Source

Merge branch '729-move_data' into dev

To update, please follow instructions in https://github.com/FreshRSS/FreshRSS/issues/729
Marien Fressinaud 11 years ago
parent
commit
0cd975bfd0

+ 8 - 7
app/Controllers/userController.php

@@ -109,7 +109,8 @@ class FreshRSS_user_Controller extends Minz_ActionController {
 			require_once(APP_PATH . '/SQL/install.sql.' . $db['type'] . '.php');
 			require_once(APP_PATH . '/SQL/install.sql.' . $db['type'] . '.php');
 
 
 			$new_user_language = Minz_Request::param('new_user_language', FreshRSS_Context::$conf->language);
 			$new_user_language = Minz_Request::param('new_user_language', FreshRSS_Context::$conf->language);
-			if (!in_array($new_user_language, FreshRSS_Context::$conf->availableLanguages())) {
+			$languages = FreshRSS_Context::$conf->availableLanguages();
+			if (!isset($languages[$new_user_language])) {
 				$new_user_language = FreshRSS_Context::$conf->language;
 				$new_user_language = FreshRSS_Context::$conf->language;
 			}
 			}
 
 
@@ -121,11 +122,10 @@ class FreshRSS_user_Controller extends Minz_ActionController {
 
 
 				$ok &= !in_array(strtoupper($new_user_name), array_map('strtoupper', listUsers()));	//Not an existing user, case-insensitive
 				$ok &= !in_array(strtoupper($new_user_name), array_map('strtoupper', listUsers()));	//Not an existing user, case-insensitive
 
 
-				$configPath = DATA_PATH . '/' . $new_user_name . '_user.php';
+				$configPath = join_path(DATA_PATH, 'users', $new_user_name, 'config.php');
 				$ok &= !file_exists($configPath);
 				$ok &= !file_exists($configPath);
 			}
 			}
 			if ($ok) {
 			if ($ok) {
-			
 				$passwordPlain = Minz_Request::param('new_user_passwordPlain', '', true);
 				$passwordPlain = Minz_Request::param('new_user_passwordPlain', '', true);
 				$passwordHash = '';
 				$passwordHash = '';
 				if ($passwordPlain != '') {
 				if ($passwordPlain != '') {
@@ -147,12 +147,13 @@ class FreshRSS_user_Controller extends Minz_ActionController {
 				if (empty($new_user_email)) {
 				if (empty($new_user_email)) {
 					$new_user_email = '';
 					$new_user_email = '';
 				} else {
 				} else {
-					$personaFile = DATA_PATH . '/persona/' . $new_user_email . '.txt';
+					$personaFile = join_path(DATA_PATH, 'persona', $new_user_email . '.txt');
 					@unlink($personaFile);
 					@unlink($personaFile);
 					$ok &= (file_put_contents($personaFile, $new_user_name) !== false);
 					$ok &= (file_put_contents($personaFile, $new_user_name) !== false);
 				}
 				}
 			}
 			}
 			if ($ok) {
 			if ($ok) {
+				mkdir(join_path(DATA_PATH, 'users', $new_user_name));
 				$config_array = array(
 				$config_array = array(
 					'language' => $new_user_language,
 					'language' => $new_user_language,
 					'passwordHash' => $passwordHash,
 					'passwordHash' => $passwordHash,
@@ -183,18 +184,18 @@ class FreshRSS_user_Controller extends Minz_ActionController {
 
 
 			$username = Minz_Request::param('username');
 			$username = Minz_Request::param('username');
 			$ok = ctype_alnum($username);
 			$ok = ctype_alnum($username);
+			$user_data = join_path(DATA_PATH, 'users', $username);
 
 
 			if ($ok) {
 			if ($ok) {
 				$ok &= (strcasecmp($username, Minz_Configuration::defaultUser()) !== 0);	//It is forbidden to delete the default user
 				$ok &= (strcasecmp($username, Minz_Configuration::defaultUser()) !== 0);	//It is forbidden to delete the default user
 			}
 			}
 			if ($ok) {
 			if ($ok) {
-				$configPath = DATA_PATH . '/' . $username . '_user.php';
-				$ok &= file_exists($configPath);
+				$ok &= is_dir($user_data);
 			}
 			}
 			if ($ok) {
 			if ($ok) {
 				$userDAO = new FreshRSS_UserDAO();
 				$userDAO = new FreshRSS_UserDAO();
 				$ok &= $userDAO->deleteUser($username);
 				$ok &= $userDAO->deleteUser($username);
-				$ok &= unlink($configPath);
+				$ok &= recursive_unlink($user_data);
 				//TODO: delete Persona file
 				//TODO: delete Persona file
 			}
 			}
 			invalidateHttpCache();
 			invalidateHttpCache();

+ 2 - 2
app/Models/Configuration.php

@@ -74,7 +74,7 @@ class FreshRSS_Configuration {
 	private $shares;
 	private $shares;
 
 
 	public function __construct($user) {
 	public function __construct($user) {
-		$this->filename = DATA_PATH . DIRECTORY_SEPARATOR . $user . '_user.php';
+		$this->filename = join_path(DATA_PATH, 'users', $user, 'config.php');
 
 
 		$data = @include($this->filename);
 		$data = @include($this->filename);
 		if (!is_array($data)) {
 		if (!is_array($data)) {
@@ -89,7 +89,7 @@ class FreshRSS_Configuration {
 		}
 		}
 		$this->data['user'] = $user;
 		$this->data['user'] = $user;
 
 
-		$this->shares = DATA_PATH . DIRECTORY_SEPARATOR . 'shares.php';
+		$this->shares = join_path(DATA_PATH, 'shares.php');
 
 
 		$shares = @include($this->shares);
 		$shares = @include($this->shares);
 		if (!is_array($shares)) {
 		if (!is_array($shares)) {

+ 1 - 1
app/Models/EntryDAOSQLite.php

@@ -169,6 +169,6 @@ class FreshRSS_EntryDAOSQLite extends FreshRSS_EntryDAO {
 	}
 	}
 
 
 	public function size($all = false) {
 	public function size($all = false) {
-		return @filesize(DATA_PATH . '/' . $this->current_user . '.sqlite');
+		return @filesize(join_path(DATA_PATH, 'users', $this->current_user, 'db.sqlite'));
 	}
 	}
 }
 }

+ 2 - 2
app/Models/LogDAO.php

@@ -3,7 +3,7 @@
 class FreshRSS_LogDAO {
 class FreshRSS_LogDAO {
 	public static function lines() {
 	public static function lines() {
 		$logs = array();
 		$logs = array();
-		$handle = @fopen(LOG_PATH . '/' . Minz_Session::param('currentUser', '_') . '.log', 'r');
+		$handle = @fopen(join_path(DATA_PATH, 'users', Minz_Session::param('currentUser', '_'), 'log.txt'), 'r');
 		if ($handle) {
 		if ($handle) {
 			while (($line = fgets($handle)) !== false) {
 			while (($line = fgets($handle)) !== false) {
 				if (preg_match('/^\[([^\[]+)\] \[([^\[]+)\] --- (.*)$/', $line, $matches)) {
 				if (preg_match('/^\[([^\[]+)\] \[([^\[]+)\] --- (.*)$/', $line, $matches)) {
@@ -20,6 +20,6 @@ class FreshRSS_LogDAO {
 	}
 	}
 
 
 	public static function truncate() {
 	public static function truncate() {
-		file_put_contents(LOG_PATH . '/' . Minz_Session::param('currentUser', '_') . '.log', '');
+		file_put_contents(join_path(DATA_PATH, 'users', Minz_Session::param('currentUser', '_'), 'log.txt'), '');
 	}
 	}
 }
 }

+ 4 - 4
app/Models/UserDAO.php

@@ -38,7 +38,7 @@ class FreshRSS_UserDAO extends Minz_ModelPdo {
 		require_once(APP_PATH . '/SQL/install.sql.' . $db['type'] . '.php');
 		require_once(APP_PATH . '/SQL/install.sql.' . $db['type'] . '.php');
 
 
 		if ($db['type'] === 'sqlite') {
 		if ($db['type'] === 'sqlite') {
-			return unlink(DATA_PATH . '/' . $username . '.sqlite');
+			return unlink(join_path(DATA_PATH, 'users', $username, 'db.sqlite'));
 		} else {
 		} else {
 			$userPDO = new Minz_ModelPdo($username);
 			$userPDO = new Minz_ModelPdo($username);
 
 
@@ -55,14 +55,14 @@ class FreshRSS_UserDAO extends Minz_ModelPdo {
 	}
 	}
 
 
 	public static function exist($username) {
 	public static function exist($username) {
-		return file_exists(DATA_PATH . '/' . $username . '_user.php');
+		return is_dir(join_path(DATA_PATH , 'users', $username));
 	}
 	}
 
 
 	public static function touch($username) {
 	public static function touch($username) {
-		return touch(DATA_PATH . '/' . $username . '_user.php');
+		return touch(join_path(DATA_PATH , 'users', $username, 'config.php'));
 	}
 	}
 
 
 	public static function mtime($username) {
 	public static function mtime($username) {
-		return @filemtime(DATA_PATH . '/' . $username . '_user.php');
+		return @filemtime(join_path(DATA_PATH , 'users', $username, 'config.php'));
 	}
 	}
 }
 }

+ 2 - 2
app/actualize_script.php

@@ -56,9 +56,9 @@ foreach ($users as $myUser) {
 	$freshRSS->run();
 	$freshRSS->run();
 
 
 	if (!invalidateHttpCache()) {
 	if (!invalidateHttpCache()) {
-		syslog(LOG_NOTICE, 'FreshRSS write access problem in ' . LOG_PATH . '/*.log!');
+		syslog(LOG_NOTICE, 'FreshRSS write access problem in ' . USERS_PATH . '/*/log.txt!');
 		if (defined('STDERR')) {
 		if (defined('STDERR')) {
-			fwrite(STDERR, 'Write access problem in ' . LOG_PATH . '/*.log!' . "\n");
+			fwrite(STDERR, 'Write access problem in ' . USERS_PATH . '/*/log.txt!' . "\n");
 		}
 		}
 	}
 	}
 	Minz_Session::unset_session(true);
 	Minz_Session::unset_session(true);

+ 5 - 4
app/i18n/en/install.php

@@ -3,6 +3,7 @@
 return array(
 return array(
 	'action' => array(
 	'action' => array(
 		'finish' => 'Complete installation',
 		'finish' => 'Complete installation',
+		'fix_errors_before' => 'Fix errors before skip to the next step.',
 		'next_step' => 'Go to the next step',
 		'next_step' => 'Go to the next step',
 	),
 	),
 	'auth' => array(
 	'auth' => array(
@@ -57,10 +58,6 @@ return array(
 			'nok' => 'Please check that you are not altering your HTTP REFERER.',
 			'nok' => 'Please check that you are not altering your HTTP REFERER.',
 			'ok' => 'Your HTTP REFERER is known and corresponds to your server.',
 			'ok' => 'Your HTTP REFERER is known and corresponds to your server.',
 		),
 		),
-		'logs' => array(
-			'nok' => 'Check permissions on <em>./data/logs</em> directory. HTTP server must have rights to write into',
-			'ok' => 'Permissions on logs directory are good.',
-		),
 		'minz' => array(
 		'minz' => array(
 			'nok' => 'You lack the Minz framework.',
 			'nok' => 'You lack the Minz framework.',
 			'ok' => 'You have the Minz framework.',
 			'ok' => 'You have the Minz framework.',
@@ -81,6 +78,10 @@ return array(
 			'nok' => 'Your PHP version is %s but FreshRSS requires at least version %s.',
 			'nok' => 'Your PHP version is %s but FreshRSS requires at least version %s.',
 			'ok' => 'Your PHP version is %s, which is compatible with FreshRSS.',
 			'ok' => 'Your PHP version is %s, which is compatible with FreshRSS.',
 		),
 		),
+		'users' => array(
+			'nok' => 'Check permissions on <em>./data/users</em> directory. HTTP server must have rights to write into',
+			'ok' => 'Permissions on users directory are good.',
+		),
 	),
 	),
 	'conf' => array(
 	'conf' => array(
 		'_' => 'General configuration',
 		'_' => 'General configuration',

+ 5 - 4
app/i18n/fr/install.php

@@ -3,6 +3,7 @@
 return array(
 return array(
 	'action' => array(
 	'action' => array(
 		'finish' => 'Terminer l’installation',
 		'finish' => 'Terminer l’installation',
+		'fix_errors_before' => 'Veuillez corriger les erreurs avant de passer à l’étape suivante.',
 		'next_step' => 'Passer à l’étape suivante',
 		'next_step' => 'Passer à l’étape suivante',
 	),
 	),
 	'auth' => array(
 	'auth' => array(
@@ -57,10 +58,6 @@ return array(
 			'nok' => 'Veuillez vérifier que vous ne modifiez pas votre HTTP REFERER.',
 			'nok' => 'Veuillez vérifier que vous ne modifiez pas votre HTTP REFERER.',
 			'ok' => 'Le HTTP REFERER est connu et semble correspondre à votre serveur.',
 			'ok' => 'Le HTTP REFERER est connu et semble correspondre à votre serveur.',
 		),
 		),
-		'logs' => array(
-			'nok' => 'Veuillez vérifier les droits sur le répertoire <em>./data/logs</em>. Le serveur HTTP doit être capable d’écrire dedans',
-			'ok' => 'Les droits sur le répertoire des logs sont bons.',
-		),
 		'minz' => array(
 		'minz' => array(
 			'nok' => 'Vous ne disposez pas de la librairie Minz.',
 			'nok' => 'Vous ne disposez pas de la librairie Minz.',
 			'ok' => 'Vous disposez du framework Minz',
 			'ok' => 'Vous disposez du framework Minz',
@@ -81,6 +78,10 @@ return array(
 			'nok' => 'Votre version de PHP est la %s mais FreshRSS requiert au moins la version %s.',
 			'nok' => 'Votre version de PHP est la %s mais FreshRSS requiert au moins la version %s.',
 			'ok' => 'Votre version de PHP est la %s, qui est compatible avec FreshRSS.',
 			'ok' => 'Votre version de PHP est la %s, qui est compatible avec FreshRSS.',
 		),
 		),
+		'users' => array(
+			'nok' => 'Veuillez vérifier les droits sur le répertoire <em>./data/users</em>. Le serveur HTTP doit être capable d’écrire dedans',
+			'ok' => 'Les droits sur le répertoire des utilisateurs sont bons.',
+		),
 	),
 	),
 	'conf' => array(
 	'conf' => array(
 		'_' => 'Configuration générale',
 		'_' => 'Configuration générale',

+ 27 - 22
app/install.php

@@ -132,12 +132,17 @@ function saveStep2() {
 			'token' => $token,
 			'token' => $token,
 		);
 		);
 
 
-		$configPath = DATA_PATH . '/' . $_SESSION['default_user'] . '_user.php';
-		@unlink($configPath);	//To avoid access-rights problems
-		file_put_contents($configPath, "<?php\n return " . var_export($config_array, true) . ';');
+		// Create default user files but first, we delete previous data to
+		// avoid access right problems.
+		$user_dir = join_path(USERS_PATH, $_SESSION['default_user']);
+		$user_config_path = join_path($user_dir, 'config.php');
+
+		recursive_unlink($user_dir);
+		mkdir($user_dir);
+		file_put_contents($user_config_path, "<?php\n return " . var_export($config_array, true) . ';');
 
 
 		if ($_SESSION['mail_login'] != '') {
 		if ($_SESSION['mail_login'] != '') {
-			$personaFile = DATA_PATH . '/persona/' . $_SESSION['mail_login'] . '.txt';
+			$personaFile = join_path(DATA_PATH, 'persona', $_SESSION['mail_login'] . '.txt');
 			@unlink($personaFile);
 			@unlink($personaFile);
 			file_put_contents($personaFile, $_SESSION['default_user']);
 			file_put_contents($personaFile, $_SESSION['default_user']);
 		}
 		}
@@ -193,8 +198,8 @@ function saveStep3() {
 			),
 			),
 		);
 		);
 
 
-		@unlink(DATA_PATH . '/config.php');	//To avoid access-rights problems
-		file_put_contents(DATA_PATH . '/config.php', "<?php\n return " . var_export($ini_array, true) . ';');
+		@unlink(join_path(DATA_PATH, 'config.php'));	//To avoid access-rights problems
+		file_put_contents(join_path(DATA_PATH, 'config.php'), "<?php\n return " . var_export($ini_array, true) . ';');
 
 
 		$res = checkBD();
 		$res = checkBD();
 
 
@@ -217,7 +222,7 @@ function newPdo() {
 		);
 		);
 		break;
 		break;
 	case 'sqlite':
 	case 'sqlite':
-		$str = 'sqlite:' . DATA_PATH . '/' . $_SESSION['default_user'] . '.sqlite';
+		$str = 'sqlite:' . join_path(USERS_PATH, $_SESSION['default_user'], 'db.sqlite');
 		$driver_options = array(
 		$driver_options = array(
 			PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
 			PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
 		);
 		);
@@ -229,7 +234,7 @@ function newPdo() {
 }
 }
 
 
 function deleteInstall() {
 function deleteInstall() {
-	$res = unlink(DATA_PATH . '/do-install.txt');
+	$res = unlink(join_path(DATA_PATH, 'do-install.txt'));
 
 
 	if (!$res) {
 	if (!$res) {
 		return false;
 		return false;
@@ -270,7 +275,7 @@ function checkStep0() {
 
 
 function checkStep1() {
 function checkStep1() {
 	$php = version_compare(PHP_VERSION, '5.2.1') >= 0;
 	$php = version_compare(PHP_VERSION, '5.2.1') >= 0;
-	$minz = file_exists(LIB_PATH . '/Minz');
+	$minz = file_exists(join_path(LIB_PATH, 'Minz'));
 	$curl = extension_loaded('curl');
 	$curl = extension_loaded('curl');
 	$pdo_mysql = extension_loaded('pdo_mysql');
 	$pdo_mysql = extension_loaded('pdo_mysql');
 	$pdo_sqlite = extension_loaded('pdo_sqlite');
 	$pdo_sqlite = extension_loaded('pdo_sqlite');
@@ -280,9 +285,9 @@ function checkStep1() {
 	$dom = class_exists('DOMDocument');
 	$dom = class_exists('DOMDocument');
 	$data = DATA_PATH && is_writable(DATA_PATH);
 	$data = DATA_PATH && is_writable(DATA_PATH);
 	$cache = CACHE_PATH && is_writable(CACHE_PATH);
 	$cache = CACHE_PATH && is_writable(CACHE_PATH);
-	$log = LOG_PATH && is_writable(LOG_PATH);
-	$favicons = is_writable(DATA_PATH . '/favicons');
-	$persona = is_writable(DATA_PATH . '/persona');
+	$users = USERS_PATH && is_writable(USERS_PATH);
+	$favicons = is_writable(join_path(DATA_PATH, 'favicons'));
+	$persona = is_writable(join_path(DATA_PATH, 'persona'));
 	$http_referer = is_referer_from_same_domain();
 	$http_referer = is_referer_from_same_domain();
 
 
 	return array(
 	return array(
@@ -297,12 +302,12 @@ function checkStep1() {
 		'dom' => $dom ? 'ok' : 'ko',
 		'dom' => $dom ? 'ok' : 'ko',
 		'data' => $data ? 'ok' : 'ko',
 		'data' => $data ? 'ok' : 'ko',
 		'cache' => $cache ? 'ok' : 'ko',
 		'cache' => $cache ? 'ok' : 'ko',
-		'log' => $log ? 'ok' : 'ko',
+		'users' => $users ? 'ok' : 'ko',
 		'favicons' => $favicons ? 'ok' : 'ko',
 		'favicons' => $favicons ? 'ok' : 'ko',
 		'persona' => $persona ? 'ok' : 'ko',
 		'persona' => $persona ? 'ok' : 'ko',
 		'http_referer' => $http_referer ? 'ok' : 'ko',
 		'http_referer' => $http_referer ? 'ok' : 'ko',
 		'all' => $php && $minz && $curl && $pdo && $pcre && $ctype && $dom &&
 		'all' => $php && $minz && $curl && $pdo && $pcre && $ctype && $dom &&
-		         $data && $cache && $log && $favicons && $persona && $http_referer ?
+		         $data && $cache && $users && $favicons && $persona && $http_referer ?
 		         'ok' : 'ko'
 		         'ok' : 'ko'
 	);
 	);
 }
 }
@@ -327,7 +332,7 @@ function checkStep2() {
 	if ($defaultUser === null) {
 	if ($defaultUser === null) {
 		$defaultUser = empty($_SESSION['default_user']) ? '' : $_SESSION['default_user'];
 		$defaultUser = empty($_SESSION['default_user']) ? '' : $_SESSION['default_user'];
 	}
 	}
-	$data = is_writable(DATA_PATH . '/' . $defaultUser . '_user.php');
+	$data = is_writable(join_path(USERS_PATH, $defaultUser, 'config.php'));
 
 
 	return array(
 	return array(
 		'conf' => $conf ? 'ok' : 'ko',
 		'conf' => $conf ? 'ok' : 'ko',
@@ -339,7 +344,7 @@ function checkStep2() {
 }
 }
 
 
 function checkStep3() {
 function checkStep3() {
-	$conf = is_writable(DATA_PATH . '/config.php');
+	$conf = is_writable(join_path(DATA_PATH, 'config.php'));
 
 
 	$bd = isset($_SESSION['bd_type']) &&
 	$bd = isset($_SESSION['bd_type']) &&
 	      isset($_SESSION['bd_host']) &&
 	      isset($_SESSION['bd_host']) &&
@@ -382,7 +387,7 @@ function checkBD() {
 			$str = 'mysql:host=' . $_SESSION['bd_host'] . ';dbname=' . $_SESSION['bd_base'];
 			$str = 'mysql:host=' . $_SESSION['bd_host'] . ';dbname=' . $_SESSION['bd_base'];
 			break;
 			break;
 		case 'sqlite':
 		case 'sqlite':
-			$str = 'sqlite:' . DATA_PATH . '/' . $_SESSION['default_user'] . '.sqlite';
+			$str = 'sqlite:' . join_path(USERS_PATH, $_SESSION['default_user'], 'db.sqlite');
 			$driver_options = array(
 			$driver_options = array(
 				PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
 				PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
 			);
 			);
@@ -414,7 +419,7 @@ function checkBD() {
 	}
 	}
 
 
 	if (!$ok) {
 	if (!$ok) {
-		@unlink(DATA_PATH . '/config.php');
+		@unlink(join_path(DATA_PATH, 'config.php'));
 	}
 	}
 
 
 	return $ok;
 	return $ok;
@@ -470,7 +475,7 @@ function printStep1() {
 	<?php if ($res['minz'] == 'ok') { ?>
 	<?php if ($res['minz'] == 'ok') { ?>
 	<p class="alert alert-success"><span class="alert-head"><?php echo _t('gen.short.ok'); ?></span> <?php echo _t('install.check.minz.ok'); ?></p>
 	<p class="alert alert-success"><span class="alert-head"><?php echo _t('gen.short.ok'); ?></span> <?php echo _t('install.check.minz.ok'); ?></p>
 	<?php } else { ?>
 	<?php } else { ?>
-	<p class="alert alert-error"><span class="alert-head"><?php echo _t('gen.short.damn'); ?></span> <?php echo _t('install.check.minz.nok', LIB_PATH . '/Minz'); ?></p>
+	<p class="alert alert-error"><span class="alert-head"><?php echo _t('gen.short.damn'); ?></span> <?php echo _t('install.check.minz.nok', join_path(LIB_PATH, 'Minz')); ?></p>
 	<?php } ?>
 	<?php } ?>
 
 
 	<?php if ($res['pdo'] == 'ok') { ?>
 	<?php if ($res['pdo'] == 'ok') { ?>
@@ -516,10 +521,10 @@ function printStep1() {
 	<p class="alert alert-error"><span class="alert-head"><?php echo _t('gen.short.damn'); ?></span> <?php echo _t('install.check.cache.nok', CACHE_PATH); ?></p>
 	<p class="alert alert-error"><span class="alert-head"><?php echo _t('gen.short.damn'); ?></span> <?php echo _t('install.check.cache.nok', CACHE_PATH); ?></p>
 	<?php } ?>
 	<?php } ?>
 
 
-	<?php if ($res['log'] == 'ok') { ?>
-	<p class="alert alert-success"><span class="alert-head"><?php echo _t('gen.short.ok'); ?></span> <?php echo _t('install.check.logs.ok'); ?></p>
+	<?php if ($res['users'] == 'ok') { ?>
+	<p class="alert alert-success"><span class="alert-head"><?php echo _t('gen.short.ok'); ?></span> <?php echo _t('install.check.users.ok'); ?></p>
 	<?php } else { ?>
 	<?php } else { ?>
-	<p class="alert alert-error"><span class="alert-head"><?php echo _t('gen.short.damn'); ?></span> <?php echo _t('install.check.logs.nok', LOG_PATH); ?></p>
+	<p class="alert alert-error"><span class="alert-head"><?php echo _t('gen.short.damn'); ?></span> <?php echo _t('install.check.users.nok', USERS_PATH); ?></p>
 	<?php } ?>
 	<?php } ?>
 
 
 	<?php if ($res['favicons'] == 'ok') { ?>
 	<?php if ($res['favicons'] == 'ok') { ?>

+ 1 - 1
constants.php

@@ -16,7 +16,7 @@ define('FRESHRSS_PATH', dirname(__FILE__));
 
 
 	define('DATA_PATH', FRESHRSS_PATH . '/data');
 	define('DATA_PATH', FRESHRSS_PATH . '/data');
 		define('UPDATE_FILENAME', DATA_PATH . '/update.php');
 		define('UPDATE_FILENAME', DATA_PATH . '/update.php');
-		define('LOG_PATH', DATA_PATH . '/log');
+		define('USERS_PATH', DATA_PATH . '/users');
 		define('CACHE_PATH', DATA_PATH . '/cache');
 		define('CACHE_PATH', DATA_PATH . '/cache');
 
 
 	define('LIB_PATH', FRESHRSS_PATH . '/lib');
 	define('LIB_PATH', FRESHRSS_PATH . '/lib');

+ 0 - 1
data/.gitignore

@@ -1,6 +1,5 @@
 application.ini
 application.ini
 config.php
 config.php
-*_user.php
 *.sqlite
 *.sqlite
 touch.txt
 touch.txt
 no-cache.txt
 no-cache.txt

+ 0 - 1
data/log/.gitignore

@@ -1 +0,0 @@
-*.log

+ 4 - 0
data/users/.gitignore

@@ -0,0 +1,4 @@
+db.sqlite
+config.php
+log.txt
+

+ 0 - 0
data/users/_/.gitkeep


+ 0 - 0
data/log/index.html → data/users/index.html


+ 0 - 4
lib/Minz/FrontController.php

@@ -30,10 +30,6 @@ class Minz_FrontController {
 	 * Initialise le dispatcher, met à jour la Request
 	 * Initialise le dispatcher, met à jour la Request
 	 */
 	 */
 	public function __construct () {
 	public function __construct () {
-		if (LOG_PATH === false) {
-			$this->killApp ('Path not found: LOG_PATH');
-		}
-
 		try {
 		try {
 			Minz_Configuration::init ();
 			Minz_Configuration::init ();
 
 

+ 3 - 3
lib/Minz/Log.php

@@ -28,7 +28,7 @@ class Minz_Log {
 	 * 	- level = NOTICE et environment = PRODUCTION
 	 * 	- level = NOTICE et environment = PRODUCTION
 	 * @param $information message d'erreur / information à enregistrer
 	 * @param $information message d'erreur / information à enregistrer
 	 * @param $level niveau d'erreur
 	 * @param $level niveau d'erreur
-	 * @param $file_name fichier de log, par défaut LOG_PATH/application.log
+	 * @param $file_name fichier de log
 	 */
 	 */
 	public static function record ($information, $level, $file_name = null) {
 	public static function record ($information, $level, $file_name = null) {
 		$env = Minz_Configuration::environment ();
 		$env = Minz_Configuration::environment ();
@@ -37,7 +37,7 @@ class Minz_Log {
 		       || ($env === Minz_Configuration::PRODUCTION
 		       || ($env === Minz_Configuration::PRODUCTION
 		       && ($level >= Minz_Log::NOTICE)))) {
 		       && ($level >= Minz_Log::NOTICE)))) {
 			if ($file_name === null) {
 			if ($file_name === null) {
-				$file_name = LOG_PATH . '/' . Minz_Session::param('currentUser', '_') . '.log';
+				$file_name = join_path(USERS_PATH, Minz_Session::param('currentUser', '_'), 'log.txt');
 			}
 			}
 
 
 			switch ($level) {
 			switch ($level) {
@@ -71,7 +71,7 @@ class Minz_Log {
 	 * Automatise le log des variables globales $_GET et $_POST
 	 * Automatise le log des variables globales $_GET et $_POST
 	 * Fait appel à la fonction record(...)
 	 * Fait appel à la fonction record(...)
 	 * Ne fonctionne qu'en environnement "development"
 	 * Ne fonctionne qu'en environnement "development"
-	 * @param $file_name fichier de log, par défaut LOG_PATH/application.log
+	 * @param $file_name fichier de log
 	 */
 	 */
 	public static function recordRequest($file_name = null) {
 	public static function recordRequest($file_name = null) {
 		$msg_get = str_replace("\n", '', '$_GET content : ' . print_r($_GET, true));
 		$msg_get = str_replace("\n", '', '$_GET content : ' . print_r($_GET, true));

+ 1 - 1
lib/Minz/ModelPdo.php

@@ -63,7 +63,7 @@ class Minz_ModelPdo {
 				);
 				);
 				$this->prefix = $db['prefix'] . $currentUser . '_';
 				$this->prefix = $db['prefix'] . $currentUser . '_';
 			} elseif ($type === 'sqlite') {
 			} elseif ($type === 'sqlite') {
-				$string = 'sqlite:' . DATA_PATH . '/' . $currentUser . '.sqlite';
+				$string = 'sqlite:' . join_path(DATA_PATH, 'users', $currentUser, 'db.sqlite');
 				$driver_options = array(
 				$driver_options = array(
 					//PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
 					//PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
 				);
 				);

+ 26 - 10
lib/lib_rss.php

@@ -15,6 +15,17 @@ if (!function_exists('json_encode')) {
 	}
 	}
 }
 }
 
 
+/**
+ * Build a directory path by concatenating a list of directory names.
+ *
+ * @param $path_parts a list of directory names
+ * @return a string corresponding to the final pathname
+ */
+function join_path() {
+	$path_parts = func_get_args();
+	return join(DIRECTORY_SEPARATOR, $path_parts);
+}
+
 //<Auto-loading>
 //<Auto-loading>
 function classAutoloader($class) {
 function classAutoloader($class) {
 	if (strpos($class, 'FreshRSS') === 0) {
 	if (strpos($class, 'FreshRSS') === 0) {
@@ -205,19 +216,24 @@ function uSecString() {
 
 
 function invalidateHttpCache() {
 function invalidateHttpCache() {
 	Minz_Session::_param('touch', uTimeString());
 	Minz_Session::_param('touch', uTimeString());
-	return touch(LOG_PATH . '/' . Minz_Session::param('currentUser', '_') . '.log');
+	return touch(join_path(DATA_PATH, 'users', Minz_Session::param('currentUser', '_'), 'log.txt'));
 }
 }
 
 
-function usernameFromPath($userPath) {
-	if (preg_match('%/([A-Za-z0-9]{1,16})_user\.php$%', $userPath, $matches)) {
-		return $matches[1];
-	} else {
-		return '';
+function listUsers() {
+	$final_list = array();
+	$base_path = join_path(DATA_PATH, 'users');
+	$dir_list = array_values(array_diff(
+		scandir($base_path),
+		array('..', '.', '_')
+	));
+
+	foreach ($dir_list as $file) {
+		if (is_dir(join_path($base_path, $file))) {
+			$final_list[] = $file;
+		}
 	}
 	}
-}
 
 
-function listUsers() {
-	return array_map('usernameFromPath', glob(DATA_PATH . '/*_user.php'));
+	return $final_list;
 }
 }
 
 
 function httpAuthUser() {
 function httpAuthUser() {
@@ -284,7 +300,7 @@ function check_install_files() {
 	return array(
 	return array(
 		'data' => DATA_PATH && is_writable(DATA_PATH),
 		'data' => DATA_PATH && is_writable(DATA_PATH),
 		'cache' => CACHE_PATH && is_writable(CACHE_PATH),
 		'cache' => CACHE_PATH && is_writable(CACHE_PATH),
-		'logs' => LOG_PATH && is_writable(LOG_PATH),
+		'users' => USERS_PATH && is_writable(USERS_PATH),
 		'favicons' => is_writable(DATA_PATH . '/favicons'),
 		'favicons' => is_writable(DATA_PATH . '/favicons'),
 		'persona' => is_writable(DATA_PATH . '/persona'),
 		'persona' => is_writable(DATA_PATH . '/persona'),
 		'tokens' => is_writable(DATA_PATH . '/tokens'),
 		'tokens' => is_writable(DATA_PATH . '/tokens'),

+ 1 - 1
p/api/greader.php

@@ -77,7 +77,7 @@ class MyPDO extends Minz_ModelPdo {
 }
 }
 
 
 function logMe($text) {
 function logMe($text) {
-	file_put_contents(LOG_PATH . '/api.log', $text, FILE_APPEND);
+	file_put_contents(join_path(USERS_PATH, '_', 'log_api.txt'), $text, FILE_APPEND);
 }
 }
 
 
 function debugInfo() {
 function debugInfo() {

+ 2 - 2
p/i/index.php

@@ -32,8 +32,8 @@ if (file_exists(DATA_PATH . '/do-install.txt')) {
 		require(LIB_PATH . '/http-conditional.php');
 		require(LIB_PATH . '/http-conditional.php');
 		$currentUser = Minz_Session::param('currentUser', '');
 		$currentUser = Minz_Session::param('currentUser', '');
 		$dateLastModification = $currentUser === '' ? time() : max(
 		$dateLastModification = $currentUser === '' ? time() : max(
-			@filemtime(LOG_PATH . '/' . $currentUser . '.log'),
-			@filemtime(DATA_PATH . '/config.php')
+			@filemtime(join_path(USERS_PATH, $currentUser, 'log.txt')),
+			@filemtime(join_path(DATA_PATH . 'config.php'))
 		);
 		);
 		if (httpConditional($dateLastModification, 0, 0, false, PHP_COMPRESSION, true)) {
 		if (httpConditional($dateLastModification, 0, 0, false, PHP_COMPRESSION, true)) {
 			exit();	//No need to send anything
 			exit();	//No need to send anything