Index: Dev/trunk/classes/QuestionDatabaseInterface.php
===================================================================
--- Dev/trunk/classes/QuestionDatabaseInterface.php	(revision 82)
+++ Dev/trunk/classes/QuestionDatabaseInterface.php	(revision 82)
@@ -0,0 +1,7 @@
+<?php
+
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+?>
Index: Dev/trunk/classes/QuestionRDFReader.php
===================================================================
--- Dev/trunk/classes/QuestionRDFReader.php	(revision 82)
+++ Dev/trunk/classes/QuestionRDFReader.php	(revision 82)
@@ -0,0 +1,182 @@
+<?php
+
+class QuestionRDFReader
+{
+    protected $model;
+
+    protected $filePath;
+
+    public function __construct()
+    {
+        // Create empty MemModel
+        $factory = new ModelFactory();
+        $this->model = $factory->getDefaultModel();
+
+        $this->filePath = 'data/questions/';
+        if (!is_dir($this->filePath))
+            mkdir($this->filePath);	
+    }
+    
+    public function loadQuestions()
+    {
+        if(file_exists($this->filePath.'questions.rdf'))
+        {
+            $this->model->load($this->filePath.'questions.rdf');
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+    
+    public function readQuestionByID($questionID)
+    {        
+        $result = array();
+        $result['title'] = $this->readQuestionTitle($questionID);				
+        $result['description'] = $this->readQuestionDescription($questionID);
+        $result['type'] = $this->readQuestionType($questionID);
+        $result['code'] = $this->readQuestionCode($questionID);
+        $result['category'] = $this->readQuestionCategory($questionID);
+        $result['answers'] = $this->readQuestionAnswers($questionID);
+
+        return $result;
+    }
+    
+    public function readQuestionIDs()
+    {
+        $result = null;
+        
+        if(file_exists($this->filePath.'questions.rdf'))
+        {
+            // Create empty MemModel
+            $factory = new ModelFactory();
+            $tempmodel= $factory->getDefaultModel();
+            $tempmodel->load($this->filePath.'questions.rdf');
+
+            $querystring = '
+            PREFIX 	predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX	resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT 	?questionID
+            WHERE 
+            {	
+                    _question	predicates:resource_type	resources:question ;
+                                predicates:uid			?questionID				
+            }';
+            
+            $result = $tempmodel->sparqlQuery($querystring);
+        }
+        return $result; 
+    }
+
+    public function readQuestionTitle($questionID)
+    {
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT  ?questionTitle
+            WHERE 
+            {	
+                    _question	predicates:resource_type	resources:question ;
+                                predicates:uid			"' . $questionID . '"  ;
+                                predicates:title		?questionTitle 		
+            }';
+
+        $result = $this->model->sparqlQuery($querystring);
+
+        return $result;
+    }
+
+    public function readQuestionDescription($questionID)
+    {
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT  ?questionDescription
+            WHERE 
+            {	
+                    _question	predicates:resource_type	resources:question ;
+                                predicates:uid			"' . $questionID . '"  ;
+                                predicates:description		?questionDescription 		
+            }';
+
+        $result = $this->model->sparqlQuery($querystring);
+
+        return $result;
+    }
+
+    public function readQuestionType($questionID)
+    {
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT  ?questionType
+            WHERE 
+            {	
+                    _question	predicates:resource_type	resources:question ;
+                                predicates:uid			"' . $questionID . '"  ;
+                                predicates:question_type	?questionType				
+            }';
+
+        $result = $this->model->sparqlQuery($querystring);
+
+        return $result;
+    }
+    
+    public function readQuestionCode($questionID)
+    {
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT  ?questionCode
+            WHERE 
+            {	
+                    _question	predicates:resource_type	resources:question ;
+                                predicates:uid			"' . $questionID . '"  ;
+                                predicates:question_code	?questionCode				
+            }';
+
+        $result = $this->model->sparqlQuery($querystring);
+
+        return $result;
+    }
+    
+    public function readQuestionCategory($questionID)
+    {
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT  ?questionCategory
+            WHERE 
+            {	
+                    _question	predicates:resource_type	resources:question ;
+                                predicates:uid			"' . $questionID . '"  ;
+                                predicates:question_category	?questionCategory				
+            }';
+
+        $result = $this->model->sparqlQuery($querystring);
+
+        return $result;
+    }
+
+    public function readQuestionAnswers($questionID)
+    {
+        $querystring = '
+            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
+            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
+            SELECT  ?answerDescription
+            WHERE 
+            {
+                    _question	predicates:resource_type	resources:question ;
+                                predicates:uid			"' . $questionID . '"  ;
+                                predicates:has_answer		_answer .
+                    _answer	predicates:description		?answerDescription
+            }';
+
+        $result = $this->model->sparqlQuery($querystring);
+
+        return $result;
+    }
+}
+
+?>
Index: Dev/trunk/classes/QuestionRDFWriter.php
===================================================================
--- Dev/trunk/classes/QuestionRDFWriter.php	(revision 82)
+++ Dev/trunk/classes/QuestionRDFWriter.php	(revision 82)
@@ -0,0 +1,82 @@
+<?php
+class QuestionRDFWriter 
+{
+    protected $model;
+
+    protected $filePath = 'data/questions/';
+
+    public function __construct()
+    {
+        // Create empty MemModel
+        $factory = new ModelFactory();
+        $this->model = $factory->getDefaultModel();
+
+        if (!is_dir($this->filePath))
+            mkdir($this->filePath);
+        
+        if(file_exists($this->filePath.'questions.rdf'))
+            $this->model->load($this->filePath.'questions.rdf');
+    }	
+
+    public function saveQuestions()
+    {	
+        $this->model->saveAs($this->filePath.'questions.rdf','rdf');
+    }
+    
+    public function createQuestion($qTitle,$qDescription,$qType,$qID,$qCode,$qCategory,$qAnswers)
+    {
+        $resourceQuestion = new Resource(QUESTION.'/'.$qID);
+
+        $resourceQuestionType = new Resource(QUESTION);
+        $predicateRType = new Resource(RTYPE);
+        $this->model->add(new Statement($resourceQuestion,$predicateRType,$resourceQuestionType));
+
+        $predicateTitle = new Resource(TITLE);		
+        $questionTitle = new Literal($qTitle);
+        $this->model->add(new Statement($resourceQuestion,$predicateTitle,$questionTitle));	
+
+        $predicateDescription = new Resource(DESCRIPTION);
+        $questionDescription = new Literal($qDescription);
+        $this->model->add(new Statement($resourceQuestion,$predicateDescription,$questionDescription));		
+
+        $predicateQType = new Resource(QTYPE);
+        $resourceQuestionType = new Literal($qType);
+        $this->model->add(new Statement($resourceQuestion,$predicateQType,$resourceQuestionType));
+
+        $predicateUniqueID = new Resource(UID);
+        $questionUID = new Literal($qID);
+        $this->model->add(new Statement($resourceQuestion,$predicateUniqueID,$questionUID));
+        
+        $predicateQCode = new Resource(QCODE);
+        $questionQCode = new Literal($qCode);
+        $this->model->add(new Statement($resourceQuestion,$predicateQCode,$questionQCode));
+        
+        $predicateQCategory = new Resource(QCATEGORY);
+        $questionQCategory = new Literal($qCategory);
+        $this->model->add(new Statement($resourceQuestion,$predicateQCategory,$questionQCategory));
+
+        foreach($qAnswers as $answer)
+        {		
+            $answerID = md5( uniqid(rand(), true) );	
+            $resourceAnswer = new Resource(ANSWER.'/'.$answerID);
+
+            $resourceAnswerType = new Resource(ANSWER);
+            $predicateRType = new Resource(RTYPE);
+            $this->model->add(new Statement($resourceAnswer,$predicateRType,$resourceAnswerType));	
+
+            $predicateUniqueID = new Resource(UID);
+            $answerUID = new Literal($answerID);
+            $this->model->add(new Statement($resourceAnswer,$predicateUniqueID,$answerUID));			
+
+            $answerTitle = new Literal($answer['Title']);
+            $this->model->add(new Statement($resourceAnswer,$predicateTitle,$answerTitle));
+
+            $answerDescription = new Literal($answer['Description']);
+            $this->model->add(new Statement($resourceAnswer,$predicateDescription,$answerDescription));
+
+            $predicateAnswer = new Resource(HAS_ANSWER);	
+            $this->model->add(new Statement($resourceQuestion,$predicateAnswer,$resourceAnswer));
+        }	
+    }
+}
+?>
Index: Dev/trunk/classes/SurveyCreationDatabaseInterface.php
===================================================================
--- Dev/trunk/classes/SurveyCreationDatabaseInterface.php	(revision 82)
+++ Dev/trunk/classes/SurveyCreationDatabaseInterface.php	(revision 82)
@@ -0,0 +1,179 @@
+<?php
+// Survey database interface class as intermediate for storing data from the site to the RDF database 
+require_once 'rdfConstants.php';
+
+// Include RAP Library to write RDF files
+include(RDFAPI_INCLUDE_DIR . "RDFAPI.php");
+
+
+
+class SurveyDatabaseInterface
+{		
+    protected $surveyRDFWriter;
+    protected $surveyRDFReader;
+    protected $questionRDFWriter;
+    protected $questionRDFReader;
+
+    public function __construct($surveyID)
+    {
+        if($surveyID == null)
+            $surveyUID = md5( uniqid(rand(), true) );
+        else
+            $surveyUID = $surveyID;
+
+        $this->surveyRDFWriter = new SurveyRDFWriter($surveyUID);
+        $this->surveyRDFReader = new SurveyRDFReader($surveyUID);
+        $this->questionRDFWriter = new QuestionRDFWriter();
+        $this->questionRDFReader = new QuestionRDFReader();
+    }
+
+    public function setSurveyInfo($survey,$user)
+    {
+        $sTitle = $survey['surveyTitle'];
+        $sDescription = $survey['surveyDescription'];
+
+        $this->surveyRDFWriter->createSurvey($sTitle,$sDescription);
+
+        $sUserID = $user['username'];
+
+        $this->surveyRDFWriter->setUserData($sUserID);
+
+        $qNumber = 1;
+        while (isset($survey['questionTitle'.$qNumber]))
+        {
+            $qTitle = $survey['questionTitle'.$qNumber];
+            $qDescription = $survey['questionDescription'.$qNumber];
+            $qType = $survey['questionType'.$qNumber];
+            if (isset($survey['questionID'.$qNumber]))
+                $qID = $survey['questionID'.$qNumber];
+            else
+                $qID = md5( uniqid(rand(), true) );
+
+            $qAnswers = array();
+            $aNumber = 1;
+            while (isset($survey['q'.$qNumber.'ans'.$aNumber]))
+            {
+                $aArray = array();
+                $aArray['Title'] = 'q'.$qNumber.'ans'.$aNumber;
+                $aArray['Description'] = $survey['q'.$qNumber.'ans'.$aNumber];
+                $qAnswers[] = $aArray;
+
+                $aNumber++;
+            }
+
+            if(!$this->checkQuestionIDExists($qID))
+            {
+                $this->questionRDFWriter->createQuestion($qTitle,$qDescription,$qType,$qID,"null","null",$qAnswers);
+            }            
+            $this->surveyRDFWriter->addQuestion($qID);
+
+            $qNumber++;
+        }
+
+        $this->surveyRDFWriter->saveSurvey();
+        $this->questionRDFWriter->saveQuestions();
+    }
+
+    public function getSurveyInfo()
+    {
+        $surveyInfo = array();
+
+        $this->questionRDFReader->loadQuestions();
+        
+        $resultSurvey = $this->surveyRDFReader->getSurveyInfo();
+        
+        $surveyInfo['surveyID'] = $resultSurvey['info'][0]['?uid']->label;
+        $surveyInfo['surveyTitle'] = $resultSurvey['info'][0]['?title']->label;
+        $surveyInfo['surveyDescription'] = $resultSurvey['info'][0]['?description']->label;
+        $surveyInfo['surveyCreator'] = $resultSurvey['info'][0]['?creator']->label;
+        $surveyQuestionIDs = $resultSurvey['questionIDs'];
+        
+        if($surveyQuestionIDs != false)
+        {
+            $qNumber = 1;
+            foreach($surveyQuestionIDs as $qID)
+            {
+                $questionID = $qID['?questionID']->label;
+                $surveyInfo['questionID'.$qNumber] = $questionID;
+
+                $questionTitleObject = $this->questionRDFReader->readQuestionTitle($questionID);
+                $surveyInfo['questionTitle'.$qNumber] = $questionTitleObject[0]['?questionTitle']->label;
+
+                $questionDescriptionObject = $this->questionRDFReader->readQuestionDescription($questionID);
+                $surveyInfo['questionDescription'.$qNumber] = $questionDescriptionObject[0]['?questionDescription']->label;
+
+                $questionTypeObject = $this->questionRDFReader->readQuestionType($questionID);
+                $surveyInfo['questionType'.$qNumber] = $questionTypeObject[0]['?questionType']->label;
+
+                $resultAnswers = $this->questionRDFReader->readQuestionAnswers($questionID);
+
+                if ($resultAnswers != null)
+                {
+                    for($aNumber = 1;$aNumber<=sizeof($resultAnswers);$aNumber++)
+                    {
+                        $surveyInfo['q'.$qNumber.'ans'.$aNumber] = $resultAnswers[$aNumber-1]['?answerDescription']->label;
+                    }
+                }
+                $resultAnswers = null;
+                $qNumber++;
+            }
+        }
+        
+        return $surveyInfo;
+    }
+
+    public function getExistingSurveys()
+    {
+        $surveyIDs = array();
+        $surveys = array();
+
+        if($handle = opendir('data/surveys/'))
+        {
+            while (false !== ($file = readdir($handle))) {
+                if(strstr($file, 'survey_') && strstr($file, '.rdf'))
+                    $surveyIDs[] = substr($file,7,strlen($file)-11);
+            }
+        }
+        
+        foreach($surveyIDs as $surveyID)
+        {
+            $surveyTitle = $this->surveyRDFReader->getSurveyTitleByID($surveyID);
+            $surveys[$surveyID] = $surveyTitle[0]['?title']->label;
+        }
+
+        return $surveys;
+    }
+    
+    public function getSurveyTitleByID($surveyID)
+    {
+        $surveyTitleLiteral = $this->surveyRDFReader->getSurveyTitleByID($surveyID);
+        $surveyTitle = $surveyTitle[0]['?title']->label;
+        
+        return $surveyTitle;
+    }
+
+    
+    
+    public function checkQuestionIDExists($qID)
+    {
+        $result = false;
+
+        $questionIDs = $this->questionRDFReader->readQuestionIDs();
+        
+        if ($questionIDs != null)
+        {
+            foreach($questionIDs as $questionID)
+            {
+                $id = $questionID['?questionID']->label;
+                if(!strcmp($id ,$qID))
+                {
+                    $result = true;
+                    break;
+                }
+            }
+        }
+
+        return $result;
+    }
+}
+?>
Index: Dev/trunk/classes/SurveyRDFReader.php
===================================================================
--- Dev/trunk/classes/SurveyRDFReader.php	(revision 80)
+++ Dev/trunk/classes/SurveyRDFReader.php	(revision 82)
@@ -25,9 +25,9 @@
     public function getSurveyInfo()
     {		
-        SurveyRDFReader::loadSurvey();
+        $this->loadSurvey();
 
         $result = array();
-        $result[] = $this->readSurveyInfo();				
-        $result[] = $this->readSurveyQuestions();
+        $result['info'] = $this->readSurveyInfo();				
+        $result['questionIDs'] = $this->readSurveyQuestionIDs();
 
         return $result;
@@ -53,68 +53,6 @@
         return $result;
     }
-
-    public function readSurveyQuestions()
-    {
-        $result = array();
-        $result[] = $this->readSurveyQuestionsTitle();				
-        $result[] = $this->readSurveyQuestionsDescription();
-        $result[] = $this->readSurveyQuestionsType();
-        $result[] = $this->readSurveyQuestionsID();		
-
-        return $result;
-    }
-
-    public function readSurveyQuestionsTitle()
-    {
-        $querystring = '
-            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-            SELECT  ?questionTitle
-            WHERE 
-            {	
-                    _question	predicates:resource_type	resources:question ;
-                                predicates:title		?questionTitle 		
-            }';
-
-        $result = $this->model->sparqlQuery($querystring);
-
-        return $result;
-    }
-
-    public function readSurveyQuestionsDescription()
-    {
-        $querystring = '
-            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-            SELECT  ?questionDescription
-            WHERE 
-            {	
-                    _question	predicates:resource_type	resources:question ;
-                                predicates:description		?questionDescription 		
-            }';
-
-        $result = $this->model->sparqlQuery($querystring);
-
-        return $result;
-    }
-
-    public function readSurveyQuestionsType()
-    {
-        $querystring = '
-            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-            SELECT  ?questionType
-            WHERE 
-            {	
-                    _question	predicates:resource_type	resources:question ;
-                                predicates:question_type	?questionType				
-            }';
-
-        $result = $this->model->sparqlQuery($querystring);
-
-        return $result;
-    }
-
-    public function readSurveyQuestionsID()
+    
+    public function readSurveyQuestionIDs()
     {
         $querystring = '
@@ -124,25 +62,6 @@
             WHERE 
             {	
-                    _question	predicates:resource_type	resources:question ;
-                                predicates:uid			?questionID				
-            }';
-
-        $result = $this->model->sparqlQuery($querystring);
-
-        return $result;
-    }
-
-    public function readSurveyAnswers($questionID)
-    {
-        $querystring = '
-            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
-            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
-            SELECT  ?answerDescription
-            WHERE 
-            {
-                    _question	predicates:resource_type	resources:question ;
-                                predicates:uid			"' . $questionID . '"  ;
-                                predicates:has_answer		_answer .
-                    _answer	predicates:description		?answerDescription
+                    _survey	predicates:resource_type	resources:survey ;
+                                predicates:has_question		?questionID				
             }';
 
Index: Dev/trunk/classes/SurveyRDFWriter.php
===================================================================
--- Dev/trunk/classes/SurveyRDFWriter.php	(revision 80)
+++ Dev/trunk/classes/SurveyRDFWriter.php	(revision 82)
@@ -48,63 +48,18 @@
     }
 
-    public function setUserData($userID)
+    public function setUserData($uID)
     {				
-        $resourceUser = new Resource(USER . '/' . $userID);
+        $userID = new Literal($uID);
 
         $predicateCreator = new Resource(CREATOR);
-        $this->model->add(new Statement($this->resourceSurvey,$predicateCreator,$resourceUser));
+        $this->model->add(new Statement($this->resourceSurvey,$predicateCreator,$userID));
     }
 
-    public function addQuestion($qTitle,$qDescription,$qType,$qID,$qAnswers)
-    {
-        $questionID = $qID;
-        $resourceQuestion = new Resource(QUESTION.'/'.$questionID);
-
-        $resourceQuestionType = new Resource(QUESTION);
-        $predicateRType = new Resource(RTYPE);
-        $this->model->add(new Statement($resourceQuestion,$predicateRType,$resourceQuestionType));
-
-        $predicateUniqueID = new Resource(UID);
-        $questionUID = new Literal($questionID);
-        $this->model->add(new Statement($resourceQuestion,$predicateUniqueID,$questionUID));
-
-        $predicateTitle = new Resource(TITLE);		
-        $questionTitle = new Literal($qTitle);
-        $this->model->add(new Statement($resourceQuestion,$predicateTitle,$questionTitle));	
-
-        $predicateDescription = new Resource(DESCRIPTION);
-        $questionDescription = new Literal($qDescription);
-        $this->model->add(new Statement($resourceQuestion,$predicateDescription,$questionDescription));		
-
-        $predicateQType = new Resource(QTYPE);
-        $resourceQuestionType = new Literal($qType);
-        $this->model->add(new Statement($resourceQuestion,$predicateQType,$resourceQuestionType));
-
-            foreach($qAnswers as $answer)
-            {		
-                $answerID = md5( uniqid(rand(), true) );	
-                $resourceAnswer = new Resource(ANSWER.'/'.$answerID);
-
-                $resourceAnswerType = new Resource(ANSWER);
-                $predicateRType = new Resource(RTYPE);
-                $this->model->add(new Statement($resourceAnswer,$predicateRType,$resourceAnswerType));	
-
-                $predicateUniqueID = new Resource(UID);
-                $answerUID = new Literal($answerID);
-                $this->model->add(new Statement($resourceAnswer,$predicateUniqueID,$answerUID));			
-
-                $answerTitle = new Literal($answer['Title']);
-                $this->model->add(new Statement($resourceAnswer,$predicateTitle,$answerTitle));
-
-                $answerDescription = new Literal($answer['Description']);
-                $this->model->add(new Statement($resourceAnswer,$predicateDescription,$answerDescription));
-
-                $predicateAnswer = new Resource(HAS_ANSWER);	
-                $this->model->add(new Statement($resourceQuestion,$predicateAnswer,$resourceAnswer));
-            }
-
-            $predicateQuestion = new Resource(HAS_QUESTION);
-            $this->model->add(new Statement($this->resourceSurvey,$predicateQuestion,$resourceQuestion));		
-        }
+    public function addQuestion($qID)
+    {		
+        $questionID = new Literal($qID);
+        $predicateQuestion = new Resource(HAS_QUESTION);
+        $this->model->add(new Statement($this->resourceSurvey,$predicateQuestion,$questionID));
+    }
 }
 
Index: Dev/trunk/classes/UserDatabaseInterface.php
===================================================================
--- Dev/trunk/classes/UserDatabaseInterface.php	(revision 80)
+++ Dev/trunk/classes/UserDatabaseInterface.php	(revision 82)
@@ -25,6 +25,9 @@
         $userPassword = $this->RIJNDAEL_encrypt($userInfo['password']);
 
-        $this->userRDFWriter->addNewUser($userName, $userPassword);
-        $this->userRDFWriter->saveUsers();
+        if($this->checkUserName($userName))
+        {
+            $this->userRDFWriter->addNewUser($userName, $userPassword);
+            $this->userRDFWriter->saveUsers();            
+        }
     }
 
@@ -39,5 +42,5 @@
             foreach($resultUser as $user)
             {
-            $name = substr($user['?name'],9,strlen($user['?name'])-11);
+            $name = $user['?name']->label;
                 if(!strcmp($name ,$userName))
                 {
@@ -58,5 +61,5 @@
 
         $encryptedPasswordLiteral = $this->userRDFReader->getUserPassword($userName);
-        $encryptedPassword = substr($encryptedPasswordLiteral[0]['?password'],9,strlen($encryptedPasswordLiteral[0]['?password'])-11);
+        $encryptedPassword = $encryptedPasswordLiteral[0]['?password']->label;
 
         if(!strcmp($this->RIJNDAEL_encrypt($userPassword),$encryptedPassword))
