summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-12-31 02:59:07 +0100
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-12-31 02:59:07 +0100
commit1ac09e7fe4a5408290d06116c6fb8152e018fe26 (patch)
treee5f4b3eb7654e0364670a4f180fc5d92f51b0309 /lib
parent84be5ff618a59c510db7627c9b6447835f4364c7 (diff)
Multi-utilisateur fonctionnel en HTTP Auth
+ Possibilité d'ajout / suppression d'utilisateur (seulement par l'administrateur) + Divers changements pour le mode multi-utilisateur https://github.com/marienfressinaud/FreshRSS/issues/126 + Minz : Renomme "sel_application" en "salt'
Diffstat (limited to 'lib')
-rw-r--r--lib/Minz/Configuration.php53
-rw-r--r--lib/Minz/FileNotExistException.php2
-rw-r--r--lib/Minz/ModelPdo.php12
3 files changed, 39 insertions, 28 deletions
diff --git a/lib/Minz/Configuration.php b/lib/Minz/Configuration.php
index 1513af6d0..873908ce6 100644
--- a/lib/Minz/Configuration.php
+++ b/lib/Minz/Configuration.php
@@ -28,7 +28,7 @@ class Minz_Configuration {
/**
* définition des variables de configuration
- * $sel_application une chaîne de caractères aléatoires (obligatoire)
+ * $salt une chaîne de caractères aléatoires (obligatoire)
* $environment gère le niveau d'affichage pour log et erreurs
* $use_url_rewriting indique si on utilise l'url_rewriting
* $base_url le chemin de base pour accéder à l'application
@@ -42,7 +42,7 @@ class Minz_Configuration {
* - password mot de passe de l'utilisateur
* - base le nom de la base de données
*/
- private static $sel_application = '';
+ private static $salt = '';
private static $environment = Minz_Configuration::PRODUCTION;
private static $base_url = '';
private static $use_url_rewriting = false;
@@ -55,17 +55,19 @@ class Minz_Configuration {
private static $auth_type = 'none';
private static $db = array (
- 'host' => false,
- 'user' => false,
- 'password' => false,
- 'base' => false
+ 'type' => 'mysql',
+ 'host' => '',
+ 'user' => '',
+ 'password' => '',
+ 'base' => '',
+ 'prefix' => '',
);
/*
* Getteurs
*/
public static function salt () {
- return self::$sel_application;
+ return self::$salt;
}
public static function environment () {
return self::$environment;
@@ -145,7 +147,7 @@ class Minz_Configuration {
'general' => array(
'environment' => self::$environment,
'use_url_rewriting' => self::$use_url_rewriting,
- 'sel_application' => self::$sel_application,
+ 'salt' => self::$salt,
'base_url' => self::$base_url,
'title' => self::$title,
'default_user' => self::$default_user,
@@ -189,14 +191,18 @@ class Minz_Configuration {
}
$general = $ini_array['general'];
- // sel_application est obligatoire
- if (!isset ($general['sel_application'])) {
- throw new Minz_BadConfigurationException (
- 'sel_application',
- Minz_Exception::ERROR
- );
+ // salt est obligatoire
+ if (!isset ($general['salt'])) {
+ if (isset($general['sel_application'])) { //v0.6
+ $general['salt'] = $general['sel_application'];
+ } else {
+ throw new Minz_BadConfigurationException (
+ 'salt',
+ Minz_Exception::ERROR
+ );
+ }
}
- self::$sel_application = $general['sel_application'];
+ self::$salt = $general['salt'];
if (isset ($general['environment'])) {
switch ($general['environment']) {
@@ -256,18 +262,15 @@ class Minz_Configuration {
}
// Base de données
- $db = false;
if (isset ($ini_array['db'])) {
$db = $ini_array['db'];
- }
- if ($db) {
- if (!isset ($db['host'])) {
+ if (empty($db['host'])) {
throw new Minz_BadConfigurationException (
'host',
Minz_Exception::ERROR
);
}
- if (!isset ($db['user'])) {
+ if (empty($db['user'])) {
throw new Minz_BadConfigurationException (
'user',
Minz_Exception::ERROR
@@ -279,19 +282,23 @@ class Minz_Configuration {
Minz_Exception::ERROR
);
}
- if (!isset ($db['base'])) {
+ if (empty($db['base'])) {
throw new Minz_BadConfigurationException (
'base',
Minz_Exception::ERROR
);
}
- self::$db['type'] = isset ($db['type']) ? $db['type'] : 'mysql';
+ if (!empty($db['type'])) {
+ self::$db['type'] = $db['type'];
+ }
self::$db['host'] = $db['host'];
self::$db['user'] = $db['user'];
self::$db['password'] = $db['password'];
self::$db['base'] = $db['base'];
- self::$db['prefix'] = isset ($db['prefix']) ? $db['prefix'] : '';
+ if (isset($db['prefix'])) {
+ self::$db['prefix'] = $db['prefix'];
+ }
}
}
diff --git a/lib/Minz/FileNotExistException.php b/lib/Minz/FileNotExistException.php
index df2b8ff6c..f8dfbdf66 100644
--- a/lib/Minz/FileNotExistException.php
+++ b/lib/Minz/FileNotExistException.php
@@ -1,7 +1,7 @@
<?php
class Minz_FileNotExistException extends Minz_Exception {
public function __construct ($file_name, $code = self::ERROR) {
- $message = 'File doesn\'t exist : `' . $file_name.'`';
+ $message = 'File not found: `' . $file_name.'`';
parent::__construct ($message, $code);
}
diff --git a/lib/Minz/ModelPdo.php b/lib/Minz/ModelPdo.php
index 1ea68e104..a643da1f0 100644
--- a/lib/Minz/ModelPdo.php
+++ b/lib/Minz/ModelPdo.php
@@ -1,5 +1,5 @@
<?php
-/**
+/**
* MINZ - Copyright 2011 Marien Fressinaud
* Sous licence AGPL3 <http://www.gnu.org/licenses/>
*/
@@ -23,7 +23,7 @@ class Minz_ModelPdo {
protected $bd;
protected $prefix;
-
+
/**
* Créé la connexion à la base de données à l'aide des variables
* HOST, BASE, USER et PASS définies dans le fichier de configuration
@@ -80,11 +80,15 @@ class Minz_ModelPdo {
$this->bd->rollBack();
}
- public function size() {
+ public function size($all = false) {
$db = Minz_Configuration::dataBase ();
$sql = 'SELECT SUM(data_length + index_length) FROM information_schema.TABLES WHERE table_schema = ?';
- $stm = $this->bd->prepare ($sql);
$values = array ($db['base']);
+ if (!$all) {
+ $sql .= ' AND table_name LIKE ?';
+ $values[] = $this->prefix . '%';
+ }
+ $stm = $this->bd->prepare ($sql);
$stm->execute ($values);
$res = $stm->fetchAll(PDO::FETCH_COLUMN, 0);
return $res[0];