MSD-19
- Changed old configuration to new class for installation - removed old classes
Dieser Commit ist enthalten in:
Ursprung
c0be3ce898
Commit
4a569043a6
18 geänderte Dateien mit 345 neuen und 753 gelöschten Zeilen
|
@ -47,12 +47,19 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
||||||
*/
|
*/
|
||||||
public function _initConfiguration()
|
public function _initConfiguration()
|
||||||
{
|
{
|
||||||
|
$dynamicConfig = Msd_Registry::getDynamicConfig();
|
||||||
|
if ($dynamicConfig === null) {
|
||||||
$dynamicConfig = new Msd_Config_Dynamic();
|
$dynamicConfig = new Msd_Config_Dynamic();
|
||||||
$configFile = $dynamicConfig->getParam('configFile', 'mysqldumper.ini');
|
}
|
||||||
|
$configFile = $dynamicConfig->getParam('configFile', 'defaultConfig.ini');
|
||||||
Msd_Registry::setConfigFilename($configFile);
|
Msd_Registry::setConfigFilename($configFile);
|
||||||
$config = new Msd_Config(
|
$config = new Msd_Config(
|
||||||
'Default',
|
'Default',
|
||||||
array('directories' => realpath(APPLICATION_PATH . '/../work/config'))
|
array('directories' => array(
|
||||||
|
realpath(APPLICATION_PATH . '/../work/config'),
|
||||||
|
realpath(APPLICATION_PATH . '/configs')
|
||||||
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
$config->load($configFile);
|
$config->load($configFile);
|
||||||
Msd_Registry::setConfig($config);
|
Msd_Registry::setConfig($config);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
[general]
|
[general]
|
||||||
|
title = "MySQLDumper"
|
||||||
mode = "easy"
|
mode = "easy"
|
||||||
logMaxsize = "1048576"
|
logMaxsize = "1048576"
|
||||||
logUnit = "kb"
|
logUnit = "kb"
|
||||||
|
@ -7,11 +8,17 @@ maxspeed = "10000"
|
||||||
gzip = "y"
|
gzip = "y"
|
||||||
multipart = "n"
|
multipart = "n"
|
||||||
multipartSize = ""
|
multipartSize = ""
|
||||||
multipartSizeUnit = "kb"
|
|
||||||
optimize = "n"
|
optimize = "n"
|
||||||
errorHandling = "s"
|
errorHandling = "s"
|
||||||
dbDelete = "n"
|
dbDelete = "n"
|
||||||
title = "defaultConfig"
|
|
||||||
|
[dbuser]
|
||||||
|
user = "root"
|
||||||
|
pass = ""
|
||||||
|
host = "localhost"
|
||||||
|
defaultDb = "otrance"
|
||||||
|
port = ""
|
||||||
|
socket = ""
|
||||||
|
|
||||||
[autodelete]
|
[autodelete]
|
||||||
Activated = "n"
|
Activated = "n"
|
||||||
|
@ -25,8 +32,11 @@ RecipientAddress = ""
|
||||||
RecipientName = ""
|
RecipientName = ""
|
||||||
attachBackup = "n"
|
attachBackup = "n"
|
||||||
Maxsize = ""
|
Maxsize = ""
|
||||||
MaxsizeUnit = "kb"
|
SendmailCall = ""
|
||||||
Program = "php"
|
SMTPHost = ""
|
||||||
|
SMTPPort = ""
|
||||||
|
SMTPUser = ""
|
||||||
|
SMTPPassword = ""
|
||||||
|
|
||||||
[ftp]
|
[ftp]
|
||||||
0.use = "n"
|
0.use = "n"
|
||||||
|
@ -38,6 +48,15 @@ Program = "php"
|
||||||
0.user = ""
|
0.user = ""
|
||||||
0.pass = ""
|
0.pass = ""
|
||||||
0.dir = "/"
|
0.dir = "/"
|
||||||
|
1.use = "n"
|
||||||
|
1.timeout = "10"
|
||||||
|
1.passiveMode = "y"
|
||||||
|
1.ssl = "n"
|
||||||
|
1.server = ""
|
||||||
|
1.port = "21"
|
||||||
|
1.user = ""
|
||||||
|
1.pass = ""
|
||||||
|
1.dir = "/"
|
||||||
|
|
||||||
[cronscript]
|
[cronscript]
|
||||||
perlExtension = "pl"
|
perlExtension = "pl"
|
||||||
|
@ -47,7 +66,7 @@ perlTextOutputComplete = "y"
|
||||||
perlFileComment = ""
|
perlFileComment = ""
|
||||||
|
|
||||||
[interface]
|
[interface]
|
||||||
language = "de"
|
language = "en"
|
||||||
theme = "msd"
|
theme = "msd"
|
||||||
notificationWindowPosition = "middleCenter"
|
notificationWindowPosition = "middleCenter"
|
||||||
showServerCaption = "y"
|
showServerCaption = "y"
|
||||||
|
@ -57,15 +76,15 @@ recordsPerPage = "50"
|
||||||
sqlbrowserViewMode = "compact"
|
sqlbrowserViewMode = "compact"
|
||||||
refreshProcesslist = "3"
|
refreshProcesslist = "3"
|
||||||
|
|
||||||
[dbuser]
|
|
||||||
host = "localhost"
|
|
||||||
user = "root"
|
|
||||||
pass = ""
|
|
||||||
manual = ""
|
|
||||||
port = ""
|
|
||||||
socket = ""
|
|
||||||
defaultDb = "information_schema"
|
|
||||||
|
|
||||||
[systemDatabases]
|
[systemDatabases]
|
||||||
0 = "mysql"
|
0 = "mysql"
|
||||||
1 = "information_schema"
|
1 = "information_schema"
|
||||||
|
|
||||||
|
[paths]
|
||||||
|
work = "E:\\PHP\\msd2/work/"
|
||||||
|
log = "E:\\PHP\\msd2/work/log"
|
||||||
|
backup = "E:\\PHP\\msd2/work/backup"
|
||||||
|
config = "E:\\PHP\\msd2/work/config"
|
||||||
|
iconPath = "css/msd/icons"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -215,7 +215,7 @@ class ConfigController extends Msd_Controller_Action
|
||||||
*/
|
*/
|
||||||
public function addRecipientCcAction()
|
public function addRecipientCcAction()
|
||||||
{
|
{
|
||||||
$recipientsCc = $this->_config->Param('email.RecipientCc');
|
$recipientsCc = $this->_config->getParam('email.RecipientCc');
|
||||||
if ($recipientsCc === null) {
|
if ($recipientsCc === null) {
|
||||||
$recipientsCc = array();
|
$recipientsCc = array();
|
||||||
}
|
}
|
||||||
|
@ -286,6 +286,7 @@ class ConfigController extends Msd_Controller_Action
|
||||||
sort($ftpConfig);
|
sort($ftpConfig);
|
||||||
}
|
}
|
||||||
$this->_config->setParam('ftp', $ftpConfig);
|
$this->_config->setParam('ftp', $ftpConfig);
|
||||||
|
//$this->_config->save();
|
||||||
}
|
}
|
||||||
$this->_forward('index');
|
$this->_forward('index');
|
||||||
}
|
}
|
||||||
|
@ -410,6 +411,7 @@ class ConfigController extends Msd_Controller_Action
|
||||||
$value = $this->_config->getParam($group . '.' . $element);
|
$value = $this->_config->getParam($group . '.' . $element);
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
list (, $key) = explode('.', $element);
|
list (, $key) = explode('.', $element);
|
||||||
|
$value[$key] = isset($value[$key]) ? $value[$key] : '';
|
||||||
$subForm->setDefault($element, $value[$key]);
|
$subForm->setDefault($element, $value[$key]);
|
||||||
} else if ($value !== null) {
|
} else if ($value !== null) {
|
||||||
$subForm->setDefault($element, $value);
|
$subForm->setDefault($element, $value);
|
||||||
|
|
|
@ -58,7 +58,6 @@ class IndexController extends Msd_Controller_Action
|
||||||
array('message' => 'L_PHP_VERSION_TOO_OLD')
|
array('message' => 'L_PHP_VERSION_TOO_OLD')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$dbo = Msd_Db::getAdapter();
|
$dbo = Msd_Db::getAdapter();
|
||||||
$data = Msd_File::getLatestBackupInfo();
|
$data = Msd_File::getLatestBackupInfo();
|
||||||
|
|
|
@ -16,8 +16,22 @@
|
||||||
* @package MySQLDumper
|
* @package MySQLDumper
|
||||||
* @subpackage Controllers
|
* @subpackage Controllers
|
||||||
*/
|
*/
|
||||||
class InstallController extends Zend_Controller_Action
|
class InstallController extends Msd_Controller_Action
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var Msd_Config
|
||||||
|
*/
|
||||||
|
public $config;
|
||||||
|
/**
|
||||||
|
* @var Msd_DynamicConfig
|
||||||
|
*/
|
||||||
|
public $dynamicConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Msd_Language
|
||||||
|
*/
|
||||||
|
public $lang;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init controller
|
* Init controller
|
||||||
*
|
*
|
||||||
|
@ -29,10 +43,7 @@ class InstallController extends Zend_Controller_Action
|
||||||
$layout->setLayout('install');
|
$layout->setLayout('install');
|
||||||
$this->version = new Msd_Version();
|
$this->version = new Msd_Version();
|
||||||
$_SESSION['msd_install'] = true;
|
$_SESSION['msd_install'] = true;
|
||||||
if (
|
if ($this->_request->getActionName() != 'badversion!' && !$this->version->checkPhpVersion()) {
|
||||||
$this->_request->getActionName() != 'badversion!' &&
|
|
||||||
!$this->version->checkPhpVersion()
|
|
||||||
) {
|
|
||||||
$this->_forward(
|
$this->_forward(
|
||||||
'badversion',
|
'badversion',
|
||||||
'install',
|
'install',
|
||||||
|
@ -42,8 +53,16 @@ class InstallController extends Zend_Controller_Action
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$config = Msd_Configuration::getInstance('defaultConfig');
|
$this->_config->setParam('interface.theme', 'msd');
|
||||||
$config->set('config.interface.theme', 'msd');
|
$this->_config->setParam('paths.iconPath', 'css/msd/icons');
|
||||||
|
$this->_config->setParam('configFile', 'mysqldumper.ini');
|
||||||
|
$this->view->config = $this->_config;
|
||||||
|
$lang = $_SESSION['msd_lang'];
|
||||||
|
if ($lang == '') {
|
||||||
|
$lang = 'en';
|
||||||
|
}
|
||||||
|
$translator = Msd_Language::getInstance();
|
||||||
|
$this->view->lang = $translator->loadLanguage($lang);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,28 +72,24 @@ class InstallController extends Zend_Controller_Action
|
||||||
*/
|
*/
|
||||||
public function indexAction()
|
public function indexAction()
|
||||||
{
|
{
|
||||||
// delete cookie from further installation if present
|
// delete cookie from further installation if present to not import old values
|
||||||
// to not import old values
|
|
||||||
if (isset($_SESSION['msd_autologin'])) {
|
if (isset($_SESSION['msd_autologin'])) {
|
||||||
setcookie('msd_autologin', null, null, '/');
|
setcookie('msd_autologin', null, null, '/');
|
||||||
$_SESSION['msd_autologin'] = array();
|
$_SESSION['msd_autologin'] = array();
|
||||||
}
|
}
|
||||||
Zend_Session_Namespace::resetSingleInstance('MySQLDumper');
|
Zend_Session_Namespace::resetSingleInstance('MySQLDumper');
|
||||||
$config = Msd_Configuration::getInstance('defaultConfig', true);
|
|
||||||
$lang = Msd_Language::getInstance();
|
|
||||||
if ($this->_request->isPost()) {
|
if ($this->_request->isPost()) {
|
||||||
$language = $this->_getParam('language');
|
$language = $this->_getParam('language');
|
||||||
$config->set('config.interface.language', $language);
|
$this->_config->setParam('interface.language', $language);
|
||||||
$config->set('dynamic.configFile', 'mysqldumper');
|
$this->_config->setParam('general.title', 'MySQLDumper');
|
||||||
$config->set('config.general.title', 'MySQLDumper');
|
$this->_config->setParam('configFile', 'mysqldumper.ini');
|
||||||
$config->saveConfigToSession();
|
|
||||||
$_SESSION['msd_lang'] = $language;
|
$_SESSION['msd_lang'] = $language;
|
||||||
$redirectUrl = $this->view->url(array('controller' => 'install', 'action' => 'step2'), null, true);
|
$redirectUrl = $this->view->url(array('controller' => 'install', 'action' => 'step2'), null, true);
|
||||||
$this->_response->setRedirect($redirectUrl);
|
$this->_response->setRedirect($redirectUrl);
|
||||||
}
|
}
|
||||||
// set selected languge
|
// set selected languge
|
||||||
$language = $this->_getParam('language', null);
|
$language = $this->_getParam('language', null);
|
||||||
$languages = $lang->getAvailableLanguages();
|
$languages = $this->_lang->getAvailableLanguages();
|
||||||
|
|
||||||
// check user browser language
|
// check user browser language
|
||||||
$locale = new Zend_Locale();
|
$locale = new Zend_Locale();
|
||||||
|
@ -100,7 +115,7 @@ class InstallController extends Zend_Controller_Action
|
||||||
'language' => $language,
|
'language' => $language,
|
||||||
'stepInfo' => array(
|
'stepInfo' => array(
|
||||||
'number' => 1,
|
'number' => 1,
|
||||||
'description' => $lang->getTranslator()
|
'description' => $this->_lang->getTranslator()
|
||||||
->_('L_SELECT_LANGUAGE')
|
->_('L_SELECT_LANGUAGE')
|
||||||
. ' (' . $language . ')'));
|
. ' (' . $language . ')'));
|
||||||
$languagesStatus = array();
|
$languagesStatus = array();
|
||||||
|
@ -112,9 +127,11 @@ class InstallController extends Zend_Controller_Action
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$config->set('config.interface.language', $language);
|
$this->_config->setParam('interface.language', $language);
|
||||||
$this->view->languages = $languagesStatus;
|
$this->view->languages = $languagesStatus;
|
||||||
$this->view->lang = $lang;
|
$this->view->lang = Msd_Language::getInstance();
|
||||||
|
Msd_Registry::setConfig($this->_config);
|
||||||
|
$this->view->config = Msd_Registry::getConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -126,24 +143,22 @@ class InstallController extends Zend_Controller_Action
|
||||||
*/
|
*/
|
||||||
public function step2Action()
|
public function step2Action()
|
||||||
{
|
{
|
||||||
$lang = Msd_Language::getInstance();
|
$language = $this->_config->getParam('interface.language');
|
||||||
$config = Msd_Configuration::getInstance();
|
|
||||||
$language = $config->get('config.interface.language');
|
|
||||||
$this->view->stepInfo = array(
|
$this->view->stepInfo = array(
|
||||||
'language' => $language,
|
'language' => $language,
|
||||||
'firstStepOK' => true,
|
'firstStepOK' => true,
|
||||||
'stepInfo' => array(
|
'stepInfo' => array(
|
||||||
'number' => 2,
|
'number' => 2,
|
||||||
'description' => $lang->getTranslator()->_('L_CHECK_DIRS'),
|
'description' => $this->_lang->getTranslator()->_('L_CHECK_DIRS'),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$creationStatus = array();
|
$creationStatus = array();
|
||||||
$checkDirs = array(
|
$checkDirs = array(
|
||||||
'work' => $config->get('paths.work'),
|
'work' => $this->_config->getParam('paths.work'),
|
||||||
'config' => $config->get('paths.config'),
|
'config' => $this->_config->getParam('paths.config'),
|
||||||
'log' => $config->get('paths.log'),
|
'log' => $this->_config->getParam('paths.log'),
|
||||||
'backup' => $config->get('paths.backup'),
|
'backup' => $this->_config->getParam('paths.backup'),
|
||||||
'iconpath' => $config->get('paths.iconPath')
|
'iconpath' => $this->_config->getParam('paths.iconPath')
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($checkDirs as $checkDir) {
|
foreach ($checkDirs as $checkDir) {
|
||||||
|
@ -162,12 +177,11 @@ class InstallController extends Zend_Controller_Action
|
||||||
$this->view->status = $creationStatus;
|
$this->view->status = $creationStatus;
|
||||||
}
|
}
|
||||||
if (!in_array(false, $creationStatus)) {
|
if (!in_array(false, $creationStatus)) {
|
||||||
$config->set('dynamic.configFile', 'mysqldumper');
|
$this->_config->setParam('configFile', 'mysqldumper');
|
||||||
$config->saveConfigToSession();
|
//$this->_config->save();
|
||||||
$redirectUrl = $this->view->url(array('controller' => 'install', 'action' => 'step3'), null, true);
|
$redirectUrl = $this->view->url(array('controller' => 'install', 'action' => 'step3'), null, true);
|
||||||
$this->_response->setRedirect($redirectUrl);
|
$this->_response->setRedirect($redirectUrl);
|
||||||
}
|
}
|
||||||
$this->view->lang = $lang;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -177,9 +191,7 @@ class InstallController extends Zend_Controller_Action
|
||||||
*/
|
*/
|
||||||
public function step3Action()
|
public function step3Action()
|
||||||
{
|
{
|
||||||
$lang = Msd_Language::getInstance();
|
$language = $this->_config->getParam('interface.language');
|
||||||
$config = Msd_Configuration::getInstance();
|
|
||||||
$language = $config->get('config.interface.language');
|
|
||||||
$form = new Application_Form_Install_User();
|
$form = new Application_Form_Install_User();
|
||||||
$this->view->stepInfo = array(
|
$this->view->stepInfo = array(
|
||||||
'language' => $language,
|
'language' => $language,
|
||||||
|
@ -187,13 +199,12 @@ class InstallController extends Zend_Controller_Action
|
||||||
'secondStepOK' => true,
|
'secondStepOK' => true,
|
||||||
'stepInfo' => array(
|
'stepInfo' => array(
|
||||||
'number' => 3,
|
'number' => 3,
|
||||||
'description' => $lang->getTranslator()->_('L_AUTHENTICATE'),
|
'description' => $this->_lang->getTranslator()->_('L_AUTHENTICATE'),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
if ($this->_request->isPost()) {
|
if ($this->_request->isPost()) {
|
||||||
$postData = $this->_request->getParams();
|
$postData = $this->_request->getParams();
|
||||||
$form->getElement('pass_confirm')->getValidator('Identical')
|
$form->getElement('pass_confirm')->getValidator('Identical')->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'], 'user');
|
$ini->set('name', $postData['user'], 'user');
|
||||||
|
@ -204,7 +215,7 @@ class InstallController extends Zend_Controller_Action
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->view->form = $form;
|
$this->view->form = $form;
|
||||||
$this->view->lang = $lang;
|
$this->view->lang = Msd_Language::getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -214,9 +225,7 @@ class InstallController extends Zend_Controller_Action
|
||||||
*/
|
*/
|
||||||
public function step4Action()
|
public function step4Action()
|
||||||
{
|
{
|
||||||
$lang = Msd_Language::getInstance();
|
$language = $this->_config->getParam('interface.language');
|
||||||
$config = Msd_Configuration::getInstance();
|
|
||||||
$language = $config->get('config.interface.language');
|
|
||||||
$this->view->stepInfo = array(
|
$this->view->stepInfo = array(
|
||||||
'language' => $language,
|
'language' => $language,
|
||||||
'firstStepOK' => true,
|
'firstStepOK' => true,
|
||||||
|
@ -224,7 +233,7 @@ class InstallController extends Zend_Controller_Action
|
||||||
'thirdStepOK' => true,
|
'thirdStepOK' => true,
|
||||||
'stepInfo' => array(
|
'stepInfo' => array(
|
||||||
'number' => 4,
|
'number' => 4,
|
||||||
'description' => $lang->getTranslator()->_('L_DBPARAMETER'),
|
'description' => $this->_lang->getTranslator()->_('L_DBPARAMETER'),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -237,22 +246,12 @@ class InstallController extends Zend_Controller_Action
|
||||||
'port' => $this->_getParam('port'),
|
'port' => $this->_getParam('port'),
|
||||||
'socket' => $this->_getParam('socket'),
|
'socket' => $this->_getParam('socket'),
|
||||||
);
|
);
|
||||||
$saveParam = $this->_getParam('save');
|
|
||||||
$config->set('config.dbuser', $options);
|
|
||||||
if ($saveParam !== null && $saveParam == 1) {
|
|
||||||
$config->set('config.general.title', 'MySQLDumper');
|
|
||||||
$config->set('config.dbuser.defaultDb', $this->_getParam('defaultDb'));
|
|
||||||
$config->save('mysqldumper');
|
|
||||||
unset($_SESSION['msd_lang']);
|
|
||||||
unset($_SESSION['msd_install']);
|
|
||||||
$redirectUrl = $this->view->url(array('controller' => 'index', 'action' => 'index', null, true));
|
|
||||||
$this->_response->setRedirect($redirectUrl);
|
|
||||||
} else {
|
|
||||||
$dbAdapter = Msd_Db::getAdapter($options);
|
$dbAdapter = Msd_Db::getAdapter($options);
|
||||||
try {
|
try {
|
||||||
$this->view->databases = $dbAdapter->getDatabaseNames();
|
$this->view->databases = $dbAdapter->getDatabaseNames();
|
||||||
$this->view->success = true;
|
$this->view->success = true;
|
||||||
$config->set('config.dbuser', $options);
|
$this->_config->setParam('dbuser', $options);
|
||||||
if (!$this->version->checkMysqlVersion()) {
|
if (!$this->version->checkMysqlVersion()) {
|
||||||
$this->_forward(
|
$this->_forward(
|
||||||
'badversion',
|
'badversion',
|
||||||
|
@ -263,15 +262,25 @@ class InstallController extends Zend_Controller_Action
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$config->saveConfigToSession();
|
|
||||||
} catch (Msd_Exception $e) {
|
} catch (Msd_Exception $e) {
|
||||||
$this->view->errorMessage = $e->getMessage();
|
$this->view->errorMessage = $e->getMessage();
|
||||||
$this->view->success = false;
|
$this->view->success = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$saveParam = $this->_getParam('save');
|
||||||
|
$this->_config->setParam('dbuser', $options);
|
||||||
|
if ($saveParam !== null && $saveParam == 1) {
|
||||||
|
$this->_config->setParam('general.title', 'MySQLDumper');
|
||||||
|
$this->_config->setParam('dbuser.defaultDb', $this->_getParam('defaultDb'));
|
||||||
|
$this->_config->save('mysqldumper.ini');
|
||||||
|
unset($_SESSION['msd_lang']);
|
||||||
|
unset($_SESSION['msd_install']);
|
||||||
|
$redirectUrl = $this->view->url(array('controller' => 'index', 'action' => 'index', null, true));
|
||||||
|
$this->_response->setRedirect($redirectUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->view->lang = $lang;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ajax action for loading language packs
|
* Ajax action for loading language packs
|
||||||
|
@ -284,7 +293,6 @@ class InstallController extends Zend_Controller_Action
|
||||||
Zend_Controller_Front::getInstance()->setParam('noViewRenderer', true);
|
Zend_Controller_Front::getInstance()->setParam('noViewRenderer', true);
|
||||||
$this->_response->setHeader('Content-Type', 'text/javascript');
|
$this->_response->setHeader('Content-Type', 'text/javascript');
|
||||||
$language = $this->_request->getParam('lang');
|
$language = $this->_request->getParam('lang');
|
||||||
$lang = Msd_Language::getInstance();
|
|
||||||
$version = new Msd_Version();
|
$version = new Msd_Version();
|
||||||
$files = array(
|
$files = array(
|
||||||
'lang' => ':language/lang.php',
|
'lang' => ':language/lang.php',
|
||||||
|
@ -292,7 +300,7 @@ class InstallController extends Zend_Controller_Action
|
||||||
);
|
);
|
||||||
if ($language === null) {
|
if ($language === null) {
|
||||||
if (!isset($_SESSION['langlist'])) {
|
if (!isset($_SESSION['langlist'])) {
|
||||||
$languages = $lang->getAvailableLanguages();
|
$languages = $this->_lang->getAvailableLanguages();
|
||||||
$_SESSION['langlist'] = array_keys($languages);
|
$_SESSION['langlist'] = array_keys($languages);
|
||||||
}
|
}
|
||||||
rsort($_SESSION['langlist']);
|
rsort($_SESSION['langlist']);
|
||||||
|
@ -303,9 +311,7 @@ class InstallController extends Zend_Controller_Action
|
||||||
echo json_encode('done');
|
echo json_encode('done');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$update = new Msd_Update(
|
$update = new Msd_Update(APPLICATION_PATH . '/configs/update.ini');
|
||||||
APPLICATION_PATH . '/configs/update.ini'
|
|
||||||
);
|
|
||||||
$update->setUpdateParam('language', $language);
|
$update->setUpdateParam('language', $language);
|
||||||
$update->setUpdateParam('version', $version->getMsdVersion());
|
$update->setUpdateParam('version', $version->getMsdVersion());
|
||||||
$updateResult = $update->doUpdate('language', $files);
|
$updateResult = $update->doUpdate('language', $files);
|
||||||
|
|
|
@ -90,8 +90,7 @@ class SqlServerController extends Msd_Controller_Action
|
||||||
public function showProcesslistAction()
|
public function showProcesslistAction()
|
||||||
{
|
{
|
||||||
$this->getProcesslistAction(false);
|
$this->getProcesslistAction(false);
|
||||||
$interval = $this->view->config
|
$interval = $this->view->config->getParam('interface.refreshProcesslist');
|
||||||
->get('config.interface.refreshProcesslist');
|
|
||||||
if ($interval < 2) {
|
if ($interval < 2) {
|
||||||
$interval = 2;
|
$interval = 2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ class Application_Form_Config_Email extends Zend_Form_SubForm
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration
|
* Configuration
|
||||||
* @var Msd_Configuration
|
* @var Msd_Config
|
||||||
*/
|
*/
|
||||||
protected $_config;
|
protected $_config;
|
||||||
|
|
||||||
|
@ -596,7 +596,7 @@ class Application_Form_Config_Email extends Zend_Form_SubForm
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param string $value
|
* @param string $value
|
||||||
*
|
*
|
||||||
* @return void
|
* @return Zend_Form
|
||||||
*/
|
*/
|
||||||
public function setDefault($name, $value)
|
public function setDefault($name, $value)
|
||||||
{
|
{
|
||||||
|
|
|
@ -329,8 +329,7 @@ class Application_Form_Config_Ftp extends Zend_Form_SubForm
|
||||||
'escape' => false,
|
'escape' => false,
|
||||||
'label' => '',
|
'label' => '',
|
||||||
'class' => 'Formbutton ftpToggle' . $index,
|
'class' => 'Formbutton ftpToggle' . $index,
|
||||||
'onclick' => "testFtpConnection(" .
|
'onclick' => "testFtpConnection(" . $index . ");",
|
||||||
$index . ");",
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -346,8 +345,7 @@ class Application_Form_Config_Ftp extends Zend_Form_SubForm
|
||||||
'escape' => false,
|
'escape' => false,
|
||||||
'label' => '',
|
'label' => '',
|
||||||
'class' => 'Formbutton',
|
'class' => 'Formbutton',
|
||||||
'onclick' => "deleteFtpConnection(" .
|
'onclick' => "deleteFtpConnection(" . $index . ");",
|
||||||
$index . ");",
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -361,19 +359,21 @@ class Application_Form_Config_Ftp extends Zend_Form_SubForm
|
||||||
*/
|
*/
|
||||||
public function getValidValues($data)
|
public function getValidValues($data)
|
||||||
{
|
{
|
||||||
$values = parent::getValidValues($data, true);
|
//$values = parent::getValidValues($data, true);
|
||||||
while (false !== (list($key, $value) = each($values))) {
|
$ftpData = array();
|
||||||
|
foreach ($data as $key => $value) {
|
||||||
if (substr($key, 0, 4) != 'ftp_') {
|
if (substr($key, 0, 4) != 'ftp_') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
list(, $ftpId, $ftpKey) = explode('_', $key);
|
list(, $ftpId, $ftpKey) = explode('_', $key);
|
||||||
if (!isset($values[$ftpId])) {
|
if (!isset($ftpData[$ftpId])) {
|
||||||
$values[$ftpId] = array();
|
$ftpData[$ftpId] = array();
|
||||||
}
|
}
|
||||||
$values[$ftpId][$ftpKey] = $value;
|
$ftpData[$ftpId][$ftpKey] = $value;
|
||||||
unset($values[$key]);
|
//unset($values[$key]);
|
||||||
}
|
}
|
||||||
return $values;
|
//var_dump($ftpData); die();
|
||||||
|
return $ftpData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -409,9 +409,6 @@ class Application_Form_Config_Ftp extends Zend_Form_SubForm
|
||||||
*/
|
*/
|
||||||
public function setDefault($name, $value)
|
public function setDefault($name, $value)
|
||||||
{
|
{
|
||||||
if (is_array($value)) {
|
|
||||||
list($ftpId, $key) = explode('.', $name);
|
|
||||||
}
|
|
||||||
$name = 'ftp_' . str_replace('.', '_', $name);
|
$name = 'ftp_' . str_replace('.', '_', $name);
|
||||||
parent::setDefault($name, $value);
|
parent::setDefault($name, $value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ class Application_Model_Config_FormValidator
|
||||||
* Checks database connection params.
|
* Checks database connection params.
|
||||||
* If connection is successfull the values are saved to the config file.
|
* If connection is successfull the values are saved to the config file.
|
||||||
*
|
*
|
||||||
* @param Zend_View $view The view of the form for adding messages
|
* @param Zend_View_Interface $view The view of the form for adding messages
|
||||||
*/
|
*/
|
||||||
public function validateAndSaveConfig(Zend_View $view)
|
public function validateAndSaveConfig(Zend_View $view)
|
||||||
{
|
{
|
||||||
|
@ -81,8 +81,8 @@ class Application_Model_Config_FormValidator
|
||||||
if ($saveConfig) {
|
if ($saveConfig) {
|
||||||
$this->_config->setConfig($this->_configData);
|
$this->_config->setConfig($this->_configData);
|
||||||
$saved = $this->_config->save();
|
$saved = $this->_config->save();
|
||||||
$this->_config->load(Msd_Registry::getConfigFilename());
|
|
||||||
if ($saved === true) {
|
if ($saved === true) {
|
||||||
|
$this->_config->load(Msd_Registry::getConfigFilename());
|
||||||
$view->popUpMessage()->addMessage(
|
$view->popUpMessage()->addMessage(
|
||||||
'save-config',
|
'save-config',
|
||||||
'L_NOTICE',
|
'L_NOTICE',
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
|
<?php
|
||||||
|
$okIcon = $this->getIcon('Ok', null, 16);
|
||||||
|
$request = Zend_Controller_Front::getInstance()->getRequest();
|
||||||
|
?>
|
||||||
<form action="<?php
|
<form action="<?php
|
||||||
echo $this->url(array(
|
echo $this->url(array(
|
||||||
'controller' => 'install',
|
'controller' => 'install',
|
||||||
'action' => 'step4',
|
'action' => 'step4',
|
||||||
));
|
));?>" method="post" enctype="multipart/formdata">
|
||||||
|
|
||||||
$okIcon = $this->getIcon('Ok', null, 16);
|
|
||||||
$request = Zend_Controller_Front::getInstance()->getRequest();
|
|
||||||
|
|
||||||
?>" method="post" enctype="multipart/formdata">
|
|
||||||
<table cellpadding="0" cellspacing="0" class="bdr" style="width: 700px;" summary="Provide MySQL access data">
|
<table cellpadding="0" cellspacing="0" class="bdr" style="width: 700px;" summary="Provide MySQL access data">
|
||||||
<?php
|
<?php
|
||||||
if (isset($this->success) && $this->success) {
|
if (isset($this->success) && $this->success) { ?>
|
||||||
?>
|
|
||||||
<tr class="thead">
|
<tr class="thead">
|
||||||
<td style="text-align:center;" colspan="2">
|
<td style="text-align:center;" colspan="2">
|
||||||
<br />
|
<br />
|
||||||
|
@ -19,10 +18,8 @@ if (isset($this->success) && $this->success) {
|
||||||
<?php echo $this->getIcon('save'); ?> <?php echo $this->lang->L_SAVEANDCONTINUE; ?>
|
<?php echo $this->getIcon('save'); ?> <?php echo $this->lang->L_SAVEANDCONTINUE; ?>
|
||||||
</button><br class="clear" /><br />
|
</button><br class="clear" /><br />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr><?php
|
||||||
<?php
|
} ?>
|
||||||
}
|
|
||||||
?>
|
|
||||||
<tr class="row-even">
|
<tr class="row-even">
|
||||||
<td><?php echo $this->lang->L_DB_HOST; ?>:</td>
|
<td><?php echo $this->lang->L_DB_HOST; ?>:</td>
|
||||||
<td><input type="text" class="text" name="host" maxlength="100" style="width:250px;"
|
<td><input type="text" class="text" name="host" maxlength="100" style="width:250px;"
|
||||||
|
@ -63,41 +60,35 @@ if (isset($this->success) && $this->success) {
|
||||||
</button></td>
|
</button></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<?php
|
|
||||||
if(isset($this->success)) {
|
<?php if(isset($this->success)) { ?>
|
||||||
?><br/><br/>
|
<p> </p>
|
||||||
<table class="bdr" cellpadding="0" cellspacing="0" style="width:700px;" summary="MySQL connection results">
|
<table class="bdr" cellpadding="0" cellspacing="0" style="width:700px;" summary="MySQL connection results"><?php
|
||||||
<?php
|
if ($this->success) { ?>
|
||||||
if ($this->success) {
|
|
||||||
?>
|
|
||||||
<tr class="thead">
|
<tr class="thead">
|
||||||
<th><?php echo $this->lang->L_DBCONNECTION; ?> <?php echo $okIcon; ?></th>
|
<th><?php echo $this->lang->L_DBCONNECTION; ?> <?php echo $okIcon; ?></th>
|
||||||
</tr>
|
</tr><?php
|
||||||
<?php
|
|
||||||
if (count($this->databases) > 0) {
|
if (count($this->databases) > 0) {
|
||||||
foreach ($this->databases as $database) {
|
foreach ($this->databases as $index => $database) { ?>
|
||||||
?>
|
|
||||||
<tr class="dbrow">
|
<tr class="dbrow">
|
||||||
<td class="small success">
|
<td class="small success">
|
||||||
<div style="float:left; padding-right: 5px;" title="<?php echo $this->lang->L_INSTALL_DB_DEFAULT; ?>">
|
<div style="float:left; padding-right: 5px;" title="<?php echo $this->lang->L_INSTALL_DB_DEFAULT; ?>">
|
||||||
<input type="radio" name="defaultDb" value="<?php echo $database; ?>" />
|
<input id="db-<?php echo $index;?>" type="radio" name="defaultDb" value="<?php echo $database; ?>" />
|
||||||
</div>
|
</div>
|
||||||
|
<label for="db-<?php echo $index;?>">
|
||||||
<?php echo $database; ?>
|
<?php echo $database; ?>
|
||||||
|
</label>
|
||||||
<div style="float:right;">
|
<div style="float:right;">
|
||||||
<?php echo $okIcon; ?>
|
<?php echo $okIcon; ?>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr><?php
|
||||||
<?php
|
|
||||||
}
|
}
|
||||||
} else {
|
} else { ?>
|
||||||
?>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td><?php echo $okIcon; ?> <?php echo $this->lang->L_NO_DB_FOUND_INFO; ?></td>
|
<td><?php echo $okIcon; ?> <?php echo $this->lang->L_NO_DB_FOUND_INFO; ?></td>
|
||||||
</tr>
|
</tr><?php
|
||||||
<?php
|
} ?>
|
||||||
}
|
|
||||||
?>
|
|
||||||
<tr class="thead">
|
<tr class="thead">
|
||||||
<td style="text-align:center;">
|
<td style="text-align:center;">
|
||||||
<br />
|
<br />
|
||||||
|
@ -106,10 +97,8 @@ if(isset($this->success)) {
|
||||||
</button><br class="clear" /><br />
|
</button><br class="clear" /><br />
|
||||||
<input type="hidden" name="save" value="1"/>
|
<input type="hidden" name="save" value="1"/>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr><?php
|
||||||
<?php
|
} else { ?>
|
||||||
} else {
|
|
||||||
?>
|
|
||||||
<tr class="thead">
|
<tr class="thead">
|
||||||
<th><?php echo $this->lang->L_DBCONNECTION; ?> <?php echo $this->getIcon('delete'); ?></th>
|
<th><?php echo $this->lang->L_DBCONNECTION; ?> <?php echo $this->getIcon('delete'); ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -117,12 +106,9 @@ if(isset($this->success)) {
|
||||||
<td class="error">
|
<td class="error">
|
||||||
<br /><?php echo $this->errorMessage; ?><br /><br/>
|
<br /><?php echo $this->errorMessage; ?><br /><br/>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr><?php
|
||||||
<?php
|
}?>
|
||||||
}
|
</table><?php
|
||||||
?>
|
|
||||||
</table>
|
|
||||||
<?php
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</form>
|
</form>
|
|
@ -35,7 +35,13 @@ class Msd_Action_Helper_AssignConfigAndLanguage extends Zend_Controller_Action_H
|
||||||
if ($controllerName == 'install') {
|
if ($controllerName == 'install') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$view = $this->getView();
|
$view = $this->getView();
|
||||||
|
if (Msd_Registry::getConfigFilename() == 'defaultConfig.ini') {
|
||||||
|
$redirectUrl = $view->serverUrl() . $view->url(array('controller' => 'install', 'action' => 'index', null, true));
|
||||||
|
$redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
|
||||||
|
$redirector->gotoUrl($redirectUrl);
|
||||||
|
}
|
||||||
$view->config = Msd_Registry::getConfig();
|
$view->config = Msd_Registry::getConfig();
|
||||||
$view->dynamicConfig = Msd_Registry::getDynamicConfig();
|
$view->dynamicConfig = Msd_Registry::getDynamicConfig();
|
||||||
$view->lang = Msd_Language::getInstance();
|
$view->lang = Msd_Language::getInstance();
|
||||||
|
|
|
@ -107,8 +107,14 @@ class Msd_Config
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function save()
|
public function save($configFilenameAndPath = null)
|
||||||
{
|
{
|
||||||
|
//$configFilename = $this->getParam('configFile');
|
||||||
|
//echo "Dateiname: ". $configFilename;
|
||||||
|
if ($configFilenameAndPath !== null) {
|
||||||
|
$this->_ioHandler->setConfigFilename(basename($configFilenameAndPath));
|
||||||
|
}
|
||||||
|
|
||||||
return $this->_ioHandler->save($this->_config);
|
return $this->_ioHandler->save($this->_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ class Msd_Config_IoHandler_Default implements Msd_Config_IoHandler_Interface
|
||||||
if (count($config) == 0) {
|
if (count($config) == 0) {
|
||||||
|
|
||||||
// Search for the config file in the given directories.
|
// Search for the config file in the given directories.
|
||||||
$this->_initIni();
|
$this->_initIni($config);
|
||||||
$config = $this->_iniConfig->getIniData();
|
$config = $this->_iniConfig->getIniData();
|
||||||
// Put configuration into session.
|
// Put configuration into session.
|
||||||
$this->_sessionNamespace->config = $config;
|
$this->_sessionNamespace->config = $config;
|
||||||
|
@ -88,6 +88,16 @@ class Msd_Config_IoHandler_Default implements Msd_Config_IoHandler_Interface
|
||||||
return $config;
|
return $config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set configuration file name
|
||||||
|
*
|
||||||
|
* @param string $configFilename File name of configuration file (without path)
|
||||||
|
*/
|
||||||
|
public function setConfigFilename($configFilename)
|
||||||
|
{
|
||||||
|
$this->_configFilename = $configFilename;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the configuration to session and .ini file.
|
* Saves the configuration to session and .ini file.
|
||||||
*
|
*
|
||||||
|
@ -98,7 +108,7 @@ class Msd_Config_IoHandler_Default implements Msd_Config_IoHandler_Interface
|
||||||
public function save($config)
|
public function save($config)
|
||||||
{
|
{
|
||||||
if ($this->_iniConfig === null) {
|
if ($this->_iniConfig === null) {
|
||||||
$this->_initIni();
|
$this->_initIni($config);
|
||||||
}
|
}
|
||||||
// Save config to session
|
// Save config to session
|
||||||
$this->_sessionNamespace->config = $config;
|
$this->_sessionNamespace->config = $config;
|
||||||
|
@ -111,17 +121,21 @@ class Msd_Config_IoHandler_Default implements Msd_Config_IoHandler_Interface
|
||||||
/**
|
/**
|
||||||
* Initializes the .ini file handler and sets the full filename of the .ini file.
|
* Initializes the .ini file handler and sets the full filename of the .ini file.
|
||||||
*
|
*
|
||||||
|
* @param array Configuration as array
|
||||||
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function _initIni()
|
private function _initIni($config)
|
||||||
{
|
{
|
||||||
foreach ($this->_configDirectories as $configDir) {
|
foreach ($this->_configDirectories as $configDir) {
|
||||||
$filename = rtrim($configDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $this->_configFilename;
|
$filename = rtrim($configDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $this->_configFilename;
|
||||||
if (file_exists($filename)) {
|
if (file_exists($filename)) {
|
||||||
$this->_configFilename = $filename;
|
$this->_configFilename = $filename;
|
||||||
$this->_iniConfig = new Msd_Ini($filename);
|
$this->_iniConfig = new Msd_Ini($filename);
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$this->_iniConfig = new Msd_Ini();
|
||||||
|
$this->_iniConfig->setIniData($config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,317 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* This file is part of MySQLDumper released under the GNU/GPL 2 license
|
|
||||||
* http://www.mysqldumper.net
|
|
||||||
*
|
|
||||||
* @package MySQLDumper
|
|
||||||
* @subpackage Configuration
|
|
||||||
* @version SVN: $Rev$
|
|
||||||
* @author $Author$
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Configuration class implemented as singleton
|
|
||||||
*
|
|
||||||
* Handles getting and setting of configuration variables
|
|
||||||
*
|
|
||||||
* @package MySQLDumper
|
|
||||||
* @subpackage Configuration
|
|
||||||
*/
|
|
||||||
class Msd_Configuration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Instance
|
|
||||||
*
|
|
||||||
* @var Msd_Configuration
|
|
||||||
*/
|
|
||||||
private static $_instance = NULL;
|
|
||||||
/**
|
|
||||||
* Configuration params
|
|
||||||
*
|
|
||||||
* @var StdClass
|
|
||||||
*/
|
|
||||||
private $_data = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Session to old values
|
|
||||||
*
|
|
||||||
* @var Zend_Session_Namespace
|
|
||||||
*/
|
|
||||||
private $_session = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* @param string $configName The name of the configuration file to load.
|
|
||||||
* If not set we will load the config from
|
|
||||||
* session if present.
|
|
||||||
* @param bool $forceLoading Force loading of configuration from file
|
|
||||||
*/
|
|
||||||
private function __construct($configName = '', $forceLoading = false)
|
|
||||||
{
|
|
||||||
$this->_session = new Zend_Session_Namespace('MySQLDumper');
|
|
||||||
if ($forceLoading === false && isset($this->_session->dynamic->configFile)) {
|
|
||||||
$this->loadConfigFromSession();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->_data = new stdClass;
|
|
||||||
|
|
||||||
if ($configName == '') {
|
|
||||||
$configName = 'defaultConfig';
|
|
||||||
}
|
|
||||||
$this->_data->dynamic = Msd_ConfigurationPhpValues::getDynamicValues();
|
|
||||||
$this->_data->paths = $this->_loadUserDirectories();
|
|
||||||
$this->loadConfiguration($configName);
|
|
||||||
$this->set('dynamic.configFile', $configName);
|
|
||||||
|
|
||||||
$defaultDb = $this->get('config.dbuser.defaultDb');
|
|
||||||
if ($defaultDb != '') {
|
|
||||||
$this->set('dynamic.dbActual', $defaultDb);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->saveConfigToSession();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* No cloning for singleton
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __clone()
|
|
||||||
{
|
|
||||||
throw new Msd_Exception('Cloning is not allowed');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the configuration instance
|
|
||||||
*
|
|
||||||
* @param string $configName The name of the configuration file to load.
|
|
||||||
* If not set we will load the config from
|
|
||||||
* session if present.
|
|
||||||
* @param boolean $forceLoading If set the config will be read from file.
|
|
||||||
*
|
|
||||||
* @return Msd_Configuration
|
|
||||||
*/
|
|
||||||
public static function getInstance($configName = '', $forceLoading = false)
|
|
||||||
{
|
|
||||||
if (null == self::$_instance) {
|
|
||||||
self::$_instance = new self($configName, $forceLoading);
|
|
||||||
}
|
|
||||||
if ($forceLoading) {
|
|
||||||
self::$_instance->loadConfiguration($configName, true);
|
|
||||||
}
|
|
||||||
return self::$_instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set a key to a val
|
|
||||||
*
|
|
||||||
* @param string $configPath Must begin with "config", "dynamic" or "paths"
|
|
||||||
* @param string $val The value to set
|
|
||||||
*
|
|
||||||
* @return Msd_Configuration
|
|
||||||
*/
|
|
||||||
public function set($configPath, $val)
|
|
||||||
{
|
|
||||||
$args = explode('.', $configPath);
|
|
||||||
if (!in_array($args[0], array('config', 'paths', 'dynamic'))) {
|
|
||||||
$msg = 'Trying to set config value with illegal key. First key '
|
|
||||||
. 'must be "config", "paths" or "dynamic"';
|
|
||||||
throw new Msd_Exception($msg);
|
|
||||||
}
|
|
||||||
switch (count($args)) {
|
|
||||||
case 2:
|
|
||||||
list($type, $var) = $args;
|
|
||||||
$this->_data->$type->$var = $val;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
list($type, $section, $var) = $args;
|
|
||||||
$this->_data->$type->$section->$var = $val;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$backTrace = debug_backtrace(false);
|
|
||||||
throw new Msd_Exception(
|
|
||||||
'Path couldn\'t be set!' . PHP_EOL . $configPath .
|
|
||||||
' invoked from ' . $backTrace[0]['file'] . '[' .
|
|
||||||
$backTrace[0]['line'] . ']',
|
|
||||||
E_USER_NOTICE
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a config parameter
|
|
||||||
*
|
|
||||||
* If first part isn't config, paths or dynamic, we assume config is meant.
|
|
||||||
*
|
|
||||||
* @param string $key Path to get
|
|
||||||
*
|
|
||||||
* @return string|array
|
|
||||||
*/
|
|
||||||
public function get($key)
|
|
||||||
{
|
|
||||||
$params = explode('.', $key);
|
|
||||||
if (!in_array($params[0], array('config', 'paths', 'dynamic'))) {
|
|
||||||
$msg = 'Trying to get config value with illegal key. First key '
|
|
||||||
. 'must be "config", "paths" or "dynamic"';
|
|
||||||
throw new Msd_Exception($msg);
|
|
||||||
}
|
|
||||||
$values = $this->_data->$params[0];
|
|
||||||
if (!is_array($values)) {
|
|
||||||
$values = $this->_data->$params[0]->toArray();
|
|
||||||
}
|
|
||||||
if (sizeof($params) == 1) {
|
|
||||||
return $values;
|
|
||||||
}
|
|
||||||
unset($params[0]);
|
|
||||||
foreach ($params as $index) {
|
|
||||||
if (isset($values[$index])) {
|
|
||||||
$values = $values[$index];
|
|
||||||
} else {
|
|
||||||
$values = null;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $values;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Save configurations to file
|
|
||||||
*
|
|
||||||
* @param string $fileName Name of configuration without extension .ini
|
|
||||||
* @param array $configArray Data to save as array
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function save($fileName = null, $configArray = null)
|
|
||||||
{
|
|
||||||
if ($fileName === null) {
|
|
||||||
$fileName = $this->get('dynamic.configFile');
|
|
||||||
}
|
|
||||||
$fileName .= '.ini';
|
|
||||||
// save branch config and skip groups "dynamic" and "paths"
|
|
||||||
if ($configArray !== null) {
|
|
||||||
$configData = new Zend_Config($configArray, true);
|
|
||||||
} else {
|
|
||||||
$configData = $this->_data->config;
|
|
||||||
}
|
|
||||||
$configWriter = new Zend_Config_Writer_Ini(
|
|
||||||
array(
|
|
||||||
'filename' => $this->get('paths.config') . '/' . $fileName,
|
|
||||||
'config' => $configData,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$configWriter->write();
|
|
||||||
$this->_data->config = $configData;
|
|
||||||
$this->set('dynamic.configFile', basename($fileName, '.ini'));
|
|
||||||
$this->saveConfigToSession();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Save config to session
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function saveConfigToSession()
|
|
||||||
{
|
|
||||||
$this->_session->unsetAll();
|
|
||||||
$this->_session->config = $this->_data->config;
|
|
||||||
$this->_session->dynamic = $this->_data->dynamic;
|
|
||||||
$this->_session->paths = $this->_data->paths;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get config from session
|
|
||||||
*
|
|
||||||
* @return object
|
|
||||||
*/
|
|
||||||
public function loadConfigFromSession()
|
|
||||||
{
|
|
||||||
if (isset($this->_session->config)) {
|
|
||||||
$this->_data->config = $this->_session->config;
|
|
||||||
}
|
|
||||||
if (isset($this->_session->dynamic)) {
|
|
||||||
$this->_data->dynamic = $this->_session->dynamic;
|
|
||||||
}
|
|
||||||
if (isset($this->_session->paths)) {
|
|
||||||
$this->_data->paths = $this->_session->paths;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load configuration file
|
|
||||||
*
|
|
||||||
* @param string $configName The configuration file to load
|
|
||||||
* @param boolean $applyValues Whether to apply loaded values to config
|
|
||||||
*
|
|
||||||
* @return Zend_Config_ini Loaded configuration as Zend_Config_Ini
|
|
||||||
*/
|
|
||||||
public function loadConfiguration($configName, $applyValues = true)
|
|
||||||
{
|
|
||||||
$this->_loadUserDirectories();
|
|
||||||
if ($configName != 'defaultConfig') {
|
|
||||||
$configName .= '.ini';
|
|
||||||
$configPath = $this->get('paths.config');
|
|
||||||
$configFile = $configPath . '/' . $configName;
|
|
||||||
} else {
|
|
||||||
// special case - defaultConfig.ini is in application/configs
|
|
||||||
$configFile = realpath(APPLICATION_PATH . '/configs') . '/defaultConfig.ini';
|
|
||||||
}
|
|
||||||
if (!is_readable($configFile)) {
|
|
||||||
throw new Msd_Exception(
|
|
||||||
'Couldn\'t read configuration file ' . $configFile
|
|
||||||
);
|
|
||||||
}
|
|
||||||
$options = array('allowModifications' => true);
|
|
||||||
$config = new Zend_Config_Ini($configFile, null, $options);
|
|
||||||
if (!$applyValues) {
|
|
||||||
return $config;
|
|
||||||
}
|
|
||||||
$this->_data->config = null;
|
|
||||||
$this->_data->config = $config;
|
|
||||||
$this->set('dynamic.configFile', basename($configFile, '.ini'));
|
|
||||||
$iconPath = 'css/' . $this->get('config.interface.theme') . '/icons';
|
|
||||||
$this->set('paths.iconpath', $iconPath);
|
|
||||||
$this->saveConfigToSession();
|
|
||||||
return $config;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get user directories and save them to config
|
|
||||||
*
|
|
||||||
* @return Zend_Config Directories as object
|
|
||||||
*/
|
|
||||||
private function _loadUserDirectories()
|
|
||||||
{
|
|
||||||
// set paths
|
|
||||||
$workRoot = realpath(APPLICATION_PATH . '/..') . '/work/';
|
|
||||||
$directories = array(
|
|
||||||
'work' => $workRoot,
|
|
||||||
'log' => $workRoot . 'log',
|
|
||||||
'backup' => $workRoot . 'backup',
|
|
||||||
'config' => $workRoot . 'config'
|
|
||||||
);
|
|
||||||
return new Zend_Config($directories, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return name of configuration
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getTitle()
|
|
||||||
{
|
|
||||||
return $this->get('config.general.title');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reloads the configuration from the current ini file.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function reloadConfig()
|
|
||||||
{
|
|
||||||
$this->loadConfiguration($this->get('dynamic.configFile'));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,138 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* This file is part of MySQLDumper released under the GNU/GPL 2 license
|
|
||||||
* http://www.mysqldumper.net
|
|
||||||
*
|
|
||||||
* @package MySQLDumper
|
|
||||||
* @subpackage Configuration
|
|
||||||
* @version SVN: $Rev$
|
|
||||||
* @author $Author$
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Helper for getting dynamic configuration values like phpRam etc.
|
|
||||||
*
|
|
||||||
* @package MySQLDumper
|
|
||||||
* @subpackage Configuration
|
|
||||||
*/
|
|
||||||
class Msd_ConfigurationPhpValues
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Read dynamic PHP config values
|
|
||||||
*
|
|
||||||
* @return Zend_Config
|
|
||||||
*/
|
|
||||||
public static function getDynamicValues ()
|
|
||||||
{
|
|
||||||
$phpRam = self::_getPhpRam();
|
|
||||||
$dynConfig = array(
|
|
||||||
'sendmailCall' => self::_getConfigSetting('sendmail_path'),
|
|
||||||
'safeMode' => self::_getConfigSetting('safe_mode', true),
|
|
||||||
'magicQuotesGpc' => get_magic_quotes_gpc(),
|
|
||||||
'disabledPhpFunctions' =>
|
|
||||||
str_replace(
|
|
||||||
',',
|
|
||||||
', ',
|
|
||||||
self::_getConfigSetting('disable_functions')
|
|
||||||
),
|
|
||||||
'maxExecutionTime' => self::_getMaxExecutionTime(),
|
|
||||||
'uploadMaxFilesize' => self::_getUploadMaxFilesize(),
|
|
||||||
'phpextensions' => implode(', ', get_loaded_extensions()),
|
|
||||||
'phpRam' => $phpRam,
|
|
||||||
'memoryLimit' => round($phpRam * 1024 * 1024 * 0.9, 0),
|
|
||||||
'compression' => self::_hasZlib(),
|
|
||||||
);
|
|
||||||
return new Zend_Config($dynConfig, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Read PHP's max_execution_time
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
private static function _getMaxExecutionTime()
|
|
||||||
{
|
|
||||||
$maxExecutionTime =
|
|
||||||
self::_getConfigSetting('max_execution_time', true);
|
|
||||||
if ($maxExecutionTime <= 5) {
|
|
||||||
// we didn't get the real value from the server - some deliver "-1"
|
|
||||||
$maxExecutionTime = 30;
|
|
||||||
} elseif ($maxExecutionTime > 30) {
|
|
||||||
// we don't use more than 30 seconds to avoid brower timeouts
|
|
||||||
$maxExecutionTime = 30;
|
|
||||||
}
|
|
||||||
return $maxExecutionTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get PHP's upload_max_filesize
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
private static function _getUploadMaxFilesize()
|
|
||||||
{
|
|
||||||
$uploadMaxFilesize = self::_getConfigSetting('upload_max_filesize');
|
|
||||||
// Is value in Megabytes? If yes create output
|
|
||||||
if (strpos($uploadMaxFilesize, 'M')) {
|
|
||||||
$uploadMaxFilesize = str_replace('M', '', $uploadMaxFilesize);
|
|
||||||
$uploadMaxFilesize = trim($uploadMaxFilesize);
|
|
||||||
// re-calculate to Bytes
|
|
||||||
$uploadMaxFilesize *= 1024 * 1024;
|
|
||||||
}
|
|
||||||
return (int) $uploadMaxFilesize;;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get PHP's ram size
|
|
||||||
*
|
|
||||||
* @return integer The memory limit in MB
|
|
||||||
*/
|
|
||||||
private static function _getPhpRam()
|
|
||||||
{
|
|
||||||
$ram = self::_getConfigSetting('memory_limit');
|
|
||||||
// we don't trust the value delivered by server config if < 16
|
|
||||||
if ($ram < 16) {
|
|
||||||
$ram = 16;
|
|
||||||
}
|
|
||||||
return $ram;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Detect if zlib is installed
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
private static function _hasZlib()
|
|
||||||
{
|
|
||||||
$zlib = false;
|
|
||||||
$extensions = get_loaded_extensions();
|
|
||||||
if (in_array('zlib', $extensions)) {
|
|
||||||
$zlib = true;
|
|
||||||
};
|
|
||||||
return (boolean) $zlib;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a PHP-Setting from ini
|
|
||||||
*
|
|
||||||
* First try to read via ini_get(), then fall back to get_cfg_var()
|
|
||||||
*
|
|
||||||
* @param string $varName The name of the setting to read
|
|
||||||
* @param bool $returnAsInt Whether to return value as integer
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
private function _getConfigSetting($varName, $returnAsInt = false)
|
|
||||||
{
|
|
||||||
$value = @ini_get($varName);
|
|
||||||
|
|
||||||
// fallback if ini_get doesn't work
|
|
||||||
if ($value == '' || $value === null) {
|
|
||||||
$value = @get_cfg_var($varName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($returnAsInt) {
|
|
||||||
$value = (int) $value;
|
|
||||||
}
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -26,6 +26,11 @@ class Msd_Controller_Action extends Zend_Controller_Action
|
||||||
*/
|
*/
|
||||||
protected $_dynamicConfig;
|
protected $_dynamicConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Msd_Language
|
||||||
|
*/
|
||||||
|
protected $_lang;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class constructor
|
* Class constructor
|
||||||
*
|
*
|
||||||
|
@ -61,6 +66,7 @@ class Msd_Controller_Action extends Zend_Controller_Action
|
||||||
{
|
{
|
||||||
$this->_config = Msd_Registry::getConfig();
|
$this->_config = Msd_Registry::getConfig();
|
||||||
$this->_dynamicConfig = Msd_Registry::getDynamicConfig();
|
$this->_dynamicConfig = Msd_Registry::getDynamicConfig();
|
||||||
|
$this->_lang = Msd_Language::getInstance();
|
||||||
parent::__construct($request, $response, $invokeArgs);
|
parent::__construct($request, $response, $invokeArgs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,21 +21,21 @@ class Msd_Registry extends Zend_Registry
|
||||||
*
|
*
|
||||||
* @const string
|
* @const string
|
||||||
*/
|
*/
|
||||||
const CONFIG_FILENAME_KEY = '_configFilename';
|
const CONFIG_FILENAME_KEY = 'configFilename';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Key for the dynamic configuration. This is used inside the registry.
|
* Key for the dynamic configuration. This is used inside the registry.
|
||||||
*
|
*
|
||||||
* @const string
|
* @const string
|
||||||
*/
|
*/
|
||||||
const DYNAMIC_CONFIG_KEY = '_dynamic';
|
const DYNAMIC_CONFIG_KEY = 'Dynamic';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Key for the configuration. This is used inside the registry.
|
* Key for the configuration. This is used inside the registry.
|
||||||
*
|
*
|
||||||
* @const string
|
* @const string
|
||||||
*/
|
*/
|
||||||
const CONFIG_KEY = '_config';
|
const CONFIG_KEY = 'Config';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the config instance if it has been registered, returns null otherwise.
|
* Returns the config instance if it has been registered, returns null otherwise.
|
||||||
|
|
|
@ -176,8 +176,8 @@ class Msd_Application_Controller_IndexControllerTest
|
||||||
'lastController' => 'index'
|
'lastController' => 'index'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$config = Msd_Configuration::getInstance();
|
$dynamicConfig = Msd_Registry::getDynamicConfig();
|
||||||
$config->set('dynamic.dbActual', -1);
|
$dynamicConfig->set('dbActual', -1);
|
||||||
$this->dispatch('/index/dbrefresh');
|
$this->dispatch('/index/dbrefresh');
|
||||||
$this->assertRedirectTo('/index/phpinfo');
|
$this->assertRedirectTo('/index/phpinfo');
|
||||||
}
|
}
|
||||||
|
@ -185,9 +185,9 @@ class Msd_Application_Controller_IndexControllerTest
|
||||||
public function testCanSelectDb()
|
public function testCanSelectDb()
|
||||||
{
|
{
|
||||||
$this->loginUser();
|
$this->loginUser();
|
||||||
$config = Msd_Configuration::getInstance();
|
$dynamicConfig = Msd_Registry::getDynamicConfig();
|
||||||
// set invalid active db
|
// set invalid active db
|
||||||
$config->set('dynamic.dbActual', -1);
|
$dynamicConfig->setParam('dbActual', -1);
|
||||||
$this->getRequest()
|
$this->getRequest()
|
||||||
->setMethod('POST')
|
->setMethod('POST')
|
||||||
->setParams(
|
->setParams(
|
||||||
|
@ -202,7 +202,7 @@ class Msd_Application_Controller_IndexControllerTest
|
||||||
// check if actual db was switched
|
// check if actual db was switched
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
'information_schema',
|
'information_schema',
|
||||||
$config->get('dynamic.dbActual')
|
$dynamicConfig->getParam('dbActual')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,8 +228,8 @@ class Msd_Application_Controller_IndexControllerTest
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->dispatch('/index/switchconfig');
|
$this->dispatch('/index/switchconfig');
|
||||||
$config = Msd_Configuration::getInstance();
|
$dynamicConfig = Msd_Registry::getDynamicConfig();
|
||||||
$this->assertEquals('mysqldumper', $config->get('dynamic.configFile'));
|
$this->assertEquals('mysqldumper', $dynamicConfig->getParam('configFile'));
|
||||||
// are we still on the phpinfo page?
|
// are we still on the phpinfo page?
|
||||||
$this->assertQueryCount('#phpinfo', 1);
|
$this->assertQueryCount('#phpinfo', 1);
|
||||||
|
|
||||||
|
|
Laden …
In neuem Issue referenzieren