diff --git a/application/Bootstrap.php b/application/Bootstrap.php
index 3819ff1..039e67b 100644
--- a/application/Bootstrap.php
+++ b/application/Bootstrap.php
@@ -32,6 +32,12 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
Zend_Session::setOptions(array('strict' => true));
Zend_Session::start();
+
+ // check if server has magic quotes enabled and normalize params
+ if ( (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc() == 1)) {
+ $_POST = Bootstrap::stripslashes_deep($_POST);
+ }
+
}
/**
@@ -41,22 +47,15 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
*/
public function _initConfiguration()
{
- $dynamicConfig = Msd_Registry::getDynamicConfig();
- if ($dynamicConfig === null) {
- $dynamicConfig = new Msd_Config_Dynamic();
- Msd_Registry::setDynamicConfig($dynamicConfig);
- }
-
- $config = Msd_Registry::getConfig();
- if ($config === null) {
- $configFile = $dynamicConfig->getParam('configFile', 'defaultConfig.ini');
- $config = new Msd_Config(
- 'Default',
- array('directories' => APPLICATION_PATH . '/configs')
- );
- $config->load($configFile);
- }
+ $dynamicConfig = new Msd_Config_Dynamic();
+ $configFile = $dynamicConfig->getParam('configFile', 'mysqldumper.ini');
+ $config = new Msd_Config(
+ 'Default',
+ array('directories' => realpath(APPLICATION_PATH . '/../work/config'))
+ );
+ $config->load($configFile);
Msd_Registry::setConfig($config);
+ Msd_Registry::setDynamicConfig($dynamicConfig);
}
/**
@@ -72,5 +71,4 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
return $value;
}
-
}
diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php
index 822d1b2..0ca4ae7 100644
--- a/application/controllers/ConfigController.php
+++ b/application/controllers/ConfigController.php
@@ -254,10 +254,19 @@ class ConfigController extends Msd_Controller_Action
if (!empty($ftpConfig)) {
$index = max(array_keys($ftpConfig)) + 1;
}
- $default = $this->view->config->load('defaultConfig');
- $default = $default->toArray();
- $ftpConfig[$index] = $default['ftp'][0];
- $this->view->config->Param('ftp', $ftpConfig);
+ $default = array(
+ 'use' => "n",
+ 'timeout' => "10",
+ 'passiveMode' => "y",
+ 'ssl' => "n",
+ 'server' => "",
+ 'port' => "21",
+ 'user' => "",
+ 'pass' => "",
+ 'dir' => "/"
+ );
+ $ftpConfig[$index] = $default;
+ $this->view->config->setParam('ftp', $ftpConfig);
$this->_forward('index');
}
@@ -436,9 +445,8 @@ class ConfigController extends Msd_Controller_Action
} else {
$configData = $form->getValidValues($postData);
$configData = $this->_addNonConfigurableConfigParams($configData);
- $configValidator =
- new Application_Model_Config_FormValidator($configData);
- $configValidator->validate($this->view);
+ $configValidator = new Application_Model_Config_FormValidator($configData);
+ $configValidator->validateAndSaveConfig($this->view);
}
}
}
diff --git a/application/forms/Config/Ftp.php b/application/forms/Config/Ftp.php
index f17d529..efc7d04 100644
--- a/application/forms/Config/Ftp.php
+++ b/application/forms/Config/Ftp.php
@@ -42,7 +42,7 @@ class Application_Form_Config_Ftp extends Zend_Form_SubForm
$ftpConfig = $config->getParam('ftp');
$ftpKeys = array_keys($ftpConfig);
- $nrOfFtpProfiles = count($ftpKeys, 1);
+ $nrOfFtpProfiles = count($ftpKeys);
foreach ($ftpKeys as $ftpConnectionId) {
$this->_addRadioActivated($ftpConnectionId);
$this->_addInputTimeout($ftpConnectionId);
@@ -60,9 +60,7 @@ class Application_Form_Config_Ftp extends Zend_Form_SubForm
$this->_addButtonsTestAndDelete($ftpConnectionId, $buttonDelete);
- $legend = $this->_lang->getTranslator()->_('L_FTP_CONNECTION')
- . ' ' . ($ftpConnectionId + 1);
-
+ $legend = $this->_lang->getTranslator()->_('L_FTP_CONNECTION') . ' ' . ($ftpConnectionId + 1);
$this->addDisplayGroup(
array(
'ftp_' . $ftpConnectionId . '_use',
@@ -342,8 +340,8 @@ class Application_Form_Config_Ftp extends Zend_Form_SubForm
array(
'disableLoadDefaultDecorators' => true,
'content' =>
- $this->getView()->getIcon('delete') . ' ' .
- $this->_lang->getTranslator()->_('L_FTP_CONNECTION_DELETE'),
+ $this->getView()->getIcon('delete') . ' '
+ . $this->_lang->getTranslator()->_('L_FTP_CONNECTION_DELETE'),
'decorators' => array('LineEnd'),
'escape' => false,
'label' => '',
@@ -404,12 +402,14 @@ class Application_Form_Config_Ftp extends Zend_Form_SubForm
/**
* Set input default value
*
- * @param string $name
- * @param string $value
+ * @param string $name Var-Name
+ * @param string $value The Value to set
+ *
+ * @return Zend_Form
*/
public function setDefault($name, $value)
{
- $name = 'ftp_'.str_replace('.', '_', $name);
+ $name = 'ftp_' . str_replace('.', '_', $name);
parent::setDefault($name, $value);
}
}
diff --git a/application/models/Config/FormValidator.php b/application/models/Config/FormValidator.php
index 0007f84..7b20dc2 100644
--- a/application/models/Config/FormValidator.php
+++ b/application/models/Config/FormValidator.php
@@ -41,17 +41,17 @@ class Application_Model_Config_FormValidator
}
/**
- * Validate config data
+ * Validate config data and save when valid
*
* Checks database connection params.
* If connection is successfull the values are saved to the config file.
*
* @param Zend_View $view The view of the form for adding messages
*/
- public function validate(Zend_View $view)
+ public function validateAndSaveConfig(Zend_View $view)
{
$saveConfig = false;
- $config = $view->config;
+ $config = Msd_Registry::getConfig();
$translator = Msd_Language::getInstance()->getTranslator();
$db = Msd_Db::getAdapter($this->_configData['dbuser']);
try {
@@ -72,19 +72,21 @@ class Application_Model_Config_FormValidator
}
if ($saveConfig) {
- $config->save(
- $view->dynamicConfig->getParam('configFile'),
- $this->_configData
- );
+ $config->setConfig($this->_configData);
+ $saved = $config->save();
+ if ($saved === true) {
$view->popUpMessage()->addMessage(
'save-config',
'L_NOTICE',
- array('L_SAVE_SUCCESS', $view->dynamicConfig->getParam('configFile')),
+ array('L_SAVE_SUCCESS', $view->config->getParam('general.title')),
array(
'modal' => true,
'dialogClass' => 'notice'
)
);
+ } else {
+ die("Fehler beim Speichern der Konfiguration!");
+ }
}
}
}
diff --git a/application/views/helpers/GetIcon.php b/application/views/helpers/GetIcon.php
index da22517..e6ca85c 100644
--- a/application/views/helpers/GetIcon.php
+++ b/application/views/helpers/GetIcon.php
@@ -28,7 +28,6 @@ class Msd_View_Helper_GetIcon extends Zend_View_Helper_Abstract
*/
public function getIcon($name, $title='', $size='')
{
- //return true;
static $baseUrl = false;
if (!$baseUrl) {
$baseUrl = Zend_Controller_Front::getInstance()->getBaseUrl();
@@ -40,11 +39,12 @@ class Msd_View_Helper_GetIcon extends Zend_View_Helper_Abstract
);
}
$img = '';
+ $config = Msd_Registry::getConfig();
if ($size>'') {
$img = '';
$ret = sprintf(
$img,
- $this->view->config->getParam('paths.iconPath'),
+ $config->getParam('paths.iconPath'),
$size,
$size,
$icons[$name],
@@ -53,7 +53,7 @@ class Msd_View_Helper_GetIcon extends Zend_View_Helper_Abstract
} else {
$ret = sprintf(
$img,
- $this->view->config->getParam('paths.iconPath'),
+ $config->getParam('paths.iconPath'),
$icons[$name],
$title,
$title
diff --git a/application/views/scripts/config/databases.phtml b/application/views/scripts/config/databases.phtml
index c9f686e..e481bce 100644
--- a/application/views/scripts/config/databases.phtml
+++ b/application/views/scripts/config/databases.phtml
@@ -115,6 +115,7 @@ echo $this->partial(
array('databases' => $dbs,
'dbActual' => $this->dynamicConfig->getParam('dbActual'),
'parent' => $this,
+ 'lang' => $this->lang
)
);
?>
diff --git a/library/Msd/Config/Dynamic.php b/library/Msd/Config/Dynamic.php
index 0684508..3521d53 100644
--- a/library/Msd/Config/Dynamic.php
+++ b/library/Msd/Config/Dynamic.php
@@ -32,7 +32,7 @@ class Msd_Config_Dynamic
*/
public function __construct($sessionNsName = 'Dynamic')
{
- $this->_namespace = new Zend_Session_Namespace($sessionNsName);
+ $this->_namespace = new Zend_Session_Namespace($sessionNsName, true);
$this->getDynamicValues();
}
diff --git a/library/Msd/Config/IoHandler/Default.php b/library/Msd/Config/IoHandler/Default.php
index f9b7f35..0f252e7 100644
--- a/library/Msd/Config/IoHandler/Default.php
+++ b/library/Msd/Config/IoHandler/Default.php
@@ -81,7 +81,6 @@ class Msd_Config_IoHandler_Default implements Msd_Config_IoHandler_Interface
// Search for the config file in the given directories.
$this->_initIni();
$config = $this->_iniConfig->getIniData();
-
// Put configuration into session.
$this->_sessionNamespace->config = $config;
}
diff --git a/library/Msd/Form/Decorator/Abstract.php b/library/Msd/Form/Decorator/Abstract.php
index bf37ebf..b7ae6e8 100644
--- a/library/Msd/Form/Decorator/Abstract.php
+++ b/library/Msd/Form/Decorator/Abstract.php
@@ -49,10 +49,12 @@ abstract class Msd_Form_Decorator_Abstract extends Zend_Form_Decorator_Abstract
$element = $this->getElement();
$helper = $element->helper;
$value = $element->getValue();
+ /*
$translator = $element->getTranslator();
if ($translator !== null) {
$value = $translator->translate($value);
}
+ */
$ret = $element->getView()->$helper(
$element->getName(),
$value,
diff --git a/library/Msd/Registry.php b/library/Msd/Registry.php
index 06c55f2..c9a9fe2 100644
--- a/library/Msd/Registry.php
+++ b/library/Msd/Registry.php
@@ -9,7 +9,7 @@
* @author $Author$
*/
/**
- * Abstract decorator for form elements of Msd_Form
+ * Registry
*
* @package MySQLDumper
* @subpackage Registry
diff --git a/public/index.php b/public/index.php
index 3a57c87..e266602 100644
--- a/public/index.php
+++ b/public/index.php
@@ -2,13 +2,9 @@
define('WORK_PATH', realpath(dirname(__FILE__) . '/../work'));
// Define path to application directory
-defined('APPLICATION_PATH') || define(
-'APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application')
-);
+defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
-defined('LIBRARY_PATH') || define(
-'LIBRARY_PATH', realpath(dirname(__FILE__) . '/../library')
-);
+defined('LIBRARY_PATH') || define('LIBRARY_PATH', realpath(dirname(__FILE__) . '/../library'));
// Define application environment
if (!defined('APPLICATION_ENV')) {
@@ -28,13 +24,7 @@ if (APPLICATION_ENV == 'development' && !class_exists('Debug')) {
include_once 'Debug.php';
}
-
-/** Zend_Application */
require_once 'Zend/Application.php';
-
// Create application, bootstrap, and run
-$application = new Zend_Application(
- APPLICATION_ENV,
- APPLICATION_PATH . '/configs/application.ini'
-);
+$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
$application->bootstrap()->run();