Added support for username based configs
This commit is contained in:
parent
02a90bd7f0
commit
144df0770c
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -6,3 +6,4 @@ test/text.atom
|
||||||
cops.zip
|
cops.zip
|
||||||
cops.sublime-*
|
cops.sublime-*
|
||||||
config_local.php
|
config_local.php
|
||||||
|
config_local.*.php
|
||||||
|
|
15
config.php
15
config.php
|
@ -6,9 +6,18 @@
|
||||||
* @author Sébastien Lucas <sebastien@slucas.fr>
|
* @author Sébastien Lucas <sebastien@slucas.fr>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once 'config_default.php';
|
require_once 'config_default.php';
|
||||||
if (file_exists(dirname(__FILE__). '/config_local.php') && (php_sapi_name() !== 'cli'))
|
if (file_exists(dirname(__FILE__) . '/config_local.php') && (php_sapi_name() !== 'cli')) {
|
||||||
require_once 'config_local.php';
|
require_once 'config_local.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
$remote_user = array_key_exists('PHP_AUTH_USER', $_SERVER) ? $_SERVER['PHP_AUTH_USER'] : '';
|
||||||
|
// Clean username, only allow a-z, A-Z, 0-9, -_ chars
|
||||||
|
$remote_user = preg_replace( "/[^a-zA-Z0-9_-]/", "", $remote_user);
|
||||||
|
$user_config_file = 'config_local.' . $remote_user . '.php';
|
||||||
|
if (file_exists(dirname(__FILE__) . '/' . $user_config_file) && (php_sapi_name() !== 'cli')) {
|
||||||
|
require_once $user_config_file;
|
||||||
|
}
|
||||||
|
|
||||||
if(!is_null($config['cops_basic_authentication']) &&
|
if(!is_null($config['cops_basic_authentication']) &&
|
||||||
is_array($config['cops_basic_authentication']))
|
is_array($config['cops_basic_authentication']))
|
||||||
|
|
Loading…
Reference in a new issue