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
|
@ -35,15 +35,36 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Initialize configuration.
|
||||||
* Set Firebug_logger in registry
|
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function _initFirbugLogger()
|
public function _initConfiguration()
|
||||||
{
|
{
|
||||||
$writer = new Zend_Log_Writer_Firebug();
|
$dynamicConfig = new Msd_Config_Dynamic();
|
||||||
$logger = new Zend_Log($writer);
|
$configFile = $dynamicConfig->getParam('configFile', 'defaultConfig.ini');
|
||||||
Zend_Registry::set('logger', $logger);
|
$config = new Msd_Config(
|
||||||
|
'Default',
|
||||||
|
array('directories' => APPLICATION_PATH . '/configs')
|
||||||
|
);
|
||||||
|
$config->load($configFile);
|
||||||
|
Msd_Registry::setConfig($config);
|
||||||
|
|
||||||
|
Msd_Registry::setDynamicConfig($dynamicConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Un-quote a string or array
|
||||||
|
*
|
||||||
|
* @param string|array $value The value to strip
|
||||||
|
*
|
||||||
|
* @return string|array
|
||||||
|
*/
|
||||||
|
public static function stripslashes_deep($value)
|
||||||
|
{
|
||||||
|
$value = is_array($value) ? array_map('Bootstrap::stripslashes_deep', $value) : stripslashes($value);
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,19 +5,19 @@ phpSettings.error_reporting = E_ALL
|
||||||
phpSettings.default_charset = "UTF-8"
|
phpSettings.default_charset = "UTF-8"
|
||||||
phpSettings.date.timezone = "Europe/Berlin"
|
phpSettings.date.timezone = "Europe/Berlin"
|
||||||
phpSettings.magic_quotes_runtime = 0
|
phpSettings.magic_quotes_runtime = 0
|
||||||
includePaths.library = APPLICATION_PATH "" DS ".." DS "library"
|
includePaths.library = APPLICATION_PATH "/../library"
|
||||||
bootstrap.path = APPLICATION_PATH "" DS "Bootstrap.php"
|
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
|
||||||
bootstrap.class = "Bootstrap"
|
bootstrap.class = "Bootstrap"
|
||||||
appnamespace = "Application"
|
appnamespace = "Application"
|
||||||
resources.frontController.controllerDirectory = APPLICATION_PATH "" DS "controllers"
|
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
|
||||||
resources.frontController.moduleDirectory = APPLICATION_PATH "" DS "modules"
|
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
|
||||||
resources.frontController.params.displayExceptions = 0
|
resources.frontController.params.displayExceptions = 0
|
||||||
resources.view.basePath = APPLICATION_PATH "" DS "views"
|
resources.view.basePath = APPLICATION_PATH "/views"
|
||||||
resources.layout.layoutPath = APPLICATION_PATH "" DS "views" DS "layouts"
|
resources.layout.layoutPath = APPLICATION_PATH "/views/layouts"
|
||||||
resources.frontController.actionHelperPaths.Msd_Action_Helper = "Msd" DS "Action" DS "Helper" DS
|
resources.frontController.actionHelperPaths.Msd_Action_Helper = "Msd/Action/Helper/"
|
||||||
resources.view.encoding = "UTF-8"
|
resources.view.encoding = "UTF-8"
|
||||||
resources.view.helperPath.ZendX_JQuery_View_Helper = "ZendX/JQuery/View/Helper/"
|
resources.view.helperPath.ZendX_JQuery_View_Helper = "ZendX/JQuery/View/Helper/"
|
||||||
resources.view.helperPath.Msd_View_Helper = APPLICATION_PATH "" DS "views" DS "helpers"
|
resources.view.helperPath.Msd_View_Helper = APPLICATION_PATH "/views/helpers"
|
||||||
resources.view.doctype = XHTML1_STRICT
|
resources.view.doctype = XHTML1_STRICT
|
||||||
; setHelperPath plugin is no longer used, because the paths are set here.
|
; setHelperPath plugin is no longer used, because the paths are set here.
|
||||||
resources.frontController.plugins.loginCheck = "Application_Plugin_LoginCheck"
|
resources.frontController.plugins.loginCheck = "Application_Plugin_LoginCheck"
|
||||||
|
|
|
@ -9,4 +9,4 @@ request.params.a = "get_language_file"
|
||||||
request.params.v = ":version"
|
request.params.v = ":version"
|
||||||
request.params.l = ":language"
|
request.params.l = ":language"
|
||||||
request.sourceFileKey = "f"
|
request.sourceFileKey = "f"
|
||||||
targetBaseDir = APPLICATION_PATH "" DS "language"
|
targetBaseDir = APPLICATION_PATH "/language"
|
||||||
|
|
|
@ -55,11 +55,10 @@ class IndexController extends Zend_Controller_Action
|
||||||
'badversion',
|
'badversion',
|
||||||
'install',
|
'install',
|
||||||
'default',
|
'default',
|
||||||
array(
|
array('message' => 'L_PHP_VERSION_TOO_OLD')
|
||||||
'message' => 'L_PHP_VERSION_TOO_OLD'
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$dbo = Msd_Db::getAdapter();
|
$dbo = Msd_Db::getAdapter();
|
||||||
$data = Msd_File::getLatestBackupInfo();
|
$data = Msd_File::getLatestBackupInfo();
|
||||||
|
|
|
@ -108,8 +108,7 @@ class InstallController extends Zend_Controller_Action
|
||||||
$languagesStatus[$langId] = array(
|
$languagesStatus[$langId] = array(
|
||||||
'langName' => $langName,
|
'langName' => $langName,
|
||||||
'installed' => file_exists(
|
'installed' => file_exists(
|
||||||
APPLICATION_PATH . DS . 'language' .
|
APPLICATION_PATH . '/language/' . $langId . '/lang.php'
|
||||||
DS . $langId . DS . 'lang.php'
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -197,9 +196,9 @@ class InstallController extends Zend_Controller_Action
|
||||||
->setToken($postData['pass']);
|
->setToken($postData['pass']);
|
||||||
if ($form->isValid($postData)) {
|
if ($form->isValid($postData)) {
|
||||||
$ini = new Msd_Ini();
|
$ini = new Msd_Ini();
|
||||||
$ini->set('name', $postData['user'], '0');
|
$ini->set('name', $postData['user'], 'user');
|
||||||
$ini->set('pass', md5($postData['pass']), '0');
|
$ini->set('pass', md5($postData['pass']), 'user');
|
||||||
$ini->save(APPLICATION_PATH . DS . 'configs' . DS . 'users.ini');
|
$ini->saveFile(APPLICATION_PATH . '/configs/users.ini');
|
||||||
$redirectUrl = $this->view->url(array('controller' => 'install', 'action' => 'step4'), null, true);
|
$redirectUrl = $this->view->url(array('controller' => 'install', 'action' => 'step4'), null, true);
|
||||||
$this->_response->setRedirect($redirectUrl);
|
$this->_response->setRedirect($redirectUrl);
|
||||||
}
|
}
|
||||||
|
@ -288,8 +287,8 @@ class InstallController extends Zend_Controller_Action
|
||||||
$lang = Msd_Language::getInstance();
|
$lang = Msd_Language::getInstance();
|
||||||
$version = new Msd_Version();
|
$version = new Msd_Version();
|
||||||
$files = array(
|
$files = array(
|
||||||
'lang' => ':language' . DS . 'lang.php',
|
'lang' => ':language/lang.php',
|
||||||
'flag' => ':language' . DS . 'flag.gif'
|
'flag' => ':language/flag.gif'
|
||||||
);
|
);
|
||||||
if ($language === null) {
|
if ($language === null) {
|
||||||
if (!isset($_SESSION['langlist'])) {
|
if (!isset($_SESSION['langlist'])) {
|
||||||
|
@ -305,8 +304,7 @@ class InstallController extends Zend_Controller_Action
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$update = new Msd_Update(
|
$update = new Msd_Update(
|
||||||
APPLICATION_PATH . DS . 'configs' .
|
APPLICATION_PATH . '/configs/update.ini'
|
||||||
DS . 'update.ini'
|
|
||||||
);
|
);
|
||||||
$update->setUpdateParam('language', $language);
|
$update->setUpdateParam('language', $language);
|
||||||
$update->setUpdateParam('version', $version->getMsdVersion());
|
$update->setUpdateParam('version', $version->getMsdVersion());
|
||||||
|
|
|
@ -73,8 +73,8 @@ class Msd_View_Helper_GetIcon extends Zend_View_Helper_Abstract
|
||||||
if (!$icons) {
|
if (!$icons) {
|
||||||
$config = Msd_Configuration::getInstance();
|
$config = Msd_Configuration::getInstance();
|
||||||
$file = realpath(
|
$file = realpath(
|
||||||
APPLICATION_PATH . DS . '..' . DS . 'public'
|
APPLICATION_PATH . '/../public/'
|
||||||
. DS . $config->get('paths.iconpath') . DS . 'icon.ini'
|
. $config->get('paths.iconpath') . '/icon.ini'
|
||||||
);
|
);
|
||||||
$iconsIni = new Zend_Config_Ini($file, 'icons');
|
$iconsIni = new Zend_Config_Ini($file, 'icons');
|
||||||
$icons = $iconsIni->toArray();
|
$icons = $iconsIni->toArray();
|
||||||
|
|
|
@ -67,8 +67,8 @@ class Msd_View_Helper_GetIconSrc extends Zend_View_Helper_Abstract
|
||||||
if (!$icons) {
|
if (!$icons) {
|
||||||
$config = Msd_Configuration::getInstance();
|
$config = Msd_Configuration::getInstance();
|
||||||
$file = realpath(
|
$file = realpath(
|
||||||
APPLICATION_PATH . DS . '..' . DS . 'public'
|
APPLICATION_PATH . '/../public/'
|
||||||
. DS . $config->get('paths.iconpath') . DS .'icon.ini'
|
. $config->get('paths.iconpath') . '/icon.ini'
|
||||||
);
|
);
|
||||||
$iconsIni = new Zend_Config_Ini($file, 'icons');
|
$iconsIni = new Zend_Config_Ini($file, 'icons');
|
||||||
$icons = $iconsIni->toArray();
|
$icons = $iconsIni->toArray();
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
$currentLanguage = $this->language;
|
$currentLanguage = $this->language;
|
||||||
$fallbackLanguage = $currentLanguage;
|
$fallbackLanguage = $currentLanguage;
|
||||||
$languages = $this->languages;
|
$languages = $this->languages;
|
||||||
$baseLangFile = APPLICATION_PATH . DS . 'language' . DS . '%s' . DS . 'lang.php';
|
$baseLangFile = APPLICATION_PATH . '/language/%s/lang.php';
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function changeLang(lang)
|
function changeLang(lang)
|
||||||
|
|
|
@ -42,7 +42,9 @@ class Msd_Auth_Adapter_Ini implements Zend_Auth_Adapter_Interface
|
||||||
*
|
*
|
||||||
* @param string $iniFilename Filename for registered users
|
* @param string $iniFilename Filename for registered users
|
||||||
*
|
*
|
||||||
* @return void
|
* @throws Msd_Exception
|
||||||
|
*
|
||||||
|
* @return Msd_Auth_Adapter_Ini
|
||||||
*/
|
*/
|
||||||
public function __construct($iniFilename)
|
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.
|
* set the username, which is used for authentication.
|
||||||
*
|
*
|
||||||
|
* @param string $username The username
|
||||||
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setUsername($username)
|
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.
|
* Set the password, which is used for authentication.
|
||||||
*
|
*
|
||||||
|
* @param string $password The password
|
||||||
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setPassword($password)
|
public function setPassword($password)
|
||||||
|
@ -77,6 +83,8 @@ class Msd_Auth_Adapter_Ini implements Zend_Auth_Adapter_Interface
|
||||||
/**
|
/**
|
||||||
* Authenticate with the given credentials.
|
* Authenticate with the given credentials.
|
||||||
*
|
*
|
||||||
|
* @throws Msd_Exception
|
||||||
|
*
|
||||||
* @return Zend_Auth_Result
|
* @return Zend_Auth_Result
|
||||||
*/
|
*/
|
||||||
public function authenticate()
|
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(
|
$configWriter = new Zend_Config_Writer_Ini(
|
||||||
array(
|
array(
|
||||||
'filename' => $this->get('paths.config') . DS . $fileName,
|
'filename' => $this->get('paths.config') . '/' . $fileName,
|
||||||
'config' => $configData,
|
'config' => $configData,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -253,11 +253,10 @@ class Msd_Configuration
|
||||||
if ($configName != 'defaultConfig') {
|
if ($configName != 'defaultConfig') {
|
||||||
$configName .= '.ini';
|
$configName .= '.ini';
|
||||||
$configPath = $this->get('paths.config');
|
$configPath = $this->get('paths.config');
|
||||||
$configFile = $configPath . DS . $configName;
|
$configFile = $configPath . '/' . $configName;
|
||||||
} else {
|
} else {
|
||||||
// special case - defaultConfig.ini is in application/configs
|
// special case - defaultConfig.ini is in application/configs
|
||||||
$configFile = realpath(APPLICATION_PATH . DS . 'configs')
|
$configFile = realpath(APPLICATION_PATH . '/configs') . '/defaultConfig.ini';
|
||||||
. DS . 'defaultConfig.ini';
|
|
||||||
}
|
}
|
||||||
if (!is_readable($configFile)) {
|
if (!is_readable($configFile)) {
|
||||||
throw new Msd_Exception(
|
throw new Msd_Exception(
|
||||||
|
@ -286,7 +285,7 @@ class Msd_Configuration
|
||||||
private function _loadUserDirectories()
|
private function _loadUserDirectories()
|
||||||
{
|
{
|
||||||
// set paths
|
// set paths
|
||||||
$workRoot = realpath(APPLICATION_PATH . DS . '..') . DS . 'work' . DS;
|
$workRoot = realpath(APPLICATION_PATH . '/..') . '/work/';
|
||||||
$directories = array(
|
$directories = array(
|
||||||
'work' => $workRoot,
|
'work' => $workRoot,
|
||||||
'log' => $workRoot . 'log',
|
'log' => $workRoot . 'log',
|
||||||
|
|
|
@ -30,12 +30,19 @@ class Msd_Ini
|
||||||
*/
|
*/
|
||||||
private $_iniFilename = null;
|
private $_iniFilename = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines the escaping of the output.
|
||||||
|
*
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
private $_escapeIniOutput = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class constructor
|
* Class constructor
|
||||||
*
|
*
|
||||||
* @param array|string $options Configuration or filename of INI to load
|
* @param array|string $options Configuration or filename of INI to load
|
||||||
*
|
*
|
||||||
* @return void
|
* @return Msd_Ini
|
||||||
*/
|
*/
|
||||||
public function __construct($options = array())
|
public function __construct($options = array())
|
||||||
{
|
{
|
||||||
|
@ -60,6 +67,8 @@ class Msd_Ini
|
||||||
*
|
*
|
||||||
* @param string $filename Name of file to load
|
* @param string $filename Name of file to load
|
||||||
*
|
*
|
||||||
|
* @throws Msd_Exception
|
||||||
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function loadFile($filename = null)
|
public function loadFile($filename = null)
|
||||||
|
@ -82,9 +91,11 @@ class Msd_Ini
|
||||||
*
|
*
|
||||||
* @param string $filename Name of file to save
|
* @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) {
|
if ($filename === null) {
|
||||||
$filename = $this->_iniFilename;
|
$filename = $this->_iniFilename;
|
||||||
|
@ -94,20 +105,20 @@ class Msd_Ini
|
||||||
'You must specify a filename to save the INI!'
|
'You must specify a filename to save the INI!'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$fileHandle = fopen($filename, 'w+');
|
$res = file_put_contents($filename, (string) $this);
|
||||||
fwrite($fileHandle, (string) $this);
|
return $res === false ? false : true;
|
||||||
fclose($fileHandle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts an array into the INI file format.
|
* Converts an array into the INI file format.
|
||||||
*
|
*
|
||||||
* @param array $array Array to convert.
|
* @param array $array Array to convert.
|
||||||
* @param integer $level Current depthlevel in the array.
|
* @param integer $level Current depth level in the array.
|
||||||
|
* @param string $prefix Prefix to use for var name.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function _arrayToIniString($array = null, $level = -1)
|
private function _arrayToIniString($array = null, $level = -1, $prefix = '')
|
||||||
{
|
{
|
||||||
if ($array === null) {
|
if ($array === null) {
|
||||||
$array = $this->_iniData;
|
$array = $this->_iniData;
|
||||||
|
@ -116,18 +127,27 @@ class Msd_Ini
|
||||||
$resultString = '';
|
$resultString = '';
|
||||||
foreach ($array as $key => $value) {
|
foreach ($array as $key => $value) {
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
$resultString .= ($level == 0) ?
|
if ($level == 0) {
|
||||||
'[' . $key . ']' . "\n" :
|
$resultString .= '[' . $key . ']' . "\n";
|
||||||
$key . '.';
|
$resultString .= $this->_arrayToIniString($value, $level);
|
||||||
$resultString .= $this->_arrayToIniString($value);
|
} else {
|
||||||
|
$resultString .= $this->_arrayToIniString($value, $level, $key);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$newValue = str_replace(
|
$newValue = $value;
|
||||||
array('\\', '"'),
|
if ($this->_escapeIniOutput) {
|
||||||
array('\\\\', '\\"'),
|
$newValue = "\"" . str_replace(
|
||||||
$value
|
array('\\', '"'),
|
||||||
);
|
array('\\\\', '\\"'),
|
||||||
$resultString .= $key . ' = "' . (string) $newValue . '"';
|
$value
|
||||||
|
) . "\"";
|
||||||
|
}
|
||||||
|
|
||||||
|
$resultString .= ltrim("$prefix.$key", '.') . " = $newValue\n";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($level < 2) {
|
||||||
$resultString .= "\n";
|
$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.
|
* Convert this class into a string.
|
||||||
*
|
*
|
||||||
|
@ -189,4 +199,68 @@ class Msd_Ini
|
||||||
{
|
{
|
||||||
return $this->_arrayToIniString();
|
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)
|
public function loadLanguage($language)
|
||||||
{
|
{
|
||||||
$this->_baseLanguageDir = APPLICATION_PATH . DS . 'language' . DS;
|
$this->_baseLanguageDir = APPLICATION_PATH . '/language/';
|
||||||
$file = $this->_baseLanguageDir . $language . DS . 'lang.php';
|
$file = $this->_baseLanguageDir . $language . '/lang.php';
|
||||||
$translator = $this->getTranslator();
|
$translator = $this->getTranslator();
|
||||||
if ($translator === null) {
|
if ($translator === null) {
|
||||||
$translator = new Zend_Translate('array', $file, $language);
|
$translator = new Zend_Translate('array', $file, $language);
|
||||||
|
|
|
@ -145,16 +145,16 @@ class Msd_Log
|
||||||
$filename = '';
|
$filename = '';
|
||||||
switch ($file) {
|
switch ($file) {
|
||||||
case self::PHP:
|
case self::PHP:
|
||||||
$filename = $this->_paths->log . DS . 'php.log';
|
$filename = $this->_paths->log . '/php.log';
|
||||||
break;
|
break;
|
||||||
case self::PERL:
|
case self::PERL:
|
||||||
$filename = $this->_paths->log . DS . 'perl.log';
|
$filename = $this->_paths->log . '/perl.log';
|
||||||
break;
|
break;
|
||||||
case self::PERL_COMPLETE:
|
case self::PERL_COMPLETE:
|
||||||
$filename = $this->_paths->log . DS . 'perlComplete.log';
|
$filename = $this->_paths->log . '/perlComplete.log';
|
||||||
break;
|
break;
|
||||||
case self::ERROR:
|
case self::ERROR:
|
||||||
$filename = $this->_paths->log . DS . 'phpError.log';
|
$filename = $this->_paths->log . '/phpError.log';
|
||||||
}
|
}
|
||||||
return $filename;
|
return $filename;
|
||||||
}
|
}
|
||||||
|
@ -202,4 +202,4 @@ class Msd_Log
|
||||||
|
|
||||||
return $output;
|
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
|
* @var int
|
||||||
*/
|
*/
|
||||||
const SUCCESS = 0x00;
|
const SUCCESS = 0x00;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* There is no file with user identities and credentials.
|
* There is no file with user identities and credentials.
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
const NO_USER_FILE = 0x01;
|
const NO_USER_FILE = 0x01;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The user file doesn't contain any valid user logins.
|
* The user file doesn't contain any valid user logins.
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
const NO_VALID_USER = 0x02;
|
const NO_VALID_USER = 0x02;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The given identity is unknown or the password is wrong.
|
* The given identity is unknown or the password is wrong.
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
const UNKNOWN_IDENTITY = 0x03;
|
const UNKNOWN_IDENTITY = 0x03;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An unknown error occured.
|
* An unknown error occured.
|
||||||
*
|
*
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
const GENERAL_FAILURE = 0xFF;
|
const GENERAL_FAILURE = 0xFF;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Path and filename of the user ini file.
|
* Path and filename of the user ini file.
|
||||||
|
@ -96,14 +96,13 @@ class Msd_User
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @return void
|
* @return Msd_User
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->_usersFile = APPLICATION_PATH . DS . 'configs' . DS
|
$this->_usersFile = APPLICATION_PATH . '/configs/users.ini';
|
||||||
. 'users.ini';
|
|
||||||
$this->_authStorage = new Zend_Auth_Storage_Session();
|
$this->_authStorage = new Zend_Auth_Storage_Session();
|
||||||
$auth = $this->_authStorage->read();
|
$auth = $this->_authStorage->read();
|
||||||
if (!empty($auth)) {
|
if (!empty($auth)) {
|
||||||
if (isset($auth['name'])) {
|
if (isset($auth['name'])) {
|
||||||
$this->_userName = $auth['name'];
|
$this->_userName = $auth['name'];
|
||||||
|
@ -157,8 +156,8 @@ class Msd_User
|
||||||
return self::NO_USER_FILE;
|
return self::NO_USER_FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
$usersIni = new Msd_Ini($this->_usersFile);
|
$usersConfig = new Msd_Ini($this->_usersFile);
|
||||||
$users = $usersIni->getAll();
|
$users = $usersConfig->get('user');
|
||||||
|
|
||||||
$hasValidUser = false;
|
$hasValidUser = false;
|
||||||
foreach ($users as $user) {
|
foreach ($users as $user) {
|
||||||
|
@ -167,7 +166,6 @@ class Msd_User
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$hasValidUser) {
|
if (!$hasValidUser) {
|
||||||
return self::NO_VALID_USER;
|
return self::NO_VALID_USER;
|
||||||
}
|
}
|
||||||
|
@ -175,14 +173,14 @@ class Msd_User
|
||||||
$authAdapter = new Msd_Auth_Adapter_Ini($this->_usersFile);
|
$authAdapter = new Msd_Auth_Adapter_Ini($this->_usersFile);
|
||||||
$authAdapter->setUsername($username);
|
$authAdapter->setUsername($username);
|
||||||
$authAdapter->setPassword($password);
|
$authAdapter->setPassword($password);
|
||||||
$auth = Zend_Auth::getInstance();
|
$auth = Zend_Auth::getInstance();
|
||||||
$authResult = $auth->authenticate($authAdapter);
|
$authResult = $auth->authenticate($authAdapter);
|
||||||
$this->_authMessages = $authResult->getMessages();
|
$this->_authMessages = $authResult->getMessages();
|
||||||
if ($authResult->isValid()) {
|
if ($authResult->isValid()) {
|
||||||
$this->_isLoggedIn = true;
|
$this->_isLoggedIn = true;
|
||||||
if ($autoLogin) {
|
if ($autoLogin) {
|
||||||
Zend_Session::regenerateId();
|
Zend_Session::regenerateId();
|
||||||
$crypt = Msd_Crypt::getInstance('MySQLDumper27112010');
|
$crypt = Msd_Crypt::getInstance('MySQLDumper27112010');
|
||||||
$identity = $crypt->encrypt(
|
$identity = $crypt->encrypt(
|
||||||
$username . ':' . $password
|
$username . ':' . $password
|
||||||
);
|
);
|
||||||
|
@ -204,7 +202,7 @@ class Msd_User
|
||||||
private function _loginByCookie()
|
private function _loginByCookie()
|
||||||
{
|
{
|
||||||
$request = Zend_Controller_Front::getInstance()->getRequest();
|
$request = Zend_Controller_Front::getInstance()->getRequest();
|
||||||
$cookie = $request->get('msd_autologin');
|
$cookie = $request->get('msd_autologin');
|
||||||
if ($cookie === null || $cookie == '') {
|
if ($cookie === null || $cookie == '') {
|
||||||
// no cookie found
|
// no cookie found
|
||||||
return false;
|
return false;
|
||||||
|
@ -221,6 +219,7 @@ class Msd_User
|
||||||
// to stay logged in until you logout.
|
// to stay logged in until you logout.
|
||||||
$this->login($username, $pass, true);
|
$this->login($username, $pass, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear the user identity and logout the user.
|
* Clear the user identity and logout the user.
|
||||||
*
|
*
|
||||||
|
@ -236,7 +235,7 @@ class Msd_User
|
||||||
/**
|
/**
|
||||||
* Set default configuration for user
|
* Set default configuration for user
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setDefaultConfiguration()
|
public function setDefaultConfiguration()
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,7 +42,7 @@ class Msd_Version
|
||||||
* @param array $options Option-array to overwrite required PHP/MySQL
|
* @param array $options Option-array to overwrite required PHP/MySQL
|
||||||
* versions
|
* versions
|
||||||
*
|
*
|
||||||
* @return void
|
* @return Msd_Version
|
||||||
*/
|
*/
|
||||||
public function __construct($options = array())
|
public function __construct($options = array())
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,18 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
define('DS', DIRECTORY_SEPARATOR);
|
define('WORK_PATH', realpath(dirname(__FILE__) . '/../work'));
|
||||||
define('WORK_PATH', realpath(dirname(__FILE__) . DS. '..' . DS . 'work'));
|
|
||||||
|
|
||||||
// Define path to application directory
|
// Define path to application directory
|
||||||
defined('APPLICATION_PATH') || define(
|
defined('APPLICATION_PATH') || define(
|
||||||
'APPLICATION_PATH', realpath(
|
'APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application')
|
||||||
dirname(__FILE__) . DS . '..' . DS . 'application'
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
defined('LIBRARY_PATH') || define(
|
defined('LIBRARY_PATH') || define(
|
||||||
'LIBRARY_PATH', realpath(
|
'LIBRARY_PATH', realpath(dirname(__FILE__) . '/../library')
|
||||||
dirname(__FILE__) . DS . '..' . DS . 'library'
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Define application environment
|
// Define application environment
|
||||||
|
@ -28,11 +23,7 @@ if (!defined('APPLICATION_ENV')) {
|
||||||
|
|
||||||
// Ensure library/ is on include_path
|
// Ensure library/ is on include_path
|
||||||
set_include_path(
|
set_include_path(
|
||||||
implode(
|
implode(PATH_SEPARATOR, array(LIBRARY_PATH, get_include_path())
|
||||||
PATH_SEPARATOR, array(realpath(
|
|
||||||
APPLICATION_PATH . DS . '..' . DS .'library'
|
|
||||||
),
|
|
||||||
get_include_path())
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -47,7 +38,7 @@ require_once 'Zend/Application.php';
|
||||||
// Create application, bootstrap, and run
|
// Create application, bootstrap, and run
|
||||||
$application = new Zend_Application(
|
$application = new Zend_Application(
|
||||||
APPLICATION_ENV,
|
APPLICATION_ENV,
|
||||||
APPLICATION_PATH . DS . 'configs' . DS .'application.ini'
|
APPLICATION_PATH . '/configs/application.ini'
|
||||||
);
|
);
|
||||||
$application->bootstrap()
|
$application->bootstrap()
|
||||||
->run();
|
->run();
|
||||||
|
|
Laden …
In neuem Issue referenzieren