Module: nagvis
Branch: master
Commit: 6d52d18eab7d6645d139c7203886e95d724717a2
URL:    
http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=6d52d18eab7d6645d139c7203886e95d724717a2

Author: Lars Michelsen <[email protected]>
Date:   Sat Oct  2 15:13:13 2010 +0200

Additional cleanups

---

 share/server/core/classes/CoreModAuth.php         |   38 +++++++++-----------
 share/server/core/classes/CoreModManageShapes.php |    5 ++-
 share/server/core/classes/CoreModule.php          |    2 +-
 3 files changed, 21 insertions(+), 24 deletions(-)

diff --git a/share/server/core/classes/CoreModAuth.php 
b/share/server/core/classes/CoreModAuth.php
index 8654eb5..dc98de7 100644
--- a/share/server/core/classes/CoreModAuth.php
+++ b/share/server/core/classes/CoreModAuth.php
@@ -78,11 +78,12 @@ class CoreModAuth extends CoreModule {
                                        }
                                break;
                                case 'logout':
-                                       if($this->AUTHENTICATION->logout()) {
-                                               new GlobalMessage('NOTE', 
$this->CORE->getLang()->getText('You have been logged out. You will be 
redirected.'), null, null, 1, $this->CORE->getMainCfg()->getValue('paths', 
'htmlbase'));
-                                       } else {
-                                               new GlobalMessage('ERROR', 
$this->CORE->getLang()->getText('Unable to log you out. Maybe it is not 
supported by your authentication module.'), null, null, 1, 
$this->CORE->getMainCfg()->getValue('paths', 'htmlbase'));
-                                       }
+                                       if($this->AUTHENTICATION->logout())
+                                               new GlobalMessage('NOTE', 
$this->CORE->getLang()->getText('You have been logged out. You will be 
redirected.'),
+                                                                 null, null, 
1, $this->CORE->getMainCfg()->getValue('paths', 'htmlbase'));
+                                       else
+                                               new GlobalMessage('ERROR', 
$this->CORE->getLang()->getText('Unable to log you out. Maybe it is not 
supported by your authentication module.'),
+                                                                 null, null, 
1, $this->CORE->getMainCfg()->getValue('paths', 'htmlbase'));
                                break;
                        }
                }
@@ -91,29 +92,22 @@ class CoreModAuth extends CoreModule {
        }
        
        private function handleResponseAuth() {
-               $bValid = true;
-               // Validate the response
-               
-               // Check for needed params
-               if($bValid && !$this->FHANDLER->isSetAndNotEmpty('username'))
-                       $bValid = false;
-               if($bValid && !$this->FHANDLER->isSetAndNotEmpty('password'))
-                       $bValid = false;
+               $attr = Array('username' => MATCH_USER_NAME,
+                             'password' => null);
+               $this->verifyValuesSet($this->FHANDLER,   $attr);
+               $this->verifyValuesMatch($this->FHANDLER, $attr);
                
                // Check length limits
+               $bValid = true;
                if($bValid && $this->FHANDLER->isLongerThan('username', 
AUTH_MAX_USERNAME_LENGTH))
                        $bValid = false;
                if($bValid && $this->FHANDLER->isLongerThan('password', 
AUTH_MAX_PASSWORD_LENGTH))
                        $bValid = false;
-
-               // Some regex validation
-               if($bValid && !$this->FHANDLER->match('username', 
MATCH_USER_NAME))
-                       $bValid = false;
                
                //@todo Escape vars?
                
-         // Store response data
-         if($bValid === true)
+               // Store response data
+               if($bValid)
                  return Array('user'     => $this->FHANDLER->get('username'),
                                     'password' => 
$this->FHANDLER->get('password'));
                else
@@ -121,12 +115,14 @@ class CoreModAuth extends CoreModule {
        }
        
        public function msgAlreadyLoggedIn() {
-               new GlobalMessage('NOTE', $this->CORE->getLang()->getText('You 
are already logged in. You will be redirected.'), null, null, 1, 
$this->CORE->getMainCfg()->getValue('paths', 'htmlbase'));
+               new GlobalMessage('NOTE', $this->CORE->getLang()->getText('You 
are already logged in. You will be redirected.'),
+                                 null, null, 1, 
$this->CORE->getMainCfg()->getValue('paths', 'htmlbase'));
                return '';
        }
        
        public function msgInvalidCredentials() {
-               new GlobalMessage('ERROR', $this->CORE->getLang()->getText('You 
entered invalid credentials.'), null, 
$this->CORE->getLang()->getText('Authentication failed'), 1, 
CoreRequestHandler::getReferer(''));
+               new GlobalMessage('ERROR', $this->CORE->getLang()->getText('You 
entered invalid credentials.'),
+                                 null, 
$this->CORE->getLang()->getText('Authentication failed'), 1, 
CoreRequestHandler::getReferer(''));
                return '';
        }
 }
diff --git a/share/server/core/classes/CoreModManageShapes.php 
b/share/server/core/classes/CoreModManageShapes.php
index 029cf87..abcc3ff 100644
--- a/share/server/core/classes/CoreModManageShapes.php
+++ b/share/server/core/classes/CoreModManageShapes.php
@@ -94,8 +94,9 @@ class CoreModManageShapes extends CoreModule {
        
        protected function handleResponseDelete() {
                $FHANDLER = new CoreRequestHandler($_POST);
-               $this->verifyValuesSet($FHANDLER,   Array('image'));
-               $this->verifyValuesMatch($FHANDLER, Array('image' => 
MATCH_PNG_GIF_JPG_FILE));
+               $attr = Array('image' => MATCH_PNG_GIF_JPG_FILE);
+               $this->verifyValuesSet($FHANDLER,   $attr);
+               $this->verifyValuesMatch($FHANDLER, $attr);
                
                if(!in_array($FHANDLER->get('image'), 
$this->CORE->getAvailableShapes()))
                        new GlobalMessage('ERROR', 
$this->CORE->getLang()->getText('The shape does not exist.'));
diff --git a/share/server/core/classes/CoreModule.php 
b/share/server/core/classes/CoreModule.php
index 1d63964..cf46db2 100644
--- a/share/server/core/classes/CoreModule.php
+++ b/share/server/core/classes/CoreModule.php
@@ -233,7 +233,7 @@ abstract class CoreModule {
         */
        protected function verifyValuesMatch($HANDLER, $list) {
                foreach($list AS $key => $pattern)
-                       if(!$HANDLER->match($key, $pattern))
+                       if($pattern && !$HANDLER->match($key, $pattern))
                                new GlobalMessage('ERROR', 
$this->CORE->getLang()->getText('The value of option "[ATTRIBUTE]" does not 
match the valid format.',
                                                                              
Array('ATTRIBUTE' => $key)));
                                


------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to