Esempio n. 1
0
 /**
  * Implement this by setting $obj values (e.g. $obj->setId($row->Id) from a DB row
  * @param GD_Model_Server $obj
  * @param Zend_Db_Table_Row_Abstract $row
  */
 protected function populateObjectFromRow(&$obj, Zend_Db_Table_Row_Abstract $row)
 {
     $crypt = new GD_Crypt();
     $decrypted_pwd = $crypt->doDecrypt($row->password);
     $obj->setId($row->id)->setName($row->name)->setHostname($row->hostname)->setConnectionTypesId($row->connection_types_id)->setPort($row->port)->setUsername($row->username)->setPassword($decrypted_pwd)->setRemotePath($row->remote_path)->setProjectsId($row->projects_id);
     $ct_map = new GD_Model_ConnectionTypesMapper();
     $connection_type = new GD_Model_ConnectionType();
     $ct_map->populateObjectFromRow($connection_type, $row->findParentRow('GD_Model_DbTable_ConnectionTypes'));
     $obj->setConnectionType($connection_type);
 }
Esempio n. 2
0
 public function changepasswordAction()
 {
     $this->view->headTitle('Change Password');
     $this->view->headLink()->appendStylesheet("/css/template/form.css");
     $this->view->headLink()->appendStylesheet("/css/pages/profile.css");
     $form = new GDApp_Form_ChangePassword();
     $this->view->form = $form;
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getParams())) {
             $password = $this->_request->getParam('password');
             $crypt = new GD_Crypt();
             $user = GD_Auth_Database::GetLoggedInUser();
             $userMapper = new GD_Model_UsersMapper();
             $user->setPassword($crypt->makeHash($password));
             $userMapper->save($user);
             $this->view->success = true;
         }
     }
 }
Esempio n. 3
0
 public function userAction()
 {
     $this->view->headLink()->appendStylesheet("/css/template/form.css");
     $this->view->headLink()->appendStylesheet("/css/pages/project_servers.css");
     $users = new GD_Model_UsersMapper();
     $user = new GD_Model_User();
     $form_options = array();
     if ($this->_getParam('id') > 0) {
         $this->view->headTitle('Edit User');
         $users->find($this->_getParam('id'), $user);
         $form_options['current_user'] = $user->getName();
         $form = new GDApp_Form_User($form_options);
     } else {
         $this->view->headTitle('Add User');
         $form = new GDApp_Form_User();
         $form->password->setRequired(true)->setDescription('');
         $user->setDateAdded(date("Y-m-d H:i:s"));
     }
     $this->view->form = $form;
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getParams())) {
             if ($this->_getParam('password', false)) {
                 $crypt = new GD_Crypt();
                 $user->setPassword($crypt->makeHash($this->_getParam('password')));
             }
             $user->setName($this->_getParam('username'));
             if ($this->_getParam('active')) {
                 $user->enableUser();
             } else {
                 $user->disableUser();
             }
             $user->setAdmin($this->_getParam('admin'));
             $users->save($user);
             $this->_redirect('/admin');
         }
     } else {
         $data = array('username' => $user->getName(), 'admin' => $user->isAdmin(), 'active' => $user->isActive());
         $form->populate($data);
     }
 }
Esempio n. 4
0
 public function dosetupAction()
 {
     $this->view->headTitle('Configuration');
     $_user_config_file = APPLICATION_PATH . '/configs/config.ini';
     // Create the config ini from session
     $setup_session = new Zend_Session_Namespace('gd_setup_session');
     if (!$setup_session->complete) {
         $config = new Zend_Config(array(), true);
         $config->database = array();
         $config->database->adapter = "PDO_MYSQL";
         $config->database->host = $setup_session->database->host;
         $config->database->username = $setup_session->database->username;
         $config->database->password = $setup_session->database->password;
         $config->database->dbname = $setup_session->database->dbname;
         $writer_opts = array('config' => $config, 'filename' => $_user_config_file);
         $writer = new Zend_Config_Writer_Ini($writer_opts);
         try {
             $writer->write();
         } catch (Exception $ex) {
             if (strpos($ex->getMessage(), 'Could not write to file') !== false) {
                 $setup_session->ini_string = $writer->render();
             }
         }
         // Load the database manually
         Zend_Db_Table::setDefaultAdapter(Zend_Db::factory($config->database->adapter, $config->database->toArray()));
         // Run the appropriate database setup script
         $db_adm = new GD_Db_Admin($config->database->host, $config->database->username, $config->database->password, $config->database->dbname);
         $db_adm->installDatabase();
         // Set the other config values into database
         GD_Config::set("language", $setup_session->language ? $setup_session->language : "english");
         GD_Config::set("setup_complete", "1");
         GD_Config::set("cryptkey", md5(microtime() . $setup_session->admin->username . $setup_session->admin->password));
         GD_Config::set("install_date", date("d/m/Y H:i:s"));
         // Create the first user in the database
         $userMapper = new GD_Model_UsersMapper();
         $crypt = new GD_Crypt();
         $user = new GD_Model_User();
         $user->setName($setup_session->admin->username)->setPassword($crypt->makeHash($setup_session->admin->password))->setDateAdded(date('Y-m-d H:i:s'))->setAdmin(1)->enableUser();
         $userMapper->save($user);
         // Setup the SSH keypair
         $ssh_key = new GD_Model_SSHKey();
         $ssh_key->setSSHKeyTypesId(1);
         $ssh_key->generateKeyPair();
         //$ssh_key->setId(1);
         $ssh_keys_map = new GD_Model_SSHKeysMapper();
         $ssh_key_id = $ssh_keys_map->save($ssh_key);
         GD_Config::set("ssh_key_id", $ssh_key_id);
         $setup_session->complete = true;
     }
     if (isset($setup_session->ini_string)) {
         $this->view->ini = $setup_session->ini_string;
     } else {
         $this->_redirect("/setup/complete");
     }
 }