aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-12-28 19:46:04 +0100
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-12-28 19:46:04 +0100
commit0cd975bfd06b45865722d85fbdab120439623ddc (patch)
tree790f442337f88cfecb20b0c62bfec2f61af83c94 /lib
parent5f327abeeca1953ff9d11f93afb9fbd9ceb825ba (diff)
parent497d295be470454b7bd068a5c5cceda8caa19527 (diff)
Merge branch '729-move_data' into dev
To update, please follow instructions in https://github.com/FreshRSS/FreshRSS/issues/729
Diffstat (limited to 'lib')
-rw-r--r--lib/Minz/FrontController.php4
-rw-r--r--lib/Minz/Log.php6
-rw-r--r--lib/Minz/ModelPdo.php2
-rw-r--r--lib/lib_rss.php36
4 files changed, 30 insertions, 18 deletions
diff --git a/lib/Minz/FrontController.php b/lib/Minz/FrontController.php
index e95c56bf3..3dac1e438 100644
--- a/lib/Minz/FrontController.php
+++ b/lib/Minz/FrontController.php
@@ -30,10 +30,6 @@ class Minz_FrontController {
* Initialise le dispatcher, met à jour la Request
*/
public function __construct () {
- if (LOG_PATH === false) {
- $this->killApp ('Path not found: LOG_PATH');
- }
-
try {
Minz_Configuration::init ();
diff --git a/lib/Minz/Log.php b/lib/Minz/Log.php
index d3eaec2ae..d19edc1dc 100644
--- a/lib/Minz/Log.php
+++ b/lib/Minz/Log.php
@@ -28,7 +28,7 @@ class Minz_Log {
* - level = NOTICE et environment = PRODUCTION
* @param $information message d'erreur / information à enregistrer
* @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) {
$env = Minz_Configuration::environment ();
@@ -37,7 +37,7 @@ class Minz_Log {
|| ($env === Minz_Configuration::PRODUCTION
&& ($level >= Minz_Log::NOTICE)))) {
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) {
@@ -71,7 +71,7 @@ class Minz_Log {
* Automatise le log des variables globales $_GET et $_POST
* Fait appel à la fonction record(...)
* 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) {
$msg_get = str_replace("\n", '', '$_GET content : ' . print_r($_GET, true));
diff --git a/lib/Minz/ModelPdo.php b/lib/Minz/ModelPdo.php
index 6198cd85c..118d89ad2 100644
--- a/lib/Minz/ModelPdo.php
+++ b/lib/Minz/ModelPdo.php
@@ -63,7 +63,7 @@ class Minz_ModelPdo {
);
$this->prefix = $db['prefix'] . $currentUser . '_';
} elseif ($type === 'sqlite') {
- $string = 'sqlite:' . DATA_PATH . '/' . $currentUser . '.sqlite';
+ $string = 'sqlite:' . join_path(DATA_PATH, 'users', $currentUser, 'db.sqlite');
$driver_options = array(
//PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
);
diff --git a/lib/lib_rss.php b/lib/lib_rss.php
index 2400ba708..d450ec858 100644
--- a/lib/lib_rss.php
+++ b/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>
function classAutoloader($class) {
if (strpos($class, 'FreshRSS') === 0) {
@@ -205,19 +216,24 @@ function uSecString() {
function invalidateHttpCache() {
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() {
@@ -284,7 +300,7 @@ function check_install_files() {
return array(
'data' => DATA_PATH && is_writable(DATA_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'),
'persona' => is_writable(DATA_PATH . '/persona'),
'tokens' => is_writable(DATA_PATH . '/tokens'),