Implemented new Configuration handling
Dieser Commit ist enthalten in:
Ursprung
6cfb97b401
Commit
edc44e2f30
22 geänderte Dateien mit 730 neuen und 107 gelöschten Zeilen
|
|
@ -42,7 +42,9 @@ class Msd_Auth_Adapter_Ini implements Zend_Auth_Adapter_Interface
|
|||
*
|
||||
* @param string $iniFilename Filename for registered users
|
||||
*
|
||||
* @return void
|
||||
* @throws Msd_Exception
|
||||
*
|
||||
* @return Msd_Auth_Adapter_Ini
|
||||
*/
|
||||
public function __construct($iniFilename)
|
||||
{
|
||||
|
|
@ -57,6 +59,8 @@ class Msd_Auth_Adapter_Ini implements Zend_Auth_Adapter_Interface
|
|||
/**
|
||||
* set the username, which is used for authentication.
|
||||
*
|
||||
* @param string $username The username
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setUsername($username)
|
||||
|
|
@ -67,6 +71,8 @@ class Msd_Auth_Adapter_Ini implements Zend_Auth_Adapter_Interface
|
|||
/**
|
||||
* Set the password, which is used for authentication.
|
||||
*
|
||||
* @param string $password The password
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setPassword($password)
|
||||
|
|
@ -77,6 +83,8 @@ class Msd_Auth_Adapter_Ini implements Zend_Auth_Adapter_Interface
|
|||
/**
|
||||
* Authenticate with the given credentials.
|
||||
*
|
||||
* @throws Msd_Exception
|
||||
*
|
||||
* @return Zend_Auth_Result
|
||||
*/
|
||||
public function authenticate()
|
||||
|
|
|
|||
193
library/Msd/Config.php
Normale Datei
193
library/Msd/Config.php
Normale Datei
|
|
@ -0,0 +1,193 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of MySQLDumper released under the GNU/GPL 2 license
|
||||
* http://www.mysqldumper.net
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage Config
|
||||
* @version SVN: $Rev$
|
||||
* @author $Author$
|
||||
*/
|
||||
/**
|
||||
* Class to handle the configuration
|
||||
*
|
||||
* @throws Msd_Config_Exception
|
||||
* @package MySQLDumper
|
||||
* @subpackage Config
|
||||
*/
|
||||
class Msd_Config
|
||||
{
|
||||
/**
|
||||
* The configuration itself.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_config = null;
|
||||
|
||||
/**
|
||||
* Instance of the IO-Handler.
|
||||
*
|
||||
* @var Msd_Config_IoHandler_Interface
|
||||
*/
|
||||
private $_ioHandler = null;
|
||||
|
||||
/**
|
||||
* Status for the automatic configuration saving on class destruction.
|
||||
* It's disabled by default.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $_autosave = false;
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @param Msd_Config_IoHandler_Interface|string $ioHandler Instance or name of the IO-Handler.
|
||||
* @param array $handlerOptions Options for the IO-Handler.
|
||||
*
|
||||
* @throws Msd_Config_Exception
|
||||
*/
|
||||
public function __construct($ioHandler, $handlerOptions = array())
|
||||
{
|
||||
if (is_string($ioHandler)) {
|
||||
$pluginLoader = new Zend_Loader_PluginLoader(
|
||||
array(
|
||||
'Msd_Config_IoHandler_' => APPLICATION_PATH . '/../library/Msd/Config/IoHandler/',
|
||||
'Module_Config_IoHandler_' => APPLICATION_PATH . '/../modules/library/Config/IoHandler/',
|
||||
)
|
||||
);
|
||||
|
||||
$className = $pluginLoader->load($ioHandler);
|
||||
$ioHandler = new $className($handlerOptions);
|
||||
}
|
||||
if (!$ioHandler instanceof Msd_Config_IoHandler_Interface) {
|
||||
throw new Msd_Config_Exception(
|
||||
"Invalid IO-Handler specified; The IO-Handler must implement Msd_Config_IoHandler_Interface"
|
||||
);
|
||||
}
|
||||
$this->_ioHandler = $ioHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the configuration from the IO-Handler.
|
||||
* The filename is used for static storage.
|
||||
*
|
||||
* @param string $configFilename Name of file on the static storage.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function load($configFilename)
|
||||
{
|
||||
$this->_config = $this->_ioHandler->load($configFilename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the configuration for the next request.
|
||||
* The filename is used for static storage.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
return $this->_ioHandler->save($this->_config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the value of a configuration parameter.
|
||||
*
|
||||
* @param string $paramName Name of the configuration parameter.
|
||||
* @param mixed $defaultValue Default value to return, if param isn't set.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getParam($paramName, $defaultValue = null)
|
||||
{
|
||||
if (isset($this->_config[$paramName])) {
|
||||
return $this->_config[$paramName];
|
||||
}
|
||||
|
||||
return $defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a configuration parameter.
|
||||
* If auto-save is enabled the configuration is also saved.
|
||||
*
|
||||
* @param $paramName
|
||||
* @param $paramValue
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setParam($paramName, $paramValue)
|
||||
{
|
||||
$this->_config[$paramName] = $paramValue;
|
||||
if ($this->_autosave) {
|
||||
$this->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class destructor.
|
||||
* If auto-save is enabled the configuration will be saved.
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
if ($this->_autosave) {
|
||||
$this->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the whole configuration.
|
||||
* If auto-save is enabled the configuration is also saved.
|
||||
*
|
||||
* @param array $config New configuration.
|
||||
*/
|
||||
public function setConfig($config)
|
||||
{
|
||||
$this->_config = (array) $config;
|
||||
if ($this->_autosave) {
|
||||
$this->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the whole configuration.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getConfig()
|
||||
{
|
||||
return $this->_config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables automatic configuration saving.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function enableAutosave()
|
||||
{
|
||||
$this->_autosave = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables automatic configuration saving.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function disableAutosave()
|
||||
{
|
||||
$this->_autosave = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the autosave status.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isAutosaveActive()
|
||||
{
|
||||
return $this->_autosave;
|
||||
}
|
||||
}
|
||||
67
library/Msd/Config/Dynamic.php
Normale Datei
67
library/Msd/Config/Dynamic.php
Normale Datei
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of MySQLDumper released under the GNU/GPL 2 license
|
||||
* http://www.mysqldumper.net
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage Config
|
||||
* @version SVN: $Rev$
|
||||
* @author $Author$
|
||||
*/
|
||||
/**
|
||||
* Class for dynamic (session lifetime) configuration settings.
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage Config
|
||||
*/
|
||||
class Msd_Config_Dynamic
|
||||
{
|
||||
/**
|
||||
* Instance of Zend_Session_Namespace for session storage.
|
||||
*
|
||||
* @var Zend_Session_Namespace
|
||||
*/
|
||||
private $_namespace = null;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param string $sessionNsName Name of the session namespace.
|
||||
*
|
||||
* @return Msd_Config_Dynamic
|
||||
*/
|
||||
public function __construct($sessionNsName = 'Dynamic')
|
||||
{
|
||||
$this->_namespace = new Zend_Session_Namespace($sessionNsName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the value of a parameter.
|
||||
*
|
||||
* @param string $name Name of the parameter.
|
||||
* @param mixed $default Default value to return, if param isn't set.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getParam($name, $default = null)
|
||||
{
|
||||
if (isset($this->_namespace->$name)) {
|
||||
return $this->_namespace->$name;
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a value for the given parameter.
|
||||
*
|
||||
* @param string $name Name of the parameter.
|
||||
* @param mixed $value Value for the parameter.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setParam($name, $value)
|
||||
{
|
||||
$this->_namespace->$name = $value;
|
||||
}
|
||||
}
|
||||
19
library/Msd/Config/Exception.php
Normale Datei
19
library/Msd/Config/Exception.php
Normale Datei
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of MySQLDumper released under the GNU/GPL 2 license
|
||||
* http://www.mysqldumper.net
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage Config
|
||||
* @version SVN: $Rev$
|
||||
* @author $Author$
|
||||
*/
|
||||
/**
|
||||
* Exception class for configuration class.
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage Config
|
||||
*/
|
||||
class Msd_Config_Exception extends Msd_Exception
|
||||
{
|
||||
}
|
||||
128
library/Msd/Config/IoHandler/Default.php
Normale Datei
128
library/Msd/Config/IoHandler/Default.php
Normale Datei
|
|
@ -0,0 +1,128 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of MySQLDumper released under the GNU/GPL 2 license
|
||||
* http://www.mysqldumper.net
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage Config_IoHandler
|
||||
* @version SVN: $Rev$
|
||||
* @author $Author$
|
||||
*/
|
||||
/**
|
||||
* Class to handle input/output for configuration params.
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage Config_IoHandler
|
||||
*/
|
||||
class Msd_Config_IoHandler_Default implements Msd_Config_IoHandler_Interface
|
||||
{
|
||||
/**
|
||||
* Array with directories, where config files are located.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_configDirectories = array();
|
||||
|
||||
/**
|
||||
* Handler for .ini files.
|
||||
*
|
||||
* @var Msd_Ini
|
||||
*/
|
||||
private $_iniConfig = null;
|
||||
|
||||
/**
|
||||
* Name of the .ini file, where the config is stored.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $_configFilename = null;
|
||||
|
||||
/**
|
||||
* Configuration namespace in session.
|
||||
*
|
||||
* @var Zend_Session_Namespace
|
||||
*/
|
||||
private $_sessionNamespace = null;
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @param array $handlerOptions
|
||||
*
|
||||
* @return Msd_Config_IoHandler_Default
|
||||
*/
|
||||
public function __construct($handlerOptions = array())
|
||||
{
|
||||
if (isset($handlerOptions['directories'])) {
|
||||
$this->_configDirectories = (array) $handlerOptions['directories'];
|
||||
}
|
||||
|
||||
// Create new namespace for session access.
|
||||
$this->_sessionNamespace = new Zend_Session_Namespace('Config');
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads and returns a configuration from session or .ini file.
|
||||
* If the config is read from .ini file, it is also stored to session.
|
||||
*
|
||||
* @param string $configFilename Name of the .ini file, where the config is stored.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function load($configFilename)
|
||||
{
|
||||
// Retrieve config from session
|
||||
$config = (array) $this->_sessionNamespace->config;
|
||||
$this->_configFilename = $configFilename;
|
||||
|
||||
// Check whether the configuration has been loaded.
|
||||
if (count($config) == 0) {
|
||||
|
||||
// Search for the config file in the given directories.
|
||||
$this->_initIni();
|
||||
$config = $this->_iniConfig->getIniData();
|
||||
|
||||
// Put configuration into session.
|
||||
$this->_sessionNamespace->config = $config;
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the configuration to session and .ini file.
|
||||
*
|
||||
* @param array $config Configuration to save.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function save($config)
|
||||
{
|
||||
if ($this->_iniConfig === null) {
|
||||
$this->_initIni();
|
||||
}
|
||||
// Save config to session
|
||||
$this->_sessionNamespace->config = $config;
|
||||
|
||||
// Save config to .ini file
|
||||
$this->_iniConfig->setIniData($config);
|
||||
return $this->_iniConfig->saveFile($this->_configFilename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the .ini file handler and sets the full filename of the .ini file.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _initIni()
|
||||
{
|
||||
foreach ($this->_configDirectories as $configDir) {
|
||||
$filename = rtrim($configDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $this->_configFilename;
|
||||
if (file_exists($filename)) {
|
||||
$this->_configFilename = $filename;
|
||||
$this->_iniConfig = new Msd_Ini($filename);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
51
library/Msd/Config/IoHandler/Interface.php
Normale Datei
51
library/Msd/Config/IoHandler/Interface.php
Normale Datei
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of MySQLDumper released under the GNU/GPL 2 license
|
||||
* http://www.mysqldumper.net
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage Config_IoHandler
|
||||
* @version SVN: $Rev$
|
||||
* @author $Author$
|
||||
*/
|
||||
/**
|
||||
* Interface for configuration IO-Handler.
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage Config_IoHandler
|
||||
*/
|
||||
interface Msd_Config_IoHandler_Interface
|
||||
{
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @abstract
|
||||
*
|
||||
* @param array $handlerOptions
|
||||
*
|
||||
* @return Msd_Config_IoHandler_Interface
|
||||
*/
|
||||
public function __construct($handlerOptions = array());
|
||||
|
||||
/**
|
||||
* Loads and returns the configuration.
|
||||
*
|
||||
* @abstract
|
||||
*
|
||||
* @param string $configFilename
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function load($configFilename);
|
||||
|
||||
/**
|
||||
* Saves the configuration.
|
||||
*
|
||||
* @abstract
|
||||
*
|
||||
* @param array $config
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function save($config);
|
||||
}
|
||||
|
|
@ -198,7 +198,7 @@ class Msd_Configuration
|
|||
}
|
||||
$configWriter = new Zend_Config_Writer_Ini(
|
||||
array(
|
||||
'filename' => $this->get('paths.config') . DS . $fileName,
|
||||
'filename' => $this->get('paths.config') . '/' . $fileName,
|
||||
'config' => $configData,
|
||||
)
|
||||
);
|
||||
|
|
@ -253,11 +253,10 @@ class Msd_Configuration
|
|||
if ($configName != 'defaultConfig') {
|
||||
$configName .= '.ini';
|
||||
$configPath = $this->get('paths.config');
|
||||
$configFile = $configPath . DS . $configName;
|
||||
$configFile = $configPath . '/' . $configName;
|
||||
} else {
|
||||
// special case - defaultConfig.ini is in application/configs
|
||||
$configFile = realpath(APPLICATION_PATH . DS . 'configs')
|
||||
. DS . 'defaultConfig.ini';
|
||||
$configFile = realpath(APPLICATION_PATH . '/configs') . '/defaultConfig.ini';
|
||||
}
|
||||
if (!is_readable($configFile)) {
|
||||
throw new Msd_Exception(
|
||||
|
|
@ -286,7 +285,7 @@ class Msd_Configuration
|
|||
private function _loadUserDirectories()
|
||||
{
|
||||
// set paths
|
||||
$workRoot = realpath(APPLICATION_PATH . DS . '..') . DS . 'work' . DS;
|
||||
$workRoot = realpath(APPLICATION_PATH . '/..') . '/work/';
|
||||
$directories = array(
|
||||
'work' => $workRoot,
|
||||
'log' => $workRoot . 'log',
|
||||
|
|
|
|||
|
|
@ -30,12 +30,19 @@ class Msd_Ini
|
|||
*/
|
||||
private $_iniFilename = null;
|
||||
|
||||
/**
|
||||
* Determines the escaping of the output.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $_escapeIniOutput = true;
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* @param array|string $options Configuration or filename of INI to load
|
||||
*
|
||||
* @return void
|
||||
* @return Msd_Ini
|
||||
*/
|
||||
public function __construct($options = array())
|
||||
{
|
||||
|
|
@ -60,6 +67,8 @@ class Msd_Ini
|
|||
*
|
||||
* @param string $filename Name of file to load
|
||||
*
|
||||
* @throws Msd_Exception
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function loadFile($filename = null)
|
||||
|
|
@ -82,9 +91,11 @@ class Msd_Ini
|
|||
*
|
||||
* @param string $filename Name of file to save
|
||||
*
|
||||
* @return void
|
||||
* @throws Msd_Exception
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function save($filename = null)
|
||||
public function saveFile($filename = null)
|
||||
{
|
||||
if ($filename === null) {
|
||||
$filename = $this->_iniFilename;
|
||||
|
|
@ -94,20 +105,20 @@ class Msd_Ini
|
|||
'You must specify a filename to save the INI!'
|
||||
);
|
||||
}
|
||||
$fileHandle = fopen($filename, 'w+');
|
||||
fwrite($fileHandle, (string) $this);
|
||||
fclose($fileHandle);
|
||||
$res = file_put_contents($filename, (string) $this);
|
||||
return $res === false ? false : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an array into the INI file format.
|
||||
*
|
||||
* @param array $array Array to convert.
|
||||
* @param integer $level Current depthlevel in the array.
|
||||
* @param array $array Array to convert.
|
||||
* @param integer $level Current depth level in the array.
|
||||
* @param string $prefix Prefix to use for var name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function _arrayToIniString($array = null, $level = -1)
|
||||
private function _arrayToIniString($array = null, $level = -1, $prefix = '')
|
||||
{
|
||||
if ($array === null) {
|
||||
$array = $this->_iniData;
|
||||
|
|
@ -116,18 +127,27 @@ class Msd_Ini
|
|||
$resultString = '';
|
||||
foreach ($array as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
$resultString .= ($level == 0) ?
|
||||
'[' . $key . ']' . "\n" :
|
||||
$key . '.';
|
||||
$resultString .= $this->_arrayToIniString($value);
|
||||
if ($level == 0) {
|
||||
$resultString .= '[' . $key . ']' . "\n";
|
||||
$resultString .= $this->_arrayToIniString($value, $level);
|
||||
} else {
|
||||
$resultString .= $this->_arrayToIniString($value, $level, $key);
|
||||
}
|
||||
} else {
|
||||
$newValue = str_replace(
|
||||
array('\\', '"'),
|
||||
array('\\\\', '\\"'),
|
||||
$value
|
||||
);
|
||||
$resultString .= $key . ' = "' . (string) $newValue . '"';
|
||||
$newValue = $value;
|
||||
if ($this->_escapeIniOutput) {
|
||||
$newValue = "\"" . str_replace(
|
||||
array('\\', '"'),
|
||||
array('\\\\', '\\"'),
|
||||
$value
|
||||
) . "\"";
|
||||
}
|
||||
|
||||
$resultString .= ltrim("$prefix.$key", '.') . " = $newValue\n";
|
||||
}
|
||||
}
|
||||
|
||||
if ($level < 2) {
|
||||
$resultString .= "\n";
|
||||
}
|
||||
|
||||
|
|
@ -170,16 +190,6 @@ class Msd_Ini
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the complete INI.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAll()
|
||||
{
|
||||
return $this->_iniData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert this class into a string.
|
||||
*
|
||||
|
|
@ -189,4 +199,68 @@ class Msd_Ini
|
|||
{
|
||||
return $this->_arrayToIniString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the INI data.
|
||||
*
|
||||
* @param array $iniData New INI data.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setIniData($iniData)
|
||||
{
|
||||
$this->_iniData = $iniData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the parsed INI data.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getIniData()
|
||||
{
|
||||
return $this->_iniData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables the escaping of the output for the INI file.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function disableEscaping()
|
||||
{
|
||||
$this->setEscapeIniOutput(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the escaping of the output for the INI file.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function enableEscaping()
|
||||
{
|
||||
$this->setEscapeIniOutput(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* En-/Disables the escaping of the output for the INI file.
|
||||
*
|
||||
* @param boolean $escapeIniOutput TRUE - Escaping enabled (default), FALSE - Escaping disabled
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setEscapeIniOutput($escapeIniOutput)
|
||||
{
|
||||
$this->_escapeIniOutput = $escapeIniOutput;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves escaping status of the output for the INI file.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getEscapeIniOutput()
|
||||
{
|
||||
return $this->_escapeIniOutput;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,8 +60,8 @@ class Msd_Language
|
|||
*/
|
||||
public function loadLanguage($language)
|
||||
{
|
||||
$this->_baseLanguageDir = APPLICATION_PATH . DS . 'language' . DS;
|
||||
$file = $this->_baseLanguageDir . $language . DS . 'lang.php';
|
||||
$this->_baseLanguageDir = APPLICATION_PATH . '/language/';
|
||||
$file = $this->_baseLanguageDir . $language . '/lang.php';
|
||||
$translator = $this->getTranslator();
|
||||
if ($translator === null) {
|
||||
$translator = new Zend_Translate('array', $file, $language);
|
||||
|
|
|
|||
|
|
@ -145,16 +145,16 @@ class Msd_Log
|
|||
$filename = '';
|
||||
switch ($file) {
|
||||
case self::PHP:
|
||||
$filename = $this->_paths->log . DS . 'php.log';
|
||||
$filename = $this->_paths->log . '/php.log';
|
||||
break;
|
||||
case self::PERL:
|
||||
$filename = $this->_paths->log . DS . 'perl.log';
|
||||
$filename = $this->_paths->log . '/perl.log';
|
||||
break;
|
||||
case self::PERL_COMPLETE:
|
||||
$filename = $this->_paths->log . DS . 'perlComplete.log';
|
||||
$filename = $this->_paths->log . '/perlComplete.log';
|
||||
break;
|
||||
case self::ERROR:
|
||||
$filename = $this->_paths->log . DS . 'phpError.log';
|
||||
$filename = $this->_paths->log . '/phpError.log';
|
||||
}
|
||||
return $filename;
|
||||
}
|
||||
|
|
@ -202,4 +202,4 @@ class Msd_Log
|
|||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
76
library/Msd/Registry.php
Normale Datei
76
library/Msd/Registry.php
Normale Datei
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of MySQLDumper released under the GNU/GPL 2 license
|
||||
* http://www.mysqldumper.net
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage Registry
|
||||
* @version SVN: $Rev$
|
||||
* @author $Author$
|
||||
*/
|
||||
/**
|
||||
* Abstract decorator for form elements of Msd_Form
|
||||
*
|
||||
* @package MySQLDumper
|
||||
* @subpackage Registry
|
||||
*/
|
||||
class Msd_Registry extends Zend_Registry
|
||||
{
|
||||
/**
|
||||
* Returns the config instance if it has been registered, returns null otherwise.
|
||||
*
|
||||
* @return Msd_Config|null
|
||||
*/
|
||||
public static function getConfig()
|
||||
{
|
||||
if (self::isRegistered('_config')) {
|
||||
return self::get('_config');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a Msd_Config instance.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @param Msd_Config $config Configuration
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function setConfig(Msd_Config $config)
|
||||
{
|
||||
self::set('_config', $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the dynamic config if it has been registered.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @return Msd_Config_Dynamic|null
|
||||
*/
|
||||
public static function getDynamicConfig()
|
||||
{
|
||||
if (self::isRegistered('_dynamic')) {
|
||||
return self::get('_dynamic');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the dynamic configuration.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @param Msd_Config_Dynamic $config Dynamic configuration.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function setDynamicConfig(Msd_Config_Dynamic $config)
|
||||
{
|
||||
self::set('_dynamic', $config);
|
||||
}
|
||||
}
|
||||
|
|
@ -21,35 +21,35 @@ class Msd_User
|
|||
*
|
||||
* @var int
|
||||
*/
|
||||
const SUCCESS = 0x00;
|
||||
const SUCCESS = 0x00;
|
||||
|
||||
/**
|
||||
* There is no file with user identities and credentials.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const NO_USER_FILE = 0x01;
|
||||
const NO_USER_FILE = 0x01;
|
||||
|
||||
/**
|
||||
* The user file doesn't contain any valid user logins.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const NO_VALID_USER = 0x02;
|
||||
const NO_VALID_USER = 0x02;
|
||||
|
||||
/**
|
||||
* The given identity is unknown or the password is wrong.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const UNKNOWN_IDENTITY = 0x03;
|
||||
const UNKNOWN_IDENTITY = 0x03;
|
||||
|
||||
/**
|
||||
* An unknown error occured.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
const GENERAL_FAILURE = 0xFF;
|
||||
const GENERAL_FAILURE = 0xFF;
|
||||
|
||||
/**
|
||||
* Path and filename of the user ini file.
|
||||
|
|
@ -96,14 +96,13 @@ class Msd_User
|
|||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @return void
|
||||
* @return Msd_User
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->_usersFile = APPLICATION_PATH . DS . 'configs' . DS
|
||||
. 'users.ini';
|
||||
$this->_usersFile = APPLICATION_PATH . '/configs/users.ini';
|
||||
$this->_authStorage = new Zend_Auth_Storage_Session();
|
||||
$auth = $this->_authStorage->read();
|
||||
$auth = $this->_authStorage->read();
|
||||
if (!empty($auth)) {
|
||||
if (isset($auth['name'])) {
|
||||
$this->_userName = $auth['name'];
|
||||
|
|
@ -157,8 +156,8 @@ class Msd_User
|
|||
return self::NO_USER_FILE;
|
||||
}
|
||||
|
||||
$usersIni = new Msd_Ini($this->_usersFile);
|
||||
$users = $usersIni->getAll();
|
||||
$usersConfig = new Msd_Ini($this->_usersFile);
|
||||
$users = $usersConfig->get('user');
|
||||
|
||||
$hasValidUser = false;
|
||||
foreach ($users as $user) {
|
||||
|
|
@ -167,7 +166,6 @@ class Msd_User
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$hasValidUser) {
|
||||
return self::NO_VALID_USER;
|
||||
}
|
||||
|
|
@ -175,14 +173,14 @@ class Msd_User
|
|||
$authAdapter = new Msd_Auth_Adapter_Ini($this->_usersFile);
|
||||
$authAdapter->setUsername($username);
|
||||
$authAdapter->setPassword($password);
|
||||
$auth = Zend_Auth::getInstance();
|
||||
$authResult = $auth->authenticate($authAdapter);
|
||||
$auth = Zend_Auth::getInstance();
|
||||
$authResult = $auth->authenticate($authAdapter);
|
||||
$this->_authMessages = $authResult->getMessages();
|
||||
if ($authResult->isValid()) {
|
||||
$this->_isLoggedIn = true;
|
||||
if ($autoLogin) {
|
||||
Zend_Session::regenerateId();
|
||||
$crypt = Msd_Crypt::getInstance('MySQLDumper27112010');
|
||||
$crypt = Msd_Crypt::getInstance('MySQLDumper27112010');
|
||||
$identity = $crypt->encrypt(
|
||||
$username . ':' . $password
|
||||
);
|
||||
|
|
@ -204,7 +202,7 @@ class Msd_User
|
|||
private function _loginByCookie()
|
||||
{
|
||||
$request = Zend_Controller_Front::getInstance()->getRequest();
|
||||
$cookie = $request->get('msd_autologin');
|
||||
$cookie = $request->get('msd_autologin');
|
||||
if ($cookie === null || $cookie == '') {
|
||||
// no cookie found
|
||||
return false;
|
||||
|
|
@ -221,6 +219,7 @@ class Msd_User
|
|||
// to stay logged in until you logout.
|
||||
$this->login($username, $pass, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the user identity and logout the user.
|
||||
*
|
||||
|
|
@ -236,7 +235,7 @@ class Msd_User
|
|||
/**
|
||||
* Set default configuration for user
|
||||
*
|
||||
* @return void
|
||||
* @return void
|
||||
*/
|
||||
public function setDefaultConfiguration()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class Msd_Version
|
|||
* @param array $options Option-array to overwrite required PHP/MySQL
|
||||
* versions
|
||||
*
|
||||
* @return void
|
||||
* @return Msd_Version
|
||||
*/
|
||||
public function __construct($options = array())
|
||||
{
|
||||
|
|
|
|||
Laden …
Tabelle hinzufügen
Einen Link hinzufügen
In neuem Issue referenzieren