From 4f4c5ce3ccf0370f926d75e700e8b0bd2208f3f6 Mon Sep 17 00:00:00 2001 From: Markus Warg Date: Wed, 31 Mar 2010 16:43:49 +0200 Subject: [PATCH] initial setup of framework code enabled features * login * crt login * top / left menu * logging * db layer --- manager/.buildpath | 6 + manager/.project | 29 ++ manager/.settings/.jsdtscope | 11 + manager/.settings/org.eclipse.php.core.prefs | 5 + ...rg.eclipse.wst.jsdt.ui.superType.container | 1 + .../org.eclipse.wst.jsdt.ui.superType.name | 1 + manager/application/Bootstrap.php | 154 ++++++++ manager/application/configs/application.ini | 56 +++ .../controllers/ErrorController.php | 35 ++ .../controllers/IndexController.php | 28 ++ .../controllers/LoginController.php | 260 ++++++++++++++ .../controllers/LogoutController.php | 27 ++ .../application/layouts/scripts/layout.phtml | 32 ++ manager/application/views/helpers/LeftNav.php | 96 +++++ manager/application/views/helpers/TopNav.php | 99 +++++ .../application/views/helpers/UserInfo.php | 95 +++++ .../views/scripts/error/error.phtml | 28 ++ .../scripts/error/permissiondenied.phtml | 8 + .../views/scripts/index/index.phtml | 7 + .../views/scripts/login/index.phtml | 16 + .../views/scripts/login/loginresult.phtml | 16 + .../views/scripts/logout/index.phtml | 7 + manager/library/actions/ActionIndex.php | 53 +++ manager/library/actions/FWAction.php | 7 + manager/library/config/Config.php | 104 ++++++ manager/library/config/Config_Db.php | 339 ++++++++++++++++++ manager/library/config/Config_Writer_Db.php | 217 +++++++++++ manager/library/date/HumanReadableTime.php | 140 ++++++++ .../exception.HumanReadableTimeException.php | 37 ++ .../library/date/testHumanReadableTime.php | 16 + manager/library/exception/exception.Base.php | 98 +++++ manager/library/global/defines.php | 28 ++ manager/library/helpers/GetEnv.php | 29 ++ manager/library/i18n/I18n.php | 95 +++++ manager/library/l10n/L10n.php | 47 +++ manager/library/log/Log.php | 105 ++++++ manager/library/plugins/plugin.buildmenu.php | 74 ++++ .../library/plugins/plugin.charsetheader.php | 13 + manager/library/plugins/plugin.forceauth.php | 29 ++ .../library/plugins/plugin.loginlogout.php | 25 ++ manager/locale/en_US/locale.php | 2 + manager/public/.htaccess | 10 + manager/public/css/form_dl.css | 23 ++ manager/public/css/form_dl_wide.css | 24 ++ manager/public/css/global.css | 123 +++++++ manager/public/css/login.css | 11 + manager/public/favicon.ico | Bin 0 -> 1406 bytes manager/public/img/cacert4.png | Bin 0 -> 6421 bytes manager/public/index.php | 51 +++ manager/public/js/center.js | 10 + manager/public/js/positionUserInfo.js | 17 + manager/tests/application/bootstrap.php | 0 manager/tests/library/bootstrap.php | 0 manager/tests/phpunit.xml | 0 54 files changed, 2744 insertions(+) create mode 100644 manager/.buildpath create mode 100644 manager/.project create mode 100644 manager/.settings/.jsdtscope create mode 100644 manager/.settings/org.eclipse.php.core.prefs create mode 100644 manager/.settings/org.eclipse.wst.jsdt.ui.superType.container create mode 100644 manager/.settings/org.eclipse.wst.jsdt.ui.superType.name create mode 100644 manager/application/Bootstrap.php create mode 100644 manager/application/configs/application.ini create mode 100644 manager/application/controllers/ErrorController.php create mode 100644 manager/application/controllers/IndexController.php create mode 100644 manager/application/controllers/LoginController.php create mode 100644 manager/application/controllers/LogoutController.php create mode 100644 manager/application/layouts/scripts/layout.phtml create mode 100644 manager/application/views/helpers/LeftNav.php create mode 100644 manager/application/views/helpers/TopNav.php create mode 100644 manager/application/views/helpers/UserInfo.php create mode 100644 manager/application/views/scripts/error/error.phtml create mode 100644 manager/application/views/scripts/error/permissiondenied.phtml create mode 100644 manager/application/views/scripts/index/index.phtml create mode 100644 manager/application/views/scripts/login/index.phtml create mode 100644 manager/application/views/scripts/login/loginresult.phtml create mode 100644 manager/application/views/scripts/logout/index.phtml create mode 100644 manager/library/actions/ActionIndex.php create mode 100644 manager/library/actions/FWAction.php create mode 100644 manager/library/config/Config.php create mode 100644 manager/library/config/Config_Db.php create mode 100644 manager/library/config/Config_Writer_Db.php create mode 100644 manager/library/date/HumanReadableTime.php create mode 100644 manager/library/date/exception.HumanReadableTimeException.php create mode 100644 manager/library/date/testHumanReadableTime.php create mode 100644 manager/library/exception/exception.Base.php create mode 100644 manager/library/global/defines.php create mode 100644 manager/library/helpers/GetEnv.php create mode 100644 manager/library/i18n/I18n.php create mode 100644 manager/library/l10n/L10n.php create mode 100644 manager/library/log/Log.php create mode 100644 manager/library/plugins/plugin.buildmenu.php create mode 100644 manager/library/plugins/plugin.charsetheader.php create mode 100644 manager/library/plugins/plugin.forceauth.php create mode 100644 manager/library/plugins/plugin.loginlogout.php create mode 100644 manager/locale/en_US/locale.php create mode 100644 manager/public/.htaccess create mode 100644 manager/public/css/form_dl.css create mode 100644 manager/public/css/form_dl_wide.css create mode 100644 manager/public/css/global.css create mode 100644 manager/public/css/login.css create mode 100644 manager/public/favicon.ico create mode 100644 manager/public/img/cacert4.png create mode 100644 manager/public/index.php create mode 100644 manager/public/js/center.js create mode 100644 manager/public/js/positionUserInfo.js create mode 100644 manager/tests/application/bootstrap.php create mode 100644 manager/tests/library/bootstrap.php create mode 100644 manager/tests/phpunit.xml diff --git a/manager/.buildpath b/manager/.buildpath new file mode 100644 index 0000000..d9b76e7 --- /dev/null +++ b/manager/.buildpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/manager/.project b/manager/.project new file mode 100644 index 0000000..5f27609 --- /dev/null +++ b/manager/.project @@ -0,0 +1,29 @@ + + + ca-mgr (mawaunix) + + + + + + org.eclipse.wst.jsdt.core.javascriptValidator + + + + + org.eclipse.wst.validation.validationbuilder + + + + + org.eclipse.dltk.core.scriptbuilder + + + + + + org.zend.php.framework.ZendFrameworkNature + org.eclipse.php.core.PHPNature + org.eclipse.wst.jsdt.core.jsNature + + diff --git a/manager/.settings/.jsdtscope b/manager/.settings/.jsdtscope new file mode 100644 index 0000000..f40dd98 --- /dev/null +++ b/manager/.settings/.jsdtscope @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/manager/.settings/org.eclipse.php.core.prefs b/manager/.settings/org.eclipse.php.core.prefs new file mode 100644 index 0000000..cbc9cef --- /dev/null +++ b/manager/.settings/org.eclipse.php.core.prefs @@ -0,0 +1,5 @@ +#Wed Mar 31 11:13:35 CEST 2010 +eclipse.preferences.version=1 +include_path=0;/ca-mgr (mawaunix)\u00055;org.zend.php.framework.CONTAINER +phpVersion=php5 +use_asp_tags_as_php=false diff --git a/manager/.settings/org.eclipse.wst.jsdt.ui.superType.container b/manager/.settings/org.eclipse.wst.jsdt.ui.superType.container new file mode 100644 index 0000000..3bd5d0a --- /dev/null +++ b/manager/.settings/org.eclipse.wst.jsdt.ui.superType.container @@ -0,0 +1 @@ +org.eclipse.wst.jsdt.launching.baseBrowserLibrary \ No newline at end of file diff --git a/manager/.settings/org.eclipse.wst.jsdt.ui.superType.name b/manager/.settings/org.eclipse.wst.jsdt.ui.superType.name new file mode 100644 index 0000000..05bd71b --- /dev/null +++ b/manager/.settings/org.eclipse.wst.jsdt.ui.superType.name @@ -0,0 +1 @@ +Window \ No newline at end of file diff --git a/manager/application/Bootstrap.php b/manager/application/Bootstrap.php new file mode 100644 index 0000000..664d5e2 --- /dev/null +++ b/manager/application/Bootstrap.php @@ -0,0 +1,154 @@ + 'Default_', + 'basePath' => dirname(__FILE__) + )); + return $autoloader; + } + + protected function _initPlugins() { + $this->bootstrap('session'); + + $fc = Zend_Controller_Front::getInstance(); + + $charset_header = new CharsetHeader(); + $fc->registerPlugin($charset_header); + + $force_auth = new ForceAuth(); + $fc->registerPlugin($force_auth); + + $buildmenu = new BuildMenu(); + $fc->registerPlugin($buildmenu); + + $loginlogout = new LoginLogout(); + $fc->registerPlugin($loginlogout); + } + + protected function _initDoctype() { + $this->bootstrap('view'); + $this->bootstrap('log'); + $this->bootstrap('I18n'); + $this->bootstrap('session'); + + $view = $this->getResource('view'); + Zend_Registry::set('view', $view); + $view->doctype('XHTML1_STRICT'); + $view->addHelperPath(APPLICATION_PATH . '/views/helpers/'); + $view->headTitle = I18n::_('CACert Test Manager'); + } + + /** + * @todo expireSessionCookie() + * @todo rememberMe(xx) + * @todo forgetMe() + * @see Zend_Registry::get('session'); + * @return Zend_Session_Namespace + */ + protected function _initSession() { + $options = $this->getOption('ca_mgr'); + + $db = Zend_Db::factory($options['db']['session']['pdo'], $options['db']['session']); + + /** + * automatically clean up expired session entries from session cache + * use the modified and lifetime stamps to calculate expire time + */ + if ($options['db']['session']['autocleanup'] == '1') { + $stmt = $db->query('delete from front_session where (modified + lifetime * 2) < unix_timestamp()'); + # $stmt->execute(); + } + + //you can either set the Zend_Db_Table default adapter + //or you can pass the db connection straight to the save handler $config + // @see lifetimeColumn / lifetime / overrideLifetime, lifetime defaults to php.ini: session.gc_maxlifetime + Zend_Db_Table_Abstract::setDefaultAdapter($db); + $config = array( + 'name' => 'front_session', + 'primary' => 'id', + 'modifiedColumn' => 'modified', + 'dataColumn' => 'data', + 'lifetimeColumn' => 'lifetime' + ); + + //create your Zend_Session_SaveHandler_DbTable and + //set the save handler for Zend_Session + Zend_Session::setSaveHandler(new Zend_Session_SaveHandler_DbTable($config)); + + // Zend_Session::rememberMe(7200); + + //start your session! + Zend_Session::start(); + + $session = new Zend_Session_Namespace(); + if (!isset($session->started)) + $session->started = time(); + if (!isset($session->authdata)) + $session->authdata = array('authed' => false); + + Zend_Registry::set('session', $session); + return $session; + } + + /** + * get the basic system config from database, store the config object in the bootstrap registry + * @see Zend_Registry::get('config'); + * @return Config + */ + protected function _initConfig() { + $options = $this->getOption('ca_mgr'); + $db = Zend_Db::factory($options['db']['config']['pdo'], $options['db']['config']); + $config = Config::getInstance(SYSTEM_CONFIG, $db); + + Zend_Registry::set('config', $config); + Zend_Registry::set('config_dbc', $db); + + return $config; + } + + /** + * make singleton system logger + * @see Zend_Registry::get('log'); + * @return Log + */ + public function _initLog() { + $this->bootstrap('Config'); + + $op = $this->getOption('log'); + $log = Log::getInstance(SYSTEM_LOG, $op['application']); + + Zend_Registry::set('log', $log); + return $log; + } + + /** + * make singleton I18n (internationalization) object (translation) + */ + public function _initI18n() { + $this->bootstrap('Config'); + // need existing L10n object for initialization + $this->bootstrap('L10n'); + + $I18n = I18n::getInstance(L10n::getInstance()->getLanguage()); + } + + /** + * make singleton L10n (localization) object (set locale, convert date and + * number formats) + */ + public function _initL10n() { + $this->bootstrap('Config'); + + $L10n = L10n::getInstance(); + } +} diff --git a/manager/application/configs/application.ini b/manager/application/configs/application.ini new file mode 100644 index 0000000..61edc99 --- /dev/null +++ b/manager/application/configs/application.ini @@ -0,0 +1,56 @@ +[production] +phpSettings.display_startup_errors = 1 +phpSettings.display_errors = 1 +includePaths.library = LIBRARY_PATH +bootstrap.path = APPLICATION_PATH "/Bootstrap.php" +bootstrap.class = "Bootstrap" +resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" +resources.frontController.noViewRenderer = 0 +resources.frontController.noErrorHandler = 0 +resources.frontController.useDefaultControllerAlways = 0 +resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts" +resources.view[] = + +; Database settings for Session DB +ca_mgr.db.session.pdo = "Pdo_Mysql" +ca_mgr.db.session.autocleanup = 1 +ca_mgr.db.session.host = "localhost" +ca_mgr.db.session.username = "front_session" +ca_mgr.db.session.password = "laskdsfzrwethv45" +ca_mgr.db.session.dbname = "ca_mgr" + +; Database settings for Auth DB (CACert User Table) +ca_mgr.db.auth.pdo = "Pdo_Mysql" +ca_mgr.db.auth.host = "localhost" +ca_mgr.db.auth.username = "ca_mgr" +ca_mgr.db.auth.password = "jsdfhsd47534hsdf7" +ca_mgr.db.auth.dbname = "cacert" +ca_mgr.db.auth.tablename = "users" + +; Database settings for Auth DB (Manager User Table) +ca_mgr.db.auth2.pdo = "Pdo_Mysql" +ca_mgr.db.auth2.host = "localhost" +ca_mgr.db.auth2.username = "ca_mgr" +ca_mgr.db.auth2.password = "jsdfhsd47534hsdf7" +ca_mgr.db.auth2.dbname = "ca_mgr" +ca_mgr.db.auth2.tablename = "system_user" + +; Database settings for Config DB (access to system_config and dnssecme data tables) +ca_mgr.db.config.pdo = "Pdo_Mysql" +ca_mgr.db.config.host = "localhost" +ca_mgr.db.config.username = "ca_mgr" +ca_mgr.db.config.password = "jsdfhsd47534hsdf7" +ca_mgr.db.config.dbname = "ca_mgr" + +; Application name for logger +log.application = "web" + +[staging : production] + +[testing : production] +phpSettings.display_startup_errors = 1 +phpSettings.display_errors = 1 + +[development : production] +phpSettings.display_startup_errors = 1 +phpSettings.display_errors = 1 \ No newline at end of file diff --git a/manager/application/controllers/ErrorController.php b/manager/application/controllers/ErrorController.php new file mode 100644 index 0000000..806565d --- /dev/null +++ b/manager/application/controllers/ErrorController.php @@ -0,0 +1,35 @@ +_getParam('error_handler'); + + switch ($errors->type) { + case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER: + case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION: + + // 404 error -- controller or action not found + $this->getResponse()->setHttpResponseCode(404); + $this->view->message = 'Page not found'; + break; + default: + // application error + $this->getResponse()->setHttpResponseCode(500); + $this->view->message = 'Application error'; + break; + } + + $this->view->exception = $errors->exception; + $this->view->request = $errors->request; + + Log::Log()->emerg($errors->exception); + } + + public function permissiondeniedAction() { + + } +} + diff --git a/manager/application/controllers/IndexController.php b/manager/application/controllers/IndexController.php new file mode 100644 index 0000000..8b185e2 --- /dev/null +++ b/manager/application/controllers/IndexController.php @@ -0,0 +1,28 @@ +getInvokeArg('bootstrap'); + $view = $bootstrap->getResource('view'); + */ + } + + public function indexAction() + { + // action body + } + + +} + diff --git a/manager/application/controllers/LoginController.php b/manager/application/controllers/LoginController.php new file mode 100644 index 0000000..e007e05 --- /dev/null +++ b/manager/application/controllers/LoginController.php @@ -0,0 +1,260 @@ +view->form = $this->getForm(); + $this->render('index'); + } + + public function loginAction() { + $form = $this->getForm(); + if ($form->isValid($_POST)) { + $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV); + + $db = Zend_Db::factory($config->ca_mgr->db->auth->pdo, $config->ca_mgr->db->auth); + Zend_Registry::set('auth_dbc', $db); + $db2 = Zend_Db::factory($config->ca_mgr->db->auth2->pdo, $config->ca_mgr->db->auth2); + Zend_Registry::set('auth2_dbc', $db2); + + $auth = new Zend_Auth_Adapter_DbTable($db); + + $auth->setTableName($config->ca_mgr->db->auth->tablename) + ->setIdentityColumn('email') + ->setCredentialColumn('password'); + + $auth->setIdentity( $this->getRequest()->getParam('login_name')) + ->setCredential( sha1($this->getRequest()->getParam('login_password'))) + ->setCredentialTreatment('?'); + + $result = $auth->authenticate(); + + $code = $result->getCode(); + switch ($code) { + case Zend_Auth_Result::FAILURE: + Log::Log()->info(__METHOD__ . ' user failed (Zend_Auth_Result::FAILURE) to log in ' . $this->getRequest()->getParam('login_name')); + throw new Exception(__METHOD__ . ': unknown error'); + case Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND: + Log::Log()->info(__METHOD__ . ' user failed (Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND) to log in ' . $this->getRequest()->getParam('login_name')); + throw new Exception(__METHOD__ . ': ID unknown'); + case Zend_Auth_Result::FAILURE_IDENTITY_AMBIGUOUS: + Log::Log()->info(__METHOD__ . ' user failed (Zend_Auth_Result::FAILURE_IDENTITY_AMBIGUOUS) to log in ' . $this->getRequest()->getParam('login_name')); + throw new Exception(__METHOD__ . ': ID not unique'); + case Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID: + Log::Log()->info(__METHOD__ . ' user failed (Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID) to log in ' . $this->getRequest()->getParam('login_name')); + throw new Exception(__METHOD__ . ': ID unknown'); // to prevent brute force password attachs + case Zend_Auth_Result::FAILURE_UNCATEGORIZED: + Log::Log()->info(__METHOD__ . ' user failed (Zend_Auth_Result::FAILURE_UNCATEGORIZED) to log in ' . $this->getRequest()->getParam('login_name')); + throw new Exception(__METHOD__ . ': unknown error'); + } + + $this->getAuthDetailsIntoSession($auth, false); + + Log::Log()->info(__METHOD__ . ' user logged in ' . $this->view->session->authdata['authed_username'] . + ' (' . $this->getRequest()->getParam('login_name') . ')'); + + #$this->_forward('index', 'index'); // only "soft" forward, we need to change the url in browser + $this->_redirect($this->view->url(array('controller' => 'index', 'action' => 'index'), 'default', true)); + + /* + $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); + $viewRenderer->setRender('loginresult'); + $this->view->request = $this->getRequest(); + */ + } + else { + $this->view->form = $form; + return $this->render('index'); + } + } + + public function crtAction() { + $ssl_client_s_dn = GetEnv::getEnvVar('SSL_CLIENT_S_DN'); + $ssl_client_i_dn = GetEnv::getEnvVar('SSL_CLIENT_I_DN'); + + $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV); + + $db = Zend_Db::factory($config->ca_mgr->db->auth->pdo, $config->ca_mgr->db->auth); + Zend_Registry::set('auth_dbc', $db); + $db2 = Zend_Db::factory($config->ca_mgr->db->auth2->pdo, $config->ca_mgr->db->auth2); + Zend_Registry::set('auth2_dbc', $db2); + + $auth = new Zend_Auth_Adapter_DbTable($db); + + $auth->setTableName($config->ca_mgr->db->auth->tablename) + ->setIdentityColumn('user_client_crt_s_dn_i_dn') + ->setCredentialColumn('user_client_crt_s_dn_i_dn'); + + $auth->setIdentity( $ssl_client_s_dn . '//' . $ssl_client_i_dn) + ->setCredential($ssl_client_s_dn . '//' . $ssl_client_i_dn) + ->setCredentialTreatment('?'); + + $result = $auth->authenticate(); + + $code = $result->getCode(); + switch ($code) { + case Zend_Auth_Result::FAILURE: + Log::Log()->info(__METHOD__ . ' user failed (Zend_Auth_Result::FAILURE) to log in ' . $ssl_client_s_dn . '//' . $ssl_client_i_dn); + throw new Exception(__METHOD__ . ': unknown error'); + case Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND: + Log::Log()->info(__METHOD__ . ' user failed (Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND) to log in ' . $ssl_client_s_dn . '//' . $ssl_client_i_dn); + throw new Exception(__METHOD__ . ': ID unknown'); + case Zend_Auth_Result::FAILURE_IDENTITY_AMBIGUOUS: + Log::Log()->info(__METHOD__ . ' user failed (Zend_Auth_Result::FAILURE_IDENTITY_AMBIGUOUS) to log in ' . $ssl_client_s_dn . '//' . $ssl_client_i_dn); + throw new Exception(__METHOD__ . ': ID not unique'); + case Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID: + Log::Log()->info(__METHOD__ . ' user failed (Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID) to log in ' . $ssl_client_s_dn . '//' . $ssl_client_i_dn); + throw new Exception(__METHOD__ . ': ID unknown'); // to prevent brute force password attachs + case Zend_Auth_Result::FAILURE_UNCATEGORIZED: + Log::Log()->info(__METHOD__ . ' user failed (Zend_Auth_Result::FAILURE_UNCATEGORIZED) to log in ' . $ssl_client_s_dn . '//' . $ssl_client_i_dn); + throw new Exception(__METHOD__ . ': unknown error'); + } + + $this->getAuthDetailsIntoSession($auth, true); + + /* + $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); + $viewRenderer->setRender('loginresult'); + */ + + Log::Log()->info(__METHOD__ . ' user logged in ' . $this->view->session->authdata['authed_username'] . + ' (' . $ssl_client_s_dn . '//' . $ssl_client_i_dn . ')'); + + #$this->_forward('index', 'index'); // only "soft" forward, we need to change the url in browser + $this->_redirect($this->view->url(array('controller' => 'index', 'action' => 'index'), 'default', true)); + } + + /** + * get user data from Zend_Auth result and store data in session + * @param Zend_Auth_Result $auth + */ + protected function getAuthDetailsIntoSession($auth, $crt) { + $session = Zend_Registry::get('session'); + + /** + * non existent in our case, look up a 2nd table (ca_mgr.system_user by login name (email)) and + * get id from there, defaulting to User (1) when no db entry exists + */ + $auth_res = $auth->getResultRowObject(); + $system_roles_id = 1; + + $session->authdata['authed'] = true; + $session->authdata['authed_id'] = $auth_res->id; + $session->authdata['authed_username'] = $auth_res->email; + $session->authdata['authed_fname'] = $auth_res->fname; + $session->authdata['authed_lname'] = $auth_res->lname; + $session->authdata['authed_by_crt'] = $crt; + $session->authdata['authed_by_cli'] = true; + + $db = Zend_Registry::get('auth2_dbc'); + $res = $db->query('select * from system_role where id=?', array($system_roles_id)); + $res_ar = $res->fetch(); + $session->authdata['authed_role'] = $res_ar['role']; + + $acl = $this->makeAcl($db); + + $session->authdata['authed_permissions'] = $acl; + + /* test cases + Log::Log()->debug(($acl->isAllowed('User', 'Administration', 'view') == true)?'true':'false'); + Log::Log()->debug(($acl->isAllowed('User', 'Administration', 'edit') == true)?'true':'false'); + Log::Log()->debug(($acl->isAllowed('User', 'Account', 'view') == true)?'true':'false'); + Log::Log()->debug(($acl->isAllowed('User', 'Account', 'edit') == true)?'true':'false'); + Log::Log()->debug(($acl->isAllowed('Admin', 'Administration', 'view') == true)?'true':'false'); + Log::Log()->debug(($acl->isAllowed('Admin', 'Account', 'view') == true)?'true':'false'); + */ + + $this->view->session = $session; + } + + /** + * build login form and return to requesting method + * @return Zend_Form + */ + protected function getForm() { + $form = new Zend_Form(); + $form->setAction('/login/login') + ->setMethod('post'); + #$form->setAttrib('id', 'loginform'); + $al = new Zend_Validate_Alnum(); + $al->setDefaultTranslator(I18n::getTranslate()); + $al->setDisableTranslator(false); + $username = new Zend_Form_Element_Text('login_name'); + $username->addValidator(new Zend_Validate_StringLength(2,20)) + ->setRequired(true) + ->addFilter('StringToLower') + ->setLabel(I18n::_('User Name')); + $password = new Zend_Form_Element_Password('login_password'); + $password->addValidator(new Zend_Validate_Alnum()) + ->addValidator(new Zend_Validate_StringLength(8,20)) + ->setRequired(true) + ->setLabel(I18n::_('Password')); + $submit = new Zend_Form_Element_Submit('submit'); + $submit->setLabel(I18n::_('Login')); + $form->addElement($username) + ->addElement($password) + ->addElement($submit); + + return $form; + } + + /** + * get roles and resources from db, build Zend_Acl structure and add permissions + * @param Zend_Db $db + */ + protected function makeAcl($db) { + $acl = new Zend_Acl(); + + $res = $db->fetchAll('select * from system_role'); + foreach ($res as $obj) { + if ($obj['inherit_role'] != '') { + if ($acl->hasRole($obj['inherit_role'])) { + $acl->addRole(new Zend_Acl_Role($obj['role']), $obj['inherit_role']); + } + else { + /** + * @todo very simply system to order roles, add role before inherited role + */ + $res[] = $obj; + continue; + } + } + else { + $acl->addRole(new Zend_Acl_Role($obj['role'])); + } + } + + $res = $db->fetchAll('select * from system_resource'); + foreach ($res as $obj) { + $acl->addResource(new Zend_Acl_Resource($obj['resource'])); + } + + $res = $db->fetchAll('select r.role as role, rs.resource as resource, permission, privilege '. + 'from system_role as r join system_role_has_system_resource as m on ' . + '(r.id = m.system_role_id) join system_resource as rs on (m.system_resource_id = rs.id)'); + + foreach ($res as $obj) { + $privilege = explode(',', $obj['privilege']); + if ($obj['permission'] == 'allow') { + $acl->allow($obj['role'], $obj['resource'], $privilege); + } + else { + $acl->deny($obj['role'], $obj['resource'], $privilege); + } + } + + return $acl; + } +} diff --git a/manager/application/controllers/LogoutController.php b/manager/application/controllers/LogoutController.php new file mode 100644 index 0000000..83859d4 --- /dev/null +++ b/manager/application/controllers/LogoutController.php @@ -0,0 +1,27 @@ +info(__METHOD__ . ' user logged out ' . $this->view->session->authdata['authed_username']); + + unset($session->authdata); + $session->authdata['authed'] = false; + + Zend_Session::destroy(); + } +} diff --git a/manager/application/layouts/scripts/layout.phtml b/manager/application/layouts/scripts/layout.phtml new file mode 100644 index 0000000..44f59cf --- /dev/null +++ b/manager/application/layouts/scripts/layout.phtml @@ -0,0 +1,32 @@ +doctype(); ?> + + + + <?php print $this->headTitle; ?> + headLink()->prependStylesheet('/css/global.css'); ?> + headScript()->appendFile('/js/positionUserInfo.js'); // ->appendFile('/js/center.js'); ?> + + +
+ + +
+ leftNav(); ?> +
+
+ layout()->content; ?> +
+
+ userInfo(); ?> + + \ No newline at end of file diff --git a/manager/application/views/helpers/LeftNav.php b/manager/application/views/helpers/LeftNav.php new file mode 100644 index 0000000..7523d6e --- /dev/null +++ b/manager/application/views/helpers/LeftNav.php @@ -0,0 +1,96 @@ +url(array('controller'=>''), 'default', true); + * + * @param string $link + * @param string $setType + * @param string $setPos + * @return Zend_View_Helper_LeftNav + */ + public function leftNav($link = null, $setType = Zend_View_Helper_Placeholder_Container_Abstract::APPEND, $setPos = 0) + { + $link = (string) $link; + if ($link !== '') { + if ($setType == Zend_View_Helper_Placeholder_Container_Abstract::SET) { + if ($setPos != 0) + $this->items[$setPos] = $link; + else + $this->items[] = $link; + } elseif ($setType == Zend_View_Helper_Placeholder_Container_Abstract::PREPEND) { + $this->items = array_merge(array($link), $this->items); + } else { + $this->items[] = $link; + } + } + + return $this; + } + + /** + * Turn helper into string + * + * @param string|null $indent + * @param string|null $locale + * @return string + */ + public function __toString($indent = null, $locale = null) + { + $output = ''; + $indent = (null !== $indent) + ? $this->getWhitespace($indent) + : $this->getIndent(); + + $output .= $indent . "\n"; + + return $output; + } +} diff --git a/manager/application/views/helpers/TopNav.php b/manager/application/views/helpers/TopNav.php new file mode 100644 index 0000000..604178a --- /dev/null +++ b/manager/application/views/helpers/TopNav.php @@ -0,0 +1,99 @@ +url(array('controller'=>''), 'default', true); + * + * @param string $link + * @param string $setType + * @param string $setPos + * @return Zend_View_Helper_TopNav + */ + public function topNav($link = null, $setType = Zend_View_Helper_Placeholder_Container_Abstract::APPEND, $setPos = 0) + { + $link = (string) $link; + if ($link !== '') { + if ($setType == Zend_View_Helper_Placeholder_Container_Abstract::SET) { + if ($setPos != 0) + $this->items[$setPos] = $link; + else + $this->items[] = $link; + } elseif ($setType == Zend_View_Helper_Placeholder_Container_Abstract::PREPEND) { + $this->items = array_merge(array($link), $this->items); + } else { + $this->items[] = $link; + } + } + + return $this; + } + + /** + * Turn helper into string + * + * @param string|null $indent + * @param string|null $locale + * @return string + */ + public function __toString($indent = null, $locale = null) + { + $output = ''; + $indent = (null !== $indent) + ? $this->getWhitespace($indent) + : $this->getIndent(); + + ksort($this->items); + + $output .= $indent . "
    \n"; + + foreach ($this->items as $item) { + $output .= $indent . "
  • " . $item . "
  • \n"; + } + $output .= $indent . "
\n"; + + return $output; + } +} diff --git a/manager/application/views/helpers/UserInfo.php b/manager/application/views/helpers/UserInfo.php new file mode 100644 index 0000000..31b0b05 --- /dev/null +++ b/manager/application/views/helpers/UserInfo.php @@ -0,0 +1,95 @@ +url(array('controller'=>''), 'default', true); + * + * @param array $data + * @return Zend_View_Helper_UserData + */ + public function UserInfo($ar = null, $setType = Zend_View_Helper_Placeholder_Container_Abstract::APPEND, $setPos = 0) + { + if ($ar !== null && is_array($ar)) { + $this->items = $ar; + } + return $this; + } + + /** + * Turn helper into string + * + * @param string|null $indent + * @param string|null $locale + * @return string + */ + public function __toString($indent = null, $locale = null) + { + $session = Zend_Registry::get('session'); + $this->items = $session->authdata; + + $output = ''; + + if ($session->authdata['authed'] !== true) + return $output; + +# $indent = (null !== $indent) +# ? $this->getWhitespace($indent) +# : $this->getIndent(); + $indent = ''; + + $output .= $indent . "
\n"; + $output .= $indent . "\tUser: " . $this->items['authed_username'] . "
\n"; + $output .= $indent . "\tName: " . $this->items['authed_fname'] . ' ' . $this->items['authed_lname'] . "
\n"; + $output .= $indent . "\tRole: " . $this->items['authed_role'] . "
\n"; + if ($this->items['authed_by_crt'] === true) + $output .= $indent . "\tLoginmethod: CRT
\n"; + else + $output .= $indent . "\tLoginmethod: PASSWD
\n"; + $output .= $indent . "
\n"; + + return $output; + } +} diff --git a/manager/application/views/scripts/error/error.phtml b/manager/application/views/scripts/error/error.phtml new file mode 100644 index 0000000..1782039 --- /dev/null +++ b/manager/application/views/scripts/error/error.phtml @@ -0,0 +1,28 @@ + + + + + Zend Framework Default Application + + +

An error occurred

+

message ?>

+ + + +

Exception information:

+

+ Message: exception->getMessage() ?> +

+ +

Stack trace:

+
exception->getTraceAsString() ?>
+  
+ +

Request Parameters:

+
request->getParams(), true) ?>
+  
+ + + + diff --git a/manager/application/views/scripts/error/permissiondenied.phtml b/manager/application/views/scripts/error/permissiondenied.phtml new file mode 100644 index 0000000..8219e5b --- /dev/null +++ b/manager/application/views/scripts/error/permissiondenied.phtml @@ -0,0 +1,8 @@ + +

+ \ No newline at end of file diff --git a/manager/application/views/scripts/index/index.phtml b/manager/application/views/scripts/index/index.phtml new file mode 100644 index 0000000..58c9dc9 --- /dev/null +++ b/manager/application/views/scripts/index/index.phtml @@ -0,0 +1,7 @@ + +

diff --git a/manager/application/views/scripts/login/index.phtml b/manager/application/views/scripts/login/index.phtml new file mode 100644 index 0000000..57f49ea --- /dev/null +++ b/manager/application/views/scripts/login/index.phtml @@ -0,0 +1,16 @@ +headScript()->appendFile('js/1st.js'); +// $this->headScript()->appendFile('js/2nd.js'); +$this->headLink()->appendStylesheet('/css/login.css'); + +$this->headLink()->appendStylesheet('/css/form_dl.css'); +?> + +

+form;?> + \ No newline at end of file diff --git a/manager/application/views/scripts/login/loginresult.phtml b/manager/application/views/scripts/login/loginresult.phtml new file mode 100644 index 0000000..09437ca --- /dev/null +++ b/manager/application/views/scripts/login/loginresult.phtml @@ -0,0 +1,16 @@ +session->authdata['authed']) { +?> +

Willkommen im Club, session->authdata['authed_username']; ?>

+ +

Bitte loggen Sie sich ein.

+ +

diff --git a/manager/library/actions/ActionIndex.php b/manager/library/actions/ActionIndex.php new file mode 100644 index 0000000..2771bad --- /dev/null +++ b/manager/library/actions/ActionIndex.php @@ -0,0 +1,53 @@ +instanceName = $instanceName; + + if ($db === null) + $db = Zend_Db::factory($config->dnssecme->db->config->pdo, $config->dnssecme->db->config); + + $this->config = new Config_Db($db, $instanceName, $where, true); + } + + /** + * get already existing instance, make new instance or throw an exception + * @param string $instanceName + * @param Zend_Db_Adapter $db + * @param string $where + */ + public static function getInstance($instanceName, $db = null, $where = null) { + if ($instanceName === null) + throw new Exception(__METHOD__ . ': expected an instance name, got none'); + + // no caching if presumeably volatile data is requested + if ($db !== null && $where !== null) { + return new Config($instanceName, $db, $where); + } + + if (!array_key_exists($instanceName, self::$instances)) { + self::$instances[$instanceName] = new Config($instanceName, $db, $where); + } + + return self::$instances[$instanceName]; + } + + /** + * magic method that dispatches all unrecognized method calls to the config object + * + * @param string $param + */ + public function __get($param) { + return $this->config->$param; + } + + /** + * magic method that handles isset inquiries to attributes + * + * @param string $param + */ + public function __isset($param) { + return isset($this->config->$param); + } + + /** + * magic method that dispatches all unrecognized method calls to the config object + * + * @param string $param + * @param string $value + */ + public function __set($param, $value) { + $this->config->$param = $value; + } + + /** + * get the config object + * @return Zend_Config_* + */ + public function getConfig() { + return $this->config; + } +} +?> \ No newline at end of file diff --git a/manager/library/config/Config_Db.php b/manager/library/config/Config_Db.php new file mode 100644 index 0000000..fa312df --- /dev/null +++ b/manager/library/config/Config_Db.php @@ -0,0 +1,339 @@ +hostname === "staging" + * $data->db->connection === "database" + * + * The $options parameter may be provided as either a boolean or an array. + * If provided as a boolean, this sets the $allowModifications option of + * Zend_Config. If provided as an array, there are two configuration + * directives that may be set. For example: + * + * $options = array( + * 'allowModifications' => false, + * 'nestSeparator' => '->' + * ); + * + * @param Zend_Db $dbc + * @param string $db_table + * @param string|null $section + * @param boolean|array $options + * @throws Zend_Config_Exception + * @return void + */ + public function __construct($dbc, $db_table, $section = null, $options = false) + { + if (empty($dbc)) { + /** + * @see Zend_Config_Exception + */ + require_once 'Zend/Config/Exception.php'; + throw new Zend_Config_Exception('Database connection is not set'); + } + + if (empty($db_table)) { + /** + * @see Zend_Config_Exception + */ + require_once 'Zend/Config/Exception.php'; + throw new Zend_Config_Exception('Database table is not set'); + } + + $allowModifications = false; + if (is_bool($options)) { + $allowModifications = $options; + } elseif (is_array($options)) { + if (isset($options['allowModifications'])) { + $allowModifications = (bool) $options['allowModifications']; + } + if (isset($options['nestSeparator'])) { + $this->_nestSeparator = (string) $options['nestSeparator']; + } + if (isset($options['skipExtends'])) { + $this->_skipExtends = (bool) $options['skipExtends']; + } + } + + $iniArray = $this->_loadIniFile($dbc, $db_table, $section); + $section = null; + + if (null === $section) { + // Load entire file + $dataArray = array(); + foreach ($iniArray as $sectionName => $sectionData) { + if(!is_array($sectionData)) { + $dataArray = array_merge_recursive($dataArray, $this->_processKey(array(), $sectionName, $sectionData)); + } else { + $dataArray[$sectionName] = $this->_processSection($iniArray, $sectionName); + } + } + parent::__construct($dataArray, $allowModifications); + } else { + // Load one or more sections + if (!is_array($section)) { + $section = array($section); + } + $dataArray = array(); + foreach ($section as $sectionName) { + if (!isset($iniArray[$sectionName])) { + /** + * @see Zend_Config_Exception + */ + require_once 'Zend/Config/Exception.php'; + throw new Zend_Config_Exception("Section '$sectionName' cannot be found"); + } + $dataArray = array_merge($this->_processSection($iniArray, $sectionName), $dataArray); + + } + parent::__construct($dataArray, $allowModifications); + } + + $this->_loadedSection = $section; + } + + /** + * Load data from database and preprocess the section separator (':' in the + * section name (that is used for section extension) so that the resultant + * array has the correct section names and the extension information is + * stored in a sub-key called ';extends'. We use ';extends' as this can + * never be a valid key name in an INI file that has been loaded using + * parse_ini_file(). + * + * @param Zend_Db $dbc + * @param string $db_table + * @throws Zend_Config_Exception + * @return array + */ + protected function _loadIniFile($dbc, $db_table, $section = null) + { + set_error_handler(array($this, '_loadFileErrorHandler')); + $loaded = $this->_parse_ini_db($dbc, $db_table, $section); // Warnings and errors are suppressed + restore_error_handler(); + // Check if there was a error while loading file + if ($this->_loadFileErrorStr !== null) { + /** + * @see Zend_Config_Exception + */ + require_once 'Zend/Config/Exception.php'; + throw new Zend_Config_Exception($this->_loadFileErrorStr); + } + + $iniArray = array(); + foreach ($loaded as $key => $data) + { + $pieces = explode($this->_sectionSeparator, $key); + $thisSection = trim($pieces[0]); + switch (count($pieces)) { + case 1: + $iniArray[$thisSection] = $data; + break; + + case 2: + $extendedSection = trim($pieces[1]); + $iniArray[$thisSection] = array_merge(array(';extends'=>$extendedSection), $data); + break; + + default: + /** + * @see Zend_Config_Exception + */ + require_once 'Zend/Config/Exception.php'; + throw new Zend_Config_Exception("Section '$thisSection' may not extend multiple sections"); + } + } + + return $iniArray; + } + + /** + * read config from (current db in $dbc).$db_table + * + * @param Zend_Db $dbc + * @param string $db_table + * @param string $section + * @return array + */ + protected function _parse_ini_db($dbc, $db_table, $section) { + $sql = 'select * from ' . $db_table; + if ($section !== null) { + $sql .= ' where ' . $section; + } + + $db_config = $dbc->query($sql); + + $config = array(); + + while (($row = $db_config->fetch()) !== false) { + $key = explode('.', $row['config_key']); + $depth = count($key); + $ci = &$config; + for ($cnt = 0; $cnt < $depth; $cnt++) { + if ($cnt == ($depth - 1)) + $ci[$key[$cnt]] = $row['config_value']; + elseif (!isset($ci[$key[$cnt]])) + $ci[$key[$cnt]] = array(); + $ci = &$ci[$key[$cnt]]; + } + } + return $config; + } + + /** + * Process each element in the section and handle the ";extends" inheritance + * key. Passes control to _processKey() to handle the nest separator + * sub-property syntax that may be used within the key name. + * + * @param array $iniArray + * @param string $section + * @param array $config + * @throws Zend_Config_Exception + * @return array + */ + protected function _processSection($iniArray, $section, $config = array()) + { + $thisSection = $iniArray[$section]; + + foreach ($thisSection as $key => $value) { + if (strtolower($key) == ';extends') { + if (isset($iniArray[$value])) { + $this->_assertValidExtend($section, $value); + + if (!$this->_skipExtends) { + $config = $this->_processSection($iniArray, $value, $config); + } + } else { + /** + * @see Zend_Config_Exception + */ + require_once 'Zend/Config/Exception.php'; + throw new Zend_Config_Exception("Parent section '$section' cannot be found"); + } + } else { + $config = $this->_processKey($config, $key, $value); + } + } + return $config; + } + + /** + * Assign the key's value to the property list. Handles the + * nest separator for sub-properties. + * + * @param array $config + * @param string $key + * @param string $value + * @throws Zend_Config_Exception + * @return array + */ + protected function _processKey($config, $key, $value) + { + if (strpos($key, $this->_nestSeparator) !== false) { + $pieces = explode($this->_nestSeparator, $key, 2); + if (strlen($pieces[0]) && strlen($pieces[1])) { + if (!isset($config[$pieces[0]])) { + if ($pieces[0] === '0' && !empty($config)) { + // convert the current values in $config into an array + $config = array($pieces[0] => $config); + } else { + $config[$pieces[0]] = array(); + } + } elseif (!is_array($config[$pieces[0]])) { + /** + * @see Zend_Config_Exception + */ + require_once 'Zend/Config/Exception.php'; + throw new Zend_Config_Exception("Cannot create sub-key for '{$pieces[0]}' as key already exists"); + } + $config[$pieces[0]] = $this->_processKey($config[$pieces[0]], $pieces[1], $value); + } else { + /** + * @see Zend_Config_Exception + */ + require_once 'Zend/Config/Exception.php'; + throw new Zend_Config_Exception("Invalid key '$key'"); + } + } else { + $config[$key] = $value; + } + return $config; + } +} diff --git a/manager/library/config/Config_Writer_Db.php b/manager/library/config/Config_Writer_Db.php new file mode 100644 index 0000000..1614a41 --- /dev/null +++ b/manager/library/config/Config_Writer_Db.php @@ -0,0 +1,217 @@ +setTableName('system_config'); + * $writer->write(Zend_Registry::get('config_dbc'), Zend_Registry::get('config')); + * + * $writer = new Config_Writer_Db(); + * $writer->setTableName('dnssec_org_param'); + * $writer->write(Zend_Registry::get('config_dbc'), dnssec_org_conf, 'dnssec_org_id="2"'); + */ + +/** + * @see Zend_Config_Writer + */ +require_once 'Zend/Config/Writer.php'; + +/** + * @category Zend + * @package Zend_Config + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) + * @license http://framework.zend.com/license/new-bsd New BSD License + */ +class Config_Writer_Db extends Zend_Config_Writer +{ + /** + * String that separates nesting levels of configuration data identifiers + * + * @var string + */ + protected $_nestSeparator = '.'; + + protected $_set = null; + + protected $_tableName = null; + + /** + * Set the nest separator + * + * @param string $filename + * @return Zend_Config_Writer_Ini + */ + public function setNestSeparator($separator) + { + $this->_nestSeparator = $separator; + + return $this; + } + + public function setTableName($name) + { + $this->_tableName = $name; + + return $this; + } + + /** + * Defined by Zend_Config_Writer + * + * use set to limit impact when a shared config file is used (i.e. config per item using foreign keys) + * + * @param string $filename + * @param Config_Db $config + * @param string $set + * @return void + */ + public function write($db = null, $config = null, $set = null) { + $this->_set = $set; + + // this method is specialized for writing back Config objects (which hold config_db objects) + if ($config !== null) { + if ($config instanceof Config) + $this->setConfig($config->getConfig()); + else { + $this->setConfig($config); + } + } + + if ($this->_config === null) { + require_once 'Zend/Config/Exception.php'; + throw new Zend_Config_Exception('No config was set'); + } + + if ($db === null) { + require_once 'Zend/Config/Exception.php'; + throw new Zend_Config_Exception('No db was set'); + } + + $sql = array(); + + $string = 'delete from ' . $this->_tableName; + if ($this->_set !== null) { + $string .= ' where ' . $this->_set; + } + + $sql[] = $string; + + $iniString = ''; + $extends = $this->_config->getExtends(); + $sectionName = $this->_config->getSectionName(); + + foreach ($this->_config as $key => $data) { + $sql= array_merge($sql, $this->addEntry($sectionName, $key, $data)); + } + + try { + $db->beginTransaction(); + foreach ($sql as $command) { + #Log::Log()->debug($command); + $db->query($command); + } + $db->commit(); + } catch (Exception $e) { + $db->rollBack(); + Log::Log()->err($e); + throw $e; + } + } + + /** + * build key value pairs, key is created by recursively adding section names, delimited by "." + * @param string $prefix + * @param string $key + * @param mixed $data + */ + protected function addEntry($prefix, $key, $data) { + $sql = array(); + + if ($data instanceof Zend_Config) { + if ($prefix != '') + $prefix .= '.'; + $prefix .= $key; + foreach ($data as $k => $v) { + $sql = array_merge($sql, $this->addEntry($prefix, $k, $v)); + } + } + else { + $string = 'insert into ' . $this->_tableName . ' set '; + $pkey = $prefix; + if ($pkey != '') + $pkey .= '.'; + $pkey .= $key; + $string .= 'config_key=' . $this->_prepareValue($pkey) . ', '; + $string .= 'config_value=' . $this->_prepareValue($data); + if ($this->_set !== null) + $string .= ', ' . $this->_set; + + $sql[] = $string; + } + + return $sql; + } + + /** + * Add a branch to an INI string recursively + * + * @param Zend_Config $config + * @return void + */ + protected function _addBranch(Zend_Config $config, $parents = array()) + { + $iniString = ''; + + foreach ($config as $key => $value) { + $group = array_merge($parents, array($key)); + + if ($value instanceof Zend_Config) { + $iniString .= $this->_addBranch($value, $group); + } else { + $iniString .= implode($this->_nestSeparator, $group) + . ' = ' + . $this->_prepareValue($value) + . "\n"; + } + } + + return $iniString; + } + + /** + * Prepare a value for INI + * + * @param mixed $value + * @return string + */ + protected function _prepareValue($value) + { + if (is_integer($value) || is_float($value)) { + return $value; + } elseif (is_bool($value)) { + return ($value ? 'true' : 'false'); + } else { + return '"' . addslashes($value) . '"'; + } + } +} diff --git a/manager/library/date/HumanReadableTime.php b/manager/library/date/HumanReadableTime.php new file mode 100644 index 0000000..ee75703 --- /dev/null +++ b/manager/library/date/HumanReadableTime.php @@ -0,0 +1,140 @@ + 0, 'd' => 0, 'h' => 0, 'm' => 0, 's' => 0); + if (!in_array($maxunit, array_keys($allowed), true)) + throw new HumanReadableTimeException('illegal value for maxunit: "' . $maxunit . '"'); + foreach ($allowed as $key => $value) { + if ($maxunit == $key) + break; + unset($allowed[$key]); + } + + $seconds = intval($seconds); + $hrt = ''; + foreach ($allowed as $key => $value) { + switch ($key) { + case 'w': + $tmp = intval($seconds / (7*86400)); + if ($tmp > 0) + $seconds %= (7*86400); + $allowed[$key] += $tmp; + break; + case 'd': + $tmp = intval($seconds / (86400)); + if ($tmp > 0) + $seconds %= (86400); + $allowed[$key] += $tmp; + break; + case 'h': + $tmp = intval($seconds / (3600)); + if ($tmp > 0) + $seconds %= (3600); + $allowed[$key] += $tmp; + break; + case 'm': + $tmp = intval($seconds / (60)); + if ($tmp > 0) + $seconds %= (60); + $allowed[$key] += $tmp; + break; + case 's': + $allowed[$key] += $seconds; + break; + } + } + + $hrt = ''; + foreach ($allowed as $key => $value) { + if ($value > 0) + $hrt .= sprintf('%d%s', $value, $key); + } + return $hrt; + } + + /** + * parse a string of 3h2m7s and return the number of seconds as integer + * add "s" to the end of the number if $addsecond is set to true + * @param string $hr + * @param boolean $addsecond + * @return integer|string + */ + public static function HR2Seconds($hr, $addsecond = false) { + $hr = trim($hr); + if ($hr == '') { + if ($addsecond === true) + return '0s'; + else + return 0; + } + + $hr = strtolower($hr); + + $matches = array(); + if (preg_match_all('/([0-9]*)([wdhms])/', $hr, $matches, PREG_SET_ORDER) > 0) { + $interval = 0; + for ($i = 0; $i < count($matches); $i++) { + switch ($matches[$i][2]) { + case 'w': + $interval += $matches[$i][1] * 7 * 86400; + break; + case 'd': + $interval += $matches[$i][1] * 86400; + break; + case 'h': + $interval += $matches[$i][1] * 3600; + break; + case 'm': + $interval += $matches[$i][1] * 60; + break; + case 's': + $interval += $matches[$i][1]; + break; + } + } + if ($addsecond === true) + return sprintf('%ds', $interval); + else + return $interval; + } + + if ($addsecond === true) + return '0s'; + else + return 0; + } +} diff --git a/manager/library/date/exception.HumanReadableTimeException.php b/manager/library/date/exception.HumanReadableTimeException.php new file mode 100644 index 0000000..2698d58 --- /dev/null +++ b/manager/library/date/exception.HumanReadableTimeException.php @@ -0,0 +1,37 @@ + + * @since 2009-02-25 13:05 + * @version $Id: exception.HumanReadableTimeException.php 91 2010-03-10 10:36:25Z markus $ + */ +class HumanReadableTimeException extends BaseException { + /** + * make new object + * + * @access public + * @param string $message + * @param int $code + * @param string $extra + */ + /* + public function __construct($message,$code = 0,$extra = '') { + parent::__construct($message,$code, $extra); + } + */ +} +?> \ No newline at end of file diff --git a/manager/library/date/testHumanReadableTime.php b/manager/library/date/testHumanReadableTime.php new file mode 100644 index 0000000..177d650 --- /dev/null +++ b/manager/library/date/testHumanReadableTime.php @@ -0,0 +1,16 @@ + + * @since 2009-02-23 16:10 + * @version $Id: exception.Base.php 90 2010-03-09 09:48:27Z markus $ + */ +class BaseException extends Exception { + /** + * additional data / string + * @var string + */ + protected $extra = ''; + + /** + * location of thrower + * @var string + */ + protected $exception_location = ''; + + /** + * make new object + * + * @access public + * @param string $message + * @param int $code + */ + public function __construct($message, $code = 0, $extra = '') { + $bt = debug_backtrace(); + + $remove_exception = 0; + while( $remove_exception < count($bt) && isset($bt[$remove_exception]['class']) && eregi('exception', $bt[$remove_exception]['class']) ) { + $remove_exception++; + } + + if ($remove_exception > 0) + $remove_exception--; + + if ($remove_exception < count($bt)) { + $this->exception_location = $bt[$remove_exception]['file'].':'.$bt[$remove_exception]['line']; + } + + $this->extra = $extra; + + parent::__construct($message,$code); + } + + /** + * Make a string out of this exception + * + * @access public + * @return string + */ + public function __toString() { + $out = __CLASS__ . '['.$this->code.']:'; + + if ($this->exception_location != '') + $out.= $this->exception_location; + $out .= ':'; + + $out .= " {$this->message}"; + + if (isset($this->extra) && strlen($this->extra) > 0) + $out .= " ({$this->extra})\n"; + + return $out; + } + + /** + * get the extra info string + * + * @access public + * @return string + */ + public function getExtraInfo() { + return $this->extra; + } + + /** + * get the exception location string + * + * @access public + * @return string + */ + public function getExceptionLocation() { + return $this->exception_location; + } + +} +?> \ No newline at end of file diff --git a/manager/library/global/defines.php b/manager/library/global/defines.php new file mode 100644 index 0000000..4e90ac5 --- /dev/null +++ b/manager/library/global/defines.php @@ -0,0 +1,28 @@ + \ No newline at end of file diff --git a/manager/library/i18n/I18n.php b/manager/library/i18n/I18n.php new file mode 100644 index 0000000..b95fb51 --- /dev/null +++ b/manager/library/i18n/I18n.php @@ -0,0 +1,95 @@ + Log::Log(), + 'logUntranslated' => true + ); + + $locale = L10n::getInstance(); + $supported = $locale->getBrowser(); + arsort($supported, SORT_NUMERIC); + + $file = ''; + foreach ($supported as $loc => $val) { + if (file_exists(LOCALE_PATH . '/' . $loc . '/locale.php')) { + $file = LOCALE_PATH . '/' . $loc . '/locale.php'; + $locale->setLocale($loc); + break; + } + } + + if ($file == '' && file_exists(LOCALE_PATH . '/en_US/locale.php')) { + $file = LOCALE_PATH . '/en_US/locale.php'; + $locale->setLocale('en_US'); + } + + if ($file != '') { + $this->translate = new Zend_Translate(Zend_Translate::AN_ARRAY, $file, $locale->getLanguage(), $options); + #Log::Log()->debug('locale ' . $locale->getLanguage() . '_' .$locale->getRegion() . ' loaded'); + } + else + throw new Exception(__METHOD__ . ': no translation files available'); + } + + /** + * get already existing instance, make new instance or throw an exception + * @return I18n + */ + public static function getInstance() { + if (self::$instance === null) { + self::$instance = new I18n(); + } + + return self::$instance; + } + + /** + * return the Zend_Translate object + * @return Zend_Translate + */ + public static function getTranslate() { + return self::getInstance()->translate; + } + + /** + * map _ to translate + * @param unknown_type $text + * @param unknown_type $locale + */ + public function _($text, $locale = null) { + return self::getInstance()->translate->_($text, $locale); + } + + /** + * magic __call dispatches all unknown methods to Zend_Translate + * @param unknown_type $method + * @param unknown_type $arguments + */ + public function __call($method, $arguments) { + return call_user_func_array(array($this->translate, $method), $arguments); + } +} diff --git a/manager/library/l10n/L10n.php b/manager/library/l10n/L10n.php new file mode 100644 index 0000000..80fb091 --- /dev/null +++ b/manager/library/l10n/L10n.php @@ -0,0 +1,47 @@ +locale = new Zend_Locale(); + } + + /** + * get already existing instance, make new instance or throw an exception + * @return L10n + */ + public static function getInstance() { + if (self::$instance === null) { + self::$instance = new L10n(); + } + + return self::$instance; + } + + /** + * magic __call dispatches all unknown methods to Zend_Locale + * @param unknown_type $method + * @param unknown_type $arguments + */ + public function __call($method, $arguments) { + return call_user_func_array(array($this->locale, $method), $arguments); + } +} diff --git a/manager/library/log/Log.php b/manager/library/log/Log.php new file mode 100644 index 0000000..8ad27b9 --- /dev/null +++ b/manager/library/log/Log.php @@ -0,0 +1,105 @@ +$instanceName; + + $this->log = new Zend_Log(); + if (isset($log_config->file) && intval($log_config->file->enabled) !== 0) { + $file_logger = new Zend_Log_Writer_Stream($log_config->file->name); + + /** + * + $format = Zend_Log_Formatter_Simple::DEFAULT_FORMAT; + $formatter = new Zend_Log_Formatter_Simple($format); + $file_logger->setFormatter($formatter); + */ + if (isset($application) && $application != '') + $this->log->setEventItem('application', $application); + $formatter = new Zend_Log_Formatter_Simple('%syslog_time% %application%[%pid%]: %priorityName%: %message%' . PHP_EOL); + $file_logger->setFormatter($formatter); + $this->log->addWriter($file_logger); + } + if (isset($log_config->syslog) && intval($log_config->syslog->enabled) !== 0) { + $param = array('facility' => $log_config->syslog->facility); + if (isset($application) && $application != '') + $param['application'] = $application; + + $sys_logger = new Zend_Log_Writer_Syslog($param); + $formatter = new Zend_Log_Formatter_Simple('%priorityName%: %message%' . PHP_EOL); + $sys_logger->setFormatter($formatter); + $this->log->addWriter($sys_logger); + } + + $filter = new Zend_Log_Filter_Priority(intval($log_config->priority)); + $this->log->addFilter($filter); + } + + /** + * get already existing instance, make new instance or throw an exception + * @param string $instanceName + * @param string $application + */ + public static function getInstance($instanceName = null, $application = null) { + if ($instanceName === null) { + if (count(self::$instances) == 0) + throw new Exception(__METHOD__ . ': expected an instance name, got none'); + return self::$instances[0]; + } + + if (!array_key_exists($instanceName, self::$instances)) { + self::$instances[$instanceName] = new Log($instanceName, $application); + } + + return self::$instances[$instanceName]; + } + + /** + * return SYSTEM_LOG for convenience + * @return Zend_Log + */ + public static function Log() { + return self::$instances[SYSTEM_LOG]->getLog(); + } + + /** + * get the Zend_Log object + * @return Zend_Log + */ + public function getLog() { + $this->log->setEventItem('pid', posix_getpid()); + $this->log->setEventItem('syslog_time', date('Y-m-d H:i:s')); + return $this->log; + } +} diff --git a/manager/library/plugins/plugin.buildmenu.php b/manager/library/plugins/plugin.buildmenu.php new file mode 100644 index 0000000..d98b14e --- /dev/null +++ b/manager/library/plugins/plugin.buildmenu.php @@ -0,0 +1,74 @@ +authdata) || !isset($session->authdata['authed']) || $session->authdata['authed'] === false) + return; + + $cur_ctrl = $request->getControllerName(); + $cur_action = $request->getActionName(); + + $view = Zend_Registry::get('view'); + + if (is_dir(FWACTIONS_PATH)) { + $dir = opendir(FWACTIONS_PATH); + + while (($file = readdir($dir)) !== false) { + if ($file == '.' || $file == '..') + continue; + if (preg_match('/^Action([a-zA-Z0-9_]*)\.php/', $file, $match)) { + $path = FWACTIONS_PATH . '/' . $file; + require_once($path); + + $r = new ReflectionClass($match[1]); + + if ($r->isSubclassOf('FWAction')) { + /** + * match Actions permission with the permissions of the currently logged in user, + * add to menu if user has access to that action + */ + + $required = $r->getMethod('getRequiredPermissions')->invoke(null); + $menuprio = $r->getMethod('getTopNavPrio')->invoke(null); + $ctrl = $r->getMethod('getController')->invoke(null); + $action = $r->getMethod('getAction')->invoke(null); + $text = $r->getMethod('getMenutext')->invoke(null); + $role = $session->authdata['authed_role']; + + if ($cur_ctrl == $ctrl) # && $cur_action == $action) + $aclass = ' class="active"'; + else + $aclass = ''; + + $acl = $session->authdata['authed_permissions']; + if (is_array($required) && count($required) == 0) { + $view->topNav('' . I18n::_($text) . '', Zend_View_Helper_Placeholder_Container_Abstract::SET, $menuprio); + } + else { + foreach ($required as $rperm) { + if ($acl->has($rperm) && $acl->isAllowed($role, $rperm, 'view')) { + $view->topNav('' . I18n::_($text) . '', Zend_View_Helper_Placeholder_Container_Abstract::SET, $menuprio); + break; // exit on first match + } + } + } + } + } + } + + closedir($dir); + } + } +} \ No newline at end of file diff --git a/manager/library/plugins/plugin.charsetheader.php b/manager/library/plugins/plugin.charsetheader.php new file mode 100644 index 0000000..57e4f50 --- /dev/null +++ b/manager/library/plugins/plugin.charsetheader.php @@ -0,0 +1,13 @@ +getResponse(); + if ($response->canSendHeaders() === true) { + $response->setHeader('Content-Type', 'text/html; charset=utf-8'); + } + } +} \ No newline at end of file diff --git a/manager/library/plugins/plugin.forceauth.php b/manager/library/plugins/plugin.forceauth.php new file mode 100644 index 0000000..4fa9068 --- /dev/null +++ b/manager/library/plugins/plugin.forceauth.php @@ -0,0 +1,29 @@ +getControllerName(), array('login', 'error', 'js', 'img', 'css'))) + return; + + if (!isset($session->authdata) || !isset($session->authdata['authed']) || $session->authdata['authed'] === false) { + $fc = Zend_Controller_Front::getInstance(); + + $response = $fc->getResponse(); + $response->canSendHeaders(true); + + $response->setHeader('Location', 'login', true); + $response->setHeader('Status', '301', true); + Log::Log()->debug('redirected to login'); + + $request->setModuleName('default') + ->setControllerName('login') + ->setActionName('index') + ->setDispatched(false); + } + } +} diff --git a/manager/library/plugins/plugin.loginlogout.php b/manager/library/plugins/plugin.loginlogout.php new file mode 100644 index 0000000..6de7a92 --- /dev/null +++ b/manager/library/plugins/plugin.loginlogout.php @@ -0,0 +1,25 @@ +authdata) || !isset($session->authdata['authed']) || $session->authdata['authed'] === false) { + $controller = 'login'; + $text = 'Login'; + } + else { + $controller = 'logout'; + $text = 'Logout'; + } + $view = Zend_Registry::get('view'); + $view->topNav('' . I18n::_($text) . '', Zend_View_Helper_Placeholder_Container_Abstract::SET, 1000); + } +} diff --git a/manager/locale/en_US/locale.php b/manager/locale/en_US/locale.php new file mode 100644 index 0000000..68e6ef9 --- /dev/null +++ b/manager/locale/en_US/locale.php @@ -0,0 +1,2 @@ +t2@_LWirQ+I*1C4tZgzFw+PkxjSJOkUeP@2>%=gWA=A8Ke3%2a-!FFpTTLF#$ zJQ-GkD`T$zFS1xemK%`m4&-^;;33Bj0**ZdJ`NE0IzSlc#5hA30BS5V3tnI@>@5=M&Bj&i*2tUzVY2lTak!$8|l)F{QMHB*UEr)t8Wq6LGU ztq}K0A?cMt(kFwI`O^O#YGpUnsveB|`OPTNHrxS)x(k|tK4=E}p;Zqt!_bW|qa)C3 zMlqxthC!=^UZ=&VUIT+(2c1C&qrm`!(aZ=VV;WoK2w=bL%pTIl-3G7FfyW{?ek1$ifL zJ++fuw{yv#tjXi>x&vW*6F1rgaVcTdR9flh;~O66X0>_~m*(3Ckw@J6gJBVihyu7Y zo4w>oYtL*u;X=zpxHOAwX+Q0zC~~HS!CbP9pFZ~Qb3AuAY>B1CmUG8)qGMi>M^2`m P<|O^g$2%r6JM-PY8ec|( literal 0 HcmV?d00001 diff --git a/manager/public/img/cacert4.png b/manager/public/img/cacert4.png new file mode 100644 index 0000000000000000000000000000000000000000..e4650a09e65ada22bf31b974cdef239724f370e1 GIT binary patch literal 6421 zcmXw;Wn5HU6TmOsEg-pcF0rt5BOoQx-ICHQ(%lWxAdP@@N_Q_HAtfOoAR*mKzWaQ5 zKiv48dvea4ng7g1FD^UgLZkh-@y(B;jm#`MWqr~E{RU^eLd1of z;ruuO_7vhPiby)>G^vYj<9h_iec`Knc&LM(Y{{7N{`u;CTBO9*7Y|oICttkGttSuI z4RO3leQT?yS{QU1U(mU?LF*OXY-)<01SQt)bKIT}e)nBL69qqW3AE!;t*r3HDm;x) zrz-9B$bbW<8rUI5U%PVL%c-HN!%g-;O=M@*+X==&enzv5Fa z29F4;Wp8}SZ)>O0knbz#r?8rVWEUx;Ycx>9q|E3%x*Y5#Za3aTOqC*8Ene1l{xQ18 zHoJpYIR%6z!mT1Z(9o|eXrMr_+Yc-N)P5<9_gzfjxRBWk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W zI??C$;z0btjSw4CBTqr2hTGDo_Z-x!tkC7RHQd%25$y5mkc$_U;zAA>{!}PNHGtzN zT+_Q?+FOqO%J%T6bye{_LvaQ_H?dKJByo@QmnHF>zHu(7I_wu;d$aM>;*y|D6)S+0 z1%ZJ+lx*w~+6#d~^RC0dP6?a4cOi1o0~Y%RrB(FSbXLslR(O2VlIC79sN!YoUpSb; zk@G8)rQ?_-b}-V*jBXI=xXZW~^8U1y$y(#l$g*Sp@@^Hf=y1G2su|nn#8?E^Er@ii z^_N!+fWB^U76H3MZ(9F%6mFfFJ60fA_qD|;$MNiueQF&I~OM>YiADt@Lu7XXuu1T#zmXSXMaMLVU1OPU7d`E`){vl z$YKYUdOWvt?Q(ffRmRnjcHs{$t^Q$(!Dvg6xBd;iI*#}ay5~jcg{9&}80GrMgfqiq zUXf=~69qokjyv&3;QcrH5;3}y{|06GZ%{248xJoFckBN~g%O--xK5ApaI>p%kAvAX d>Sy@*0pPVOdaTC&!Zo4=pd_y*S1W5C`ahc%Nc;c* literal 0 HcmV?d00001 diff --git a/manager/public/index.php b/manager/public/index.php new file mode 100644 index 0000000..229290b --- /dev/null +++ b/manager/public/index.php @@ -0,0 +1,51 @@ + getForm, ...) + * @todo favicon + * @todo sinnvolle Defaults, wenn system_config leer ist (globale Config BIND) + * @todo sinnvolle Defaults, wenn system_config leer ist (Organisationsconfig BIND) + * @todo Links zum Löschen für Zonen / Organisationen, Rechtechecks in ActionController (foreign key constraints beachten!) + * @todo ConfigBIND left Menu geht nicht aus, wenn man die selektierte Org deaktiviert (init vor Action) + * @todo Textausgabe, wenn Attribute aus Defaults initialisiert und NICHT aus der DB geladen wurden + */ + +require_once('../library/global/defines.php'); + +try { + /** Zend Autoloader */ + require_once 'Zend/Loader/Autoloader.php'; + Zend_Loader_Autoloader::getInstance(); + + // Create application, bootstrap, and run + $application = new Zend_Application( + APPLICATION_ENV, + APPLICATION_PATH . '/configs/application.ini' + ); + + /** override settings from application.ini, if necessary + $fc = Zend_Controller_Front::getInstance(); + $fc->setControllerDirectory(realpath(APPLICATION_PATH . '/controllers')); + $fc->setParam('noViewRenderer', false); + $fc->throwExceptions(true); + $fc->setParam('noErrorHandler', false); + */ + + $application->bootstrap() + ->run(); +} catch (Exception $e) { + print "Exception: " . $e->getMessage() . "\n"; + print $e->getTraceAsString() . "\n"; + Log::Log()->emerg($e); +} diff --git a/manager/public/js/center.js b/manager/public/js/center.js new file mode 100644 index 0000000..267550c --- /dev/null +++ b/manager/public/js/center.js @@ -0,0 +1,10 @@ +function setCSS() { + var x = window.innerWidth; + + x = x - 18; // maybe scroll bar + document.getElementById('center').style.width = x + "px"; + document.getElementById('center').style.marginLeft = "-" + x/2 + "px"; +} + +window.onload = setCSS; +window.onresize = setCSS; diff --git a/manager/public/js/positionUserInfo.js b/manager/public/js/positionUserInfo.js new file mode 100644 index 0000000..0de1db4 --- /dev/null +++ b/manager/public/js/positionUserInfo.js @@ -0,0 +1,17 @@ +function setUserInfoPos() { + var x = window.innerWidth; + var ui; + + x = x - 18; // maybe scroll bar + + ui = document.getElementById('userinfo'); + if (ui != null) { + ui.style.right = "3px"; +// document.getElementById('userinfo').style.bottom = "3px"; + ui.style.bottom = 3 - window.pageYOffset + "px"; + } +} + +window.onload = setUserInfoPos; +window.onresize = setUserInfoPos; +window.onscroll = setUserInfoPos; diff --git a/manager/tests/application/bootstrap.php b/manager/tests/application/bootstrap.php new file mode 100644 index 0000000..e69de29 diff --git a/manager/tests/library/bootstrap.php b/manager/tests/library/bootstrap.php new file mode 100644 index 0000000..e69de29 diff --git a/manager/tests/phpunit.xml b/manager/tests/phpunit.xml new file mode 100644 index 0000000..e69de29